.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
/* The maths typeface, for the words on the page. Its pound sign is a slanted one from old metal type, so that one character comes from the next face in the list. */
@font-face { font-family: "Document Serif"; src: url("/vendor/katex/fonts/KaTeX_Main-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; unicode-range: U+0000-00A2, U+00A4-FFFF; }
@font-face { font-family: "Document Serif"; src: url("/vendor/katex/fonts/KaTeX_Main-Italic.woff2") format("woff2"); font-weight: 400; font-style: italic; unicode-range: U+0000-00A2, U+00A4-FFFF; }
@font-face { font-family: "Document Serif"; src: url("/vendor/katex/fonts/KaTeX_Main-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; unicode-range: U+0000-00A2, U+00A4-FFFF; }
@font-face { font-family: "Document Serif"; src: url("/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff2") format("woff2"); font-weight: 700; font-style: italic; unicode-range: U+0000-00A2, U+00A4-FFFF; }
:root { --good: #18794e; --good-soft: #e3f5ec; --bad: #c8322b; --bad-soft: #fdf0ee; --warn: #a66300; --warn-soft: #fdf4e1;
  --v0: #dbe7ff; --v1: #ffe3d6; --v2: #dff5e4; --v3: #f8def0; --v4: #fff2c7; --v5: #e4e0fb; --v6: #d6f3f4; --v7: #f6dfdf;
  --v0i: #1d4fc4; --v1i: #b4481a; --v2i: #1c7a3d; --v3i: #a62680; --v4i: #8a6500; --v5i: #5639c9; --v6i: #0f7780; --v7i: #a93434;
  --graph-bg: #ffffff; --graph-axis: #c3c9d4; --graph-grid: #eceef3; --mark-ink: inherit; --note: rgba(255, 153, 51, .16); --note-strong: rgba(255, 153, 51, .38); --note-line: #f08c2b;
  /* Maths in a sentence sits on a faint tint, so it is easy to pick out from the words in either page font. */
  --maths-tint: rgba(255, 227, 71, .2);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px;
  --radius-s: 6px; --radius-m: 10px; --radius-l: 14px;
  /* The page is set in the same typeface as its maths, so words and maths read as one piece of typesetting. The app around it stays in the system face. */
  --doc-font: "Document Serif", "Latin Modern Roman", "CMU Serif", "Times New Roman", serif;
  --page-zoom: 1; --page-font-size: 17.5px;
  --text-s: 12px; --text-m: 14px; --text-l: 18px; --motion: 120ms;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --canvas: #181818; --side: #181818; --good: #89d185; --good-soft: #1d3322; --bad: #f48771; --bad-soft: #3a2320; --warn: #cca700; --warn-soft: #332b00;
    --v0: #22325a; --v1: #4a2c1e; --v2: #1e3d28; --v3: #482140; --v4: #40340f; --v5: #2f2a58; --v6: #173c40; --v7: #472626;
    --v0i: #a9c3ff; --v1i: #ffb896; --v2i: #93e0ab; --v3i: #f3a5dc; --v4i: #e8cf7a; --v5i: #c0b3fb; --v6i: #8fdde3; --v7i: #f0a8a8;
    --graph-bg: #1f1f1f; --graph-axis: #5a5a5a; --graph-grid: #2b2b2b; --plot-1: #84a6f8; --plot-2: #ff9f6e; --plot-3: #5fcf96; --plot-4: #f3a5dc; --plot-5: #e8cf7a; --mark-ink: #f3e6d8; --note: rgba(255, 153, 51, .16); --note-strong: rgba(255, 153, 51, .36); --note-line: #e38a3a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] { --canvas: #181818; --side: #181818; --good: #89d185; --good-soft: #1d3322; --bad: #f48771; --bad-soft: #3a2320; --warn: #cca700; --warn-soft: #332b00;
  --v0: #22325a; --v1: #4a2c1e; --v2: #1e3d28; --v3: #482140; --v4: #40340f; --v5: #2f2a58; --v6: #173c40; --v7: #472626;
  --v0i: #a9c3ff; --v1i: #ffb896; --v2i: #93e0ab; --v3i: #f3a5dc; --v4i: #e8cf7a; --v5i: #c0b3fb; --v6i: #8fdde3; --v7i: #f0a8a8;
  --graph-bg: #1f1f1f; --graph-axis: #5a5a5a; --graph-grid: #2b2b2b; --plot-1: #84a6f8; --plot-2: #ff9f6e; --plot-3: #5fcf96; --plot-4: #f3a5dc; --plot-5: #e8cf7a; --mark-ink: #f3e6d8; --note: rgba(255, 153, 51, .16); --note-strong: rgba(255, 153, 51, .36); --note-line: #e38a3a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; display: flex; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Documents */
#sidebar { flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.no-sidebar #sidebar { display: none; }
.brand { gap: 9px; font-size: 15px; letter-spacing: -.015em; }
.wordmark span { font-weight: 400; color: var(--dim); }
.side-action { display: flex; align-items: center; text-align: left; transition: filter var(--motion); }
#doc-search { width: 100%; margin-top: 2px; font: inherit; color: inherit; outline: 0; transition: border-color var(--motion), box-shadow var(--motion); }
#doc-list { flex: 1; overflow-y: auto; min-height: 0; }
.doc-row { position: relative; display: flex; align-items: center; margin-bottom: 1px; }
.doc-open { flex: 1; min-width: 0; text-align: left; display: flex; line-height: 1.3; }
.doc-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.doc-when { font-size: 11px; font-weight: 400; }
.doc-delete { position: absolute; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; color: var(--dim); opacity: 0; }
.doc-row:hover .doc-delete, .doc-delete:focus-visible { opacity: 1; }
.doc-delete:hover { color: var(--bad); background: var(--paper); }
.side-foot { display: flex; flex-direction: column; }
.side-link { text-decoration: none; cursor: pointer; }
.side-note { font-size: 11px; }
#scrim { display: none; }

/* Top of the window */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* The bars sit on the same quiet grey as the desk, so the page is the only bright thing in the window. */
#topbar { flex: none; display: flex; align-items: center; font-size: 13px; }
#crumb { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#save-state { flex: none; font-size: 12px; }
.top-actions { margin-left: auto; display: flex; align-items: center; flex: none; }
.top-actions > button, .menu-wrap > button { padding: 5px 10px; color: var(--dim); border-radius: 8px; transition: background var(--motion), color var(--motion); }
.top-gap { flex: none; }
.top-actions > button:hover, .menu-wrap > button:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; padding: 5px 8px; color: var(--dim); border-radius: 7px; }
.icon-button:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; z-index: 25; transform-origin: top right; }
.menu button { position: relative; display: block; width: 100%; text-align: left; color: var(--ink); line-height: 1.35; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: 0; }
.menu button:focus-visible { box-shadow: inset 0 0 0 1.5px var(--ring); }
.menu small { display: block; margin-top: 1px; font-size: 11.5px; }
.menu .menu-key { position: absolute; right: 9px; top: 7px; }
.menu hr { border: 0; border-top: 1px solid var(--line); }

/* Toolbar */
#toolbar { flex: none; display: flex; }
/* One row at every width, so the page never jumps when the toolbar changes between words, maths and tables. A narrow window scrolls it sideways. */
#tools-main { min-width: 0; display: flex; flex-wrap: nowrap; align-items: center; overflow-x: auto; scrollbar-width: none; }
#tools-main::-webkit-scrollbar { display: none; }
#tools-main.fade-end { mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
#tools-main.fade-start { mask-image: linear-gradient(to right, transparent, #000 36px); }
#tools-main.fade-start.fade-end { mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); }
.tool.tool-more { min-width: 24px; padding: 0 4px; font-size: 18px; color: var(--dim); }
.tool.tool-more[hidden] { display: none; }
#toolbar.is-off { visibility: hidden; height: 0; min-height: 0; padding: 0; border: 0; }
.tool-section { flex: none; display: flex; flex-wrap: nowrap; align-items: center; gap: 2px; }
.tool-group { flex: none; display: flex; align-items: center; gap: 2px; }
.tool { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; transition: background var(--motion), color var(--motion); }
.tool:disabled { color: var(--faint); opacity: .55; }
.tool-kbd { font: 600 10.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
/* In maths, an action that does not apply to this line is left out, not shown greyed. */
#tools-maths .tool:disabled { display: none; }
.tool.is-bold { font-weight: 750; }
.tool.is-italic { font-style: italic; }
.tool.is-underline { text-decoration: underline; }
.tool.is-strike { text-decoration: line-through; }
.tool.is-highlight { background: linear-gradient(transparent 62%, var(--mark) 62%); }
#topbar [hidden], #doc-search[hidden] { display: none !important; }
.tool-cluster { display: contents; }
.tool-cluster[hidden], #toolbar .tool[hidden], #toolbar .tool-gap[hidden] { display: none; }
.tool-gap { width: 1px; flex: none; }
.tool-label { flex: none; display: inline-flex; align-items: center; margin: 0 4px 0 2px; }
.tool-select { font: inherit; font-size: 13px; color: var(--dim); background: transparent; border: 0; cursor: pointer; }
.tool-select:hover { color: var(--ink); }

/* The page */
#stage { flex: 1; min-height: 0; display: flex; }
/* The scrollbar's room is always kept, so the page never changes width when it appears: otherwise content right at the
   edge of needing one made the width flip, every line of maths redraw, and the redraw flip it back, for ever. */
#canvas { flex: 1; min-width: 0; overflow-y: auto; scrollbar-gutter: stable; scroll-behavior: auto; }
/* The page grows with the window, like "fit to width" in a document app. --page-zoom is set in main.js; every size on the page follows it, so lines break in the same places at any size. */
#page { position: relative; width: 100%; max-width: calc(816px * var(--page-zoom)); min-height: calc(100% - 4px); margin: 0 auto; padding: calc(72px * var(--page-zoom)) calc(88px * var(--page-zoom)) calc(44px * var(--page-zoom)); background: var(--paper); color: var(--text); font-family: var(--doc-font); font-size: calc(var(--page-font-size) * var(--page-zoom)); line-height: 1.62; }
#title { margin: 0 0 .65em; font-size: 1.943em; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; color: var(--ink); outline: none; }
#title:empty::before { content: attr(data-placeholder); color: var(--faint); }
#tail { min-height: 34vh; cursor: text; }
#editor .ProseMirror { outline: none; }
#editor p { margin: 0 0 .65em; }
#editor h1, #editor h2, #editor h3 { color: var(--ink); letter-spacing: 0; margin: 1.5em 0 .45em; line-height: 1.28; }
#editor .ProseMirror > :first-child { margin-top: 0; }
#editor h1 { font-size: 1.371em; font-weight: 700; }
#editor h2 { font-size: 1.143em; font-weight: 700; }
#editor h3 { font-size: 1em; font-weight: 700; }
#editor ul, #editor ol { margin: 0 0 .62em; padding-left: 26px; }
#editor li > p { margin-bottom: .25em; }
#editor ol[data-kind="lower-alpha"], #editor ol[data-kind="lower-roman"] { list-style: none; counter-reset: part; padding-left: 34px; }
#editor ol[data-kind="lower-alpha"] > li, #editor ol[data-kind="lower-roman"] > li { position: relative; counter-increment: part; }
#editor ol[data-kind="lower-alpha"] > li::before { content: "(" counter(part, lower-alpha) ")"; position: absolute; left: -34px; color: var(--dim); }
#editor ol[data-kind="lower-roman"] > li::before { content: "(" counter(part, lower-roman) ")"; position: absolute; left: -34px; color: var(--dim); }
#editor a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); text-underline-offset: .16em; }
#editor mark { background: var(--mark); color: var(--mark-ink); padding: 0 1px; }
#editor hr { margin: 1.2em 0; border: 0; border-top: 1px solid var(--line); }
#editor img { display: block; max-width: 100%; height: auto; margin: .6em auto; border-radius: 3px; }
/* In dark mode a white graph is turned down a little, so it does not glare out of the dark page. Print is unaffected. */
@media screen and (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #editor img { filter: brightness(.88); } }
:root[data-theme="dark"] #editor img { filter: brightness(.88); }
/* A drawn chart is a white picture, so on a dark page it is turned dark with its colours kept, instead of glowing as a grey slab. Photos keep only the gentle dimming above. */
@media screen and (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #editor .chart-block img { filter: invert(.9) hue-rotate(180deg); } }
:root[data-theme="dark"] #editor .chart-block img { filter: invert(.9) hue-rotate(180deg); }
@media print { #editor img { filter: none !important; } }
#editor img.ProseMirror-selectednode { outline: 2px solid var(--accent); outline-offset: 2px; }
#editor hr.ProseMirror-selectednode { border-top-color: var(--accent); }
/* Question lines: the app draws one above each question. They are not part of the text. */
#editor .ProseMirror > .question-start { margin-top: 1.9em; padding-top: 1.3em; border-top: 1px solid var(--line-strong); }
#editor .ProseMirror > .part-start { margin-top: 1.15em; padding-top: .85em; border-top: 1px dashed var(--line-strong); }
/* The question lines themselves in larger type, one size per level, so the questions stand out from the answers.
   Maths in these lines is sized in em, so it grows with the words. Shown on the page only. */
#editor .ProseMirror > .q-level-0 { font-size: 1.22em; font-weight: 680; line-height: 1.3; margin-bottom: .5em; letter-spacing: -.012em; color: var(--ink); }
#editor .ProseMirror > .q-level-1 { font-size: 1.06em; font-weight: 600; line-height: 1.45; margin-bottom: .55em; color: var(--ink); }
#editor .ProseMirror > .q-level-2 { font-weight: 600; line-height: 1.5; margin-top: .85em; color: var(--ink); }
#editor .ProseMirror > .q-level-3 { font-weight: 550; margin-top: .6em; color: var(--text); }
.q-level-2 .q-num, .q-level-3 .q-num { color: var(--dim); font-weight: 650; }
/* A faint prompt on the empty line the cursor is on: what to type next. */
#editor p.tour-task { position: relative; margin: 1.05em 0 .35em; padding-left: 34px; }
#editor p.tour-task::before { content: attr(data-tour-number); position: absolute; left: 0; top: .12em; display: grid; place-items: center; width: 23px; height: 23px; color: var(--dim); background: var(--tile-soft); border: 1px solid var(--line); border-radius: 50%; font: 650 11px/1 var(--ui-font); }
#editor p.tour-task.is-done::before { content: "✓"; color: var(--on-spark-soft); background: var(--spark-soft); border-color: transparent; }
#editor p.tour-task + p:empty { min-height: 1.5em; }
@media print { #page #line-numbers { display: none !important; } #page #editor { margin-left: 0; } }
.page-break { display: flex; align-items: center; gap: 10px; margin: 1.2em 0; color: var(--faint); font-family: var(--ui-font); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.page-break::before, .page-break::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.page-break.ProseMirror-selectednode { color: var(--accent); }
#editor .tableWrapper { margin: .8em 0; overflow-x: auto; }
#editor table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .857em; font-variant-numeric: tabular-nums; }
#editor th, #editor td { position: relative; min-width: 40px; padding: 6px 10px; vertical-align: top; border: 1px solid var(--line); box-sizing: border-box; }
#editor th { text-align: left; font-size: .933em; font-weight: 600; color: var(--ink); }
#editor td p, #editor th p { margin: 0; }
#editor .selectedCell::after { background: var(--accent); opacity: .12; position: absolute; inset: 0; content: ""; pointer-events: none; }
#editor .column-resize-handle { background: var(--accent); }
#editor .ProseMirror-gapcursor::after { border-top-color: var(--accent); }
/* Maths inside a bold question line is bold too, so the line reads as one weight. */
.q-level-0 .katex, .q-level-1 .katex, .q-level-2 .katex, #editor h1 .katex, #editor h2 .katex, #editor h3 .katex { font-weight: 700; }
/* Maths in a sentence is drawn in a shadow root (checkers.js), so its size and weight are passed in. */
.q-level-0 .math-inline, .q-level-1 .math-inline, .q-level-2 .math-inline, #editor h1 .math-inline, #editor h2 .math-inline, #editor h3 .math-inline { --maths-weight: 700; }
.math-inline math-field { display: inline-block; min-width: 18px; font-size: 1em; vertical-align: baseline; }
.math-block { position: relative; display: flex; flex-wrap: wrap; align-items: center; column-gap: 14px; min-height: calc(38px * var(--page-zoom)); padding: 4px 8px; border-radius: 7px; cursor: text; transition: background var(--motion); }
#editor .ProseMirror > p + .math-block { margin-top: -.15em; }
#editor .ProseMirror > .math-block + p, #editor .ProseMirror > .math-block + h1, #editor .ProseMirror > .math-block + h2, #editor .ProseMirror > .math-block + h3 { margin-top: .5em; }
.math-main { display: inline-flex; align-items: center; gap: 12px; flex: 0 1 auto; min-width: 0; max-width: 100%; padding: 8px 0; margin: -5px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.math-render { display: inline-block; }
/* Typeset maths draws its letters from data-t, so writing checkers such as Grammarly never read them as words (checkers.js). */
.math-render [data-t]::before { content: attr(data-t); }
/* The stand-in word a checker reads instead: it takes no room, is never selected and never prints. */
.math-word, .label-word { font-size: 0; line-height: 0; color: transparent; user-select: none; pointer-events: none; }
.math-block .math-render .katex-display { margin: 0; text-align: left; }
.math-block .math-render .katex-display > .katex { text-align: left; font-size: 1.06em; }
.math-empty { color: var(--faint); font-family: var(--ui-font); font-size: 14px; }
.math-block math-field { flex: 0 1 auto; min-width: 72px; font-size: 1.06em; }
math-field { background: transparent; border: 0; outline: 0; color: inherit; --caret-color: var(--accent); --selection-background-color: var(--selection); --contains-highlight-background-color: transparent; --placeholder-color: var(--faint); --smart-fence-color: var(--faint); --smart-fence-opacity: .6; }
math-field::part(virtual-keyboard-toggle), math-field::part(menu-toggle) { display: none; }
math-field.unit-mode { background: rgba(47, 91, 234, 0.08); border-radius: 4px; }
.tool.is-on { background: var(--accent); color: #fff; }
math-field::part(container) { padding: 0; }
/* No padding of its own: an open line is the same height as a closed one, so the page does not move as the cursor does. */
math-field::part(content) { padding: 0; overflow: visible; }
math-field::part(container) { overflow: visible; }
#math-keypad { position: fixed; left: 0; right: 0; z-index: 55; display: flex; gap: 6px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); overflow-x: auto; background: var(--glass); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -18px rgba(0, 0, 0, .5); backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%); }
#math-keypad[hidden] { display: none !important; }
#math-keypad button { flex: 0 0 44px; min-width: 44px; height: 44px; padding: 0; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; font: 600 18px/1 var(--sans); }
#math-keypad button:active { background: var(--spark-soft); transform: scale(.98); }
body.math-keypad-open #statusbar { margin-bottom: var(--math-keypad-clearance, 58px); }
.math-ghost { display: inline-flex; align-items: center; gap: 8px; flex: none; color: var(--faint); }
.math-ghost .katex { font-size: 1.06em; }
/* On a phone the answer and its controls drop under the equation instead of running off the screen. */
@media (max-width: 700px) {
  .math-main.has-ghost { flex-wrap: wrap; row-gap: 6px; }
  .math-ghost { flex-wrap: wrap; max-width: 100%; row-gap: 6px; }
}
/* Exact is on but this answer has no exact form (ln 2, sin 1 rad): the button stays on and its outline is dashed. */
kbd { display: inline-block; min-width: 18px; padding: 0 5px; font: 500 11px/17px -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif; letter-spacing: .03em; text-align: center; color: var(--dim); background: var(--paper); border: 1px solid var(--line); border-bottom-width: 1.5px; white-space: nowrap; }
.math-below { flex-basis: 100%; }
.math-below:empty { display: none; }
.vc { border-radius: 3px; padding: 0 .1em; }
.vc0 { background: var(--v0); color: var(--v0i); } .vc1 { background: var(--v1); color: var(--v1i); }
.vc2 { background: var(--v2); color: var(--v2i); } .vc3 { background: var(--v3); color: var(--v3i); }
.vc4 { background: var(--v4); color: var(--v4i); } .vc5 { background: var(--v5); color: var(--v5i); }
.vc6 { background: var(--v6); color: var(--v6i); } .vc7 { background: var(--v7); color: var(--v7i); }

/* What a check says, under the line it is about */

.slider { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; cursor: default; }
.slider input { flex: 1; max-width: 300px; accent-color: var(--accent); }

/* Graphs */
.graph-block { position: relative; margin: 8px 0; max-width: calc(648px * var(--page-zoom)); border-radius: 8px; }
.graph-block.is-selected { box-shadow: 0 0 0 2px var(--accent); }
.graph-canvas { color: var(--dim); font-size: 13px; }
.graph-canvas { user-select: none; touch-action: none; cursor: grab; }
.graph-canvas:active { cursor: grabbing; }
.plot-block .graph-canvas { cursor: default; touch-action: auto; }
.graph-canvas svg { display: block; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.graph-tip { position: absolute; z-index: 2; font-size: 11.5px; color: var(--ink); border: 1px solid var(--line); box-shadow: var(--pop); pointer-events: none; white-space: nowrap; }
.graph-cross { position: absolute; width: 1px; background: var(--dim); pointer-events: none; }
.graph-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin: 2px 2px 8px; font-size: 15px; color: var(--ink); }
.graph-title, .graph-ends, .graph-letter { display: inline-flex; align-items: center; gap: 7px; }
.graph-words { color: var(--dim); font-size: 14px; }
.graph-note { color: var(--faint); font-size: 12px; }
.graph-letters { display: grid; gap: 10px; margin: 12px 2px 2px; }
.graph-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-size: 15px; }
.graph-letter { min-width: 3.2em; }
.graph-heading select, .graph-box { font: inherit; font-size: 14px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; outline: 0; }
.graph-heading select:focus, .graph-box:focus { border-color: var(--accent); }
.graph-box { width: 5.5em; }
.graph-slider { flex: 1 1 180px; max-width: 360px; accent-color: var(--accent); }
.graph-compare { font: inherit; font-size: 13px; color: var(--accent); background: none; border: 1px dashed var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.graph-compare:hover { border-color: var(--accent); }
.graph-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border: 1px solid var(--line); border-radius: 999px; }
.graph-chip .graph-box { width: 4.5em; border: 0; padding: 2px 2px; background: transparent; }
.graph-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--chip); }
.graph-chip-remove { border: 0; background: none; color: var(--dim); font-size: 15px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 999px; }
.graph-chip-remove:hover { color: var(--ink); background: var(--hover); }
.graph-labels { display: none; gap: 8px; margin-top: 6px; }
.graph-block.is-selected .graph-labels { display: flex; }
.graph-label-input { flex: 1; min-width: 0; padding: 4px 8px; font: inherit; font-size: 12.5px; color: inherit; background: var(--canvas); border: 1px solid var(--line); border-radius: 6px; outline: 0; }
.graph-label-input:focus { border-color: var(--accent); }
.plot-readout { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 6px 2px 0; font-size: 13px; }
.plot-readout:empty { display: none; }
.plot-note { padding: 16px; color: var(--dim); font-size: 13px; border: 1px dashed var(--line); border-radius: 8px; }
.plot-controls { display: none; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; padding: 10px; background: var(--side); border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; }
.plot-block.is-selected .plot-controls { display: flex; }
.plot-field { display: flex; align-items: center; gap: 5px; color: var(--dim); }
.plot-field select { max-width: 160px; padding: 2px 4px; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 5px; }
.plot-field .graph-label-input { width: 120px; flex: none; }
.plot-buttons { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.plot-buttons button { padding: 3px 9px; font-size: 12.5px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 6px; }
.plot-buttons button:hover { background: var(--hover); }
.graph-controls { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; opacity: 0; transition: opacity .1s; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; padding: 2px; }
.graph-block:hover .graph-controls { opacity: 1; }
.graph-controls button { min-width: 24px; height: 24px; padding: 0 5px; font-size: 12px; color: var(--dim); border-radius: 5px; line-height: 1; }
.graph-controls button:hover { background: var(--hover); color: var(--ink); }

/* The list at the caret */
#popup { position: fixed; z-index: 30; max-height: 320px; overflow-y: auto; }
.pop-item { display: flex; align-items: center; cursor: pointer; }
.pop-preview { flex: none; max-width: 150px; overflow: hidden; }
.pop-name { white-space: nowrap; text-overflow: ellipsis; }
.pop-key { margin-left: auto; flex: none; }
.pop-empty { font-size: 13px; color: var(--dim); }

/* Symbols */
.symbols { position: fixed; z-index: 26; width: 430px; max-width: calc(100vw - 16px); max-height: 60vh; display: flex; flex-direction: column; overflow: hidden; }
.symbol-tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); }
.symbol-tabs button { padding: 2px 8px; font-size: 12px; color: var(--dim); border-radius: 12px; }
.symbol-tabs button:hover { background: var(--hover); }
.symbol-tabs button.on { background: var(--accent-soft); color: var(--accent); }
.symbol-body { display: flex; flex-wrap: wrap; gap: 3px; padding: 8px; overflow-y: auto; }
.symbol-tile { min-width: 44px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; border-radius: 7px; overflow: hidden; }
.symbol-tile:hover { background: var(--accent-soft); }
.symbol-tile.wide { flex-basis: 100%; height: auto; min-height: 42px; flex-direction: row; justify-content: space-between; gap: 12px; padding: 6px 8px; }
.symbol-tile small { color: var(--dim); font-size: 12px; white-space: nowrap; }

/* LaTeX view */
#source { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--paper); }
.source-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; font-size: 12.5px; color: var(--dim); border-bottom: 1px solid var(--line); }
#copy-source { flex: none; padding: 4px 14px; color: var(--on-accent); background: var(--accent); border-radius: 7px; font-size: 13px; font-weight: 550; }
#source-text { flex: 1; min-height: 0; width: 100%; padding: 20px 26px; resize: none; border: 0; outline: 0; color: inherit; background: var(--paper); font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; }

#statusbar { flex: none; display: flex; align-items: center; gap: 10px; font-size: 11.5px; }
#key-hints { flex: 1; display: flex; align-items: center; gap: 14px; min-width: 0; overflow: hidden; white-space: nowrap; color: var(--faint); }
.key-hint { display: inline-flex; align-items: center; gap: 5px; }
.key-hint kbd { min-width: 0; padding: 0 4px; font-size: 10.5px; line-height: 15px; color: var(--dim); background: transparent; }
#word-count { flex: none; }

/* Windows on top */
/* The command box: one solid panel, an inset search field, grouped results, and keys at the bottom. */
#commands { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 14vh var(--space-4) var(--space-4); background: rgba(10, 12, 16, .28); }
.commands-box { width: 620px; max-width: 100%; max-height: 72vh; display: flex; flex-direction: column; overflow: hidden; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--pop); }
.command-search { flex: none; display: flex; align-items: center; gap: 10px; margin: 12px 12px 8px; padding: 0 12px; color: var(--dim); background: var(--hover); border: 1px solid transparent; border-radius: 10px; }
.command-search:focus-within { color: var(--ink); background: var(--paper); border-color: var(--line-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 6%, transparent); }
.command-search svg { flex: none; }
#command-input { flex: 1; min-width: 0; padding: 12px 0; border: 0; outline: 0; color: var(--ink); background: transparent; font: inherit; font-size: 15px; }
#command-input::placeholder { color: var(--faint); }
#command-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; }
#command-list:empty::after { content: "Nothing matches. Try another word."; display: block; padding: 14px 10px; font-size: 13px; color: var(--dim); }
.command-group { padding: 9px 10px 5px; font-size: 11px; font-weight: 600; }
.command-separator { height: 1px; margin: 6px 8px; background: var(--line); }
.command-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 10px; border-radius: 8px; text-align: left; font-size: 14px; color: var(--text); }
.command-icon { flex: none; width: 28px; height: 28px; display: grid; place-items: center; color: var(--dim); border-radius: 7px; }
.command-icon svg { display: block; }
.command-name { flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.command-item small { flex: none; margin-left: auto; font-size: 12px; }
.command-item small + .command-key, .command-item small + .command-typed { margin-left: 6px; }
.command-item.selected { color: var(--ink); background: var(--hover); }
.command-item.selected .command-name { font-weight: 600; }
.command-item.selected .command-icon { color: var(--spark); background: var(--spark-soft); }
.command-item:hover:not(.selected) { background: color-mix(in srgb, var(--hover) 55%, transparent); }
.command-typed { flex: none; margin-left: auto; padding: 1px 6px; font: 500 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--dim); border: 1px solid var(--line); border-radius: 5px; }

#modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; }
#modal-box { position: relative; width: 560px; max-width: 100%; max-height: 82vh; overflow-y: auto; padding: 24px 28px 26px; background: var(--paper); box-shadow: var(--pop); font-size: 14px; }
#modal-box h2 { margin: 0 0 10px; font-size: 18px; letter-spacing: -.01em; }
#modal-box h3 { margin: 16px 0 6px; font-size: 13px; color: var(--dim); font-weight: 600; }
#modal-box.guide { width: 760px; line-height: 1.55; }
.guide h2 { font-size: 22px !important; }
.guide h3 { margin-top: 24px !important; font-size: 16px !important; color: var(--ink) !important; }
.guide h4 { margin: 16px 0 4px; font-size: 14px; }
.guide p { margin: 6px 0; }
.guide ul { margin: 6px 0; padding-left: 22px; }
.guide li { margin: 3px 0; }
.guide table { width: 100%; margin: 8px 0; border-collapse: collapse; font-size: 13px; }
.guide th, .guide td { padding: 5px 8px; text-align: left; vertical-align: top; border: 1px solid var(--line); }
.guide th { background: var(--side); font-weight: 600; }
.guide code { padding: 0 4px; font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--hover); border-radius: 4px; }
.modal-close { position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; color: var(--dim); font-size: 17px; border-radius: 6px; }
.modal-close:hover { background: var(--hover); }
#modal-box.handwriting { width: min(900px, 100%); }
.handwriting-box { display: grid; gap: 14px; }
.handwriting-original { display: block; width: 100%; max-height: 330px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.handwriting-review { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 18px; align-items: start; }
.handwriting-editing { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.handwriting-label { font-size: 12px; font-weight: 650; color: var(--dim); }
.handwriting-latex { width: 100%; min-height: 90px; resize: vertical; padding: 12px; color: var(--text); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; outline: 0; }
.handwriting-latex:focus { border-color: var(--spark); box-shadow: 0 0 0 2px var(--spark-soft); }
.handwriting-preview { display: grid; gap: 8px; max-height: 260px; overflow: auto; padding: 12px; background: var(--tile-soft); border-radius: 12px; }
.handwriting-rendered { overflow-x: auto; }
.handwriting-status, .handwriting-error { margin: 0; color: var(--dim); font-size: 12.5px; line-height: 1.45; }
.handwriting-error { color: var(--bad); }
.handwriting-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 680px) { .handwriting-review { grid-template-columns: 1fr; } .handwriting-original { max-height: 240px; } }
.muted { color: var(--dim); margin: 4px 0; }
.version-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.version-row { padding: 7px 10px; text-align: left; border-radius: 7px; }
.version-row:hover { background: var(--accent-soft); color: var(--accent); }
#toast { position: fixed; z-index: 80; font-size: 13px; line-height: 1.4; opacity: 0; pointer-events: none; }
/* What was heard while saying maths. It sits still: no pulse, no meter. */
#voice { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); z-index: 79; display: flex; align-items: baseline; gap: 10px; max-width: min(620px, calc(100vw - 24px)); padding: 9px 16px; font-size: 13px; line-height: 1.4; color: var(--text); background: var(--paper); border-radius: 11px; box-shadow: var(--pop); }
#voice[hidden] { display: none; }
#voice strong { flex: none; font-weight: 600; color: var(--ink); }
#voice span { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool[data-tool="say-maths"][aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
#toast.show { opacity: 1; pointer-events: auto; }
#toast button { color: inherit; font-weight: 600; text-decoration: underline; }

@media (max-width: 960px) {
  #page { padding: 40px 44px 30px; }
}
@media (max-width: 760px) {
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; transform: translateX(-100%); transition: transform .18s; }
  #sidebar.open { transform: none; }
  #sidebar.open + #scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .3); }
  #crumb, #save-state, #statusbar { display: none; }
  #toolbar { overflow-x: auto; scrollbar-width: none; }
  #tools-main, .tool-section { flex-wrap: nowrap; flex: none; }
  #page { padding: 24px 28px 24px; max-width: none; min-height: 100%; box-shadow: none; }
  #title { font-size: 26px; }
  .top-actions > button, .menu-wrap > button { padding: 5px 7px; }
  #popup { width: min(340px, calc(100vw - 16px)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@page { size: A4; margin: 20mm 20mm 22mm; }
/* Tables that calculate */

#editor .tableWrapper.table-active { padding: 19px 0 0 24px; margin-left: -24px; overflow: visible; }
.table-active table { counter-reset: table-row; }
.table-active tr { counter-increment: table-row; }
.table-active tr:first-child { counter-reset: table-column; }
.table-active tr:first-child > * { counter-increment: table-column; }
.table-active tr:first-child > *::before { content: counter(table-column, upper-alpha); position: absolute; top: -19px; left: 0; right: 0; text-align: center; color: var(--dim); font-size: 10.5px; font-weight: 600; pointer-events: none; }
.table-active tr > :first-child:not(.selectedCell)::after { content: counter(table-row); position: absolute; left: -22px; top: 50%; transform: translateY(-50%); width: 18px; text-align: right; color: var(--dim); font-size: 10.5px; font-weight: 600; pointer-events: none; }

/* Diagrams */
.drawing-block { width: fit-content; max-width: 100%; }
.drawing-canvas svg { display: block; border-radius: 6px; }
.drawing-block.is-selected .drawing-canvas svg { outline: 1px solid var(--line); }
.board { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--canvas); outline: 0; }
.board-top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; min-height: 48px; padding: 8px 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
.board-gap { width: 8px; }
.board-spacer { flex: 1; }
.board-button { padding: 4px 10px; font-size: 13px; border-radius: 6px; color: var(--ink); }
.board-button:hover:not(:disabled) { background: var(--hover); }
.board-button:disabled { opacity: .4; }
.board-button.on { background: var(--accent-soft); color: var(--accent); }
.board-button.is-primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.board-selection { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.board-selection.is-empty { display: none; }
.board-label { width: 170px; padding: 4px 8px; font: inherit; font-size: 13px; color: inherit; background: var(--canvas); border: 1px solid var(--line); border-radius: 6px; outline: 0; }
.board-label:focus { border-color: var(--accent); }
.board-quick { display: flex; }
.board-symbol-key { width: 22px; height: 24px; font-size: 13px; border-radius: 4px; }
.board-symbol-key:hover { background: var(--hover); }
.board-colours { display: flex; gap: 3px; padding: 0 4px; }
.board-colour { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .4); }
.board-colour.on { border-color: var(--accent); }
.board-body { flex: 1; min-height: 0; display: flex; }
.board-palette { width: 188px; flex: none; overflow-y: auto; padding: 10px; background: var(--side); border-right: 1px solid var(--line); }
.board-heading { margin: 12px 0 5px; color: var(--dim); font-size: 11.5px; font-weight: 600; }
.board-heading:first-child { margin-top: 0; }
.board-tool { display: block; width: 100%; text-align: left; }
.board-symbols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.board-thumb { display: flex; align-items: center; justify-content: center; height: 40px; padding: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; }
.board-thumb:hover { border-color: var(--accent); }
.board-thumb svg { max-width: 100%; }
.board-stage { flex: 1; min-width: 0; overflow: auto; padding: 18px; display: flex; align-items: flex-start; justify-content: center; }
.board-surface { position: relative; flex: none; width: min(100%, 980px); box-shadow: var(--shadow); border-radius: 6px; overflow: hidden; touch-action: none; user-select: none; }
.board-svg { display: block; width: 100%; height: auto; }
.board-text-input { position: absolute; width: 180px; padding: 2px 6px; font: italic 15px "Times New Roman", serif; color: var(--ink); background: var(--paper); border: 1px solid var(--accent); border-radius: 4px; outline: 0; }

/* Sources and references */
.citation-link { color: var(--link); cursor: pointer; border-radius: 3px; }
.citation-link:hover { background: var(--accent-soft); }
.citation-link.is-selected { box-shadow: 0 0 0 1.5px var(--accent); }
.citation-link.is-missing { color: var(--bad); }
.references-block { position: relative; margin: 1.2em 0; border-radius: 6px; }
.references-block.is-selected { box-shadow: 0 0 0 2px var(--accent); }
.references-block:hover .graph-controls { opacity: 1; }
#editor .references-title { margin: 0 0 .5em; }
.reference { margin: 0 0 .55em; padding-left: 1.6em; text-indent: -1.6em; overflow-wrap: anywhere; }
.references-empty { margin: 0; color: var(--faint); }
.references-style { padding: 0 2px; font-size: 12px; color: var(--ink); background: var(--paper); border: 0; }
.source-form { display: flex; flex-direction: column; gap: 8px; }
.source-lookup { display: flex; gap: 6px; }
.source-form input, .source-form select { width: 100%; padding: 6px 9px; font: inherit; font-size: 13px; color: inherit; background: var(--canvas); border: 1px solid var(--line); border-radius: 6px; outline: 0; }
.source-note { margin: 0; color: var(--dim); font-size: 12px; }
.source-fields { display: flex; flex-direction: column; gap: 6px; }
.source-field { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 8px; color: var(--dim); font-size: 12.5px; }
.source-preview { margin: 4px 0 0; padding: 8px 10px; font-size: 12.5px; background: var(--side); overflow-wrap: anywhere; }
.source-preview-label { color: var(--dim); }
.source-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.source-button { white-space: nowrap; }
.source-button.is-primary { font-weight: 600; }
.source-button.is-danger { color: var(--bad); }
.source-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; font-size: 13px; text-align: left; border: 1px solid var(--line); overflow-wrap: anywhere; }
.source-row:hover { background: var(--hover); }
.source-state { flex: none; color: var(--dim); font-size: 12px; }

/* Python */
.code-block { position: relative; margin: .8em 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--side); }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 3px 6px 3px 12px; font-size: 11.5px; color: var(--dim); border-bottom: 1px solid var(--line); user-select: none; }
.code-text { margin: 0; padding: 10px 12px; overflow-x: auto; }
.code-text code { font: 13.5px/1.55 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; tab-size: 4; }
.code-comment { color: var(--dim); font-style: italic; }
.code-string { color: var(--plot-3); }
.code-number { color: var(--plot-2); }
.code-keyword { color: var(--plot-4); font-weight: 600; }
.code-builtin { color: var(--plot-1); }

