/* dsviz: one stylesheet for every page. Colors are tokens on :root; the dark theme
   redefines them. js/linkedlist.js reads the --viz-* tokens to draw the canvas. */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --border: #e3e8f0;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2f5bea;
  --accent-hover: #2249c9;
  --accent-soft: #e8eeff;
  --accent-text: #2441a8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;

  /* canvas */
  --viz-bg: #ffffff;
  --viz-node: #ffffff;
  --viz-stroke: #1f2937;
  --viz-text: #111827;
  --viz-named: #2563eb;    /* the variable a node was created with: x, y... */
  --viz-pointer: #dc2626;  /* pointers: p, curr, slow... */
  --viz-local: #7c3aed;    /* local variables of a function call */
  --viz-changed: #f59e0b;  /* what the last step changed */

  /* code editor */
  --code-bg: #fbfcfe;
  --cm-keyword: #8b2fc9;
  --cm-def: #2563eb;
  --cm-number: #0f766e;
  --cm-string: #b45309;
  --cm-comment: #6b7280;
  --cm-atom: #2563eb;
  --cm-active: #f1f4fb;
  --cm-selection: #dbe4ff;
  --cm-gutter: #b0b8c8;

  /* line highlighting while the animation runs */
  --hl-line: #fff3b0;
  --hl-true: #c8f7c5;
  --hl-false: #ffd2cf;

  --console-bg: #0f172a;
  --console-text: #e2e8f0;
  --console-muted: #64748b;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f141c;
  --surface: #161d28;
  --surface-2: #1b2330;
  --border: #283244;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #6d8dff;
  --accent-hover: #8aa3ff;
  --accent-soft: #1f2b47;
  --accent-text: #b9c8ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .35);

  --viz-bg: #161d28;
  --viz-node: #1e2836;
  --viz-stroke: #cbd5e1;
  --viz-text: #f1f5f9;
  --viz-named: #7aa2ff;
  --viz-pointer: #ff7b72;
  --viz-local: #c4a5ff;
  --viz-changed: #fbbf24;

  --code-bg: #121924;
  --cm-keyword: #c792ea;
  --cm-def: #82aaff;
  --cm-number: #f78c6c;
  --cm-string: #c3e88d;
  --cm-comment: #7f8ba3;
  --cm-atom: #89ddff;
  --cm-active: #1a2332;
  --cm-selection: #2a3a5c;
  --cm-gutter: #4b5870;

  --hl-line: #4a4320;
  --hl-true: #1f4d2b;
  --hl-false: #5a2626;

  --console-bg: #0a0f17;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--accent-soft); color: var(--accent-text); padding: 1px 5px; border-radius: 5px; font: .88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
kbd { background: var(--text); color: var(--bg); border-radius: 4px; padding: 1px 5px; font-size: .8em; }
h1 { font-size: 26px; line-height: 1.25; margin: 4px 0 8px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 28px 0 10px; }
.lead { color: var(--muted); margin-top: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--accent); }
.topbar .page-name { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); border-color: transparent; }
.menu-btn { width: auto; padding: 0 12px 0 10px; gap: 8px; font-weight: 600; font-size: 14px; }

