:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: #292722;
  background: #f4f0e6;
  font-synthesis: none;
  --ink: #28241f;
  --ink-soft: #39342e;
  --muted: #625c53;
  --subtle: #81796d;
  --line: #d8d0c1;
  --line-soft: #e5ddcf;
  --paper: #fffdf8;
  --wash: #f4f0e6;
  --panel-tint: #eee9dd;
  --surface-hover: #f8f5ee;
  --accent: #e66b35;
  --accent-deep: #c85225;
  --accent-wash: #f7e4d7;
  --blue: var(--accent);
  --blue-deep: var(--accent-deep);
  --blue-wash: var(--accent-wash);
  --green: var(--accent);
  --red: #b84232;
  --red-wash: #f7e5df;
  --amber: var(--accent);
  --amber-bright: #ed9a72;
  --amber-wash: #f8e8dd;
  --neutral-edge: #48433c;
  --pointer: #302c27;
  --visited: #f2eee5;
  --ring: rgba(230, 107, 53, .24);
  --code-bg: #fffdf8;
  --code-edge: #d8d1c2;
  --code-ink: #292722;
  --code-muted: #686258;
  --code-gold: #e66b35;
  --shadow-sm: 0 1px 2px rgba(54, 46, 34, .07);
  --shadow-md: 0 1px 2px rgba(54, 46, 34, .07), 0 4px 12px rgba(54, 46, 34, .06);
  --shadow-lg: 0 8px 28px rgba(54, 46, 34, .14);
  --shadow-card: 0 2px 7px rgba(54, 46, 34, .08);
  --ease-out: cubic-bezier(.22, .8, .32, 1);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-width: 320px; min-height: 100%; }
body { height: 100dvh; overflow: hidden; background-color: var(--wash); background-image: linear-gradient(rgba(60, 55, 42, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(60, 55, 42, .045) 1px, transparent 1px); background-size: 40px 40px; color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .72; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
::selection { background: var(--blue-wash); }

@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes dialogIn { from { opacity: 0; transform: translateY(16px) scale(.965); } }
@keyframes drawerIn { from { opacity: 0; transform: translateY(-6px); } }

header {
  height: 46px; min-height: 46px; display: flex; align-items: center; justify-content: space-between;
  padding: 4px clamp(16px, 2.2vw, 30px); border-bottom: 1px solid var(--line); background: var(--paper);
}
.page-switcher { display:flex; align-items:center; gap:4px; min-width:0; }
.page-switcher-link { display:inline-flex; min-height:32px; align-items:center; justify-content:center; padding:0 10px; border-radius:5px; color:var(--ink-soft); font-size:14px; line-height:1.2; font-weight:600; text-decoration:none; white-space:nowrap; }
.page-switcher-link:hover { background:var(--surface-hover); color:var(--ink); }
.page-switcher-link[aria-current="page"] { background:var(--accent-wash); color:var(--accent-deep); font-weight:700; }
.brand { display: flex; flex-direction: column; justify-content: center; color: var(--ink); font-size: 17px; font-weight: 800; letter-spacing: .06em; line-height: 1.05; }
.brand span { display: block; margin-top: 2px; color: var(--subtle); font-size: 8px; font-weight: 600; letter-spacing: .34em; }
main {
  height: calc(100dvh - 46px); min-height: 0; max-width: none; margin: 0;
  padding: 8px clamp(16px, 2.2vw, 30px) 10px; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 40px auto minmax(0, 1fr) 54px; gap: 9px;
}
#nav { grid-column: 1; grid-row: 1; height: 40px; min-height: 40px; margin: 0; display: flex; align-items: center; gap: 12px; }
#catalogButton, .btn, .speed {
  min-height: 40px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink-soft); font-size: 14px; line-height: 1.2;
  box-shadow: var(--shadow-sm);
  transition: background-color .18s, border-color .18s, color .18s, box-shadow .18s, transform .12s;
}
#catalogButton:hover, .btn:not(:disabled):hover, .speed:hover { background: var(--surface-hover); border-color: #c4c7c5; }
#catalogButton:active, .btn:not(:disabled):active { transform: translateY(1px); box-shadow: none; }
#breadcrumb { min-width: 0; overflow: hidden; color: var(--muted); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
#breadcrumb strong { color: var(--ink); font-weight: 650; }
#breadcrumb i { margin: 0 8px; color: var(--subtle); font-style: normal; }

