/* CS 374 Study — styles */
:root {
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #f0f2f8; --border: #dde1ec; --text: #1b2333; --muted: #5d6882;
  --primary: #1f3a68; --primary-ink: #ffffff; --accent: #e8572c; --accent-soft: #fde9e1;
  --good: #1d8a4e; --good-soft: #e3f5ea; --bad: #c2362f; --bad-soft: #fbe6e4; --warn: #b26b00; --warn-soft: #fdf1dc;
  --def: #2457c5; --def-soft: #e8effd; --thm: #7a3fc4; --thm-soft: #f1e9fc; --key: #0d7f83; --key-soft: #e0f4f4; --ex: #4b5872; --ex-soft: #eef0f5;
  --node: #ffffff; --node-stroke: #31405e; --active: #ffd9a8; --active-stroke: #e8572c;
  --c0: #2f6fdf; --c1: #d4482b; --c2: #1f9d5b; --c3: #9a4fd1; --c4: #c98a00; --c5: #0f9aa3; --c6: #c2337a; --c7: #6b7a2a;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .05);
  --mono: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141d; --surface: #161d2a; --surface-2: #1d2636; --border: #2a3548; --text: #e3e8f2; --muted: #95a1b8;
    --primary: #7aa2ff; --primary-ink: #0d1422; --accent: #ff8a5c; --accent-soft: #3a2219;
    --good: #4cc786; --good-soft: #15301f; --bad: #ff7a70; --bad-soft: #3a1b19; --warn: #f0b44c; --warn-soft: #362812;
    --def: #7fa6ff; --def-soft: #18243d; --thm: #c39bff; --thm-soft: #261b3a; --key: #4fd0d4; --key-soft: #102c2e; --ex: #a9b4c9; --ex-soft: #1c2433;
    --node: #1d2636; --node-stroke: #a9b8d6; --active: #5a3a1c; --active-stroke: #ff8a5c;
    --c0: #79a6ff; --c1: #ff8a6b; --c2: #58d38f; --c3: #c79bff; --c4: #f3c04f; --c5: #4fd0d4; --c6: #ff7fb8; --c7: #b9c86a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141d; --surface: #161d2a; --surface-2: #1d2636; --border: #2a3548; --text: #e3e8f2; --muted: #95a1b8;
  --primary: #7aa2ff; --primary-ink: #0d1422; --accent: #ff8a5c; --accent-soft: #3a2219;
  --good: #4cc786; --good-soft: #15301f; --bad: #ff7a70; --bad-soft: #3a1b19; --warn: #f0b44c; --warn-soft: #362812;
  --def: #7fa6ff; --def-soft: #18243d; --thm: #c39bff; --thm-soft: #261b3a; --key: #4fd0d4; --key-soft: #102c2e; --ex: #a9b4c9; --ex-soft: #1c2433;
  --node: #1d2636; --node-stroke: #a9b8d6; --active: #5a3a1c; --active-stroke: #ff8a5c;
  --c0: #79a6ff; --c1: #ff8a6b; --c2: #58d38f; --c3: #c79bff; --c4: #f3c04f; --c5: #4fd0d4; --c6: #ff7fb8; --c7: #b9c86a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.2em 0 .5em; }
h1 { font-size: 1.75rem; margin-top: 0; letter-spacing: -.01em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
:not(pre) > code { background: var(--surface-2); border: 1px solid var(--border); padding: .05em .35em; border-radius: 5px; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
[hidden] { display: none !important; }

/* layout */
.app { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: 100vh; }
#sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px 24px; display: flex; flex-direction: column; gap: 10px; }
#main { padding: 28px clamp(16px, 4vw, 48px) 80px; max-width: 1280px; width: 100%; }
.topbar { display: none; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--text); padding: 4px 6px 8px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; color: var(--muted); font-size: .74rem; font-weight: 400; }
.logo { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: var(--primary-ink); font-weight: 800; letter-spacing: -.03em; }
.search input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; }
.nav-main { display: flex; flex-direction: column; }
.nav-main a, .nav-topic { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--text); font-size: .93rem; }
.nav-main a:hover, .nav-topic:hover { background: var(--surface-2); text-decoration: none; }
#sidebar a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 7px; font-weight: 700; }
.nav-unit { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 10px 4px; font-weight: 700; }
.nav-num { width: 20px; color: var(--muted); font-size: .78rem; text-align: right; flex: none; }
.nav-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-bar { width: 34px; height: 5px; background: var(--surface-2); border-radius: 9px; overflow: hidden; flex: none; border: 1px solid var(--border); }
.mini-bar i { display: block; height: 100%; background: var(--good); }
.sidebar-foot { margin-top: auto; padding-top: 10px; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: .84rem; border-radius: 7px; }
.btn.good { color: var(--good); border-color: var(--good); } .btn.bad { color: var(--bad); border-color: var(--bad); } .btn.warn { color: var(--warn); border-color: var(--warn); }
.btn small { opacity: .6; font-weight: 400; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.editor { width: 100%; resize: vertical; line-height: 1.5; background: var(--surface-2); tab-size: 2; }
.code-editor { min-height: 260px; }

/* generic */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.pill { display: inline-block; font-size: .74rem; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-weight: 600; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); margin-right: 4px; }
.tag.good { color: var(--good); } .tag.bad { color: var(--bad); } .tag.warn { color: var(--warn); }
.bar { height: 7px; background: var(--surface-2); border-radius: 9px; overflow: hidden; border: 1px solid var(--border); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--good), var(--key)); border-radius: 9px; transition: width .3s; }
.bar.thin { height: 4px; border: 0; margin: 10px 0 0; }
.bar.inline { display: inline-block; width: 80px; vertical-align: middle; }
.table-wrap { overflow-x: auto; margin: .8em 0; }
table { border-collapse: collapse; width: auto; min-width: 50%; }
th, td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; }

