/* Decision Brain: a restrained research-instrument look. All colours, spacing and type come from the tokens below;
   dark values are set deliberately (not inverted) and apply for the OS setting or an explicit data-theme="dark". */
:root {
  color-scheme: light;
  /* surfaces and text */
  --bg: #f6f6f7; --surface: #ffffff; --surface-2: #f3f3f5; --surface-3: #e8e8ec;
  --border: #e3e3e8; --border-strong: #cfcfd6;
  --ink: #18181b; --ink-2: #3f3f46; --muted: #63636e;
  /* one accent, semantic states */
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-ink: #ffffff; --accent-text: #4338ca; --accent-soft: rgba(79,70,229,.09);
  --ok: #15803d; --ok-soft: #e7f5ec; --warn: #9a5800; --warn-soft: #fdf4e3; --warn-border: #efd29a;
  --danger: #c42b2b; --danger-soft: #fdeded; --danger-border: #f2c1c1;
  --ring: #6366f1;
  /* graph */
  --g-bg: #fbfbfc; --g-dot: #e6e6ea; --g-edge: #b9b9c3; --g-edge-strong: #52525b; --g-edge-label: #63636e;
  --g-label: #27272a; --g-label-bg: #ffffff; --g-node-border: #ffffff; --g-select: #4f46e5; --g-flash: #f59e0b;
  --kep-ok: #34c759; --kep-mid: #ff9f0a; --kep-no: #ff3b30;
  --person: #8b5cf6; --team: #0ea5b7; --code: #71717a; --other: #a1a1aa;
  /* atlas (whole-graph view): team hues are generated in atlas.js from --atlas-sat / --atlas-light */
  --atlas-bg: #fbfbfc; --atlas-dot: #ececf0; --atlas-link: rgba(63,63,70,.13); --atlas-link-hl: rgba(79,70,229,.5);
  --atlas-label: #18181b; --atlas-halo: rgba(255,255,255,.88); --atlas-sat: 68; --atlas-light: 47; --atlas-glow: 10;
  --atlas-panel: rgba(255,255,255,.86);
  /* scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;
  --fs-xs: 11.5px; --fs-sm: 12.5px; --fs-md: 14px; --fs-lg: 15px; --fs-xl: 20px;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
  --shadow-1: 0 1px 2px rgba(16,16,24,.05); --shadow-2: 0 6px 24px rgba(16,16,24,.10);
  --dur: 160ms;
  --header-h: 52px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0c0f; --surface: #141417; --surface-2: #1b1b20; --surface-3: #25252c;
    --border: #2a2a31; --border-strong: #3b3b44;
    --ink: #ececf1; --ink-2: #c6c6ce; --muted: #9b9ba6;
    --accent: #7c7ff2; --accent-hover: #9395f6; --accent-ink: #0c0c0f; --accent-text: #a5a7fb; --accent-soft: rgba(124,127,242,.14);
    --ok: #4ade80; --ok-soft: rgba(74,222,128,.10); --warn: #fbbf24; --warn-soft: rgba(251,191,36,.09); --warn-border: rgba(251,191,36,.32);
    --danger: #f87171; --danger-soft: rgba(248,113,113,.10); --danger-border: rgba(248,113,113,.32);
    --ring: #a5a7fb;
    --g-bg: #111114; --g-dot: #222229; --g-edge: #4b4b56; --g-edge-strong: #c6c6ce; --g-edge-label: #9b9ba6;
    --g-label: #dcdce3; --g-label-bg: #141417; --g-node-border: #141417; --g-select: #a5a7fb; --g-flash: #fbbf24;
    --code: #8e8e99; --other: #6b6b76;
    --atlas-bg: #0a0a0d; --atlas-dot: #17171c; --atlas-link: rgba(200,200,215,.09); --atlas-link-hl: rgba(165,167,251,.55);
    --atlas-label: #ececf1; --atlas-halo: rgba(10,10,13,.82); --atlas-sat: 78; --atlas-light: 64; --atlas-glow: 22;
    --atlas-panel: rgba(20,20,23,.84);
    --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 8px 28px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0c0f; --surface: #141417; --surface-2: #1b1b20; --surface-3: #25252c;
  --border: #2a2a31; --border-strong: #3b3b44;
  --ink: #ececf1; --ink-2: #c6c6ce; --muted: #9b9ba6;
  --accent: #7c7ff2; --accent-hover: #9395f6; --accent-ink: #0c0c0f; --accent-text: #a5a7fb; --accent-soft: rgba(124,127,242,.14);
  --ok: #4ade80; --ok-soft: rgba(74,222,128,.10); --warn: #fbbf24; --warn-soft: rgba(251,191,36,.09); --warn-border: rgba(251,191,36,.32);
  --danger: #f87171; --danger-soft: rgba(248,113,113,.10); --danger-border: rgba(248,113,113,.32);
  --ring: #a5a7fb;
  --g-bg: #111114; --g-dot: #222229; --g-edge: #4b4b56; --g-edge-strong: #c6c6ce; --g-edge-label: #9b9ba6;
  --g-label: #dcdce3; --g-label-bg: #141417; --g-node-border: #141417; --g-select: #a5a7fb; --g-flash: #fbbf24;
  --code: #8e8e99; --other: #6b6b76;
  --atlas-bg: #0a0a0d; --atlas-dot: #17171c; --atlas-link: rgba(200,200,215,.09); --atlas-link-hl: rgba(165,167,251,.55);
  --atlas-label: #ececf1; --atlas-halo: rgba(10,10,13,.82); --atlas-sat: 78; --atlas-light: 64; --atlas-glow: 22;
  --atlas-panel: rgba(20,20,23,.84);
  --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 8px 28px rgba(0,0,0,.55);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* the hidden attribute must win over display rules */
html, body { background: var(--bg); }
body { margin: 0; font: var(--fs-md)/1.5 var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.005em; }
p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--r-sm); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.mono { font-family: var(--mono); font-size: .93em; }
.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; }
.skip { position: absolute; left: var(--s-2); top: var(--s-2); z-index: 50; background: var(--surface); color: var(--ink);
        padding: var(--s-2) var(--s-3); border-radius: var(--r-md); box-shadow: var(--shadow-2); transform: translateY(-200%); }