.classroom-tools {
  grid-column: 1; grid-row: 2; min-width: 0; display: grid;
  grid-template-columns: minmax(170px, max-content) minmax(0, 1fr) max-content;
  align-items: center; gap: 5px 14px; padding: 0 2px;
}
.classroom-tools > .intro, .classroom-tools > .operation-toolbar, .classroom-tools > .settings-drawer { min-width: 0; margin: 0; }
.intro { display: block; }
.intro h1, .lessons-heading h1 { font-family: ui-serif, "Songti SC", "Noto Serif CJK SC", serif; }
.intro h1 { margin: 0; color: var(--ink); font-size: 23px; line-height: 1.2; font-weight: 750; letter-spacing: -.3px; white-space: nowrap; }
.intro .eyebrow, .intro .sub { display: none; }
.operation-toolbar { min-width: 0; overflow: hidden; }
#operationButtons { display: flex; min-width: 0; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: thin; }
#operationButtons button {
  flex: 0 0 auto; min-height: 40px; padding: 8px 14px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 14px; white-space: nowrap;
  transition: background-color .18s, color .18s, box-shadow .18s;
}
#operationButtons button:hover { background: var(--surface-hover); color: var(--ink); }
#operationButtons button[aria-pressed="true"] { border-color: transparent; background: var(--blue-wash); color: var(--blue-deep); font-weight: 650; }
.settings-drawer { position: relative; margin: 0; color: var(--muted); font-size: 14px; }
.settings-drawer summary {
  min-height: 40px; display: flex; align-items: center; padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--paper); color: var(--ink-soft); cursor: pointer; list-style: none; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background-color .18s, border-color .18s;
}
.settings-drawer summary:hover { background: var(--surface-hover); border-color: #c4c7c5; }
.settings-drawer summary::-webkit-details-marker { display: none; }
.settings-drawer summary::after { content: "+"; margin-left: 8px; color: var(--subtle); transition: transform .2s; }
.settings-drawer[open] summary::after { content: "−"; }
.settings-drawer[open] { grid-column: 1 / -1; align-self: stretch; }
.settings-drawer[open] .setup { animation: drawerIn .24s var(--ease-out); }
.settings-drawer .setup {
  position: static; inset: auto; width: 100%; max-width: none; margin: 6px 0 1px; padding: 12px 14px;
  display: grid; grid-template-columns: minmax(230px, 2fr) minmax(140px, 1fr) minmax(130px, .9fr) max-content max-content;
  align-items: end; gap: 9px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-tint);
  box-shadow: var(--shadow-md); color: var(--ink); font-size: 14px;
}
.setup-heading { grid-column: 1 / -1; color: var(--ink-soft); font-size: 15px; font-weight: 650; }
.config-field { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 13px; }
.config-field input {
  width: 100%; min-width: 0; min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink); font-size: 15px;
  transition: border-color .18s, box-shadow .18s;
}
.config-field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--ring); }
#data { width: 100%; }
.apply-config, .cancel-config { min-height: 40px; }
.apply-config { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.apply-config:not(:disabled):hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.cancel-config { color: var(--ink-soft); border-color: var(--line); }
#error { grid-column: 1 / -1; min-height: 0; color: var(--red); font-size: 14px; font-weight: 550; }
#error:not(:empty) { padding: 5px 0 0; }
.config-field input[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 3px rgba(217, 48, 37, .16); }

.workspace {
  grid-column: 1; grid-row: 3; min-width: 0; min-height: 0; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(340px, 1fr); gap: 16px;
}
.panel { min-width: 0; min-height: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); box-shadow: none; }
.canvas-panel { display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto; }
.panel-head {
  min-height: 37px; height: 37px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); background: var(--paper);
  color: var(--muted); font-size: 13px; font-weight: 650; letter-spacing: .06em;
}
.panel-head .small { display: none; }
.stage {
  flex: 1 0 220px; min-width: 0; min-height: 220px; padding: 5px 12px 2px; overflow: hidden;
  display: grid; grid-template-rows: 26px minmax(0, 1fr); align-items: stretch;
}
.stage-goal {
  min-width: 0; overflow: hidden; padding-left: 10px; border-left: 3px solid var(--blue); border-radius: 1px;
  color: var(--ink-soft); font-size: 15px; line-height: 24px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis;
}
.stage svg { display: block; width: 100%; height: 100%; min-height: 0; overflow: visible; border-radius: 6px; background: transparent; }
.node { filter: drop-shadow(0 1px 1px rgba(61, 50, 39, .08)); }
.node rect { fill: var(--paper); stroke: var(--line); stroke-width: 1.6; rx: 8; }
.node text { font-family: inherit; }
.node .value { fill: var(--ink); font-size: 34px; font-weight: 700; }
.node .value.long { font-size: 22px; }
.node .value.wide { font-size: 18px; }
.node .field { display: block; fill: var(--muted); font-size: 16px; }
.node .nextval { visibility: visible; fill: var(--blue-deep); font-size: 18px; font-weight: 620; }
.node .addr { visibility: hidden; font-size: 13px; fill: var(--muted); }
.node path { stroke: var(--line-soft); }
.node.target { filter: drop-shadow(0 2px 4px rgba(230, 107, 53, .18)); }
.node.target rect { fill: var(--blue-wash); stroke: var(--blue); stroke-width: 2.2; }
.node.visited { filter: none; }
.node.visited rect { fill: var(--visited); stroke: var(--line); }
.node.visited .value { fill: var(--subtle); }
.node.released { filter: none; }
.node.released rect { fill: var(--red-wash); stroke: var(--red); stroke-dasharray: 5 4; }
.node.released text { fill: var(--red); }
.edge { fill: none; stroke: var(--neutral-edge); stroke-width: 1.8; marker-end: url(#arrow); }
.edge.changed { stroke: var(--blue); marker-end: url(#bluearrow); }
.pointer { fill: var(--pointer); font-size: 14px; font-weight: 650; }
.pointer.active { fill: var(--blue); }
.memcell { fill: var(--paper); stroke: var(--line); stroke-width: 1.6; }
.array-cell { filter: drop-shadow(0 1.5px 1.5px rgba(61, 50, 39, .06)); }
.memcell.hot { fill: var(--blue-wash); stroke: var(--blue); stroke-width: 2.3; }
.array-cell:has(.memcell.hot) { filter: drop-shadow(0 2px 4px rgba(230, 107, 53, .16)); }
.memcell.inactive { fill: var(--panel-tint); stroke: var(--line); stroke-dasharray: 4 3; }
.array-cell:has(.memcell.inactive) { filter: none; }
.array-cell [data-key^="address-"] { visibility: hidden; fill: var(--subtle); }
.array-cell [data-key^="index-"] { fill: var(--subtle); }
.array-value { fill: var(--ink); font-weight: 700; font-size: 34px; }
.array-cell:has(.memcell.inactive) .array-value { fill: var(--subtle); }
.focus rect { stroke: var(--blue); stroke-width: 2.5; }
.new rect, .node.new rect { stroke: var(--blue); fill: var(--blue-wash); }

.explanation { flex: 0 0 auto; min-height: 0; display: block; padding: 10px 15px 2px; border-top: 1px solid var(--line-soft); }
.explanation .stepbadge { display: none; }
.explanation h2 { margin: 0; color: var(--ink); font-size: 23px; line-height: 1.22; font-weight: 750; letter-spacing: -.2px; }
.explanation p { margin: 5px 0 0; color: var(--ink-soft); font-size: 16px; line-height: 1.45; }
.explanation #description { display: none; }
.variable-check { flex: 0 0 auto; min-width: 0; max-height: 94px; overflow: auto; margin: 5px 15px 0; padding: 7px 0 8px; border-top: 1px solid var(--line-soft); }
.variable-check h3 { display: none; }
.variables { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 8px; padding: 0; font-size: 14px; line-height: 1.4; }
.variables span {
  display: inline-flex; max-width: 100%; padding: 2px 9px; border: 1px solid var(--line); border-radius: 7px;
  color: var(--ink-soft); background: var(--wash); font: 13.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: normal; overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
  transition: color .2s, background-color .2s, border-color .2s;
}
.variables span.changed, .variables span.semantic-changing { color: var(--amber); background: var(--amber-wash); border-color: var(--amber-bright); font-weight: 700; }
.variables span.metric { color: var(--subtle); background: transparent; border-color: transparent; padding-left: 2px; padding-right: 2px; font-size: 13px; }
.code-note { flex: 0 0 auto; max-height: 26px; overflow: hidden; margin: 0 15px 8px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 13.5px; }
.code-note[open] { max-height: min(27vh, 190px); overflow: auto; padding: 8px 0 3px; border-top: 1px solid var(--line-soft); }
.code-note summary { color: var(--muted); font-size: 13.5px; cursor: pointer; transition: color .18s; }
.code-note summary:hover { color: var(--ink); }
.code-note pre { max-height: 13vh; overflow: auto; margin: 6px 0; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--wash); color: var(--ink-soft); font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.detail-vars { margin: 6px 0; }
.detail-vars h4, .detail-heading { margin: 5px 0; color: var(--muted); font-size: 13px; font-weight: 650; letter-spacing: .03em; }
.address-details { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 5px 0; color: var(--ink-soft); font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-note #source { color: var(--subtle); font-size: 12.5px; }

.inspector-panel { display: grid; grid-template-rows: 38px minmax(0, 1fr); background: var(--paper); border-color: var(--line); box-shadow: none; }
.inspector-panel .panel-head { min-height: 38px; height: 38px; padding: 0 14px; background: var(--paper); border-bottom-color: var(--line); color: var(--muted); font-size: 13px; }
.code {
  position: relative; min-width: 0; min-height: 0; overflow: auto; padding: 10px 0 16px;
  background: var(--code-bg); color: var(--code-ink);
  font: 14.5px/1.62 ui-monospace, SFMono-Regular, Menlo, monospace;
}
#code .line {
  position: relative; z-index: 1; display: grid; grid-template-columns: 2.9em minmax(0, 1fr); min-width: 0;
  padding: 0 14px 0 0; color: inherit; white-space: normal; transition: color .22s;
}
#code .num { display: block; grid-column: 1; padding-right: 13px; color: var(--subtle); font-size: 11px; line-height: inherit; text-align: right; user-select: none; }
#code .code-text { grid-column: 2; display: block; min-width: 0; padding-left: var(--indent, 0ch); color: inherit; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; }
#code .line.active { color: var(--ink); font-weight: 600; }
#code .line.active .num { color: var(--blue); }
#code .code-line-highlight {
  position: absolute; z-index: 0; left: 0; right: 0; top: 0; height: 28px;
  border-left: 3px solid var(--blue); border-radius: 0 4px 4px 0;
  background: linear-gradient(90deg, rgba(230, 107, 53, .14), rgba(230, 107, 53, .045) 62%, transparent);
  pointer-events: none; will-change: transform;
}
#code::-webkit-scrollbar { width: 10px; height: 10px; }
#code::-webkit-scrollbar-track { background: transparent; }
#code::-webkit-scrollbar-thumb { background: var(--line); border: 2px solid var(--code-bg); border-radius: 6px; }
#code::-webkit-scrollbar-thumb:hover { background: var(--neutral-edge); }
.canvas-panel::-webkit-scrollbar, .variable-check::-webkit-scrollbar, .code-note::-webkit-scrollbar, .code-note pre::-webkit-scrollbar { width: 8px; height: 8px; }
.canvas-panel::-webkit-scrollbar-thumb, .variable-check::-webkit-scrollbar-thumb, .code-note::-webkit-scrollbar-thumb, .code-note pre::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
.edge, .node rect, .memcell, .code-line-highlight { transition: none !important; }

.controls {
  grid-column: 1; grid-row: 4; min-width: 0; min-height: 52px; margin: 0; padding: 5px 10px;
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); box-shadow: none;
}
.controls .btn { min-height: 40px; padding: 7px 12px; font-size: 14px; }
.controls .primary { min-width: 78px; border-color: var(--blue); background: var(--blue); color: #fff; font-weight: 650; }
.controls .primary:hover:not(:disabled) { background: var(--blue-deep); border-color: var(--blue-deep); }
.controls .btn:disabled { opacity:1; color:var(--muted); border-color:var(--line); background:var(--panel-tint); }
.progress { flex: 1 1 auto; min-width: 55px; height: 24px; margin: 0 6px; background: transparent; cursor: pointer; -webkit-appearance: none; appearance: none; touch-action: pan-y; }
.progress:focus-visible { outline:2px solid var(--accent); outline-offset:3px; border-radius:12px; }
.progress::-webkit-slider-runnable-track { height: 10px; border:1px solid rgba(87,67,49,.10); border-radius: 99px; background:linear-gradient(90deg,var(--accent) 0,var(--accent) var(--progress-fill,0%),#d8d0c1 var(--progress-fill,0%),#d8d0c1 100%); box-shadow:inset 0 1px 2px rgba(67,51,37,.18),inset 0 1px 0 rgba(255,255,255,.72); }
.progress::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -4px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid var(--paper); box-shadow:0 1px 2px rgba(56,42,31,.30),inset 0 1px 1px rgba(255,255,255,.35);
  transition: transform .15s;
}
.progress::-webkit-slider-thumb:hover { transform: scale(1.18); }
.progress::-moz-range-track { height: 10px; border:1px solid rgba(87,67,49,.10); border-radius: 99px; background:#d8d0c1; box-shadow:inset 0 1px 2px rgba(67,51,37,.18),inset 0 1px 0 rgba(255,255,255,.72); }
.progress::-moz-range-progress { height:10px; border-radius:99px; background:var(--accent); box-shadow:inset 0 1px 0 rgba(255,255,255,.24); }
.progress::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--paper); box-shadow:0 1px 2px rgba(56,42,31,.30),inset 0 1px 1px rgba(255,255,255,.35); }
.count { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.speed {
  min-height: 40px; padding: 6px 30px 6px 11px; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236e675a' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.playback-state, .config-feedback { flex: 0 1 auto; max-width: 165px; overflow: hidden; color: var(--muted); font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.config-feedback { color: var(--green); font-weight: 550; }

#catalog {
  width: min(840px, calc(100% - 28px)); max-height: calc(100dvh - 24px); padding: 0; overflow: auto;
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-lg);
}
#catalog[open] { animation: dialogIn .3s var(--ease-out); }
#catalog::backdrop { background: rgba(32, 33, 36, .38); backdrop-filter: blur(5px); }
#catalog[open]::backdrop { animation: fadeIn .25s ease-out; }
.catalog-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line-soft); }
.catalog-top h2 { margin: 0; color: var(--ink); font-size: 19px; font-weight: 750; letter-spacing: -.2px; }
.catalog-top button { width: 34px; height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--subtle); font-size: 24px; line-height: 1; transition: background-color .18s, color .18s; }
.catalog-top button:hover { background: var(--surface-hover); color: var(--ink); }
.catalog-body { display: grid; grid-template-columns: 180px minmax(0, 1fr); min-height: 320px; }
.chapters { display: flex; flex-direction: column; gap: 4px; padding: 14px 10px; background: var(--wash); border-right: 1px solid var(--line-soft); }
.chapters button {
  min-height: 40px; padding: 9px 13px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 14px; text-align: left; transition: background-color .18s, color .18s, box-shadow .18s;
}
.chapters button:hover { background: var(--surface-hover); color: var(--ink); }
.chapters button.active { background: var(--blue-wash); color: var(--blue-deep); font-weight: 650; }
.chapter-content { padding: 20px 26px; }
.chapter-content h3 { margin: 0 0 15px; color: var(--ink); font-size: 20px; font-weight: 750; letter-spacing: -.2px; }
.course-section { margin: 0 0 18px; }
.course-section h4, .topic-title { margin: 0 0 8px; color: var(--subtle); font-size: 12.5px; font-weight: 650; letter-spacing: .08em; }
.course-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.course-actions button {
  min-height: 40px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper);
  color: var(--ink-soft); font-size: 14px; box-shadow: var(--shadow-sm);
  transition: background-color .18s, border-color .18s, color .18s, transform .12s, box-shadow .18s;
}
.course-actions button:hover { background: var(--surface-hover); border-color: #c4c7c5; transform: translateY(-1px); }
.course-actions button.current { border-color: transparent; background: var(--blue-wash); color: var(--blue-deep); font-weight: 600; }
.course-note { margin: 8px 0; color: var(--muted); font-size: 14.5px; }
.future-topic, .coming { color: var(--subtle); font-size: 14px; line-height: 1.8; }

.topology-edge { fill: none; stroke: var(--neutral-edge); stroke-width: 2.2; vector-effect: non-scaling-stroke; }
.topology-edge.visited { stroke: var(--line); }
.topology-edge.active { stroke: var(--blue); stroke-width: 3.2; }
.topology-node { filter: drop-shadow(0 1.5px 2px rgba(61, 50, 39, .08)); }
.topology-node rect { fill: var(--paper); stroke: var(--line); stroke-width: 1.8; rx: 8; }
.topology-node.visited { filter: none; }
.topology-node.visited rect { fill: var(--visited); stroke: var(--line); }
.topology-node.current { filter: drop-shadow(0 2px 4px rgba(230, 107, 53, .16)); }
.topology-node.current rect { fill: var(--blue-wash); stroke: var(--blue); stroke-width: 2.6; }
.topology-id { fill: var(--ink); font-size: 24px; font-weight: 700; }
.graph-mode .topology-id { font-size: 28px; }
.tree-side { fill: var(--muted); font-size: 14px; }
.topology-note { fill: var(--subtle); font-size: 14px; }
.adjacency-title { fill: var(--ink-soft); font-size: 18px; font-weight: 650; }
.adjacency-row rect { fill: transparent; stroke: var(--line); stroke-width: 1; }
.adjacency-row.active rect { fill: var(--blue-wash); stroke: var(--blue); }
.adjacency-vertex { fill: var(--ink-soft); font-size: 16px; font-weight: 620; }
.adjacency-chain { fill: var(--ink-soft); font-size: 19px; }
.adjacency-neighbor.active { fill: var(--blue-deep); font-weight: 750; }
.chain-arrow, .first-pointer, .null-pointer { fill: var(--subtle); }
.graph-mode .variables, .tree-mode .variables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 8px; }
.graph-mode .variables span, .tree-mode .variables span { min-width: 0; overflow-wrap: anywhere; }
.tree-mode .stage, .graph-mode .stage { min-height: 335px; }

