/* Palette and fonts shared with the other prep tools (AlgoScope, Java/DB/OS Steppers):
   light by default, dark when the OS prefers it, and data-theme="light"/"dark" overrides. */
:root {
  --bg: #eef2f5; --bg2: #ffffff; --panel: #ffffff; --card: #ffffff; --card2: #f4f7f9;
  --line: #d8e0e7; --line2: #c6d1db; --text: #15202b; --muted: #5a6977; --dim: #7b8794;
  --body-ink: #26333f; --lede: #3d4b58;
  --blue: #0b6aa8; --accent-soft: #dcecf7; --on-accent: #ffffff;
  --green: #0a8a5f; --red: #c43c3c; --amber: #b7790a; --orange: #c2560b; --violet: #b02bb8; --pink: #c26a05;
  --ok-bg: #dff5ea; --bad-bg: #fde3e1; --warn-bg: #fff1bf; --muted-bg: #e9eef2;
  --code-bg: #f7f9fb; --grid-dot: #c9d3dc; --edge: #a9b7c4; --edge-live: #6f8ca6; --edge-hover: #0b6aa8;
  --glass: rgba(255, 255, 255, .94); --overlay: rgba(15, 21, 27, .42);
  --shadow: rgba(21, 32, 43, .10); --shadow-strong: rgba(21, 32, 43, .18); --glow: 0;
  --accent: var(--blue);
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --top: 52px;
  --side: 268px;
  --panelw: 400px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f151b; --bg2: #161e26; --panel: #161e26; --card: #161e26; --card2: #1b2530;
  --line: #2a3642; --line2: #364554; --text: #e3eaf0; --muted: #93a2b0; --dim: #6b7a88;
  --body-ink: #cfd9e2; --lede: #b4c1cd;
  --blue: #5cb3ef; --accent-soft: #16334a; --on-accent: #0b1620;
  --green: #3ccf98; --red: #ff7b6e; --amber: #f0b84a; --orange: #ff9a52; --violet: #e07ae8; --pink: #f0a43c;
  --ok-bg: #15352a; --bad-bg: #3e1f1f; --warn-bg: #3d3415; --muted-bg: #1f2a36;
  --code-bg: #121a22; --grid-dot: #1f2a35; --edge: #34424f; --edge-live: #4f6d88; --edge-hover: #5cb3ef;
  --glass: rgba(22, 30, 38, .94); --overlay: rgba(3, 6, 12, .62);
  --shadow: rgba(0, 0, 0, .35); --shadow-strong: rgba(0, 0, 0, .6); --glow: 8;
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0f151b; --bg2: #161e26; --panel: #161e26; --card: #161e26; --card2: #1b2530;
  --line: #2a3642; --line2: #364554; --text: #e3eaf0; --muted: #93a2b0; --dim: #6b7a88;
  --body-ink: #cfd9e2; --lede: #b4c1cd;
  --blue: #5cb3ef; --accent-soft: #16334a; --on-accent: #0b1620;
  --green: #3ccf98; --red: #ff7b6e; --amber: #f0b84a; --orange: #ff9a52; --violet: #e07ae8; --pink: #f0a43c;
  --ok-bg: #15352a; --bad-bg: #3e1f1f; --warn-bg: #3d3415; --muted-bg: #1f2a36;
  --code-bg: #121a22; --grid-dot: #1f2a35; --edge: #34424f; --edge-live: #4f6d88; --edge-hover: #5cb3ef;
  --glass: rgba(22, 30, 38, .94); --overlay: rgba(3, 6, 12, .62);
  --shadow: rgba(0, 0, 0, .35); --shadow-strong: rgba(0, 0, 0, .6); --glow: 8;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select { font: inherit; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 20px; }

/* ---------- top bar ---------- */
.topbar { height: var(--top); display: flex; align-items: center; gap: 14px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--bg2); position: relative; z-index: 30; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { color: var(--blue); font-size: 20px; text-shadow: none; }
.brand-name { font-family: var(--display); font-weight: 700; letter-spacing: -.02em; font-size: 16px; }
.brand-tag { color: var(--dim); font-size: 12px; }
.crumb { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; padding-left: 14px; border-left: 1px solid var(--line); }
.crumb span { font-size: 11px; }
.crumb b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.run-ctl, .top-actions { display: flex; align-items: center; gap: 6px; }
.clock { font: 12px var(--mono); color: var(--muted); min-width: 78px; }
#speed { background: var(--card); border: 1px solid var(--line2); border-radius: 8px; padding: 5px 6px; font-size: 12px; }
.btn { border: 1px solid var(--line2); background: var(--card); padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 13px; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--dim); background: var(--card2); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-accent); box-shadow: 0 1px 2px var(--shadow); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.primary.running { background: var(--card2); border-color: var(--line2); color: var(--text); box-shadow: none; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line2); background: var(--card); display: grid; place-items: center; font-size: 15px; }
.icon-btn:hover { background: var(--card2); }
.only-mobile { display: none; }
/* theme toggle: show the moon in light mode, the sun in dark mode */
.theme-btn svg { width: 17px; height: 17px; }
.theme-btn .sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-btn .sun { display: block; } :root:not([data-theme="light"]) .theme-btn .moon { display: none; } }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line2); border-radius: 12px; padding: 6px; min-width: 250px; display: none; box-shadow: 0 16px 40px -12px var(--shadow-strong); z-index: 50; }
.menu.open { display: block; }
.menu button, .ctx-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.menu button:hover, .ctx-menu button:hover { background: var(--card2); }
.menu-h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); padding: 8px 10px 2px; }
.menu-foot { font-size: 11px; color: var(--muted); padding: 8px 10px 4px; border-top: 1px solid var(--line); margin-top: 6px; }