/* dashboard */
.hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 28px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.hero h1 { font-size: 2.1rem; margin-bottom: .3em; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 60ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; border: 1px solid var(--border); }
.stat b { display: block; font-size: 1.7rem; line-height: 1.1; }
.stat b small { font-size: .9rem; color: var(--muted); }
.stat span { color: var(--muted); font-size: .84rem; }
.unit { margin-top: 34px; }
.unit-head h2 { margin: 0; } .unit-head p { margin: 4px 0 14px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.topic-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--text); box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.topic-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--primary); }
.topic-card h3 { margin: 2px 0 0; font-size: 1.04rem; }
.topic-card p { margin: 0; color: var(--muted); font-size: .88rem; flex: 1; }
.tc-top { display: flex; justify-content: space-between; align-items: center; }
.tc-num { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: .85rem; padding: 0 4px; }
.tc-num.big { min-width: 36px; height: 36px; font-size: 1.05rem; vertical-align: middle; margin-right: 6px; }
.tc-meta { display: flex; justify-content: space-between; font-size: .76rem; color: var(--muted); gap: 6px; }
.lab-icon { font-size: 1.6rem; }

/* topic page */
.page-head { margin-bottom: 18px; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.head-row h1 { margin: 0; }
.head-nav { display: flex; gap: 6px; }
.meta-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 14px; overflow-x: auto; }
.tab { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2.5px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab small { background: var(--surface-2); border-radius: 99px; padding: 0 6px; font-size: .72rem; color: var(--muted); }
.lesson-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 32px; align-items: start; }
.toc { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 2px; font-size: .84rem; max-height: calc(100vh - 40px); overflow-y: auto; border-left: 2px solid var(--border); padding-left: 12px; }
.toc b { margin-bottom: 6px; color: var(--muted); text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; }
.toc a { color: var(--muted); padding: 2px 0; } .toc a:hover { color: var(--primary); }
.objectives { background: var(--key-soft); border-radius: 10px; padding: 12px 18px; margin-bottom: 1.4em; }
.objectives ul { margin: 6px 0 0; }
.lesson-end { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2.5em; padding-top: 1.5em; border-top: 1px solid var(--border); }

