:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #14202e; --muted: #5a6877; --line: #d9dee5; --accent: #2c6a7a;
  --good: #1b7a4b; --warn: #a15c00; --bad: #b3261e;
  --good-bg: #e3f3ea; --warn-bg: #fbefd9; --bad-bg: #fbe3e1; --track: #e7ebf0;
  --c0: #0072B2; --c1: #D55E00; --c2: #009E73; --c3: #CC79A7; --c4: #E69F00; --c5: #56B4E9;
  --command: #8f6c17; --command-soft: #efe3c3; --disp: "Saira", system-ui, -apple-system, "Segoe UI", sans-serif; --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 8px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10161d; --panel: #18212b; --ink: #e6ebf1; --muted: #9aa8b7; --line: #2c3946; --accent: #58a6ba;
    --command: #d4ad53; --command-soft: #2b2412;
    --good: #5fd09a; --warn: #f0b45a; --bad: #ff8f86;
    --good-bg: #143324; --warn-bg: #3a2c12; --bad-bg: #3d1a18; --track: #263340;
    --c0: #5aa9e6; --c1: #ff9a5c; --c2: #3ed6a4; --c3: #e69bc8; --c4: #f2c14e; --c5: #86ccf2;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
h1 { font-size: 1.25rem; margin: 0; } h2 { font-size: 1.05rem; margin: 0 0 .5rem; } h3 { font-size: .95rem; margin: 0 0 .4rem; }
h1, h2, h3, .tabs button, .hero .big, .hero .label { font-family: var(--disp); }
.num, output, .dtg { font-family: var(--mono); font-variant-numeric: tabular-nums; }
p { margin: .3rem 0; }
.top { display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; align-items: center; padding: 10px clamp(14px, 2vw, 22px);
       background: color-mix(in srgb, var(--panel) 86%, transparent); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
       position: sticky; top: 0; z-index: 30; }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
              background: linear-gradient(90deg, transparent, var(--accent) 22%, var(--command) 55%, transparent); opacity: .55; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.seal { font-family: var(--disp); font-weight: 700; letter-spacing: .16em; font-size: 1.15rem; white-space: nowrap; margin: 0; }
.seal .seal360 { font-style: normal; color: var(--command); letter-spacing: .08em; margin-left: .1rem; }
.brandtext { min-width: 0; }
.name { font-family: var(--disp); font-weight: 600; font-size: .98rem; line-height: 1.15; }
.sub, .tag { color: var(--muted); font-size: .76rem; }
.classif { background: repeating-linear-gradient(135deg, var(--command-soft) 0 12px, color-mix(in srgb, var(--command-soft) 70%, var(--bg)) 12px 24px);
           color: var(--command); border-bottom: 1px solid color-mix(in srgb, var(--command) 40%, transparent);
           font-family: var(--mono); font-size: .68rem; letter-spacing: .05em; text-align: center; padding: 4px 10px; }
.pack-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.pack-pick select { min-width: 0; max-width: 100%; flex: 1 1 220px; text-overflow: ellipsis; }
.top { min-width: 0; } .top > * { min-width: 0; max-width: 100%; }
label { font-size: .85rem; color: var(--muted); }
select, button, input[type=range] { font: inherit; }
select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); max-width: 100%; }
button { padding: 5px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; border: 1px solid var(--line); color: var(--muted); }
.chip:empty { display: none; }
.chip.good { color: var(--good); background: var(--good-bg); border-color: transparent; }
.chip.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.chip.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }

.mission { padding: 10px 20px 0; max-width: 1200px; margin: 0 auto; }
#mission { font-size: .95rem; }
details { margin-top: 6px; }
summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.whatif-body { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 8px; }
.row { display: flex; align-items: center; gap: 10px; margin: 6px 0; flex-wrap: wrap; }
.row label { min-width: 180px; }
.row input[type=range] { flex: 1; min-width: 160px; max-width: 360px; }
.hint { color: var(--muted); font-size: .8rem; }
output { color: var(--ink); font-weight: 600; margin-left: 4px; }

