/* Eljae: the free California politics assistant, run by Lina (templates/eljae/*.html + eljae-text.js + eljae.js).
   Lina's brand kit, dark first: black stock, emerald marks (tokens.css is linked before this sheet, and every value below carries its
   kit value as the fallback). Mobile first: one column, a thumb-sized control everywhere (44px), nothing wider than the screen.
   The font is Inter behind the system stack; the "Eljae" word is Michroma, set as written (no text-transform anywhere in this sheet).
   Contrast (WCAG 2.x): text on the ground 17.9, muted on the ground 7.9, light emerald on the ground 10.4, the ground on emerald 7.1. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/inter-latin.woff2') format('woff2');
}

:root {
  --ground: var(--brand-black, #050807);
  --surface: var(--brand-surface, #0B1410);
  --raised: #12201A;
  --ink: var(--brand-text, #EEF3F0);
  --muted: var(--brand-muted-dark, #8FA89B);
  --accent: var(--brand-emerald, #00B070);
  --accent-light: var(--brand-emerald-light, #2FD394);
  --accent-ink: var(--brand-black, #050807);
  --line: #25362E;
  --rim: #7E9A8B;
  --bad: #FF9E94;
  --bad-fill: #E5584B;
  --radius: 16px;
  --radius-sm: 12px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; height: 100%; }

body.eljae {
  margin: 0;
  min-height: 100%;
  background: var(--ground);
  color: var(--ink);
  font: 400 17px/1.55 -apple-system, BlinkMacSystemFont, 'Inter', system-ui, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2.5px solid var(--accent-light); outline-offset: 2px; border-radius: 4px; }
a { color: var(--accent-light); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
h1, h2 { font-weight: 700; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 6vw, 2.5rem); letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1em; }

.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* The wordmark */
.mark {
  font-family: var(--brand-display, 'Michroma', ui-sans-serif, system-ui, sans-serif);
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.mark:hover { color: var(--accent-light); }

/* Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--accent-light); border-color: var(--accent-light); color: var(--accent-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rim); }
.btn-ghost:hover { background: var(--raised); color: var(--ink); border-color: var(--accent-light); }
.btn-small { padding: 8px 14px; font-size: .95rem; }
.btn-danger { background: var(--bad-fill); border-color: var(--bad-fill); color: var(--accent-ink); }
.btn-danger:hover { background: var(--bad); border-color: var(--bad); color: var(--accent-ink); }

.link {
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: none;
  color: var(--accent-light);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link:hover { color: var(--ink); }

input[type="email"], input[type="text"], textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--rim);
  border-radius: var(--radius-sm);
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
label { display: block; font-weight: 600; margin: 0 0 6px; }
.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 44px;
  padding: 8px 0;
  font-weight: 400;
  cursor: pointer;
}
.check input { flex: none; width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--accent); }

/* Pages */
.stage { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; }
.page { padding-top: 8px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.top-nav { display: flex; gap: 8px; }
.top-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; }
.boot, .note, .muted { color: var(--muted); }
.boot { padding: 40vh 0 0; text-align: center; }
.lede { font-size: 1.125rem; color: var(--ink); max-width: 36em; }
.hero { padding: 16px 0 8px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 0 0 16px;
}
.signin { max-width: 440px; }
.step { display: grid; gap: 12px; }
.step-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; }
.line { margin: 12px 0 0; min-height: 1.5em; color: var(--bad); }
.line.ok { color: var(--accent-light); }
.tiers { color: var(--muted); }
.banner { background: var(--raised); border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 12px 16px; }
.noscript { padding: 24px 0; }

.examples h2 { color: var(--muted); font-size: 1rem; font-weight: 600; }
.example-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.example {
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.example:hover { border-color: var(--accent-light); background: var(--raised); }

.foot { color: var(--muted); font-size: .9rem; padding-top: 24px; }
.foot-links { margin: 0; }

/* The chat: one flex column, the log scrolls (min-height: 0 lets it shrink) */
body[data-page="home"] .stage { max-width: 860px; padding-bottom: 0; }
.chat-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-bottom: 8px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent-light);
  font-size: .875rem;
  font-weight: 600;
}
.counter { color: var(--muted); font-size: .9375rem; flex: 1 1 12em; }
.bar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.log { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 14px; }
.welcome { color: var(--muted); }
.welcome h1 { color: var(--ink); font-size: clamp(1.4rem, 5vw, 1.9rem); }
.msg { max-width: 92%; padding: 12px 16px; border-radius: var(--radius); overflow-wrap: anywhere; }
.msg p { margin: 0 0 .7em; }
.msg > :last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 0 0 .7em; padding-left: 1.4em; }
.msg code { background: var(--ground); padding: 1px 5px; border-radius: 6px; font-size: .92em; }
.msg-user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg-user a { color: var(--accent-ink); }
.msg-bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.msg-wait { color: var(--muted); }
.msg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding-top: 8px; border-top: 1px solid var(--line); }
.composer textarea { resize: none; max-height: 9em; flex: 1 1 auto; }
.fineprint { color: var(--muted); font-size: .8125rem; margin: 8px 0 0; }

