:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --line: #d9e0e4;
  --text: #172126;
  --muted: #5e6b72;
  --accent: #126d62;
  --accent-strong: #0c574f;
  --danger: #aa2d2d;
  --danger-strong: #8d2222;
  --soft: #e8f2f0;
  --mine: #dff0eb;
  --theirs: #ffffff;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.home-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.home-panel {
  width: min(720px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(22px, 5vw, 44px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(30px, 6vw, 46px);
  line-height: 1.1;
}

h2 {
  margin-bottom: 10px;
  font-size: 22px;
}

.lead {
  max-width: 58ch;
  margin-bottom: 24px;
  color: var(--muted);
  line-height: 1.7;
}

.hint,
.status-line,
.read-line,
.system-message,
.image-name {
  color: var(--muted);
  font-size: 13px;
}

.primary-action,
.secondary-action,
.danger-action,
.primary-link,
.icon-action {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.primary-action,
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.primary-action:hover,
.primary-link:hover {
  background: var(--accent-strong);
}

.secondary-action {
  min-height: 40px;
  padding: 0 14px;
  background: #edf3f4;
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary-action:hover {
  border-color: #b7c5ca;
}

.danger-action {
  min-height: 40px;
  padding: 0 14px;
  background: var(--danger);
  color: #ffffff;
}

.danger-action:hover {
  background: var(--danger-strong);
}

.primary-action:disabled,
.secondary-action:disabled,
.danger-action:disabled,
.icon-action:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.result-panel {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.field {
  display: grid;
  gap: 8px;
  margin: 16px 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.field input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
}

.primary-link {
  margin-top: 18px;
}

.chat-shell {
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  overflow: hidden;
  padding: 16px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chat-header h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 5vw, 34px);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.messages {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0;
}

.message {
  max-width: min(720px, 88%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--theirs);
  overflow-wrap: anywhere;
}

.message.mine {
  align-self: flex-end;
  background: var(--mine);
}

.message.theirs {
  align-self: flex-start;
}

.message-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.message-text {
  white-space: pre-wrap;
  line-height: 1.55;
}

.message img {
  display: block;
  max-width: min(420px, 100%);
  max-height: 52vh;
  margin-top: 8px;
  border-radius: 8px;
  object-fit: contain;
}

.read-line {
  margin-top: 7px;
}

.system-message {
  align-self: center;
  max-width: min(620px, 94%);
  padding: 6px 10px;
  border-radius: 999px;
  background: #e9eef0;
  text-align: center;
}

.composer {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.composer textarea {
  width: 100%;
  min-height: 58px;
  max-height: 180px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-action {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: #edf3f4;
  border: 1px solid var(--line);
  color: var(--text);
}

.file-action input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.send-action {
  min-width: 86px;
}

.emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.emoji-row button {
  width: 38px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.closed-panel {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  background: rgba(245, 247, 248, 0.96);
  text-align: center;
}

.closed-panel[hidden],
[hidden] {
  display: none !important;
}

@media (max-width: 680px) {
  .chat-shell {
    padding: 12px;
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .header-actions button,
  .primary-action,
  .primary-link {
    width: 100%;
  }

  .message {
    max-width: 94%;
  }
}
