:root {
  --deep-forest: #142d32;
  --emerald: #287d6b;
  --mint: #74c8ae;
  --soft-gray: #f3f6f4;
  --white: #ffffff;
  --graphite: #172b30;
  --danger: #dc2626;
  --muted: #64748b;
  --bg: var(--soft-gray);
  --surface: var(--white);
  --text: var(--graphite);
  --text-soft: var(--muted);
  --accent: var(--emerald);
  --accent-text: var(--white);
  --nav-bg: var(--deep-forest);
  --line: color-mix(in srgb, var(--graphite) 14%, transparent);
  --radius: 6px;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: var(--graphite);
  --surface: var(--deep-forest);
  --text: var(--soft-gray);
  --text-soft: var(--mint);
  --accent: var(--mint);
  --accent-text: var(--deep-forest);
  --line: color-mix(in srgb, var(--soft-gray) 16%, transparent);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.app { min-height: 100%; display: grid; grid-template-rows: 52px 1fr; }
.top {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--nav-bg); color: var(--soft-gray);
}
.top h1 { font-size: 16px; font-weight: 600; margin: 0; }
.top .spacer { flex: 1; }
.top button, .pass input { background: transparent; border: 1px solid color-mix(in srgb, var(--soft-gray) 30%, transparent); color: inherit; border-radius: var(--radius); padding: 6px 10px; }
.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 0; }
.list, .thread, .side { background: var(--surface); min-height: 0; }
.list { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.tabs, .tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; }
.tabs button, .tools button, .composer button {
  border: 1px solid var(--line); background: transparent; border-radius: var(--radius); padding: 6px 8px;
}
.tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.rooms, .log, .side { overflow: auto; }
.room, .msg, .person { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.room { width: 100%; text-align: left; background: transparent; border-left: 0; border-right: 0; border-top: 0; }
.room small, .msg small { color: var(--text-soft); }
.unread { display: inline-block; min-width: 1.2em; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-text); }
.thread { display: flex; flex-direction: column; }
.log { flex: 1; padding: 12px; }
.msg { margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.msg p { white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; min-height: 44px; resize: vertical; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); padding: 8px; }
.side { border-left: 1px solid var(--line); padding: 12px; }
.gate { max-width: 520px; margin: 48px auto; background: var(--surface); padding: 24px; border-radius: var(--radius); }
.note { color: var(--text-soft); }
.warn { color: var(--danger); }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .shell.reading .list { display: none; }
  .composer { flex-wrap: wrap; }
  .composer textarea { flex: 1 1 100%; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .shell { grid-template-columns: 220px minmax(0, 1fr); }
  .side { display: none; }
}
