/* Aquaman system explorer. Calm marine palette, follows the OS light/dark preference. */
/* Colour tokens (light, dark) and the body background live in index.html so the page is themed before this file loads. */

* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* module colour on text: the raw colour in light mode, a lighter tint in dark mode */
.mc { --mt: var(--mc); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mc { --mt: var(--mcl); } }
:root[data-theme="dark"] .mc { --mt: var(--mcl); }

/* ---------- top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background:
    radial-gradient(circle at 50% 50%, var(--surface) 0 30%, transparent 31%),
    conic-gradient(#b7791f 0 25%, #2f7d46 0 50%, #3554a5 0 75%, #b3362b 0);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.brand h1 { font-size: 17px; }
.subtitle { margin: 0; color: var(--muted); font-size: 12.5px; }
.config { display: flex; align-items: center; gap: 10px; }
.config-label { color: var(--muted); font-size: 12.5px; }

/* ---------- segmented control */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.segmented button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  color: var(--ink-2); font-weight: 500; white-space: nowrap;
}
.segmented button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.segmented button:hover:not([aria-checked="true"]) { background: var(--line); }
.segmented.small button { padding: 5px 10px; font-size: 13px; }
.segmented .sub { font-weight: 400; opacity: 0.8; font-size: 12px; margin-left: 4px; }

/* ---------- layout */
.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 360px;
  grid-template-rows: minmax(0, 1fr);
}
.sidebar, .panel {
  overflow-y: auto; background: var(--bg); min-height: 0;
  scrollbar-width: thin;
}
.sidebar { padding: 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.sidebar > .card { flex: none; }
.panel { border-left: 1px solid var(--line); padding: 18px 20px 28px; background: var(--surface); position: relative; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.rule { margin: 0 0 10px; color: var(--ink-2); font-style: italic; font-size: 13px; }

/* ---------- configuration card */
.config-card h2 { font-size: 15px; }
.config-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 8px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-width: 0; }
.stat .k { font-size: 11px; color: var(--muted); display: block; }
.stat .v { font-size: 15px; font-weight: 600; display: block; white-space: nowrap; }
.est { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); vertical-align: middle; margin-left: 6px; font-weight: 500; }

/* ---------- modules */
.module-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.module-btn {
  width: 100%; text-align: left; display: grid; grid-template-columns: 14px 1fr; gap: 2px 10px; align-items: start;
  padding: 8px 10px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer;
}
.module-btn:hover { background: var(--surface-2); border-color: var(--line); }
.module-btn[aria-pressed="true"] { background: var(--surface-2); border-color: var(--mc); box-shadow: inset 3px 0 0 var(--mc); }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--mc); margin-top: 4px; }
.module-btn .name { font-weight: 600; color: var(--mt); }
.module-btn .sum { grid-column: 2; font-size: 12.5px; color: var(--muted); }

