/* Studio Semantic knowledge base.
   Tokens follow the Semantic Runway brand: Geist, ink #111, rule #e8e8e8, accent #3b4bff, black dark theme. */

@font-face { font-family: "Geist"; src: url("fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f2f2f2;
  --ink: #111111;
  --ink-2: #333333;
  --muted: #6b6b6b;
  --rule: #e8e8e8;
  --rule-strong: #d2d2d2;
  --accent: #3b4bff;
  --accent-text: #2a39e0;
  --accent-soft: rgba(59, 75, 255, 0.09);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 28px rgba(0, 0, 0, 0.08);

  /* Graph families */
  --f-history: #8a8a8a;
  --f-problem: #e5484d;
  --f-evidence: #c98500;
  --f-strength: #a23fc4;
  --f-choice: #3b4bff;
  --f-move: #008f6b;

  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --top: 60px;
  --side: 264px;
  --rail: 248px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #151515;
  --ink: #ededed;
  --ink-2: #cdcdcd;
  --muted: #9a9a9a;
  --rule: #222222;
  --rule-strong: #383838;
  --accent-text: #8d97ff;
  --accent-soft: rgba(91, 107, 255, 0.18);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  --f-problem: #e5636a;
  --f-evidence: #b98a14;
  --f-strength: #b866d6;
  --f-choice: #5b6bff;
  --f-move: #1fa37d;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { display: block; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }
kbd { font: 500 11px/1 var(--mono); color: var(--muted); border: 1px solid var(--rule-strong); border-radius: 4px; padding: 3px 5px; background: var(--bg); }

.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 6px; }
.skip:focus { top: 10px; }

.label { font: 500 11px/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- Password page ---------- */
body.locked > .skip, body.locked > .top, body.locked > main { display: none; }
.gate { height: 100vh; height: 100dvh; overflow-y: auto; display: grid; place-items: center; padding: 32px 20px; }
.gate.checking { visibility: hidden; }
.gate-box { width: 100%; max-width: 340px; padding-bottom: 6vh; }
.gate .logo { width: 156px; margin-bottom: 40px; }
.gate h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.03em; font-weight: 600; margin: 8px 0 6px; }
.gate-note { color: var(--muted); font-size: 14.5px; }
.gate form { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--ink); }
.gate label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 7px; }
.gate-field { display: flex; align-items: center; height: 46px; border: 1px solid var(--rule-strong); border-radius: 8px; padding-right: 5px; transition: border-color .14s, box-shadow .14s; }
.gate-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gate-field:has(input[aria-invalid="true"]) { border-color: var(--f-problem); }
.gate-field input { flex: 1; min-width: 0; height: 100%; padding: 0 12px; border: 0; outline: 0; background: transparent; font-size: 16px; }
.gate-field button { height: 34px; padding: 0 10px; border-radius: 6px; font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.gate-field button:hover { color: var(--ink); background: var(--surface-2); }
.gate-error { min-height: 22px; margin: 6px 0 8px; font-size: 13px; color: var(--ink); }
.gate-error:not(:empty)::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; background: var(--f-problem); }
.gate .btn { width: 100%; min-height: 46px; font-size: 14.5px; }
.gate .btn:disabled { cursor: progress; }

/* ---------- Header ---------- */
.top { height: var(--top); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--rule); position: relative; z-index: 20; background: var(--bg); }
/* Crosshair where the header rule meets the sidebar rule, as on the Runway site */
.top::after { content: ""; position: absolute; left: calc(var(--side) - 5px); bottom: -5px; width: 9px; height: 9px; pointer-events: none;
  background: linear-gradient(var(--muted), var(--muted)) center / 1px 100% no-repeat, linear-gradient(var(--muted), var(--muted)) center / 100% 1px no-repeat; }
body.is-graph .top::after { display: none; }
.top-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; min-height: 40px; }
.logo { width: 104px; height: auto; fill: currentColor; flex: none; }
.brand-sub { font: 500 11px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding-left: 14px; border-left: 1px solid var(--rule-strong); white-space: nowrap; }