/* ---------- settings panel (gear button in the top bar) ---------- */
.settings-panel {
  position: fixed; top: 62px; right: 16px; z-index: 40;
  width: min(340px, calc(100vw - 32px)); max-height: calc(100vh - 80px); overflow: auto;
  padding: 12px 16px 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.settings-panel[hidden] { display: none; }
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.settings-head strong { font-size: 15px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.setting > span { font-weight: 600; }
.setting select { font: inherit; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.setting-note { font-size: 12px; color: var(--muted); margin: -4px 0 6px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.segmented label { margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 5px 10px; font-size: 13px; }
.segmented label + label span { border-left: 1px solid var(--border); }
.segmented input:checked + span { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .segmented input:checked + span { color: #0f141c; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.setting.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.link-btn { border: 0; background: none; padding: 8px 0 0; color: var(--accent); cursor: pointer; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

/* code font size (setting) */
:root[data-font="large"] .CodeMirror { font-size: 16px; }
:root[data-font="xlarge"] .CodeMirror { font-size: 18px; }

/* ---------- drawer with all examples ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(15, 23, 42, .35); opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 31;
  width: min(320px, 88vw); overflow: auto; padding: 14px 12px 24px;
  background: var(--surface); border-right: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  transform: translateX(-102%); transition: transform .22s ease;
}
body.drawer-open .drawer { transform: none; }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 6px 8px; }
.drawer-head strong { font-size: 15px; }
/* menu groups fold like submenus */
.drawer-group { margin-top: 2px; }
.drawer-group-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer;
}
.drawer-group-btn:hover { background: var(--surface-2); }
.drawer-group-btn > span:first-child { flex: 1; }
.drawer-group.current > .drawer-group-btn { color: var(--accent-text); }
.drawer-count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; }
.drawer-chevron { flex: none; color: var(--muted); transition: transform .15s; }
.drawer-group.open .drawer-chevron { transform: rotate(90deg); }
.drawer-items { display: none; margin: 0 0 6px 10px; padding-left: 8px; border-left: 2px solid var(--border); }
.drawer-group.open .drawer-items { display: block; }
.drawer a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: 14px; line-height: 1.35; }
.drawer a:hover { background: var(--surface-2); text-decoration: none; }
.drawer a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* ---------- two-column workspace ---------- */
.layout {
  display: grid; grid-template-columns: minmax(360px, 1fr) minmax(480px, 1.25fr);
  gap: 24px; max-width: 1560px; margin: 0 auto; padding: 22px 24px 40px;
}
.lesson { min-width: 0; }
.viz-col { min-width: 0; }
.viz { position: sticky; top: 72px; overflow: hidden; }

/* reference tables in a lesson (the language guide) */
.table-wrap { overflow-x: auto; margin: 8px 0 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ref-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ref-table th, .ref-table td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.ref-table tr:last-child td { border-bottom: 0; }
.ref-table th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); }
.ref-table td:first-child { white-space: nowrap; }

/* code blocks */
.code-card { position: relative; margin: 8px 0 24px; }
.code-label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 6px 2px; }
.CodeMirror {
  height: auto; border: 1px solid var(--border); border-radius: var(--radius);
  font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 8px 4px 46px 0;
}
.CodeMirror-focused { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* editor theme "dsv" (colors come from the tokens above) */
.cm-s-dsv.CodeMirror { background: var(--code-bg); color: var(--text); }
.cm-s-dsv .CodeMirror-gutters { background: transparent; border-right: 0; }
.cm-s-dsv .CodeMirror-linenumber { color: var(--cm-gutter); }
.cm-s-dsv .CodeMirror-cursor { border-left-color: var(--text); }
.cm-s-dsv .CodeMirror-activeline-background { background: var(--cm-active); }
.cm-s-dsv .CodeMirror-selected, .cm-s-dsv.CodeMirror-focused .CodeMirror-selected { background: var(--cm-selection); }
.cm-s-dsv .cm-keyword { color: var(--cm-keyword); font-weight: 600; }
.cm-s-dsv .cm-def { color: var(--cm-def); }
.cm-s-dsv .cm-variable, .cm-s-dsv .cm-variable-2, .cm-s-dsv .cm-property, .cm-s-dsv .cm-operator { color: var(--text); }
.cm-s-dsv .cm-number { color: var(--cm-number); }
.cm-s-dsv .cm-string { color: var(--cm-string); }
.cm-s-dsv .cm-comment { color: var(--cm-comment); font-style: italic; }
.cm-s-dsv .cm-atom { color: var(--cm-atom); }
.cm-s-dsv .cm-variable-3, .cm-s-dsv .cm-type { color: var(--cm-def); font-weight: 600; } /* C++ types: int, Node */
.cm-s-dsv .cm-meta { color: var(--cm-comment); }                                            /* #include */
.cm-s-dsv .cm-builtin { color: var(--cm-keyword); }
.cm-s-dsv .CodeMirror-matchingbracket { color: var(--accent) !important; }

/* run button the engine adds after every editor */
.dsv-run {
  position: absolute; right: 10px; bottom: 10px; z-index: 3;
  height: 34px; padding: 0 14px 0 12px; border: 0; border-radius: 9px;
  background: var(--accent); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px;
}
.dsv-run:hover { background: var(--accent-hover); }
.dsv-run svg { flex: none; }
:root[data-theme="dark"] .dsv-run { color: #0f141c; }

/* the line an error happened on */
.dsv-error-line { background: color-mix(in srgb, var(--viz-pointer) 18%, transparent); box-shadow: inset 3px 0 0 var(--viz-pointer); }

/* shares the page's code as a link */
.dsv-share {
  position: absolute; right: 118px; bottom: 10px; z-index: 3;
  width: 34px; height: 34px; padding: 0; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.dsv-share:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }

/* a page opened from a shared link */
.share-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 4px 0 16px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-text); font-size: 14px;
}

/* a short message at the bottom of the window */
.dsv-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); z-index: 50; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.dsv-toast.show { opacity: 1; transform: translate(-50%, 0); }
.share-banner .link-btn { padding: 0; font-weight: 600; font-size: 14px; }