.tabs { display: flex; gap: 2px; padding: 0 20px; max-width: 1200px; margin: 8px auto 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 9px 14px; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
main { max-width: 1200px; margin: 0 auto; padding: 16px 20px 30px; outline: none; }
footer { max-width: 1200px; margin: 0 auto; padding: 0 20px 30px; color: var(--muted); font-size: .75rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.hero { display: flex; flex-wrap: wrap; gap: 18px 32px; align-items: center; }
.hero .big { font-size: 2.6rem; font-weight: 700; line-height: 1; }
.hero .label { color: var(--muted); font-size: .8rem; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
ul.findings { margin: 0; padding-left: 1.1rem; } ul.findings li { margin: .35rem 0; }
.altpick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.altpick button[aria-pressed=true] { background: var(--accent); color: var(--bg); border-color: var(--accent); }

table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; }
td.num { font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }

/* MOE tree */
.tree { font-size: .9rem; }
.node { display: grid; grid-template-columns: minmax(180px, 2.4fr) minmax(120px, 2fr) 74px; gap: 8px 12px; align-items: center;
        padding: 6px 4px; border-bottom: 1px solid var(--line); }
.node .name { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.node .sub { color: var(--muted); font-size: .76rem; width: 100%; }
.node.branch .name { font-weight: 600; }
.bar { position: relative; height: 12px; background: var(--track); border-radius: 6px; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; }
.bar > b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .55; }
.val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.lv-bad { background: var(--bad); } .lv-warn { background: var(--warn); } .lv-good { background: var(--good); }
.tag-s { font-size: .68rem; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.tag-s.crit { color: var(--bad); border-color: var(--bad); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); margin: 6px 0 10px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--c); }

svg text { fill: var(--ink); font-family: inherit; }
svg .muted { fill: var(--muted); }
svg .axis { stroke: var(--line); }
.chart { width: 100%; height: auto; display: block; }
.heat td { text-align: center; font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: .82rem; }
.err { color: var(--bad); }

.picks { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 12px; }
.pick { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); font-size: .9rem; cursor: pointer; }
.pick input { margin-top: 4px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input[type=file] { max-width: 100%; font: inherit; color: var(--ink); }
td .hint { text-align: left; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ask { max-width: 1200px; margin: 8px auto 0; padding: 0 20px; }
#ask-form { display: flex; gap: 8px; }
#ask-q { flex: 1; min-width: 0; padding: 9px 12px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); }
#ask-go { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.examples { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.examples button { font-size: .78rem; padding: 2px 10px; border-radius: 999px; color: var(--muted); }
.answer { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin: 8px 0; }
.answer p { white-space: pre-wrap; }
.answer .srcs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.answer .srcs button { font-size: .78rem; padding: 2px 10px; border-radius: 999px; }

.rec .rec-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.rec .rec-head h2 { margin: 0; flex: 1 1 260px; }
.rec.stale { border-left: 4px solid var(--bad); }
.recform { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 8px; }
.recform textarea, .row input[type=text] { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
.row input[type=text] { width: auto; flex: 1 1 180px; max-width: 280px; }
button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
button.srcbtn { font-size: .72rem; padding: 0 8px; border-radius: 999px; color: var(--muted); }

.rolebar { display: flex; gap: 8px 14px; align-items: center; flex-wrap: wrap; }
.rolebar select { min-width: 0; max-width: 100%; }
.chk { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: .85rem; }
.node.dim { opacity: .45; }
.node.mine { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tag-s.mineflag { color: var(--accent); border-color: var(--accent); }
.rolecard h2 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }

@media (max-width: 700px) { .seal .seal360 { display: none; } }

/* compact control strip: role, what-if and mission take one short band above the answer */
.mission p.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; margin: 0; color: var(--ink); }
.mission p.clamp.open { display: block; }
.strip { max-width: 1200px; margin: 6px auto 0; padding: 0 20px; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.strip details { margin: 0; } .strip details[open] { flex: 1 1 100%; }
.card.lead { border-left: 4px solid var(--accent); }
.more { font-size: .78rem; padding: 2px 10px; border-radius: 999px; border-style: dashed; color: var(--accent); }
.skip { position: absolute; left: 8px; top: -48px; z-index: 100; background: var(--accent); color: var(--bg); padding: 8px 14px; border-radius: 0 0 8px 8px; text-decoration: none; font-weight: 600; }
.skip:focus { top: 0; }

/* touch targets and keyboard focus */
button, select, summary { min-height: 30px; }
.examples button, button.srcbtn, .answer .srcs button, .more, .chip { min-height: 26px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
th[scope] { font-weight: 600; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (max-width: 640px) { button, select, summary { min-height: 40px; } .examples button, .more, button.srcbtn { min-height: 34px; } }

/* print: the analysis, not the controls */
@media print {
  .ask, .strip, .tabs, .skip, .rolebar, .altpick, .row button, .recform, .top::after { display: none !important; }
  .top { position: static; backdrop-filter: none; -webkit-backdrop-filter: none; }
  body { background: #fff; color: #000; } .card { break-inside: avoid; box-shadow: none; }
  .mission p.clamp { display: block; }
}

@media (max-width: 640px) {
  .strip { padding-left: 14px; padding-right: 14px; }
  .rolebar { padding-left: 14px; padding-right: 14px; }
  .ask { padding-left: 14px; padding-right: 14px; }
  .top, .mission, main, footer { padding-left: 14px; padding-right: 14px; }
  .node { grid-template-columns: 1fr 70px; } .node .bar { grid-column: 1 / -1; order: 3; }
  .hero .big { font-size: 2.1rem; }
}