.skip:focus { transform: none; }
.icon { width: 16px; height: 16px; flex: none; fill: none; vertical-align: -3px; }
.hint { font-size: var(--fs-xs); color: var(--muted); }

/* ---------- controls ---------- */
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 var(--s-3); font-size: 13px; font-weight: 500;
       border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); border-radius: var(--r-md);
       transition: background var(--dur), border-color var(--dur), color var(--dur); }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.ghost[aria-expanded="true"] { color: var(--accent-text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 0 var(--s-4); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.wide { width: 100%; justify-content: center; }
.btn.small { min-height: 28px; font-size: var(--fs-sm); }
.btn .spin { display: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
             animation: spin .7s linear infinite; }
.btn[aria-busy="true"] .spin { display: inline-block; }
.btn[aria-busy="true"]:disabled { opacity: .85; }
.iconbtn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 1px solid transparent; border-radius: var(--r-md);
           background: transparent; color: var(--ink-2); transition: background var(--dur); }
.iconbtn:hover { background: var(--surface-2); border-color: var(--border); }
select { min-height: 32px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 0 var(--s-2); font-size: 13px; max-width: 100%; }
select:hover { border-color: var(--muted); }
.lbl { font-size: var(--fs-sm); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 500; line-height: 18px; padding: 0 7px;
        border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.chip.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.chip .icon { width: 12px; height: 12px; vertical-align: 0; }

/* ---------- header ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s-4); min-height: var(--header-h);
          padding: var(--s-2) var(--s-4); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.mark { width: 22px; height: 22px; color: var(--accent); fill: var(--accent); flex: none; }
.name { font-size: var(--fs-lg); font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.tagline { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; padding-left: var(--s-2); border-left: 1px solid var(--border); }
.topright { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; justify-content: flex-end; }
.graphpick { display: flex; align-items: center; gap: 6px; }
.fresh { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink-2); padding: 0 var(--s-2);
         min-height: 28px; border-radius: 999px; background: var(--surface-2); max-width: 480px; }
.fresh #freshtext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fdot { width: 7px; height: 7px; border-radius: 50%; background: var(--other); flex: none; }
.fresh.ok .fdot { background: var(--ok); }
.fresh.danger { color: var(--danger); background: var(--danger-soft); }
.fresh.danger .fdot { background: var(--danger); }
.seg { display: inline-flex; margin: 0; padding: 2px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.seg label { position: relative; display: grid; place-items: center; width: 28px; height: 24px; border-radius: 5px; color: var(--muted); cursor: pointer; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--ring); outline-offset: 1px; }
.seg.text label { width: auto; padding: 0 10px; font-size: 13px; font-weight: 500; }
.seg.text.small label { height: 22px; padding: 0 8px; font-size: var(--fs-sm); }

/* ---------- about, notices, walkthrough ---------- */
.about { margin: var(--s-3) var(--s-4) 0; padding: var(--s-5) var(--s-6); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.about-head { display: flex; gap: var(--s-6); align-items: flex-start; }
.about h2 { margin-bottom: var(--s-2); font-size: var(--fs-xl); line-height: 1.3; letter-spacing: -.015em; max-width: 46ch; }
.about p { color: var(--ink-2); max-width: 92ch; }
.about-head > div { flex: 1; }
.about-head .btn { flex: none; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); margin: var(--s-4) 0 0; padding: 0; list-style: none; }
.tile { border-top: 2px solid var(--accent-soft); padding: var(--s-3) 0 0; font-size: 13px; display: flex; flex-direction: column; gap: var(--s-1); }
.tile b { font-weight: 600; }
.tile span { color: var(--muted); }
.notice { margin: var(--s-3) var(--s-4) 0; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); font-size: 13px;
          background: var(--accent-soft); color: var(--ink-2); border: 1px solid var(--border); }

.scenario { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin: var(--s-3) var(--s-4) 0; }
.scenario ol { display: flex; flex-wrap: wrap; list-style: none; margin: 0; padding: 2px; gap: 2px; background: var(--surface-2);
               border: 1px solid var(--border); border-radius: var(--r-md); font-size: var(--fs-sm); }
.scenario li { display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 6px; border-radius: 6px; color: var(--muted); }
.scenario .num { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 10.5px; font-weight: 600;
                 border: 1px solid var(--border-strong); }
.scenario li.done { color: var(--ink-2); }
.scenario li.done .num { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.scenario li.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1); }
.scenario li.active .num { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.scenario .hint { font-size: var(--fs-sm); color: var(--ink-2); max-width: 70ch; }

/* ---------- workspace ---------- */
.tabs { display: none; }
.layout { display: grid; grid-template-columns: minmax(380px, 1.15fr) minmax(340px, 1fr) minmax(250px, 300px); gap: var(--s-3);
          padding: var(--s-3) var(--s-4) var(--s-4); min-height: 600px;
          height: calc(100vh - var(--header-h) - var(--c-scenario) - var(--c-banner));
          height: calc(100dvh - var(--header-h) - var(--c-scenario) - var(--c-banner)); }
/* rows shown above the workspace shrink it, so the three panels still fit one screen */
body { --c-scenario: 0px; --c-banner: 0px; }
body:has(#scenario:not([hidden])) { --c-scenario: 44px; }
body:has(#replaybanner:not([hidden])) { --c-banner: 46px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); overflow: auto; min-width: 0; }
.left { container-type: inline-size; }
.center { display: flex; flex-direction: column; padding-bottom: var(--s-3); }
.panelhead { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); min-height: 30px; }
.panelhead h2 { font-size: 13px; text-transform: none; }
.panelhead .muted { font-size: var(--fs-xs); }
.panelhead .tools { margin-left: auto; display: flex; gap: 2px; }
.status { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); }

/* ---------- composer ---------- */
.flabel { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.askform textarea { display: block; width: 100%; resize: vertical; min-height: 64px; border: 1px solid var(--border-strong); background: var(--surface);
                    border-radius: var(--r-md); padding: 10px 12px; font-size: var(--fs-lg); line-height: 1.45; outline: none;
                    transition: border-color var(--dur), box-shadow var(--dur); }
.askform textarea::placeholder { color: var(--muted); }
.askform textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.askform textarea[aria-invalid="true"] { border-color: var(--danger); }
.controls { display: flex; align-items: center; gap: var(--s-3); margin-top: var(--s-2); flex-wrap: wrap; font-size: 13px; }
.field { display: flex; align-items: center; gap: 6px; }
#askbtn { margin-left: auto; min-width: 84px; justify-content: center; }
.askform .hint { margin-top: 6px; }
.field-error { margin-top: 6px; font-size: var(--fs-sm); color: var(--danger); }
.toggle { display: flex; align-items: center; gap: var(--s-2); cursor: pointer; user-select: none; min-height: 32px; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { width: 30px; height: 18px; border-radius: 9px; background: var(--surface-3); border: 1px solid var(--border-strong);
                 position: relative; transition: background var(--dur); flex: none; }
.toggle .track::after { content: ""; position: absolute; top: 1px; left: 1px; width: 14px; height: 14px; border-radius: 50%;
                        background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform var(--dur); }
.toggle input:checked + .track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(12px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--ring); outline-offset: 2px; }

.exbox { margin: var(--s-3) 0 0; font-size: 13px; }
.exbox summary, .drawer summary, .prev summary, .pathtext summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.exbox summary::-webkit-details-marker, .drawer summary::-webkit-details-marker, .prev summary::-webkit-details-marker,
.pathtext summary::-webkit-details-marker { display: none; }
.exbox summary::before, .drawer summary::before, .prev summary::before, .pathtext summary::before {
  content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform var(--dur); margin: 0 4px 0 2px; flex: none; }
.exbox[open] > summary::before, .drawer[open] > summary::before, .prev[open] > summary::before, .pathtext[open] > summary::before { transform: rotate(45deg); }
.exbox summary { color: var(--muted); font-size: var(--fs-sm); }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--s-2) 0 0; }
.examples button { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--r-md); padding: 5px 10px; font-size: var(--fs-sm);
                   text-align: left; color: var(--ink-2); transition: border-color var(--dur), color var(--dur); }
