:root {
  --bg: #0b0d10;
  --panel: #11151a;
  --panel-2: #151b22;
  --line: #27303a;
  --line-strong: #3a4653;
  --text: #f4f7f8;
  --muted: #99a6b2;
  --soft: #c7d0d6;
  --accent: #9de8d1;
  --accent-2: #b6c7ff;
  --warm: #f2c17f;
  --danger: #ffaaa5;
  --ok: #a7efb5;
  --focus: #ffffff;
  --shadow: 0 18px 56px rgba(0,0,0,.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
button, input, select { font: inherit; }
button, select, input { outline: none; }
button:focus-visible, select:focus-visible, input:focus-visible, [tabindex]:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.skip { position: fixed; left: 10px; top: -60px; z-index: 50; padding: 10px 14px; background: var(--text); color: var(--bg); border-radius: 8px; }
.skip:focus { top: 10px; }
.topbar { min-height: 72px; padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 91%, transparent); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; border: 1px solid var(--line-strong); background: linear-gradient(145deg, var(--panel-2), var(--panel)); color: var(--accent); font-weight: 800; }
.eyebrow, .section-label, .card-kicker { font-size: 10px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); font-weight: 760; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 16px; margin-bottom: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
h2 { font-size: 18px; margin-bottom: 6px; }
h3 { font-size: 15px; margin-bottom: 6px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.badge { border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 10px; font-size: 11px; white-space: nowrap; }
.badge.ok { border-color: color-mix(in srgb, var(--ok) 60%, var(--line)); color: var(--ok); }
.badge.fail { border-color: color-mix(in srgb, var(--danger) 60%, var(--line)); color: var(--danger); }
.badge.pending { color: var(--muted); }
.notice { padding: 7px 18px; border-bottom: 1px solid var(--line); color: var(--soft); background: #10161a; font-size: 12px; }
.notice strong { color: var(--warm); }
.shell { display: grid; grid-template-columns: 220px minmax(620px, 1fr) 300px; min-height: calc(100vh - 108px); }
.control-rail, .inspector { background: var(--panel); padding: 16px; }
.control-rail { border-right: 1px solid var(--line); position: sticky; top: 108px; height: calc(100vh - 108px); overflow: auto; }
.inspector { border-left: 1px solid var(--line); position: sticky; top: 108px; height: calc(100vh - 108px); overflow: auto; }
.control-rail label { display: block; margin: 10px 0; }
.control-rail label > span { display: block; color: var(--soft); font-size: 11px; margin-bottom: 5px; }
input, select { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px; font-size: 12px; }
.preset-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 10px 0 22px; }
.chip { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 7px; padding: 6px 4px; cursor: pointer; font-size: 11px; }
.chip.active, .chip:hover { background: var(--panel-2); color: var(--text); border-color: var(--line-strong); }
.story { display: grid; gap: 6px; margin-top: 8px; }
.story-item { display: grid; grid-template-columns: 30px 1fr; gap: 0 8px; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; color: var(--muted); padding: 8px; border-radius: 9px; cursor: pointer; }
.story-item span { grid-row: 1 / 3; font-variant-numeric: tabular-nums; color: #667481; font-size: 11px; padding-top: 2px; }
.story-item b { color: var(--soft); font-size: 12px; }
.story-item small { font-size: 10px; }
.story-item:hover, .story-item.active { border-color: var(--line); background: var(--panel-2); color: var(--muted); }
.story-item.active b { color: var(--accent); }
.workspace { min-width: 0; padding: 16px; background: radial-gradient(circle at 50% -20%, #17202a 0, transparent 42%); }
.canvas-head, .impact-head, .dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.meta-line { color: var(--muted); font-size: 11px; text-align: right; }
.graph-wrap { position: relative; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, #0e1217, #0b0e12); min-height: 470px; box-shadow: var(--shadow); overflow: hidden; }
.graph-wrap::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.027) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.027) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(to bottom, black, transparent 92%); }
#graph { width: 100%; min-height: 470px; display: block; }
.edge { stroke: #52606d; stroke-width: 1.25; opacity: .72; fill: none; }
.edge.highlight { stroke: var(--accent); stroke-width: 2.3; opacity: 1; }
.node { cursor: pointer; }
.node circle, .node rect { fill: #111820; stroke: #546170; stroke-width: 1.25; }
.node:hover circle, .node:hover rect, .node:focus circle, .node:focus rect { stroke: var(--focus); stroke-width: 2; }
.node.authority rect { fill: #15221f; stroke: #5b9686; }
.node.interpretation rect { fill: #1c1b25; stroke: #7771a8; }
.node.obligation rect { fill: #221c16; stroke: #9b805d; }
.node.company circle { fill: #171e29; stroke: #6d82ae; }
.node text { fill: var(--text); font-size: 12px; font-weight: 650; pointer-events: none; }
.node .sub { fill: var(--muted); font-size: 9px; font-weight: 500; }
.legend { position: absolute; left: 12px; bottom: 10px; display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 10px; background: rgba(10,13,16,.82); border: 1px solid var(--line); padding: 6px 8px; border-radius: 8px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--line-strong); }
.dot.authority { background: #5b9686; } .dot.interpretation { background: #7771a8; } .dot.obligation { background: #9b805d; } .dot.company { background: #6d82ae; }
.impact-strip { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: var(--panel); }
.impact-head select { width: min(360px, 52%); }
.impact-path { list-style: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; padding: 0; margin: 12px 0 0; }
.impact-path li { min-width: 0; padding: 9px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: 10px; color: var(--muted); position: relative; }
.impact-path li:not(:last-child)::after { content: "→"; position: absolute; right: -8px; top: 50%; transform: translateY(-50%); z-index: 2; color: var(--accent); }
.impact-path strong { display: block; color: var(--text); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-deck { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.action-card { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 13px; min-height: 240px; }
.action-card p { color: var(--muted); font-size: 11px; min-height: 48px; }
.button-row { display: flex; gap: 7px; flex-wrap: wrap; }
.button, .icon-button { border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 13%, var(--panel-2)); color: var(--text); border-radius: 8px; padding: 7px 10px; cursor: pointer; font-size: 11px; font-weight: 650; }
.button:hover { border-color: var(--accent); }
.button.secondary { background: var(--panel-2); border-color: var(--line); }
.button.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: color-mix(in srgb, var(--danger) 9%, var(--panel-2)); }
.button:disabled { opacity: .5; cursor: progress; }
.result { margin: 11px 0 0; min-height: 90px; max-height: 170px; overflow: auto; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #090c10; color: #cbd7de; font: 10px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.runtime-grid { display: grid; gap: 6px; margin-top: 10px; }
.runtime-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; border-top: 1px solid var(--line); padding-top: 6px; font-size: 10px; color: var(--muted); }
.runtime-row strong { color: var(--soft); }
.runtime-cell { border-top: 1px solid var(--line); padding-top: 7px; display: grid; gap: 3px; font-size: 10px; color: var(--muted); }
.runtime-cell-top { display: flex; justify-content: space-between; gap: 8px; }
.runtime-cell-top strong { color: var(--soft); }
.runtime-status { color: var(--muted); }
.runtime-cell small { color: var(--muted); }
.fact { display: grid; grid-template-columns: 92px 1fr; gap: 8px; border-top: 1px solid var(--line); padding: 7px 0; }
.fact span { color: var(--muted); }
.fact strong { color: var(--soft); font-weight: 650; word-break: break-word; }
.mini-code { white-space: pre-wrap; word-break: break-word; font: 10px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; background: color-mix(in srgb, var(--panel-2) 75%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow: auto; }
.error-text { color: var(--danger); }
.acceptance-summary { border: 1px solid var(--line); border-radius: 9px; padding: 9px; font-weight: 800; }
.acceptance-summary.pass { color: var(--ok); }
.acceptance-summary.fail { color: var(--danger); }
.acceptance-row { display: grid; grid-template-columns: 52px 1fr; gap: 8px; border-top: 1px solid var(--line); padding: 8px 0; font-size: 11px; }
.acceptance-row.pass span { color: var(--ok); }
.acceptance-row.fail span { color: var(--danger); }
.acceptance-row small { grid-column: 2; color: var(--muted); }
.runtime-version { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent-2); }
.inspector h2 { margin-top: 6px; }
.decision { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 10px 0 13px; font-size: 11px; font-weight: 700; }
.decision.allow, .decision.allowed { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.decision.refuse, .decision.refused { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.decision.neutral { color: var(--muted); }
.inspector-body { font-size: 11px; color: var(--muted); }
.inspector-body dl { margin: 0; }
.inspector-body dt { color: var(--soft); margin-top: 10px; font-weight: 700; }
.inspector-body dd { margin: 2px 0 0; word-break: break-word; }
.evidence-rule { height: 1px; background: var(--line); margin: 18px 0; }
.boundary-list { padding-left: 17px; color: var(--muted); font-size: 10px; }
.boundary-list li { margin-bottom: 8px; }
.dialog { border: 1px solid var(--line-strong); border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); width: min(720px, 92vw); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0,0,0,.7); }
.dialog-inner { padding: 16px; }
.icon-button { width: 32px; height: 32px; padding: 0; font-size: 20px; }
.acceptance-results { margin-top: 14px; display: grid; gap: 5px; }
.acceptance-item { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding: 7px 0; color: var(--muted); font-size: 11px; }
.acceptance-item b.pass { color: var(--ok); } .acceptance-item b.fail { color: var(--danger); }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 205px minmax(560px, 1fr); }
  .inspector { grid-column: 1 / -1; position: static; height: auto; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .topbar { position: static; align-items: flex-start; }
  .top-actions { flex-direction: column; align-items: flex-end; }
  .shell { display: block; }
  .control-rail, .inspector { position: static; height: auto; border: 0; border-bottom: 1px solid var(--line); }
  .story { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .workspace { padding: 10px; }
  .action-deck { grid-template-columns: 1fr; }
  .impact-path { grid-template-columns: 1fr 1fr; }
  .impact-path li::after { display: none; }
  .graph-wrap, #graph { min-height: 410px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media (prefers-color-scheme: light) {
  :root { --bg:#f4f5f6; --panel:#ffffff; --panel-2:#f2f4f6; --line:#d8dde2; --line-strong:#aeb8c1; --text:#101418; --muted:#58636e; --soft:#313a43; --focus:#111; --shadow:0 16px 44px rgba(30,40,50,.11); }
  .notice { background:#f8f6ef; }
  .workspace { background: radial-gradient(circle at 50% -20%, #e8eef4 0, transparent 42%); }
  .graph-wrap { background: linear-gradient(180deg,#fff,#f6f8f9); }
  .result { background:#f4f6f8; color:#26323a; }
  .legend { background:rgba(255,255,255,.88); }
  .node text { fill:#101418; }
}