/* Boxes for definitions, theorems, examples, notes and proofs */
.callout { position: relative; margin: .9em 0; }
.callout::before { position: absolute; font-family: var(--ui-font); content: "Note"; }
.callout[data-callout="definition"]::before { content: "Definition"; }
.callout[data-callout="theorem"]::before { content: "Theorem"; color: var(--plot-4); }
.callout[data-callout="theorem"] { border-left-color: var(--plot-4); }
.callout[data-callout="example"]::before { content: "Example"; color: var(--plot-3); }
.callout[data-callout="example"] { border-left-color: var(--plot-3); }
.callout[data-callout="proof"]::before { content: "Proof"; color: var(--dim); }
.callout[data-callout="proof"] { border-left-color: var(--dim); }
.callout[data-callout="note"]::before { content: "Note"; color: var(--plot-5); }
.callout[data-callout="note"] { border-left-color: var(--plot-5); }
.callout > :last-child { margin-bottom: 0; }

/* Templates */
.side-template { display: block; width: 100%; padding: 3px 10px 6px; text-align: left; }
.template-list { display: flex; flex-direction: column; gap: 10px; }
.template-row { display: flex; flex-direction: column; gap: 4px; padding: 14px; text-align: left; font-size: 13px; border: 1px solid var(--line); border-radius: 14px; }
.template-row:hover { background: var(--hover); border-color: var(--spark); }
.template-row span { color: var(--dim); font-size: 12.5px; line-height: 1.45; }
.template-sections { color: var(--faint); font-size: 11.5px; line-height: 1.45; }
#modal-box.templates { width: min(980px, 100%); }
.template-search { position: sticky; top: -24px; z-index: 1; width: 100%; height: 40px; padding: 0 14px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; font: inherit; font-size: 14px; box-shadow: 0 6px 10px -8px rgba(0,0,0,.25); }
.template-search:focus { outline: 2px solid var(--spark); outline-offset: 1px; }
.template-group[hidden], .template-row[hidden] { display: none; }
.template-group-title { margin: 10px 0 8px !important; text-transform: uppercase; letter-spacing: .06em; font-size: 11.5px !important; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.template-grid .template-row { min-width: 0; }
.template-empty { color: var(--dim); text-align: center; padding: 18px 0; }

/* Numbers, captions and links to them */
.math-number { margin-left: auto; padding-left: 12px; color: var(--dim); font-size: 14px; user-select: none; white-space: nowrap; }
.math-number:empty { display: none; }
.math-number { order: 4; }
.math-below { order: 5; }
#editor p.caption { margin: .25em 0 1em; text-align: center; color: var(--dim); font-size: .77em; }
.caption-label { font-weight: 600; color: var(--ink); }
.caption-empty::after { content: "Type a caption"; color: var(--faint); }
.ref-link { color: var(--link); cursor: pointer; border-radius: 3px; padding: 0 1px; }
.ref-link:hover { background: var(--accent-soft); }
.ref-link.is-selected { box-shadow: 0 0 0 1.5px var(--accent); }
.ref-link.is-missing { color: var(--bad); }
.flash { animation: flash-target 1.2s ease-out; }
@keyframes flash-target { 0%, 40% { background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); } 100% { background: transparent; box-shadow: none; } }

