:root {
  color-scheme: light dark;
  --bg: #f4f7f9;
  --card: #ffffff;
  --text: #102833;
  --muted: #526b78;
  --line: #d8e3e8;
  --accent: #087e65;
  --accent-ink: #ffffff;
  --tint: #e1f3ec;
  --danger: #a32e3d;
  --focus: #327dac;
}

* { box-sizing: border-box; }
[hidden], [data-locked] [data-sensitive] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
main { width: 100%; max-width: 980px; margin: auto; padding: 30px 28px 64px; }
.app-header { display: flex; align-items: center; gap: 14px; margin-bottom: 40px; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { min-height: 46px; padding: 12px 18px; border: 1px solid transparent; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 650; cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button:enabled:hover { filter: brightness(.95); }
button:focus-visible, a:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
a { color: var(--accent); }
button.brand { min-height: 48px; padding: 0; border: 0; background: transparent; color: var(--text); font-size: 19px; font-weight: 850; letter-spacing: .18em; }
.test-badge { padding: 3px 8px; border: 1px solid var(--line); border-radius: 20px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.browser-menu { position: relative; margin-left: auto; }
button.menu-toggle { display: grid; place-items: center; width: 48px; height: 48px; padding: 12px; background: transparent; color: var(--text); border-color: var(--line); }
.menu-icon, .menu-icon::before, .menu-icon::after { display: block; width: 21px; height: 2px; background: currentColor; border-radius: 2px; }
.menu-icon { position: relative; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
.menu-icon::before { top: -7px; }
.menu-icon::after { top: 7px; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 3; display: grid; width: min(270px, calc(100vw - 32px)); gap: 4px; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 30px #07172018; }
.menu-panel a, .menu-panel button { display: block; width: 100%; min-height: 48px; margin: 0; padding: 12px 14px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; text-decoration: none; font: 500 15px/1.55 system-ui, sans-serif; }
.menu-panel a:hover, .menu-panel button:enabled:hover { background: var(--bg); }
h1 { margin: 8px 0 14px; font-size: clamp(28px, 5vw, 38px); line-height: 1.18; letter-spacing: -.035em; overflow-wrap: anywhere; }
h2 { margin: 0 0 16px; font-size: 19px; line-height: 1.35; letter-spacing: -.015em; }
h3 { margin: 0 0 14px; font-size: 16px; }
p { margin: 0 0 18px; }
.muted, .caption, .account { color: var(--muted); }
.caption { font-size: 13px; }
.account { margin-bottom: 24px; font-size: 13px; overflow-wrap: anywhere; }
.eyebrow { margin: 0; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.card { padding: 26px; background: var(--card); border: 1px solid var(--line); border-radius: 21px; }
.narrow { max-width: 540px; margin: 52px auto 0; }
.card > :last-child { margin-bottom: 0; }
label { display: block; margin: 18px 0 7px; font-size: 14px; font-weight: 600; }
input { display: block; width: 100%; min-width: 0; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); color: var(--text); font-size: 16px; }
input::placeholder { color: var(--muted); opacity: .8; }
#private-root textarea { display:block; width:100%; min-height:90px; resize:vertical; padding:12px; margin-bottom:16px; border:1px solid var(--line); border-radius:11px; background:var(--card); color:var(--text); font:inherit; }
#private-root #answer, #private-root #review-text { white-space:pre-wrap; overflow-wrap:anywhere; margin-top:18px; }
#private-root #status { margin-top:18px; }
#private-root button { margin:4px 4px 4px 0; }
input + .caption { margin: 9px 0 0; }
form > button { margin-top: 22px; }
.quiet { border-color: var(--line); background: var(--card); color: var(--text); }
.text-button { padding: 10px 0; border: 0; background: transparent; color: var(--accent); text-align: left; }
.back-link { margin: -12px 0 18px; }
#dismiss-invite { margin-top: 12px; }
.page-heading { margin-bottom: 34px; }
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, .85fr); align-items: start; gap: 32px; }
.room-list { display: grid; gap: 12px; }
.room-link { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 76px; padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; color: var(--text); font-weight: 650; text-decoration: none; overflow-wrap: anywhere; }
.room-link::after { content: "→"; color: var(--accent); font-weight: 400; }
.room-link:hover { border-color: var(--accent); }
.empty-state { padding: 34px 22px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }
.room-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 22px; margin-bottom: 26px; }
.room-heading > div { min-width: 0; }
.room-heading h1 { margin-bottom: 10px; }
.room-heading p:last-child { margin-bottom: 0; }
.room-heading > button { flex-shrink: 0; margin-top: 20px; }
.tabs { display: flex; gap: 5px; margin-bottom: 28px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.tabs button { flex: 1; min-width: 0; padding: 12px 8px; background: transparent; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--tint); color: var(--accent); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 16px; }
.section-head h2 { margin: 0; }
.messages, .plain-list { margin: 0; padding: 0; list-style: none; }
.message { padding: 22px 24px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.message-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 12px; }
.message-author { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.message time { color: var(--muted); }
.message-text { margin: 12px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistance-note { margin: 24px 0 0; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.person { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.person > div { min-width: 0; overflow-wrap: anywhere; }
.person strong { display: block; font-size: 15px; }
.person small { display: block; color: var(--muted); font-size: 12px; }
.person button { flex-shrink: 0; }
.invite-form { max-width: 480px; margin-top: 28px; }
.invite-output { margin-top: 24px; padding: 18px 20px; background: var(--tint); border: 1px solid var(--line); border-radius: 14px; }
.invite-output label { margin-top: 0; }
.invite-output .caption { margin: 10px 0 0; }
#invite-link { font-size: 16px; }
.invitations-section { margin-top: 28px; }
.conversation-actions { margin-top: 26px; }
.danger { color: var(--danger); }
.danger-solid { background: var(--danger); color: var(--card); }
.notice, .error { padding: 12px 16px; border-radius: 12px; font-size: 14px; }
.notice { color: var(--accent); background: var(--tint); }
.error { color: var(--danger); border: 1px solid var(--line); }
.notice:empty, .error:empty { display: none; }
dialog { width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 28px; overflow: auto; border: 1px solid var(--line); border-radius: 20px; background: var(--card); color: var(--text); }
dialog::backdrop { background: #07172099; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 24px; }

@media (max-width: 660px) {
  main { padding: 22px 16px 40px; }
  .app-header { margin-bottom: 28px; }
  .narrow { margin-top: 28px; }
  .card { padding: 22px; }
  .lobby-grid { grid-template-columns: 1fr; gap: 28px; }
  .message { padding: 18px; }
  .room-heading { gap: 14px; }
  .person { flex-wrap: wrap; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #071720;
    --card: #0e232e;
    --text: #edf5f8;
    --muted: #a8bdc9;
    --line: #2a4553;
    --accent: #20c697;
    --accent-ink: #071b16;
    --tint: #10392e;
    --danger: #ffa6b2;
    --focus: #69b5ed;
  }
}

@media (prefers-reduced-motion: no-preference) {
  button, .room-link { transition: background-color .12s ease, border-color .12s ease; }
}
