:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --text: #1f1b16;
  --muted: #5b5248;
  --accent: #2f6b4f;
  --accent-text: #ffffff;
  --mine: #e3efe7;
  --theirs: #ffffff;
  --border: #d9cfc2;
  --error: #a3261b;
  font-size: 22px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512;
    --surface: #221f1b;
    --text: #f3ede4;
    --muted: #c3b8aa;
    --accent: #7cc4a0;
    --accent-text: #10241a;
    --mine: #23392d;
    --theirs: #2a2621;
    --border: #3d372f;
    --error: #ff9b8f;
  }
}
* { box-sizing: border-box; }
/* The hidden attribute must win over display rules (modal, login, shell). */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}
#app { max-width: 820px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; padding: 0 16px; }
h1 { font-size: 1.6rem; margin: 0.6em 0 0.2em; }
.lead { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px; margin-top: 10vh; }
label { display: block; margin: 0.8em 0; font-weight: 600; }
input, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--border); border-radius: 14px; padding: 0.6em 0.8em;
}
input:focus, textarea:focus, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button { font: inherit; cursor: pointer; border-radius: 14px; }
.big { background: var(--accent); color: var(--accent-text); border: 0; padding: 0.6em 1.4em; font-weight: 700; min-height: 2.6em; }
.big:disabled { opacity: 0.5; cursor: default; }
.quiet { background: transparent; color: var(--muted); border: 2px solid var(--border); padding: 0.3em 0.8em; font-size: 0.8rem; }
.error { color: var(--error); min-height: 1.5em; }
#chat { display: flex; flex-direction: column; flex: 1; min-height: 100vh; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#messages { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 12px 0 24px; }
.msg { max-width: 85%; padding: 0.7em 1em; border-radius: 20px; border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--mine); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--theirs); border-bottom-left-radius: 6px; }
.day { align-self: center; color: var(--muted); font-size: 0.75rem; }
.typing { color: var(--muted); margin: 0 0 8px; }
.dots i { display: inline-block; width: 0.45em; height: 0.45em; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
#composer { position: sticky; bottom: 0; background: var(--bg); display: flex; gap: 10px; align-items: flex-end; padding: 12px 0 18px; border-top: 1px solid var(--border); }
#composer textarea { resize: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 520px) {
  :root { font-size: 20px; }
  #composer { flex-direction: column; align-items: stretch; }
  .msg { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.quiet[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
#voice-panel { position: sticky; bottom: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0 22px; border-top: 1px solid var(--border); }
.talk { width: min(100%, 420px); min-height: 4.2em; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 1.15rem; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 12px; }
.talk-icon { font-size: 1.6rem; }
.talk.recording { background: #b3261e; color: #fff; animation: pulse 1.4s infinite; }
.talk.busy { opacity: 0.75; }
.voice-status { color: var(--muted); min-height: 1.5em; margin: 0; text-align: center; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(179, 38, 30, 0.45); } 50% { box-shadow: 0 0 0 14px rgba(179, 38, 30, 0); } }
@media (prefers-reduced-motion: reduce) { .talk.recording { animation: none; } }
