:root {
  --bg: #f6f4f0;
  --panel: #ffffff;
  --panel-2: #f0ece5;
  --ink: #1d1a24;
  --muted: #625c6b;
  --line: #e2dcd2;
  --accent: #b4441f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe7dd;
  --night: #2a2440;
  --night-ink: #f4efe6;
  --ok: #1f7a4a;
  --ok-soft: #e3f3ea;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --warn: #8a5300;
  --warn-soft: #fff4de;
  --info: #3b4d8f;
  --info-soft: #eaedfa;
  --shadow: 0 1px 2px rgba(30, 20, 40, 0.06), 0 8px 24px rgba(30, 20, 40, 0.06);
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #131119;
  --panel: #1c1924;
  --panel-2: #24202e;
  --ink: #eeeaf3;
  --muted: #a49db0;
  --line: #342f40;
  --accent: #ff8a5c;
  --accent-ink: #20120b;
  --accent-soft: #3a2219;
  --night: #2b2540;
  --night-ink: #f4efe6;
  --ok: #6fd69d;
  --ok-soft: #173326;
  --bad: #ff8a80;
  --bad-soft: #3a1c1b;
  --warn: #ffc76b;
  --warn-soft: #3a2c14;
  --info: #a9b8f5;
  --info-soft: #1f2440;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--accent); }
.hidden { display: none !important; }
code { font-family: var(--mono); font-size: .86em; background: var(--panel-2); border-radius: 4px; padding: .05rem .3rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
h1, h2, h3 { line-height: 1.2; }
ul.plain { list-style: none; padding: 0; margin: 0; }

button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent; padding: .55rem 1rem; color: var(--ink); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.primary:hover:not(:disabled) { filter: brightness(1.07); }
button.ghost, a.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover:not(:disabled), a.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.small { padding: .3rem .65rem; font-size: .85rem; }
button.icon { padding: .35rem .6rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- Header ---------------------------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap;
  padding: .65rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.backlink { text-decoration: none; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.sep { color: var(--line); }
.appname { white-space: nowrap; }
.logo { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: 7px;
  background: var(--night); color: var(--accent); font-size: .75rem; margin-right: .2rem; }
.topactions { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.linkbtn { text-decoration: none; border-radius: 10px; padding: .35rem .7rem; font-size: .9rem; }
.count { display: inline-block; min-width: 1.3rem; text-align: center; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: .78rem; font-weight: 700; padding: 0 .35rem; margin-left: .2rem; }
.credits { font-size: .88rem; color: var(--muted); }
.topup { font-size: .88rem; font-weight: 600; text-decoration: none; }

/* ---- Hero and examples ----------------------------------------------------- */
main { max-width: 1180px; margin: 0 auto; padding: 0 16px 3rem; }
.hero { padding: 2rem 0 .6rem; }
.hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); margin: 0 0 .5rem; letter-spacing: -.01em; }
.lede { font-size: 1.07rem; color: var(--muted); max-width: 46rem; margin: 0 0 .7rem; }
.pitch { margin: 0; font-size: .94rem; }
.pill { display: inline-block; background: var(--night); color: var(--night-ink); border-radius: 999px; padding: .12rem .6rem; font-size: .8rem;
  font-weight: 650; margin-right: .35rem; }
.examples { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin: 1rem 0 1.2rem; }
.exlabel { font-size: .88rem; color: var(--muted); margin-right: .2rem; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .8rem; font-size: .88rem; }
.chip:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

/* ---- Layout: thread + watchlist ------------------------------------------------ */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.4rem; align-items: start; }
.thread { min-width: 0; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Intake as a conversation ------------------------------------------------- */
.intake { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; }
.turn { display: flex; flex-direction: column; gap: .45rem; margin-bottom: 1rem; }
.bubble { border-radius: 16px; padding: .65rem .9rem; margin: 0; max-width: 100%; }
.bubble.q { align-self: flex-start; background: var(--night); color: var(--night-ink); border-bottom-left-radius: 4px; font-weight: 600; max-width: 92%; }
.bubble.q .hint { display: block; font-weight: 400; font-size: .84rem; opacity: .82; margin-top: .15rem; }
.bubble.q code { background: rgba(255, 255, 255, .14); color: inherit; }
.bubble.a { align-self: stretch; margin-left: 1.4rem; background: var(--panel-2); border: 1px solid var(--line); border-bottom-right-radius: 4px; }
textarea.bubble.a, input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .65rem; width: 100%;
}
textarea.bubble.a { border-radius: 16px; border-bottom-right-radius: 4px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chips.parsed { margin-left: 1.4rem; min-height: 0; }
.tchip { font-size: .8rem; border-radius: 999px; padding: .1rem .55rem; background: var(--info-soft); color: var(--info); }
.tchip.conflict { background: var(--warn-soft); color: var(--warn); font-weight: 650; }
.tchip.repeat::after { content: " x2"; opacity: .7; }
.chip.toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.toggle[aria-pressed="true"]:hover:not(:disabled) { color: var(--accent-ink); filter: brightness(1.06); }
.chips.toggles.small .chip { font-size: .8rem; padding: .25rem .6rem; }
.limits { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem .8rem; }
.fld { display: flex; flex-direction: column; gap: .25rem; font-size: .84rem; color: var(--muted); }
.fld select, .fld input { color: var(--ink); font-size: .95rem; background: var(--panel); }
.fld.wide { grid-column: 1 / -1; }
.checkrow { display: flex; gap: .5rem; align-items: center; font-size: .9rem; margin: .2rem 0 .8rem; }
.checkrow input { width: auto; }
.tastecard { border: 1px dashed var(--line); border-radius: 12px; padding: .65rem .85rem; margin-bottom: .9rem; }
.tastehead { margin: 0 0 .2rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.tastecard p { margin: 0; }
.warnlist li { color: var(--warn); font-size: .88rem; margin-top: .3rem; }
.warnlist li::before { content: "! "; font-weight: 800; }
.notice { border-radius: 10px; padding: .55rem .8rem; font-size: .9rem; margin: .5rem 0; }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.tastecard .notice { background: var(--warn-soft); color: var(--warn); }
.runrow { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; }
.runrow .primary { font-size: 1.05rem; padding: .7rem 1.5rem; }
.meter { font-size: .86rem; color: var(--muted); }
.gate { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: .5rem .8rem; margin-top: .6rem; font-size: .9rem; }
.gate p { margin: 0; }

/* ---- Progress -------------------------------------------------------------------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-top: 1.1rem; }
.progresshead { display: flex; justify-content: space-between; gap: 1rem; }
.steps { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .3rem; }
.stage { display: flex; gap: .55rem; align-items: center; color: var(--muted); font-size: .92rem; }
.stagedot { display: inline-flex; width: 1.4rem; height: 1.4rem; border-radius: 999px; align-items: center; justify-content: center;
  border: 1px solid var(--line); font-size: .75rem; }
.stage.done { color: var(--ink); }
.stage.done .stagedot { background: var(--ok); border-color: var(--ok); color: #fff; }
.stage.now { color: var(--ink); font-weight: 650; }
.stage.now .stagedot { border-color: var(--accent); color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) { .stage.now .stagedot { animation: none; } }

/* ---- Rounds and pick cards ---------------------------------------------------------- */
.round { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-top: 1.1rem; }
details.round > summary { cursor: pointer; list-style: none; }
details.round > summary::-webkit-details-marker { display: none; }
details.round > summary::before { content: "+ "; color: var(--muted); }
details.round[open] > summary::before { content: "- "; }
.roundhead { display: flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: baseline; margin-bottom: .5rem; }
.roundno { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 750; }
.roundtitle { font-size: 1.15rem; }
.bubble.r { background: var(--info-soft); color: var(--ink); border-bottom-left-radius: 4px; margin: .4rem 0; }
.bubble.r.changes { background: var(--accent-soft); }
.reconbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; font-size: .88rem;
  background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: .45rem .75rem; margin: .7rem 0; }
.reconbar.has-broken { background: var(--warn-soft); color: var(--warn); }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .8rem; }
.pick { border: 1px solid var(--line); border-radius: 12px; padding: .8rem .85rem; background: var(--panel); display: flex; flex-direction: column; gap: .35rem; }
.pick.broken { border-color: var(--warn); }
.pick.dimmed { opacity: .62; }
.pickhead { display: flex; gap: .55rem; align-items: flex-start; }
.num { flex: none; width: 1.7rem; height: 1.7rem; border-radius: 8px; background: var(--night); color: var(--night-ink); display: inline-flex;
  align-items: center; justify-content: center; font-weight: 750; font-size: .85rem; }
.picktitle { flex: 1; min-width: 0; }
.picktitle h3 { margin: 0; font-size: 1.02rem; overflow-wrap: anywhere; }
.meta { margin: .1rem 0 0; font-size: .82rem; color: var(--muted); }
.fit { flex: none; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: .12rem .5rem; white-space: nowrap; }
.fit-safe { background: var(--ok-soft); color: var(--ok); }
.fit-stretch { background: var(--info-soft); color: var(--info); }
.fit-wildcard { background: var(--accent-soft); color: var(--accent); }
.genres { margin: 0; font-size: .8rem; color: var(--muted); }
.anchor { margin: 0; font-size: .85rem; }
.anchorlbl { color: var(--muted); }
.why { margin: 0; font-size: .93rem; }
.cnotes { margin: 0; font-size: .84rem; color: var(--muted); }
.cnotes strong { color: var(--ink); font-weight: 650; }
.conf { margin: 0; font-size: .8rem; color: var(--warn); }
.flags { list-style: none; padding: 0; margin: .1rem 0 0; display: grid; gap: .2rem; }
.flag { font-size: .8rem; border-radius: 8px; padding: .2rem .5rem; }
.flag.break { background: var(--warn-soft); color: var(--warn); font-weight: 650; }
.flag.warn { background: var(--bad-soft); color: var(--bad); }
.flag.note { background: var(--panel-2); color: var(--muted); }
.pickactions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: auto; padding-top: .35rem; align-items: center; }
.pickactions button { font-size: .78rem; padding: .25rem .55rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; }
.pickactions button:hover:not(:disabled) { border-color: var(--accent); }
.pickactions button[aria-pressed="true"] { background: var(--night); color: var(--night-ink); border-color: var(--night); }
.pickactions .mark-less[aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.pickactions .watchbtn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.wherelink { font-size: .78rem; margin-left: auto; }
.leftout, .followups { margin-top: 1rem; }
.leftout h3, .followups h3 { font-size: .9rem; margin: 0 0 .35rem; color: var(--muted); }
.leftout li { font-size: .9rem; margin-bottom: .2rem; }
.followups { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.followups h3 { width: 100%; }
.chip.followup { text-align: left; border-radius: 12px; }
.exportrow { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.refinebar { position: static; bottom: .6rem; z-index: 4; background: var(--night); color: var(--night-ink); border-radius: var(--radius);
  padding: .7rem .9rem; margin-top: 1rem; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.refinebar.armed { position: sticky; }
.refinebar p { margin: 0 0 .4rem; }
.refinebar .muted { color: var(--night-ink); opacity: .75; }
.refinerow { display: flex; gap: .5rem; }
.refinerow input { flex: 1; min-width: 0; background: rgba(255, 255, 255, .1); color: var(--night-ink); border-color: rgba(255, 255, 255, .2); }
.refinerow input::placeholder { color: rgba(244, 239, 230, .6); }
.refinebar #refineMeter { margin: .35rem 0 0; }
pre.raw { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: .82rem; background: var(--panel-2); padding: .7rem; border-radius: 10px; }

/* ---- History and watchlist -------------------------------------------------------- */
.histhead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem; align-items: center; }
.histhead h2 { margin: 0; font-size: 1.1rem; }
.histhead input { max-width: 240px; }
.histlist, .watchlist { list-style: none; padding: 0; margin: .7rem 0 0; display: grid; gap: .4rem; }
.histitem { display: flex; gap: .4rem; align-items: center; }
.histopen { flex: 1; text-align: left; background: var(--panel-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: .1rem; }
.histopen:hover:not(:disabled) { border-color: var(--accent); }
li.none { color: var(--muted); font-size: .9rem; }
.watchcard { position: sticky; top: 4.4rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem; max-height: calc(100vh - 5.5rem); overflow: auto; }
.watchhead h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
.watchtabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.wtab { font-size: .8rem; padding: .25rem .55rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; }
.wtab[aria-selected="true"] { background: var(--night); color: var(--night-ink); border-color: var(--night); }
.watchadd { display: flex; gap: .35rem; margin-top: .6rem; }
.watchadd input { font-size: .9rem; padding: .35rem .55rem; }
.wrow { display: flex; gap: .35rem; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: .4rem; }
.wtitle { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: .9rem; overflow-wrap: anywhere; }
.wstatus { width: auto; font-size: .78rem; padding: .2rem .3rem; }
.watchexport { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .7rem; }
@media (max-width: 900px) {
  .watchcard { position: static; max-height: none; margin-top: 1.2rem; }
}
@media (max-width: 560px) {
  .bubble.a, .chips.parsed { margin-left: 0; }
  .backlink { display: none; }
  .brand .sep { display: none; }
  .picks { grid-template-columns: minmax(0, 1fr); }
  .refinerow { flex-direction: column; }
  .intake { padding: .8rem; }
}

/* ---- Footer, toasts, docs ---------------------------------------------------------- */
.foot { max-width: 1180px; margin: 0 auto; padding: 1.2rem 16px 2.5rem; color: var(--muted); font-size: .86rem; border-top: 1px solid var(--line); }
.foot p { margin: .3rem 0; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .4rem; z-index: 20; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 10px; padding: .55rem .8rem;
  box-shadow: var(--shadow); font-size: .9rem; transition: opacity .5s; }
.toast.err { border-left-color: var(--bad); }
.toast.gone { opacity: 0; }
.doc { max-width: 900px; }
.doc pre, pre.block { overflow-x: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; font-family: var(--mono); font-size: .82rem; }
.codegroup { margin: .6rem 0 1.2rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .35rem; }
.tab { font-size: .8rem; padding: .25rem .6rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.tab[aria-selected="true"] { background: var(--night); color: var(--night-ink); border-color: var(--night); }
.errtable { width: 100%; border-collapse: collapse; font-size: .9rem; display: block; overflow-x: auto; }
.errtable th, .errtable td { border-bottom: 1px solid var(--line); padding: .4rem .5rem; text-align: left; vertical-align: top; }
@media print {
  .topbar, .examples, .intake, .refinebar, .watchcard, .history, .pickactions, .exportrow, .toasts, .foot { display: none !important; }
  .layout { display: block; }
  .round, .pick { box-shadow: none; break-inside: avoid; }
}
.statebox { border: 1px solid var(--line); border-radius: 8px; padding: .8rem;
  background: var(--panel-2); margin: .75rem 0 1.25rem; }
.tokenrow { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .5rem 0; }
.tokenbox { flex: 1 1 20rem; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: .55rem .7rem; font-size: .82rem; word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.mini { background: transparent; color: var(--ink); padding: .3rem .6rem; font-size: .82rem; }
.mini:hover:enabled { background: var(--panel-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.mini { border: 1px solid var(--line); border-radius: 8px; }
.statebox p { margin: .3rem 0; }
.tab.active { background: var(--night); color: var(--night-ink); border-color: var(--night); }
.doc h1 { margin-top: 1.5rem; }