/* puts the example's own code back (shown once the code was changed) */
.dsv-restore {
  position: absolute; right: 160px; bottom: 10px; z-index: 3;
  height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 13px; font-weight: 600;
}
.dsv-restore:hover { background: var(--accent-soft); border-color: transparent; }
.dsv-restore[hidden] { display: none; }

/* highlighting of the running line */
.styled-background-normal { background: var(--hl-line); }
.styled-background-logical-true { background: var(--hl-true); }
.styled-background-logical-false { background: var(--hl-false); }

/* ---------- visualisation card ---------- */
.dsv-player { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.dsv-btn { width: 34px; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.dsv-btn:hover { background: var(--accent-soft); border-color: transparent; }
/* play / pause / play again: the main button, in every language (it used to match the Turkish title) */
.dsv-btn.dsv-play { background: var(--accent); color: #fff; border-color: var(--accent); }
.dsv-btn.dsv-play:hover { background: var(--accent-hover); }
:root[data-theme="dark"] .dsv-btn.dsv-play { color: #0f141c; }
.dsv-btn:disabled, .dsv-btn.dsv-play:disabled { opacity: .4; cursor: default; background: var(--surface); color: var(--text); border-color: var(--border); }
.dsv-speed { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; }
.dsv-speed input { width: 90px; accent-color: var(--accent); }
.dsv-counter { margin-left: auto; font-variant-numeric: tabular-nums; }
.dsv-timeline { flex-basis: 100%; width: 100%; margin: 4px 0 0; accent-color: var(--accent); }

/* one sentence about the last step, and a warning about nodes that got lost */
.dsv-narration { padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.5; min-height: 38px; display: flex; flex-direction: column; gap: 2px; }
.dsv-narration:empty::before { content: attr(data-empty); color: var(--muted); font-size: 13px; }
.dsv-narration code { font-size: .9em; }
.narration-warning { color: var(--viz-pointer); font-weight: 600; }

.viz-canvas { background: var(--viz-bg); }
.viz-canvas canvas { display: block; }

.viz-vars { border-top: 1px solid var(--border); padding: 10px 14px; }
.panel-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
#variables { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
#variables:empty::before { content: attr(data-empty); color: var(--muted); font-size: 13px; }
#variables li { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font: 13px ui-monospace, Menlo, Consolas, monospace; }
#variables .value { font-weight: 700; }
#variables li.is-null .name, #variables li.is-null .value { color: var(--viz-pointer); }
#variables li.changed { animation: dsv-flash .8s ease; }
@keyframes dsv-flash { from { background: var(--hl-line); } to { background: var(--surface-2); } }

.tabs { display: flex; align-items: center; gap: 4px; padding: 8px 10px 0; border-top: 1px solid var(--border); }
.tab { border: 0; background: none; padding: 6px 10px; border-radius: 8px 8px 0 0; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.tab.active { color: var(--accent-text); background: var(--accent-soft); }
.tab-body { padding: 10px 12px 12px; }
#output { margin: 0; min-height: 44px; max-height: 160px; overflow: auto; background: var(--console-bg); color: var(--console-text); border-radius: 8px; padding: 10px 12px; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; }
#output:empty::before { content: attr(data-empty); color: var(--console-muted); }
.command-wrap .CodeMirror { padding: 4px 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
#resultSign { font-size: 12px; margin-left: 8px; }
#resultSign.label-success { color: #16a34a; }
#resultSign.label-warning { color: var(--viz-pointer); }

/* call stack: the running calls, innermost on top */
.viz-stack { border-top: 1px solid var(--border); padding: 10px 14px; }
#callstack { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#callstack li { border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface-2); }
#callstack li.current { border-left-color: var(--viz-local); }
.frame-head { font: 600 13px ui-monospace, Menlo, Consolas, monospace; color: var(--viz-local); }
.frame-vars { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; font: 12px ui-monospace, Menlo, Consolas, monospace; color: var(--text); }
.frame-var.is-null { color: var(--viz-pointer); }
#callstack-note { font-size: 12px; color: var(--muted); margin-top: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; }
#callstack-note:empty { display: none; }

/* ---------- main page: example groups ---------- */
.example-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 8px; }
.example-group { padding: 14px 16px; }
.example-group h3 { margin: 0 0 6px; font-size: 14px; color: var(--accent-text); }
.example-group ul { margin: 0; padding-left: 18px; }
.example-group li { margin: 3px 0; font-size: 14px; line-height: 1.4; }

/* previous / next example */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 14px; }
.pager a { display: block; max-width: 48%; }
.pager .next { text-align: right; margin-left: auto; }
.pager small { display: block; color: var(--muted); }

.footer { margin-top: 32px; font-size: 13px; color: var(--muted); }

/* lesson mode: one part of the page at a time */
.lesson-toggle {
  display: inline-flex; align-items: center; height: 30px; margin: -4px 0 10px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--accent-text);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.lesson-toggle:hover, .lesson-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; }
.lesson-hidden { display: none !important; }
.lesson-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 20px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.lesson-nav[hidden] { display: none; }
.lesson-nav button {
  height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer;
}
:root[data-theme="dark"] .lesson-nav button { color: #0f141c; }
.lesson-nav button:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.lesson-count { font-size: 13px; color: var(--muted); font-weight: 600; }

/* folding the panels under the canvas: only on narrow screens */
.viz-folds { display: none; }
.fold-btn {
  flex: 1 1 0; min-width: 0; height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative;
}
.fold-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.fold-btn[hidden] { display: none; }
.fold-count { color: var(--muted); font-weight: 500; }
.fold-btn.has-news::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--viz-changed); }

/* ---------- narrow screens ---------- */
@media (max-width: 960px) {
  .viz-folds { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); }
  .viz:not([data-open="stack"]) .viz-stack,
  .viz:not([data-open="vars"]) .viz-vars,
  .viz:not([data-open="out"]) .viz-out { display: none; }
  .layout { grid-template-columns: 1fr; padding: 14px 14px 32px; gap: 14px; }
  /* the visualisation comes first and stays in view while the code scrolls under it */
  .viz-col { order: -1; position: sticky; top: 56px; z-index: 10; }
  .viz { position: static; max-height: 48vh; overflow: auto; }
  .topbar .page-name { display: none; }
  .menu-btn .label { display: none; }
  .menu-btn { width: 38px; padding: 0; }
}

/* ---------- the introduction tour (js/layout.js) ---------- */
.tour-block { position: fixed; inset: 0; z-index: 60; }
.tour-spot {
  position: fixed; z-index: 61; pointer-events: none; border-radius: 12px;
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 100vmax rgba(10, 15, 28, .62);
  transition: left .25s, top .25s, width .25s, height .25s;
}
.tour-spot-none { left: 50%; top: 50%; width: 0; height: 0; box-shadow: 0 0 0 100vmax rgba(10, 15, 28, .62); }
.tour-card {
  position: fixed; z-index: 62; width: 380px; padding: 16px 18px 12px; box-sizing: border-box;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28); transition: left .25s, top .25s;
}
.tour-count { font-size: 12px; color: var(--muted); }
.tour-title { margin: 2px 0 6px; font-size: 17px; }
.tour-text { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: var(--text); }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-actions .spacer { flex: 1; }
.tour-actions .link-btn { padding: 0; }
.tour-back, .tour-next {
  font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.tour-next { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tour-back[hidden] { display: none; }
.tour-on .settings-panel { z-index: 59; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-card { transition: none; } }
.settings-panel .link-btn { display: block; }

.dsv-stats { font-variant-numeric: tabular-nums; }
.dsv-stats[hidden] { display: none; }

/* ---------- lesson plans (js/layout.js, js/plan.js; teacher.html, plan.html) ---------- */
.plan-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; margin: 0 0 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 13px; }
.plan-bar .plan-name { font-weight: 600; color: var(--accent); text-decoration: none; margin-right: auto; }
.plan-bar .plan-name:hover { text-decoration: underline; }
.plan-bar .plan-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-bar .plan-prev, .plan-bar .plan-next { padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; }
.plan-bar .plan-next { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.plan-note { margin: 0 0 14px; padding: 10px 14px; border-left: 4px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--surface); font-size: 14px; line-height: 1.5; white-space: pre-line; }
.drawer-teacher { font-weight: 600; }

.layout-plain { display: block; max-width: 1040px; }
.tp-field { display: block; margin: 0 0 14px; }
.tp-field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.tp-field input[type=text], .tp-field textarea, .tp-field select, .tp-note, .tp-linkbox input { width: 100%; box-sizing: border-box; font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.tp-field textarea { min-height: 70px; resize: vertical; }
.tp-row { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin: 0 0 14px; }
.tp-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.tp-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.tp-chip { font: inherit; font-size: 13px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; }
.tp-chip:hover { border-color: var(--accent); color: var(--accent); }
.tp-help { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.tp-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
@media (max-width: 800px) { .tp-cols { grid-template-columns: 1fr; } }
.tp-box { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 12px 14px; }
.tp-box h2 { margin: 0 0 8px; font-size: 16px; }
.tp-box details { margin: 0 0 6px; }
.tp-box summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }
.tp-page { display: flex; align-items: center; gap: 8px; padding: 4px 0 4px 10px; font-size: 14px; }
.tp-page span { flex: 1; min-width: 0; }
.tp-btn { font: inherit; font-size: 12.5px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; }
.tp-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.tp-btn:disabled { opacity: .45; cursor: default; }
.tp-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tp-item { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin: 0 0 8px; background: var(--bg); }
.tp-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.tp-item-head .tp-no { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.6em; }
.tp-item-head .tp-name { flex: 1; min-width: 0; }
.tp-empty { color: var(--muted); font-size: 14px; padding: 12px 0; }
.tp-linkbox { margin-top: 18px; }
.tp-linkbox .tp-row { margin: 8px 0 0; }
.tp-warn { color: var(--viz-pointer); font-size: 13px; margin-top: 6px; }
.pp-head { margin-bottom: 16px; }
.pp-intro { white-space: pre-line; font-size: 15px; line-height: 1.55; margin: 0 0 14px; }
.pp-meta { color: var(--muted); font-size: 13px; margin: 0 0 4px; }
.pp-progress { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin: 8px 0 14px; }
.pp-progress > div { height: 100%; background: var(--accent); transition: width .3s; }
.pp-list { list-style: none; padding: 0; margin: 0 0 18px; }
.pp-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin: 0 0 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.pp-item.done { border-color: var(--accent); }
.pp-no { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pp-item.done .pp-no { background: var(--accent); border-color: var(--accent); color: #fff; }
.pp-body { flex: 1; min-width: 0; }
.pp-body a { font-weight: 600; font-size: 15px; text-decoration: none; color: var(--text); }
.pp-body a:hover { color: var(--accent); text-decoration: underline; }
.pp-group { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.pp-note { margin: 6px 0 0; font-size: 14px; line-height: 1.5; white-space: pre-line; }
.pp-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* exercise pages: the check under the student's block (js/exercise.js) */
.exercise-panel { margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.ex-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ex-check {
  height: 36px; padding: 0 16px; border: 0; border-radius: 9px; background: var(--accent); color: #fff;
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.ex-check:hover { background: var(--accent-hover); }
:root[data-theme="dark"] .ex-check { color: #0f141c; }
.ex-status { font-weight: 600; font-size: 13px; color: var(--accent-text); }
.ex-attempts { color: var(--muted); font-size: 13px; }
.ex-result { margin-top: 10px; padding: 10px 12px; border-radius: 9px; font-size: 14px; color: var(--text); }
.ex-result.ok { background: var(--hl-true); }
.ex-result.bad { background: var(--hl-false); }
.ex-result ul { margin: 6px 0 0; padding-left: 20px; }
.ex-result[hidden] { display: none; }
.ex-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ex-hint-btn, .ex-solution-btn {
  height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer;
}
.ex-hint-btn:hover:not(:disabled), .ex-solution-btn:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.ex-hint-btn:disabled { opacity: .55; cursor: default; }
.ex-hint-list { margin: 10px 0 0; padding-left: 22px; font-size: 14px; }
.ex-hint-list:empty { display: none; }
.ex-solution { margin-top: 10px; }
.ex-solution summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.ex-solution pre { margin: 8px 0 0; padding: 10px 12px; overflow: auto; border-radius: 9px; background: var(--code-bg); border: 1px solid var(--border); font-size: 13px; }
.ex-hints, .ex-solution-source { display: none; }
.ex-mark { color: #16a34a; font-weight: 700; margin-left: 4px; }
.ex-hint-note { align-self: center; color: var(--muted); font-size: 13px; }
.ex-hint-note[hidden] { display: none; }