.examples button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-text); }

/* ---------- banners and answers ---------- */
.banner { display: flex; gap: var(--s-2); align-items: center; margin: var(--s-3) 0 0; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); font-size: 13px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
#outdated { position: sticky; top: calc(-1 * var(--s-4)); z-index: 3; background: var(--surface);
            background-image: linear-gradient(var(--warn-soft), var(--warn-soft)); box-shadow: var(--shadow-2); }
.banner #outdatedtext { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.btn.warnbtn { flex: none; border-color: var(--warn-border); color: var(--warn); background: var(--surface); }

.answers { display: grid; gap: var(--s-3); margin-top: var(--s-4); }
@container (min-width: 760px) { .answers.two { grid-template-columns: 1fr 1fr; align-items: start; } }
.emptystate { padding: var(--s-6) var(--s-4); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); text-align: center;
              color: var(--muted); font-size: 13px; }
.emptytitle { color: var(--ink-2); font-weight: 600; margin-bottom: 2px; }
.card { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); background: var(--surface); min-width: 0;
        transition: opacity var(--dur); }
.card.baseline { background: var(--surface-2); }
.card.is-outdated .text, .card.is-outdated .sources { opacity: .55; }
.cardhead { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-3); }
.cardhead h3 { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink-2); }
.cardhead .chips { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.modedot { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.modedot.vector { background: var(--muted); }
.card .text { font-size: var(--fs-lg); line-height: 1.6; max-width: 68ch; overflow-wrap: anywhere; }
.card .text p, .prev .text p { margin: 0 0 var(--s-2); }
.card .text ul, .prev .text ul { margin: 0 0 var(--s-2); padding-left: 20px; }
.card .text li { margin-bottom: 2px; }
.cite { font-size: 10.5px; vertical-align: super; line-height: 0; margin: 0 1px; font-weight: 600; font-family: var(--mono); }
.srchead { margin-top: var(--s-3); font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.sources { margin: 4px 0 0; padding-left: 24px; font: var(--fs-sm)/1.55 var(--mono); color: var(--muted); }
.sources li { overflow-wrap: anywhere; padding-left: 2px; }
.sources li::marker { color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 2px var(--s-4); margin: var(--s-3) 0 0; padding-top: var(--s-2); border-top: 1px solid var(--border);
        font-size: var(--fs-xs); color: var(--muted); }
.meta div { display: flex; gap: 5px; min-width: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.loading { display: flex; align-items: center; gap: var(--s-2); color: var(--muted); font-size: 13px; }
.loading::before { content: ""; width: 12px; height: 12px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%;
                   animation: spin .8s linear infinite; flex: none; }
.skel { height: 10px; border-radius: 4px; background: var(--surface-3); margin-top: var(--s-2); }
.skel.w80 { width: 80%; } .skel.w60 { width: 60%; }
@keyframes spin { to { transform: rotate(360deg); } }
.errbox { display: flex; align-items: flex-start; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--danger-soft);
          color: var(--danger); border: 1px solid var(--danger-border); font-size: 13px; }
.errbox p { flex: 1; overflow-wrap: anywhere; color: var(--ink); }
.errbox .icon { margin-top: 2px; }

.prev { margin-top: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); font-size: 13px; }
.prev summary { color: var(--ink-2); font-weight: 500; }
.prev .text { margin-top: var(--s-2); color: var(--muted); max-width: 68ch; overflow-wrap: anywhere; }

/* evidence */
.evidence { margin-top: var(--s-4); }
.evidence h3, .actions h3 { font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: 2px; }
.evidence > p { font-size: var(--fs-xs); color: var(--muted); margin-bottom: var(--s-2); }
.evtable { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.evtable th, .evtable td { text-align: left; padding: 5px var(--s-2); border-bottom: 1px solid var(--border); vertical-align: top; }
.evtable thead th { font-weight: 600; color: var(--ink-2); font-size: var(--fs-xs); }
.evtable tbody th { font-weight: 400; color: var(--muted); }
.evtable td { font-variant-numeric: tabular-nums; }
.evtable .na { color: var(--muted); font-style: italic; }

/* trace drawer */
.drawer { margin-top: var(--s-4); border-top: 1px solid var(--border); padding-top: var(--s-3); }
.drawer summary { font-weight: 600; font-size: 13px; }
.drawer summary .muted { font-weight: 400; }
.trace { margin-top: var(--s-2); max-height: 440px; overflow: auto; }
.trace h4 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: var(--s-3) 0 var(--s-1); }
.trace .calls { list-style: none; margin: 0 0 var(--s-2); padding: 0; }
.trace .calls li { display: flex; flex-wrap: wrap; gap: 4px var(--s-2); align-items: baseline; padding: 4px 0; border-bottom: 1px dashed var(--border); font-size: var(--fs-sm); }
.trace .calls code { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.trace .args { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; flex: 1 1 200px; }
.trace .q { margin: var(--s-2) 0 var(--s-3); }
.trace .qhead { font-size: var(--fs-xs); color: var(--muted); display: flex; gap: var(--s-2); flex-wrap: wrap; }
.trace .qhead b { color: var(--ink-2); font-family: var(--mono); font-weight: 600; }
.trace .params { font: var(--fs-xs)/1.45 var(--mono); color: var(--muted); overflow-wrap: anywhere; margin-top: 2px; }
.trace pre { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--border);
             padding: var(--s-2) var(--s-3); border-radius: var(--r-md); font: var(--fs-xs)/1.55 var(--mono); color: var(--ink); }

/* actions */
.actions { margin-top: var(--s-4); border-top: 1px solid var(--border); padding-top: var(--s-3); }
.actions .row { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.actout { margin-top: var(--s-2); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto;
          background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3); }
.actout:empty { display: none; }
.actout h4 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: var(--s-1); white-space: normal; }
.actout .err { color: var(--danger); }

/* ---------- graph ---------- */
.cywrap { position: relative; flex: 1; min-height: 280px; border-radius: var(--r-md); border: 1px solid var(--border); overflow: hidden;
          background-color: var(--g-bg); background-image: radial-gradient(var(--g-dot) 1px, transparent 1px); background-size: 18px 18px; }
.cy { position: absolute; inset: 0; }
.center:fullscreen { background: var(--surface); padding: var(--s-4); border-radius: 0; }
.center.is-max { position: fixed; inset: 0; z-index: 40; border-radius: 0; padding: var(--s-4); }
.layout .center.is-max { display: flex; height: auto; }   /* also on phones, where inactive tabs are hidden */
#graphmax[aria-pressed="true"] { color: var(--accent-text); }
.cyempty { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--s-6); text-align: center; color: var(--muted);
           font-size: 13px; pointer-events: none; }