/* Find and replace */
#findbar { display: flex; flex-direction: column; gap: 4px; padding: 6px 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
.find-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.find-row input[type="search"], .find-row input[type="text"] { width: 240px; padding: 4px 8px; font: inherit; font-size: 13px; color: inherit; background: var(--canvas); border: 1px solid var(--line); border-radius: 6px; outline: 0; }
.find-row input:focus { border-color: var(--accent); }
.find-row select { max-width: 160px; min-height: 28px; padding: 3px 6px; color: var(--text); background: var(--canvas); border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 12px; }
.find-count { min-width: 66px; color: var(--dim); font-size: 12px; }
.find-case { display: flex; align-items: center; gap: 4px; color: var(--dim); font-size: 12px; cursor: pointer; }
.find-case[hidden] { display: none !important; }
.find-hit { background: var(--mark); color: var(--mark-ink); border-radius: 2px; }
.find-current { background: #ffb547; color: #1a1300; }

/* Contents */
#outline,#notes,#references { position: relative; display: flex; width: 248px; flex: none; overflow: hidden; background: var(--side); border-left: 1px solid var(--line); }
#outline { border-left: 0; border-right: 1px solid var(--line); }
#references { width: 300px; }
.outline-scroll { flex: 1; min-width: 0; overflow-y: auto; }
.outline-edge.on-right { left: auto; right: -1px; }
.outline-edge { position: absolute; left: -1px; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 2; }
.outline-edge:hover, body.resizing-outline .outline-edge { background: linear-gradient(to right, transparent 2px, var(--accent) 2px, var(--accent) 4px, transparent 4px); }
body.resizing-outline { cursor: col-resize; user-select: none; }
.outline-head { justify-content: space-between; }
.outline-title { font-size: 12px; font-weight: 600; }
.outline-item { display: flex; align-items: center; }
.outline-item .outline-row { flex: 1; min-width: 0; padding-left: 2px; }
.outline-item .outline-row:hover { background: none; }
.outline-item.level-1 .outline-row { font-weight: 600; }
.outline-item.level-2 { padding-left: 12px; }
.outline-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.outline-grip { flex: none; width: 14px; font-size: 10px; letter-spacing: -2px; color: var(--dim); cursor: grab; opacity: 0; user-select: none; touch-action: none; text-align: center; }
.outline-remove { flex: none; width: 22px; color: var(--dim); font-size: 15px; opacity: 0; border-radius: 4px; }
.outline-item:hover .outline-grip, .outline-item:hover .outline-remove, .outline-item:focus-within .outline-remove { opacity: 1; }
.outline-remove:hover { color: var(--ink); background: var(--line); }
.outline-rename { flex: 1; min-width: 0; margin: 1px 0; }
.outline-picker { margin: 0 0 12px; }
.outline-picker-title { margin: 0 0 6px; color: var(--dim); font-size: 12px; }
.outline-pick { display: flex; gap: 6px; align-items: baseline; padding: 3px 0; font-size: 13px; line-height: 1.35; cursor: pointer; }
.outline-pick span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.outline-pick.level-1 { font-weight: 600; }
.outline-pick.level-2 { padding-left: 12px; }
.outline-actions { display: flex; gap: 6px; margin-top: 8px; }
.outline-add, .outline-cancel { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; border: 1px solid var(--line); }
.outline-add { border-color: var(--accent); }
.outline-add:disabled { opacity: .5; }
.marker-layer { position: absolute; inset: 0; pointer-events: none; }
/* A quiet tag in the margin: it says the line is in the contents without competing with the writing. */
.marker-tag { position: absolute; left: 46px; width: 8px; height: 12px; margin-top: 2px; background: var(--faint); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); opacity: .6; }
@media (max-width: 760px) { .marker-tag { left: 6px; } }
#editor p.marker-target { box-shadow: inset 3px 0 0 var(--accent); background: rgba(47, 98, 233, .07); }
@media print { .marker-layer { display: none; } }
.outline-empty { margin: 0; }
/* The panel's two tabs, Sections and Values: plain words, the chosen one in ink. */