/* ---------- layout ---------- */
.main { display: grid; grid-template-columns: var(--side) minmax(0, 1fr) var(--panelw); grid-template-rows: minmax(0, 1fr); height: calc(100% - var(--top)); }
.main > * { min-height: 0; }
@media (min-width: 981px) {
  body.hide-sidebar .main { grid-template-columns: 0 minmax(0, 1fr) var(--panelw); }
  body.hide-sidebar .sidebar { visibility: hidden; padding: 0; border: 0; }
}
.sidebar { border-right: 1px solid var(--line); background: var(--bg2); overflow-y: auto; padding: 12px 10px 30px; }
.stage { position: relative; overflow: hidden; }
.panel { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-width: 0; }

/* sidebar */
.side-head { padding: 4px 6px 10px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.progress-label b { color: var(--text); }
.progress { height: 6px; border-radius: 6px; background: var(--card); margin: 6px 0 12px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); border-radius: 6px; transition: width .4s; }
.mod { margin-top: 10px; }
.mod-h { display: grid; grid-template-columns: 1fr auto; padding: 6px 6px 4px; }
.mod-h .wk { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--blue); font-weight: 700; }
.mod-h .mod-t { grid-column: 1; font-weight: 700; font-size: 13px; }
.mod-h .mod-c { grid-row: 1 / span 2; grid-column: 2; align-self: center; font: 11px var(--mono); color: var(--dim); }
.side-item { display: flex; gap: 9px; align-items: center; padding: 6px 8px; border-radius: 8px; color: var(--muted); font-size: 13px; line-height: 1.3; }
.side-item:hover { background: var(--card); color: var(--text); text-decoration: none; }
.side-item.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 2px 0 var(--blue); }
.side-item .dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line2); flex: none; display: grid; place-items: center; font-size: 11px; }
.side-item.done .dot { background: var(--green); border-color: var(--green); color: var(--on-accent); font-weight: 800; }
.side-item.sandbox { border: 1px dashed var(--line2); color: var(--text); }
.side-item.sandbox .dot { border: 0; }
.side-foot { font-size: 11px; color: var(--dim); padding: 20px 8px 0; }