.nodeinfo { margin-top: var(--s-2); padding: var(--s-2) var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.nihead { display: flex; align-items: center; gap: var(--s-2); }
.nihead strong { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.nihead .iconbtn { width: 26px; height: 26px; }
.nodeinfo dl { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--s-3); margin: 4px 0 0; }
.nodeinfo dt { color: var(--muted); }
.nodeinfo dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px var(--s-3); font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s-2); }
.lg::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.kep-ok::before { background: var(--kep-ok); } .kep-mid::before { background: var(--kep-mid); } .kep-no::before { background: var(--kep-no); }
.person::before { background: var(--person); } .team::before { background: var(--team); } .code::before { background: var(--code); }
.other::before { background: var(--other); }
.past::before { background: none; border-top: 1.5px dashed var(--muted); border-radius: 0; height: 0; width: 14px; vertical-align: 3px; }
.pathtext { margin-top: var(--s-2); font-size: var(--fs-sm); }
.pathtext summary { color: var(--muted); }
.pathtext ul { list-style: none; margin: var(--s-1) 0 0; padding: 0; max-height: 160px; overflow: auto; }
.pathtext li { padding: 2px 0; overflow-wrap: anywhere; }
.pathtext button { border: 0; background: none; padding: 2px 0; color: var(--accent-text); text-align: left; }
.pathtext button:hover { text-decoration: underline; }
.pathtext .rel { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); }