.switch { display: flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 10px; }
.switch a { display: flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 16px; border-radius: 7px; text-decoration: none; font-weight: 500; font-size: 14px; color: var(--muted); transition: color .14s, background-color .14s; }
.switch a:hover { color: var(--ink); }
.switch a[aria-current="page"] { background: var(--bg); color: var(--ink); box-shadow: 0 0 0 1px var(--rule), 0 1px 2px rgba(0,0,0,.06); }
:root[data-theme="dark"] .switch a[aria-current="page"] { background: #2a2a2a; box-shadow: none; }

.switch svg, .top-tools svg, .icon-btn svg, .palette-in svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.top-tools { display: flex; justify-content: flex-end; align-items: center; gap: 8px; min-width: 0; }
.search-btn { display: flex; align-items: center; gap: 9px; height: 38px; width: 100%; max-width: 300px; padding: 0 8px 0 11px; border: 1px solid var(--rule); border-radius: 8px; color: var(--muted); font-size: 13.5px; transition: border-color .14s; }
.search-btn:hover { border-color: var(--rule-strong); color: var(--ink); }
.search-btn span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; flex: none; }
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; }
:root[data-theme="light"] .sun, :root[data-theme="dark"] .moon { display: none; }

main { height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); position: relative; }

/* ---------- Document view ---------- */
.doc { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); height: 100%; }
.sidebar { border-right: 1px solid var(--rule); overflow-y: auto; padding: 22px 12px 40px; overscroll-behavior: contain; background: var(--bg); }
.sidebar .label { padding: 0 10px 8px; }
.page-link { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 6px; text-decoration: none; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.page-link:hover { background: var(--surface-2); }
.page-link[aria-current="page"] { background: var(--ink); color: var(--bg); }
.page-link small { font: 400 11px/1 var(--mono); opacity: .6; white-space: nowrap; }
.sections { list-style: none; padding: 6px 0 12px; margin: 0 0 0 16px; border-left: 1px solid var(--rule); }
.sections a { display: block; padding: 4px 10px 4px 12px; margin-left: -1px; border-left: 1px solid transparent; text-decoration: none; font-size: 13px; line-height: 1.45; color: var(--muted); }
.sections a:hover { color: var(--ink); }
.sections a.sub { padding-left: 24px; }
.sections a.on { color: var(--accent-text); border-left-color: var(--accent); }

.reader { overflow-y: auto; scroll-behavior: smooth; }
.reader-grid { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail); gap: 40px; max-width: 1360px; margin: 0 auto; padding: 0 28px 0 48px; }
.article { min-width: 0; width: 100%; max-width: 980px; margin: 0 auto; padding: 44px 0 120px; }

.doc-head { padding-bottom: 28px; margin-bottom: 8px; border-bottom: 1px solid var(--rule); }
.doc-head h1 { font-size: clamp(30px, 3.4vw, 44px); line-height: 1.08; letter-spacing: -0.035em; font-weight: 600; margin: 10px 0 14px; text-wrap: balance; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font: 400 12px/1.5 var(--mono); color: var(--muted); }

.body h2 { font-size: 25px; line-height: 1.22; letter-spacing: -0.022em; font-weight: 600; margin: 56px 0 14px; text-wrap: balance; }
.body h3 { font-size: 17px; line-height: 1.35; letter-spacing: -0.01em; font-weight: 600; margin: 32px 0 10px; }
.body h2, .body h3 { scroll-margin-top: 20px; }
.body h2 + h3 { margin-top: 20px; }
.body p, .body ul, .body ol { max-width: 70ch; }
.body p { margin: 0 0 14px; color: var(--ink-2); }
.body strong { font-weight: 600; color: var(--ink); }
.body a { color: var(--accent-text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); overflow-wrap: anywhere; }
.body a:hover { text-decoration-color: currentColor; }
.body ul, .body ol { padding-left: 20px; margin: 0 0 18px; color: var(--ink-2); }
.body li { margin: 5px 0; padding-left: 4px; }
.body li::marker { color: var(--muted); }
.body li p { margin: 0; }
.body ul.tasks { list-style: none; padding-left: 0; max-width: 76ch; }
.body ul.tasks li { padding: 8px 0; margin: 0; border-bottom: 1px solid var(--rule); }
.body ul.tasks p { display: flex; gap: 12px; align-items: flex-start; }
.body input[type="checkbox"] { appearance: none; flex: none; width: 16px; height: 16px; margin: 4px 0 0; border: 1.5px solid var(--rule-strong); border-radius: 4px; }
.body input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--bg); }
.body time { font-family: var(--mono); font-size: .9em; white-space: nowrap; }

