/* ============================================================
   Quant Prep Path — styles
   Colour tokens live on :root; dark mode re-steps them.
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efeb;
  --border: #e2e0da;
  --text: #1b1b1a;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-soft: #e4eefb;
  --good: #1a8a3a;
  --good-soft: #e3f4e8;
  --bad: #c43c3b;
  --bad-soft: #fbe7e6;
  --warn: #a86b00;
  --warn-soft: #fbf1dc;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #e7e5e0;
  --axis: #8d8b85;
  --code-bg: #f0efeb;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --radius: 10px;
  --sidebar-w: 290px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #33322f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --accent: #5a9be8;
    --accent-soft: #1d2a3b;
    --good: #45b866;
    --good-soft: #17291d;
    --bad: #e66767;
    --bad-soft: #3a1d1d;
    --warn: #d9a03a;
    --warn-soft: #34290f;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --grid: #2b2b29;
    --axis: #7d7c76;
    --code-bg: #232321;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: #33322f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8f8e88;
  --accent: #5a9be8;
  --accent-soft: #1d2a3b;
  --good: #45b866;
  --good-soft: #17291d;
  --bad: #e66767;
  --bad-soft: #3a1d1d;
  --warn: #d9a03a;
  --warn-soft: #34290f;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #2b2b29;
  --axis: #7d7c76;
  --code-bg: #232321;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.4em 0 .5em; }
h1 { font-size: 1.85rem; margin-top: .2em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: .7em 0; }
code { font-family: var(--mono); font-size: .9em; background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: .86rem; line-height: 1.5; border: 1px solid var(--border); }
pre code { background: none; padding: 0; font-size: inherit; }
hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
table { border-collapse: collapse; margin: 1em 0; font-size: .93rem; }
th, td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 18px 14px 40px;
}
#main { flex: 1; min-width: 0; padding: 28px 40px 80px; }
.content { max-width: 860px; margin: 0 auto; }

.side-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.side-collapse { flex-shrink: 0; width: 28px; height: 28px; border: none; border-radius: 7px; background: transparent; color: var(--muted); font: inherit; font-size: 1.05rem; cursor: pointer; }
.side-collapse:hover { background: var(--surface-2); color: var(--text); }
.sidebar-open { position: fixed; top: 14px; left: 14px; z-index: 30; display: none; place-items: center; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 1rem; cursor: pointer; box-shadow: var(--shadow); }
.sidebar-open:hover { background: var(--surface-2); color: var(--text); }
.sidebar-collapsed #sidebar { display: none; }
.sidebar-collapsed .sidebar-open { display: grid; }
.sidebar-collapsed #main { padding-left: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); padding: 0 6px 10px; }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: .9rem; }
.side-section { margin-top: 16px; }
.side-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 8px; margin-bottom: 4px; }
.side-link { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; color: var(--text-2); font-size: .92rem; line-height: 1.3; }
.side-link:hover { background: var(--surface-2); text-decoration: none; }
.side-link.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.side-link .num { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: .72rem; font-weight: 700; border: 1.5px solid var(--border); color: var(--muted); }
.side-link .num.done { background: var(--good); border-color: var(--good); color: #fff; }
.side-link .num.partial { border-color: var(--accent); color: var(--accent); }
.side-link .q { margin-left: auto; font-size: .7rem; color: var(--muted); }
.side-footer { margin-top: 24px; padding: 0 8px; display: flex; gap: 8px; flex-wrap: wrap; }
/* Sync status (js/sync.js) */
.sync-badge { position: sticky; bottom: -40px; z-index: 5; margin: 12px -14px -40px; padding: 10px 22px 12px; background: var(--surface); border-top: 1px solid var(--border); }
@media (max-width: 900px) { .sync-badge { position: relative; bottom: auto; margin: 12px 0 0; padding: 0 8px; border-top: none; } }
.sync-btn { display: flex; align-items: center; gap: 7px; width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: .8rem; text-align: left; color: var(--text-2); background: var(--surface); cursor: pointer; }
.sync-btn:hover { background: var(--surface-2); color: var(--text); }
.sync-label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sync-badge.ok .sync-icon { color: var(--good, #2f9e5c); }
.sync-badge.syncing .sync-icon { display: inline-block; animation: sync-spin 1s linear infinite; }
.sync-badge.offline .sync-btn, .sync-badge.error .sync-btn { color: var(--warn, #b7791f); }
.sync-badge.signin .sync-btn { color: var(--bad); border-color: var(--bad); }
@keyframes sync-spin { to { transform: rotate(360deg); } }
.sync-menu { position: absolute; left: 14px; right: 14px; bottom: calc(100% + 6px); z-index: 20; display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.sync-menu .btn { justify-content: center; }
.sync-info { margin: 0 0 4px; font-size: .76rem; line-height: 1.45; color: var(--text-2); }
/* "A new version is ready" (js/pwa.js) */
.update-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 24px rgba(0,0,0,.22); font-size: .86rem; }

/* ---------- generic components ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: .9rem; font-weight: 600;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: .82rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }

.progress-bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--good); border-radius: 99px; transition: width .3s; }

/* callouts used in lesson bodies */
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: 0 8px 8px 0; margin: 1em 0; }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout.key { border-color: var(--good); background: var(--good-soft); }
.callout.key::before { content: "Key idea"; display: block; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--good); margin-bottom: 2px; }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout.warn::before { content: "Watch out"; display: block; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--warn); margin-bottom: 2px; }
.callout.tip::before { content: "Exam tip"; display: block; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: 2px; }
details.deep { border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; margin: 1em 0; background: var(--surface); }
details.deep > summary { cursor: pointer; font-weight: 600; color: var(--text-2); }
details.deep[open] > summary { margin-bottom: 6px; }
.qa > details.deep { margin: 6px 0; }
.qa > details.deep > summary { color: var(--text); }
.formula { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 14px; margin: 1em 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.steps { counter-reset: step; padding-left: 0; list-style: none; }
.steps > li { counter-increment: step; position: relative; padding-left: 34px; margin: .6em 0; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 1px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); font-size: .75rem; font-weight: 700; display: grid; place-items: center; }

/* ---------- module page ---------- */
.module-head .eyebrow { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.module-head .summary { color: var(--text-2); font-size: 1.02rem; }
.step-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 8px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.step-tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .85rem; font-weight: 600; cursor: pointer; }
.step-tab:hover { background: var(--surface-2); text-decoration: none; }
.step-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.step-tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.step-tab .dot.done { background: var(--good); }
.step-tab.active .dot { background: rgba(255,255,255,.6); }
.step-tab.active .dot.done { background: #fff; }
.lesson-nav { display: flex; justify-content: space-between; margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border); }

.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 1.2em 0; box-shadow: var(--shadow); }
.widget-title { font-weight: 700; font-size: .95rem; margin-bottom: 6px; }
.widget-title::before { content: "▶ Interactive · "; color: var(--accent); font-size: .78rem; letter-spacing: .03em; }
.widget-controls { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; margin: 8px 0; }
.readout { font-family: var(--mono); font-size: .9rem; background: var(--surface-2); padding: 6px 10px; border-radius: 6px; display: inline-block; }
.readout-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.slider { display: flex; flex-direction: column; gap: 2px; min-width: 190px; flex: 1; }
.slider label { font-size: .85rem; color: var(--text-2); display: flex; justify-content: space-between; gap: 10px; }
.slider label .val { font-family: var(--mono); color: var(--text); font-weight: 600; }
.slider input[type=range] { width: 100%; accent-color: var(--accent); }
select, input[type=text], input[type=number] { font: inherit; font-size: .92rem; padding: 6px 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
input[type=text]:focus, input[type=number]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- charts ---------- */
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis line, .chart .axis path { stroke: var(--axis); stroke-width: 1; }
.chart .zero { stroke: var(--axis); stroke-width: 1.25; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .axis-label { fill: var(--text-2); font-size: 12px; font-weight: 600; }
.chart .ann { fill: var(--text-2); font-size: 11.5px; }
.chart .hover-line { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: .78rem; box-shadow: var(--shadow); white-space: nowrap; font-family: var(--mono); color: var(--text); z-index: 5; }
.chart-tip .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--text-2); margin: 4px 0 0; }
.legend .sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* ---------- exercises ---------- */
.exercises-head { margin-top: 2.2em; display: flex; align-items: center; gap: 10px; }
.exercises-head h2 { margin: 0; }
.ex { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 14px 0; box-shadow: var(--shadow); }
.ex.correct { border-color: var(--good); }
.ex-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ex-head .tag { font-size: .72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.ex-head .status { margin-left: auto; font-size: .8rem; font-weight: 700; }
.ex-head .status.ok { color: var(--good); }
.ex-prompt > :first-child { margin-top: 0; }
.ex-answer { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.ex-answer input[type=text] { width: 220px; font-family: var(--mono); }
.ex-options { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ex-option { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--surface); }
.ex-option:hover { background: var(--surface-2); }
.ex-option.selected { border-color: var(--accent); background: var(--accent-soft); }
.ex-option.right { border-color: var(--good); background: var(--good-soft); }
.ex-option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.ex-option input { margin-top: 5px; accent-color: var(--accent); }
.ex-option .opt-body { flex: 1; min-width: 0; }
.ex-option .opt-body pre { margin: 6px 0 0; }
.ex-feedback { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: .92rem; }
.ex-feedback.ok { background: var(--good-soft); color: var(--good); font-weight: 600; }
.ex-feedback.no { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.ex-hint, .ex-solution { margin-top: 10px; padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--border); }
.ex-solution::before { content: "Solution"; display: block; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ex-hint::before { content: "Hint"; display: block; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ex-solution > :last-child, .ex-hint > :last-child { margin-bottom: 0; }
.input-help { font-size: .76rem; color: var(--muted); }

.exam-box { border: 2px solid var(--accent); }
.exam-banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.figure { margin: 12px 0; display: flex; justify-content: center; }
.figure > .chart { margin: 0 auto; }
.widget .chart { margin: 0 auto; }
.figure svg { max-width: 100%; height: auto; }
.screenshot img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); margin-top: 8px; }

/* ---------- home ---------- */
.hero { margin-bottom: 26px; }
.hero p { color: var(--text-2); font-size: 1.05rem; max-width: 680px; }
.track { margin: 28px 0 10px; }
.track h2 { margin: 0 0 4px; font-size: 1.1rem; }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 10px; }
.mod-card { display: flex; flex-direction: column; gap: 8px; color: var(--text); transition: transform .12s, box-shadow .12s; }
.mod-card:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.mod-card .t { font-weight: 700; font-size: 1rem; line-height: 1.3; }
.mod-card .s { color: var(--text-2); font-size: .87rem; line-height: 1.45; flex: 1; }
.mod-card .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.qmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.qmap a { display: block; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-2); font-size: .85rem; line-height: 1.35; }
.qmap a b { color: var(--text); display: block; }
.qmap a:hover { background: var(--surface-2); text-decoration: none; }
.qmap a.done { border-color: var(--good); }