/* ---------- parts tree */
.parts-card { display: flex; flex-direction: column; min-height: 0; }
.parts-head { display: flex; justify-content: space-between; align-items: baseline; }
.count { font-size: 12px; color: var(--muted); }
.search input {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface-2); margin-bottom: 8px;
}
.phase-filter { margin-bottom: 10px; width: 100%; display: flex; }
.phase-filter button { flex: 1; }
.tree-group { margin: 6px 0 2px; }
.tree-group-title {
  display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--mt);
  text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 6px;
}
.tree-group-title .swatch { margin: 0; width: 8px; height: 8px; border-radius: 2px; }
.tree-list { list-style: none; margin: 0; padding: 0; }
.part-btn {
  width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer; border-radius: 6px;
  padding: 5px 8px 5px 22px; display: flex; justify-content: space-between; gap: 8px; color: var(--ink-2);
}
.part-btn:hover { background: var(--surface-2); color: var(--ink); }
.part-btn[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.part-btn[aria-current="true"] .badge { border-color: currentColor; color: inherit; }
.part-btn.related { box-shadow: inset 2px 0 0 var(--accent); color: var(--ink); }
.part-btn.dimmed { opacity: 0.5; }
.part-btn .off { font-size: 11px; color: var(--muted); }
.badge {
  font-size: 10.5px; padding: 0 6px; border-radius: 999px; border: 1px dashed var(--planned); color: var(--planned);
  white-space: nowrap; align-self: center; font-weight: 600; line-height: 1.5;
}
.empty { color: var(--muted); font-size: 13px; padding: 6px; }

/* ---------- fit card */
.fit-card h2 { margin-bottom: 6px; }
.fit-ok { color: var(--ok); font-weight: 600; }
.fit-bad { color: var(--warn-ink); font-weight: 600; }
.fit-card ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); }
.fit-card p { margin: 4px 0; font-size: 12.5px; color: var(--ink-2); }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- stage */
.stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--stage); }
.canvas-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.canvas-wrap canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.labels { position: absolute; inset: 0; pointer-events: none; }
.mlabel {
  position: absolute; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--mt); background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--mc) 45%, transparent); border-radius: 999px; padding: 2px 9px;
  white-space: nowrap; user-select: none;
}
.mlabel.dim { opacity: 0.35; }
.dlabel {
  position: absolute; transform: translate(-50%, -50%); font: 600 11.5px var(--font); color: var(--ink-2);
  background: color-mix(in srgb, var(--stage) 85%, transparent); padding: 1px 6px; border-radius: 4px; white-space: nowrap;
}
.tooltip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap; transform: translate(12px, 12px); z-index: 3;
}
.warning {
  position: absolute; left: 12px; right: 12px; top: 12px; z-index: 4;
  background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line);
  border-radius: 8px; padding: 9px 12px; font-size: 13px; box-shadow: var(--shadow); max-width: 640px;
}
.warning strong { display: block; margin-bottom: 2px; }
.fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px;
  padding: 24px; max-width: 520px; margin: 0 auto; color: var(--ink-2);
}
.fallback h2 { font-size: 17px; color: var(--ink); }
.fallback p { margin: 0; }

/* ---------- toolbar */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 14px;
  border-top: 1px solid var(--line); background: var(--surface);
}
.btn {
  border: 1px solid var(--line-strong); background: var(--surface-2); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 500;
}
.btn:hover { background: var(--line); }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; user-select: none; }
.check input, .slider input { accent-color: var(--accent); }
.check input { width: 16px; height: 16px; margin: 0; }
.slider { display: inline-flex; align-items: center; gap: 8px; }
.slider input { width: 140px; }

/* ---------- details panel */
.panel-close {
  display: none; position: absolute; right: 14px; top: 12px; border: 1px solid var(--line-strong); background: var(--surface-2);
  border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 13px;
}
.sheet-handle { display: none; }
.kicker { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--mt); margin-bottom: 6px; }
.kicker .swatch { margin: 0; }
.kicker button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-transform: inherit; letter-spacing: inherit; }
.kicker button:hover { text-decoration: underline; }
.panel h2.title { font-size: 21px; line-height: 1.2; margin-bottom: 8px; }
.panel .role { font-size: 15px; color: var(--ink); margin: 0 0 10px; }
.panel .desc { color: var(--ink-2); margin: 0 0 14px; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 6px; }
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv th, .kv td { text-align: left; vertical-align: top; padding: 5px 0; border-bottom: 1px solid var(--line); }
.kv th { color: var(--muted); font-weight: 500; width: 38%; padding-right: 10px; }
.kv td { color: var(--ink); overflow-wrap: anywhere; }
.src { font-size: 12px; color: var(--muted); margin-top: 6px; overflow-wrap: anywhere; }
.src.ph { color: var(--warn-ink); }
.mono { font-family: var(--mono); font-size: 12px; }
.notsourced { display: inline-block; font-size: 12.5px; color: var(--warn-ink); background: var(--warn-bg); border: 1px solid var(--warn-line); padding: 2px 8px; border-radius: 6px; }
.conn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.conn-btn {
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; cursor: pointer;
  display: grid; grid-template-columns: 10px 1fr; gap: 2px 10px;
}
.conn-btn:hover { border-color: var(--line-strong); }
.conn-btn .swatch { margin-top: 5px; width: 10px; height: 10px; }
.conn-btn .to { font-weight: 600; }
.conn-btn .ty { grid-column: 2; font-size: 12.5px; color: var(--muted); }
.features { margin: 0; padding-left: 18px; }
.features li { margin: 4px 0; }
.features li.planned { color: var(--muted); }
.planned-note { font-size: 12.5px; color: var(--planned); border: 1px dashed var(--planned); border-radius: 8px; padding: 6px 10px; margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.chip:hover { border-color: var(--line-strong); }
.intro p { color: var(--ink-2); }
.intro .hint { color: var(--muted); font-size: 13px; }
.note { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; }

/* ---------- footer */
.footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 9px 20px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface);
}