.heading-graph { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; margin-left: 12px; padding: 4px 10px 4px 8px; border: 1px solid var(--rule); border-radius: 99px; font: 500 11px/1.3 var(--mono); letter-spacing: 0; color: var(--muted); text-decoration: none !important; white-space: nowrap; transition: border-color .14s, color .14s; }
.body a.heading-graph { color: var(--muted); }
.body a.heading-graph:hover { color: var(--accent-text); border-color: var(--accent); }
.heading-graph svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.flash { animation: flash 2.2s var(--ease); }
@keyframes flash { 0%, 40% { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); } 100% { background: transparent; box-shadow: 0 0 0 6px transparent; } }
tr.flash { box-shadow: none; }

/* Tables */
.table { margin: 20px 0 28px; }
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
.table-tools input { height: 34px; width: 230px; max-width: 100%; padding: 0 11px; border: 1px solid var(--rule); border-radius: 7px; background: var(--bg); font-size: 13.5px; }
.table-tools input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.seg { display: flex; border: 1px solid var(--rule); border-radius: 7px; padding: 2px; gap: 2px; }
.seg button { padding: 0 10px; height: 28px; border-radius: 5px; font-size: 12.5px; color: var(--muted); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 500; }
.row-count { margin-left: auto; font: 400 12px/1 var(--mono); color: var(--muted); }
.table-scroll { overflow-x: auto; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.table.fits .table-scroll { overflow: visible; }
.body table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; line-height: 1.5; }
.body th { text-align: left; font: 500 11px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 14px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: bottom; background: var(--bg); }
.table.fits th { position: sticky; top: 0; z-index: 2; }
.body th button { display: inline-flex; gap: 5px; align-items: center; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; text-align: left; }
.body th button:hover { color: var(--ink); }
.body th button::after { content: "↕"; opacity: 0; }
.body th button:hover::after, .body th button:focus-visible::after { opacity: .6; }
.body th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; }
.body th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; }
.body th[aria-sort] { color: var(--ink); }
.body td { padding: 11px 14px 11px 0; vertical-align: top; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
.body tbody tr:last-child td { border-bottom: 0; }
.body tbody tr:hover td { background: var(--surface); }
.body td:first-child { color: var(--ink); font-weight: 500; min-width: 120px; }
.body td:first-child, .body th:first-child { padding-left: 4px; }
.table.wide table { min-width: 760px; }
.empty-row { padding: 20px 4px; color: var(--muted); font-size: 13.5px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; line-height: 1; padding: 5px 8px; border-radius: 99px; border: 1px solid var(--rule-strong); white-space: nowrap; color: var(--ink-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.pill.high::before { background: var(--f-move); }
.pill.medium::before { background: var(--f-evidence); }
.pill.low::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.pill.partner::before { background: var(--f-choice); }
.fit-note { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.status { display: inline-block; font: 500 11.5px/1 var(--mono); padding: 5px 7px; border-radius: 5px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 72px; }
.pager a { display: block; padding: 16px 18px; border: 1px solid var(--rule); border-radius: 8px; text-decoration: none; font-weight: 500; transition: border-color .14s; }
.pager a:hover { border-color: var(--ink); }
.pager a.next { grid-column: 2; text-align: right; }

.rail { position: sticky; top: 0; align-self: start; max-height: calc(100vh - var(--top)); max-height: calc(100dvh - var(--top)); overflow-y: auto; padding: 48px 0 40px; font-size: 13px; }
.rail .label { margin-bottom: 6px; }
.rail-graph { border-top: 1px solid var(--ink); padding-top: 14px; }
.rail-title { font-weight: 600; font-size: 14px; line-height: 1.4; margin-bottom: 10px; }
.rail-note { color: var(--muted); }

.node-list { list-style: none; padding: 0; margin: 0; }
.node-list a, .node-list button { display: flex; gap: 9px; align-items: flex-start; width: calc(100% + 12px); margin: 0 -6px; padding: 5px 6px; border-radius: 6px; text-decoration: none; text-align: left; color: var(--ink-2); line-height: 1.45; }
.node-list a:hover, .node-list button:hover { background: var(--surface-2); color: var(--ink); }
.node-list small { color: var(--muted); font-size: .92em; }
.shape { width: 11px; height: 11px; flex: none; margin-top: .28em; overflow: visible; }
.more { margin-top: 6px; font: 500 12px/1.4 var(--mono); color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px; border: 1px solid var(--rule-strong); border-radius: 8px; font-size: 13.5px; font-weight: 500; text-decoration: none; background: var(--bg); transition: border-color .14s, transform .09s; }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn:disabled { opacity: .4; cursor: default; }
.rail-graph .btn { margin-top: 12px; width: 100%; }

/* ---------- Graph view ---------- */
.graph { position: absolute; inset: 0; overflow: hidden; background: var(--bg) radial-gradient(var(--rule-strong) 1px, transparent 1px) 0 0 / 24px 24px; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
#canvas.panning { cursor: grabbing; }
.edge { fill: none; stroke: var(--ink); stroke-opacity: .13; stroke-width: 1; vector-effect: non-scaling-stroke; transition: stroke-opacity .16s; }
.edge.hot { stroke: var(--accent); stroke-opacity: .95; stroke-width: 1.6; }
.edge.dim { stroke-opacity: .035; }
.edge-label { font: 500 11px var(--mono); fill: var(--accent-text); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; text-anchor: middle; }
.node { cursor: pointer; outline: none; transition: opacity .16s; }
.node .mark { stroke: var(--bg); stroke-width: 1.5; }
.node .hit { fill: transparent; }
.node .ring { fill: none; stroke: transparent; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.node:hover .ring { stroke: var(--rule-strong); }
.node.sel .ring { stroke: var(--ink); stroke-width: 2; }
.node.near .ring { stroke: var(--accent); }
.node:focus-visible .ring { stroke: var(--accent); stroke-width: 3; }
.node text { font-family: var(--sans); font-weight: 450; fill: var(--ink); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.node.sel text { font-weight: 650; }
.node.dim { opacity: .13; }
.col-head { font-family: var(--mono); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; fill: var(--muted); paint-order: stroke; stroke: var(--bg); stroke-width: 5px; }
.col-rule { stroke: var(--rule-strong); vector-effect: non-scaling-stroke; }

.panel { position: absolute; background: var(--bg); border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow); }
.controls { left: 16px; top: 16px; width: 236px; max-height: calc(100% - 92px); display: flex; flex-direction: column; font-size: 13px; z-index: 3; }
.controls-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 14px; }
.controls-head button { min-width: 30px; height: 30px; border-radius: 6px; color: var(--muted); font-size: 16px; }
.controls-head button:hover { background: var(--surface-2); color: var(--ink); }
.controls-body { overflow-y: auto; padding: 0 14px 14px; border-top: 1px solid var(--rule); overscroll-behavior: contain; }
.controls-body .label { margin: 16px 0 8px; display: flex; justify-content: space-between; gap: 8px; }
.controls-body .label button { font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--accent-text); }
.controls .seg { width: 100%; }
.controls .seg button { flex: 1; }
.kinds { list-style: none; padding: 0; margin: 0; }
.kinds button { display: flex; align-items: center; gap: 9px; width: calc(100% + 12px); margin: 0 -6px; padding: 4px 6px; border-radius: 6px; text-align: left; }
.kinds button:hover { background: var(--surface-2); }
.kinds .shape { margin: 0; }
.kinds .n { margin-left: auto; font: 400 11px var(--mono); color: var(--muted); }
.kinds button[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.kinds button[aria-pressed="false"] .shape { opacity: .25; }
.stories { list-style: none; padding: 0; margin: 0; }
.stories button { display: flex; justify-content: space-between; gap: 8px; width: calc(100% + 12px); margin: 0 -6px; padding: 5px 6px; border-radius: 6px; text-align: left; }
.stories button:hover { background: var(--surface-2); }
.stories button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 500; }
.stories span:last-child { font: 400 11px/1.8 var(--mono); color: var(--muted); }
.controls-open { position: absolute; left: 16px; top: 16px; z-index: 3; box-shadow: var(--shadow); }
.controls:not([hidden]) ~ .controls-open { display: none; }

.zoom { position: absolute; left: 16px; bottom: 16px; display: flex; background: var(--bg); border: 1px solid var(--rule); border-radius: 9px; overflow: hidden; z-index: 2; }
.zoom button { width: 40px; height: 38px; font-size: 18px; }
.zoom button.wide { width: auto; padding: 0 14px; font-size: 13px; font-weight: 500; }
.zoom button + button { border-left: 1px solid var(--rule); }
.zoom button:hover { background: var(--surface-2); }

.focusbar { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px); padding: 7px 7px 7px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 13px; z-index: 4; box-shadow: var(--shadow); white-space: nowrap; }
.focusbar span { overflow: hidden; text-overflow: ellipsis; }
.focusbar .btn { min-height: 30px; padding: 0 10px; background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 30%, transparent); }
.focusbar .btn:hover { border-color: var(--bg); }

.inspector { position: absolute; right: 16px; top: 16px; bottom: 16px; width: 348px; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow); padding: 18px 20px 24px; z-index: 5; }
.inspector.closed { bottom: auto; width: auto; padding: 0; overflow: visible; }
.insp-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; margin-bottom: 10px; }
.insp-top .close { width: 30px; height: 30px; margin-right: -6px; border-radius: 6px; font-size: 18px; color: var(--muted); }
.insp-top .close:hover { background: var(--surface-2); color: var(--ink); }
.kind-tag { display: inline-flex; align-items: center; gap: 8px; }
.kind-tag .shape { margin: 0; }
.inspector h2 { font-size: 21px; line-height: 1.2; letter-spacing: -.022em; font-weight: 600; margin-bottom: 10px; text-wrap: balance; }
.inspector p { color: var(--ink-2); font-size: 14px; margin-bottom: 12px; }
.inspector section { border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 16px; font-size: 13.5px; }
.inspector section .label { margin-bottom: 6px; }
.rel-label { display: block; font: 400 11px/1.4 var(--mono); color: var(--muted); }
.doc-links a { display: flex; justify-content: space-between; gap: 12px; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 8px; text-decoration: none; margin-top: 6px; line-height: 1.4; }
.doc-links a:hover { border-color: var(--ink); }
.doc-links small { display: block; color: var(--muted); font-size: 11.5px; }
.doc-links a > span:last-child { align-self: center; color: var(--muted); }
.progress { display: flex; gap: 3px; margin-bottom: 10px; }
.progress i { flex: 1; height: 3px; border-radius: 2px; background: var(--rule-strong); }
.progress i.on { background: var(--accent); }
.story-nav { display: flex; gap: 8px; margin: 12px 0 18px; }
.story-nav .btn { flex: 1; }