/* ---------- exam / drill ---------- */
.exam-toolbar { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 10px 0; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--border); margin-bottom: 10px; flex-wrap: wrap; }
.timer { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; }
.score-big { font-size: 2.4rem; font-weight: 800; }

/* ---------- cheat sheet ---------- */
.cs-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 8px; }
.cs-toc a { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 5px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .82rem; }
.cs-toc a:hover { background: var(--surface-2); text-decoration: none; }
.cs-toc .n, .cs-head .n { width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: .7rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.cs-track { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 32px 0 10px; }
.cs-card { padding: 0; overflow: hidden; margin: 14px 0; scroll-margin-top: 16px; }
.cs-head { display: flex; align-items: center; gap: 10px; padding: 11px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cs-head a { font-weight: 700; color: var(--text); line-height: 1.3; }
.cs-head .pill { margin-left: auto; }
.cs-head .pill + .pill { margin-left: 0; }
table.cs { width: 100%; margin: 0; font-size: .95rem; }
table.cs th, table.cs td { border: none; border-top: 1px solid var(--border); padding: 8px 18px; vertical-align: baseline; line-height: 1.75; }
table.cs tr:first-child > * { border-top: none; }
table.cs th { width: 13.5em; background: none; font-weight: 600; font-size: .86rem; color: var(--text-2); padding-right: 8px; }
table.cs td { overflow-x: auto; }
table.cs tr.sub td { padding: 14px 18px 4px; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
table.cs tr.sub .katex { text-transform: none; }
table.cs tr.sub + tr > * { border-top: none; }
table.cs tr.exam > * { background: var(--accent-soft); }
table.cs tr.exam th { color: var(--accent); font-weight: 800; }
table.cs .sep { color: var(--muted); margin: 0 .7em; }
table.cs .note { color: var(--muted); font-size: .88em; }
@media (max-width: 640px) {
  table.cs th, table.cs td { display: block; width: auto; }
  table.cs th { padding-bottom: 0; }
  table.cs th + td { border-top: none; padding-top: 2px; }
}

/* ---------- Ask Claude chat panel (js/chat.js) ---------- */
:root { --chat-w: 400px; }
.chat-launcher { position: fixed; right: 20px; bottom: 20px; z-index: 40; font: inherit; font-size: .9rem; font-weight: 700; padding: 10px 16px; border: none; border-radius: 999px; background: var(--accent); color: #fff; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.chat-launcher:hover { filter: brightness(1.08); }
.chat-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: min(var(--chat-w), 100vw); display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); box-shadow: -4px 0 18px rgba(0,0,0,.08); }
.chat-launcher[hidden], .chat-panel[hidden], .chat-panel [hidden] { display: none !important; }
@media (min-width: 1300px) { body.chat-open #main { margin-right: var(--chat-w); } }
.chat-resize { position: absolute; top: 0; bottom: 0; left: -4px; width: 9px; z-index: 1; cursor: ew-resize; touch-action: none; }
.chat-resize::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; background: transparent; transition: background .15s; }
.chat-resize:hover::after, .chat-resize:focus-visible::after, body.chat-resizing .chat-resize::after { background: var(--accent); }
.chat-resize:focus-visible { outline: none; }
body.chat-resizing { cursor: ew-resize; user-select: none; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.chat-title { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.chat-sub { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-actions { display: flex; gap: 2px; }
.chat-settings { max-height: 65vh; overflow-y: auto; padding: 10px 14px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.chat-field { display: flex; flex-direction: column; gap: 3px; flex: 1; margin-top: 8px; font-size: .8rem; color: var(--text-2); }
.chat-field input, .chat-field select, .chat-field textarea { width: 100%; }
.chat-field textarea { font: inherit; font-size: .88rem; line-height: 1.45; padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--surface); resize: vertical; min-height: 60px; }
.chat-field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chat-field input { font: inherit; font-size: .92rem; padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--surface); }
.chat-field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chat-field-row { display: flex; gap: 10px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.chat-msg { font-size: .92rem; line-height: 1.55; overflow-wrap: anywhere; }
.chat-msg.user { align-self: flex-end; max-width: 88%; padding: 8px 12px; border-radius: 12px 12px 2px 12px; background: var(--accent-soft); }
.chat-md > :first-child { margin-top: 0; }
.chat-md > :last-child { margin-bottom: 0; }
.chat-md p { margin: .5em 0; }
.chat-md ul, .chat-md ol { margin: .4em 0; padding-left: 1.3em; }
.chat-md h4 { margin: .9em 0 .3em; font-size: .95rem; }
.chat-md pre { font-size: .8rem; }
.chat-md blockquote { margin: .5em 0; padding-left: 10px; border-left: 3px solid var(--border); color: var(--text-2); }
.chat-md .katex-display { margin: .5em 0; }
.chat-thinking { margin-bottom: 6px; font-size: .8rem; color: var(--muted); }
.chat-thinking summary { cursor: pointer; }
.chat-thinking-body { margin-top: 4px; padding: 4px 10px; border-left: 2px solid var(--border); white-space: pre-wrap; }
.chat-note { margin-top: 4px; font-size: .75rem; color: var(--muted); }
.chat-notice { margin-top: 6px; color: var(--text-2); }
.chat-notice.bad { color: var(--bad); }
.chat-error { padding: 8px 10px; border-radius: 8px; font-size: .85rem; color: var(--bad); background: var(--bad-soft); }
.chat-empty { color: var(--text-2); }
.chat-chips { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.chat-chip { padding: 5px 10px; font-size: .8rem; text-align: left; cursor: pointer; }
.chat-chip:hover { background: var(--accent-soft); }
.chat-actions .btn.active { color: var(--accent); background: var(--accent-soft); }
.chat-context { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin: -4px 0 -4px; font-size: .76rem; color: var(--muted); }
.chat-link { padding: 0; border: none; background: none; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.chat-hist-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.chat-tabs { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.chat-tab { padding: 4px 10px; border: none; border-radius: 6px; font: inherit; font-size: .8rem; color: var(--text-2); background: none; cursor: pointer; }
.chat-tab.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 600; }
.chat-hist-group { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.chat-hist-group.here { border-color: var(--accent); }
.chat-hist-lesson { padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.chat-hist-module { font-size: .72rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.chat-hist-page { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 1px; font-size: .88rem; font-weight: 600; }
.chat-badge { padding: 1px 7px; border-radius: 999px; font-size: .68rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); }
.chat-hist-row { display: flex; align-items: center; gap: 4px; padding-right: 6px; }
.chat-hist-row + .chat-hist-row { border-top: 1px solid var(--border); }
.chat-hist-row.current { background: var(--accent-soft); }
.chat-hist-open { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; padding: 8px 12px; border: none; background: none; font: inherit; text-align: left; color: var(--text); cursor: pointer; }
.chat-hist-open:hover:not(:disabled) .chat-hist-title { color: var(--accent); }
.chat-hist-open:disabled { cursor: not-allowed; opacity: .6; }
.chat-hist-title { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chat-hist-meta { font-size: .74rem; color: var(--muted); }
.chat-hist-del { flex: none; }
.chat-composer { padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chat-thumb { position: relative; width: 56px; height: 56px; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: var(--surface-2); }
.chat-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-thumb button { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; padding: 0; border: none; border-radius: 50%; font-size: 10px; line-height: 18px; color: #fff; background: rgba(0,0,0,.6); cursor: pointer; }
.chat-attach { padding-left: 6px; padding-right: 6px; }
.chat-composer-row .chat-status { flex: 1; min-width: 0; }
.chat-images { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.chat-images + .chat-md { margin-top: 6px; }
.chat-images img { display: block; max-width: 100%; max-height: 160px; border-radius: 6px; cursor: zoom-in; }
.chat-images.multi img { height: 80px; max-width: 140px; object-fit: cover; }
.chat-panel.chat-drop { outline: 2px dashed var(--accent); outline-offset: -6px; }
.chat-input { width: 100%; resize: none; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: .92rem; color: var(--text); background: var(--bg); }
.chat-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chat-composer-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }

/* ---------- print (cheat sheet → PDF) ---------- */
/* ---------- Handwriting notes ---------- */
/* Docked notes: the layout makes room on that side (variables set by js/notes.js). */
.layout { padding: var(--nd-top, 0px) var(--nd-right, 0px) var(--nd-bottom, 0px) var(--nd-left, 0px); }
@media (min-width: 901px) { #sidebar { top: var(--nd-top, 0px); height: calc(100vh - var(--nd-top, 0px) - var(--nd-bottom, 0px)); } }
.sidebar-open { left: calc(var(--nd-left, 0px) + 14px); top: calc(var(--nd-top, 0px) + 14px); }
.chat-launcher { right: calc(var(--nd-right, 0px) + 20px); bottom: calc(var(--nd-bottom, 0px) + 20px); }
body.notes-docked .chat-panel { z-index: 55; } /* an overlaid chat (narrow screens) goes above docked notes */
.notes-launcher { position: fixed; right: 20px; bottom: 20px; z-index: 40; font: inherit; font-size: .9rem; font-weight: 700; padding: 10px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.14); }
.notes-launcher:hover { border-color: var(--accent); }
body.chat-avail .notes-launcher { bottom: 72px; }
body.chat-avail.chat-open .notes-launcher { bottom: 20px; right: calc(min(var(--chat-w), 100vw) + 20px); }
.notes-launcher[hidden], .notes-win[hidden], .notes-win [hidden] { display: none !important; }
.notes-win { container-type: inline-size; position: fixed; z-index: 50; display: flex; flex-direction: column; min-width: 300px; min-height: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.22); overflow: hidden; touch-action: manipulation; }
.notes-win.max { inset: 0; border-radius: 0; border: none; }
.notes-win.docked { min-width: 0; min-height: 0; border-radius: 0; box-shadow: none; border: 0 solid var(--border); }
.notes-win.dock-left { top: 0; bottom: 0; left: 0; border-right-width: 1px; }
.notes-win.dock-right { top: 0; bottom: 0; right: 0; border-left-width: 1px; }
.notes-win.dock-top { top: 0; left: 0; right: 0; border-bottom-width: 1px; }
.notes-win.dock-bottom { bottom: 0; left: 0; right: 0; border-top-width: 1px; }
@media (min-width: 1300px) { body.chat-open .notes-win.dock-right, body.chat-open .notes-win.dock-top, body.chat-open .notes-win.dock-bottom { right: min(var(--chat-w), 100vw); } }
.notes-win.docked .notes-grip { display: none; }
.notes-split { display: none; position: absolute; z-index: 6; touch-action: none; outline: none; }
.notes-win.docked .notes-split { display: block; }
.notes-win.dock-left .notes-split { top: 0; bottom: 0; right: -5px; width: 10px; cursor: ew-resize; }
.notes-win.dock-right .notes-split { top: 0; bottom: 0; left: -5px; width: 10px; cursor: ew-resize; }
.notes-win.dock-top .notes-split { left: 0; right: 0; bottom: -5px; height: 10px; cursor: ns-resize; }
.notes-win.dock-bottom .notes-split { left: 0; right: 0; top: -5px; height: 10px; cursor: ns-resize; }
.notes-split::after { content: ''; position: absolute; inset: 4px; border-radius: 2px; background: transparent; transition: background .15s; }
.notes-split:hover::after, .notes-split:focus-visible::after, body.notes-splitting .notes-split::after { background: var(--accent); }
body.notes-splitting { user-select: none; -webkit-user-select: none; }
.notes-win.docked { overflow: visible; }
.notes-win.docked > .notes-head, .notes-win.docked > .notes-body { overflow: hidden; }
.notes-snap { position: fixed; z-index: 49; border: 2px solid var(--accent); border-radius: 10px; background: color-mix(in srgb, var(--accent) 16%, transparent); pointer-events: none; opacity: 0; transition: opacity .12s, left .12s, top .12s, width .12s, height .12s; }
.notes-snap.on { opacity: 1; }
.notes-dock-menu { position: absolute; top: 44px; right: 48px; z-index: 7; width: 200px; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.notes-dock-title { padding: 4px 8px 6px; font-size: .72rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.notes-dock-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: none; border-radius: 7px; font: inherit; font-size: .86rem; text-align: left; color: var(--text); background: none; cursor: pointer; }
.notes-dock-item:hover { background: var(--surface-2); }
.notes-dock-item.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.notes-dock-glyph { position: relative; flex: none; width: 22px; height: 16px; border: 1.5px solid currentColor; border-radius: 3px; opacity: .85; }
.notes-dock-glyph::after { content: ''; position: absolute; background: currentColor; opacity: .55; }
.notes-dock-glyph.left::after { left: 0; top: 0; bottom: 0; width: 45%; }
.notes-dock-glyph.right::after { right: 0; top: 0; bottom: 0; width: 45%; }
.notes-dock-glyph.top::after { left: 0; right: 0; top: 0; height: 45%; }
.notes-dock-glyph.bottom::after { left: 0; right: 0; bottom: 0; height: 45%; }
.notes-dock-glyph.float::after { left: 25%; right: 15%; top: 22%; bottom: 18%; border-radius: 1px; }
.notes-dock-tip { margin: 4px 8px 2px; font-size: .72rem; color: var(--muted); }
.notes-win:not(.max) .notes-head { cursor: grab; }
@media (min-width: 1300px) { body.chat-open .notes-win.max { right: min(var(--chat-w), 100vw); border-right: 1px solid var(--border); } }
.notes-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--border); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.notes-win.max .notes-head { cursor: default; padding-top: max(6px, env(safe-area-inset-top)); }
.notes-title { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.notes-sub { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-actions { display: flex; gap: 2px; flex: none; }
.notes-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); user-select: none; -webkit-user-select: none; }
.notes-group { display: flex; align-items: center; gap: 3px; }
.notes-right { margin-left: auto; }
.notes-tool { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 4px 10px; border: 1px solid transparent; border-radius: 8px; font: inherit; font-size: .82rem; color: var(--text-2); background: none; cursor: pointer; }
.notes-tool.active { color: var(--text); border-color: var(--border); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.1); font-weight: 600; }
.notes-icon { display: inline-flex; }
.notes-icon svg { display: block; }
.notes-ib { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; min-height: 32px; padding: 4px 6px; }
.notes-ib:disabled { opacity: .35; }
.notes-swatch { width: 26px; height: 26px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.notes-swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.notes-swatch.small { width: 22px; height: 22px; }
.notes-colors { gap: 4px; }
.notes-wheel-btn { position: relative; width: 26px; height: 26px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 1px var(--border); cursor: pointer;
  background: conic-gradient(from 90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.notes-wheel-btn.active { box-shadow: 0 0 0 2px var(--accent); }
.notes-wheel-dot { position: absolute; inset: 5px; border-radius: 50%; border: 2px solid var(--surface); }
.notes-picker { position: absolute; top: 108px; left: 50%; transform: translateX(-50%); z-index: 5; width: 260px; max-width: calc(100% - 16px); max-height: calc(100% - 116px); overflow-y: auto; padding: 10px 14px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 12px 36px rgba(0,0,0,.28); user-select: none; -webkit-user-select: none; }
.notes-picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: .9rem; }
.notes-wheel-wrap { position: relative; width: 196px; height: 196px; margin: 4px auto 10px; }
.notes-wheel { display: block; border-radius: 50%; touch-action: none; cursor: crosshair; }
.notes-wheel-marker { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.45), 0 1px 4px rgba(0,0,0,.4); pointer-events: none; }
.notes-picker-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: .8rem; color: var(--text-2); }
.notes-picker-row > span:first-child { flex: none; }
.notes-bright { flex: 1; min-width: 0; height: 22px; -webkit-appearance: none; appearance: none; border-radius: 11px; background: linear-gradient(90deg, #000, var(--hue, #f00)); outline: none; }
.notes-bright::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border: 3px solid #fff; border-radius: 50%; background: transparent; box-shadow: 0 0 0 1px rgba(0,0,0,.45); cursor: pointer; }
.notes-bright::-moz-range-thumb { width: 16px; height: 16px; border: 3px solid #fff; border-radius: 50%; background: transparent; box-shadow: 0 0 0 1px rgba(0,0,0,.45); cursor: pointer; }
.notes-prev { display: inline-flex; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; }
.notes-prev span { display: block; width: 34px; height: 28px; }
.notes-hex { flex: 1; min-width: 0; font: inherit; font-family: ui-monospace, Menlo, monospace; font-size: .88rem; padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--bg); text-transform: uppercase; }
.notes-picker-slots .notes-group { flex-wrap: wrap; }
.notes-picker-note { margin: 8px 0 0; font-size: .72rem; color: var(--muted); }
.notes-picker-btns { justify-content: flex-end; margin-top: 10px; }
.notes-size { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer; }
.notes-size span { display: block; border-radius: 50%; background: var(--text-2); }
.notes-size.active { border-color: var(--border); background: var(--surface); }
.notes-hint { font-size: .78rem; color: var(--muted); }
.notes-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.notes-selbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; width: max-content; max-width: calc(100% - 24px); padding: 6px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 20px rgba(0,0,0,.2); user-select: none; -webkit-user-select: none; }
.notes-selbar .notes-right { margin-left: 0; }
.notes-selbar.top { top: 12px; bottom: auto; }
@container (max-width: 640px) { .notes-hint { display: none; } }
.notes-count { font-size: .8rem; font-weight: 600; color: var(--text); }
.notes-swatch.hl { border-radius: 6px; }
.notes-act { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 4px 8px; }
.notes-act:disabled { opacity: .4; }
.notes-act.danger { color: var(--bad); }
.notes-status.info { color: var(--muted); }
.notes-zoom { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.notes-zoom-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: none; background: none; color: var(--text-2); cursor: pointer; }
.notes-zoom-btn .notes-icon svg { width: 15px; height: 15px; }
.notes-zoom-label { min-width: 46px; height: 30px; padding: 0 2px; border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border); font: inherit; font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--text); background: none; cursor: pointer; }
.notes-seg { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.notes-seg-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 3px 8px; border: none; border-radius: 6px; font: inherit; font-size: .8rem; color: var(--text-2); background: none; cursor: pointer; }
.notes-seg-btn.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.notes-foot { position: absolute; left: 0; height: 76px; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; pointer-events: none; --pull: 0; }
.notes-foot-pull { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.notes-foot-arrow { display: inline-block; transition: transform .15s; transform: translateY(calc(var(--pull) * -4px)) scale(calc(1 + var(--pull) * .4)); }
.notes-foot.pulling .notes-foot-pull { color: var(--text-2); }
.notes-foot.ready .notes-foot-pull { color: var(--accent); font-weight: 600; }
.notes-foot-pull::after { content: ''; width: 60px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--accent) calc(var(--pull) * 100%), var(--border) 0); opacity: 0; transition: opacity .15s; }
.notes-foot.pulling .notes-foot-pull::after { opacity: 1; }
.notes-foot-btns { display: flex; gap: 6px; pointer-events: auto; }
.notes-paper { font: inherit; font-size: .8rem; padding: 4px 6px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--surface); }
.notes-tools .btn.active { color: var(--accent); background: var(--accent-soft); }
.notes-scroll { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.notes-space { position: relative; }
.notes-canvas { position: sticky; top: 0; left: 0; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; outline: none; }
.notes-status { position: absolute; left: 12px; bottom: 8px; font-size: .75rem; color: var(--bad); pointer-events: none; }
.notes-status:empty { display: none; }
.notes-body:has(.notes-selbar:not([hidden]):not(.top)) ~ .notes-status { bottom: 72px; }
.notes-status { z-index: 3; padding: 2px 8px; border-radius: 6px; background: var(--surface); }
.notes-grip { position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; touch-action: none; background: linear-gradient(135deg, transparent 50%, var(--border) 50%, var(--border) 58%, transparent 58%, transparent 70%, var(--border) 70%, var(--border) 78%, transparent 78%); }
.notes-win.max .notes-grip { display: none; }
@container (max-width: 640px) { .notes-tool-label, .notes-act-label { display: none; } }

@media print {
  @page { size: A4; margin: 12mm; }
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    color-scheme: light;
    --bg: #fff; --surface: #fff; --surface-2: #f3f2ef; --border: #dcdad3;
    --text: #1b1b1a; --text-2: #52514e; --muted: #7a7974;
    --accent: #2a78d6; --accent-soft: #e8f0fb; --shadow: none;
  }
  html { font-size: 12px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #sidebar, .cs-toc, #error-log, .chat-panel, .chat-launcher, .notes-launcher, .notes-win, .sidebar-open { display: none !important; }
  .sidebar-collapsed #main { padding-left: 0; }
  .layout { padding: 0 !important; }
  body.chat-open #main { margin-right: 0; }
  .layout { display: block; }
  #main { padding: 0; }
  .content { max-width: none; }
  .cs-track { margin-top: 18px; break-after: avoid; }
  .cs-card { margin: 10px 0; }
  .cs-head { padding: 6px 12px; break-after: avoid; }
  table.cs th, table.cs td { padding: 3px 12px; line-height: 1.5; overflow: visible; }
  table.cs th { width: 12em; }
  table.cs tr.sub td { padding: 7px 12px 1px; }
  table.cs tr { break-inside: avoid; }
  table.cs tr.sub { break-after: avoid; }
}

#error-log { position: fixed; bottom: 12px; right: 12px; max-width: 520px; max-height: 40vh; overflow: auto; z-index: 100; background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad); border-radius: 8px; padding: 10px 12px; font-family: var(--mono); font-size: .78rem; white-space: pre-wrap; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  #sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  #main { padding: 20px 16px 60px; }
  .sidebar-collapsed #main { padding: 64px 16px 60px; }
}