/* Values: each section's letters with their values. */
.outline-list[hidden],.outline-find[hidden] { display: none; }
/* Under each section in the Sections list: the values it sets, then what it holds. Quiet, one line, never maths-coloured. */
.outline-item { flex-wrap: wrap; }
.outline-row.is-question.level-2 { padding-left: 16px; }
.outline-row { display: flex; align-items: baseline; gap: 6px; width: 100%; line-height: 1.35; text-align: left; overflow: hidden; }
.outline-row.level-1 { font-weight: 600; }
.outline-row.level-2 { padding-left: 16px; }
.outline-row.level-3 { padding-left: 26px; color: var(--dim); }
.outline-row.is-equation, .outline-row.is-caption { padding-left: 26px; color: var(--dim); font-size: 12px; }
.outline-label { flex: none; font-weight: 600; }
.outline-text { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.outline-text .outline-math { display: inline; }
.outline-math { overflow: hidden; white-space: nowrap; font-size: 11px; }
/* Between phone and desktop widths a panel never sits on top of the writing: it takes its place beside the page,
   which narrows, and the documents list steps aside to make room while a panel is open. */
/* On a phone a panel is a sheet over the page, opened and closed with its own button at the top. */
@media (max-width: 760px) {
}
/* Up to 1500px, a panel on each side leaves room for the page only if the documents list steps aside. */
@media (min-width: 761px) and (max-width: 1100px) {
  #tools { width: 264px !important; }
  body:has(#tools:not([hidden])) #sidebar { display: none; }
}

@media print {
  :root, :root[data-theme="dark"] { --paper: #fff; --canvas: #fff; --ink: #000; --text: #111; --dim: #444; --line: #bbb; --side: #f4f4f4; --accent: #1a46c0; --graph-bg: #fff; --graph-axis: #bbb; --mark: #fff3a3; --mark-ink: inherit; color-scheme: light; }
  body { display: block; overflow: visible; }
  #sidebar, #topbar, #toolbar, #statusbar, #source, #tail, #popup, #toast, #voice, #modal, #symbols, #scrim, .copied-badge { display: none !important; }
  #main, #stage, #canvas { display: block; overflow: visible; height: auto; padding: 0; background: #fff; }
  #page { max-width: none; padding: 0; min-height: 0; font-size: 12pt; }
  .math-block { margin: 2px 0; padding: 2px 0; background: none !important; box-shadow: none !important; break-inside: avoid; }
  .vc { background: none !important; color: inherit !important; padding: 0; }
  #editor h1, #editor h2, #editor h3 { break-after: avoid; }
  #editor img, .graph-block { break-inside: avoid; }
  .page-break { break-after: page; border: 0; height: 0; margin: 0; visibility: hidden; }
}

@media print {
  #tools, #findbar, #ref-status { display: none !important; }
  .caption-empty { display: none; }
  .ref-link { color: inherit; }
  .find-hit, .find-current { background: none; color: inherit; box-shadow: none; }
}

@media print {
  .graph-controls, .graph-labels, .graph-letters, .graph-heading select, .graph-ends, .plot-controls, .graph-tip, .graph-cross { display: none !important; }
  .plot-block, .graph-block { break-inside: avoid; }
}

@media print {
  .board { display: none !important; }
}

@media print {
  .references-block.is-empty { display: none; }
  .citation-link { color: inherit; }
}

@page { margin: 18mm; @bottom-center { content: counter(page); font: 10pt -apple-system, Helvetica, Arial, sans-serif; color: #555; } }
@media print {
  .code-bar { display: none; }
  .code-block, .callout { break-inside: avoid; background: none; }
}

/* Writing working faster */
.rename-box, .name-tip { position: fixed; z-index: 60; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; max-width: 330px; padding: 8px 10px; font-size: 13px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--pop); }
.rename-box input { width: 90px; padding: 3px 7px; font: inherit; color: inherit; background: var(--canvas); border: 1px solid var(--accent); border-radius: 5px; outline: 0; }
.rename-box small { width: 100%; color: var(--dim); font-size: 11.5px; }
.name-tip button { padding: 2px 8px; font-size: 12px; color: var(--accent); border-radius: 5px; }
.name-tip button:hover { background: var(--accent-soft); }
.command-key { flex: none; margin-left: auto; }
.command-key.is-choosing { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.command-hint { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 9px 16px; border-top: 1px solid var(--line); font-size: 11.5px; }
.command-hint span { display: inline-flex; align-items: center; gap: 5px; }
@media print { .rename-box, .name-tip { display: none !important; } }

/* Charts drawn with Python */
.chart-block { width: fit-content; max-width: 100%; margin-inline: auto; }
.chart-image { display: block; max-width: 100%; height: auto; border-radius: 6px; background: #fff; }

@media print { .chart-block { break-inside: avoid; } }

/* Notes: a soft orange wash, so a note never looks like a yellow highlight. */
.note-mark { background: var(--note); border-bottom: 2px solid var(--note-line); border-radius: 2px; cursor: pointer; }
.note-mark .note-mark { background: var(--note-strong); }
.note-mark.note-active, .note-active .note-mark, .note-mark .note-active { background: var(--note-strong); }
.has-note { box-shadow: inset 3px 0 0 var(--note-line); background: var(--note); border-radius: 4px; }
.has-note.note-active { background: var(--note-strong); }
#toggle-notes[aria-pressed="true"], #toggle-outline[aria-pressed="true"] { color: var(--accent); }
.notes-count { margin-left: 4px; font-weight: 600; }
.notes-count:empty { display: none; }
.notes-list { display: flex; flex-direction: column; gap: 8px; }
.note-card { border-left: 3px solid var(--note-line); cursor: pointer; font-size: 13px; line-height: 1.4; outline: 0; }
.note-card:hover { border-color: var(--note-line); }
.note-card.is-active, .note-card:focus-visible { border-color: var(--note-line); box-shadow: 0 0 0 2px var(--note); }
.note-top { display: flex; align-items: center; gap: 2px; margin-bottom: 4px; }
.note-when { flex: 1; color: var(--dim); font-size: 11.5px; }
.note-button { opacity: 0; }
.note-remove { font-size: 15px; line-height: 1; }
.note-card:hover .note-button, .note-card.is-active .note-button, .note-card:focus-within .note-button { opacity: 1; }
.note-button:hover { color: var(--ink); }
.note-quote { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; padding-left: 6px; color: var(--dim); font-size: 12px; border-left: 2px solid var(--line); }
.note-quote-math { font-size: 11px; }
.note-text { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.note-edit { display: block; width: 100%; margin-top: 6px; resize: none; }
@media print { .note-mark, .has-note, .note-active { background: none !important; border: 0 !important; box-shadow: none !important; } }
.refs-body { display: flex; flex-direction: column; font-size: 13px; }
.refs-summary { margin: 0; line-height: 1.4; }
.refs-section { display: flex; flex-direction: column; gap: 6px; }
.refs-heading { font-size: 11px; font-weight: 650; }
.refs-note { margin: 0; }
.refs-card { display: flex; flex-direction: column; gap: 6px; border-left: 3px solid var(--good); cursor: pointer; line-height: 1.4; outline: 0; }
.refs-card:hover, .refs-card:focus-visible { border-color: var(--accent); border-left-color: var(--accent); }
.refs-card.is-uncited { border-left-color: var(--faint); }
.refs-card.is-uncited .refs-reference { color: var(--dim); }
.refs-card.has-gaps { border-left-color: var(--warn); }
.refs-reference { color: var(--text); overflow-wrap: anywhere; }
.refs-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11.5px; }
.refs-chip { background: var(--hover); color: var(--dim); }
.refs-chip.is-good { background: var(--good-soft); color: var(--good); }
.refs-gap { color: var(--warn); }
.refs-typed { display: flex; flex-direction: column; gap: 4px; border-left: 3px solid var(--warn); }
.refs-typed-text { align-self: flex-start; color: var(--ink); text-align: left; font-weight: 500; overflow-wrap: anywhere; }
.refs-typed-text:hover { text-decoration: underline; }
.refs-typed-count { flex: 1; color: var(--dim); font-size: 11.5px; }
.refs-button { flex: none; margin-left: auto; white-space: nowrap; }
.refs-button.is-primary { font-weight: 600; }
.refs-button.is-quiet { padding: 1px 6px; }
.refs-section > .refs-button { align-self: flex-start; margin-left: 0; }
.refs-wide { align-self: stretch !important; margin-left: 0; }
.refs-bibtex-paste summary { cursor: pointer; }
.refs-bibtex-paste[open] summary { margin-bottom: 6px; }
.refs-bibtex-input { box-sizing: border-box; width: 100%; margin-bottom: 6px; resize: vertical; }
#ref-status { flex: none; padding: 0 8px; border-radius: 9px; color: var(--dim); font-size: 11.5px; }
#ref-status:hover { background: var(--hover); color: var(--ink); }
#ref-status.is-warn { color: var(--warn); }
#ref-status.is-warn::before { content: "●"; margin-right: 5px; font-size: 8px; vertical-align: 1px; }

/* ---------- Tooltips: a name, and the keys that do the same ---------- */
/* Where a letter's value was set: a plain note under the letter, never on the maths itself. */
#tip { position: fixed; z-index: 95; display: flex; align-items: center; gap: 8px; max-width: 320px; padding: 5px 9px; font-size: 12px; line-height: 1.35; color: var(--paper); background: var(--ink); border-radius: 8px; box-shadow: var(--pop); pointer-events: none; opacity: 0; transform: translateY(3px); transition: opacity 90ms var(--ease), transform 90ms var(--ease); }
#tip.show { opacity: 1; transform: none; }
#tip kbd, #tip code { color: inherit; background: color-mix(in srgb, var(--paper) 16%, transparent); border-color: transparent; }
#tip code { padding: 0 5px; font: 500 11px/17px ui-monospace, SFMono-Regular, Menlo, monospace; border-radius: 5px; }

/* ---------- Keyboard shortcuts sheet ---------- */
#modal-box.keys-sheet { width: 920px; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.keys-top { display: flex; align-items: center; gap: 16px; padding: 22px 28px 16px; border-bottom: 1px solid var(--line); }
.keys-top h2 { margin: 0 auto 0 0 !important; font-size: 19px !important; }
.keys-search { width: 260px; margin-right: 34px; padding: 7px 11px; font: inherit; font-size: 13px; color: inherit; background: var(--side); border: 1px solid var(--line); border-radius: 9px; outline: 0; }
.keys-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--paper); }
.keys-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 28px 22px; columns: 2 360px; column-gap: 36px; }
.keys-card { break-inside: avoid; margin: 0 0 20px; }
.keys-card h3 { margin: 0 0 6px !important; font-size: 11px !important; font-weight: 650 !important; letter-spacing: .05em; text-transform: uppercase; color: var(--dim) !important; }
.keys-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.4; color: var(--text); }
.keys-row:last-child { border-bottom: 0; }
.keys-what { min-width: 0; }
.keys-how { flex: none; display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 48%; }
.keys-how code { padding: 0 6px; font: 500 11.5px/18px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); background: var(--hover); border-radius: 5px; white-space: nowrap; }
.keys-how .keys-words { color: var(--dim); font-size: 12px; }
.keys-foot { margin: 0; padding: 12px 28px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--dim); background: var(--side); }
.keys-none { margin: 4px 0 0; color: var(--dim); }