/* ---------- live feed ---------- */
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--other); display: inline-block; flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--warn); }
.democtl { margin-bottom: var(--s-2); padding-bottom: var(--s-3); border-bottom: 1px solid var(--border); }
.democtl p:not(:empty) { margin-top: var(--s-2); overflow-wrap: anywhere; }
.feed { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.feed li { padding: var(--s-2) var(--s-1); border-bottom: 1px solid var(--border); overflow-wrap: anywhere; border-radius: 4px; }
.feed li.new { animation: fadein 1.8s; }
.feed .when { color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; }
.feed .src { display: inline-block; font: 600 10px/16px var(--mono); letter-spacing: .03em; text-transform: uppercase; background: var(--surface-2);
             color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin-right: 6px; vertical-align: 1px; }
.feed:not(:empty) + .empty { display: none; }
.empty { margin-top: var(--s-3); }
@keyframes fadein { from { background: var(--warn-soft); } to { background: transparent; } }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent);
         color: var(--accent-ink); font-size: 10.5px; font-weight: 600; margin-left: 4px; }

/* ---------- atlas (whole-graph view) ---------- */
body[data-mode="atlas"] :is(#about, #replaybanner, #scenario, .tabs, #main) { display: none !important; }
.atlas { position: relative; height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); min-height: 480px; overflow: hidden;
         background-color: var(--atlas-bg); background-image: radial-gradient(var(--atlas-dot) 1px, transparent 1px); background-size: 22px 22px; }
