/* ==========================================================================
   OpenInterval — Inflection
   Loaded after studio.css. Layout and presentation only: no editor, maths,
   engine, storage, graph or export behaviour changes.

   The idea: the point of inflection on an S-curve, where an idea takes off.
   It is the mark (a curve through a single orange point), it draws itself on
   launch, and it redraws every time the work saves.

   The window is a bento of soft tiles on a warm stone desk: documents, the
   page and each side panel are their own rounded tiles; the window controls
   float in a glass pill; the formatting tools sit in a second pill. Documents
   are colour cards; the open one fills with its colour and carries a black
   arrow set into a bite in its corner.

   Motion is small and springy, on controls only, never on maths or words
   while they are written, and all of it switches off with reduced motion.
   ========================================================================== */

/* Figtree, a friendly sans serif (SIL Open Font License, static/vendor/fonts/figtree/OFL.txt), shipped with the app so it works offline. */
@font-face { font-family: "Figtree"; src: url("/vendor/fonts/figtree/figtree-latin-wght-normal.woff2") format("woff2"); font-weight: 300 900; font-style: normal; font-display: swap; unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Figtree"; src: url("/vendor/fonts/figtree/figtree-latin-wght-italic.woff2") format("woff2"); font-weight: 300 900; font-style: italic; font-display: swap; unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Figtree"; src: url("/vendor/fonts/figtree/figtree-latin-ext-wght-normal.woff2") format("woff2"); font-weight: 300 900; font-style: normal; font-display: swap; unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Figtree"; src: url("/vendor/fonts/figtree/figtree-latin-ext-wght-italic.woff2") format("woff2"); font-weight: 300 900; font-style: italic; font-display: swap; unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

:root {
  --sans: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: var(--sans);
  --ui-font: var(--sans);

  --desk: #ece9e3; --tile: #fbfaf7; --tile-soft: #f4f2ed; --glass: rgba(251, 250, 247, .72);
  --paper: #ffffff; --canvas: var(--tile-soft); --side: var(--tile); --side-wash: var(--tile); --hover: #efece6;
  --line: #e4e0d8; --line-strong: #d3cec4;
  --ink: #111110; --text: #262522; --dim: #6e6b64; --faint: #6b6861;

  /* One warm spark, the colour of the point on the curve, carries every highlight. */
  --spark: #ff6b3d; --spark-soft: #ffe7dc; --on-spark-soft: #8f2f0b;
  --tangerine: #ff6b3d; --iris: #6e5bff; --mint: #2fbf8f; --sky: #36a3f7; --rose: #f2559c; --olive: #8a9a2b; --clay: #c8693e; --cobalt: #2747d9;
  /* Letters that have a value, on screen only: eight inks, every one at least 4.5:1 on any section's maths wash, ordered so
     neighbours stay apart (colour-blind ΔE 10.4, normal 17.7, light and dark), validated 18 November 2026. A section never
     uses an ink close to its own colour (lettercolours.js). Past eight in one place, the quiet slate (--letter-8). */
  --letter-0: #2750a2; --letter-1: #932b2a; --letter-2: #006a74; --letter-3: #844100; --letter-4: #8e4088; --letter-5: #007834; --letter-6: #714ca6; --letter-7: #007b5f; --letter-8: #4f5b6b;
  /* Section colours (washes, dots, the open section's tint), ordered so neighbours differ, colour-blind readers included. */
  --section-0: #e77b60; --section-1: #00b8b9; --section-2: #d0901e; --section-3: #a58bec; --section-4: #61b565; --section-5: #46a6ef; --section-6: #db78b2;

  --brand: var(--ink); --accent: var(--iris); --accent-soft: #eeebff; --on-accent: #ffffff; --link: var(--iris);
  --highlighter: var(--spark); --on-highlighter: #ffffff;
  --heading: var(--ink); --q-rule: var(--ink);
  --ring: color-mix(in srgb, var(--iris) 55%, transparent);

  --maths-tint: rgba(255, 120, 60, .085); --maths-strong: rgba(255, 120, 60, .18); --selection: rgba(255, 120, 60, .24);
  --mark: #ffe2b8;
  --tint-definition: var(--iris); --tint-theorem: var(--cobalt); --tint-example: var(--mint); --tint-note: var(--tangerine); --tint-proof: #7b776e;
  --chip-0: var(--tangerine); --chip-1: var(--iris); --chip-2: var(--mint); --chip-3: var(--sky); --chip-4: var(--rose); --chip-5: var(--olive); --chip-6: var(--clay); --chip-7: var(--cobalt);
  --plot-1: var(--iris); --plot-2: var(--tangerine); --plot-3: var(--mint); --plot-4: var(--rose); --plot-5: var(--sky);

  --tile-radius: 26px;
  --shadow: 0 1px 2px rgba(17, 17, 16, .04), 0 18px 40px -24px rgba(60, 50, 30, .22);
  --pop: 0 0 0 1px rgba(17, 17, 16, .05), 0 12px 28px -12px rgba(17, 17, 16, .2), 0 40px 80px -30px rgba(60, 50, 30, .3);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #0d0d0c; --tile: #171715; --tile-soft: #121211; --glass: rgba(28, 28, 26, .74);
    --paper: #1c1c1a; --hover: #24231f; --line: #2a2926; --line-strong: #3a3934;
    --ink: #f4f2ec; --text: #dad7cf; --dim: #9c988f; --faint: #8f8b83;
    --iris: #a094ff; --cobalt: #7f95ff; --accent-soft: #26214a; --on-accent: #111110;
    --spark: #ff8455; --spark-soft: #3a2116; --on-spark-soft: #ffc8b0;
    --letter-0: #93beff; --letter-1: #ff9e96; --letter-2: #43d5dc; --letter-3: #f6ab6b; --letter-4: #d58ecf; --letter-5: #6fc082; --letter-6: #b699eb; --letter-7: #42c3a6; --letter-8: #aab4c2; --section-0: #ea856b; --section-1: #00bdbe; --section-2: #d49838; --section-3: #ab93ed; --section-4: #6dba70; --section-5: #56acf0; --section-6: #de82b7;
    --maths-tint: rgba(255, 132, 85, .11); --maths-strong: rgba(255, 132, 85, .22); --selection: rgba(255, 132, 85, .3);
    --mark: #5a3a16; --tint-proof: #a29d92; --heading: var(--ink); --q-rule: var(--ink); --link: var(--iris); --accent: var(--iris); --heading: var(--ink); --q-rule: var(--ink); --link: var(--iris); --accent: var(--iris);
    --shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 24px 50px -28px rgba(0, 0, 0, .8);
    --pop: 0 0 0 1px rgba(255, 255, 255, .07), 0 40px 80px -24px rgba(0, 0, 0, .8);
  }
}
:root[data-theme="dark"] {
  --desk: #0d0d0c; --tile: #171715; --tile-soft: #121211; --glass: rgba(28, 28, 26, .74);
  --paper: #1c1c1a; --hover: #24231f; --line: #2a2926; --line-strong: #3a3934;
  --ink: #f4f2ec; --text: #dad7cf; --dim: #9c988f; --faint: #8f8b83;
  --iris: #a094ff; --cobalt: #7f95ff; --accent-soft: #26214a; --on-accent: #111110;
  --spark: #ff8455; --spark-soft: #3a2116; --on-spark-soft: #ffc8b0;
  --letter-0: #93beff; --letter-1: #ff9e96; --letter-2: #43d5dc; --letter-3: #f6ab6b; --letter-4: #d58ecf; --letter-5: #6fc082; --letter-6: #b699eb; --letter-7: #42c3a6; --letter-8: #aab4c2; --section-0: #ea856b; --section-1: #00bdbe; --section-2: #d49838; --section-3: #ab93ed; --section-4: #6dba70; --section-5: #56acf0; --section-6: #de82b7;
  --maths-tint: rgba(255, 132, 85, .11); --maths-strong: rgba(255, 132, 85, .22); --selection: rgba(255, 132, 85, .3);
  --mark: #5a3a16; --tint-proof: #a29d92; --heading: var(--ink); --q-rule: var(--ink); --link: var(--iris); --accent: var(--iris);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 24px 50px -28px rgba(0, 0, 0, .8);
  --pop: 0 0 0 1px rgba(255, 255, 255, .07), 0 40px 80px -24px rgba(0, 0, 0, .8);
}