.tip { position: absolute; z-index: 6; pointer-events: none; max-width: 260px; padding: 7px 10px; border-radius: 7px; background: var(--ink); color: var(--bg); font-size: 12.5px; line-height: 1.4; }
.tip small { display: block; opacity: .65; font: 400 10.5px/1.5 var(--mono); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Search palette ---------- */
.palette { width: min(640px, calc(100vw - 24px)); max-height: min(560px, calc(100dvh - 96px)); margin: 72px auto auto; padding: 0; border: 1px solid var(--rule-strong); border-radius: 12px; background: var(--bg); color: var(--ink); box-shadow: 0 24px 64px rgba(0,0,0,.28); overflow: hidden; }
.palette[open] { display: flex; flex-direction: column; }
.palette::backdrop { background: rgba(0, 0, 0, .42); backdrop-filter: blur(2px); }
.palette-in { display: flex; align-items: center; gap: 12px; padding: 0 12px 0 18px; border-bottom: 1px solid var(--rule); color: var(--muted); }
.palette-in input { flex: 1; min-width: 0; height: 54px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; }
.palette-in input::-webkit-search-cancel-button { display: none; }
.esc { font: 500 11px/1 var(--mono); color: var(--muted); border: 1px solid var(--rule-strong); border-radius: 4px; padding: 5px 6px; }
.palette-list { overflow-y: auto; padding: 6px; flex: 1; min-height: 80px; }
.palette-list .label { padding: 12px 12px 6px; }
.result { display: flex; gap: 11px; align-items: flex-start; padding: 9px 12px; border-radius: 8px; cursor: pointer; line-height: 1.45; }
.result[aria-selected="true"] { background: var(--surface-2); }
.result .shape { margin-top: .32em; }
.result > svg.ico { width: 14px; height: 14px; flex: none; margin-top: 3px; fill: none; stroke: var(--muted); stroke-width: 1.5; }
.result b { font-weight: 500; font-size: 14px; display: block; }
.result small { display: block; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.result mark { background: var(--accent-soft); color: var(--accent-text); border-radius: 2px; }
.palette-empty { padding: 28px 14px; text-align: center; color: var(--muted); font-size: 14px; }
.palette-foot { display: flex; gap: 18px; align-items: center; padding: 9px 16px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted); }
.palette-foot kbd { margin-right: 3px; }
#paletteCount { margin-left: auto; font-family: var(--mono); font-size: 11px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .reader-grid { grid-template-columns: minmax(0, 1fr); padding: 0 32px; }
  .rail { display: none; }
  .brand-sub { display: none; }
}