/* prose */
.prose { max-width: 78ch; overflow-wrap: break-word; }
.prose.lesson { max-width: 80ch; font-size: 1.01rem; }
.prose h2 { font-size: 1.4rem; padding-top: .4em; margin-top: 1.8em; border-top: 1px solid var(--border); }
.prose h2:first-child, .objectives + h2 { border-top: 0; margin-top: .3em; }
.prose h3 { font-size: 1.15rem; } .prose h4 { font-size: 1rem; }
.prose p, .prose li { margin: .5em 0; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose blockquote { margin: 1.1em 0; padding: 10px 16px; border-left: 4px solid var(--border); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.prose blockquote > :first-child { margin-top: 0; } .prose blockquote > :last-child { margin-bottom: 0; }
.callout.def { border-color: var(--def); background: var(--def-soft); }
.callout.thm { border-color: var(--thm); background: var(--thm-soft); }
.callout.key { border-color: var(--key); background: var(--key-soft); }
.callout.ex { border-color: var(--ex); background: var(--ex-soft); }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout.tip { border-color: var(--accent); background: var(--accent-soft); }
.callout.note { border-color: var(--muted); }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; overflow-x: auto; line-height: 1.5; font-size: .88rem; }
pre.code code { background: none; border: 0; padding: 0; }
.math-raw { font-family: var(--mono); color: var(--def); }
.math-raw.display { display: block; text-align: center; margin: 1em 0; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.prose table { font-size: .93rem; }

/* reveal & steps */
details.reveal { margin: 1em 0; border: 1px dashed var(--good); border-radius: 10px; background: var(--surface); }
details.reveal > summary { padding: 9px 14px; font-weight: 600; color: var(--good); list-style-position: inside; font-size: .95rem; }
details.reveal[open] > summary { border-bottom: 1px dashed var(--good); }
.reveal-body { padding: 4px 16px 10px; }
.steps-w { border-left: 4px solid var(--def); }
.steps-title { font-weight: 700; margin-bottom: 6px; }
.step { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 6px; }
.step:first-of-type { border-top: 0; }
.step-no { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--def); }
.step > p:nth-child(2) { margin-top: 2px; }

/* widgets */
.widget { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 1.1em 0; background: var(--surface); }
.w-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.w-row input.mono, .w-rx { flex: 1; min-width: 140px; }
.w-trace { color: var(--muted); margin: 4px 0; overflow-wrap: anywhere; }
.w-diagram { overflow-x: auto; text-align: center; }
.w-diagram svg, .graph-host svg { max-width: 100%; height: auto; }
.w-edit summary, details summary { cursor: pointer; color: var(--muted); font-size: .86rem; }
.w-edit textarea { width: 100%; margin-top: 6px; background: var(--surface-2); }
.w-gram { margin: 0 0 6px; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; white-space: pre-wrap; }
.w-tree, .tree-host { overflow-x: auto; }
svg.diagram .node circle { fill: var(--node); stroke: var(--node-stroke); stroke-width: 1.6; }
svg.diagram .node.accept circle.inner { fill: none; }
svg.diagram .node.active circle { fill: var(--active); stroke: var(--active-stroke); stroke-width: 2.4; }
svg.diagram .node.active circle.inner { fill: none; }
svg.diagram .node text { fill: var(--text); font-family: var(--mono); font-size: 13px; }
svg.diagram .edge { fill: none; stroke: var(--node-stroke); stroke-width: 1.4; opacity: .85; }
svg.diagram .edge.hot { stroke: var(--active-stroke); stroke-width: 2.6; opacity: 1; }
svg.diagram .arrowhead { fill: var(--node-stroke); } svg.diagram .arrowhead.hot { fill: var(--active-stroke); }
svg.diagram .elabel { fill: var(--text); font-family: var(--mono); font-size: 12.5px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
svg.diagram .elabel.hot { fill: var(--active-stroke); font-weight: 700; }
.tape { display: flex; gap: 0; overflow-x: auto; margin: 8px 0; font-family: var(--mono); }
.tape .cell { min-width: 34px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border); margin-left: -1px; background: var(--surface-2); font-size: 1rem; }
.tape .cell.head { background: var(--active); border-color: var(--active-stroke); border-width: 2px; font-weight: 700; position: relative; }
.tape .cell.head::after { content: '▲'; position: absolute; bottom: -18px; font-size: .7rem; color: var(--active-stroke); }
.w-status { margin-top: 14px; color: var(--muted); }
svg.tree-svg .tedge { stroke: var(--muted); stroke-width: 1.2; }
svg.tree-svg .tnode { font-family: var(--mono); font-size: 14px; fill: var(--text); }
svg.tree-svg .tnode.nt { fill: var(--def); font-weight: 700; }
svg.tree-svg .tnode.eps { fill: var(--muted); font-style: italic; }

/* graphs */
.graph-host { text-align: center; }
svg.graph-svg { width: 100%; max-height: 460px; }
svg.graph-svg .gnode circle { fill: var(--node); stroke: var(--node-stroke); stroke-width: 1.6; }
svg.graph-svg .gnode text { fill: var(--text); font-family: var(--mono); font-size: 13px; font-weight: 600; }
svg.graph-svg .gnode.frontier circle { fill: var(--warn-soft); stroke: var(--warn); stroke-width: 2.2; }
svg.graph-svg .gnode.current circle { fill: var(--active); stroke: var(--active-stroke); stroke-width: 3; }
svg.graph-svg .gnode.done circle { fill: var(--good-soft); stroke: var(--good); stroke-width: 2; }
svg.graph-svg .gedge { fill: none; stroke: var(--node-stroke); stroke-width: 1.4; opacity: .55; }
svg.graph-svg .gedge.tree { stroke: var(--good); stroke-width: 3.2; opacity: 1; }
svg.graph-svg .gedge.considered { stroke: var(--warn); stroke-width: 2.4; stroke-dasharray: 6 4; opacity: 1; }
svg.graph-svg .gedge.back { stroke: var(--bad); stroke-width: 2.4; opacity: 1; }
svg.graph-svg .gedge.forward { stroke: var(--def); stroke-width: 2; stroke-dasharray: 2 4; opacity: 1; }
svg.graph-svg .gedge.cross { stroke: var(--thm); stroke-width: 2; stroke-dasharray: 8 3 2 3; opacity: 1; }
svg.graph-svg .gedge.rejected { stroke: var(--muted); stroke-dasharray: 2 5; opacity: .5; }
svg.graph-svg .garrow { fill: var(--node-stroke); } svg.graph-svg .garrow.tree { fill: var(--good); } svg.graph-svg .garrow.back { fill: var(--bad); } svg.graph-svg .garrow.considered { fill: var(--warn); } svg.graph-svg .garrow.forward { fill: var(--def); } svg.graph-svg .garrow.cross { fill: var(--thm); }
svg.graph-svg .wlabel { fill: var(--text); font-family: var(--mono); font-size: 12px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
svg.graph-svg .gnode.c0 circle { fill: var(--c0); stroke: var(--c0); } svg.graph-svg .gnode.c1 circle { fill: var(--c1); stroke: var(--c1); } svg.graph-svg .gnode.c2 circle { fill: var(--c2); stroke: var(--c2); } svg.graph-svg .gnode.c3 circle { fill: var(--c3); stroke: var(--c3); }
svg.graph-svg .gnode.c4 circle { fill: var(--c4); stroke: var(--c4); } svg.graph-svg .gnode.c5 circle { fill: var(--c5); stroke: var(--c5); } svg.graph-svg .gnode.c6 circle { fill: var(--c6); stroke: var(--c6); } svg.graph-svg .gnode.c7 circle { fill: var(--c7); stroke: var(--c7); }
svg.graph-svg .gnode[class*=" c"] text { fill: #fff; }
svg.graph-svg .gedge.c0 { stroke: var(--c0); opacity: 1; stroke-width: 2.6; } svg.graph-svg .gedge.c1 { stroke: var(--c1); opacity: 1; stroke-width: 2.6; } svg.graph-svg .gedge.c2 { stroke: var(--c2); opacity: 1; stroke-width: 2.6; } svg.graph-svg .gedge.c3 { stroke: var(--c3); opacity: 1; stroke-width: 2.6; }
svg.graph-svg .gedge.c4 { stroke: var(--c4); opacity: 1; stroke-width: 2.6; } svg.graph-svg .gedge.c5 { stroke: var(--c5); opacity: 1; stroke-width: 2.6; } svg.graph-svg .gedge.c6 { stroke: var(--c6); opacity: 1; stroke-width: 2.6; } svg.graph-svg .gedge.c7 { stroke: var(--c7); opacity: 1; stroke-width: 2.6; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; color: var(--muted); }
.lg::before { content: ''; display: inline-block; width: 22px; height: 0; border-top: 3px solid; vertical-align: middle; margin-right: 5px; }
.lg.tree::before { border-color: var(--good); } .lg.considered::before { border-color: var(--warn); border-top-style: dashed; } .lg.back::before { border-color: var(--bad); } .lg.forward::before { border-color: var(--def); border-top-style: dotted; } .lg.cross::before { border-color: var(--thm); border-top-style: dashed; } .lg.rejected::before { border-color: var(--muted); border-top-style: dotted; }
.step-msg { background: var(--surface-2); border-radius: 9px; padding: 10px 12px; min-height: 3em; margin: 8px 0; }
.player { gap: 6px; }

/* labs */
.lab-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; align-items: start; }
.op-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.spec { max-width: none; }
.dp-host { overflow-x: auto; }
table.dp { font-family: var(--mono); font-size: .86rem; }
table.dp td, table.dp th { text-align: center; min-width: 34px; padding: 5px 7px; }
table.dp td.empty { background: transparent; }
table.dp td.cur { background: var(--active); outline: 2px solid var(--active-stroke); font-weight: 700; }
table.dp td.dep { background: var(--def-soft); color: var(--def); font-weight: 700; }
table.dp td.trace { background: var(--good-soft); color: var(--good); font-weight: 700; }
.answer { margin-top: 10px; font-size: 1.05rem; }

/* quiz & cards */
.quiz-wrap { max-width: 820px; }
.quiz-card { padding: 22px 26px; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.q-text { margin: 14px 0 10px; font-size: 1.04rem; }
.choices { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.choices.tf { flex-direction: row; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); }
.choices.tf .choice { flex: 1; }
.choice:hover { border-color: var(--primary); }
.choice input { margin-top: 5px; accent-color: var(--primary); }
.choice .ckey { font-weight: 700; color: var(--muted); font-size: .82rem; margin-top: 2px; min-width: 1em; }
.choice .ctext { flex: 1; min-width: 0; }
.choice .ctext p { margin: 0; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--def-soft); }
.choice.right { border-color: var(--good); background: var(--good-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.short-in { width: 100%; max-width: 360px; padding: 9px 12px; }
.short-in.right { border-color: var(--good); } .short-in.wrong { border-color: var(--bad); }
.q-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.feedback { border-radius: 10px; padding: 12px 16px; margin-top: 12px; border: 1px solid; }
.feedback.good { background: var(--good-soft); border-color: var(--good); }
.feedback.bad { background: var(--bad-soft); border-color: var(--bad); }
.feedback.warn { background: var(--warn-soft); border-color: var(--warn); }
.feedback .prose { margin-top: 6px; max-width: none; }
.quiz-done { text-align: center; padding: 20px 0; }
.quiz-done .q-actions { justify-content: center; }
.big-score { font-size: 3.2rem; font-weight: 800; }
.big-score.good { color: var(--good); } .big-score.warn { color: var(--warn); } .big-score.bad { color: var(--bad); }
.card-intro { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; color: var(--muted); font-size: .9rem; }
.flashcard { min-height: 220px; border: 1px solid var(--border); border-radius: 14px; margin: 14px 0; padding: 26px; cursor: pointer; background: var(--surface-2); display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.flashcard .fc-face { font-size: 1.12rem; text-align: center; max-width: none; }
.flashcard .fc-back { border-top: 1px dashed var(--border); padding-top: 14px; max-width: none; }
.fc-hint { text-align: center; }
.rate { justify-content: center; }
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.muted-strong { color: var(--muted); }

/* problems */
.sec { margin-top: 24px; }
.prob-list { display: flex; flex-direction: column; gap: 6px; }
.prob-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); }
.prob-row:hover { border-color: var(--primary); text-decoration: none; }
.prob-title { flex: 1; min-width: 0; }
.prob-list.compact .prob-row { padding: 7px 10px; font-size: .9rem; }
.prob-type { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap; min-width: 74px; text-align: center; }
.t-dfa, .t-nfa { background: var(--def-soft); color: var(--def); } .t-regex { background: var(--key-soft); color: var(--key); } .t-cfg { background: var(--thm-soft); color: var(--thm); } .t-tm { background: var(--warn-soft); color: var(--warn); } .t-code { background: var(--good-soft); color: var(--good); } .t-written { background: var(--accent-soft); color: var(--accent); }
.diff { color: var(--accent); letter-spacing: 1px; font-size: .78rem; white-space: nowrap; }
.problem-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 18px; align-items: start; }
.prompt { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; max-width: none; }
.work-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.fmt { font-size: .85rem; } .fmt[open] { width: 100%; }
.tester { display: inline-flex; gap: 6px; margin-left: auto; } .tester input { width: 150px; }
.preview { margin-top: 12px; }
.msg { padding: 6px 0; }
.help-row { display: flex; gap: 8px; margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.hint { background: var(--warn-soft); border-radius: 10px; padding: 10px 14px; margin-top: 10px; max-width: none; }
.solution { margin-top: 14px; border-top: 2px solid var(--good); padding-top: 6px; max-width: none; }
.rubric { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; background: var(--surface-2); padding: 12px 14px; border-radius: 10px; }
.rubric label { display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; }
.rubric input { margin-top: 5px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

/* drills */
.drill-banner { display: flex; flex-direction: column; gap: 2px; margin: 14px 0 4px; padding: 12px 16px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent); color: var(--text); }
.drill-banner:hover { text-decoration: none; filter: brightness(1.02); }
.drill-controls .w-row { justify-content: space-between; }
.dtypes { flex: 1; min-width: 200px; }
.drill-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.drill-card { max-width: 900px; }
.drill-visual { margin: 8px 0; }
.drill-visual svg { max-height: 330px; }
button.choice { font: inherit; color: var(--text); text-align: left; width: 100%; }
button.choice:disabled { cursor: default; }
.choices.tf button.choice { justify-content: center; font-weight: 600; }
.tm-slot:not(:empty) { margin-top: 12px; }

/* review/exam/misc */
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.review-grid .card h3 { margin-top: 0; }
.topic-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px 14px; margin: 12px 0; font-size: .92rem; }
.unit-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.exam-opts { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 10px; }
.exam-opts input { width: 5em; margin-left: 6px; }
.exam-head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.timer { font-family: var(--mono); font-size: 1.2rem; font-weight: 700; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 4px 12px; }
.timer.low { color: var(--bad); border-color: var(--bad); }
.weak { display: flex; flex-wrap: wrap; gap: 6px; }
.sheet-all { columns: 2 460px; column-gap: 18px; }
.sheet-all .card { break-inside: avoid; max-width: none; }
.sheet-all .card h2 { margin-top: 0; font-size: 1.2rem; border: 0; }
.search-results div { padding: 8px 0; border-bottom: 1px solid var(--border); }
.pad { padding: 10px; }

/* midterm 2 */
.mt2-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.mt2-stats input[type=date] { display: block; margin-top: 8px; width: 100%; font: inherit; font-size: .85rem; padding: 4px 6px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); }
.mock-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 14px; }
.mock-card.active { border-color: var(--primary); }
.mock-card .head-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.mock-card h3 { margin: 0 0 10px; }
.mock-row { display: flex; align-items: center; gap: 8px; }
.mock-row .prob-row { flex: 1; min-width: 0; }
.mock-num { width: 1.4em; text-align: right; color: var(--muted); }
.mt2-table td.links { font-size: .88rem; }
.mock-timer { position: fixed; right: 16px; bottom: 16px; z-index: 40; font-family: var(--mono); font-weight: 700; background: var(--surface); color: var(--text); border: 1px solid var(--primary); border-radius: 10px; padding: 8px 14px; box-shadow: var(--shadow); }
.mock-timer:hover { text-decoration: none; }
.mock-timer.low { color: var(--bad); border-color: var(--bad); }

