:root {
  color-scheme: light dark;
  --ink: light-dark(#252b3d,#edf0fa);
  --muted: light-dark(#546174,#adbad1);
  --line: light-dark(#cbd3e4,#3a4359);
  --accent: light-dark(#383d82,#bec7ff);
  --on-accent: light-dark(#fff,#171e40);
  --surface: light-dark(#f7f9fe,#222a3c);
  --stage: light-dark(#edf0fa,#161d2b);
  --selected: light-dark(#d5dcef,#313d59);
  --outgoing: light-dark(#dbe3f6,#36446b);
  font-family: -apple-system,BlinkMacSystemFont,"PingFang SC","Segoe UI",sans-serif;
  color: var(--ink);
  background: var(--stage);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main { display: flex; flex-direction: column; gap: 9px; min-height: 0; height: 100dvh; max-width: 760px; margin: auto; padding: max(10px,env(safe-area-inset-top)) 10px max(8px,env(safe-area-inset-bottom)); }
header,#compose,nav { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
header h1 { font-size: 17px; margin: 0; min-width: 0; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
h2 { font-size: 19px; margin-top: 0; }
button,select,textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; min-width: 0; }
button { cursor: pointer; }
button[aria-pressed=true] { background: var(--selected); }
button:focus-visible,select:focus-visible,textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:disabled { opacity: .55; }
.primary { background: var(--accent); color: var(--on-accent); flex-shrink: 0; }
#notice { margin: 0; padding: 8px 10px; border-radius: 9px; background: light-dark(#f8e7e2,#493230); color: light-dark(#8b362d,#ffccc2); font-size: 14px; }
#pair { width: min(100%,450px); padding: 18px; margin: auto; border-radius: 15px; background: var(--surface); border: 1px solid var(--line); }
#pair textarea { display: block; width: 100%; margin: 12px 0; }
#pair label { line-height: 1.55; color: var(--muted); }
#navigation,#chat { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: 8px; }
#rooms,#receipts,#messages { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
nav button { flex: 1; }
.room-row { display: flex; align-items: center; width: 100%; margin-bottom: 5px; text-align: left; gap: 10px; border-color: transparent; }
.avatar { background: var(--selected); color: var(--accent); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px; }
.room-text { min-width: 0; }
.room-text small,.room-text strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
small { color: var(--muted); font-size: 12px; }
.bubble { margin: 8px 12% 8px 1px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; }
.bubble.mine { margin: 8px 1px 8px 12%; border-radius: 12px 4px 12px 12px; background: var(--outgoing); }
.bubble p { white-space: pre-wrap; overflow-wrap: anywhere; margin: 5px 0 0; line-height: 1.45; }
.bubble:focus { outline: 2px solid var(--accent); }
#compose { align-items: stretch; flex-direction: column; }
.compose-row { display: flex; gap: 5px; align-items: end; }
.compose-row textarea { flex: 1; resize: vertical; min-height: 39px; max-height: 26dvh; }