.semantic-read { fill: var(--blue) !important; stroke: var(--blue) !important; filter: drop-shadow(0 0 4px rgba(230, 107, 53, .24)); }
.semantic-write { fill: var(--green) !important; stroke: var(--green) !important; filter: drop-shadow(0 0 4px rgba(230, 107, 53, .22)); }
.semantic-free { fill: var(--red) !important; stroke: var(--red) !important; filter: drop-shadow(0 0 4px rgba(217, 48, 37, .22)); }
.semantic-malloc { fill: var(--blue) !important; stroke: var(--blue) !important; filter: drop-shadow(0 0 4px rgba(230, 107, 53, .24)); }
.address-traveler { filter: drop-shadow(0 0 4px rgba(230, 107, 53, .24)); }
.semantic-value-flight {
  position: fixed; z-index: 1000; display: flex; align-items: center; gap: 8px; max-width: min(320px, calc(100vw - 24px));
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--blue-deep);
  font-size: 15px; line-height: 1.25; white-space: nowrap; pointer-events: none; transform: translate(-50%, -50%);
  box-shadow: var(--shadow-md); will-change: left, top;
}
.semantic-flight-caption { color: var(--subtle); font-size: 13.5px; }
.semantic-value-flight strong { color: var(--blue-deep); font-size: 16px; font-weight: 700; }
.flight-caption { fill: var(--muted); font-size: 14px; font-weight: 550; }
.flight-value text { fill: var(--accent-deep) !important; }