/* ---------- canvas ---------- */
#canvas, .viewport { position: absolute; inset: 0; }
.viewport { overflow: hidden; touch-action: none; cursor: grab; user-select: none; }
.viewport:active { cursor: grabbing; }
.viewport.connecting { cursor: crosshair; }
.grid-bg { position: absolute; inset: 0; background-image: radial-gradient(circle, var(--grid-dot) 1.1px, transparent 1.2px); }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
svg.edges { position: absolute; overflow: visible; pointer-events: none; }
.edge-hit { stroke: transparent; stroke-width: 14; fill: none; pointer-events: stroke; cursor: pointer; }
.edge-line { fill: none; stroke: var(--edge); stroke-width: 1.5; color: var(--edge); transition: stroke .3s; }
.edge[data-state="live"] .edge-line { stroke: var(--edge-live); color: var(--edge-live); }
.edge[data-state="fail"] .edge-line { stroke: color-mix(in srgb, var(--red) 65%, transparent); color: var(--red); }
.edge[data-state="cut"] .edge-line { stroke: var(--red); stroke-dasharray: 3 6; color: var(--red); }
.edge[data-state="open"] .edge-line { stroke: var(--dim); stroke-dasharray: 2 4; }
.edge.async .edge-line { stroke-dasharray: 7 5; }
.edge.selected .edge-line { stroke: var(--blue) !important; color: var(--blue); }
.edge:hover .edge-line { stroke: var(--edge-hover); }
.edge-label { font: 10px var(--mono); fill: var(--muted); text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.edge[data-state="fail"] .edge-label, .edge[data-state="cut"] .edge-label { fill: var(--red); }
.edge-temp { fill: none; stroke: var(--blue); stroke-width: 2; stroke-dasharray: 5 4; }
canvas.particles { position: absolute; inset: 0; pointer-events: none; }
.canvas-hint { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center; color: var(--muted); pointer-events: none; line-height: 1.8; }
.canvas-hint b { color: var(--text); font-size: 16px; }

.node { position: absolute; width: 184px; background: var(--card); border: 1px solid var(--line2); border-radius: 12px; padding: 8px 10px 8px; cursor: pointer; box-shadow: 0 6px 18px -10px var(--shadow-strong); transition: border-color .25s, box-shadow .25s; }
.node::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); opacity: .9; }
.node:hover { border-color: var(--dim); }
.node.selected { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent), 0 6px 18px -10px var(--shadow-strong); }
.node.drop-target { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 30%, transparent); }
.node-head { display: flex; align-items: center; gap: 7px; }
.node-head .ico { font-size: 15px; }
.node-head .name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-sub { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 1px 0 6px; }
.node-status { display: flex; justify-content: space-between; align-items: center; }
.badge { font: 700 9.5px var(--mono); letter-spacing: .06em; padding: 2px 6px; border-radius: 5px; background: var(--muted-bg); color: var(--muted); }
.metric-a { font: 600 11px var(--mono); }
.node[data-status="healthy"] .badge { background: var(--ok-bg); color: var(--green); }
.node[data-status="stressed"] .badge { background: var(--warn-bg); color: var(--orange); }
.node[data-status="saturated"] .badge { background: var(--bad-bg); color: var(--red); }
.node[data-status="down"] .badge { background: var(--red); color: var(--on-accent); }
.node[data-status="client"] .badge { background: var(--muted-bg); color: var(--muted); }
.node[data-status="saturated"] { border-color: color-mix(in srgb, var(--red) 70%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 35%, transparent), 0 0 22px -6px color-mix(in srgb, var(--red) 50%, transparent); }
.node[data-status="stressed"] { border-color: color-mix(in srgb, var(--orange) 60%, transparent); }
.node[data-status="down"] { opacity: .55; border-color: var(--red); background: repeating-linear-gradient(135deg, var(--card), var(--card) 8px, var(--bad-bg) 8px, var(--bad-bg) 16px); }
.node-bar { height: 4px; border-radius: 4px; background: var(--muted-bg); margin: 6px 0 5px; overflow: hidden; }
.node-bar i { display: block; height: 100%; width: 0; background: var(--green); border-radius: 4px; transition: width .25s, background .25s; }
.node-bar i[data-level="mid"] { background: var(--orange); }
.node-bar i[data-level="hi"] { background: var(--red); }
.node-stats { display: flex; justify-content: space-between; font: 10.5px var(--mono); color: var(--muted); }
.port { position: absolute; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--card); border: 2px solid var(--dim); }
.port.in { left: -8px; pointer-events: none; }
.port.out { right: -8px; cursor: crosshair; }
/* Invisible, much larger hit zone around the dot. */
.port.out::before { content: ''; position: absolute; inset: -12px; border-radius: 50%; }
/* The card's right edge is also a handle. */
.node::after { content: ''; position: absolute; top: 0; bottom: 0; right: 0; width: 26px; cursor: crosshair; border-radius: 0 12px 12px 0; }
.node:hover::after { background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--blue) 14%, transparent)); }
.node:hover .port.out, .port.out:hover { border-color: var(--blue); background: var(--blue); transform: scale(1.3); box-shadow: 0 0 8px color-mix(in srgb, var(--blue) 55%, transparent); }
.node.connect-source { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 35%, transparent); }
.node.is-client .port.in { display: none; }