.atlascanvas { position: absolute; inset: 0; }
.atlascanvas canvas { display: block; }
.atlas-status { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; pointer-events: none; }
.atlas-status:empty { display: none; }
.atlas-panel { position: absolute; z-index: 2; background: var(--atlas-panel); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
               border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-2); }
.atlas-controls { top: var(--s-3); left: var(--s-3); width: 268px; padding: var(--s-2) var(--s-3); }
.atlas-controls summary { display: flex; align-items: baseline; gap: var(--s-2); cursor: pointer; list-style: none; padding: 4px 0; }
.atlas-controls summary::-webkit-details-marker { display: none; }
.atlas-controls summary::after { content: "▾"; margin-left: auto; color: var(--muted); font-size: 11px; }
.atlas-controls:not([open]) summary::after { content: "▸"; }
.atlas-controls h2 { font-size: var(--fs-md); }
.atlas-controls summary .muted { font-size: var(--fs-xs); }
.atlas-body { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-2) 0 var(--s-1); }
.atlas-search { width: 100%; min-height: 32px; padding: 0 var(--s-2); border: 1px solid var(--border-strong); border-radius: var(--r-md);
                background: var(--surface); font-size: 13px; }
.atlas-layers { display: grid; grid-template-columns: 1fr 1fr; gap: 4px var(--s-2); margin: 0; padding: 0; border: 0; font-size: 13px; }
.atlas-layers legend { margin-bottom: 4px; padding: 0; }
.atlas-layers label { display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.atlas-layers input { margin: 0; accent-color: var(--accent); }
.atlas-layers .muted { font-size: var(--fs-xs); }
.sw { display: inline-block; flex: none; width: 9px; height: 9px; background: var(--ink-2); }
.sw-team { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 2px var(--atlas-bg), 0 0 0 3px var(--ink-2); }
.sw-kep { border-radius: 50%; }
.sw-code { transform: rotate(45deg) scale(.85); border-radius: 1px; }
.sw-person { border-radius: 50%; background: none; border: 2.5px solid var(--ink-2); }
.atlas-row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.atlas-row.tools .btn { flex: 1; justify-content: center; }
.atlas-controls .legend { margin-top: 0; }
.legend .swatch::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; background: var(--c); }
.atlas-time { left: 50%; bottom: var(--s-4); transform: translateX(-50%); width: min(760px, calc(100% - 2 * var(--s-3)));
              display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); }