/* Plus and Account */
.tiers-grid { display: grid; gap: 16px; margin: 16px 0; }
.tier-price { font-size: 2rem; font-weight: 700; margin: 0 0 .4em; }
.per { font-size: 1rem; font-weight: 400; color: var(--muted); }
.tier-plus { border-color: var(--accent); }
.ticks { margin: 0; padding-left: 1.2em; }
.ticks li { margin: 0 0 .4em; }
.renewal { background: var(--raised); border-radius: var(--radius-sm); padding: 12px 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.actions, .confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 0; }
.danger { border-color: var(--bad-fill); }

/* Saved chats: a column beside the conversation on a wide screen, a full-screen sheet behind the Chats button on a phone */
.history { display: none; }
.history.open { display: flex; position: fixed; inset: 0; z-index: 20; flex-direction: column; gap: 8px; padding: 16px; background: var(--ground); }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.history-list { list-style: none; margin: 0; padding: 0; flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.history-item { display: flex; align-items: stretch; gap: 4px; }
.history-pick { flex: 1 1 auto; min-width: 0; text-align: left; padding: 10px 12px; background: transparent; color: var(--ink); border: 1px solid transparent; border-radius: var(--radius-sm); font: inherit; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-pick:hover { background: var(--raised); }
.history-item.current .history-pick { border-color: var(--accent); background: var(--surface); }
.history-del { flex: 0 0 auto; min-width: 36px; background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: var(--radius-sm); font: inherit; cursor: pointer; }
.history-del:hover { color: var(--bad); border-color: var(--bad-fill); }
@media (min-width: 900px) {
  body[data-page="home"].in-app .stage { max-width: 1120px; }
  .chat-app { display: grid; grid-template-columns: 260px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; column-gap: 20px; }
  .history { display: flex; flex-direction: column; gap: 8px; grid-column: 1; grid-row: 1 / span 4; min-height: 0; padding-right: 12px; border-right: 1px solid var(--line); }
  .chat-app > .bar, .chat-app > .log, .chat-app > .composer, .chat-app > .fineprint { grid-column: 2; }
  .history-open, .history-close { display: none; }
}

@media (min-width: 640px) {
  .tiers-grid { grid-template-columns: 1fr 1fr; }
  .msg { max-width: 80%; }
}

@media (pointer: coarse), (max-width: 640px) {
  .btn, .link, .example, .check, input[type="email"], input[type="text"], textarea { min-height: 44px; }
  input, textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* The Terms and the Privacy Notice (no script runs on them) */
.doc { max-width: 720px; }
.doc h1 { margin-top: .5em; }
.doc h2 { margin-top: 1.6em; }
.doc ul { padding-left: 1.3em; }
.doc li { margin: 0 0 .5em; }

/* The list sorter (templates/eljae/lists.html + eljae-lists.js) */
.stage.wide { max-width: 1040px; }
.privacy-box { background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 16px; margin: 0 0 12px; }
.col-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin: 0 0 8px; }
@media (min-width: 640px) { .col-grid { grid-template-columns: repeat(3, 1fr); } }
select, input[type="file"] {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--rim);
  border-radius: var(--radius-sm);
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
input[type="file"]:disabled { opacity: .5; cursor: not-allowed; }
progress { width: 100%; height: 14px; accent-color: var(--accent); }
.preview { overflow-x: auto; margin: 8px 0; }
.tbl { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: .95rem; }
.tbl caption { text-align: left; font-weight: 600; padding: 8px 0; color: var(--ink); }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl thead th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.results-tbl { display: block; overflow-x: auto; }
.results-tbl td.v0 { color: var(--accent-light); font-weight: 600; }
.results-tbl td.v1 { color: var(--ink); font-weight: 600; }
.results-tbl td.v2, .results-tbl td.v4, .results-tbl td.v5, .results-tbl td.v6, .results-tbl td.v7 { color: var(--muted); }
.caveat { margin-top: 16px; }