/* ---------- Motion: things open with a short, soft movement ---------- */
@keyframes rise-in { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .menu:not([hidden]), #popup:not([hidden]), .symbols:not([hidden]) { animation: rise-in 140ms var(--ease); }
  #commands:not([hidden]), #modal:not([hidden]) { animation: fade-in 120ms var(--ease); }
  #commands:not([hidden]) .commands-box, #modal:not([hidden]) #modal-box { animation: rise-in 170ms var(--ease); }
}
@media print { #tip, #key-hints { display: none !important; } }
.key-hint code { padding: 0 4px; font: 500 10.5px/15px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--dim); background: var(--hover); border-radius: 4px; }
body.no-key-hints #key-hints { visibility: hidden; }
.tip-keys { display: inline-flex; align-items: center; gap: 4px; color: color-mix(in srgb, var(--paper) 72%, transparent); }
.keys-search:focus-visible, #doc-search:focus-visible, #command-input:focus-visible { outline: none; }
.pop-shortcut { flex: none; margin-left: auto; }
.pop-item .pop-shortcut + .pop-key { margin-left: 6px; }
/* A line of maths lined up in the centre or on the right. Its number stays at the right-hand edge. */
.math-block[data-align="center"] { justify-content: center; }
.math-block[data-align="right"] { justify-content: flex-end; }
.math-block[data-align] .math-number { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); margin: 0; }
.math-block[data-align="right"]:has(.math-number:not(:empty)) { padding-right: 56px; }