/* ---------- The desk and its tiles ---------- */
body { gap: 10px; padding: 10px; background: var(--desk); font-family: var(--sans); color: var(--ink); }
::selection { background: var(--selection); }
.ico { flex: none; display: block; }
#main { gap: 8px; }
#stage { gap: 10px; }
#canvas { border-radius: var(--tile-radius); background: var(--tile-soft); padding: 30px 26px 56px; }
#outline,#notes,#references { border: 0; border-radius: var(--tile-radius); background: var(--tile); }
#source { border-radius: var(--tile-radius); overflow: hidden; }

/* ---------- Documents tile ---------- */
#sidebar { width: 268px; gap: 10px; padding: 14px 12px 12px; background: var(--tile); border: 0; border-radius: var(--tile-radius); }
.brand { display: flex; align-items: center; padding: 6px 8px 12px; }
.wordmark { font-family: var(--display); font-size: 22px; font-weight: 650; letter-spacing: -.04em; line-height: 1.05; color: var(--ink); }

.side-action { position: relative; border: 0; }
.side-action:hover { filter: none; }
.side-action .plus { color: #fff; background: var(--spark); border-radius: 50%; }
.side-action kbd { border-color: var(--line); }
.side-link { display: flex; align-items: center; color: var(--dim); }
.side-template .ico { color: var(--tangerine); }
.side-link:hover { color: var(--ink); background: var(--hover); }

#doc-search { padding: 10px 14px 10px 38px; font-size: 13px; background: var(--desk) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='7' cy='7' r='4.6' fill='none' stroke='%23888378' stroke-width='1.6'/%3E%3Cpath d='m10.5 10.5 3 3' stroke='%23888378' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") 14px 50% / 14px no-repeat; border: 1px solid transparent; border-radius: 999px; }
#doc-search:focus { background-color: var(--paper); border-color: var(--ink); box-shadow: none; }

/* Documents are colour cards. */
#doc-list { margin-top: 2px; padding: 2px 16px 28px 2px; margin-right: -12px; border: 0; mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); }
#doc-list::before { display: block; margin: 4px 0 8px 10px; padding: 0; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); border: 0; border-radius: 0; }
.doc-row { margin: 0 0 6px; min-height: 56px; border: 0; border-radius: 18px; background: color-mix(in srgb, var(--chip, var(--chip-0)) 9%, var(--tile)); box-shadow: none; }
.doc-row::before, .doc-row.active::before { display: none; }
.doc-row:hover { background: color-mix(in srgb, var(--chip, var(--chip-0)) 16%, var(--tile)); }
.doc-open { gap: 11px; padding: 10px 40px 10px 10px; }
.doc-title { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.doc-when { margin-top: 1px; font: 11.5px var(--sans); color: var(--dim); }
.doc-chip { width: 34px; height: 34px; border-radius: 50%; font: 650 14px/1 var(--display); color: #fff; background: var(--chip, var(--chip-0)); }
.doc-row.active { background: var(--chip, var(--chip-0)); font-weight: 600; box-shadow: 0 14px 26px -18px var(--chip, var(--chip-0)); }
.doc-row.active .doc-title { color: #fff; }
.doc-row.active .doc-when { color: rgba(255, 255, 255, .78); }
.doc-row.active .doc-chip { color: var(--chip, var(--chip-0)); background: #fff; box-shadow: none; }
/* The open card carries a black arrow, set into a bite out of its corner. */
.doc-row.active::after { content: ""; position: absolute; right: -12px; top: 50%; margin-top: -17px; width: 34px; height: 34px; border-radius: 50%; background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8M8.5 4.5 12 8l-3.5 3.5' fill='none' stroke='%23111110' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 15px no-repeat; box-shadow: 0 0 0 5px var(--tile); pointer-events: none; }
.doc-row.active:hover::after { opacity: 0; }
.doc-delete { right: 8px; border-radius: 50%; }
.doc-row.active .doc-delete { color: rgba(255, 255, 255, .85); }
.doc-row.active .doc-delete:hover { color: #fff; background: rgba(0, 0, 0, .18); }

.side-foot { gap: 2px; padding-top: 8px; border-top: 0; }
.side-note { padding: 2px 12px; font: 11px var(--sans); letter-spacing: 0; text-transform: none; color: var(--faint); }

/* ---------- Top: title on the desk, controls in a floating glass pill ---------- */
/* The topbar sits above the page so its menus are never painted underneath it. */
#topbar { position: relative; z-index: 30; height: 48px; gap: 10px; padding: 0 2px 0 4px; background: transparent; border: 0; }
#crumb { min-width: 60px; font-family: var(--display); font-size: 17px; font-weight: 650; letter-spacing: -.025em; color: var(--ink); }
.save-wrap { flex: none; display: inline-flex; align-items: center; gap: 6px; color: var(--mint); }
.save-wrap:has(#save-state:empty) { display: none; }
.save-curve path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.save-wrap:has(#save-state.saving) .save-curve path, .save-wrap:has(#save-state.working) .save-curve path { stroke-dashoffset: 1; }
.save-wrap:has(#save-state.saving), .save-wrap:has(#save-state.working) { color: var(--tangerine); }
.save-wrap:has(#save-state.bad) { color: var(--rose); }
#save-state { font: 500 12px var(--sans); letter-spacing: 0; text-transform: none; color: var(--dim); }
#save-state.bad { color: var(--rose); }

.top-actions { gap: 2px; padding: 4px; background: var(--glass); border-radius: 999px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 6%, transparent), 0 10px 26px -16px rgba(40, 30, 10, .35); backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%); }
.top-actions > button, .menu-wrap > button { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; font-size: 13px; font-weight: 550; color: var(--text); border-radius: 999px; }
.top-actions > button::after, .menu-wrap > button::after { display: none; }
.top-actions .ico, .menu-wrap .ico { color: var(--dim); transition: color var(--motion), transform .35s var(--spring); }
.top-actions > button:hover, .menu-wrap > button:hover, .menu-wrap > button[aria-expanded="true"] { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
/* An open panel's button is a raised white chip inside the glass, like a segmented control. */
.top-actions button[aria-pressed="true"] { color: var(--ink); background: var(--paper); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 6%, transparent), 0 2px 6px -2px rgba(40, 30, 10, .22); }
.top-actions button[aria-pressed="true"] .ico { color: var(--spark); }
.top-gap { width: 1px; height: 18px; margin: 0 4px; background: color-mix(in srgb, var(--ink) 12%, transparent); }
#more { width: 36px; padding: 0; justify-content: center; }
#toggle-side { width: 38px; height: 38px; padding: 0; border-radius: 50%; color: var(--ink); background: var(--tile); }
#toggle-side:hover { background: var(--paper); }

/* ---------- Menus ---------- */
.menu { top: calc(100% + 10px); min-width: 300px; padding: 8px; border: 0; border-radius: 22px; background: var(--paper); box-shadow: var(--pop); }
.menu button { padding: 9px 66px 9px 14px; border-radius: 14px; font-size: 13.5px; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); color: var(--ink); }
.menu small { color: var(--dim); }
.menu hr { margin: 6px 12px; border-top-color: var(--line); }
.menu button[role="menuitemcheckbox"]::before { right: 12px; width: 32px; height: 20px; margin-top: -10px; border-radius: 999px; }
.menu button[role="menuitemcheckbox"]::after { right: 28px; width: 14px; height: 14px; margin-top: -7px; transition: background var(--motion), transform .35s var(--spring); }
.menu button[role="menuitemcheckbox"][aria-checked="true"]::before { background: var(--spark); }
.menu button[role="menuitemcheckbox"][aria-checked="true"]::after { background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }

/* ---------- Formatting tools, in their own pill ---------- */
#toolbar { min-height: 46px; align-items: center; padding: 5px 8px; background: var(--tile); border: 0; border-radius: 999px; }
#tools-main { gap: 3px; }
.tool { height: 34px; min-width: 34px; padding: 0 10px; font-size: 13px; color: var(--text); border-radius: 999px; }
.tool:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.tool.on { background: var(--spark-soft); color: var(--on-spark-soft); }
/* Insert leads the toolbar: the one way in to everything, with its keys beside it. */
.tool.is-insert { gap: 8px; padding: 0 8px 0 12px; font-weight: 600; color: var(--ink); background: var(--hover); }
.tool.is-insert:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.tool.is-insert .tool-kbd { font-weight: 550; }
/* Narrow toolbars drop key labels, but Insert keeps its: it is the one key worth learning from the toolbar. */
#tools-main .tool.is-insert .tool-kbd:not([hidden]) { display: inline-block; }
/* The maths buttons are ordinary buttons: // and $$ are the real way in, so the buttons stay quiet and show what to type. */
.tool.is-primary { color: var(--text); font-weight: 550; background: transparent; padding: 0 10px; }
.tool.is-primary + .tool.is-primary { margin-left: 2px; }
.tool.is-primary:hover:not(:disabled) { color: var(--ink); background: var(--hover); }
.tool-kbd { color: var(--dim); background: transparent; box-shadow: inset 0 0 0 1px var(--line); border-radius: 999px; font-family: var(--sans); font-weight: 650; padding: 2px 6px; }
.tool.is-italic { font-family: var(--sans); }
.tool-gap { height: 18px; margin: 0 6px; background: var(--line-strong); }
.tool-label { height: 26px; padding: 0 11px; font-size: 11.5px; font-weight: 650; letter-spacing: 0; text-transform: none; color: var(--on-spark-soft); background: var(--spark-soft); border-radius: 999px; }
.tool-select { height: 34px; padding: 0 10px; border-radius: 999px; }
.tool-select:hover { background: var(--hover); }

/* ---------- Status line ---------- */
#statusbar { min-height: 22px; padding: 0 8px; font: 11.5px var(--sans); letter-spacing: 0; text-transform: none; color: var(--dim); background: transparent; border: 0; }
kbd { font-family: var(--sans); border-radius: 6px; }
#word-count { padding: 2px 10px; color: var(--text); background: var(--tile); border-radius: 999px; font-variant-numeric: tabular-nums; }
#word-count:empty { display: none; }
#sidebar,#canvas,#outline,#notes,#references,#doc-list,.menu,#command-list { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 18%, transparent) transparent; }

/* ---------- The page ---------- */
#page { border: 0; border-radius: 22px; box-shadow: var(--shadow); }
#page::before, #page::after { content: none; }
#editor .ProseMirror { caret-color: var(--ink); }
:root[data-page-font="plain"] #page { --page-font-size: 16.5px; line-height: 1.66; letter-spacing: -.003em; }
:root[data-page-font="plain"] #title { font-family: var(--display); font-weight: 650; letter-spacing: -.04em; line-height: 1.08; }
:root[data-page-font="plain"] #editor h1, :root[data-page-font="plain"] #editor h2 { font-family: var(--display); font-weight: 650; letter-spacing: -.025em; }
:root[data-page-font="plain"] #editor h3 { font-weight: 650; letter-spacing: -.01em; }
.q-num, #editor .ProseMirror > ol.q-level-1 > li::marker { color: var(--iris); font-weight: 700; }
#editor .ProseMirror > .question-start { background: linear-gradient(90deg, var(--ink) 0 26px, transparent 26px 32px, var(--line-strong) 32px) top left / 100% 1px no-repeat border-box; }
.callout { padding: 34px 18px 12px; border-left: 0; border-radius: 18px; background: color-mix(in srgb, var(--tint) 9%, var(--paper)); }
.callout[data-callout] { border-left: 0; }
.callout::before, .callout[data-callout]::before { top: 10px; left: 12px; padding: 3px 10px; font-size: 11px; font-weight: 650; letter-spacing: 0; color: #fff; background: var(--tint); border-radius: 999px; }
:root[data-theme="dark"] .callout::before { color: #111110; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .callout::before { color: #111110; } }
#editor th { background: var(--tile-soft); }
#editor mark { border-radius: 4px; }
#line-numbers span { font-family: var(--sans); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.outline-row.is-here, .outline-item.is-here { background: var(--hover); }
.outline-row.is-here, .outline-item.is-here .outline-row { color: var(--ink); }
#popup, .symbols { border-radius: 20px; }
.commands-box { border-radius: 20px; }
#modal { background: color-mix(in srgb, var(--ink) 24%, transparent); backdrop-filter: blur(8px); }
#modal-box { border-radius: 28px; }
.command-hint { background: var(--paper); }
#toast { left: auto; right: 24px; bottom: 24px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; min-width: 300px; max-width: min(430px, calc(100vw - 32px)); padding: 12px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); box-shadow: var(--pop); border-radius: 16px; font-weight: 500; transform: translateY(3px) scale(.985); transition: opacity var(--motion-enter) var(--motion-ease), transform var(--motion-enter) var(--motion-ease); }
#toast.show { transform: none; }
#toast::before { content: none; }
.toast-icon { width: 30px; height: 30px; display: grid; place-items: center; color: var(--on-spark-soft); background: var(--spark-soft); border-radius: 50%; }
.toast-message { min-width: 0; line-height: 1.45; }
#toast .toast-action { padding: 6px 10px; color: var(--on-spark-soft); background: var(--spark-soft); border-radius: 8px; font-weight: 650; text-decoration: none; white-space: nowrap; }
#toast .toast-action:hover { background: color-mix(in srgb, var(--spark) 24%, var(--paper)); }
#toast .toast-dismiss { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; color: var(--dim); border-radius: 8px; font-size: 18px; font-weight: 400; text-decoration: none; }
#toast .toast-dismiss:hover { color: var(--ink); background: var(--hover); }
@media (max-width: 760px) { #toast { left: 12px; right: 12px; bottom: 16px; min-width: 0; max-width: none; } }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
.copied-badge { border-radius: 999px; padding: 3px 10px; }

/* In the dark the open card's arrow takes the page colour, with a light arrow. */
:root[data-theme="dark"] .doc-row.active::after { background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8M8.5 4.5 12 8l-3.5 3.5' fill='none' stroke='%23f4f2ec' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 15px no-repeat; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .doc-row.active::after { background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8M8.5 4.5 12 8l-3.5 3.5' fill='none' stroke='%23f4f2ec' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 15px no-repeat; } }

/* ---------- Drop-down lists (Insert, the / list, line-up, symbols): the same plain panel as the command box ---------- */
#popup, .symbols { padding: 6px; background: var(--paper); border: 0; border-radius: 16px; box-shadow: var(--pop); }
.pop-item { min-height: 36px; padding: 6px 10px; gap: 10px; font-size: 14px; color: var(--text); border-radius: 9px; }
.pop-item:hover { background: color-mix(in srgb, var(--hover) 55%, transparent); }
.pop-item.selected { color: var(--ink); background: var(--hover); }
.pop-item.selected .pop-name { font-weight: 600; }
.pop-group, .pop-item.selected .pop-group { color: var(--faint); font-size: 12.5px; }
.pop-item.selected .pop-shortcut { color: var(--dim); border-color: var(--line); background: transparent; }
.pop-query { padding: 4px 10px 6px; font: 600 12.5px var(--sans); color: var(--spark); }
.pop-empty { padding: 8px 10px; }
#toolbar > .tool-symbols { box-shadow: none; }
.outline-title { display: inline-flex; align-items: center; gap: 6px; }
.notes-count, #references .notes-count { margin: 0; padding: 1px 8px; font: 650 11px/1.5 var(--sans); color: var(--on-spark-soft); background: var(--spark-soft); border-radius: 999px; }
.outline-row, .outline-item { border-radius: 10px; }
.outline-row:hover, .outline-item:hover { background: var(--hover); }
.outline-row.is-here, .outline-item.is-here { background: var(--paper); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 6%, transparent), 0 2px 6px -3px rgba(40, 30, 10, .2); }
.outline-row.is-here, .outline-item.is-here .outline-row { color: var(--ink); }
.outline-empty, .refs-note { color: var(--dim); font-size: 13px; line-height: 1.5; }
.outline-picker { padding: 12px; background: var(--paper); border: 0; border-radius: 16px; box-shadow: 0 0 0 1px var(--line); }
.outline-add, .outline-cancel { padding: 6px 14px; border: 0; border-radius: 999px; }
.outline-rename, .note-edit { border-radius: 10px; }
.note-card.is-active, .note-card:focus-visible { box-shadow: 0 0 0 2px var(--note-line); }
.note-when { display: inline-flex; align-items: center; gap: 6px; }
.note-when::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--note-line); }
.note-quote { border-radius: 0; }
.refs-body { gap: 18px; padding: 0 2px 14px; }
.refs-summary { box-shadow: none; }
.refs-summary.is-warn { box-shadow: none; }
.refs-summary.is-good { box-shadow: none; }
.refs-card, .refs-typed { padding: 12px 14px; background: var(--paper); border: 0; border-radius: 16px; box-shadow: 0 0 0 1px var(--line); }
.refs-card:hover, .refs-card:focus-visible { border: 0; box-shadow: 0 0 0 1px var(--line-strong), 0 6px 16px -10px rgba(40, 30, 10, .3); }
.refs-card.has-gaps { box-shadow: 0 0 0 1px color-mix(in srgb, var(--tangerine) 45%, var(--line)); }
.refs-chip { padding: 2px 9px; border-radius: 999px; }
.refs-button, .source-button { padding: 6px 14px; font-size: 12.5px; font-weight: 550; color: var(--ink); background: var(--hover); border-radius: 999px; }
.refs-button:hover, .source-button:hover { background: var(--line); }
.refs-button.is-primary, .source-button.is-primary { color: #fff; background: var(--spark); }
.refs-button.is-primary:hover, .source-button.is-primary:hover { filter: none; background: color-mix(in srgb, var(--spark) 88%, #000); }
.refs-button.is-quiet { color: var(--on-spark-soft); background: none; }
.refs-wide { font-size: 13.5px; }
.source-form input, .source-form select { padding: 8px 12px; background: var(--tile-soft); border: 1px solid transparent; border-radius: 12px; }
.source-form input:focus { background: var(--paper); border-color: var(--line-strong); }
.source-row { border-radius: 14px; }
.source-preview { border-radius: 12px; }

/* ---------- Motion: Figma-inspired fades and pops, kept deliberately quiet ---------- */
:root { --motion-fast: 120ms; --motion-enter: 150ms; --motion-ease: cubic-bezier(.2, .75, .25, 1); }
@media (prefers-reduced-motion: no-preference) {
  @keyframes oi-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
  @keyframes oi-fade { from { opacity: 0; } to { opacity: 1; } }
  @keyframes oi-enter { from { opacity: 0; transform: translateY(3px) scale(.985); } to { opacity: 1; transform: none; } }
  @keyframes oi-panel { from { opacity: 0; transform: translateX(3px); } to { opacity: 1; transform: none; } }
  @keyframes oi-pop { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

  /* One quiet arrival, never replayed when documents redraw. */
  #sidebar, .top-actions { animation: oi-enter 160ms var(--motion-ease) both; }
  .save-curve path { transition: stroke-dashoffset .7s var(--ease); }
  .save-wrap:has(#save-state.saving) .save-curve path { transition-duration: .01s; }

  .side-action, .tool, .top-actions > button, .menu-wrap > button, #toggle-side, .side-link { transition: background var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast); }
  .doc-row { transition: background var(--motion-fast); }
  .side-action:active, .tool:active:not(:disabled), .top-actions > button:active, .menu-wrap > button:active, #toggle-side:active, .side-link:active { transform: scale(.98); }
  .top-actions button[aria-pressed="true"] .ico { animation: oi-pop var(--motion-fast) var(--motion-ease); }
  .top-actions .ico, .menu-wrap .ico { transition: color var(--motion-fast); }

  .menu:not([hidden]),#popup:not([hidden]),.symbols:not([hidden]),.rename-box:not([hidden]),.name-tip:not([hidden]) { animation: oi-enter 140ms var(--motion-ease); transform-origin: top left; }
  .menu { transform-origin: top right; }
  #commands:not([hidden]), #modal:not([hidden]) { animation: oi-fade var(--motion-fast) var(--motion-ease); }
  #commands:not([hidden]) .commands-box, #modal:not([hidden]) #modal-box { animation: oi-enter var(--motion-enter) var(--motion-ease); }
  #tools:not([hidden]) { animation: oi-panel var(--motion-enter) var(--motion-ease); }
  #tools .tool-view:not([hidden]) { animation: oi-fade var(--motion-fast) var(--motion-ease); }
  .command-item, .tool-tab, .tool-tab svg { transition: background var(--motion-fast) var(--motion-ease), color var(--motion-fast) var(--motion-ease), box-shadow var(--motion-fast) var(--motion-ease); }
  #outline .outline-caret { transition: transform var(--motion-fast) var(--motion-ease); }
}

/* ---------- Below 1180px the window controls show icons only; each keeps its name as a tip and for screen readers ---------- */
@media (max-width: 1180px) {
  .top-actions > button, .menu-wrap > button { width: 36px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
}

/* ---------- Narrower windows give the page the room back ---------- */
@media (max-width: 960px) {
  body { gap: 8px; padding: 8px; }
  #sidebar { width: 236px; }
  #canvas { padding: 12px 8px 24px; }
}

/* ---------- Medium screens: side panels sit beside the page as tiles (see studio.css) ---------- */

/* ---------- Narrow screens: the page takes the whole width ---------- */
@media (max-width: 760px) {
  body { padding: 0; gap: 0; }
  #main { gap: 0; }
  /* The documents panel slides in from the side here, so it must not use the arrival animation, which would hold it open. */
  #sidebar { width: 280px; border-radius: 0 var(--tile-radius) var(--tile-radius) 0; animation: none; }
  #topbar { z-index: 12; padding: 6px 8px 4px; height: 56px; }
  .save-wrap { display: none; }
  .top-actions > button, .menu-wrap > button { padding: 0 10px; font-size: 0; gap: 0; }
  #toolbar { margin: 0 8px 8px; }
  #canvas { border-radius: 0; padding: 0; }
  #page { border-radius: 0; }
  /* Every control is big enough for a finger: 44 points each way. */
  #topbar button, #toolbar .tool, #toolbar .tool-select { min-width: 44px; min-height: 44px; }
  #toolbar .tool-select { padding-inline: 10px; }
}

/* ---------- Side panels, redesigned (17 November 2026) ----------
   One look for Sections, Values, Notes and References: a clear title with a close ×, quiet small-caps labels, flat
   rows separated by hairlines instead of boxes inside boxes, plain text buttons with one main action, and proper
   fields. Owner: "hate the styling of all sidebar stuff". */
#outline,#notes,#references { background: var(--paper); }
.outline-scroll { padding: 16px 16px 24px; }
.outline-head { position: sticky; top: -16px; z-index: 2; display: flex; align-items: center; gap: 8px; margin: -16px -16px 12px; padding: 16px 16px 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
.outline-title { flex: 1; min-width: 0; padding: 0; font: 650 16px/1.25 var(--display); letter-spacing: -.015em; color: var(--ink); }
.outline-title .notes-count { margin-left: 4px; padding: 0; font: 500 13px/1 var(--ui-font); color: var(--dim); background: none; }
.panel-close { flex: none; width: 28px; height: 28px; display: grid; place-items: center; font-size: 18px; line-height: 1; color: var(--dim); border-radius: 8px; }
.panel-close:hover { color: var(--ink); background: var(--hover); }
.outline-find, .refs-style { padding: 5px 10px; font-size: 12.5px; font-weight: 550; color: var(--ink); background: none; border: 1px solid var(--line); border-radius: 8px; }
.outline-find:hover, .refs-style:hover { color: var(--ink); background: var(--hover); }
/* Labels for parts of a panel. */
.refs-heading, .values-label { margin: 18px 0 6px; padding: 0 4px; font: 600 11px/1.3 var(--ui-font); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
/* Rows, not cards. */
.outline-row, .outline-item { border-radius: 8px; }
.outline-row { padding: 7px 8px; font-size: 13.5px; }
.outline-row.is-here, .outline-item.is-here { background: var(--hover); box-shadow: none; }
.note-card, .refs-card, .refs-typed { padding: 10px 8px; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.note-card:hover, .refs-card:hover, .refs-card:focus-visible { background: var(--hover); box-shadow: none; border-radius: 8px; border-bottom-color: transparent; }
.note-card.is-active, .note-card:focus-visible { background: var(--hover); box-shadow: inset 3px 0 0 var(--note-line); border-radius: 8px; }
.refs-summary, .refs-summary.is-warn, .refs-summary.is-good { padding: 0 4px; background: none; border-radius: 0; color: var(--dim); font-size: 13px; }
.outline-empty, .refs-note { padding: 0 4px; }
/* Buttons: quiet words, with one main action in the accent colour. */
.refs-button,.source-button,.note-button,.outline-cancel { padding: 6px 10px; font-size: 13px; font-weight: 550; color: var(--ink); background: none; border: 0; border-radius: 8px; }
.refs-button:hover,.source-button:hover,.note-button:hover,.outline-cancel:hover { background: var(--hover); }
.refs-button.is-primary, .source-button.is-primary, .outline-add { color: #fff; background: var(--spark); border-radius: 10px; }
.refs-button.is-primary:hover, .source-button.is-primary:hover, .outline-add:hover { background: color-mix(in srgb, var(--spark) 88%, #000); }
/* Fields. */
.outline-rename,.note-edit,.refs-bibtex-input,#references input:not([type=checkbox]),#references textarea { min-height: 34px; padding: 7px 10px; font: inherit; font-size: 13.5px; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: 10px; outline: 0; }
.outline-rename:focus,.note-edit:focus,#references input:focus,#references textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 8%, transparent); }

/* References: the style menu sits quietly after the title; BibTeX buttons sit in a row on the left. */
#references .outline-title { flex: 1 1 auto; }
#references .refs-style { flex: none; max-width: 110px; padding: 4px 8px; font-size: 12px; }
.refs-section .refs-meta { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 4px; margin-left: -10px; }
.refs-section .refs-meta .refs-button { margin: 0; }
.refs-bibtex-paste summary { color: var(--ink); font-size: 13px; font-weight: 550; }
.refs-wide { width: 100%; margin-top: 18px; padding: 9px 14px; }

/* ---------- The tool panel ---------- */
#tools { border-radius: var(--tile-radius); background: var(--paper); box-shadow: var(--shadow); }
.tool-tabs { display: flex; align-items: center; gap: 3px; margin: 10px 10px 0; padding: 4px; background: var(--hover); border: 1px solid var(--line); border-radius: 13px; }
.tool-tab { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; margin: 0; padding: 7px 10px; font: 600 12.5px/1 var(--ui-font); color: var(--dim); border: 0; border-radius: 9px; }
.tool-tab:hover { color: var(--ink); background: color-mix(in srgb, var(--paper) 60%, transparent); }
.tool-tab[aria-selected="true"] { color: var(--ink); background: var(--paper); box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 12%, transparent), 0 0 0 1px color-mix(in srgb, var(--ink) 5%, transparent); }
.tool-tab svg { width: 15px; height: 15px; flex: none; }
/* Only the open tool shows its name; the others are icons with their name on hover, so four always fit. */
.tool-tab:not([aria-selected="true"]) span { display: none; }
.tool-tab:not([aria-selected="true"]) { padding-inline: 10px; }
.tool-tab[aria-selected="true"] svg { color: var(--spark); }
.tools-close { margin: 0 0 0 auto; }
/* Inside the tool panel the tab says what this is: the panels' own titles and close buttons step aside. */
#tools .outline-title, #tools .outline-head .panel-close { display: none; }
#tools #notes .outline-head { display: none; }
#tools .outline-head { position: static; margin: 0 0 10px; padding: 0; border: 0; justify-content: flex-end; background: none; }
#tools .outline-scroll { padding: 14px 14px 28px; }

/* ---------- Values ---------- */

/* ---------- Values as a tool (17 November 2026, late) ----------
   Owner: "doesnt feel like a tool panel. feels lame". Values follows the cursor: where you are, then a card per letter
   with a box to type in and a slider to drag, the answers kept here, and the other sections folded to one line. */
.values-label { margin: 22px 0 8px; padding: 0 2px; font: 600 11px/1.3 var(--ui-font); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }

/* ---------- Sections as a navigator ---------- */
#outline .outline-list { display: flex; flex-direction: column; }
#outline .outline-section { position: relative; }
#outline .outline-section:has(.is-here) { background: color-mix(in srgb, var(--spark) 7%, var(--paper)); }
#outline .outline-section:has(.is-here)::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--spark); }
#outline .outline-row { align-items: center; gap: 8px; padding: 8px 10px; font-size: 13.5px; font-weight: 550; color: var(--ink); background: none; }
#outline .outline-row:hover { background: var(--hover); }
#outline .outline-row.is-here { background: none; }
#outline .outline-row.is-heading.level-1 { font: 650 14.5px/1.3 var(--display); }
.outline-badge { flex: none; min-width: 28px; padding: 3px 7px; font: 650 11.5px/1.2 var(--ui-font); text-align: center; color: var(--on-spark-soft); background: var(--spark-soft); border-radius: 7px; }
#outline .outline-row .outline-text { min-width: 0; text-overflow: ellipsis; color: var(--ink); }
#outline .outline-row.is-equation, #outline .outline-row.is-caption { font-weight: 450; color: var(--text); padding-left: 46px; }

/* ---------- Sections on the page and in the panel ----------
   Each section has one colour; the section you are in is tinted on the page in it, with a bar down its left edge, and
   its row in the panel wears the same colour. */
.section-band { position: absolute; z-index: 0; pointer-events: none; transition: top var(--motion), height var(--motion), background var(--motion); }
.section-band[hidden] { display: none; }
#editor { position: relative; z-index: 1; }
@media print { .section-band { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .section-band { transition: none; } }
#outline .outline-section { --section-colour: var(--line-strong); border-left: 3px solid color-mix(in srgb, var(--section-colour) 55%, transparent); }
#outline .outline-section.is-current { padding-bottom: 10px; background: color-mix(in srgb, var(--section-colour) 7%, var(--paper)); border-left-color: var(--section-colour); }
#outline .outline-section:has(.is-here)::before, #outline .outline-section.is-current::before { display: none; }

/* ---------- Print: only the page ---------- */
@media print {
  body { padding: 0; background: #fff; }
  #canvas { background: none; border-radius: 0; }
  #page { border: 0; border-radius: 0; box-shadow: none; }
  .callout { border: 1px solid color-mix(in srgb, var(--tint) 40%, #fff); }
}
/* Line numbers stay above a section's tint. Cards keep room for the number: no = sign, the use count under the slider. */
#line-numbers { z-index: 2; }
:root[data-maths-wash="off"] .math-inline, :root[data-maths-wash="off"] .math-block { --maths-rest: transparent !important; }
#outline .outline-section { border-radius: 14px; transition: background var(--motion); }
#outline .outline-section::before { display: none !important; }
#outline .outline-section .outline-badge { font-size: 11px; }
#outline .outline-section .outline-text { color: var(--ink); }
#outline .is-whole-document { --section-colour: #8a8578; }
#outline .outline-head { margin-bottom: 8px; }
#outline .outline-find { font-size: 12px; font-weight: 550; }
/* Equations and captions listed under their section stay quiet. */
#outline .outline-row.is-equation, #outline .outline-row.is-caption { padding-left: 30px; font-size: 12.5px; color: var(--dim); }

/* ---------- The Navigator as a tree (18 November 2026, evening) ----------
   Sections nest as the page does. Each line: a fold arrow when it holds sections, the row (colour dot, badge, title),
   and on hover a + and a grip. Sections inside hang from a thin guide in the parent's colour. */
#outline .outline-line { position: relative; display: flex; gap: 0; }
#outline .outline-caret { flex: none; margin: 0; padding: 0; border: 0; background: none; color: var(--faint); text-align: center; border-radius: 8px; cursor: pointer; transform: rotate(90deg); transition: transform var(--motion), color var(--motion); }
#outline .outline-caret[aria-expanded="false"] { transform: none; }
#outline .outline-caret:hover:not(:disabled) { color: var(--ink); background: var(--hover); }
#outline .outline-caret:disabled, #outline span.outline-caret { cursor: default; }
#outline .outline-line > .outline-row { position: relative; flex: 1; min-width: 0; display: flex; background: none; border-radius: 12px; text-align: left; }
#outline .outline-line > .outline-row::before { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--section-colour); box-shadow: 0 0 0 3px color-mix(in srgb, var(--section-colour) 18%, transparent); }
#outline .outline-line > .outline-row:hover { background: none; }
#outline .outline-line > .outline-row:focus-visible { outline: 2px solid color-mix(in srgb, var(--section-colour) 70%, var(--ink)); outline-offset: 1px; }
#outline .outline-line > .outline-item { flex: 1; min-width: 0; }
#outline .outline-actions-row { flex: none; display: flex; align-items: center; gap: 2px; padding: 5px 6px 0 0; opacity: 0; transition: opacity var(--motion); }
#outline .outline-line:hover .outline-actions-row, #outline .outline-line:focus-within .outline-actions-row { opacity: 1; }
#outline .outline-act { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 7px; background: none; color: var(--dim); font: 600 15px/1 var(--ui-font); cursor: pointer; }
#outline .outline-act:hover { color: var(--ink); background: color-mix(in srgb, var(--section-colour) 16%, var(--paper)); }
#outline .outline-move { font-size: 11px; letter-spacing: -2px; cursor: grab; touch-action: none; }
#outline .outline-move:active { cursor: grabbing; }
#outline .outline-section.is-open > .outline-extras { margin-left: 12px; }
#outline .outline-section.is-open:hover { background: color-mix(in srgb, var(--section-colour) 9%, var(--paper)); }
#outline .outline-line:hover { border-radius: 12px; }
/* Sections inside hang from a guide in the parent's colour. */
#outline .outline-children { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); }
#outline .outline-section { min-width: 0; }
#outline .outline-children::before { content: ""; position: absolute; border-radius: 2px; }
/* The section your cursor is in: a small ring round its dot, nothing opens. */
#outline .outline-section.is-cursor > .outline-line > .outline-row::before { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--section-colour); }
#outline .outline-section.is-cursor > .outline-line > .outline-row::after { content: "here"; margin-left: auto; padding: 1px 6px; font: 600 10px/1.5 var(--ui-font); letter-spacing: .02em; color: color-mix(in srgb, var(--section-colour) 70%, var(--ink)); background: color-mix(in srgb, var(--section-colour) 14%, var(--paper)); border-radius: 6px; }
/* Renaming in place. */
#outline .outline-rename { flex: 1; min-width: 0; margin: 4px 6px 2px 2px; padding: 5px 9px; font: 600 13.5px/1.35 var(--ui-font); color: var(--ink); background: var(--paper); border: 1px solid var(--section-colour); border-radius: 9px; outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--section-colour) 20%, transparent); }
/* Dragging: the section being moved fades, and a line shows where it will land (indented when it goes inside). */
#outline .outline-list { position: relative; }
#outline .outline-drop { position: absolute; z-index: 3; border-radius: 3px; background: var(--spark); box-shadow: 0 0 0 2px var(--paper); pointer-events: none; }
#outline .outline-drop::before { content: ""; position: absolute; left: -4px; top: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--spark); }
#outline .outline-extras { display: grid; gap: 1px; }
#outline .outline-extras .outline-row { padding-left: 8px; }
#outline .outline-empty { padding: 12px; font-size: 12.5px; color: var(--dim); }
#outline .is-whole-document .outline-line > .outline-row::before { border-radius: 3px; }
@media (prefers-reduced-motion: reduce) { #outline .outline-section, #outline .outline-caret, #outline .outline-actions-row { transition: none; } }
/* The line being read (scrolling) is shown on its own row only; parents are never tinted for it. */
#outline .outline-section:not(.is-open):has(.is-here) { background: none; }
#outline .outline-line > .outline-row.is-here { background: none; box-shadow: none; }
#outline .outline-line > .outline-row.is-here .outline-text { text-underline-offset: 4px; }

/* ---------- Letters and sections on the page (18 November 2026, night) ----------
   Owner: "the variables do NOT have different colours. the colour backdrop washes everything out. should just be a
   border outline." Every letter wears its own colour as a soft chip (a firmer chip with a ring once it has a value
   here); maths in a section is outlined in the section's colour with no fill; the open section is outlined on the
   page. Nothing prints. */
.mathnormal.has-letter { color: var(--letter); background: color-mix(in srgb, var(--letter) 15%, transparent); padding: 0 .06em; margin: 0 .04em; border-radius: .2em; }
.mathnormal.has-letter { box-decoration-break: clone; -webkit-box-decoration-break: clone; }
@media print { .mathnormal.has-letter { color: inherit !important; background: none !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; } }
.math-inline { box-shadow: inset 0 -1.5px 0 var(--maths-edge, transparent); }
.math-block > .math-main::before { box-shadow: inset 0 0 0 1px var(--maths-edge, transparent); }
:root[data-maths-wash="off"] .math-inline, :root[data-maths-wash="off"] .math-block { --maths-edge: transparent !important; }
@media print { .math-inline, .math-block > .math-main::before { box-shadow: none !important; } }
.section-band { background: none; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--section-colour) 55%, transparent); border-radius: 18px; }
#outline .outline-make { margin-right: auto; cursor: pointer; }
#outline .outline-make:focus-visible { outline: 2px solid var(--spark); outline-offset: 2px; }
#outline .outline-line > .outline-row { cursor: pointer; touch-action: pan-y; user-select: none; }
#outline.is-dragging-section, #outline.is-dragging-section * { cursor: grabbing !important; user-select: none; }
#outline .outline-more { font-size: 15px; letter-spacing: 0; }
/* The drop line: a dot and a line at the depth it will land, and a label saying where. */
#outline .outline-drop { height: 2px; transition: left 80ms ease-out, width 80ms ease-out, top 60ms ease-out; }
#outline .outline-drop-label { position: absolute; right: 0; top: -21px; padding: 2px 8px; font: 600 11px/1.5 var(--ui-font); color: #fff; background: var(--spark); border-radius: 7px; white-space: nowrap; box-shadow: 0 2px 6px -2px rgba(0, 0, 0, .3); }
#outline .outline-drop.is-same { background: var(--faint); }
#outline .outline-drop.is-same::before, #outline .outline-drop.is-same .outline-drop-label { background: var(--faint); }
#outline .outline-section.is-dragging { opacity: .35; }
/* Where a moved section landed, a brief glow. */
@keyframes outline-moved { from { background: color-mix(in srgb, var(--section-colour) 30%, transparent); } to { background: transparent; } }
#outline .outline-line.is-moved { animation: outline-moved .9s ease-out; border-radius: 12px; }
/* The section menu. */
#outline { position: relative; }
.outline-menu { position: absolute; z-index: 40; padding: 5px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px -12px rgba(30, 20, 10, .35), 0 2px 6px -3px rgba(30, 20, 10, .2); }
.outline-menu-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 7px 10px; font: 500 13px/1.3 var(--ui-font); color: var(--ink); text-align: left; background: none; border: 0; border-radius: 8px; cursor: pointer; }
.outline-menu-item:hover, .outline-menu-item:focus-visible { background: var(--hover); outline: none; }
.outline-menu-item kbd { font: 500 11px/1 var(--ui-font); color: var(--faint); background: none; border: 0; }
.outline-menu-rule { height: 1px; margin: 4px 6px; background: var(--line); }
@media (prefers-reduced-motion: reduce) { #outline .outline-line.is-moved { animation: none; } #outline .outline-drop { transition: none; } }
.outline-menu { min-width: 0; width: min(232px, calc(100% - 16px)); }
/* Letters selected in maths: one small button to join them into one name (KE), or split one. */

/* The tool panel over the right of the writing area; the page glides aside only as far as it must. */
#stage { position: relative; }
#stage.tools-float #tools { position: absolute; top: 0; right: 0; bottom: 0; z-index: 5; }
#stage.tools-float #page { left: calc(-1 * var(--page-shift, 0px)); }
@media (prefers-reduced-motion: no-preference) {
  #stage.tools-float #page { transition: left 260ms cubic-bezier(.2, .7, .2, 1); }
  #stage.tools-float #tools:not([hidden]) { animation: oi-fade var(--motion-enter) var(--motion-ease); }
}
/* The open document's card in dark mode: the bright chip colours are deepened so its white text reads. */
:root[data-theme="dark"] .doc-row.active { background: color-mix(in srgb, var(--chip, var(--chip-0)) 62%, #000); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .doc-row.active { background: color-mix(in srgb, var(--chip, var(--chip-0)) 62%, #000); } }

/* ---------- Weight follows use (24 November 2026) ----------
   Owner: "New Doc is the largest button but the least important." The sidebar is for finding and switching documents,
   so the document cards keep the weight; New document and Start from a template are two quiet rows of the same size
   above them, the + still in its orange disc. In the toolbar Insert is the one filled button and Symbols is a plain
   word. In the top bar Tools and Download keep their names; the LaTeX view, used least, shows its icon and keeps its
   name as a tip and for screen readers. Keys a phone cannot press are not shown on one. Every button, key and command
   is unchanged. */
.brand { padding-bottom: 8px; }
.side-action, .side-link { min-height: 36px; gap: 10px; padding: 0 12px 0 8px; font-size: 13.5px; border-radius: 12px; }
.side-action { font-weight: 600; color: var(--ink); background: none; box-shadow: none; }
.side-action:hover { background: var(--hover); box-shadow: none; }
.side-action .plus { width: 20px; height: 20px; padding: 4px; }
.side-action kbd { margin-left: auto; min-width: 0; padding: 0; font: 500 11.5px/1 var(--sans); letter-spacing: .03em; color: var(--faint); background: none; border: 0; }
.side-action:hover kbd, .side-action:focus-visible kbd { color: var(--dim); }
/* Icons sit in the same 20px column as the +, so the words line up. */
.side-link .ico { width: 20px; height: 15px; }
.side-link { font-weight: 500; }
/* The two ways to start a document read as one small group. */
#new-doc + .side-template { margin-top: -8px; }
#toolbar > .tool-symbols { color: var(--text); background: none; }
#toolbar > .tool-symbols:hover { color: var(--ink); background: var(--hover); }
#toggle-latex { width: 36px; padding: 0; justify-content: center; gap: 0; font-size: 0; }
@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  .side-action kbd, #tools-main .tool.is-insert .tool-kbd:not([hidden]) { display: none; }
  #tools-main .tool.is-insert { padding: 0 14px; }
}
/* In the slide-out documents panel on a phone, every row is big enough for a finger. */
@media (max-width: 760px) { .side-action, .side-link { min-height: 44px; } }

/* ---------- Folder saving on the website ---------- */
#folder-controls { display: grid; gap: 6px; padding: 4px 4px 2px; }
#folder-controls[hidden], #folder-first-run[hidden] { display: none; }
#folder-first-run { position: relative; display: grid; gap: 7px; padding: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
#folder-first-run > p { margin: 0; padding-right: 20px; font: 12px/1.45 var(--sans); color: var(--dim); }
#choose-folder { min-height: 36px; padding: 8px 10px; font: 600 12.5px/1.3 var(--sans); color: var(--on-spark-soft); text-align: left; background: var(--spark-soft); border-radius: 9px; }
#choose-folder:hover { background: color-mix(in srgb, var(--spark) 24%, var(--paper)); }
#dismiss-folder { position: absolute; top: 5px; right: 5px; width: 28px; height: 28px; padding: 0; overflow: hidden; color: var(--dim); font-size: 0; border-radius: 8px; }
#dismiss-folder::after { content: "×"; font-size: 18px; }
#dismiss-folder:hover { color: var(--ink); background: var(--hover); }
#reconnect-folder { min-height: 34px; padding: 6px 10px; font: 550 12.5px/1.3 var(--sans); color: var(--text); text-align: left; background: var(--hover); border-radius: 9px; }
#folder-status, #folder-note { margin: 0; padding: 0 8px; font: 11.5px/1.45 var(--sans); }
#folder-status { color: var(--text); }
#folder-note { color: var(--dim); }
#folder-status:empty, #folder-note:empty { display: none; }
#title[contenteditable="false"] { opacity: .65; }
#editor .ProseMirror[contenteditable="false"] { cursor: default; }
#folder-lock-note { margin: 0 0 18px; padding: 10px 14px; font: 500 14px/1.4 var(--sans); color: var(--dim); background: var(--tile-soft); border-radius: 12px; }
@media (max-width: 760px) { #choose-folder, #reconnect-folder, #dismiss-folder { min-height: 44px; } #dismiss-folder { width: 44px; top: 2px; right: 2px; } }
@media print { #folder-controls, #folder-lock-note { display: none !important; } }

/* Privacy choices and device-data deletion. */
.danger-menu-item { color: var(--bad); }
#modal-box.privacy { width: min(520px, 100%); }
.privacy-dialog p { margin: 10px 0; line-height: 1.55; }
.privacy-exact { font-size: 15px; color: var(--ink); }
.privacy-backup-note { color: var(--dim); font-size: 13px; }
.privacy-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.privacy-actions button { min-height: 40px; padding: 9px 15px; font: 600 13px/1.2 var(--sans); border-radius: 11px; }
.privacy-actions button:hover { background: var(--hover); }
.privacy-actions .privacy-primary { color: #111; background: var(--spark); }
.privacy-actions .privacy-primary:hover { background: color-mix(in srgb, var(--spark) 88%, var(--ink)); }
.privacy-actions .privacy-danger { color: #fff; background: var(--bad); }
.privacy-actions .privacy-danger:hover { background: color-mix(in srgb, var(--bad) 88%, var(--ink)); }
.privacy-delete-actions { justify-content: flex-start; }
.privacy-delete-actions .privacy-danger { margin-left: auto; }
@media (max-width: 760px) {
  .privacy-actions button { min-height: 44px; }
  .privacy-delete-actions .privacy-danger { margin-left: 0; }
}
@media print { .danger-menu-item { display: none !important; } }

/* The Navigator's section search (26 November 2026), in the place of the retired value box. */
.outline-search { display: block; width: calc(100% - 8px); margin: 0 4px 12px; min-height: 34px; padding: 6px 12px; font: 500 13px/1.3 var(--ui-font); color: var(--text); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; outline: 0; }
.outline-search:focus-visible { border-color: var(--spark); box-shadow: 0 0 0 3px var(--spark-soft); }

/* The calculator (26 November 2026): a tab of the tool panel. One maths box, a row of actions, answers newest first. */
#calculator { display: flex; }
.calc-scroll { flex: 1; min-width: 0; overflow-y: auto; padding: 14px 14px 28px; }
.calc-head { display: flex; align-items: center; margin-bottom: 10px; }
.calc-input { display: block; width: 100%; min-height: 44px; padding: 8px 12px; font-size: 18px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; outline: 0; --caret-color: var(--spark); --selection-background-color: var(--spark-soft); --contains-highlight-background-color: transparent; }
.calc-input:focus-within { border-color: var(--spark); box-shadow: 0 0 0 3px var(--spark-soft); }
.calc-input::part(virtual-keyboard-toggle), .calc-input::part(menu-toggle) { display: none; }
.calc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.calc-action { min-height: 32px; padding: 4px 11px; font: 550 12.5px/1 var(--ui-font); color: var(--text); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.calc-action:hover { background: var(--hover); }
.calc-action.is-main { min-width: 44px; color: #fff; background: var(--spark); border-color: var(--spark); font-size: 15px; }
.calc-action.is-main:hover { background: color-mix(in srgb, var(--spark) 88%, #000); }
.calc-action:focus-visible, .calc-insert:focus-visible, .calc-letter:focus-visible, .calc-question:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--spark-soft); }
.calc-status { min-height: 18px; margin: 6px 2px; font-size: 12.5px; line-height: 1.4; color: var(--dim); }
.calc-history { display: flex; flex-direction: column; gap: 8px; }
.calc-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; background: var(--paper); border-radius: 14px; box-shadow: 0 0 0 1px var(--line); }
.calc-question { max-width: 100%; padding: 2px 4px; margin: -2px -4px; overflow-x: auto; color: var(--dim); text-align: left; background: none; border: 0; border-radius: 6px; cursor: pointer; font-size: 13px; }
.calc-question:hover { background: var(--hover); }
.calc-answer { max-width: 100%; overflow-x: auto; font-size: 18px; color: var(--ink); }
.calc-decimal { max-width: 100%; overflow-x: auto; font-size: 14px; color: var(--dim); }
.calc-note { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--dim); }
.calc-for { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; font-size: 12px; color: var(--dim); }
.calc-letter { min-width: 28px; min-height: 26px; padding: 2px 8px; font: italic 500 13px/1 "KaTeX_Math", serif; color: var(--text); background: var(--tile); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.calc-letter.is-on { color: var(--on-spark-soft, var(--ink)); background: var(--spark-soft); border-color: var(--spark); }
.calc-insert { align-self: flex-end; min-height: 30px; padding: 4px 12px; font: 600 12px/1 var(--ui-font); color: var(--ink); background: var(--tile); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.calc-insert:hover { background: var(--hover); }
@media (max-width: 760px), (pointer: coarse) and (hover: none) { .calc-action, .calc-insert, .calc-letter { min-height: 44px; } }

/* Navigator, plain (26 November 2026). Owner on the old look: "what on earth is this monstrosity". One quiet list:
   no colour dot per row, no coloured guide lines, no word counts, no "here" pill, no loud + Section button. Rows
   are one or two lines; the open section keeps a soft tint in its colour, as its outline on the page has. */
#outline .outline-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 0 0 8px; padding: 0; }
#outline .outline-make, #outline .outline-find { margin: 0; padding: 5px 8px; font: 550 12.5px/1.2 var(--ui-font); color: var(--dim); background: none; border: 0; border-radius: 8px; box-shadow: none; white-space: nowrap; }
#outline .outline-make:hover, #outline .outline-find:hover { color: var(--ink); background: var(--hover); }
#outline .outline-search { width: 100%; margin: 0 0 10px; min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 9px; }
#outline .outline-scroll { min-width: 0; }
#outline .outline-list { gap: 0; }
#outline .outline-section, #outline .outline-section.is-open, #outline .outline-section:hover { margin: 0; padding: 0; border: 0; box-shadow: none; background: none; }
#outline .outline-section.is-open { padding-bottom: 4px; border-radius: 10px; background: color-mix(in srgb, var(--section-colour) 9%, var(--paper)); }
#outline .outline-line { align-items: flex-start; border-radius: 8px; }
#outline .outline-line:hover { background: var(--hover); }
#outline .outline-section.is-open > .outline-line:hover { background: none; }
#outline .outline-caret { width: 18px; height: 28px; line-height: 28px; font-size: 14px; }
#outline .outline-line > .outline-row, #outline .outline-line > .outline-row.is-heading.level-1 { align-items: baseline; gap: 7px; padding: 5px 6px 5px 0; font: 500 13px/1.35 var(--ui-font); color: var(--text); }
#outline .outline-line > .outline-row.is-heading { font-weight: 600; color: var(--ink); }
#outline .outline-line > .outline-row::before, #outline .outline-line > .outline-row::after { content: none !important; display: none !important; }
#outline .outline-row .outline-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
#outline .outline-row .outline-math { font-size: 1em; white-space: nowrap; }
#outline .outline-row .outline-math .katex { font-size: 1.02em; }
#outline .outline-section .outline-badge, #outline .outline-badge { flex: none; min-width: 0; padding: 0; font: 600 12px/1.35 var(--ui-font); color: var(--faint); background: none; border-radius: 0; }
#outline .outline-children { margin: 0 0 2px 8px; padding-left: 8px; gap: 0; }
#outline .outline-children::before { left: 0; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
#outline .outline-section.is-open > .outline-children { margin-top: 0; }
#outline .outline-section.is-cursor > .outline-line > .outline-row, #outline .outline-section.is-cursor > .outline-line > .outline-row .outline-badge { color: var(--spark); }
#outline .outline-line > .outline-row.is-here .outline-text { text-decoration: none; }
#outline .outline-actions-row { padding-top: 2px; }
#outline .outline-extras { padding: 2px 8px 2px 18px; }