@media (prefers-reduced-motion: no-preference) {
  header { animation: riseIn .5s var(--ease-out) backwards; }
  #nav { animation: riseIn .5s var(--ease-out) .05s backwards; }
  .classroom-tools { animation: riseIn .55s var(--ease-out) .1s backwards; }
  .canvas-panel { animation: riseIn .6s var(--ease-out) .16s backwards; }
  .inspector-panel { animation: riseIn .6s var(--ease-out) .22s backwards; }
  .controls { animation: riseIn .6s var(--ease-out) .28s backwards; }
}

@media (max-width: 1000px) {
  body { height: auto; min-height: 100dvh; overflow: auto; }
  header { height: 46px; }
  main { height: auto; min-height: calc(100dvh - 46px); display: block; overflow: visible; padding: 8px 18px 82px; }
  #nav { height: auto; min-height: 40px; margin-bottom: 8px; }
  .classroom-tools { display: flex; flex-wrap: wrap; gap: 7px 12px; margin: 0 0 10px; padding: 0; }
  .intro { flex: 1 1 180px; }
  .intro h1, .lessons-heading h1 { font-family: ui-serif, "Songti SC", "Noto Serif CJK SC", serif; }
.intro h1 { font-size: 20px; white-space: normal; }
  .operation-toolbar { flex: 1 1 100%; order: 3; min-height: 40px; }
  #operationButtons { max-width: 100%; }
  .settings-drawer { margin-left: auto; }
  .settings-drawer[open] { flex: 1 0 100%; order: 4; }
  .settings-drawer .setup { grid-template-columns: minmax(210px, 2fr) repeat(2, minmax(120px, 1fr)) max-content max-content; width: 100%; }
  .workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; overflow: visible; }
  .panel { height: auto; overflow: visible; }
  .canvas-panel { min-height: 0; padding-bottom: 7px; border: 1px solid var(--line); }
  .stage { flex: none; height: clamp(285px, 48vw, 420px); min-height: 285px; overflow: hidden; }
  .stage svg { width: 100%; height: 100%; min-width: 0; }
  .tree-mode .stage, .graph-mode .stage { height: clamp(330px, 52vw, 420px); min-height: 330px; }
  .inspector-panel { min-height: 290px; grid-template-rows: 38px minmax(210px, auto); }
  .code { min-height: 210px; max-height: none; overflow: auto; }
  .variable-check { max-height: none; overflow: visible; }
  .code-note { max-height: 26px; }
  .code-note[open] { max-height: 230px; }
  .code-note pre { max-height: 150px; }
  .controls { position: fixed; z-index: 30; left: 18px; right: 18px; bottom: max(8px, env(safe-area-inset-bottom)); width: auto; margin: 0; flex-wrap: nowrap; overflow: visible; background: var(--paper); box-shadow: var(--shadow-lg); }
  .progress { flex: 1 1 130px; }
  .playback-state, .config-feedback { max-width: 130px; }
}
@media (max-width: 600px) {
  header { gap:4px; padding-inline:10px; }
  header .brand span { display:none; }
  .classroom-page-switcher { gap:1px; }
  .classroom-page-switcher .page-switcher-link { min-height:34px; padding-inline:5px; font-size:12px; }
  header #fullscreen { min-height:34px; padding:5px 7px; font-size:12px; white-space:nowrap; }
  main { padding: 7px 12px 150px; }
  #nav { gap: 7px; }
  #catalogButton { padding: 5px 8px; font-size: 14px; }
  #breadcrumb { max-width: 42vw; font-size: 14px; }
  .classroom-tools { gap: 7px; }
  .intro h1, .lessons-heading h1 { font-family: ui-serif, "Songti SC", "Noto Serif CJK SC", serif; }
.intro h1 { font-size: 19px; }
  .settings-drawer .setup { grid-template-columns: minmax(0, 1fr) minmax(100px, .7fr); gap: 10px; }
  .setup-heading, #error { grid-column: 1 / -1; }
  .config-field:first-of-type { grid-column: 1 / -1; }
  .apply-config, .cancel-config { grid-column: 1 / -1; }
  .stage { height: 310px; min-height: 285px; padding-inline: 6px; }
  .stage svg { min-width: 560px; }
  .graph-mode .stage svg, .tree-mode .stage svg { min-width: 0; }
  .explanation h2 { font-size: 21px; }
  .explanation p { font-size: 15px; }
  .controls { left: 12px; right: 12px; gap: 5px; padding: 6px; flex-wrap: wrap; }
  .controls .btn { padding: 6px 9px; font-size: 14px; }
  .progress { flex-basis: 35%; min-width: 80px; }
  .playback-state, .config-feedback { max-width: 100%; flex: 1 1 auto; }
  .catalog-body { grid-template-columns: 118px minmax(0, 1fr); }
  .chapter-content { padding: 18px 14px; }
  .chapters { padding: 12px 6px; }
  .chapters button { padding: 9px 9px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; }
}
/* Fine cylindrical seek rail with a quiet, precisely centred handle. */
.progress{height:28px;border:0!important;padding:0!important;box-shadow:none!important;outline:none}
.progress:focus-visible{outline:none;box-shadow:none}
.progress::-webkit-slider-runnable-track{height:7px;border:0;background:linear-gradient(90deg,#e66b35 0%,#e66b35 var(--progress-fill,0%),#dfd8cd var(--progress-fill,0%),#dfd8cd 100%);box-shadow:inset 0 1px 1px rgba(62,48,32,.14),inset 0 -1px 0 rgba(255,255,255,.6)}
.progress::-webkit-slider-thumb{-webkit-appearance:none;width:15px;height:15px;margin-top:-4px;border:2px solid #fffdf7;background:#e66b35;box-shadow:0 1px 3px rgba(54,39,25,.24);transition:box-shadow .16s,transform .16s}
.progress::-webkit-slider-thumb:hover{transform:scale(1.08)}
.progress:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 3px rgba(230,107,53,.22),0 1px 3px rgba(54,39,25,.24)}
.progress:active::-webkit-slider-thumb{transform:scale(1.1)}
.progress::-moz-range-track{height:7px;border:0;background:#dfd8cd;box-shadow:inset 0 1px 1px rgba(62,48,32,.14)}
.progress::-moz-range-progress{height:7px;background:#e66b35;box-shadow:inset 0 1px 0 rgba(255,255,255,.2)}
.progress::-moz-range-thumb{width:11px;height:11px;border:2px solid #fffdf7;background:#e66b35;box-shadow:0 1px 3px rgba(54,39,25,.24)}
.progress:focus-visible::-moz-range-thumb{box-shadow:0 0 0 3px rgba(230,107,53,.22)}
.progress:disabled{opacity:.45;cursor:default}