.callout { position: absolute; width: 230px; background: var(--glass); border: 1px solid var(--line2); border-left: 3px solid var(--red); border-radius: 10px; padding: 8px 10px; font-size: 11.5px; line-height: 1.4; box-shadow: 0 10px 26px -10px var(--shadow-strong); pointer-events: auto; cursor: pointer; animation: pop .25s ease-out; }
.callout b { display: block; font-size: 12px; margin-bottom: 2px; color: var(--red); }
.callout span { color: var(--body-ink); }
.callout.sev-good { border-left-color: var(--green); }
.callout.sev-good b { color: var(--green); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

.zoom-ctl { position: absolute; right: 12px; bottom: 58px; display: flex; flex-direction: column; gap: 4px; }
.zoom-ctl button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line2); background: var(--card); }

/* palette */
.palette { position: absolute; left: 10px; top: 10px; bottom: 70px; width: 158px; display: flex; flex-direction: column; z-index: 5; pointer-events: none; }
.pal-toggle { pointer-events: auto; align-self: flex-start; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line2); background: var(--card); margin-bottom: 6px; font-size: 16px; }
.pal-list { pointer-events: auto; background: var(--glass); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 12px; padding: 6px; overflow-y: auto; }
.palette.collapsed .pal-list { display: none; }
.pal-cat { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); padding: 7px 6px 3px; }
.pal-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 12.5px; cursor: grab; border: 1px solid transparent; touch-action: none; }
.pal-item:hover { background: var(--card); border-color: var(--line2); }
.pal-item .ico { width: 22px; text-align: center; }
.pal-item.ghost { position: fixed; z-index: 100; background: var(--card); border-color: var(--blue); pointer-events: none; box-shadow: 0 10px 26px var(--shadow-strong); }