/* ---------- Pop-ups tied to what opened them ---------- */
/* The browser keeps each one beside its button or the cursor as the page scrolls, and moves it to the other side when
   it would run off the window. anchor.js decides which pop-ups use this; the rest keep their fixed position. */
.anchor-layer { position: absolute; inset: 0; pointer-events: none; }
.anchor-mark { position: absolute; width: 1px; height: 22px; }
.is-anchored { inset: auto; margin: 4px 0 0; position-area: block-end span-inline-end; position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline; }
.is-anchored.anchor-centre { margin-top: 7px; position-area: block-end; position-try-fallbacks: flip-block; }
.is-anchored.anchor-end { margin-top: 6px; position-area: block-end span-inline-start; position-try-fallbacks: flip-block, flip-inline; }
@media print { .anchor-layer { display: none; } }

/* ---------- Panels and pop-ups ease in ---------- */
/* They play once each time they appear, so a list that stays open while you type does not flicker. */
@keyframes panel-in-left { from { opacity: 0; translate: -10px 0; } }
@keyframes panel-in-right { from { opacity: 0; translate: 10px 0; } }
@keyframes pop-in { from { opacity: 0; scale: .97; } }
@media (prefers-reduced-motion: no-preference) {
  #tools { animation: panel-in-right 200ms var(--ease); }
  #popup, .menu, .symbols, .rename-box, .name-tip { animation: pop-in 110ms var(--ease); transform-origin: top left; }
}

/* ---------- Moving between documents ---------- */
/* Only the page itself fades across; the bars around it stay still. */
#page { view-transition-name: page; }
::view-transition-old(page) { animation: page-out 100ms var(--ease) both; }
::view-transition-new(page) { animation: page-in 140ms var(--ease) both; }
@keyframes page-out { to { opacity: 0; } }
@keyframes page-in { from { opacity: 0; translate: 0 3px; } }
@media print { #page { view-transition-name: none; } }

/* The toolbar keeps one thin line under it; no shadow grows as the page scrolls. */
#toolbar { position: relative; z-index: 3; }

/* ---------- Where you are, in the contents ---------- */
.outline-row.is-here, .outline-item.is-here { background: var(--accent-soft); }
.outline-row.is-here, .outline-item.is-here .outline-row { color: var(--accent); }

/* ---------- Finish: depth, feel and small moments ---------- */
/* A faint wash of colour at the top of the desk, which scrolls away with the page. */
#canvas { background-attachment: local; background-repeat: no-repeat; }

/* Thin, quiet scroll bars that match the page. */
#canvas,#doc-list,.outline-scroll,#notes,#references,#popup,.symbols,#command-list,#source-text { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--dim) 32%, transparent) transparent; }

/* Buttons give a little as they are pressed. */
@media (prefers-reduced-motion: no-preference) {
  .tool, .top-actions > button, .menu-wrap > button, .side-action, .icon-button { transition: background var(--motion), color var(--motion), scale 90ms var(--ease); }
  .tool:active:not(:disabled), .top-actions > button:active, .menu-wrap > button:active, .side-action:active, .icon-button:active { scale: .95; }
}

/* The open document has a small accent bar. */
.doc-row.active::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; }

/* Saving shows as a small dot: grey and breathing while it saves, green once it is saved, red if it could not be. */
#save-state { display: inline-flex; align-items: center; gap: 6px; }
#save-state::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--good); opacity: .85; transition: background 200ms var(--ease); }
#save-state:empty::before { display: none; }
#save-state.saving::before { background: var(--faint); animation: save-breathe 1.1s ease-in-out infinite; }
#save-state.bad::before { background: var(--bad); }
@keyframes save-breathe { 50% { opacity: .25; } }

#editor .ProseMirror > .block-picked::selection, #editor .ProseMirror > .block-picked ::selection, body.is-block-dragging #editor ::selection { background: transparent; }
body.is-block-dragging, body.is-block-dragging * { cursor: default !important; }
.q-num { cursor: pointer; }

/* Controls that sit on the page keep the app's own typeface; only the writing is set in the document face. */
.graph-heading, .graph-letters, .graph-labels, .graph-controls, .graph-tip, .plot-readout, .plot-controls, .plot-note, .code-bar, .slider, .references-style, .name-tip { font-family: var(--ui-font); }

/* Page font: plain. The app's own typeface for the words, so the maths stands out from them. */
:root[data-page-font="plain"] #page { font-family: var(--ui-font); }
:root[data-page-font="plain"] #title { font-size: 2.125em; }
:root[data-page-font="plain"] #editor h1, :root[data-page-font="plain"] #editor h2, :root[data-page-font="plain"] #editor h3 { letter-spacing: -.015em; }
:root[data-page-font="plain"] #editor h1 { font-size: 1.5em; }
:root[data-page-font="plain"] #editor h2 { font-size: 1.219em; }
:root[data-page-font="plain"] #editor h3 { font-size: 1.031em; }
:root[data-page-font="plain"] .math-inline .katex, :root[data-page-font="plain"] .math-inline math-field { font-size: 1.07em; }
:root[data-page-font="plain"] .math-inline { --maths-size: 1.07em; }
:root[data-page-font="plain"] .math-block .math-render .katex-display > .katex, :root[data-page-font="plain"] .math-block math-field, :root[data-page-font="plain"] .math-ghost .katex { font-size: 1.12em; }

@media print { }

/* Build 124 */
/* Every row of the symbol list starts its name at the same place, whatever the width of the symbol. */
.pop-preview { min-width: 30px; display: inline-flex; justify-content: center; }
/* Menus and windows arrive with a short lift. The list at the caret does not: nothing may move while you type. */
@keyframes lift { from { opacity: 0; transform: translateY(5px) scale(.985); } }
@media (prefers-reduced-motion: no-preference) {
  .menu:not([hidden]), .symbols:not([hidden]) { animation: lift .13s var(--ease); }
  #commands:not([hidden]) .commands-box, #modal:not([hidden]) #modal-box { animation: lift .17s var(--ease); }
}

/* A printed page is always its real size. */
@media print { :root { --page-zoom: 1 !important; } }

/* Build 126 */
/* Selecting words on the page looks like running a highlighter over them. */
#page ::selection { background: var(--selection); color: inherit; }
/* A setting in a menu shows a switch, so on and off can be seen without reading. */
.menu button[role="menuitemcheckbox"]::before, .menu button[role="menuitemcheckbox"]::after { content: ""; position: absolute; top: 50%; transition: background var(--motion), transform var(--motion); }
.menu button[role="menuitemcheckbox"]::before { background: var(--line-strong); }
.menu button[role="menuitemcheckbox"]::after { border-radius: 50%; background: var(--paper); box-shadow: 0 1px 2px rgba(16, 24, 40, .25); }
.menu button[role="menuitemcheckbox"][aria-checked="true"]::after { transform: translateX(12px); }

/* Build 127 */

/* One flat row of tools lined up on the left, as in Google Docs. Lined up on the left, the buttons stay where they are
   when the row changes between words, maths and tables, instead of re-centring and jumping sideways. Symbols sits at
   the far right. Where the row is short of room, the typed-key badges go first, so every button still fits. */
#toolbar { container: toolbar / inline-size; justify-content: flex-start; gap: 4px; border-bottom: 1px solid var(--line); }
#tools-main { flex: 1 1 auto; padding: 0; background: none; border-radius: 0; box-shadow: none; }
#toolbar > .tool { height: 30px; padding: 0 9px; background: none; border-radius: 7px; box-shadow: none; }
#toolbar > .tool-symbols { margin-left: auto; }
@container toolbar (max-width: 1060px) {
  #tools-main .tool-kbd { display: none; }
  #toolbar .tool { min-width: 26px; padding: 0 5px; }
  #toolbar .tool-gap { margin: 6px 2px; }
}
#canvas { padding-top: 22px; }
#doc-list::before { content: "Documents"; }
.doc-row { font-size: 13.5px; }

/* ---------- Build 128: one look for maths ----------
   Every piece of maths, in a sentence or on a line of its own, is the same rounded wash that hugs the maths. Only its
   strength changes: faint at rest, deeper when pointed at or being written in, and the highlighter colour when it is
   part of a selection, exactly like selected words. There are no bars, rings or outlines, so nothing on the page
   jumps or shouts while you write. The wash is on screen only and never prints. */
:root { --maths-rest: var(--maths-tint); }
@media (prefers-color-scheme: dark) { }
/* ⋯ → Wash behind maths: off leaves the maths as plain typeset maths, as in a printed book. */
:root[data-maths-wash="off"] { --maths-rest: transparent; }

