:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #182234;
  --muted: #697586;
  --line: #e5e9ef;
  --primary: #263a5b;
  --primary-2: #34527d;
  --green: #279568;
  --red: #b42318;
  --shadow: 0 14px 40px rgba(24, 34, 52, .08);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(100%, 760px); min-height: 100dvh; margin: 0 auto; background: var(--panel); box-shadow: var(--shadow); }
.hidden { display: none !important; }
.setup-view { width: min(100%, 520px); margin: 0 auto; padding: 46px 24px 30px; }
.brand-mark { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: white; background: var(--primary); font-size: 24px; font-weight: 700; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 20px; flex: 0 0 auto; }
.eyebrow { margin: 24px 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .13em; }
h1, h2, h3, p { margin-top: 0; }
.setup-view h1 { margin-bottom: 10px; font-size: 30px; letter-spacing: -.04em; }
.intro { color: var(--muted); line-height: 1.65; margin-bottom: 28px; }
.setup-card { padding: 20px; margin: 14px 0; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.setup-card h2 { margin-bottom: 7px; font-size: 17px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.6; }
.primary-btn, .secondary-btn, .danger-btn { border: 0; border-radius: 11px; min-height: 46px; padding: 11px 16px; font-weight: 650; }
.primary-btn { background: var(--primary); color: #fff; }
.primary-btn:active { background: var(--primary-2); }
.secondary-btn { background: #edf1f6; color: var(--primary); }
.danger-btn { color: #fff; background: var(--red); }
.full-btn { width: 100%; }
.invite-input, .invite-output, .text-input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--ink); background: #fbfcfe; outline: none; }
.invite-input { resize: vertical; margin: 4px 0 12px; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.invite-output { margin: 6px 0 12px; min-height: 90px; resize: none; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.error-text { min-height: 20px; color: var(--red); font-size: 13px; }
.footnote { margin-top: 28px; color: #8791a0; font-size: 11px; line-height: 1.6; }
.chat-view { height: 100dvh; min-height: 520px; display: flex; flex-direction: column; }
.chat-header { height: 74px; padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.header-title-wrap { display: flex; align-items: center; gap: 12px; }
.chat-header h1 { margin: 0 0 3px; font-size: 16px; }
.connection-line { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #d69b36; }
.status-dot.online { background: var(--green); }
.status-dot.offline { background: #c24f4f; }
.header-actions { display: flex; gap: 8px; }
.icon-btn { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--primary); font-size: 22px; }
.notice-strip { padding: 9px 16px; text-align: center; color: #45634f; background: #f0f7f2; font-size: 11px; flex: 0 0 auto; }
.chat-error { padding: 9px 14px; color: #8e241c; background: #fff2f0; font-size: 12px; line-height: 1.5; }
.history-toolbar { min-height: 35px; padding: 5px 16px 0; display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; }
.text-btn { border: 0; padding: 5px 0; background: transparent; color: var(--primary-2); font-size: 12px; }
.tiny { font-size: 11px; }
.message-list { padding: 12px 16px 18px; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; background: #fafbfd; }
.empty-state { max-width: 280px; margin: 70px auto 0; color: #8a94a3; text-align: center; font-size: 13px; line-height: 1.7; }
.message-row { display: flex; flex-direction: column; align-items: flex-start; margin: 10px 0; }
.message-row.mine { align-items: flex-end; }
.message-meta { margin: 0 4px 4px; color: #8b95a3; font-size: 10px; }
.message-bubble { max-width: min(82%, 520px); padding: 10px 13px; border: 1px solid #e7ebf1; border-radius: 4px 15px 15px 15px; background: #fff; box-shadow: 0 2px 7px rgba(24,34,52,.03); line-height: 1.55; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mine .message-bubble { border-color: #dce6f3; border-radius: 15px 4px 15px 15px; background: #eaf1fa; }
.composer { padding: 12px 12px 6px; display: flex; align-items: flex-end; gap: 9px; border-top: 1px solid var(--line); background: #fff; flex: 0 0 auto; }
.composer textarea { min-height: 44px; max-height: 140px; flex: 1; resize: none; padding: 11px 12px; border: 1px solid var(--line); border-radius: 13px; outline: none; background: #f8fafc; line-height: 1.4; font-size: 14px; }
.composer textarea:focus, .text-input:focus, .invite-input:focus { border-color: #8ca3c4; }
.send-btn { min-width: 62px; height: 44px; border: 0; border-radius: 12px; color: #fff; background: var(--primary); font-weight: 650; }
.send-btn:disabled { opacity: .55; cursor: wait; }
.composer-foot { padding: 0 16px 10px; display: flex; justify-content: space-between; color: #9aa3af; font-size: 10px; background: #fff; flex: 0 0 auto; }
.modal { width: min(calc(100% - 32px), 440px); border: 0; border-radius: 20px; padding: 22px; color: var(--ink); box-shadow: 0 20px 80px rgba(0,0,0,.22); }
.modal::backdrop { background: rgba(15,23,42,.45); }
.modal h2 { margin-bottom: 8px; font-size: 20px; }
.modal-close-row { display: flex; justify-content: flex-end; margin: -10px -8px 4px 0; }
.close-btn { width: 32px; height: 32px; border: 0; border-radius: 50%; background: #f0f2f5; color: #586273; font-size: 22px; line-height: 1; }
.field-label { display: block; margin: 16px 0 6px; color: var(--muted); font-size: 12px; }
.text-input { height: 44px; margin-bottom: 12px; }
.notification-setting { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.notification-setting h3 { margin-bottom: 6px; font-size: 15px; }
.danger-zone { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.danger-zone h3 { margin-bottom: 6px; font-size: 15px; }
@media (min-width: 700px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100dvh - 48px); border-radius: 22px; overflow: hidden; }
  .chat-view { height: calc(100dvh - 48px); }
}