details.notation { margin-top: 18px; }
details.notation summary { cursor: pointer; }
details.notation[open] summary { margin-bottom: 8px; }
.symbols { margin-bottom: 8px; }
.notation table { font-size: .9rem; }
details.rubric summary { cursor: pointer; margin-bottom: 6px; }
details.rubric:not([open]) summary { margin-bottom: 0; }

/* responsive */
@media (max-width: 1100px) {
  .lesson-wrap { grid-template-columns: minmax(0, 1fr); } .toc { display: none; }
  .problem-grid, .lab-grid { grid-template-columns: minmax(0, 1fr); }
  .prompt { position: static; max-height: none; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .topbar b { font-size: 1rem; }
  #sidebar { position: fixed; z-index: 30; left: 0; top: 0; width: 290px; max-width: 86vw; transform: translateX(-105%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  body.nav-open #sidebar { transform: none; }
  #main { padding: 18px 16px 60px; }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 20px; }
  .hero h1 { font-size: 1.6rem; }
  .card-row { grid-template-columns: minmax(0, 1fr); }
  .tester { margin-left: 0; width: 100%; } .tester input { flex: 1; }
  .quiz-card { padding: 16px; }
}
@media print {
  #sidebar, .topbar, .head-nav, .tabs, .btn, .mock-timer { display: none !important; }
  .app { display: block; } #main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}
