/* Reading-first. Palette and type follow the product site (site/public/styles.css). */
:root {
  --paper: #F6F5F0; --ink: #1E1F1C; --navy: #1F3A5F; --quiet: #66655E; --rule: #D8D5CB; --field: #FFFFFF; --wash: #EEECE4;
  --err: #7A2E2E;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --measure: 660px;
  --header-h: 64px;   /* measured at runtime */
  --composer-h: 120px; /* measured at runtime */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper: #1C1B18; --ink: #E6E3DA; --navy: #9DB6D6; --quiet: #9A978E; --rule: #37352F; --field: #24231F; --wash: #24231F; --err: #D98B8B; }
}
:root[data-theme="dark"] { --paper: #1C1B18; --ink: #E6E3DA; --navy: #9DB6D6; --quiet: #9A978E; --rule: #37352F; --field: #24231F; --wash: #24231F; --err: #D98B8B; }
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--serif); font-size: 20px; line-height: 1.6; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body.center { min-height: 100vh; display: grid; place-items: center; }
a { color: var(--navy); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* controls: sans, quiet, never louder than the text */
input, select, textarea, button { font-family: var(--sans); font-size: 16px; color: var(--ink); background: var(--field); border: 1px solid var(--rule); border-radius: 3px; padding: 9px 12px; line-height: 1.3; }
button { cursor: pointer; background: transparent; color: var(--quiet); }
button:hover { color: var(--navy); border-color: var(--navy); }
button.primary { background: var(--navy); color: var(--paper); border-color: var(--navy); font-weight: 600; }
button.primary:hover { color: var(--paper); opacity: .92; }
button.small { font-size: 14px; padding: 4px 10px; }
select { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%2366655E'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; }
.muted { color: var(--quiet); font-family: var(--sans); font-size: 15px; }
.err { color: var(--err); }

/* sign in */
.card { width: min(380px, 90vw); display: grid; gap: 12px; }
h1 { font-family: var(--serif); font-weight: 500; font-size: 30px; letter-spacing: -.01em; margin: 0 0 8px; }

/* header */
header { position: sticky; top: 0; z-index: 3; background: var(--paper); max-width: var(--measure); margin: 0 auto; padding: 24px 24px 14px; display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--rule); }
header .brand { font-family: var(--serif); font-weight: 500; font-size: 24px; letter-spacing: -.01em; }
header nav { display: flex; gap: 22px; }
header nav button { font-size: 15px; padding: 0; border: 0; background: none; color: var(--quiet); }
header nav button:hover { color: var(--navy); }

/* transcript */
main { max-width: var(--measure); margin: 0 auto; padding: 36px 24px calc(var(--composer-h) + 40px); }
.turn { margin-top: 40px; min-height: 0; transition: color .3s ease, opacity .3s ease; scroll-margin-top: calc(var(--header-h) + 28px); animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .turn { animation: none; } }
.turn:first-child { margin-top: 0; }
.turn:not(.current) { color: var(--quiet); opacity: .42; }
.turn:not(.current):hover { color: var(--ink); opacity: 1; }
.q { font-style: italic; color: var(--quiet); margin: 0 0 12px; white-space: pre-wrap; }
.a { max-width: 66ch; }
.a.pending { white-space: pre-wrap; }
.a.reveal { animation: rise .35s ease both; }
@media (prefers-reduced-motion: reduce) { .a.reveal { animation: none; } }
.a p { margin: 0 0 12px; }
.a p:last-child, .a ol:last-child, .a ul:last-child { margin-bottom: 0; }
.a ol, .a ul { margin: 0 0 12px; padding-left: 1.4em; }
.a li { margin: 0 0 8px; padding-left: .2em; }
.a li::marker { color: var(--quiet); font-family: var(--sans); font-size: .9em; }
.a li.fold > .lead { cursor: pointer; }
.a li.fold > .lead::after { content: "+"; display: inline-block; margin-left: 8px; color: var(--quiet); font-family: var(--sans); font-size: .85em; }
.a li.fold.open > .lead::after { content: "–"; }
.a li.fold > .lead:hover { color: var(--navy); }
.a li.fold > .rest { display: block; margin-top: 4px; }
.a li.fold > .rest[hidden] { display: none; }
.a .showall { display: inline-block; font-family: var(--sans); font-size: 13px; color: var(--quiet); text-decoration: none; margin: -6px 0 12px 1.6em; }
.a .showall:hover { color: var(--navy); }
.a sup { font-family: var(--sans); font-size: .7em; line-height: 0; margin-left: 1px; }
.a sup a { text-decoration: none; color: var(--navy); }
.a .sources { margin: 14px 0 0; padding-left: 1.4em; font-family: var(--sans); font-size: 13px; color: var(--quiet); }
.a .sources li { margin: 0 0 2px; }
.a .sources a { color: var(--quiet); }
.a .sources a:hover { color: var(--navy); }
.a b { font-weight: 500; }
.a code { font-family: var(--mono); font-size: .85em; background: var(--wash); padding: 1px 4px; border-radius: 3px; }
.a.pending::after { content: "▍"; color: var(--navy); margin-left: 1px; animation: blink 1s steps(2, start) infinite; }
.a.pending:empty::before { content: attr(data-status); font-family: var(--sans); font-size: 15px; color: var(--quiet); animation: pulse 1.6s ease-in-out infinite; }
.a.pending:empty::after { display: none; }
@keyframes blink { to { visibility: hidden; } }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .a.pending::after, .a.pending:empty::before { animation: none; } }
.meta { font-family: var(--mono); font-size: 12.5px; color: var(--quiet); margin-top: 10px; opacity: 0; transition: opacity .2s ease; }
.turn:hover .meta, .turn.show-meta .meta { opacity: 1; }
.fb { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.fb button.small { border-color: transparent; padding-left: 6px; padding-right: 6px; }
.fb input { flex: 1; min-width: 180px; padding: 5px 10px; font-size: 15px; background: transparent; border-color: transparent; border-bottom-color: var(--rule); border-radius: 0; }
.fb input:focus { border-color: var(--rule); background: var(--field); }
.fb .note { font-family: var(--sans); font-size: 14px; color: var(--quiet); width: 100%; }

/* compare */
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
main:has(.compare) { max-width: 1200px; }
.compare .col { border-top: 2px solid var(--rule); padding: 12px 0 0; }
.compare .col h4 { margin: 0 0 8px; font-family: var(--mono); font-size: 12.5px; color: var(--quiet); font-weight: 400; }
.compare .a { font-size: 18px; }

/* composer */
footer { position: fixed; left: 0; right: 0; bottom: 0; background: linear-gradient(to bottom, transparent, var(--paper) 22px); padding: 30px 24px calc(20px + env(safe-area-inset-bottom)); transition: bottom .35s cubic-bezier(.2,.7,.2,1), transform .35s cubic-bezier(.2,.7,.2,1); }
@media (prefers-reduced-motion: reduce) { footer { transition: none; } }
body.empty footer { bottom: 50vh; transform: translateY(50%); background: none; }
body.empty main { display: none; }
.composer { max-width: var(--measure); margin: 0 auto; display: grid; gap: 8px; }
.box { display: flex; align-items: flex-end; gap: 8px; background: transparent; border: 1px solid transparent; border-bottom-color: var(--rule); border-radius: 0; padding: 6px 2px; transition: background .15s ease, border-color .15s ease, padding .15s ease; }
.box:focus-within { background: var(--field); border-color: var(--rule); border-radius: 4px; padding: 6px 8px 6px 12px; }
.restore { font-family: var(--sans); font-size: 14px; color: var(--quiet); text-decoration: none; text-align: center; }
.restore:hover { color: var(--navy); }
.restore[hidden] { display: none; }
.typos { font-family: var(--sans); font-size: 14px; color: var(--quiet); padding: 0 2px; }
.typos b { font-weight: 600; color: var(--err); }
.typos[hidden] { display: none; }
.box.warn { border-color: var(--err); }
.box.warn #send { color: var(--err); }
.composer textarea { flex: 1; display: block; resize: none; min-height: 30px; max-height: 220px; border: 0; padding: 4px 0; background: transparent; font-family: var(--serif); font-size: 19px; line-height: 1.5; outline: none; }
.composer textarea::placeholder { color: var(--quiet); }
.box button { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 1px solid transparent; border-radius: 3px; background: transparent; color: var(--quiet); font-size: 17px; line-height: 1; opacity: .55; margin-bottom: 4px; }
.box button[hidden] { display: none; }
.box button:hover { color: var(--navy); border-color: var(--rule); }
.box:focus-within button { opacity: 1; }
.box:focus-within #send { color: var(--navy); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips:empty { display: none; }
.chip { font-family: var(--sans); font-size: 13px; background: var(--wash); border: 1px solid var(--rule); border-radius: 3px; padding: 1px 8px; }
.chip b { cursor: pointer; margin-left: 6px; font-weight: 400; color: var(--quiet); }
#models-pick { display: none; gap: 6px 16px; flex-wrap: wrap; font-family: var(--sans); font-size: 14px; color: var(--quiet); padding: 0 2px; }
#models-pick label { display: flex; gap: 5px; align-items: center; }
#models-pick input { accent-color: var(--navy); margin: 0; }
body.compare-on #models-pick { display: flex; }
.install { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-family: var(--sans); font-size: 14px; color: var(--quiet); background: var(--wash); border: 1px solid var(--rule); border-radius: 4px; padding: 8px 12px; }
.install span { flex: 1; min-width: 200px; }
.install button { font-size: 13px; padding: 3px 10px; }
.install[hidden] { display: none; }

/* settings: tier choice */
.tiers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 12px; }
.tier { text-align: left; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 4px; background: var(--field); color: var(--ink); display: grid; gap: 4px; }
.tier b { font-weight: 600; font-size: 16px; }
.tier small { color: var(--quiet); font-size: 13px; line-height: 1.35; }
.tier[aria-pressed="true"] { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.tier:hover { border-color: var(--navy); }
#tier-note { margin: 6px 0 0; font-size: 13px; }
.diy { display: inline-block; margin-top: 8px; font-family: var(--sans); font-size: 14px; padding: 5px 12px; border: 1px solid var(--rule); border-radius: 3px; background: transparent; color: var(--navy); cursor: pointer; }
.diy:hover { border-color: var(--navy); }
@media (max-width: 560px) { .tiers { grid-template-columns: 1fr; } }

/* settings */
dialog { max-height: 86vh; overflow-y: auto; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink); width: min(600px, 92vw); padding: 26px 28px; font-family: var(--sans); font-size: 16px; }
dialog::backdrop { background: rgba(30, 31, 28, .45); }
dialog h2 { font-family: var(--serif); font-weight: 500; font-size: 26px; margin: 0 0 8px; }
dialog h3 { margin: 26px 0 8px; font-size: 13px; color: var(--quiet); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-top: 1px solid var(--rule); }
.toggle small { display: block; color: var(--quiet); font-size: 14px; }
.toggle input[type=checkbox] { accent-color: var(--navy); width: 18px; height: 18px; flex: none; }
.rule { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--rule); font-family: var(--serif); font-size: 17px; }
.rule span { flex: 1; }
.rule input { accent-color: var(--navy); }
.rule.off span { color: var(--quiet); text-decoration: line-through; }
dialog textarea { width: 100%; min-height: 140px; font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

@media (max-width: 560px) {
  body { font-size: 18px; }
  header { padding: calc(14px + env(safe-area-inset-top)) 18px 0; }
  main { padding: 24px 18px calc(var(--composer-h) + 24px); }
  .a { max-width: none; }
  footer { padding: 20px 12px calc(12px + env(safe-area-inset-bottom)); }
  .composer textarea { font-size: 17px; }
  input, select, textarea { font-size: 16px; } /* iOS zooms on anything smaller */
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; }
  .compare { grid-template-columns: 1fr; }
}

/* Phones: a fixed column sized to the visible area (shrinks when the keyboard opens); the transcript scrolls inside it. Desktop keeps window scrolling. */
@media (max-width: 760px) {
  html, body { height: 100%; overflow: hidden; }
  body { position: fixed; top: var(--app-top, 0px); left: 0; right: 0; height: var(--app-h, 100dvh); display: flex; flex-direction: column; }
  header { position: static; flex: none; width: 100%; max-width: none; margin: 0; padding-bottom: 12px; }
  main { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 20px 18px 24px; }
  footer { position: static; flex: none; background: var(--paper); padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); transition: none; }
  body.empty footer { bottom: auto; transform: none; margin: auto 0; background: none; }
  body.empty main { display: none; }
  .turn { animation: none; }
}
