:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1c1b18; --muted: #6b6860; --line: #e4e1d8; --line-strong: #cfcbc0;
  --accent: #2f5d50; --accent-ink: #ffffff; --accent-soft: #e3efe9;
  --warn: #9a5b12; --warn-soft: #fbeedb; --bad: #a13b2f; --bad-soft: #f9e5e1; --good: #2f6b3a; --good-soft: #e2f1e4; --info: #3b5b8a; --info-soft: #e5ecf7;
  --preview: #6b4bb5; --preview-soft: #ede7fa;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #15161a; --panel: #1e2026; --ink: #ecebe6; --muted: #9a9890; --line: #2d3038; --line-strong: #40444f;
  --accent: #7fc0aa; --accent-ink: #0f1a16; --accent-soft: #1f312b;
  --warn: #e2a860; --warn-soft: #3a2c17; --bad: #e08a7e; --bad-soft: #3c2320; --good: #8ccb96; --good-soft: #1f3423; --info: #93b2e6; --info-soft: #1f2a3c;
  --preview: #b9a3f0; --preview-soft: #2a2340; --shadow: none;
} }
:root[data-theme="dark"] {
  --bg: #15161a; --panel: #1e2026; --ink: #ecebe6; --muted: #9a9890; --line: #2d3038; --line-strong: #40444f;
  --accent: #7fc0aa; --accent-ink: #0f1a16; --accent-soft: #1f312b;
  --warn: #e2a860; --warn-soft: #3a2c17; --bad: #e08a7e; --bad-soft: #3c2320; --good: #8ccb96; --good-soft: #1f3423; --info: #93b2e6; --info-soft: #1f2a3c;
  --preview: #b9a3f0; --preview-soft: #2a2340; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0; }
textarea, input:not([type]), input[type=text], input[type=email], input[type=number], input[type=url], select { width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 12px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail { border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; background: var(--panel); }
.rail .brand { font-weight: 700; padding: 6px 10px 14px; font-size: 15px; }
.rail .brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.rail a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink); }
.rail a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rail .spacer { flex: 1; }
.main { padding: 28px 32px 120px; max-width: 1180px; width: 100%; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.crumbs { color: var(--muted); font-size: 13px; }
.crumbs a { color: var(--muted); }
.areas { display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.areas a { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.areas a.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.areas a .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--preview); }
.bottombar { display: none; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .main { padding: 16px 16px 110px; }
  .bottombar { display: flex; position: fixed; bottom: calc(34px + env(safe-area-inset-bottom, 0px)); left: 0; right: 0; background: var(--panel); border-top: 1px solid var(--line); justify-content: space-around; padding: 6px 4px; z-index: 5; }
  .bottombar a { color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 4px; border-radius: 8px; min-width: 44px; flex: 1; }
  .bottombar a.active { color: var(--accent); font-weight: 600; }
}

/* Cards and panels */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid3 { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.panel > h2, .panel > h3 { margin-bottom: 10px; }
.panel .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.panel .head a { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.lead { font-size: 16px; color: var(--muted); max-width: 62ch; }
.hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.list { display: flex; flex-direction: column; }
.list > * { padding: 10px 0; border-top: 1px solid var(--line); }
.list > *:first-child { border-top: 0; padding-top: 0; }
.item { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item .body { flex: 1; min-width: 0; }
.item .body p { white-space: pre-wrap; }
.clickable { cursor: pointer; }
.clickable:hover { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--panel); font-size: 14px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--accent); padding: 6px 8px; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: normal; text-align: left; border: 1px solid transparent; }
.chip.open { background: var(--bg); color: var(--muted); border-color: var(--line-strong); }
.chip.attached { background: var(--info-soft); color: var(--info); }
.chip.reviewing { background: var(--info-soft); color: var(--info); }
.chip.accepted { background: var(--good-soft); color: var(--good); }
.chip.weak { background: var(--warn-soft); color: var(--warn); }
.chip.overridden { background: var(--bad-soft); color: var(--bad); }
.chip.draft { background: var(--info-soft); color: var(--info); }
.chip.origin { background: var(--bg); color: var(--muted); font-weight: 500; border-color: var(--line); }
.chip.preview { background: var(--preview-soft); color: var(--preview); }
.chip.area { background: var(--bg); color: var(--muted); border-color: var(--line); font-weight: 500; }
.chip.area.money { color: #7a5a00; } .chip.area.life { color: #3a6a8a; }
.chip .n { width: 18px; height: 18px; border-radius: 50%; background: currentColor; color: var(--panel); display: inline-grid; place-items: center; font-size: 11px; }

/* Reason line */
.reason { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 13px; }
.reason::before { content: ""; width: 3px; border-radius: 2px; background: var(--line-strong); align-self: stretch; flex: none; }
.reason.good::before { background: var(--good); } .reason.warn::before { background: var(--warn); } .reason.bad::before { background: var(--bad); } .reason.info::before { background: var(--info); }

/* Notices */
.notice { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.notice.info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.notice.preview { background: var(--preview-soft); border-color: transparent; color: var(--preview); }
.notice.coach { background: var(--bg); }
.notice p { color: inherit; }

/* Sections in record */
.section { padding: 14px 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; padding-top: 0; }
.section .head h3 { display: flex; align-items: center; gap: 8px; }
.section .hint { color: var(--muted); font-size: 13px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 8px; }
.section .hint.later { border-style: solid; background: var(--bg); }
.entry { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.entry p { white-space: pre-wrap; }
.entry .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.entry.flagged { border-color: var(--warn); }

/* Home summaries */
.summary .section-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.summary .section-row:first-child { border-top: 0; }
.summary .section-row .n { color: var(--muted); font-size: 13px; }

/* Stage ladder */
.ladder { display: flex; gap: 6px; align-items: stretch; margin-bottom: 14px; flex-wrap: wrap; }
.ladder .step { flex: 1; min-width: 120px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.ladder .step.current { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.ladder .step.done { color: var(--good); border-color: var(--good); }
.ladder .step small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; }
.criterion { color: var(--ink); display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 12px 8px; border-radius: 8px; }
.criterion .num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-strong); font-size: 12px; font-weight: 600; color: var(--muted); }
.criterion.accepted .num { background: var(--good); color: #fff; border-color: var(--good); }
.criterion.overridden .num { background: var(--bad); color: #fff; border-color: var(--bad); }
.criterion.weak .num { background: var(--warn); color: #fff; border-color: var(--warn); }
@media (max-width: 700px) { .criterion { grid-template-columns: 28px 1fr; } .criterion > .chip { grid-column: 2; justify-self: start; } }

/* Quadrants */
.quadrants { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .quadrants { grid-template-columns: 1fr; } }
.quadrant { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 160px; display: flex; flex-direction: column; gap: 8px; }
.quadrant.over { border-color: var(--accent); background: var(--accent-soft); }
.quadrant .qhead { display: flex; justify-content: space-between; align-items: baseline; }
.quadrant .qhead small { color: var(--muted); font-size: 12px; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel); cursor: grab; display: flex; flex-direction: column; gap: 6px; position: relative; }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .5; }
.card .title { font-weight: 600; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.card .title a { color: var(--ink); flex: 1; }
.card .why { color: var(--muted); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card .move { position: relative; }
.card select.move, .panel select.move { width: auto; padding: 6px 8px; font-size: 13px; border-radius: 6px; color: var(--muted); min-height: 32px; }
.start { border-left: 4px solid var(--accent); }
.start h2 { display: flex; gap: 8px; align-items: center; }
.areacards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1000px) { .areacards { grid-template-columns: 1fr; } }
.areacard { display: block; color: var(--ink); }
.areacard .big { font-size: 22px; font-weight: 600; }
.qmini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 480px) { .qmini { grid-template-columns: repeat(2, 1fr); } }
select { max-width: 100%; }
.decide { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.decided { color: var(--good); font-size: 13px; margin-top: 6px; }
.qmini a { display: block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 13px; }
.qmini a strong { display: block; font-size: 18px; }
.rail .group { margin: 10px 10px 2px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.filledby { color: var(--muted); font-size: 12px; text-align: right; max-width: 55%; }
.card.done { opacity: .6; }
.card.done .title a { text-decoration: line-through; }

/* Drafts */
.draftbox { border: 1px dashed var(--info); border-radius: var(--radius); padding: 12px; background: var(--info-soft); }
.draftbox textarea, .draftbox input:not([type=radio]) { background: var(--panel); }
.draftbox .label { color: var(--info); font-weight: 600; font-size: 13px; display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }

/* Read view */
.doc { max-width: 72ch; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 36px 40px; }
@media (max-width: 700px) { .doc { padding: 22px 18px; } }
.doc h1 { font-size: 26px; margin-bottom: 4px; }
.doc h2 { font-size: 18px; margin: 28px 0 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.doc p { margin: 0 0 10px; white-space: pre-wrap; }
.doc .annot { color: var(--muted); font-size: 12px; margin: -6px 0 12px; }
.doc .empty { color: var(--muted); font-style: italic; }

/* Onboarding / sign in */
.center { max-width: 560px; margin: 8vh auto 0; padding: 0 16px; }
.center .panel { padding: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); }
.field .req { color: var(--warn); }

/* Sheet (confirmation) */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: end center; z-index: 60; }
@media (min-width: 700px) { .scrim { place-items: center; } }
.sheet { background: var(--panel); border-radius: 14px 14px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px)); max-height: 90vh; overflow: auto; width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 700px) { .sheet { border-radius: 14px; } }
.sheet .actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Demo bar */
#demobar { position: fixed; left: 0; right: 0; bottom: 0; background: #2a2a2a; color: #eee; font-size: 12px; padding: 6px 12px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; z-index: 30; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; min-height: 34px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
#demobar .toggle { display: none; }
@media (max-width: 820px) { #demobar .toggle { display: inline-block; } #demobar:not(.open) > :not(.tag):not(.toggle) { display: none; } #demobar.open { flex-direction: column; align-items: flex-start; gap: 8px; } body.demo-open .bottombar { display: none; } }
#demobar .tag { background: #444; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
#demobar label { display: flex; align-items: center; gap: 5px; }
#demobar select { width: auto; padding: 2px 4px; font-size: 12px; background: #3a3a3a; color: #eee; border-color: #555; border-radius: 4px; }
#demobar button { background: #3a3a3a; color: #eee; border: 1px solid #555; border-radius: 4px; padding: 2px 8px; font-size: 12px; }
#demobar .code { color: #9ad; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 60px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 13px; z-index: 40; max-width: 90vw; display: none; }
#toast.show { display: block; }

/* Facts for vision areas */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.fact { padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.fact .v { font-size: 20px; font-weight: 600; }
.fact .l { color: var(--muted); font-size: 12px; }
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); }
.evidence { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; }
.evidence .kind { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.later-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.later-item:first-child { border-top: 0; }
.later-item .when { color: var(--muted); font-size: 13px; text-align: right; max-width: 50%; }
.history { color: var(--muted); font-size: 12px; }
.history div { padding: 4px 0; border-top: 1px dashed var(--line); }
/* Guided onboarding */
.intake { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.intake-side { padding: 28px 22px; border-right: 1px solid var(--line); background: var(--panel); }
.intake-side .brand { font-weight: 700; margin-bottom: 10px; }
.intake-main { padding: 28px 32px 120px; max-width: 760px; width: 100%; margin: 0 auto; }
.intake-rail { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.intake-rail li { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; padding: 6px 8px; border-radius: 8px; }
.intake-rail li .n { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 12px; }
.intake-rail li.current { color: var(--ink); background: var(--accent-soft); font-weight: 600; }
.intake-rail li.current .n { border-color: var(--accent); color: var(--accent); }
.intake-rail li.done .n { background: var(--good); color: #fff; border-color: var(--good); }
.reflect { display: grid; gap: 10px; }
.reflect > div { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; }
.reflect .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.reflect input { background: var(--panel); padding: 8px 10px; font-size: 14px; min-width: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.checks .ok { color: var(--good); }
.checks em { color: var(--warn); font-style: normal; }
.statement { margin: 0 0 8px; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--panel); border-radius: 0 8px 8px 0; font-size: 15px; }
.sorted { display: flex; gap: 10px; align-items: flex-start; }
.option { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 14px; cursor: pointer; }
.option input { margin-top: 3px; }
@media (max-width: 820px) { .intake { grid-template-columns: 1fr; } .intake-side { border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; } .intake-rail { flex-direction: row; flex-wrap: wrap; gap: 4px; } .intake-rail li span:last-child { display: none; } .intake-rail li.current span:last-child { display: inline; } .intake-main { padding: 16px 16px 120px; } .reflect > div { grid-template-columns: 1fr; gap: 2px; } }

/* Companies and people */
.cswitch { padding: 0 6px 4px; }
.cswitch select { width: 100%; font-size: 13px; padding: 6px 8px; border-radius: 8px; }
.corow { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); }
.corow:hover { border-color: var(--line-strong); }
.corow.active { border-color: var(--accent); background: var(--accent-soft); }
.corow .name { font-weight: 600; }
.chip.who { background: var(--info-soft); color: var(--info); border-color: transparent; }
.member { display: grid; grid-template-columns: 1.4fr 1fr .9fr 1.4fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.member.head-row { border-top: 0; padding: 0 0 6px; }
.member .who { display: flex; flex-direction: column; }
@media (max-width: 820px) { .member { grid-template-columns: 1fr 1fr; } .member.head-row { display: none; } }

/* Live mode (API behind this origin) and uploaded screenshots */
#demobar .tag.live { background: #2f5d50; }
#demobar a { color: #9ad; }
.evidence .thumb { max-height: 72px; max-width: 120px; border-radius: 6px; vertical-align: middle; border: 1px solid var(--line); }