/* KPI strip */
.kpis { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; display: flex; gap: 2px; background: var(--glass); border: 1px solid var(--line2); box-shadow: 0 6px 18px -10px var(--shadow-strong); border-radius: 12px; padding: 4px; backdrop-filter: blur(8px); z-index: 6; max-width: calc(100% - 24px); overflow-x: auto; }
.kpi { padding: 4px 12px; display: flex; flex-direction: column; min-width: 70px; }
.kpi span { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.kpi b { font: 600 14px var(--mono); white-space: nowrap; }
.kpi.good b { color: var(--green); }
.kpi.warn b { color: var(--amber); }
.kpi.bad b { color: var(--red); }
.runbar { position: absolute; left: 0; right: 0; top: 0; height: 2px; }
.runbar i { display: block; height: 100%; background: var(--blue); width: 0; transition: width .25s linear; }

/* ---------- right panel ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 6px; flex: none; }
.tabs button { background: none; border: 0; padding: 12px 11px 10px; color: var(--muted); font-weight: 600; font-size: 13px; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--blue); }
.panel-body { overflow-y: auto; flex: 1; padding: 0 0 40px; }
.lesson, .lab, .inspect, .metrics, .trace { padding: 18px 20px; }
.lesson h1 { font-family: var(--display); font-size: 24px; letter-spacing: -.02em; line-height: 1.2; margin: 10px 0 8px; }
.lede { color: var(--lede); font-size: 15px; margin: 0 0 14px; }
.lesson-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--card); border: 1px solid var(--line2); color: var(--muted); }
.pill.ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.md { color: var(--body-ink); }
.md h2, .lesson h2, .lab h2 { font-family: var(--display); font-size: 18px; margin: 26px 0 8px; letter-spacing: -.01em; }
.md h3, .lab h3, .inspect h3, .metrics h3 { font-size: 14px; margin: 20px 0 6px; color: var(--text); }
.md h4 { font-size: 13px; margin: 16px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.md p { margin: 8px 0; }
.md ul, .md ol { padding-left: 20px; margin: 8px 0; }
.md li { margin: 4px 0; }
.md code { font: 12.5px var(--mono); background: var(--code-bg); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; color: var(--text); }
.md pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; }
.md pre code { background: none; border: 0; padding: 0; color: var(--text); font-size: 12px; line-height: 1.55; }
.md strong { color: var(--text); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.md blockquote { margin: 14px 0; padding: 10px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line2); border-left: 3px solid var(--blue); }
.md blockquote p { margin: 4px 0; }
.md blockquote.bq-interview { border-left-color: var(--violet); background: color-mix(in srgb, var(--violet) 6%, transparent); }
.md blockquote.bq-warning, .md blockquote.bq-pitfall { border-left-color: var(--amber); background: color-mix(in srgb, var(--amber) 7%, transparent); }
.md blockquote.bq-tryit { border-left-color: var(--green); background: color-mix(in srgb, var(--green) 6%, transparent); }
.md blockquote.bq-numbers { border-left-color: var(--pink); }
.md blockquote.bq-keyidea { border-left-color: var(--blue); background: var(--accent-soft); }
.table-wrap { overflow-x: auto; margin: 10px 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--card); color: var(--muted); font-weight: 600; }
.cta { display: flex; align-items: center; gap: 12px; margin: 24px 0 10px; padding: 14px; border-radius: 12px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--blue) 35%, transparent); }
.cta .muted { font-size: 12.5px; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; }

.quiz .q { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); }
.q-t { font-weight: 600; margin-bottom: 8px; }
.opt { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line2); padding: 8px 10px; border-radius: 9px; margin: 5px 0; font-size: 13px; }
.opt:hover:not(:disabled) { border-color: var(--blue); }
.opt.right { border-color: var(--green); background: var(--ok-bg); }
.opt.wrong { border-color: var(--red); background: var(--bad-bg); }
.opt:disabled { cursor: default; }
.why { font-size: 13px; color: var(--body-ink); margin-top: 8px; }

.lab-run { font-size: 13px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.timeline { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.ev { display: flex; gap: 10px; font-size: 12.5px; }
.ev .at { font: 600 11px var(--mono); color: var(--amber); min-width: 34px; }
.goal { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; background: var(--bg2); }
.goal small { display: block; font-size: 10.5px; color: var(--dim); }
.goal .gv { text-align: right; font: 600 13px var(--mono); }
.goal .gi { font-weight: 800; text-align: center; color: var(--dim); }
.goal.ok .gi, .goal.pass .gi { color: var(--green); }
.goal.pass { border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.goal.fail { border-color: color-mix(in srgb, var(--red) 55%, transparent); background: color-mix(in srgb, var(--red) 6%, transparent); }
.goal.fail .gi, .goal.fail .gv { color: var(--red); }
.goal.warn { border-color: color-mix(in srgb, var(--amber) 50%, transparent); }
.goal.warn .gi, .goal.warn .gv { color: var(--amber); }
.lab-actions { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.hint { font-size: 13px; background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent); border-radius: 10px; padding: 9px 11px; margin: 6px 0; }
.solution { margin-top: 18px; display: flex; gap: 10px; align-items: center; font-size: 12px; }

/* inspector */
.ins-head { display: flex; gap: 10px; align-items: center; }
.ins-head .ico { font-size: 24px; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--card); border: 1px solid var(--line2); box-shadow: inset 0 -2px var(--accent); }
.ins-head input { background: transparent; border: 1px solid transparent; font-weight: 700; font-size: 16px; padding: 2px 4px; border-radius: 6px; width: 100%; }
.ins-head input:hover, .ins-head input:focus { border-color: var(--line2); outline: none; background: var(--bg2); }
.ins-head small { display: block; color: var(--dim); padding-left: 5px; font-size: 11px; }
.ins-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.form { display: flex; flex-direction: column; gap: 2px; }
.field { display: grid; grid-template-columns: 1fr 132px; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.field label { font-size: 12.5px; color: var(--body-ink); }
.field input[type=number], .field select { width: 100%; background: var(--bg2); border: 1px solid var(--line2); border-radius: 7px; padding: 5px 7px; font-size: 12.5px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--blue); }
.help { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--dim); color: var(--dim); font-size: 10px; font-style: normal; margin-left: 6px; cursor: help; }
.range { display: flex; align-items: center; gap: 6px; }
.range input { flex: 1; min-width: 0; accent-color: var(--blue); }
.range output { font: 11px var(--mono); width: 34px; text-align: right; }
.switch { position: relative; width: 38px; height: 21px; justify-self: end; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line2); border-radius: 20px; transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: var(--card); border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px var(--shadow-strong); }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::before { transform: translateX(17px); background: var(--card); }
table.kv { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.kv td { padding: 5px 0; border-bottom: 1px solid var(--line); }
table.kv td:first-child { color: var(--muted); }
table.kv td:last-child { text-align: right; font-family: var(--mono); }
table.kv small { color: var(--dim); }
.st { font: 700 10.5px var(--mono); padding: 2px 6px; border-radius: 5px; }
.st-healthy { color: var(--green); background: var(--ok-bg); }
.st-stressed { color: var(--orange); background: var(--warn-bg); }
.st-saturated { color: var(--red); background: var(--bad-bg); }
.st-down { color: var(--on-accent); background: var(--red); }
.insight { border: 1px solid var(--line2); border-left: 3px solid var(--dim); border-radius: 10px; padding: 8px 11px; margin: 8px 0; font-size: 12.5px; background: var(--bg2); }
.insight b { font-size: 13px; }
.insight p { margin: 3px 0; color: var(--body-ink); }
.insight .fix { color: var(--blue); }
.insight.sev-bad { border-left-color: var(--red); }
.insight.sev-warn { border-left-color: var(--amber); }
.insight.sev-good { border-left-color: var(--green); }
.empty-state { text-align: center; padding-top: 60px; }
.empty-state .big { font-size: 40px; }

/* metrics */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; }
.tile span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); }
.tile b { font: 600 14px var(--mono); }
.metrics h3 small { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 6px; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 3px 0 6px; vertical-align: -1px; }
.chart-box { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 4px; min-height: 60px; }
.chart .grid { stroke: var(--line); }
.chart .threshold { stroke: var(--red); stroke-dasharray: 4 3; opacity: .7; }
.chart .axis { fill: var(--dim); font: 9.5px var(--mono); }
.log { font: 11.5px/1.45 var(--mono); max-height: 260px; overflow-y: auto; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.log .l { padding: 2px 0; color: var(--body-ink); }
.log .l span { color: var(--dim); margin-right: 8px; }
.log .lv-chaos { color: var(--orange); }
.log .lv-bad { color: var(--red); }
.log .lv-good { color: var(--green); }

/* trace */
.trace-tabs { display: flex; gap: 4px; margin: 10px 0; }
.trace-tabs button { background: var(--card); border: 1px solid var(--line2); border-radius: 8px; padding: 5px 10px; font-size: 12px; }
.trace-tabs button.active { border-color: var(--blue); color: var(--blue); }
.tr-total { font-size: 13px; margin-bottom: 10px; }
.span { display: grid; grid-template-columns: 130px 1fr 54px; align-items: center; gap: 8px; padding: 3px 0; font-size: 12px; }
.sp-name { padding-left: calc(var(--d) * 8px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-name span { margin-right: 5px; }
.sp-bar { position: relative; height: 16px; background: var(--muted-bg); border-radius: 4px; }
.sp-all { position: absolute; top: 2px; bottom: 2px; background: color-mix(in srgb, var(--c) 28%, transparent); border-radius: 3px; display: flex; overflow: hidden; }
.sp-all .net { background: var(--dim); height: 100%; }
.sp-all .own { background: var(--c); height: 100%; }
.span.down .sp-all { background: color-mix(in srgb, var(--red) 50%, transparent); }
.sp-ms { font: 11px var(--mono); text-align: right; color: var(--muted); }

/* sandbox templates */
.templates { display: grid; gap: 8px; }
.tpl { text-align: left; background: var(--card); border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; }
.tpl:hover { border-color: var(--blue); }
.tpl b { display: block; }
.tpl span { font-size: 12px; color: var(--muted); }

/* calculator */
.calc { margin: 22px 0; padding: 14px; border: 1px solid var(--line2); border-radius: 12px; background: var(--bg2); }
.calc h2 { margin-top: 0 !important; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 14px; }
.calc-grid label { display: flex; flex-direction: column; font-size: 11.5px; color: var(--muted); gap: 3px; }
.calc-grid input { background: var(--card); border: 1px solid var(--line2); border-radius: 7px; padding: 5px 7px; font: 12.5px var(--mono); }

/* context menu, toasts, modal */
.ctx-menu { position: fixed; z-index: 80; background: var(--card); border: 1px solid var(--line2); border-radius: 10px; padding: 5px; min-width: 190px; display: none; box-shadow: 0 14px 34px -10px var(--shadow-strong); }
.ctx-menu.open { display: block; }
.toasts { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--card2); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 14px; font-size: 13px; box-shadow: 0 10px 26px -8px var(--shadow-strong); animation: pop .2s; max-width: 520px; transition: opacity .4s; }
.toast.warn { border-color: var(--amber); }
.toast.bad { border-color: var(--red); }
.toast.out { opacity: 0; }
.modal-wrap { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(3px); z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-wrap.open { display: flex; }
.modal { position: relative; background: var(--panel); border: 1px solid var(--line2); border-radius: 18px; padding: 26px; max-width: 580px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 30px 70px -24px var(--shadow-strong); animation: pop .25s; }
.modal-x { position: absolute; right: 12px; top: 12px; background: none; border: 0; color: var(--muted); font-size: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.welcome h1 { font-family: var(--display); font-size: 27px; letter-spacing: -.02em; margin: 6px 0 10px; }
.logo-big { font-size: 40px; color: var(--blue); }
.how { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.how div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.how b { display: block; color: var(--blue); }
.how span { font-size: 12.5px; color: var(--muted); }
.result .big { font-family: var(--display); font-size: 24px; font-weight: 700; }
.result li { margin: 6px 0; }
.debrief { margin-top: 10px; padding: 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-size: 13px; }

/* ---------- interview practice ---------- */
.iv-head { position: relative; }
.iv-head h1 { padding-right: 96px; }
.iv-clock { position: absolute; right: 0; top: 0; text-align: right; padding: 6px 10px; border: 1px solid var(--line2); border-radius: 10px; background: var(--bg2); }
.iv-clock span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.iv-clock b { font: 600 18px var(--mono); }
.iv-clock.low { border-color: color-mix(in srgb, var(--amber) 55%, transparent); }
.iv-clock.low b { color: var(--amber); }
.iv-clock.over { border-color: color-mix(in srgb, var(--red) 55%, transparent); background: color-mix(in srgb, var(--red) 6%, transparent); }
.iv-clock.over b { color: var(--red); }
.iv-steps { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 14px; }
.iv-step { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--dim); padding: 3px 9px 3px 4px; border-radius: 20px; border: 1px solid var(--line); }
.iv-step i { font-style: normal; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font: 700 10px var(--mono); background: var(--muted-bg); }
.iv-step.cur { color: var(--text); border-color: var(--blue); background: var(--accent-soft); }
.iv-step.cur i { background: var(--blue); color: var(--on-accent); }
.iv-step.done { color: var(--muted); }
.iv-step.done i { background: var(--green); color: var(--on-accent); }
.iv-req { display: flex; gap: 9px; align-items: flex-start; padding: 8px 10px; margin: 5px 0; border: 1px solid var(--line2); border-radius: 9px; background: var(--card); font-size: 13px; cursor: pointer; }
.iv-req:hover { border-color: var(--blue); }
.iv-req input { margin-top: 3px; accent-color: var(--blue); flex: none; }
.iv-req small { display: block; font-size: 12px; color: var(--body-ink); margin-top: 3px; }
.iv-req.right { border-color: var(--green); background: var(--ok-bg); }
.iv-req.wrong { border-color: var(--red); background: var(--bad-bg); }
.iv-req.missed { border-color: var(--amber); border-style: dashed; }
.iv-req.skip { opacity: .7; }
.iv-req:has(input:disabled) { cursor: default; }
.iv-est { display: grid; gap: 10px; margin: 14px 0; }
.iv-est label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.iv-est input, .iv-est select { background: var(--card); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 9px; font: 13px var(--mono); min-width: 0; width: 100%; }
.iv-est input:focus, .iv-est select:focus { outline: 2px solid color-mix(in srgb, var(--blue) 40%, transparent); border-color: var(--blue); }
.iv-ratio { display: flex; align-items: center; gap: 6px; }
.iv-ratio input { flex: 1 1 0; width: 0; }
.iv-ratio select { flex: none; width: auto; }
.iv-ratio b { color: var(--muted); }
.iv-est-row { border: 1px solid var(--line2); border-left: 3px solid var(--dim); border-radius: 10px; padding: 9px 11px; margin: 8px 0; background: var(--bg2); font-size: 13px; }
.iv-est-row.ok { border-left-color: var(--green); }
.iv-est-row.bad { border-left-color: var(--red); }
.iv-est-top { display: flex; justify-content: space-between; gap: 8px; }
.iv-tag { font: 600 11px var(--mono); color: var(--muted); white-space: nowrap; }
.iv-est-row.ok .iv-tag { color: var(--green); }
.iv-est-row.bad .iv-tag { color: var(--red); }
.iv-est-vals { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin: 3px 0; }
.iv-est-vals b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.iv-how { font-size: 12.5px; color: var(--body-ink); }
.iv-score { margin: 14px 0 4px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 13.5px; }
.iv-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.iv-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 26px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.iv-total { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line2); margin: 4px 0 12px; }
.iv-total span { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.iv-total b { grid-row: span 2; font: 700 34px var(--display); letter-spacing: -.02em; }
.iv-total b small { font-size: 15px; color: var(--muted); }
.iv-total em { font-style: normal; font-weight: 600; }
.iv-total.pass { border-color: color-mix(in srgb, var(--green) 50%, transparent); background: var(--ok-bg); }
.iv-total.pass em { color: var(--green); }
.iv-total.fail { border-color: color-mix(in srgb, var(--red) 45%, transparent); background: var(--bad-bg); }
.iv-total.fail em { color: var(--red); }
.iv-list { font-size: 13px; padding-left: 18px; }
.iv-list li { margin: 5px 0; }
.iv-prompt { display: block; color: var(--text); }
.iv-prompt:hover { text-decoration: none; }
.iv-best { display: inline-block; margin-top: 5px; font: normal 600 11px var(--mono); color: var(--green); }
.iv-hist td:last-child { font-family: var(--sans); }

/* ---------- responsive ---------- */
@media (max-width: 1250px) {
  :root { --side: 230px; --panelw: 360px; }
  .brand-tag { display: none; }
}
@media (max-width: 980px) {
  .main { grid-template-columns: 1fr; }
  .only-mobile { display: grid; }
  .sidebar { position: fixed; left: 0; top: var(--top); bottom: 0; width: min(300px, 85vw); z-index: 40; transform: translateX(-100%); transition: transform .25s; box-shadow: 20px 0 50px var(--shadow-strong); }
  body.show-sidebar .sidebar { transform: none; }
  .panel { position: fixed; right: 0; top: var(--top); bottom: 0; width: min(420px, 100vw); z-index: 40; transform: translateX(100%); transition: transform .25s; box-shadow: -20px 0 50px var(--shadow-strong); }
  body.show-panel .panel { transform: none; }
  .crumb { display: none; }
  .clock { display: none; }
}
@media (max-width: 560px) {
  .brand-name { display: none; }
  .top-actions #btn-undo, .top-actions #btn-redo, #speed { display: none; }
  .topbar { gap: 5px; padding: 0 6px; }
  .run-ctl, .top-actions { gap: 4px; }
  #btn-chaos { padding: 7px 9px; }
  #btn-chaos .lbl { display: none; }
  #btn-run { padding: 7px 11px; }
  .icon-btn { width: 32px; height: 32px; }
  .kpi { min-width: 58px; padding: 3px 8px; }
  .how { grid-template-columns: 1fr; }
  .field { grid-template-columns: 1fr 120px; }
}

/* ---------- explain-on-hover ---------- */
.tip {
  position: fixed; z-index: 120; max-width: 300px; padding: 9px 11px; border-radius: 10px;
  background: var(--panel); color: var(--body-ink); border: 1px solid var(--line2);
  box-shadow: 0 12px 30px -10px var(--shadow-strong); font: 12.5px/1.45 var(--sans);
  pointer-events: none; opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s;
}
.tip.show { opacity: 1; transform: none; }
.tip b { display: block; color: var(--text); font-size: 13px; margin-bottom: 2px; }
.tip span b { display: inline; font-size: inherit; margin: 0; }
[data-tip]:not(.node-head):not(.edge-hit):not(.pal-item):not(.kpi):not(.tile):not(h3) { cursor: help; }
.kpi[data-tip], .tile[data-tip], .metrics h3[data-tip] { cursor: help; }
td.has-tip { text-decoration: underline dotted var(--dim); text-underline-offset: 3px; cursor: help; }
.help:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
