/* chat.css: the look of the chat web app. The same family as the calculator's: dark or light as the device is set; one column at
   phone width, the conversations beside the chat on a wider screen. */
:root {
  color-scheme: dark;
  --bg: #05070f; --bg-glow: #12204a; --panel: rgb(18 24 46 / 0.72); --line: rgb(148 163 184 / 0.18);
  --text: #e6ecff; --muted: #94a3c4; --bad: #fb7185; --good: #34d399; --accent: #22d3ee;
  --mine: rgb(34 211 238 / 0.14); --theirs: rgb(255 255 255 / 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f6fc; --bg-glow: #cfd9ff; --panel: rgb(255 255 255 / 0.85); --line: rgb(71 85 105 / 0.2);
    --text: #0f172a; --muted: #475569; --bad: #be123c; --good: #047857; --accent: #0369a1;
    --mine: rgb(3 105 161 / 0.1); --theirs: rgb(15 23 42 / 0.05);
  }
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0; min-height: 100vh; font: 16px/1.45 var(--font); color: var(--text);
  background:
    radial-gradient(60rem 40rem at 85% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    radial-gradient(50rem 35rem at -10% 110%, var(--bg-glow), transparent 60%),
    repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 48px), var(--bg);
  background-attachment: fixed;
}
.bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; max-width: 64rem; margin: 0 auto; padding: 1.25rem 1rem .5rem; }
h1 { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  background: linear-gradient(90deg, var(--text), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { margin: 0 0 .4rem; font-size: 1.1rem; }
.head { display: flex; flex-direction: column; gap: .15rem; }
.tagline, .note { margin: 0; color: var(--muted); font-size: .85rem; }
.who { display: flex; gap: .5rem; align-items: center; }
.person { color: var(--muted); font-size: .9rem; } .person::before { content: "● "; color: var(--good); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ghost { border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); background: transparent; border-radius: 999px; padding: .4rem .9rem; font-size: .9rem; }
.ghost:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); } .ghost:disabled { opacity: .45; cursor: not-allowed; }
.wide { width: 100%; margin: .5rem 0; }
.send { border: 0; border-radius: 999px; padding: .5rem 1.3rem; font-weight: 600; color: var(--bg); background: var(--accent); }
.send:disabled { opacity: .45; cursor: not-allowed; }
.layout { display: grid; gap: 1rem; grid-template-columns: 1fr; max-width: 64rem; margin: 0 auto; padding: .5rem 1rem 1.5rem; }
@media (min-width: 52rem) { .layout { grid-template-columns: 16rem minmax(0, 1fr); align-items: start; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 1.25rem; padding: 1rem; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 10%, transparent), 0 24px 60px rgb(0 0 0 / .22); }
.history summary { cursor: pointer; font-weight: 600; }
#conversations { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; max-height: 16rem; overflow: auto; }
#conversations li { display: flex; gap: .3rem; align-items: center; }
#conversations .pick { flex: 1; text-align: left; border: 1px solid transparent; background: transparent; border-radius: .6rem; padding: .35rem .5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#conversations .pick:hover, #conversations li.current .pick { border-color: var(--line); background: var(--theirs); }
#conversations .del { border: 0; background: transparent; color: var(--muted); padding: .2rem .4rem; }
.chat { display: flex; flex-direction: column; gap: .75rem; min-height: 60vh; }
.gate { text-align: center; padding: 2rem 1rem; }
.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; flex: 1; overflow-y: auto; max-height: 62vh; }
.messages li { max-width: 92%; padding: .55rem .8rem; border-radius: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.messages li.user { align-self: flex-end; background: var(--mine); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.messages li.assistant { align-self: flex-start; background: var(--theirs); border: 1px solid var(--line); }
.messages li.assistant.writing::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
.messages li.refused { color: var(--bad); }
@keyframes blink { 50% { opacity: 0; } }
.composer { display: grid; gap: .4rem; }
textarea { width: 100%; resize: vertical; min-height: 3.2rem; max-height: 12rem; padding: .6rem .8rem; border-radius: .9rem; font: inherit; color: var(--text);
  background: color-mix(in srgb, var(--bg) 70%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.row { display: flex; gap: .5rem; align-items: center; } .said { flex: 1; min-height: 1.3em; margin: 0; font-size: .85rem; color: var(--muted); }
@media (max-width: 30rem) { .bar { padding-top: .8rem; } .messages li { max-width: 100%; } }
@media (prefers-reduced-motion: reduce) { .messages li.assistant.writing::after { animation: none; } }