@media (max-width: 900px) {
  :root { --top: 56px; }
  .top { grid-template-columns: auto 1fr auto; gap: 8px; padding: 0 8px; }
  .top::after { display: none; }
  .menu-btn { display: grid; }
  body.is-graph .menu-btn { display: none; }
  body.is-graph .top-brand { padding-left: 8px; }
  .logo { width: 86px; }
  .switch { justify-self: center; }
  .switch a { padding: 0 11px; }
  .switch svg { display: none; }
  .search-btn { width: 38px; padding: 0; justify-content: center; border-color: transparent; }
  .search-btn span, .search-btn kbd { display: none; }

  .doc { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: var(--top); bottom: 0; width: min(320px, 86vw); z-index: 15; transform: translateX(-102%); visibility: hidden; transition: transform .26s var(--ease), visibility .26s; }
  body.menu-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow); }
  .page-link { min-height: 44px; align-items: center; }
  .sections a { padding-top: 8px; padding-bottom: 8px; }
  .scrim { position: fixed; inset: var(--top) 0 0; background: rgba(0,0,0,.4); z-index: 14; }
  .reader-grid { padding: 0 18px; }
  .article { padding-top: 28px; }
  .heading-graph { margin-left: 8px; }
  .table-tools input { width: 100%; font-size: 16px; height: 40px; }

  .controls { width: min(300px, calc(100% - 32px)); max-height: calc(100% - 90px); z-index: 7; }
  .inspector { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 52%; border-radius: 16px 16px 0 0; border-width: 1px 0 0; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 6; }
  .inspector.closed { left: auto; right: 16px; bottom: 16px; border: 0; box-shadow: none; max-height: none; }
  .graph.has-sheet .zoom, .graph.has-sheet .focusbar { display: none; }
  .focusbar { bottom: 66px; }
}

@media (max-width: 560px) {
  .top { gap: 4px; }
  .logo { width: 62px; }
  .brand { padding-right: 2px; }
  body.is-graph .top-brand { padding-left: 6px; }
  .switch a { padding: 0 7px; font-size: 13px; }
  .top-tools { gap: 0; }
  .icon-btn, .search-btn { width: 32px; }
  .pager { grid-template-columns: 1fr; }
  .pager a.next { grid-column: 1; }
  .palette { margin-top: 12px; max-height: calc(100dvh - 24px); }
  .palette-foot span:not(#paletteCount) { display: none; }
}

@media (max-width: 359px) {
  .brand { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  body { overflow: visible; }
  .gate, .top, .sidebar, .rail, .graph, .table-tools, .pager, .heading-graph { display: none !important; }
  main, .doc, .reader { height: auto; display: block; overflow: visible; }
}