.math-inline { display: inline-block; vertical-align: baseline; line-height: 1; margin: -.06em .03em; padding: .06em .16em; border-radius: 5px; background: var(--maths-rest); cursor: text; transition: background var(--motion); }
/* The wash fits the maths itself: a single letter gets a small, even wash, not a tall narrow pill. */
.math-inline .katex { font-size: 1em; line-height: 1; }
.math-inline > .math-main { padding: 5px 0; margin: -5px 0; }
.math-block { margin: 0 -8px 0 -18px; padding-left: 18px; background: none; box-shadow: none; }
/* Moved with left, not a margin: lining up equals signs sets the margin. */
.math-block > .math-main { position: relative; left: -10px; isolation: isolate; padding: 10px 0; margin: -5px 0; }
/* While a line is being written in, tall maths such as a fraction may stand a little proud of the field. It is shown
   whole rather than cut off, and the line keeps its height, so nothing below moves when it opens. */
.math-block.is-active > .math-main { overflow: visible; }
/* The side room belongs to the maths itself, so a click or drag anywhere on the wash lands in the maths. */
.math-block > .math-main > .math-render, .math-block > .math-main > .math-empty { padding: 0 10px; }
/* The open field is a little taller than the typeset maths; it overlaps its own wash, so opening a line never moves the page. */
.math-block > .math-main > math-field { margin: -4px 10px; }
.math-block > .math-main::before { content: ""; position: absolute; inset: 4px 0; z-index: -1; border-radius: 6px; background: var(--maths-rest); transition: background var(--motion); }
.math-block:not(.is-active) > .math-main:has(.math-empty)::before { background: none; }

/* Where Space will put the caret when it steps out of a power, a subscript, the bottom of a fraction or a root: a
   faint, still caret standing at that spot. It is drawn over the line, so it never moves anything, and never prints. */
.math-inline > .math-main { position: relative; }
.math-landing { position: absolute; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--accent); opacity: .22; pointer-events: none; }
.math-landing[hidden] { display: none; }
@media print { .math-landing { display: none; } }

/* Pointed at, or being written in: the same wash, deeper. */
.math-inline:hover, .math-inline.is-active { background: var(--maths-strong); }
.math-block:hover > .math-main::before, .math-block.is-active > .math-main::before { background: var(--maths-strong); }
/* The lines a result was worked out from, while it is offered, and every use of a value pointed at in the Values
   list: the same wash, deeper, as when pointed at. */
/* Part of a selection, however it was made: the highlighter, like selected words. */
.math-inline.in-selection, .math-inline.is-selected:not(.is-active), .block-picked .math-inline { background: var(--selection); }
.math-block.in-selection > .math-main::before, .math-block.is-selected:not(.is-active) > .math-main::before, .math-block.block-picked > .math-main::before { background: var(--selection); }

/* Whole lines selected by Ctrl+Shift+A, a question number or the margin look like selected words: the same colour,
   no box around them. */
#editor .ProseMirror > .block-picked:not(.math-block) { background: var(--selection); border-radius: 3px; box-shadow: none; }
#editor .ProseMirror > .block-picked.math-block { background: none; }

/* Find marks the maths itself. */
.math-inline.find-hit, .math-block.find-hit > .math-main::before { box-shadow: 0 0 0 2px var(--mark); }
.math-inline.find-current, .math-block.find-current > .math-main::before { box-shadow: 0 0 0 2px #ffb547; }

/* Tab keeps a grey answer: the wash glows once. Copying: the copied thing flashes once and a small "Copied" label
   rises beside it, so a copy is felt even when nothing was highlighted. */
@keyframes maths-glow { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--highlighter) 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }
@keyframes copied-flash { 0%, 35% { background: var(--selection); } 100% { background: transparent; } }
@keyframes copied-flash-maths { 0%, 35% { background: var(--selection); } }
.math-inline.just-kept, .math-block.just-kept > .math-main::before { animation: maths-glow 700ms var(--ease); }
.just-copied:not(.math-inline):not(.math-block) { animation: copied-flash 650ms var(--ease); border-radius: 3px; }
.math-inline.just-copied, .math-block.just-copied > .math-main::before { animation: copied-flash-maths 650ms var(--ease); }
.copied-badge { position: fixed; z-index: 90; font: 600 11.5px/1.3 var(--ui-font); color: var(--on-highlighter); background: var(--highlighter); box-shadow: 0 4px 12px -4px rgba(16, 24, 40, .3); pointer-events: none; animation: copied-badge 1.1s var(--ease) forwards; }
@keyframes copied-badge { 0% { opacity: 0; transform: translateY(4px); } 15%, 70% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .copied-badge { animation-duration: 1.4s; } }

@media print {
  .math-inline { margin: 0; padding: 0 1px; background: none !important; }
  .math-block > .math-main::before { display: none; }
  #editor .ProseMirror > .block-picked { background: none !important; }
}