.atlas-time .iconbtn { flex: none; color: var(--accent-text); }
.atlas-slider { position: relative; flex: 1; min-width: 0; padding-bottom: 14px; }
.atlas-slider input { width: 100%; margin: 0; accent-color: var(--accent); }
.atlas-ticks { position: absolute; left: 8px; right: 8px; bottom: 0; height: 14px; pointer-events: none; }
.atlas-ticks span { position: absolute; top: 0; transform: translateX(-50%); font: 10px/14px var(--mono); color: var(--muted); white-space: nowrap; }
.atlas-ticks span::before { content: ""; position: absolute; left: 50%; top: -5px; width: 1px; height: 4px; background: var(--border-strong); }
.atlas-date { flex: none; min-width: 74px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }
.atlas-card { top: var(--s-3); right: var(--s-3); width: 310px; max-height: calc(100% - 120px); overflow: auto; padding: var(--s-3) var(--s-4) var(--s-4); }
.atlas-card .nihead { margin-bottom: var(--s-1); }
.atlas-card .kind { flex: 1; font: 600 10px/16px var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.atlas-card h3 { font-size: var(--fs-lg); line-height: 1.35; overflow-wrap: anywhere; }
.atlas-card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px var(--s-3); margin: var(--s-3) 0; font-size: var(--fs-sm); }
.atlas-card dt { color: var(--muted); }
.atlas-card dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.atlas-card .row { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.atlas-card h4 { margin-top: var(--s-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.atlas-card .neigh { margin: var(--s-1) 0 0; padding: 0; list-style: none; font-size: var(--fs-sm); max-height: 180px; overflow: auto; }
.atlas-card .neigh button { border: 0; background: none; padding: 2px 0; color: var(--accent-text); text-align: left; overflow-wrap: anywhere; }
.atlas-card .neigh button:hover { text-decoration: underline; }
.atlas-card .neigh .rel { font: var(--fs-xs) var(--mono); color: var(--muted); margin-right: 6px; }
#viewpick label:has(input[value="atlas"]:checked) { color: var(--accent-text); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .tagline { display: none; }
}
@media (max-width: 1200px) {
  .layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: minmax(560px, calc(100dvh - var(--header-h) - 28px)) auto;
            height: auto; }
  .right { grid-column: 1 / -1; max-height: 380px; }
  .tiles { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .topbar { position: static; flex-wrap: wrap; gap: var(--s-2) var(--s-3); }
  .topright { margin-left: 0; width: 100%; justify-content: flex-start; }
  .fresh { order: 5; max-width: 100%; }
  .fresh #freshtext { white-space: normal; }
  .about { padding: var(--s-4); }
  .about-head { flex-direction: column; gap: var(--s-3); }
  .about h2 { font-size: 17px; }
  .tabs { display: flex; position: sticky; top: 0; z-index: 15; gap: 2px; padding: var(--s-2) var(--s-4); background: var(--bg); border-bottom: 1px solid var(--border); }
  .tabs button { flex: 1; min-height: 40px; border: 1px solid transparent; background: transparent; border-radius: var(--r-md); font-size: 13px; font-weight: 500; color: var(--muted); }
  .tabs button[aria-selected="true"] { background: var(--surface); border-color: var(--border); color: var(--ink); box-shadow: var(--shadow-1); }
  .layout { display: block; height: auto; min-height: 0; padding: var(--s-3) var(--s-4) var(--s-6); }
  .layout .panel { max-height: none; }
  .layout[data-view="answer"] > .panel:not(.left),
  .layout[data-view="graph"] > .panel:not(.center),
  .layout[data-view="live"] > .panel:not(.right) { display: none; }
  .center { height: calc(100dvh - 130px); min-height: 420px; }
  .tiles { grid-template-columns: 1fr; }
  .btn, select { min-height: 40px; }
  .iconbtn { width: 40px; height: 40px; }
  .seg label { width: 36px; height: 34px; }
  .seg.text label { width: auto; }
  .atlas { height: calc(100dvh - 24px); }
  .atlas-controls { right: var(--s-3); width: auto; }
  .atlas-card { top: auto; left: var(--s-3); right: var(--s-3); bottom: 96px; width: auto; max-height: 45%; }
  .atlas-ticks span:nth-child(even) { display: none; }
}
@media (max-width: 480px) {
  .scenario li:not(.active) span:not(.num) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .controls { gap: var(--s-2); }
  #askbtn { width: 100%; margin-left: 0; }
}

.theming *, .theming *::before, .theming *::after { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0s !important; }
  .loading::before, .btn .spin { animation: none; border-right-color: currentColor; opacity: .6; }
}