/* ---------- medium screens (tablets): stage and details side by side, lists below the stage */
@media (max-width: 1180px) and (min-width: 761px) {
  body { height: auto; min-height: 100vh; }
  .layout {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto auto;
    grid-template-areas: "stage panel" "side panel";
  }
  .stage { grid-area: stage; height: 64vh; min-height: 380px; }
  .sidebar { grid-area: side; overflow: visible; border-right: 0; display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .sidebar > .parts-card { grid-row: span 2; }
  .panel { grid-area: panel; position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; }
}
@media (max-width: 900px) and (min-width: 761px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .sidebar { grid-template-columns: 1fr; }
}

/* ---------- phones: stacked, details as a bottom sheet */
@media (max-width: 760px) {
  body { font-size: 15px; height: auto; min-height: 100vh; }
  .panel { position: fixed; z-index: 10; display: none; box-shadow: var(--shadow); border: 1px solid var(--line); }
  .panel.open { display: block; }
  .panel-close { display: block; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  .top-actions .btn { order: 2; width: 100%; }
  .topbar { padding: 10px 16px; }
  .config { width: 100%; justify-content: space-between; }
  .config-label { display: none; }
  .config .segmented { width: 100%; }
  .config .segmented button { flex: 1; }
  .segmented .sub { display: none; }
  .layout { display: flex; flex-direction: column; height: auto; }
  .stage { order: -1; height: 58vh; min-height: 340px; flex: none; }
  .sidebar { border-right: 0; padding: 12px 16px 24px; overflow: visible; }
  .toolbar { gap: 8px 12px; padding: 10px 16px; }
  .slider input { width: 110px; }
  .panel {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none; max-height: 62vh;
    border-radius: 16px 16px 0 0; border-bottom: 0; padding: 22px 16px calc(24px + env(safe-area-inset-bottom));
  }
  .sheet-handle { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: -10px auto 12px; }
  .panel-close { top: 14px; right: 12px; }
  .panel h2.title { font-size: 19px; padding-right: 64px; }
  .footer { padding: 10px 16px; }
  .footer-hint { display: none; }
  .warning { font-size: 12.5px; left: 8px; right: 8px; top: 8px; }
}
@media (prefers-reduced-motion: no-preference) {
  .panel.open { animation: rise 160ms ease-out; }
  @keyframes rise { from { transform: translateY(8px); opacity: 0.6; } to { transform: none; opacity: 1; } }
}

/* ---------- header actions */
.top-actions { display: flex; align-items: center; gap: 12px; }

/* ---------- catalogue lines in the details panel */
.cat-line { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 10px; background: var(--surface-2); }
.cat-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.cat-head strong { font-size: 13.5px; }
.cat-line .kv th { width: 34%; }
.cat-notes summary { cursor: pointer; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.cat-notes p { font-size: 12.5px; color: var(--ink-2); margin: 6px 0 0; overflow-wrap: anywhere; }
.use-badge { font-size: 10.5px; font-weight: 600; padding: 0 7px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; line-height: 1.6; }
.use-badge.u-product { color: var(--ok); border-color: currentColor; }
.use-badge.u-comparison, .use-badge.u-development { color: var(--planned); border-color: currentColor; }
.status.s-verified { color: var(--ok); }
.status.s-summary { color: var(--warn-ink); }
.status.s-unverified { color: var(--warn-ink); }
.confirm { color: var(--warn-ink); font-style: italic; }

/* ---------- parts and cost dialog */
dialog.cost {
  width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 20px 22px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); overflow: auto;
}
dialog.cost::backdrop { background: rgba(8, 20, 26, 0.45); }
.cost-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cost-head h2 { font-size: 19px; }
.cost-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 6px; }
.cost-sum .stat .v { white-space: normal; font-size: 16px; margin: 2px 0; }
.cost .segmented { margin: 8px 0 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.cost-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 760px; }
.cost-table th, .cost-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cost-table thead th { position: sticky; top: 0; background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 600; }
.cost-table .num { text-align: right; white-space: nowrap; }
.cost-table tr.grp th { background: var(--surface-2); color: var(--mt, var(--ink)); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.cost-table tr.grp .swatch { display: inline-block; margin: 0 8px 0 0; width: 9px; height: 9px; }
.cost-table tr.sub td { font-weight: 600; color: var(--ink-2); background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.cost-table tr.total td { font-weight: 700; border-top: 2px solid var(--line-strong); }
.cost-table tr.not-counted td { color: var(--muted); }
.cost-table tr.not-counted td:first-child { text-decoration: none; }
.cost-table .linkish { text-align: left; font: inherit; }
@media (max-width: 760px) {
  dialog.cost { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; margin: 0; border-radius: 0; padding: 16px; }
  .cost-sum { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .cost .segmented { display: flex; width: 100%; }
  .cost .segmented button { flex: 1; white-space: normal; }
}

/* ---------- views: tabs and panes */
.view-tabs { display: flex; gap: 2px; padding: 8px 12px 0; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.view-tabs [role="tab"] {
  border: 0; background: transparent; padding: 8px 12px 9px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13.5px;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.view-tabs [role="tab"]:hover { color: var(--ink); }
.view-tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.canvas-wrap-inner { position: absolute; inset: 0; }
.view-pane { flex: 1; min-height: 0; overflow: auto; padding: 18px 20px 28px; background: var(--bg); }
.view-head h2 { font-size: 19px; margin-bottom: 4px; }
.view-head { margin-bottom: 10px; }
.view-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin: 12px 0; align-items: start; }
.view-pane .card { margin-bottom: 12px; }
.view-pane .card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
.view-pane .card h3 ~ h3 { margin-top: 14px; }

/* ---------- rails and legend */
.rail-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--rc, #888); flex: none; vertical-align: -1px; }
.rail-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 3px 10px 3px 7px; font-size: 12.5px; cursor: pointer; }
.rail-chip .rail-dot { background: var(--rc); }
.rails-row { margin-bottom: 8px; }
.legend-list { display: flex; flex-direction: column; gap: 2px; }
.sch-legend { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 6px 0 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 4px 8px; cursor: pointer; text-align: left; font-size: 13px; color: var(--ink-2); }
.legend-item:hover { background: var(--surface-2); border-color: var(--line); }
.legend-item.on { background: var(--surface-2); border-color: var(--rc); box-shadow: inset 3px 0 0 var(--rc); color: var(--ink); }
.legend-line { display: inline-block; width: 22px; height: 2px; background: var(--rc); border-radius: 2px; flex: none; }
.legend-line.thick { height: 5px; }
.conn-btn { grid-template-columns: 10px 1fr; }
.conn-btn .rail-dot { margin-top: 5px; background: var(--rc); }
.conn-btn .elec { color: var(--ink-2); }
.conn-btn .elec-notes { font-style: italic; }

/* ---------- schematic */
.sch-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; overflow-x: auto; }
.sch-svg, .st-svg { display: block; width: 100%; min-width: 720px; height: auto; }
.st-svg { min-width: 560px; max-width: 900px; margin: 0 auto; }
.sch-edge { fill: none; stroke-width: 1.6; stroke-linejoin: round; opacity: 0.9; }
.sch-edge.power { stroke-width: 3.6; }
.sch-edge.dim { opacity: 0.12; }
.sch-edge.hot { opacity: 1; filter: drop-shadow(0 0 2px var(--surface)); }
.sch-node { cursor: pointer; }
.sch-node .sch-box { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1; }
.sch-node:hover .sch-box, .sch-node:focus-visible .sch-box { stroke: var(--accent); stroke-width: 1.6; }
.sch-node:focus { outline: none; }
.sch-node.sel .sch-box { stroke: var(--accent); stroke-width: 2.4; fill: var(--surface); }
.sch-node.dim { opacity: 0.35; }
.sch-label { font: 600 14px var(--font); fill: var(--ink); }
.sch-sub { font: 12px var(--font); fill: var(--muted); }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mini-table th, .mini-table td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.mini-table thead th { color: var(--muted); font-weight: 600; font-size: 11.5px; background: var(--surface-2); }
.mini-table .num { text-align: right; white-space: nowrap; }
.mini-table tr.total td { font-weight: 700; border-top: 2px solid var(--line-strong); }
.mini-table tr.variant td:first-child { border-left: 3px solid var(--line-strong); }
.mini-table .strong, .cost-table .strong { font-weight: 700; }
.lp-tag { display: inline-block; margin-left: 6px; font: 600 10px var(--font); color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; }
.checks { margin: 8px 0; padding-left: 18px; font-size: 13px; color: var(--warn-ink); }
.checks li { margin: 4px 0; }
.basis { font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.basis.b-sourced { color: var(--ok); }
.basis.b-estimate { color: var(--warn-ink); }
.basis.b-to-measure, .basis.b-to-confirm { color: var(--planned); }
.inline-input input { width: 64px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-2); }

/* ---------- states */
.st-box { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.4; }
.st-name { font: 700 15px var(--font); fill: var(--ink); }
.st-sub { font: 11.5px var(--font); fill: var(--muted); }
.st-edge { stroke: var(--ink-2); stroke-width: 1.4; }
.st-arrow { fill: var(--ink-2); }
.st-elabel { font: 600 11px var(--font); fill: var(--accent); }
.state-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 12px 0; }
.flashes { display: inline-flex; gap: 4px; vertical-align: middle; }
.flash { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.flash.f-g { background: #22a04a; box-shadow: 0 0 6px #22a04a; }
.flash.f-r { background: #d93025; box-shadow: 0 0 6px #d93025; }
.flash.f-gr { background: linear-gradient(90deg, #22a04a 50%, #d93025 50%); box-shadow: 0 0 6px #b58a2a; }
.transitions { margin: 0; padding-left: 22px; font-size: 13.5px; }
.transitions li { margin: 4px 0; }

/* ---------- notes */
.notes { max-width: 860px; }
.notes-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; }
.notes-toc a { font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; text-decoration: none; color: var(--ink-2); background: var(--surface); }
.notes-sec { margin: 0 0 28px; }
.notes-sec h2 { font-size: 18px; margin: 8px 0 6px; scroll-margin-top: 12px; }
.notes-sec h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 16px 0 6px; }
.notes .lead { color: var(--ink-2); font-size: 14.5px; }
.decisions { display: grid; grid-template-columns: 44px 1fr; gap: 6px 10px; margin: 0; }
.decisions dt { font: 600 12.5px var(--mono); color: var(--accent); padding-top: 2px; }
.decisions dd { margin: 0; font-size: 14px; line-height: 1.5; }
.notes-list { padding-left: 18px; font-size: 14px; line-height: 1.5; }
.notes-list li { margin: 6px 0; }
.phase-table td.yes { color: var(--ok); font-weight: 600; }

/* ---------- cost dialog sections */
.cost-sec { margin-top: 18px; }
.cost-sec h3 { font-size: 15px; margin-bottom: 2px; }
.cost-table.summary { min-width: 560px; }
.cost-table.compare { min-width: 560px; }
.use-badge.u-camera { color: var(--ok); border-color: currentColor; }
.use-badge.u-shared { color: var(--accent); border-color: currentColor; }
.use-badge.u-initial { color: var(--planned); border-color: currentColor; }
@media (max-width: 760px) {
  .view-pane { padding: 14px 16px 22px; }
  .stage { height: auto; min-height: 0; }
  .stage #view-3d { height: 58vh; min-height: 340px; flex: none; }
  .view-pane { max-height: none; overflow: visible; }
  .decisions { grid-template-columns: 38px 1fr; }
}
@media (max-width: 1180px) and (min-width: 761px) {
  .stage { height: auto; min-height: 0; }
  .stage #view-3d { height: 64vh; min-height: 380px; flex: none; }
  .view-pane { overflow: visible; }
}

.view-cols.wide { grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); }
@media (max-width: 600px) { .view-cols.wide, .view-cols { grid-template-columns: 1fr; } }

/* ---------- purpose and reason */
.why { border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; padding: 8px 12px; margin: 0 0 12px; }
.why p { margin: 3px 0; font-size: 13.5px; color: var(--ink); }
.why-k { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.why-line { color: var(--ink-2); }
.hovercard {
  position: fixed; z-index: 50; max-width: 340px; pointer-events: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow); padding: 8px 11px; font-size: 12.5px; line-height: 1.4; display: flex; flex-direction: column; gap: 3px;
}
.hovercard[hidden] { display: none !important; }
.hc-title { font-size: 13px; }
.hc-line em { font-style: normal; font-weight: 700; color: var(--accent); }
.st-node { cursor: default; }
.st-node:focus { outline: none; }
.st-node:focus-visible .st-box { stroke: var(--accent); stroke-width: 2.4; }
.sch-edge { pointer-events: stroke; }
/* light rhythm icons */
.flashes.p-steady .flash { width: 22px; border-radius: 6px; }
.flashes.p-slow { gap: 9px; }
.flashes.p-fast { gap: 2px; }
.flashes.p-fast .flash { width: 7px; height: 7px; }
/* future view */
.future-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 4px 0 14px; }
.future-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.future-card h3 { font-size: 14.5px !important; text-transform: none !important; letter-spacing: 0 !important; color: var(--ink) !important; margin: 0 !important; }
.future-card .kv th { width: 34%; }
@media (max-width: 600px) { .future-grid { grid-template-columns: 1fr; } }
.st-svg { min-width: 0 !important; }

/* ---------- tests */
.unproven { font-size: 10px; font-weight: 700; color: var(--warn-ink); border: 1px dotted var(--warn-ink); border-radius: 999px; padding: 0 6px; white-space: nowrap; align-self: center; line-height: 1.5; margin-left: 4px; }
.sch-unproven circle { fill: var(--warn-bg); stroke: var(--warn-ink); stroke-width: 1.5; }
.test-progress { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 6px 0 12px; }
.test-progress .bar { display: block; height: 5px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.test-progress .bar span { display: block; height: 100%; background: var(--ok); }
.test-card { margin-bottom: 8px; padding: 10px 12px; }
.test-card summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13.5px; }
.test-card[open] summary { margin-bottom: 8px; }
.test-card .chips { margin-top: 8px; }
.test-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--line-strong); flex: none; }
.test-dot.s-passed { background: var(--ok); }
.test-dot.s-failed { background: #c0392b; }
.test-dot.s-running, .test-dot.s-partial { background: #e08a1e; }
.chip.static { cursor: default; }
.tests-block h3 { color: var(--warn-ink) !important; }
.flash.f-off { background: transparent; border: 1.5px dashed var(--muted); box-shadow: none; }
.future-tools .segmented { flex-wrap: wrap; max-width: 100%; }