/* A list at the caret or under a button: the name is never cut short; the grey description gives way instead. */
#popup { width: min(380px, calc(100vw - 16px)); }
.pop-name { flex: none; overflow: visible; }
.pop-group { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* The shortcuts sheet: an action's keys are a button. Pointing at it shows it can be changed. */
.keys-set { display: inline-flex; align-items: center; gap: 6px; margin: -3px -6px; padding: 3px 6px; border-radius: 7px; transition: background var(--motion); }
.keys-set:hover, .keys-set:focus-visible { background: var(--hover); }
.keys-pencil { font-size: 11.5px; color: var(--dim); opacity: 0; transition: opacity var(--motion); }
.keys-set:hover .keys-pencil, .keys-set:focus-visible .keys-pencil { opacity: 1; }
.keys-add { font-size: 12px; color: var(--faint); }
.keys-set.is-choosing { background: var(--accent-soft); }
.keys-set.is-choosing kbd { color: var(--on-highlighter); background: var(--highlighter); border-color: transparent; }

/* The writing area is one plain white sheet, as in Google Docs: no grey desk, no card, no shadow and no glow around
   the page. The sidebar alone keeps its own shade. */
#main, #stage, #canvas, #topbar, #toolbar, #statusbar { background: var(--paper); background-image: none; }

#modal-box.snippets-modal { width: 680px; }
.snippet-tools, .snippet-buttons { display: flex; gap: 8px; margin: 12px 0; }
.snippet-form { display: grid; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.snippet-form input { width: 100%; padding: 8px 10px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 7px; font: inherit; }
#snippet-maths { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; }
.snippet-list { display: grid; gap: 6px; }
.snippet-row { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(120px, 1.5fr) auto auto; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.snippet-names { display: grid; gap: 3px; }
.snippet-names span { color: var(--dim); font-size: 12px; }
.snippet-preview { min-width: 0; overflow-x: auto; }
.snippet-message { min-height: 1.3em; margin: 0; color: var(--dim); }
.snippet-buttons .primary { padding: 6px 12px; color: var(--on-highlighter); background: var(--highlighter); border-radius: 7px; font-weight: 600; }
@media (max-width: 600px) { .snippet-row { grid-template-columns: 1fr auto auto; } .snippet-preview { grid-column: 1 / -1; grid-row: 2; } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --highlighter: #ffd84d; --on-highlighter: #1f1f1f;
    --side-wash: linear-gradient(180deg, #1e1c33 0%, #191921 48%, #181818 100%);
    --tint-definition: #9b97ff; --tint-theorem: #d08cff; --tint-example: #5fd3a4; --tint-note: #ffb35c;
    --chip-0: #8a85ff; --chip-1: #f472b6; --chip-2: #4fd1a0; --chip-3: #fbab4c; --chip-4: #4cc9e0; --chip-5: #c18cff; --chip-6: #f87171; --chip-7: #a3d65c;
  }
}
:root[data-theme="dark"] {
  --highlighter: #ffd84d; --on-highlighter: #1f1f1f;
  --side-wash: linear-gradient(180deg, #1e1c33 0%, #191921 48%, #181818 100%);
  --tint-definition: #9b97ff; --tint-theorem: #d08cff; --tint-example: #5fd3a4; --tint-note: #ffb35c;
  --chip-0: #8a85ff; --chip-1: #f472b6; --chip-2: #4fd1a0; --chip-3: #fbab4c; --chip-4: #4cc9e0; --chip-5: #c18cff; --chip-6: #f87171; --chip-7: #a3d65c;
}
.doc-open { flex-direction: row; align-items: center; }
.doc-text { display: flex; flex-direction: column; min-width: 0; }
.doc-chip { flex: none; display: inline-flex; align-items: center; justify-content: center; }
:root[data-theme="dark"] .doc-row.active .doc-chip { color: #141414; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .doc-row.active .doc-chip { color: #141414; } }

/* Headings and questions: the structure of the page reads in colour. */
#editor h1, #editor h2, #editor h3 { color: var(--heading); }
.q-num, #editor .ProseMirror > ol.q-level-1 > li::marker { color: var(--accent); }

/* Boxes: each kind has its own colour, as a soft tint with a matching edge and label. */
.callout { --tint: var(--tint-note); border-left-color: var(--tint); }
.callout[data-callout="definition"] { --tint: var(--tint-definition); }
.callout[data-callout="theorem"] { --tint: var(--tint-theorem); }
.callout[data-callout="example"] { --tint: var(--tint-example); }
.callout[data-callout="note"] { --tint: var(--tint-note); }
.callout[data-callout="proof"] { --tint: var(--tint-proof); }
.callout[data-callout] { border-left-color: var(--tint); }

/* Table headings pick up the accent, so a table reads as data at a glance. */
#editor th { border-bottom-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }

/* The toolbar's maths buttons and the active document marker share the accent. */
.doc-row.active::before { background: var(--chip, var(--accent)); }

/* ---------- Desmos-style graph workspace ---------- */
.graph-block:has(> .graph-workspace) { max-width: calc(900px * var(--page-zoom)); }
.graph-workspace { display: grid; min-height: 420px; overflow: hidden; color: var(--ink); background: var(--paper); border: 1px solid var(--line); font-family: var(--ui-font); }
.graph-sidebar { min-width: 0; overflow-y: auto; max-height: 520px; border-right: 1px solid var(--line); }
.graph-sidebar-actions { position: sticky; top: 0; z-index: 3; display: flex; gap: 5px; padding: 7px; background: var(--canvas); border-bottom: 1px solid var(--line); }
.graph-ui-button { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; min-height: 28px; padding: 3px 7px; color: var(--dim); background: transparent; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font: inherit; line-height: 1; }
.graph-ui-button:hover { color: var(--ink); background: var(--hover); }
.graph-ui-button:focus-visible, .graph-expression-row summary:focus-visible, .graph-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.graph-add-expression { color: var(--accent); font-size: 20px; }
.graph-settings-toggle { margin-left: auto; }
.graph-expression-list { display: grid; }
.graph-expression-row { border-bottom: 1px solid var(--line); }
.graph-expression-input { flex: 1; min-width: 0; padding: 5px 4px; color: var(--ink); border: 1px solid transparent; font-size: 16px; }
.graph-expression-input:focus-within { background: var(--paper); border-color: var(--accent); }
.graph-expression-row.is-hidden .graph-expression-input { opacity: .42; }
.graph-colour-button { font-size: 17px; }
.graph-visibility-button { color: var(--dim); font-size: 13px; }
.graph-expression-options { position: relative; flex: none; }
.graph-expression-options > summary { min-width: 25px; padding: 5px; color: var(--dim); border-radius: 5px; cursor: pointer; list-style: none; text-align: center; }
.graph-expression-options > summary::-webkit-details-marker { display: none; }
.graph-expression-options[open] > summary { color: var(--ink); background: var(--hover); }
.graph-expression-options[open] { position: relative; z-index: 4; background: var(--paper); }
.graph-option-row { position: absolute; right: 0; display: flex; gap: 4px; min-width: 150px; padding: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--pop); }
.graph-option-row + .graph-option-row { top: 37px; }
.graph-line-style, .graph-line-width { min-width: 68px; padding: 3px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 4px; font: inherit; font-size: 12px; }
.graph-plot-area { position: relative; min-width: 0; background: var(--graph-bg); }
.graph-plot-area .graph-canvas, .graph-plot-area .graph-canvas svg { width: 100%; height: 100%; min-height: 420px; }
.graph-plot-area .graph-canvas svg { border: 0; border-radius: 0; }
.graph-workspace .graph-controls { z-index: 2; }
.graph-workspace .graph-heading, .graph-workspace .graph-letters { margin: 0; padding: 10px; border-bottom: 1px solid var(--line); }
.graph-workspace .graph-title, .graph-workspace .graph-row { font-size: 13px; }
.graph-workspace .graph-letter { min-width: 2.5em; }
.graph-slider-play { flex: none; width: 25px; height: 25px; padding: 0; color: var(--accent); background: transparent; border: 0; border-radius: 50%; }
.graph-slider-play:hover { background: var(--hover); }
.graph-slider-settings { flex: none; font-size: 11px; color: var(--dim); }
.graph-slider-settings summary { cursor: pointer; }
.graph-slider-settings input { display: block; width: 65px; margin: 3px; font-size: 11px; }
.graph-settings-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 10px; color: var(--dim); background: var(--canvas); border-bottom: 1px solid var(--line); font-size: 12px; }
.graph-settings-panel[hidden] { display: none; }
.graph-settings-bounds { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.graph-setting-number { min-width: 0; width: 100%; padding: 5px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 4px; font: inherit; }
.graph-settings-labels { display: flex; gap: 5px; margin: 0; }
.graph-angle-mode { grid-column: 1 / -1; padding: 5px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 4px; font: inherit; }
.graph-setting-toggle { display: flex; align-items: center; gap: 5px; }
.graph-workspace.is-collapsed { grid-template-columns: minmax(0, 1fr); }
.graph-workspace.is-collapsed .graph-sidebar { display: none; }
.graph-block.is-fullscreen { position: fixed; inset: 0; z-index: 10000; width: 100vw; max-width: none; height: 100dvh; margin: 0; border-radius: 0; background: var(--paper); }
.graph-block.is-fullscreen .graph-workspace { height: 100dvh; border: 0; border-radius: 0; }
.graph-block.is-fullscreen .graph-sidebar { max-height: none; }
.graph-block.is-fullscreen .graph-plot-area .graph-canvas, .graph-block.is-fullscreen .graph-plot-area .graph-canvas svg { height: 100%; min-height: 0; }
body.graph-fullscreen-open { overflow: hidden; }
body.graph-fullscreen-open #topbar, body.graph-fullscreen-open #toolbar, body.graph-fullscreen-open #sidebar, body.graph-fullscreen-open #statusbar { display: none; }
@media (max-width: 700px) {
  .graph-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .graph-plot-area .graph-canvas, .graph-plot-area .graph-canvas svg { min-height: 350px; }
  .graph-block.is-fullscreen .graph-sidebar { max-height: 38dvh; }
}
@media print {
  .graph-sidebar, .graph-workspace .graph-controls { display: none !important; }
  .graph-workspace { display: block; min-height: 0; border: 0; }
  .graph-plot-area .graph-canvas, .graph-plot-area .graph-canvas svg { min-height: 0; height: auto; }
  .graph-block.is-fullscreen { position: static; width: auto; height: auto; }
}

/* Graph workspace refinement: the plot leads, and every control is available without hovering. */
.graph-workspace { grid-template-columns: minmax(140px, 26%) minmax(0, 1fr); border-radius: 14px; }
.graph-sidebar { background: var(--tile-soft); }
.graph-expression-row { padding: 6px; }
.graph-expression-input { min-height: 38px; background: var(--paper); border-color: var(--line); border-radius: 8px; }
.graph-plot-area .graph-canvas, .graph-plot-area .graph-canvas svg { min-height: 460px; }
.graph-workspace .graph-controls { top: auto; bottom: 10px; right: 10px; max-width: calc(100% - 20px); padding: 4px; opacity: 1; background: var(--glass); border-radius: 999px; backdrop-filter: blur(14px) saturate(150%); -webkit-backdrop-filter: blur(14px) saturate(150%); }
.graph-workspace .graph-controls button { flex: 0 0 auto; min-width: 30px; padding: 0 8px; border-radius: 999px; white-space: nowrap; }
.graph-workspace .graph-controls button:hover, .graph-workspace .graph-controls button:focus-visible { color: var(--ink); background: var(--hover); }
@media (max-width: 700px) {
  .graph-workspace { grid-template-columns: minmax(0, 1fr); }
  .graph-plot-area .graph-canvas, .graph-plot-area .graph-canvas svg { min-height: 370px; }
  .graph-workspace .graph-controls { bottom: 8px; right: 8px; max-width: calc(100% - 16px); overflow-x: auto; }
}
@media (max-width: 480px) {
  .graph-workspace .graph-controls { border-radius: 16px; }
  .graph-workspace .graph-controls button { min-width: 38px; min-height: 38px; }
}
#editor { margin-left: 44px; }
#line-numbers { position: absolute; inset: 0; overflow: hidden; pointer-events: none; user-select: none; }
#line-numbers span { position: absolute; left: 0; width: 34px; color: var(--faint); font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-align: right; }
@media (max-width: 760px) { #editor { margin-left: 32px; } #line-numbers span { width: 28px; } }
/* Letters with a value are coloured on screen only (lettercolours.js). */
/* ---------- The tool panel: Values, Sections, Notes and References behind one tab strip ---------- */
#tools { position: relative; display: flex; flex-direction: column; flex: none; width: 340px; min-height: 0; overflow: hidden; }
#tools[hidden] { display: none; }
.tool-body { position: relative; flex: 1; min-height: 0; display: flex; }
#tools .tool-view { position: relative; flex: 1; width: auto !important; min-width: 0; border: 0; border-radius: 0; background: none; box-shadow: none; animation: none; }
#tools .tool-view[hidden] { display: none; }
#tools .tool-view > .outline-edge { display: none; }
#tools > .outline-edge, #tools .tool-view:not([hidden]) > .outline-edge:first-child { display: block; }
/* On a phone the tool panel is a sheet over the page, under the top bar; this comes after the panel's own rules. */
@media (max-width: 760px) {
  #tools { position: fixed; inset: 64px 0 0 0; z-index: 14; width: auto !important; border-radius: 0; box-shadow: var(--pop); }
  #tools .tool-tab, #tools .tools-close { min-width: 44px; min-height: 44px; justify-content: center; }
}

/* Graph interaction and expression states. */
.graph-workspace { box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 5%, transparent); }
.graph-expression-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 28px 28px; align-items: center; gap: 4px; min-height: 52px; }
.graph-expression-row .graph-ui-button, .graph-expression-row summary { min-width: 28px; min-height: 32px; }
.graph-expression-input { transition: border-color 120ms var(--motion-ease, ease), background 120ms var(--motion-ease, ease); }
.graph-expression-row.is-checking .graph-expression-input { border-color: var(--accent); background: var(--spark-soft, var(--hover)); }
.graph-expression-row.has-error .graph-expression-input { border-color: var(--bad); }
.graph-expression-error { grid-column: 1 / -1; padding: 0 4px 5px; color: var(--bad); font-size: 11.5px; line-height: 1.35; overflow-wrap: anywhere; }
.graph-expression-error[hidden] { display: none; }
.graph-trace-dot { position: absolute; z-index: 3; width: 11px; height: 11px; border: 2px solid var(--graph-bg); border-radius: 50%; background: var(--trace-colour); box-shadow: 0 0 0 1px var(--trace-colour); transform: translate(-50%, -50%); pointer-events: none; }
.graph-trace-dot[hidden] { display: none; }
.graph-tip { display: grid; gap: 2px; min-width: 82px; padding: 7px 9px; border-radius: 8px; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.graph-tip strong { font-size: 12px; font-weight: 650; }
.graph-tip span { max-width: 180px; overflow: hidden; color: var(--dim); font-size: 10.5px; text-overflow: ellipsis; }
.graph-tip[hidden], .graph-cross[hidden] { display: none; }
.graph-cross { z-index: 1; opacity: .25; }
.graph-empty { display: grid; place-items: center; min-height: 320px; padding: 30px; color: var(--dim); text-align: center; }
.graph-workspace .graph-controls { border: 1px solid var(--line); box-shadow: 0 3px 14px color-mix(in srgb, var(--ink) 10%, transparent); scrollbar-width: none; }
.graph-workspace .graph-controls::-webkit-scrollbar { display: none; }
.graph-workspace .graph-controls button { min-height: 32px; }
@media (max-width: 700px) {
  .graph-sidebar { max-height: min(38dvh, 280px); }
  .graph-expression-row .graph-ui-button, .graph-expression-row summary { min-width: 40px; min-height: 40px; }
  .graph-workspace .graph-controls button { min-width: 44px; min-height: 44px; }
  .graph-tip { padding: 8px 10px; }
}
@media print { .graph-trace-dot { display: none !important; } }
body.graph-fullscreen-open #line-numbers { display: none; }
.graph-block.is-fullscreen { overflow: hidden; isolation: isolate; }
.graph-block.is-fullscreen .graph-workspace { grid-template-rows: minmax(0, 1fr); min-height: 0; overflow: hidden; }
.graph-block.is-fullscreen .graph-plot-area { min-height: 0; overflow: hidden; }
.graph-block.is-fullscreen .graph-plot-area .graph-canvas,
.graph-block.is-fullscreen .graph-plot-area .graph-canvas svg { height: 100% !important; min-height: 0 !important; }
@media (max-width: 700px) {
  .graph-block.is-fullscreen .graph-workspace { grid-template-rows: auto minmax(0, 1fr); }
}

/* Chart studio: visual controls first, code and advanced settings second. */

/* Chart studio clarity pass: identity, stroke and value are visible at a glance. */

/* Each curve is edited as typeset maths in its own card. */

.chart-expression-input { display: block; width: 100%; min-width: 0; min-height: 38px; padding: 6px 8px; color: var(--ink); background: var(--tile-soft); border: 1px solid transparent; border-radius: 9px; font-size: 18px; outline: none; }
.chart-expression-input:focus-within { background: var(--paper); border-color: color-mix(in srgb, var(--curve-colour) 55%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--curve-colour) 12%, transparent); }
@media (max-width: 900px) {
  .chart-expression-input { min-height: 44px; font-size: 18px; }
}

/* Command metadata stays readable throughout the panel's opening fade. */
.command-group, .command-item small, .command-item .command-key, .command-hint, .command-hint kbd { color: var(--text); }

/* Live graphs of functions (chartlive.js): while its chart is being edited, the graph on the page is interactive. */

/* The coordinates are labelled on the graph itself; this copy is for screen readers. */

/* On narrow screens the chart settings are a sheet along the bottom, so the live graph stays in view above it. */

