:root {
  --bg: #0B1020; --card: #141C34; --card2: #10172C; --line: #243052; --ink: #EEF2FA; --muted: #A3AEC7; --dim: #6F7C99;
  --accent: #F5A623; --teal: #3FD0B6; --error: #FF8A80; --accent-ink: #0B1020;
  --edge: #3A4A75; --node: #1A2442; --node-ink: #DCE3F2;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F6F7FB; --card: #FFFFFF; --card2: #EEF1F8; --line: #D7DDEB; --ink: #121829; --muted: #55607A; --dim: #7B86A0;
  --accent: #C77700; --teal: #0E8F7A; --error: #C2372C; --accent-ink: #FFFFFF;
  --edge: #B8C2DA; --node: #EEF1F8; --node-ink: #121829;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F6F7FB; --card: #FFFFFF; --card2: #EEF1F8; --line: #D7DDEB; --ink: #121829; --muted: #55607A; --dim: #7B86A0;
    --accent: #C77700; --teal: #0E8F7A; --error: #C2372C; --accent-ink: #FFFFFF;
    --edge: #B8C2DA; --node: #EEF1F8; --node-ink: #121829;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; }
code, pre, .mono { font-family: var(--mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.accent { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 10px 18px; font-weight: 650; }
button.ghost { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; color: var(--ink); }
button.ghost:hover, button.icon:hover { border-color: var(--muted); }
button.icon { background: transparent; border: 1px solid var(--line); border-radius: 8px; width: 36px; height: 36px; }
button.small { padding: 3px 9px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-bg { fill: var(--card); stroke: var(--line); }
.brand-x { stroke: var(--accent); stroke-width: 3.2; stroke-linecap: round; fill: none; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* landing */
.landing { max-width: 1080px; margin: 0 auto; padding: 48px 24px 24px; width: 100%; }
.eyebrow { text-transform: uppercase; letter-spacing: .09em; font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.hero h1 { font-size: clamp(30px, 5vw, 50px); line-height: 1.08; margin: 0 0 16px; letter-spacing: -.02em; font-weight: 750; }
.lead { font-size: 18px; color: var(--muted); max-width: 700px; margin: 0 0 28px; }
.drop { display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; text-align: center; border: 2px dashed var(--line); border-radius: 14px; padding: 40px 20px; background: var(--card); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); }
.drop-title { font-size: 18px; font-weight: 650; }
.drop-sub { color: var(--muted); font-size: 14px; max-width: 560px; }
.hero-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.error { color: var(--error); margin-top: 14px; }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 52px; }
.how > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.how h2 { font-size: 16px; margin: 0 0 8px; }
.how ol, .how ul { margin: 0; padding-left: 18px; }
.how li { margin: 4px 0; }
.how p { margin: 8px 0 0; }

/* app */
.app { width: 100%; max-width: 1440px; margin: 0 auto; padding: 22px 24px 8px; }
.verdict-head h1 { font-size: clamp(22px, 3vw, 30px); margin: 0 0 16px; letter-spacing: -.01em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-height: 108px; }
.tile:hover { border-color: var(--muted); }
.tile[aria-pressed="true"] { border-color: var(--accent); }
.tile .n { font: 700 30px/1.1 var(--sans); letter-spacing: -.02em; }
.tile .n small { font-size: 15px; color: var(--muted); font-weight: 600; }
.tile .t { color: var(--muted); font-size: 14px; }
.tile.warn .n { color: var(--error); }
.tile.ok .n { color: var(--teal); }
.tile.key .n { color: var(--accent); }
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 16px 0 6px; color: var(--muted); font-size: 13px; }
.stats b { color: var(--ink); font-family: var(--mono); font-weight: 600; }

.explorer { display: grid; grid-template-columns: 330px 1fr; gap: 16px; margin-top: 18px; align-items: start; }
.list-pane { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; position: sticky; top: 12px; }
.list-tools { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
input[type=search] { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 8px 10px; font: inherit; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); }
.mlist { list-style: none; margin: 0; padding: 4px 0; max-height: 640px; overflow: auto; }
.mlist li button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 14px; border-left: 3px solid transparent; }
.mlist li button:hover { background: var(--card2); }
.mlist li button[aria-current="true"] { border-left-color: var(--accent); background: var(--card2); }
.mlist .mn { display: block; font-weight: 600; font-size: 14px; }
.mlist .mt { display: flex; gap: 6px; align-items: center; color: var(--dim); font-size: 12px; margin-top: 2px; flex-wrap: wrap; }
.flag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.flag.bad { border-color: color-mix(in srgb, var(--error) 55%, transparent); color: var(--error); }
.mlist .empty { padding: 16px; color: var(--muted); font-size: 14px; }

.detail-pane { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.lineage-wrap, .dax-wrap, .facts, .plain-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.lineage-head { padding: 14px 18px 0; }
.lineage-head h2 { margin: 0; font-size: 20px; }
.lineage-head p { margin: 2px 0 0; font-size: 14px; }
.lineage-scroll { overflow-x: auto; padding: 8px 6px 4px; }
#lineage { display: block; }
#lineage .edge { fill: none; stroke: var(--edge); stroke-width: 1.4; }
#lineage .edge.hot { stroke: var(--accent); stroke-width: 1.8; }
#lineage .node rect { fill: var(--node); stroke: var(--line); }
#lineage .node text { fill: var(--node-ink); font: 12.5px var(--sans); }
#lineage .node .k { fill: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
#lineage .node.src rect { fill: transparent; stroke: var(--muted); stroke-dasharray: 3 3; }
#lineage .node.col rect { fill: var(--card2); }
#lineage .node.vis rect { fill: transparent; stroke: var(--teal); }
#lineage .node.sel rect { fill: var(--accent); stroke: var(--accent); }
#lineage .node.sel text { fill: var(--accent-ink); font-weight: 700; }
#lineage .node.warn rect { stroke: var(--error); stroke-width: 1.6; }
#lineage .node.click { cursor: pointer; }
#lineage .node.click:hover rect { stroke: var(--accent); }
#lineage .colhead { fill: var(--dim); font: 11px var(--sans); text-transform: uppercase; letter-spacing: .08em; }
#lineage .more text { fill: var(--dim); font: 12px var(--sans); }
.draw .edge { stroke-dasharray: 600; stroke-dashoffset: 600; animation: draw .9s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .draw .edge { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 4px 18px 14px; font-size: 12.5px; color: var(--muted); }
.lg { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--line); background: var(--node); }
.lg.src { background: transparent; border: 1px dashed var(--muted); }
.lg.col { background: var(--card2); }
.lg.sel { background: var(--accent); border-color: var(--accent); }
.lg.vis { background: transparent; border-color: var(--teal); }
.lg.warn { border: 1.6px solid var(--error); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0; }
.fact { padding: 14px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fact h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.fact p { margin: 0; }
.fact .big { font: 700 22px/1.2 var(--sans); }
.fact .bad { color: var(--error); }
.fact .good { color: var(--teal); }
.fact ul { margin: 4px 0 0; padding-left: 16px; font-size: 14px; }
.fact .linkish { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.dax-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px 0; }
.dax-head h3 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.dax { margin: 0; padding: 12px 18px 16px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.6; }
.dax .fn { color: var(--ink); font-weight: 700; }
.dax .mref { color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.dax .cref { color: var(--teal); }
.dax .str, .dax .num { color: var(--muted); }
.dax .hc { color: var(--error); background: color-mix(in srgb, var(--error) 14%, transparent); border-radius: 3px; }
.dax .cmt { color: var(--dim); font-style: italic; }

.tabs-wrap { margin-top: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 12px 16px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab-body { padding: 6px 0 10px; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { text-align: left; padding: 8px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
table.grid td.mono { font-size: 13px; word-break: break-all; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.bad { border-color: var(--error); color: var(--error); }
.pill.good { border-color: var(--teal); color: var(--teal); }
.note { padding: 8px 16px; color: var(--muted); font-size: 13.5px; margin: 0; }

.foot { margin-top: auto; padding: 22px 24px; border-top: 1px solid var(--line); color: var(--dim); font-size: 13px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .how { grid-template-columns: 1fr; }
  .explorer { grid-template-columns: 1fr; }
  .list-pane { position: static; }
  .mlist { max-height: 300px; }
  .top, .landing, .app, .foot { padding-left: 16px; padding-right: 16px; }
}

.plain { list-style: none; margin: 0; padding: 10px 18px 16px; font-size: 16px; line-height: 1.7; }
.plain li + li { margin-top: 4px; }
.plain .mref { color: var(--accent); cursor: pointer; font-weight: 600; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.plain .cref { color: var(--teal); font-weight: 600; }
.plain .cref small { color: var(--muted); font-weight: 400; font-size: 12px; margin-right: 3px; }
.plain .str { font-family: var(--mono); font-size: 14px; color: var(--ink); }
.plain .hc { font-family: var(--mono); font-size: 14px; color: var(--error); background: color-mix(in srgb, var(--error) 14%, transparent); border-radius: 3px; padding: 0 3px; }
.plain .var { font-family: var(--mono); font-size: 14px; color: var(--muted); }
.plain li.sub { position: relative; font-size: 15px; line-height: 1.6; padding-left: 22px; }
.plain li.sub::before { content: ''; position: absolute; left: 8px; top: 0.75em; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.plain li.sub + li.sub { margin-top: 2px; }
.plain li.d2 { padding-left: 44px; } .plain li.d2::before { left: 30px; }
.plain li.d3 { padding-left: 66px; } .plain li.d3::before { left: 52px; }
.plain .fallback { color: var(--muted); font-size: 14px; }
