/* Kladde — a Collegeblock in light mode, a lecture-hall Tafel in dark mode.
   Ink blue means "you can act on this". Highlighter yellow means "this is the state right now". */

@font-face { font-family: 'Barlow SC'; font-weight: 600; font-display: swap; src: url(../fonts/barlow-semi-condensed-latin-600-normal.woff2) format('woff2'); 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: 'Barlow SC'; font-weight: 600; font-display: swap; src: url(../fonts/barlow-semi-condensed-latin-ext-600-normal.woff2) format('woff2'); 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: 'Barlow SC'; font-weight: 700; font-display: swap; src: url(../fonts/barlow-semi-condensed-latin-700-normal.woff2) format('woff2'); 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: 'Barlow SC'; font-weight: 700; font-display: swap; src: url(../fonts/barlow-semi-condensed-latin-ext-700-normal.woff2) format('woff2'); 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: 'Schibsted'; font-weight: 400; font-display: swap; src: url(../fonts/schibsted-grotesk-latin-400-normal.woff2) format('woff2'); 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: 'Schibsted'; font-weight: 400; font-display: swap; src: url(../fonts/schibsted-grotesk-latin-ext-400-normal.woff2) format('woff2'); 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: 'Schibsted'; font-weight: 400; font-style: italic; font-display: swap; src: url(../fonts/schibsted-grotesk-latin-400-italic.woff2) format('woff2'); 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: 'Schibsted'; font-weight: 400; font-style: italic; font-display: swap; src: url(../fonts/schibsted-grotesk-latin-ext-400-italic.woff2) format('woff2'); 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: 'Schibsted'; font-weight: 600; font-display: swap; src: url(../fonts/schibsted-grotesk-latin-600-normal.woff2) format('woff2'); 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: 'Schibsted'; font-weight: 600; font-display: swap; src: url(../fonts/schibsted-grotesk-latin-ext-600-normal.woff2) format('woff2'); 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: 'Atkinson Mono'; font-weight: 400; font-display: swap; src: url(../fonts/atkinson-hyperlegible-mono-latin-400-normal.woff2) format('woff2'); 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: 'Atkinson Mono'; font-weight: 400; font-display: swap; src: url(../fonts/atkinson-hyperlegible-mono-latin-ext-400-normal.woff2) format('woff2'); 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; }


/* =====================================================================
   Tokens. Everything below is built from these; nothing picks its own
   size, radius or shadow.
   ===================================================================== */
:root {
  color-scheme: light;
  --paper: #ffffff;
  --sheet: #ffffff;
  --sheet-2: #f5f7fb;
  --grid: #e3eaf3;
  --text: #17213d;
  --text-soft: #4c5673;
  --text-faint: #7a839c;
  --ink: #1d3a9e;
  --ink-press: #142b7a;
  --on-ink: #ffffff;
  --margin: #e2546b;
  --marker: #ffe94d;
  --marker-soft: #fff6b8;
  --ok: #17704a;
  --err: #b3263e;
  --line: #c8d2e1;
  --sep: #dde4ee;
  --line-soft: var(--sep);
  --surface: #f4f7fb;
  --fill: rgba(29, 58, 158, .08);
  --fill-strong: rgba(29, 58, 158, .14);
  --fill-2: rgba(76, 86, 115, .08);
  --fill-3: rgba(76, 86, 115, .16);
  --thumb: var(--marker);
  --ok-tint: rgba(23, 112, 74, .10);
  --err-tint: rgba(179, 38, 62, .08);
  --e1: 0 0 0 transparent;
  --e2: 2px 2px 0 var(--grid);
  --e3: 4px 4px 0 #d3dcea;
  --e4: 6px 6px 0 #e3eaf3, 12px 12px 0 #d3dcea;
  --material: var(--paper);
  --sweep: var(--marker);
  --backdrop: rgba(14, 22, 44, .42);
  --tab-pdf: #d4def7;
  --tab-pdf-text: #1d3a9e;
  --tab-scan: #d3eedf;
  --tab-scan-text: #145c3b;
  --tab-convert: #fbe0e5;
  --tab-convert-text: #8f1f35;
  --tab-study: #fff0a3;
  --tab-study-text: #6a5300;
  --tab-write: #e8e0fb;
  --tab-write-text: #4a2c8f;
  --shadow-sheet: 3px 3px 0 #e3eaf3, 6px 6px 0 #d3dcea;

  /* Type: one family per job, seven sizes */
  --font-display: 'Barlow SC', 'Arial Narrow', sans-serif;
  --font-body: 'Schibsted', system-ui, sans-serif;
  --font-mono: 'Atkinson Mono', ui-monospace, monospace;
  --fs-caption: .8125rem;   /* 13 badges, kbd, small print */
  --fs-footnote: .875rem;   /* 14 help text, meta lines */
  --fs-subhead: .9375rem;   /* 15 labels, secondary text, small buttons */
  --fs-body: 1.0625rem;     /* 17 reading text */
  --fs-lede: 1.1875rem;     /* 19 the line under a page title */
  --fs-title3: 1.25rem;     /* 20 card titles, list item titles */
  --fs-title2: 1.5rem;      /* 24 drop zone, section titles */
  --fs-title1: 1.875rem;    /* 30 h2 */
  --fs-large: clamp(2.25rem, 1.4rem + 3.2vw, 3.5rem);

  /* Space: a 4-point scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 48px;
  --cell: 24px;             /* grid cell; body line height sits on it */
  --margin-col: 176px;
  --content-max: 920px;
  --header-h: 64px;

  /* Shape */
  /* Boxy, like paper: sheets have sharp corners, controls barely softened */
  --r-xs: 2px;              /* badges, keys, thumbnails */
  --r-sm: 3px;              /* buttons, fields, segmented controls */
  --r-md: 2px;              /* cards and sheets of paper */
  --r-lg: 3px;              /* dialogs */
  --bw: 1.5px;              /* every control and card border; separators are 1px */
  --r-pill: 999px;
  --radius-btn: var(--r-sm); --radius-input: var(--r-sm);

  /* Motion */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in: cubic-bezier(.55, 0, 1, .45);
  --ease-spring: cubic-bezier(.34, 1.45, .64, 1);
  --t-fast: 140ms; --t-med: 240ms; --t-slow: 420ms;

  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --tick-white: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  interpolate-size: allow-keywords;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #203029;
    --sheet: #263a32;
    --sheet-2: #2a4037;
    --grid: rgba(237, 241, 234, 0.055);
    --text: #edf1ea;
    --text-soft: #b2beb6;
    --text-faint: #8a988f;
    --ink: #a9c1ff;
    --ink-press: #c9d8ff;
    --on-ink: #13203a;
    --margin: #ff8e9e;
    --marker: #f2dc6b;
    --marker-soft: rgba(242, 220, 107, 0.16);
    --ok: #7fd6a7;
    --err: #ff9aa8;
    --line: #4a6156;
    --sep: #34493f;
    --line-soft: var(--sep);
    --surface: #24362e;
    --fill: rgba(169, 193, 255, .13);
    --fill-strong: rgba(169, 193, 255, .20);
    --fill-2: rgba(237, 241, 234, .07);
    --fill-3: rgba(237, 241, 234, .16);
    --thumb: var(--marker);
    --ok-tint: rgba(127, 214, 167, .13);
    --err-tint: rgba(255, 154, 168, .13);
    --e1: 0 0 0 transparent;
    --e2: 2px 2px 0 #1b2823;
    --e3: 4px 4px 0 #17221e;
    --e4: 6px 6px 0 #1b2823, 12px 12px 0 #17221e;
    --material: var(--paper);
    --sweep: rgba(242, 220, 107, .34);
    --backdrop: rgba(0, 0, 0, .5);
    --tab-pdf: #2c3d68;
    --tab-pdf-text: #c9d8ff;
    --tab-scan: #24493a;
    --tab-scan-text: #b5ecd0;
    --tab-convert: #5a2a35;
    --tab-convert-text: #ffd0d8;
    --tab-study: #4f4720;
    --tab-study-text: #f6e9a6;
    --tab-write: #3d3160;
    --tab-write-text: #e3d9ff;
    --shadow-sheet: 3px 3px 0 #1b2823, 6px 6px 0 #17221e;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #203029;
  --sheet: #263a32;
  --sheet-2: #2a4037;
  --grid: rgba(237, 241, 234, 0.055);
  --text: #edf1ea;
  --text-soft: #b2beb6;
  --text-faint: #8a988f;
  --ink: #a9c1ff;
  --ink-press: #c9d8ff;
  --on-ink: #13203a;
  --margin: #ff8e9e;
  --marker: #f2dc6b;
  --marker-soft: rgba(242, 220, 107, 0.16);
  --ok: #7fd6a7;
  --err: #ff9aa8;
  --line: #4a6156;
  --sep: #34493f;
  --line-soft: var(--sep);
  --surface: #24362e;
  --fill: rgba(169, 193, 255, .13);
  --fill-strong: rgba(169, 193, 255, .20);
  --fill-2: rgba(237, 241, 234, .07);
  --fill-3: rgba(237, 241, 234, .16);
  --thumb: var(--marker);
  --ok-tint: rgba(127, 214, 167, .13);
  --err-tint: rgba(255, 154, 168, .13);
  --e1: 0 0 0 transparent;
  --e2: 2px 2px 0 #1b2823;
  --e3: 4px 4px 0 #17221e;
  --e4: 6px 6px 0 #1b2823, 12px 12px 0 #17221e;
  --material: var(--paper);
  --sweep: rgba(242, 220, 107, .34);
  --backdrop: rgba(0, 0, 0, .5);
  --tab-pdf: #2c3d68;
  --tab-pdf-text: #c9d8ff;
  --tab-scan: #24493a;
  --tab-scan-text: #b5ecd0;
  --tab-convert: #5a2a35;
  --tab-convert-text: #ffd0d8;
  --tab-study: #4f4720;
  --tab-study-text: #f6e9a6;
  --tab-write: #3d3160;
  --tab-write-text: #e3d9ff;
  --shadow-sheet: 3px 3px 0 #1b2823, 6px 6px 0 #17221e;
}
@media (max-width: 860px) { :root { --header-h: 56px; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--s4));
  scroll-padding-bottom: calc(var(--dock-h, 0px) + var(--s4));
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  min-height: 100vh;
  font: 400 var(--fs-body)/var(--cell) var(--font-body);
  color: var(--text);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: -1px -1px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--marker); color: #17213d; }
img, canvas, svg, video { max-width: 100%; }
a { color: var(--ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); color: var(--text); margin: 0; }
h1 { font-weight: 700; font-size: var(--fs-large); line-height: 1.02; letter-spacing: -0.015em; }
h2 { font-weight: 600; font-size: var(--fs-title1); line-height: 36px; letter-spacing: -0.005em; }
h3 { font-weight: 600; font-size: var(--fs-title3); line-height: 26px; }
p { margin: 0 0 var(--cell); max-width: 68ch; }
small, .small { font-size: var(--fs-footnote); line-height: 20px; }
code, kbd, .mono { font-family: var(--font-mono); font-size: .92em; }
kbd { font-size: .86em; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: var(--r-xs); background: var(--sheet-2); white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: var(--on-ink); padding: 8px 14px; z-index: 50; border-radius: var(--r-sm); }
.skip:focus { top: 8px; }
[hidden] { display: none !important; }

/* Small helpers, so pages don't need inline styles */
.hint { color: var(--text-soft); font-size: var(--fs-footnote); line-height: 20px; margin: 0; }
.soft { color: var(--text-soft); }
.row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.stack { display: grid; gap: var(--s3); }
.span-all { grid-column: 1 / -1; }
.m-0 { margin: 0; }
.strong { font-weight: 600; }
.value-lg { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-title2); line-height: 30px; }
.mt-1 { margin-top: var(--s1); } .mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); } .mt-4 { margin-top: var(--s4); } .mt-6 { margin-top: var(--s6); }
.mb-2 { margin-bottom: var(--s2); } .mb-3 { margin-bottom: var(--s3); } .mb-4 { margin-bottom: var(--s4); } .mb-6 { margin-bottom: var(--s6); }

/* ---------- Page frame: margin column | red line | content ---------- */
.frame {
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, 1fr);
  max-width: calc(var(--margin-col) + var(--content-max) + 96px);
  margin: 0 auto;
  position: relative;
}
.frame::before {               /* Randlinie */
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: var(--margin-col);
  width: 2px;
  background: var(--margin);
  opacity: .85;
}
.frame > .margin { padding: 0 var(--s6) 0 var(--s4); text-align: right; }
.frame > .content { padding: 0 48px 0 46px; min-width: 0; }

/* ---------- Header: frosted, stays on top; a small title slides in once the big one has scrolled away ---------- */
.masthead-bar {
  position: sticky; top: 0; z-index: 30; background: transparent;
  transition: background-color var(--t-med), box-shadow var(--t-med);
}
/* Once you scroll, the header becomes a strip of paper with a ruled edge under it. */
.masthead-bar.is-scrolled { background: var(--paper); box-shadow: 0 var(--bw) 0 var(--line), 0 5px 0 var(--grid); }
.masthead { height: var(--header-h); align-items: center; }
.brand {
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-title2); line-height: 30px;
  color: var(--text); text-decoration: none; letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand .brand-dot { color: var(--margin); }
.masthead .content { display: flex; align-items: center; gap: var(--s1); height: 100%; }
.masthead nav { margin-left: auto; display: flex; gap: var(--s1); align-items: center; }
.masthead-title {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 600 var(--fs-body)/24px var(--font-display); color: var(--text); text-decoration: none;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-slow) var(--ease-out);
}
.masthead-bar.show-title .masthead-title { opacity: 1; transform: none; pointer-events: auto; }
.masthead-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--s3);
  border-radius: var(--r-sm); color: var(--text); text-decoration: none; font-weight: 600; font-size: var(--fs-subhead);
  transition: background-color var(--t-fast);
}
.masthead-link:hover { background: var(--fill-2); text-decoration: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-sm);
  border: 0; background: transparent; color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--fill-2); }
.icon-btn:active { transform: scale(.92); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn svg { width: 20px; height: 20px; }
.masthead .icon-btn { width: 36px; height: 36px; }
.theme-toggle svg { transition: transform var(--t-slow) var(--ease-spring); }
.theme-toggle:hover svg { transform: rotate(-20deg); }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}

.lang-hint {
  display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap;
  background: var(--marker-soft); border-bottom: 1px solid var(--sep);
  padding: var(--s2) var(--s4); font-size: var(--fs-subhead); justify-content: center;
}
.lang-hint button { font: inherit; }

main { display: block; padding-bottom: calc(var(--cell) * 3); }
.page-head { padding-top: var(--s6); }
.page-head .margin { padding-top: 6px; }
.lede { font-size: var(--fs-lede); line-height: 28px; color: var(--text-soft); max-width: 60ch; margin-top: var(--s4); }
.back-link { font-size: var(--fs-subhead); display: inline-block; line-height: 20px; }
.margin-top { padding-top: 30px; }
.cat-label {
  display: inline-block; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-body); line-height: 22px;
  padding: 3px 10px 3px 12px; border-radius: var(--r-xs) 0 0 var(--r-xs); margin-top: var(--s3); margin-right: -24px;
  text-align: right; max-width: calc(100% + 24px);
}
.cat-pdf { background: var(--tab-pdf); color: var(--tab-pdf-text); }
.cat-scan { background: var(--tab-scan); color: var(--tab-scan-text); }
.cat-convert { background: var(--tab-convert); color: var(--tab-convert-text); }
.cat-study { background: var(--tab-study); color: var(--tab-study-text); }
.cat-write { background: var(--tab-write); color: var(--tab-write-text); }

.section { margin-top: var(--s8); }
.section-title { margin-bottom: var(--s3); }

/* ---------- Start page ---------- */
.hero h1 { max-width: 15ch; }
.home-drop { margin-top: var(--s7); }
.tool-search { margin-top: var(--s8); max-width: 420px; }
.register { margin-top: var(--s6); }
.register-group { padding: var(--s5) 0 var(--s2); }
.register-group .margin { padding-top: 0; }
.register-group .cat-label { margin-top: 2px; }
.tool-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--s1) var(--s7); }
.tool-link {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 14px; align-items: start;
  padding: 10px 0 12px; text-decoration: none; color: var(--text); border-radius: var(--r-xs); -webkit-tap-highlight-color: transparent;
}
.tool-link:hover { text-decoration: none; }
.tool-ico {
  width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center; margin-top: 1px;
  transition: transform var(--t-slow) var(--ease-spring), box-shadow var(--t-med) var(--ease-out);
}
.tool-ico svg { width: 24px; height: 24px; }
.tool-link:hover .tool-ico, .tool-link:focus-visible .tool-ico { transform: translate(-2px, -2px) rotate(-4deg); box-shadow: 3px 3px 0 var(--line); }
.tool-link:active .tool-ico { transform: translate(1px, 1px); box-shadow: none; transition-duration: 80ms; }
.tool-text { min-width: 0; }
.tool-link .tool-name {
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-title3); line-height: 24px; color: var(--ink);
  background-image: linear-gradient(transparent 55%, var(--marker) 55%, var(--marker) 92%, transparent 92%);
  background-size: 0% 100%; background-repeat: no-repeat; transition: background-size .28s var(--ease-out), color var(--t-fast);
  padding: 0 2px; margin: 0 -2px;
}
.tool-link:hover .tool-name, .tool-link:focus-visible .tool-name { background-size: 100% 100%; }
:root[data-theme="dark"] .tool-link:hover .tool-name, :root[data-theme="dark"] .tool-link:focus-visible .tool-name { color: #13203a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tool-link:hover .tool-name, :root:not([data-theme="light"]) .tool-link:focus-visible .tool-name { color: #13203a; } }
.tool-link .tool-desc { display: block; color: var(--text-soft); font-size: var(--fs-subhead); line-height: 22px; margin-top: var(--s1); }
.no-results { color: var(--text-soft); }
.search-wrap { position: relative; }
.search-wrap .input { padding-right: 44px; }
.search-key { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-soft); transition: opacity var(--t-fast); }
.search-wrap:focus-within .search-key, .search-wrap:has(input:not(:placeholder-shown)) .search-key { opacity: 0; }
@media (pointer: coarse) { .search-key { display: none; } .search-wrap .input { padding-right: 12px; } }

.suggestions { margin-top: var(--s4); }
.suggestions h2 { font-size: var(--fs-title3); line-height: 26px; margin-bottom: var(--s2); }
.suggestion-list { display: flex; flex-wrap: wrap; gap: var(--s2); list-style: none; padding: 0; margin: 0; }

.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s6) var(--s7); margin-top: var(--s4); }
.why h3 { margin-bottom: var(--s2); }
.why p { color: var(--text-soft); font-size: var(--fs-subhead); line-height: 23px; margin: 0; }

/* ---------- Drop zone: a sheet lying on the pad ---------- */
.drop {
  position: relative; display: grid; justify-items: start; gap: var(--s3);
  background: var(--sheet); border: var(--bw) solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-sheet);
  padding: var(--s7) 180px var(--s6) var(--s7); cursor: pointer;
  transition: background-color var(--t-med), border-color var(--t-med), transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}
@media (hover: hover) { .drop:not(.is-compact):hover { border-color: var(--line); } }
.drop.is-over { background: var(--marker-soft); border-color: var(--ink); transform: translate(-3px, -3px); box-shadow: 6px 6px 0 var(--grid), 10px 10px 0 var(--line); }
.drop-title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-title2); line-height: 28px; margin: 0; }
.drop-hint { color: var(--text-soft); margin: 0; font-size: var(--fs-subhead); line-height: 22px; }
.drop-paste { margin: var(--s1) 0 0; color: var(--text-soft); font-size: var(--fs-caption); line-height: 20px; }
@media (pointer: coarse) { .drop-paste { display: none; } }
.drop-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s1); }
/* Once files are in, adding more is a side matter: the button steps back and the start button leads. */
.drop.is-compact { padding: 14px var(--s4) 14px var(--s5); grid-template-columns: 1fr auto; align-items: center; box-shadow: 2px 2px 0 var(--grid); cursor: default; }
.drop.is-compact .drop-title { font-size: var(--fs-body); line-height: 24px; }
.drop.is-compact .drop-actions { margin-top: 0; }
.drop.is-compact .drop-actions .btn:not(.btn-quiet) { background: var(--sheet); color: var(--ink); }
.drop.is-compact .drop-actions .btn:not(.btn-quiet):hover { background: var(--sheet); color: var(--ink); border-color: var(--ink); }
.drop.is-compact .drop-art, .drop.is-compact .drop-paste { display: none; }
.drop::after {                         /* marching ants while files hover over the page */
  content: ''; position: absolute; inset: 7px; pointer-events: none; opacity: 0;
  background-image: linear-gradient(90deg, var(--ink) 50%, transparent 0), linear-gradient(90deg, var(--ink) 50%, transparent 0),
    linear-gradient(0deg, var(--ink) 50%, transparent 0), linear-gradient(0deg, var(--ink) 50%, transparent 0);
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-size: 12px 2px, 12px 2px, 2px 12px, 2px 12px;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  transition: opacity var(--t-med);
}
.drop.is-over::after { opacity: 1; animation: kl-ants .55s linear infinite; }
@keyframes kl-ants { to { background-position: 12px 0, -12px 100%, 0 -12px, 100% 12px; } }
.drop-art { position: absolute; right: 34px; top: 50%; width: 120px; height: 100px; margin-top: -50px; pointer-events: none; overflow: visible; }
.drop-art rect { fill: var(--sheet); stroke: var(--line); stroke-width: 1.5; }
.drop-art .s3 rect { stroke: var(--text-soft); }
.drop-art .ln { stroke: var(--line); stroke-width: 2.5; stroke-linecap: round; fill: none; }
.drop-art .hl { stroke: var(--marker); stroke-width: 7; stroke-linecap: round; fill: none; opacity: .9; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset var(--t-slow) var(--ease-out); }
.drop-art .s { transform-box: fill-box; transform-origin: 50% 100%; transition: transform var(--t-slow) var(--ease-spring); }
.drop:hover .drop-art .hl, .drop.is-over .drop-art .hl { stroke-dashoffset: 0; }
.drop:hover .drop-art .s1 { transform: translate(-8px, 1px) rotate(-7deg); }
.drop:hover .drop-art .s2 { transform: translate(7px, 0) rotate(6deg); }
.drop:hover .drop-art .s3 { transform: translateY(-5px); }
.drop.is-over .drop-art .s1 { transform: translate(-14px, 2px) rotate(-13deg); }
.drop.is-over .drop-art .s2 { transform: translate(12px, 0) rotate(11deg); }
.drop.is-over .drop-art .s3 { transform: translateY(-14px); }
@media (max-width: 640px) { .drop:not(.is-compact) { padding: var(--s6) var(--s5) var(--s5); } .drop-art { display: none; } }

.drag-overlay {
  position: fixed; inset: 0; z-index: 70; pointer-events: none; opacity: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--paper) 62%, transparent); transition: opacity var(--t-med);
}
.drag-overlay::before {
  content: ''; position: absolute; inset: 14px;
  background-image: linear-gradient(90deg, var(--ink) 50%, transparent 0), linear-gradient(90deg, var(--ink) 50%, transparent 0),
    linear-gradient(0deg, var(--ink) 50%, transparent 0), linear-gradient(0deg, var(--ink) 50%, transparent 0);
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-size: 14px 3px, 14px 3px, 3px 14px, 3px 14px;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
}
.drag-overlay.is-on { opacity: 1; }
.drag-overlay.is-on::before { animation: kl-ants-big .6s linear infinite; }
@keyframes kl-ants-big { to { background-position: 14px 0, -14px 100%, 0 -14px, 100% 14px; } }
.drag-overlay-card {
  display: inline-flex; gap: var(--s3); align-items: center; padding: 14px 22px; max-width: calc(100vw - 64px);
  background: var(--ink); color: var(--on-ink); border-radius: var(--r-sm); font: 600 var(--fs-body)/22px var(--font-body);
  box-shadow: 4px 4px 0 var(--marker); transform: translateY(10px) scale(.96); transition: transform var(--t-slow) var(--ease-spring);
}
.drag-overlay-card svg { width: 22px; height: 22px; flex: none; }
.drag-overlay.is-on .drag-overlay-card { transform: none; }

/* =====================================================================
   Controls. Three kinds of button, one kind of field.
   Filled = the one main action. Tinted = everything else. Link = in text.
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 18px; border: var(--bw) solid var(--ink); border-radius: var(--r-sm);
  font: 600 1rem/1 var(--font-body); text-decoration: none; white-space: nowrap; cursor: pointer;
  background: var(--ink); color: var(--on-ink);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast),
    transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), opacity var(--t-fast);
}
/* Every button lifts off the page onto a highlighter shadow, and presses back down into it. */
@media (hover: hover) {
  .btn:not(:disabled):not(.is-busy):hover { transform: translate(-2px, -2px); box-shadow: 3px 3px 0 var(--marker); text-decoration: none; }
}
.btn:hover { background: var(--ink-press); border-color: var(--ink-press); }
.btn:not(:disabled):active { transform: translate(1px, 1px); box-shadow: 0 0 0 transparent; transition-duration: 60ms; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; }
.btn-quiet { background: var(--sheet); color: var(--ink); }
.btn-quiet:hover { background: var(--sheet); border-color: var(--ink); color: var(--ink); }
.btn-danger, .btn-quiet.btn-danger { background: var(--sheet); color: var(--err); border-color: currentColor; }
.btn-danger:hover, .btn-quiet.btn-danger:hover { background: var(--err-tint); border-color: currentColor; color: var(--err); }
@media (hover: hover) { .btn-danger:not(:disabled):hover { box-shadow: 3px 3px 0 var(--err-tint); } }
.btn-small { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-subhead); }
.btn-big { min-height: 52px; padding: 0 26px; font-size: var(--fs-body); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.is-busy { opacity: 1; cursor: progress; }
.btn.is-busy::before {
  content: ''; width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: kl-spin .7s linear infinite;
}
@keyframes kl-spin { to { transform: rotate(360deg); } }
.btn-link { font: inherit; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.btn-link:hover { text-decoration-thickness: 2px; }

.field { display: grid; gap: var(--s2); align-content: start; }
.field > label, .field > .label, .label { font-weight: 600; font-size: var(--fs-subhead); line-height: 20px; }
.field .help, .help { color: var(--text-soft); font-size: var(--fs-footnote); line-height: 20px; }
.input, select.input, textarea.input {
  font: 400 1rem/22px var(--font-body); color: var(--text);
  background: var(--sheet); border: var(--bw) solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; min-height: 44px; width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-med) var(--ease-out);
}
.input:hover { border-color: var(--text-soft); }
/* The field you're writing in gets a highlighter edge, like marking the line on paper. */
.input:focus, .input:focus-visible { outline: none; border-color: var(--ink); box-shadow: 3px 3px 0 var(--marker); }
.input::placeholder { color: var(--text-faint); opacity: 1; }
.input:disabled { opacity: .55; cursor: not-allowed; }
textarea.input { resize: vertical; min-height: 120px; }
.input.is-invalid { border-color: var(--err); }
.input.is-invalid:focus { box-shadow: 3px 3px 0 var(--err-tint); }
select.input { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%237a839c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; }
.input-num { max-width: 120px; }
.input-sm { min-height: 36px; padding: 6px 10px; }

/* ---------- Segmented control: a raised thumb slides along a track ---------- */
.field > .seg { justify-self: start; }
.seg {
  position: relative; isolation: isolate; display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px;
  background: var(--sheet); border: var(--bw) solid var(--line); border-radius: var(--r-sm);
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 14px; border-radius: var(--r-xs); cursor: pointer;
  font-weight: 600; font-size: var(--fs-subhead); color: var(--text); user-select: none; -webkit-user-select: none;
  transition: color var(--t-fast), background-color var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.seg label:hover { background: var(--fill-2); }
.seg label:active { transform: scale(.97); }
/* The chosen option is highlighted, as you would mark it on paper. */
.seg input:checked + label { background: var(--marker); color: #17213d; }   /* until the thumb is set up */
.seg input:focus-visible + label { outline: 2px solid var(--ink); outline-offset: 1px; }
.seg-thumb {
  position: absolute; left: 0; top: 0; z-index: -1; border-radius: var(--r-xs); background: var(--marker);
  pointer-events: none; opacity: 0; box-shadow: inset 0 -3px 0 rgba(23, 33, 61, .08);
  transition: transform var(--t-med) var(--ease-out), width var(--t-med) var(--ease-out), height var(--t-med) var(--ease-out), opacity var(--t-fast);
}
.seg-thumb.is-instant { transition: none; }
.seg.has-thumb input:checked + label, .seg.has-thumb input:checked + label:hover { background: transparent; color: #17213d; }
/* Many short options (aspect ratios): an even grid instead of a ragged wrap. */
.seg:has(> input:nth-of-type(5)) { display: grid; grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); }
@media (max-width: 480px) { .seg:has(> input:nth-of-type(5)) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Choice cards: options that say what they do ---------- */
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s2); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label {
  position: relative; display: grid; gap: var(--s1); align-content: start; padding: var(--s3) var(--s4) 14px 44px; cursor: pointer;
  background: var(--sheet); border: var(--bw) solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--t-fast), background-color var(--t-fast), box-shadow var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
}
.choice label::before {               /* one choice: a ring that gets a pen tick */
  content: ''; position: absolute; left: 13px; top: 12px; width: 22px; height: 22px; border-radius: 50%;
  border: var(--bw) solid var(--text-soft); background: var(--sheet);
  transition: border-color var(--t-fast);
}
.choice label::after {
  content: ''; position: absolute; left: 16px; top: 15px; width: 16px; height: 16px; background: var(--ink);
  -webkit-mask: var(--tick) center / 16px no-repeat; mask: var(--tick) center / 16px no-repeat;
  clip-path: inset(0 100% 0 0); transition: clip-path var(--t-med) var(--ease-out);
}
.choice-title { font-weight: 600; line-height: 20px; }
.choice-desc { color: var(--text-soft); font-size: var(--fs-footnote); line-height: 19px; }
.choice label:hover { border-color: var(--text-soft); }
.choice input:checked + label { border-color: var(--ink); background: var(--marker-soft); box-shadow: 3px 3px 0 var(--marker); transform: translate(-1px, -1px); }
.choice input:checked + label::before { border-color: var(--ink); }
.choice input:checked + label::after { clip-path: inset(0 0 0 0); }
.choice input:focus-visible + label { outline: 2px solid var(--ink); outline-offset: 2px; }
.options > .field-wide { grid-column: 1 / -1; }

/* ---------- On/off settings are switches; radios stay round ---------- */
.check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; line-height: 22px; -webkit-tap-highlight-color: transparent; }
.check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 20px; height: 20px; margin: 1px 0 0;
  border: var(--bw) solid var(--text-soft); border-radius: var(--r-xs); background: var(--sheet); cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-fast) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}
.check input[type="checkbox"]::after {      /* the tick is drawn left to right, like a pen stroke */
  content: ''; position: absolute; inset: 0; background: var(--ink);
  -webkit-mask: var(--tick) center / 15px no-repeat; mask: var(--tick) center / 15px no-repeat;
  clip-path: inset(0 100% 0 0); transition: clip-path var(--t-med) var(--ease-out);
}
.check input[type="checkbox"]:checked { border-color: var(--ink); box-shadow: 2px 2px 0 var(--marker); }
.check input[type="checkbox"]:checked::after { clip-path: inset(0 0 0 0); }
.check input[type="checkbox"]:active:not(:disabled) { transform: scale(.9); }
.check input[type="radio"] {
  appearance: none; -webkit-appearance: none; flex: none; width: 20px; height: 20px; margin: 1px 0 0; border-radius: 50%;
  border: var(--bw) solid var(--text-soft); background: var(--sheet); display: inline-grid; place-items: center; cursor: pointer;
  transition: border-color var(--t-fast);
}
.check input[type="radio"]::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); transform: scale(0); transition: transform var(--t-med) var(--ease-spring); }
.check input[type="radio"]:checked { border-color: var(--ink); }
.check input[type="radio"]:checked::after { transform: scale(1); }
.check:hover input:not(:disabled):not(:checked) { border-color: var(--ink); }
.check input:disabled { opacity: .45; cursor: not-allowed; }
.check input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.check.small { font-size: var(--fs-subhead); }
.target-row { display: flex; align-items: center; gap: var(--s2) var(--s3); flex-wrap: wrap; }
.target-row .input-inline { width: 76px; min-height: 38px; padding: 6px 10px; transition: opacity var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast); }
.target-row:has([data-target-on]:not(:checked)) .input-inline { opacity: .55; }

/* ---------- Sliders: a thin track and a raised knob ---------- */
input[type="range"].range, .cv-photo input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; accent-color: var(--ink);
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 1px; background: var(--line); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 1px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 1px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: var(--sheet); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--marker); transition: transform var(--t-fast) var(--ease-out); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--sheet); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--marker); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Chips: small tinted buttons (formula palette, templates, history) ---------- */
.chip {
  font: 400 var(--fs-subhead)/1 var(--font-body); min-height: 36px; min-width: 40px; padding: 0 10px; border-radius: var(--r-sm);
  border: var(--bw) solid var(--line); background: var(--sheet); color: var(--text); cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip:active { transform: translate(1px, 1px); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); box-shadow: 2px 2px 0 var(--marker); }

/* =====================================================================
   Tool workspace
   ===================================================================== */
.workspace { margin-top: var(--s7); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s6); }
.panel { background: var(--sheet); border: var(--bw) solid var(--line); border-radius: var(--r-md); padding: 22px var(--s6) var(--s6); }
.panel-title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-title3); line-height: 24px; margin: 0 0 var(--s4); }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s5) var(--s6); }
.options-row { display: flex; flex-wrap: wrap; gap: var(--s5) var(--s6); align-items: end; }
.action-bar { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.local-note { display: inline-flex; gap: var(--s2); align-items: center; color: var(--text-soft); font-size: var(--fs-footnote); line-height: 20px; }
.local-note svg { width: 16px; height: 16px; flex: none; }

/* Files: a grouped list with hairlines between rows */
.file-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--sep); counter-reset: file; }
.file-row {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: var(--s3); align-items: center;
  min-height: 64px; padding: var(--s2) var(--s1); border-bottom: 1px solid var(--sep); background: var(--sheet); position: relative;
  counter-increment: file;
}
.file-row.is-dragging { box-shadow: 4px 4px 0 var(--marker); outline: var(--bw) solid var(--ink); z-index: 3; }
.file-thumb { width: 40px; height: 52px; display: grid; place-items: center; overflow: hidden; background: var(--sheet-2); border: 1px solid var(--sep); border-radius: var(--r-xs); }
.file-name { font-weight: 600; font-size: 1rem; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--text-soft); font-size: var(--fs-footnote); line-height: 20px; }
.file-meta.is-error { color: var(--err); }
.file-actions { display: flex; gap: 2px; }
/* The order is the point of a merge, so each row shows its place. Pointing at it shows the grip. */
.handle {
  position: relative; cursor: grab; touch-action: none; color: var(--text-soft); display: grid; place-items: center;
  width: 32px; height: 44px; border-radius: var(--r-xs); border: 0; background: none; transition: background-color var(--t-fast), color var(--t-fast);
}
.handle::before {
  content: counter(file); position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 var(--fs-title3)/1 var(--font-display); color: var(--text-faint); font-variant-numeric: tabular-nums;
  transition: opacity var(--t-fast), transform var(--t-med) var(--ease-out);
}
.handle svg { width: 18px; height: 18px; opacity: 0; transform: scale(.7); transition: opacity var(--t-fast), transform var(--t-med) var(--ease-spring); }
.file-row:hover .handle::before, .handle:focus-visible::before, .file-row.is-dragging .handle::before { opacity: 0; transform: scale(.7); }
.file-row:hover .handle svg, .handle:focus-visible svg, .file-row.is-dragging .handle svg { opacity: 1; transform: none; }
.handle:hover { background: var(--fill-2); color: var(--text); }
.handle:active { cursor: grabbing; }
@media (hover: none) {           /* touch: number and grip side by side, nothing to point at */
  .handle { width: 40px; grid-template-columns: 1fr 1fr; }
  .handle::before { position: static; font-size: var(--fs-body); }
  .handle svg { opacity: .7; transform: none; }
}

/* Page tiles (split, organize, scanner, PDF to images) */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: var(--s4); }
.page-card {
  position: relative; display: grid; gap: 6px; justify-items: center; padding: var(--s2); border-radius: var(--r-md);
  border: 2px solid transparent; background: transparent; touch-action: manipulation;
  transition: background-color var(--t-fast), border-color var(--t-fast), transform var(--t-med) var(--ease-out);
}
.page-card canvas, .page-card img { width: 100%; height: auto; display: block; background: #fff; border: 1px solid var(--sep); box-shadow: 2px 2px 0 var(--sep); transition: opacity var(--t-med), box-shadow var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out); }
.page-card .page-no { font-size: var(--fs-caption); line-height: 18px; color: var(--text-soft); }
@media (hover: hover) { .page-card:hover canvas { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--line); } }
.page-card.is-selected { background: var(--marker-soft); border-color: var(--ink); }
.page-card.is-selected::after {      /* a ticked box in the corner */
  content: ''; position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: var(--r-xs); z-index: 2; pointer-events: none;
  background: var(--ink) var(--tick-white) center / 15px no-repeat; box-shadow: 2px 2px 0 var(--marker);
  animation: kl-badge var(--t-med) var(--ease-spring) backwards;
}
@keyframes kl-badge { from { transform: scale(.4) rotate(-12deg); opacity: 0; } }
.page-card.is-deleted canvas { opacity: .2; }
.page-card .page-tools { display: flex; gap: 2px; position: relative; z-index: 1; }
.page-card button.page-hit { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; border-radius: var(--r-md); }
.page-thumb-wrap { width: 100%; display: grid; place-items: center; aspect-ratio: 0.72; }
.page-thumb-wrap canvas { max-height: 100%; width: auto; max-width: 100%; transition: transform var(--t-med) var(--ease-out); }
.page-card.is-dragging { z-index: 5; background: var(--sheet); box-shadow: 5px 5px 0 var(--marker); border-color: var(--ink); }

/* Work in progress */
.progress { display: grid; gap: var(--s2); }
.progress-bar { height: 10px; background: var(--sheet); border: var(--bw) solid var(--line); border-radius: var(--r-xs); overflow: hidden; }
.progress-bar > span {
  position: relative; display: block; height: 100%; width: 0; overflow: hidden; transition: width .35s var(--ease-out);
  background: repeating-linear-gradient(-45deg, var(--ink) 0 6px, color-mix(in srgb, var(--ink) 78%, var(--sheet)) 6px 10px) 0 0 / 28px 100%;
  animation: kl-hatch .9s linear infinite;
}
@keyframes kl-hatch { to { background-position: 28px 0; } }
.progress.is-indeterminate .progress-bar > span { width: 30%; animation: slide 1.2s ease-in-out infinite, kl-hatch .9s linear infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.progress-text { font-size: var(--fs-footnote); color: var(--text-soft); line-height: 20px; font-variant-numeric: tabular-nums; }

/* Result: a card with a drawn tick and a highlighted title */
.result {
  position: relative; background: var(--sheet); border: var(--bw) solid var(--line); border-top: 0; border-radius: 0 0 var(--r-md) var(--r-md);
  box-shadow: var(--shadow-sheet); padding: 26px var(--s6) var(--s6); display: grid; gap: var(--s3);
}
/* Its top edge is perforated, like a page you tear out of the pad: this is yours to take. */
.result::before {
  content: ''; position: absolute; left: -1.5px; right: -1.5px; top: 0; height: 9px; pointer-events: none;
  background:
    radial-gradient(circle at 6px 0, var(--paper) 3.2px, transparent 3.6px) 0 0 / 12px 9px repeat-x,
    linear-gradient(var(--line), var(--line)) 0 0 / 100% var(--bw) no-repeat;
}
.result-title { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-title3); line-height: 26px; margin: 0; }
.result-tick { width: 28px; height: 28px; flex: none; color: var(--ok); display: grid; }
.result-tick svg { width: 100%; height: 100%; }
.result-meta { color: var(--text-soft); margin: 0; font-size: var(--fs-subhead); line-height: 22px; }
.result:has(> .notice.is-error:only-child) { box-shadow: none; border-top: var(--bw) solid var(--line); border-radius: var(--r-md); padding: var(--s3); }
.result:has(> .notice.is-error:only-child)::before { display: none; }
.result > .notice.is-error:only-child { margin: 0; }

/* Callouts: a tinted box, never a coloured stripe */
.notice { padding: 10px 14px; border-left: 3px solid var(--line); border-radius: 0 var(--r-xs) var(--r-xs) 0; background: var(--fill-2); color: var(--text-soft); font-size: var(--fs-subhead); line-height: 22px; }
.notice.is-error { border-left-color: var(--err); background: var(--err-tint); color: var(--err); }
.notice.is-ok { border-left-color: var(--ok); background: var(--ok-tint); color: var(--text); }
.notice > :last-child { margin-bottom: 0; }

/* Numbers in a grouped grid with hairlines */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, calc(50% - 1px)), 1fr)); gap: 1px; background: var(--sep); border: 1px solid var(--sep); border-radius: var(--r-md); overflow: hidden; }
.stat { padding: var(--s3) var(--s4); background: var(--sheet); }
.stat-value { font-variant-numeric: tabular-nums; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-title1); line-height: 34px; display: block; }
.stat-label { color: var(--text-soft); font-size: var(--fs-footnote); line-height: 20px; }
.big-number { font-family: var(--font-display); font-weight: 700; font-size: clamp(3rem, 2rem + 4vw, 4.5rem); line-height: 1; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table.grid-table { border-collapse: collapse; width: 100%; font-size: var(--fs-subhead); }
.grid-table th { text-align: left; font-weight: 600; font-size: var(--fs-footnote); color: var(--text-soft); padding: var(--s2); border-bottom: 1px solid var(--sep); white-space: nowrap; }
.grid-table td { padding: var(--s1) 6px; border-bottom: 1px solid var(--sep); vertical-align: middle; }
.grid-table tr:last-child td { border-bottom: 0; }
.grid-table td .input { min-height: 40px; padding: 8px 10px; }
.grid-table .num { text-align: right; }

.help-text { margin-top: var(--s8); max-width: 68ch; }
.help-text h2 { font-size: var(--fs-title2); line-height: 30px; margin-bottom: var(--s2); }
.help-text h3 { margin: var(--s5) 0 6px; font-size: var(--fs-body); line-height: 24px; }
.help-text p, .help-text li { color: var(--text-soft); }
.help-text ul { padding-left: var(--s5); margin: 0 0 var(--cell); }
.help-text .related { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); padding: 0; list-style: none; margin: var(--s2) 0 0; }

.prose { max-width: 70ch; }
.prose h2 { font-size: var(--fs-title2); line-height: 30px; margin: var(--s7) 0 10px; }
.prose h3 { margin: var(--s6) 0 6px; font-size: var(--fs-body); line-height: 24px; }
.prose p, .prose li { line-height: 26px; }
.prose ul { padding-left: 22px; }
.prose .placeholder { background: var(--marker-soft); padding: 0 3px; border-radius: 3px; }

/* ---------- Floating things: toast and loading card ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--s5) + var(--dock-h, 0px)); z-index: 60;
  display: flex; align-items: center; gap: var(--s3); width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 1px;
  background: #fff3a1; color: #2b2a1a; box-shadow: 1px 1px 0 rgba(0, 0, 0, .06), 4px 5px 0 rgba(23, 33, 61, .14);
  font: 600 var(--fs-subhead)/20px var(--font-body);
  opacity: 0; transform: translate(-50%, 24px) rotate(2deg); pointer-events: none;
  transition: opacity var(--t-med), transform var(--t-slow) var(--ease-spring), bottom var(--t-med) var(--ease-out);
}
/* A sticky note slapped onto the page: it lands slightly crooked. */
.toast.is-on { opacity: 1; transform: translate(-50%, 0) rotate(-.8deg); }
.toast.has-action { pointer-events: auto; padding: 6px 6px 6px 18px; }
.toast-action {
  font: 600 var(--fs-subhead)/1 var(--font-body); color: #1d3a9e; background: none; border: var(--bw) solid #1d3a9e;
  padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer; flex: none; transition: background-color var(--t-fast);
}
.toast-action:hover { background: rgba(29, 58, 158, .1); }
.toast-action:focus-visible { outline: 2px solid #1d3a9e; outline-offset: 2px; }

.loader {
  position: fixed; inset: auto; top: auto; right: auto; left: 50%; bottom: calc(var(--s6) + var(--dock-h, 0px)); margin: 0; overflow: hidden;
  z-index: 58; display: flex; align-items: center; gap: var(--s4);
  width: min(360px, calc(100vw - 32px)); padding: 14px 18px 18px; color: var(--text);
  background: var(--material);
  border: var(--bw) solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sheet);
  opacity: 0; transform: translate(-50%, 18px) scale(.97); pointer-events: none;
  transition: opacity .25s ease, transform .35s var(--ease-out);
}
.loader.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.loader-tiles { display: grid; grid-template-columns: repeat(3, 12px); gap: 4px; flex: none; }
.loader-tiles span {
  width: 12px; height: 12px; border-radius: 1px; border: 1.5px solid var(--line); background: transparent;
  animation: kl-wave 1.3s ease-in-out infinite; animation-delay: calc((var(--x) + var(--y)) * 110ms);
  transition: background-color .2s, border-color .2s;
}
.loader-tiles span.next { background: var(--marker); border-color: var(--marker); }
.loader-tiles span.on { background: var(--ink); border-color: var(--ink); animation: kl-lock .45s cubic-bezier(.3, 1.6, .5, 1) both; }
.loader-body { display: grid; gap: 2px; min-width: 0; }
.loader-label { font-weight: 600; font-size: var(--fs-subhead); line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loader-sub { font-size: var(--fs-caption); color: var(--text-soft); min-height: 18px; font-variant-numeric: tabular-nums; }
.loader-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--ink); transform-origin: left; transform: scaleX(.02); }
@keyframes kl-wave {
  0%, 100% { transform: translateY(0) scale(1); opacity: .5; }
  50% { transform: translateY(-3px) scale(1.14); opacity: 1; }
}
@keyframes kl-lock { 0% { transform: translateY(-9px) scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .loader-tiles span { animation: none !important; } .loader-tiles span:not(.on):not(.next) { opacity: .6; } }

/* ---------- Footer ---------- */
.colophon { padding: var(--s8) 0; border-top: 1px solid var(--sep); background: var(--paper); }
.colophon .content { display: flex; flex-wrap: wrap; gap: var(--s2) 22px; align-items: baseline; font-size: var(--fs-subhead); }
.colophon .content p { margin: 0; color: var(--text-soft); flex-basis: 100%; }
.colophon .brand { font-size: var(--fs-title3); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  :root { --margin-col: 18px; }
  .frame > .margin { padding: 0; text-align: left; }
  .frame > .margin > * { display: none; }
  .frame > .content { padding: 0 var(--s4) 0 26px; }
  .masthead .brand-slot { display: block !important; transition: opacity var(--t-med), transform var(--t-slow) var(--ease-out); }
  .masthead .content { position: relative; }
  .masthead-title { position: absolute; left: 26px; right: 150px; }
  .masthead-bar.show-title .brand-slot { opacity: 0; transform: translateY(-8px); pointer-events: none; }
  .page-head .margin-mobile, .register-group .margin-mobile { display: block !important; }
  .cat-label { margin: 0 0 10px; border-radius: var(--r-xs); }
  .panel { padding: var(--s4); }
  .result { padding: var(--s4); }
  .drop.is-compact { grid-template-columns: 1fr; padding: var(--s4); }
  .tool-list { grid-template-columns: 1fr; }
  .workspace { margin-top: var(--s6); gap: var(--s5); }
}
@media (min-width: 861px) { .brand-slot, .margin-mobile { display: none !important; } }
@media (max-width: 480px) {
  body { font-size: 16px; }
  .lede { font-size: var(--fs-body); line-height: 26px; }
  .file-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .file-row .file-thumb { display: none; }
  .pages { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  body { background: #fff; }
  .masthead-bar, .colophon, .frame::before { display: none; }
}

/* Register tabs: category labels hang in the margin, touching the red line */
.register-row { position: relative; }
.register-tab { position: absolute; right: calc(100% + 46px); top: 12px; white-space: nowrap; }
.register-tab .cat-label { margin: 0; border-radius: var(--r-xs) 0 0 var(--r-xs); max-width: none; white-space: normal; width: max-content; max-width: calc(var(--margin-col) - 20px); }
@media (max-width: 860px) { .register-tab { display: none; } }

/* =====================================================================
   Shared pieces: dialogs, menus, folding sections, banner
   ===================================================================== */
dialog.modal {
  width: min(560px, calc(100vw - 24px)); max-height: min(86vh, 900px); padding: 0; overflow: hidden;
  border: var(--bw) solid var(--line); border-radius: var(--r-lg); background: var(--sheet); color: var(--text);
  box-shadow: var(--e4); display: flex; flex-direction: column;
  --mx: 30px;                    /* where the red margin line runs */
}
dialog.modal:not([open]) { display: none; }
dialog.modal.is-wide { width: min(720px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: var(--backdrop); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s3) var(--s3) calc(var(--mx) + 16px); border-bottom: var(--bw) solid var(--line); }
.modal-title { font-size: var(--fs-title3); line-height: 26px; }
.modal-body {
  padding: var(--s5) var(--s6) var(--s6) calc(var(--mx) + 16px); overflow: auto; overscroll-behavior: contain;
  background:
    linear-gradient(90deg, transparent var(--mx), var(--margin) var(--mx), var(--margin) calc(var(--mx) + 2px), transparent calc(var(--mx) + 2px)),
    var(--sheet);
}
.modal-body > :last-child { margin-bottom: 0; }
.modal-actions { padding: var(--s3) var(--s6) var(--s5); border-top: var(--bw) solid var(--line); justify-content: flex-end; }
@media (max-width: 560px) {
  dialog.modal, dialog.modal.is-wide { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0; }
  dialog.modal { --mx: 14px; }
  .modal-body { padding: var(--s4) var(--s4) var(--s4) calc(var(--mx) + 14px); }
  .modal-head { position: relative; padding: 22px var(--s2) var(--s2) calc(var(--mx) + 14px); touch-action: none; }
  .modal-head::before { content: ''; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 1px; background: var(--line); }
  .modal-actions { padding: var(--s3) var(--s4) max(var(--s4), env(safe-area-inset-bottom)); }
  .modal-actions .btn { flex: 1 1 auto; }
  dialog.modal.is-dragging { transition: none; animation: none; }
}

.changelog h3 { font-size: var(--fs-body); line-height: 24px; margin: 22px 0 6px; }
.changelog h3:first-child { margin-top: 0; }
.changelog h3.changelog-title { font-size: var(--fs-title3); }
.changelog ul { margin: 0 0 var(--s3); padding-left: var(--s5); }
.changelog li { margin-bottom: var(--s1); line-height: 23px; }
.changelog p { margin: 0 0 var(--s3); color: var(--text-soft); line-height: 23px; }

/* "Continue with …": a popover menu */
.next-menu { position: relative; display: inline-block; }
.next-menu > summary { list-style: none; }
.next-menu > summary::-webkit-details-marker { display: none; }
.next-menu > summary::after { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); margin-left: 2px; transition: transform var(--t-med) var(--ease-out); }
.next-menu[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.next-list {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 240px; margin: 0; padding: 6px; list-style: none;
  background: var(--material);
  border: var(--bw) solid var(--line); border-radius: var(--r-md); box-shadow: 4px 4px 0 var(--line);
}
.next-item { display: block; width: 100%; text-align: left; font: 600 var(--fs-subhead)/22px var(--font-body); color: var(--ink); background: none; border: 0; padding: 9px 12px; border-radius: var(--r-xs); cursor: pointer;
  background-image: linear-gradient(transparent 60%, var(--sweep) 60%, var(--sweep) 92%, transparent 92%); background-size: 0% 100%; background-repeat: no-repeat; background-position: 12px 0;
  transition: background-size var(--t-med) var(--ease-out); }
/* Pointing at an entry highlights it, like running a marker over it. */
.next-item:hover, .next-item:focus-visible { background-size: calc(100% - 24px) 100%; }
@media (max-width: 480px) { .next-list { position: static; margin-top: 6px; box-shadow: var(--e1); } }

/* Folding sections (Extras, writing tips): a card whose row opens with a chevron on the right */
.extras, .coach { border: var(--bw) solid var(--line); border-radius: var(--r-md); background: var(--sheet); padding: 0 var(--s5); transition: box-shadow var(--t-med) var(--ease-out); }
.extras[open], .coach[open] { box-shadow: 3px 3px 0 var(--grid); }
.extras > summary, .coach > summary {
  cursor: pointer; padding: 14px 0; font-weight: 600; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; list-style: none;
}
.extras > summary::-webkit-details-marker, .coach > summary::-webkit-details-marker { display: none; }
.extras > summary::after, .coach > summary::after {
  content: ''; width: 8px; height: 8px; margin-left: auto; align-self: center; flex: none;
  border-right: 2px solid var(--text-faint); border-bottom: 2px solid var(--text-faint);
  transform: translateY(-2px) rotate(45deg); transition: transform var(--t-med) var(--ease-out);
}
.extras[open] > summary::after, .coach[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.extras > summary:hover .extras-title { color: var(--ink); }
.extras[open], .coach[open] { padding-bottom: var(--s5); }
.extras-sum { font-weight: 400; color: var(--text-soft); font-size: var(--fs-subhead); }
.extras::details-content, .coach::details-content {
  block-size: 0; overflow-y: clip;
  transition: block-size var(--t-med) var(--ease-out), content-visibility var(--t-med) allow-discrete;
}
.extras[open]::details-content, .coach[open]::details-content { block-size: auto; }

/* Site banner (message.json / message.txt) */
.site-banner {
  --b-bg: #e3eafb; --b-fg: #13286e; --b-accent: #1d3a9e; --b-on: #ffffff;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s2) 14px;
  padding: 10px 56px 10px var(--s4); position: relative;
  background: var(--b-bg); color: var(--b-fg); border-bottom: 1px solid color-mix(in srgb, var(--b-accent) 30%, transparent);
  font-size: var(--fs-subhead); line-height: 22px;
}
.site-banner[data-color="red"] { --b-bg: #fde8eb; --b-fg: #6e1022; --b-accent: #b3263e; }
.site-banner[data-color="green"] { --b-bg: #ddf2e6; --b-fg: #0f4a30; --b-accent: #17704a; }
.site-banner[data-color="grey"] { --b-bg: #eceff3; --b-fg: #2b3245; --b-accent: #5d6680; }
.site-banner-text { margin: 0; max-width: 80ch; text-align: center; }
.site-banner-text a { color: inherit; font-weight: 600; }
.site-banner .site-banner-btn { background: var(--b-accent); color: var(--b-on); }
.site-banner .site-banner-btn:hover { filter: brightness(1.1); background: var(--b-accent); }
.site-banner-close { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: inherit; width: 36px; height: 36px; }
.site-banner-close:hover { background: rgba(0, 0, 0, .07); }
.site-banners + .site-banners { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .site-banner { --b-bg: #26345c; --b-fg: #d8e3ff; --b-accent: #a9c1ff; --b-on: #13203a; }
  :root:not([data-theme="light"]) .site-banner[data-color="red"] { --b-bg: #4a2129; --b-fg: #ffd5dc; --b-accent: #ff8e9e; }
  :root:not([data-theme="light"]) .site-banner[data-color="green"] { --b-bg: #1f4433; --b-fg: #c8f0da; --b-accent: #7fd6a7; }
  :root:not([data-theme="light"]) .site-banner[data-color="grey"] { --b-bg: #303b36; --b-fg: #e3e8e4; --b-accent: #b2beb6; }
}
:root[data-theme="dark"] .site-banner { --b-bg: #26345c; --b-fg: #d8e3ff; --b-accent: #a9c1ff; --b-on: #13203a; }
:root[data-theme="dark"] .site-banner[data-color="red"] { --b-bg: #4a2129; --b-fg: #ffd5dc; --b-accent: #ff8e9e; }
:root[data-theme="dark"] .site-banner[data-color="green"] { --b-bg: #1f4433; --b-fg: #c8f0da; --b-accent: #7fd6a7; }
:root[data-theme="dark"] .site-banner[data-color="grey"] { --b-bg: #303b36; --b-fg: #e3e8e4; --b-accent: #b2beb6; }
:root[data-theme="dark"] .site-banner-close:hover { background: rgba(255, 255, 255, .08); }
@media (max-width: 560px) { .site-banner { justify-content: flex-start; } .site-banner-text { text-align: left; } }

/* Header extras */
.news-btn { position: relative; border: 0; background: transparent; font-family: inherit; cursor: pointer; }
.news-btn svg { width: 18px; height: 18px; }
.news-btn.has-news::after {
  content: ''; position: absolute; top: 5px; left: 21px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--margin); box-shadow: 0 0 0 2px var(--paper);
}
.offline-pill {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: var(--r-xs);
  background: var(--marker-soft); color: var(--text); font-size: var(--fs-caption); font-weight: 600; cursor: help;
}
@media (max-width: 520px) { .news-btn .news-label { display: none; } .news-btn { padding: 0 9px; } }

/* =====================================================================
   Tool-specific parts, on the same tokens
   ===================================================================== */
/* Scanner: corner editor */
.scan-edit { position: relative; display: inline-block; max-width: 100%; touch-action: none; user-select: none; -webkit-user-select: none; line-height: 0; border-radius: var(--r-sm); overflow: hidden; }
.scan-edit canvas[data-edit-canvas] { display: block; max-width: 100%; max-height: 70vh; width: auto; height: auto; background: #222; }
.scan-edit svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.scan-edit .quad { fill: rgba(255, 233, 77, .16); stroke: var(--marker); stroke-width: 2.5; }
.scan-edit .knob { fill: #fff; stroke: #1d3a9e; stroke-width: 3; }
.scan-edit .hit { fill: transparent; cursor: grab; }
.scan-edit .hit:focus-visible + .knob, .scan-edit .knob.is-active { fill: var(--marker); }
.loupe { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 16px rgba(0,0,0,.35); pointer-events: none; z-index: 4; }
.scan-pages { grid-template-columns: repeat(auto-fill, minmax(186px, 1fr)); }
@media (max-width: 520px) { .scan-pages { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.scan-pages .page-card { cursor: grab; }
.scan-pages .page-tools { flex-wrap: wrap; justify-content: center; }
.scan-pages .page-flag { font-size: var(--fs-caption); line-height: 18px; color: var(--err); text-align: center; }
/* a reflection hid text: the flag itself opens the second photo, and the button is marked */
.scan-pages .page-flag.is-action { cursor: pointer; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.scan-pages .icon-btn.is-suggested { background: var(--marker); color: #1a1a1a; }
/* what the scanner did by itself: a highlighter label on the thumbnail */
.scan-pages .page-thumb-wrap { position: relative; }
.scan-pages .page-auto {
  position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 12px); padding: 0 6px;
  font-size: var(--fs-caption); font-weight: 600; line-height: 17px; padding-block: 1px;
  background: var(--marker); color: #111; border-radius: var(--r-xs); box-shadow: 2px 2px 0 rgba(0, 0, 0, .18); pointer-events: none;
  animation: kl-pop .32s var(--ease-out, ease-out) both;
}
.cam-launch { display: grid; gap: 10px; justify-items: start; }
.cam-launch .help { margin: 0; color: var(--text-soft); max-width: 62ch; font-size: var(--fs-subhead); line-height: 22px; }

/* Scanner: live camera. Always dark, like a camera app, whatever the theme. */
html.cam-open, html.cam-open body { overflow: hidden; overscroll-behavior: none; }
.cam { position: fixed; inset: 0; z-index: 1000; background: #000; color: #fff; display: grid; grid-template-rows: auto 1fr auto; height: 100vh; height: 100dvh; }
.cam-view { position: absolute; inset: 0; overflow: hidden; }
.cam-view video, .cam-view svg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
/* the outline: a thin edge, corner brackets, and a highlighter that traces it while you hold still
   (--u is one screen pixel in video pixels, set from script) */
.cam-view svg { --u: 1; opacity: 0; }
.cam-fill { fill: #ffe94d; fill-opacity: .05; stroke: none; }
.cam-edge { fill: none; stroke: rgba(255, 255, 255, .6); stroke-width: calc(1.5 * var(--u)); }
.cam-trace { fill: none; stroke: #ffe94d; stroke-width: calc(5 * var(--u)); stroke-linejoin: miter; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.cam-corners { fill: none; stroke: #ffe94d; stroke-width: calc(6 * var(--u)); stroke-linecap: square; stroke-linejoin: miter; }
.cam-view svg.is-locked .cam-trace, .cam-view svg.is-locked .cam-corners { stroke: #fff; }
.cam-view svg.is-locked .cam-fill { fill: #fff; fill-opacity: .3; }
/* tip under the outline, as a sticky note */
.cam-hint {
  position: absolute; left: 50%; bottom: calc(176px + env(safe-area-inset-bottom)); z-index: 3; margin: 0; max-width: calc(100% - 32px);
  padding: 6px 12px; background: #ffe94d; color: #111; font: 600 var(--fs-subhead)/20px var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-radius: var(--r-xs); box-shadow: 3px 3px 0 rgba(0, 0, 0, .35); pointer-events: none;
  opacity: 0; transform: translate(-50%, 8px) rotate(-1deg); transition: opacity .2s, transform .25s var(--ease-out, ease-out);
}
.cam-hint.is-on { opacity: 1; transform: translate(-50%, 0) rotate(-1deg); }
/* spirit level: the square settles in the middle when the phone lies flat */
.cam-level { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; z-index: 2; pointer-events: none; display: grid; place-items: center; border: 1.5px solid rgba(255, 255, 255, .5); border-radius: var(--r-xs); }
.cam-level::before { content: ''; width: 16px; height: 16px; border: 1.5px solid rgba(255, 255, 255, .6); border-radius: 2px; }
.cam-bubble { position: absolute; width: 12px; height: 12px; border-radius: 2px; background: rgba(255, 255, 255, .9); transition: transform .12s linear, background-color .2s; }
.cam-level.is-level { border-color: #ffe94d; }
.cam-level.is-level .cam-bubble { background: #ffe94d; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .35s ease-out; }
.cam-flash.is-on { opacity: .8; transition: none; }
.cam-top { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; padding: max(12px, env(safe-area-inset-top)) 12px 28px; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.cam-status { flex: 1; margin: 0; text-align: center; font: 600 var(--fs-body)/22px var(--font-body); text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.cam-icon { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; cursor: pointer; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.cam-icon svg { width: 22px; height: 22px; }
.cam-icon[aria-pressed="true"] { background: #ffe94d; color: #111; }
.cam-icon:focus-visible, .cam-shutter:focus-visible, .cam-done:focus-visible, .cam-last:focus-visible { outline: 3px solid #ffe94d; outline-offset: 3px; }
.cam-top::after { content: ''; width: 44px; flex: none; }
.cam-top:has(.cam-icon[data-cam-torch]:not([hidden]))::after { display: none; }
.cam-bottom { grid-row: 3; position: relative; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px 16px; padding: 28px 20px max(18px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.cam-shutter { position: relative; width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; background: rgba(255,255,255,.22); box-shadow: inset 0 0 0 4px rgba(0,0,0,.4); cursor: pointer; transition: transform .1s; }
.cam-shutter svg { position: absolute; left: 50%; top: 50%; width: 96px; height: 96px; max-width: none; max-height: none; margin: -48px 0 0 -48px; transform: rotate(-90deg); pointer-events: none; overflow: visible; }
.cam-ring { fill: none; stroke: #ffe94d; stroke-width: 4; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.cam-shutter:active { transform: scale(.94); background: #fff; }
.cam-last { justify-self: start; position: relative; width: 52px; height: 70px; padding: 0; border-radius: var(--r-xs); border: 2px solid rgba(255,255,255,.85); background: rgba(255,255,255,.12); cursor: pointer; display: grid; place-items: center; }
.cam-last canvas { max-width: 100%; max-height: 100%; display: block; background: #fff; }
.cam-last span { position: absolute; top: -9px; right: -9px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: #ffe94d; color: #111; font: 700 var(--fs-caption)/22px var(--font-body); text-align: center; }
.cam-last.is-empty { visibility: hidden; }
.cam-done { justify-self: end; min-height: 44px; padding: 0 20px; border: 0; border-radius: var(--r-pill); background: #fff; color: #111; font: 600 1rem/1 var(--font-body); cursor: pointer; }
.cam-auto { grid-column: 1 / -1; justify-self: center; display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-subhead); text-shadow: 0 1px 3px rgba(0,0,0,.7); cursor: pointer; }
.cam-auto input { width: 20px; height: 20px; accent-color: #ffe94d; }

/* Cover page generator */
.cover-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); gap: var(--s6); align-items: start; }
.cover-form { display: grid; gap: var(--s6); }
.cover-form .options { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.cover-side { position: sticky; top: calc(var(--header-h) + var(--s4)); }
.cover-paper { background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px var(--sep), var(--e3); aspect-ratio: 210 / 297; display: grid; place-items: center; overflow: hidden; }
.cover-paper canvas { width: 100%; height: auto; display: block; }
@media (max-width: 1060px) { .cover-grid { grid-template-columns: 1fr; } .cover-side { position: static; max-width: 420px; } }

/* Formula editor */
.formula-stage { background: #fff; border: var(--bw) solid var(--line); border-radius: var(--r-md); min-height: 168px; display: grid; place-items: center; padding: 28px 20px; overflow-x: auto; box-shadow: var(--e1); }
.formula-stage.is-dark { background: #1b2430; }
.formula-stage mjx-container { margin: 0 !important; }
.formula-input { font-family: var(--font-mono); font-size: 1rem; line-height: 24px; min-height: 112px; }
.palette { display: grid; gap: 10px; }
.palette-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.palette-row .palette-name { font-size: var(--fs-footnote); color: var(--text-soft); min-width: 92px; }
.formula-error { color: var(--err); font-size: var(--fs-subhead); }
.mf-wrap { min-width: 0; max-width: 100%; }
.mf-wrap math-field { display: block; width: 100%; max-width: 100%; overflow-x: auto; min-height: 66px; font-size: 1.75rem; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--sheet); color: var(--text); --caret-color: var(--ink); --selection-background-color: var(--marker-soft); --selection-color: var(--text); --contains-highlight-background-color: var(--surface); --placeholder-color: var(--text-soft); --smart-fence-color: var(--text-soft); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.mf-wrap math-field:focus-within { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 22%, transparent); }
.mf-loading { min-height: 66px; display: flex; align-items: center; padding: 0 14px; border: 1px dashed var(--line); border-radius: var(--r-sm); color: var(--text-soft); }
.workspace > .field { min-width: 0; }
.history { display: flex; flex-wrap: wrap; gap: 6px; }
.history-chip { font-family: var(--font-mono); font-size: var(--fs-caption); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Document tools (letter, CV): form on the left, the real pages on the right */
.doc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: var(--s6); align-items: start; }
.doc-form { display: grid; gap: var(--s6); }
.doc-form .options { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.doc-side { position: sticky; top: calc(var(--header-h) + var(--s4)); }
.doc-preview { display: grid; gap: 14px; max-height: calc(100vh - var(--header-h) - 96px); overflow: auto; padding: 2px 10px 10px 2px; overscroll-behavior: contain; }
.doc-preview canvas { width: 100%; height: auto; display: block; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px var(--sep), var(--e2); }
.doc-warn { display: grid; gap: var(--s1); margin: var(--s3) 0 0; padding: 10px 14px; border-radius: var(--r-sm); background: var(--marker-soft); font-size: var(--fs-subhead); line-height: 21px; }
.tpl-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip.tpl { min-height: 40px; padding: 0 14px; font-weight: 600; }
.kv-rows { display: grid; gap: var(--s2); }
.kv-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto; gap: var(--s2); align-items: center; }
.doc-form textarea.input { min-height: 0; }
.doc-form textarea[data-f="body"] { min-height: 260px; line-height: 24px; }
.sig { display: grid; gap: 10px; }
.sig-show { min-height: 64px; display: flex; align-items: center; padding: 8px 12px; border: 1px dashed var(--line); border-radius: var(--r-sm); background: #fff; }
.sig-show img { max-height: 64px; max-width: 100%; }
.sig-empty { color: #6b7280; font-size: var(--fs-subhead); }
.sig-pad { display: grid; gap: 10px; padding: var(--s3); border: var(--bw) solid var(--line); border-radius: var(--r-md); background: var(--sheet-2); }
.sig-pad .help { margin: 0; }
.sig-pad canvas { width: 100%; height: 180px; background: #fff; border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px var(--sep); touch-action: none; cursor: crosshair; display: block; }
.sig-ink { margin-left: auto; }
.doc-jump { display: none; }
@media (max-width: 1060px) {
  .doc-grid { grid-template-columns: 1fr; }
  .doc-side { position: static; }
  .doc-preview { max-height: none; overflow: visible; max-width: 520px; }
  .doc-jump.is-away { display: inline-flex; position: fixed; right: var(--s4); bottom: max(var(--s4), env(safe-area-inset-bottom)); z-index: 50; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 18px; border-radius: var(--r-sm); background: var(--ink); color: var(--on-ink); font-weight: 600; text-decoration: none; box-shadow: 3px 3px 0 var(--marker); }
}
@media (max-width: 480px) { .kv-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; } }

/* CV builder */
.cv-person { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: var(--s5); align-items: start; }
.cv-photo { gap: var(--s2); }
.photo-frame { position: relative; width: 140px; aspect-ratio: 7 / 9; border-radius: var(--r-sm); background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--sep); overflow: hidden; }
.photo-frame canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.photo-frame canvas:active { cursor: grabbing; }
.photo-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-faint); font-size: var(--fs-footnote); pointer-events: none; }
.cv-photo input[type="range"] { width: 140px; }
.cv-entries { display: grid; gap: var(--s3); }
.cv-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2); padding: var(--s4); border: var(--bw) solid var(--line); border-radius: var(--r-md); background: var(--sheet-2); }
.cv-entry-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3) 14px; }
.cv-span2 { grid-column: span 2; }
.cv-span3 { grid-column: 1 / -1; }
.cv-entry-tools { display: flex; flex-direction: column; gap: 2px; }
.cv-entry textarea.input { min-height: 72px; }
.swatches label { padding: 0 10px; }
.swatch { display: block; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); }
.seg.swatches input:checked + label { background: var(--thumb); box-shadow: var(--e2), inset 0 0 0 2px var(--ink); }
@media (max-width: 640px) {
  .cv-person { grid-template-columns: 1fr; }
  .cv-entry-grid { grid-template-columns: 1fr; }
  .cv-span2, .cv-span3 { grid-column: auto; }
}

/* Page editor */
.ws-bar {
  display: flex; flex-wrap: wrap; gap: var(--s2) 18px; align-items: center; justify-content: space-between;
  position: sticky; top: var(--header-h); z-index: 6; margin: 0 calc(-1 * var(--s3)); padding: var(--s2) var(--s3);
  background: var(--material);
  border-radius: var(--r-sm); box-shadow: 0 1px 0 var(--sep);
}
.ws-group { display: flex; flex-wrap: wrap; gap: var(--s1); align-items: center; }
.ws-count { font-weight: 600; font-size: var(--fs-subhead); margin-right: 6px; min-width: 9ch; }
.ws-card .page-tools { flex-wrap: wrap; justify-content: center; }
.ws-card .page-tools .icon-btn { width: 32px; height: 32px; }
.ws-card .page-tools .icon-btn svg { width: 18px; height: 18px; }
.ws-src { font-size: var(--fs-caption); line-height: 16px; padding: 1px 7px; border-radius: var(--r-xs); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--fill-2); color: var(--text-soft); margin-top: 0; }
.ws-zoom { display: grid; place-items: center; }
.ws-zoom canvas { max-width: 100%; height: auto; border-radius: 3px; background: #fff; box-shadow: 0 0 0 1px var(--sep), var(--e2); }
.page-card .page-tools .icon-btn { flex: none; }
@media (max-width: 480px) {
  .ws-bar .btn > span { display: none; }
  .ws-bar .btn { padding: 0 9px; }
  .ws-card .page-tools .icon-btn { width: 30px !important; height: 30px !important; }
}

/* Before / after comparison */
.compare { display: grid; gap: 10px; }
.compare-head { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: center; }
.compare-head .label { margin-right: auto; }
select.compare-page { width: auto; min-height: 36px; padding: 4px 34px 4px 10px; }
.compare-stage { position: relative; overflow: auto; max-height: 72vh; border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px var(--sep); background: var(--sheet-2); touch-action: pan-y; cursor: ew-resize; }
.compare-stage.is-zoomed { touch-action: pan-x pan-y; }
.compare-inner { position: relative; width: 100%; margin: 0 auto; }
.compare-inner canvas { display: block; width: 100%; height: auto; background: #fff; }
.compare-before { position: absolute; inset: 0; }
.compare-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); pointer-events: none; }
.compare-knob { position: absolute; top: 50%; left: 50%; width: 32px; height: 32px; margin: -16px 0 0 -16px; border-radius: 50%; background: var(--ink); box-shadow: var(--e2); }
.compare-knob::before, .compare-knob::after { content: ''; position: absolute; top: 11px; border: 5px solid transparent; }
.compare-knob::before { left: 2px; border-right-color: var(--on-ink); }
.compare-knob::after { right: 2px; border-left-color: var(--on-ink); }
.compare-tag { position: absolute; top: 8px; padding: 2px 8px; border-radius: var(--r-xs); background: rgba(23, 33, 61, .72); color: #fff; font-size: var(--fs-caption); font-weight: 600; pointer-events: none; }
.compare-tag.is-left { left: 8px; } .compare-tag.is-right { right: 8px; }
.compare-stage:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* OCR review */
.ocr-review { border: var(--bw) solid var(--line); border-radius: var(--r-md); background: var(--paper); overflow: hidden; }
.ocr-bar { display: flex; flex-wrap: wrap; gap: var(--s2) 14px; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--sep); background: var(--sheet); }
.ocr-count { font-size: var(--fs-subhead); color: var(--text-soft); }
.ocr-text { padding: 14px var(--s4); max-height: 460px; overflow: auto; position: relative; font-size: var(--fs-subhead); line-height: 26px; }
.ocr-text p { margin: 0 0 var(--s3); max-width: none; }
.ocr-page { font-family: var(--font-display); font-weight: 600; color: var(--text-soft); border-bottom: 1px solid var(--sep); margin-top: var(--s2) !important; }
.ocr-w { font: inherit; color: inherit; background: none; border: 0; padding: 0 1px; margin: 0 -1px; border-radius: 3px; cursor: pointer; line-height: inherit; }
.ocr-w:hover { background: var(--fill-2); }
.ocr-w.is-unsure { background: var(--marker-soft); box-shadow: inset 0 -2px 0 var(--marker); }
.ocr-w.is-fixed { box-shadow: inset 0 -2px 0 var(--ok); }
.ocr-w.is-gone { color: var(--text-soft); text-decoration: line-through; }
.ocr-pop { display: grid; gap: var(--s2); margin: var(--s2) 0 var(--s3); padding: var(--s3); border: var(--bw) solid var(--line); border-radius: var(--r-md); background: var(--sheet); max-width: 420px; box-shadow: var(--e3); }
.ocr-pop-img { min-height: 20px; }
.ocr-crop { display: block; max-width: 100%; height: auto; border-radius: var(--r-xs); box-shadow: 0 0 0 1px var(--sep); background: #fff; }
.ocr-tables { display: grid; gap: 10px; }
.ocr-table td { white-space: nowrap; padding: 4px 10px; }

/* Scanner: adjust one page */
.adjust { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.adjust-stage { display: grid; place-items: center; background: var(--sheet-2); border-radius: var(--r-md); padding: 10px; min-height: 200px; }
.adjust-preview { max-width: 100%; max-height: 52vh; width: auto; height: auto; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px var(--sep), var(--e2); }
.adjust-controls { display: grid; gap: var(--s4); }
@media (max-width: 600px) { .adjust { grid-template-columns: 1fr; } .adjust-preview { max-height: 38vh; } }

/* Grade calculator: progress, chart, impact */
.grades-progress { margin-top: 18px; }
.grades-progress .progress-bar { height: 8px; }
.grades-chart svg { width: 100%; max-width: 640px; height: auto; display: block; }
.gc-axis { stroke: var(--sep); stroke-width: 1; }
.gc-mark { fill: var(--ink); }
.gc-hit { fill: transparent; }
.gc-bar:hover .gc-mark, .gc-bar:focus-visible .gc-mark { fill: var(--ink-press); }
.gc-bar:hover .gc-hit, .gc-bar:focus-visible .gc-hit { fill: var(--fill-2); }
.gc-bar:focus-visible { outline: none; }
.gc-tick { fill: var(--text-soft); font: 400 12px var(--font-body); }
.gc-val { fill: var(--text); font: 600 12px var(--font-body); }
.grades-sub { font-size: var(--fs-body); margin: 18px 0 6px; }
.grades-impact { margin: 0; padding-left: var(--s5); }
.grades-impact li { margin-bottom: 6px; line-height: 23px; }
.pages-out { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-title3); line-height: 28px; margin: 18px 0 6px; }
.style-list { margin: 0; padding-left: var(--s5); }
.style-list li { margin-bottom: var(--s1); }
.attach { display: grid; gap: 6px; justify-items: start; }
@media (max-width: 480px) {
  .grades .grid-table td .input-num { min-width: 58px; }
  .grades .grid-table th:first-child { width: auto !important; }
}

/* Versions, writing tips, ATS view */
.drafts { display: grid; gap: 6px; justify-items: start; }
.drafts-row { display: flex; gap: 6px; width: 100%; }
.drafts-select { min-height: 38px; padding: 6px 34px 6px 10px; font-size: var(--fs-subhead); }
.coach { margin-top: 14px; }
.coach > summary::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--marker); align-self: center; flex: none; }
.coach-list { margin: 0; padding-left: 18px; font-size: var(--fs-subhead); line-height: 22px; }
.coach-list li { margin-bottom: var(--s2); color: var(--text-soft); }
.coach-list q { color: var(--text); font-style: italic; }
.ats-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ats-checks li { display: flex; gap: 10px; align-items: baseline; }
.ats-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 700; font-size: var(--fs-caption); flex: none; }
.ats-checks .is-ok .ats-mark { background: var(--ok); color: var(--paper); }
.ats-checks .is-bad .ats-mark { background: var(--err); color: var(--paper); }
.ats-text { white-space: pre-wrap; word-break: break-word; font: 400 var(--fs-footnote)/1.5 var(--font-mono); background: var(--sheet-2); border: var(--bw) solid var(--line); padding: var(--s3) 14px; margin: 0; max-height: 46vh; overflow: auto; border-radius: var(--r-sm); }

/* =====================================================================
   Motion and flow
   One language for every tool: things slide into place, the highlighter
   marks what is current, ticks are drawn on. Every movement answers
   something the person did; with "reduce motion" on, things just change.
   ===================================================================== */

/* Page changes: the header stays, the page underneath slides in. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .masthead-bar { view-transition-name: kl-masthead; }
  main > .content { view-transition-name: kl-page; }
  ::view-transition-old(kl-page) { animation: kl-page-out .16s var(--ease-in) both; }
  ::view-transition-new(kl-page) { animation: kl-page-in .38s var(--ease-out) both; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .2s; }
}
@keyframes kl-page-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes kl-page-in { from { opacity: 0; transform: translateY(14px); } }

/* Things appearing in a tool slide up into place. "backwards" on purpose: a transform that
   stayed applied would make fixed-position children position against the panel. */
.workspace > :not(.drop):not(.dock):not(.result):not([hidden]) { animation: kl-in var(--t-slow) var(--ease-out) backwards; }
.dock:not([hidden]) { animation: kl-fade var(--t-slow) var(--ease-out) backwards; }
@keyframes kl-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes kl-fade { from { opacity: 0; } }

/* Files land one after another and leave sideways */
.file-row { animation: kl-row-in var(--t-slow) var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes kl-row-in { from { opacity: 0; transform: translateY(-10px); } }
.file-row.is-leaving { animation: none; }
.file-thumb:empty {
  background: linear-gradient(100deg, var(--sheet-2) 30%, var(--fill-3) 50%, var(--sheet-2) 70%) 0 0 / 300% 100%;
  animation: kl-shimmer 1.3s linear infinite;
}
@keyframes kl-shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.file-thumb.is-none { font: 600 .6875rem/1 var(--font-body); letter-spacing: .02em; color: var(--text-soft); }

/* The result lands, its tick is drawn, "Fertig" gets highlighted */
.result:not([hidden]) { animation: kl-land var(--t-slow) var(--ease-out) backwards; }
@keyframes kl-land { from { opacity: 0; transform: translateY(16px) scale(.99); } }
.result-tick circle, .result-tick path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.result-tick circle { animation: kl-draw .5s var(--ease-out) .1s forwards; }
.result-tick path { animation: kl-draw .32s var(--ease-out) .5s forwards; }
@keyframes kl-draw { to { stroke-dashoffset: 0; } }
.mark {
  background: linear-gradient(transparent 58%, var(--sweep) 58%, var(--sweep) 94%, transparent 94%) no-repeat 0 0 / 0% 100%;
  padding: 0 3px; margin: 0 -3px; animation: kl-sweep .55s var(--ease-out) .55s forwards;
}
@keyframes kl-sweep { to { background-size: 100% 100%; } }
.result .notice.is-error { animation: kl-nudge .45s var(--ease-out); }
@keyframes kl-nudge { 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-2px); } }

/* The action bar floats at the bottom while it would be out of sight.
   Floating changes only its paint, never its size: a size change would unstick it again. */
.dock { position: sticky; bottom: 0; z-index: 8; margin-inline: calc(-1 * var(--s3)); padding: 10px var(--s3) max(10px, env(safe-area-inset-bottom)); border-radius: var(--r-md) var(--r-md) 0 0;
  transition: background-color var(--t-med), box-shadow var(--t-med); }
.dock.is-stuck {
  background: var(--paper);
  box-shadow: 0 calc(-1 * var(--bw)) 0 var(--line), 0 -5px 0 var(--grid);
}
@media (max-width: 480px) {
  .dock { gap: var(--s2); }
  .dock .btn-big { flex: 1 1 auto; padding: 0 var(--s5); }
  .dock .local-note { flex-basis: 100%; min-width: 0; font-size: var(--fs-caption); line-height: 16px; }
  .dock .local-note svg { width: 14px; height: 14px; }
}
/* Once there's a result, its download leads; starting again steps back. */
body[data-flow="done"] .dock { position: relative; }
body[data-flow="done"] .dock [data-run], body[data-flow="done"] .dock [data-run]:hover { background: var(--sheet); color: var(--ink); border-color: var(--ink); }
body[data-flow="done"] .dock .btn-big { flex: 0 1 auto; }

/* Steps in the margin, threaded on the red line */
.steps { list-style: none; margin: 38px 0 0; padding: 0; display: grid; gap: 6px; position: sticky; top: calc(var(--header-h) + var(--s6)); }
.step { display: flex; justify-content: flex-end; }
.step-btn {
  display: inline-flex; align-items: center; gap: var(--s3); margin-right: -36px; padding: var(--s1) 0; border: 0; background: none; cursor: pointer;
  font: 600 1rem/20px var(--font-display); color: var(--text-soft); text-align: right; border-radius: var(--r-xs);
}
.step-t { max-width: 118px; transition: color var(--t-med); }
.step-t > span {
  padding: 1px 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background-size var(--t-slow) var(--ease-out);
  background: linear-gradient(transparent 55%, var(--sweep) 55%, var(--sweep) 95%, transparent 95%) no-repeat 0 0 / 0% 100%;
}
.step-n {
  position: relative; width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--text-soft); font: 600 var(--fs-caption)/1 var(--font-body);
  transition: background-color var(--t-med), border-color var(--t-med), color var(--t-med), transform var(--t-slow) var(--ease-spring);
}
.step-n::after {
  content: ''; position: absolute; inset: 4px; background: var(--on-ink); opacity: 0;
  -webkit-mask: var(--tick) center / 14px 14px no-repeat; mask: var(--tick) center / 14px 14px no-repeat;
  clip-path: inset(0 100% 0 0); transition: clip-path var(--t-med) var(--ease-out) .1s, opacity 0s .1s;
}
.step-btn:hover .step-t { color: var(--text); }
.step.is-current .step-t { color: var(--text); }
.step.is-current .step-t > span { background-size: 100% 100%; }
.step.is-current .step-n { background: var(--marker); border-color: var(--text); color: #17213d; transform: scale(1.15); }
.step.is-done .step-n { background: var(--ink); border-color: var(--ink); color: transparent; }
.step.is-done .step-n::after { opacity: 1; clip-path: inset(0 0 0 0); }
.step.is-busy .step-n { animation: kl-pulse 1.3s ease-in-out infinite; }
@keyframes kl-pulse { 50% { box-shadow: 0 0 0 6px var(--marker-soft); } }

/* Dialogs: laid down like a sheet, closed quickly */
dialog.modal[open] { animation: kl-modal-in .32s var(--ease-out); }
dialog.modal[open]::backdrop { animation: kl-fade .3s ease; }
dialog.modal.is-closing { animation: kl-modal-out .18s var(--ease-in) forwards; }
dialog.modal.is-closing::backdrop { animation: kl-fade-out .18s ease forwards; }
@keyframes kl-modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes kl-modal-out { to { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes kl-fade-out { to { opacity: 0; } }
@media (max-width: 560px) {
  dialog.modal[open] { animation: kl-sheet-up .36s var(--ease-out); }
  dialog.modal.is-closing { animation: kl-sheet-down .22s var(--ease-in) forwards; }
}
@keyframes kl-sheet-up { from { transform: translateY(100%); } }
@keyframes kl-sheet-down { to { transform: translateY(100%); } }

/* Menus pop from where they were opened */
.next-menu[open] > .next-list { animation: kl-pop var(--t-med) var(--ease-out) backwards; transform-origin: top left; }
@keyframes kl-pop { from { opacity: 0; transform: translateY(-6px) scale(.96); } }

/* Start page */
.register-group:not([hidden]), [data-tool]:not([hidden]) { animation: kl-fade var(--t-med) var(--ease-out) backwards; }
.suggestions:not([hidden]) { animation: kl-in var(--t-slow) var(--ease-out) backwards; }
.suggestion-list li { animation: kl-in var(--t-slow) var(--ease-out) backwards; }
.suggestion-list li:nth-child(2) { animation-delay: 50ms; } .suggestion-list li:nth-child(3) { animation-delay: 100ms; }
.suggestion-list li:nth-child(4) { animation-delay: 150ms; } .suggestion-list li:nth-child(n+5) { animation-delay: 200ms; }

/* Page editor: the selection tools appear once something is selected */
.ws-bar[data-sel="off"] [data-sel-tools] .btn, .ws-bar[data-sel="off"] [data-act="none"] { display: none; }
.ws-bar[data-sel="off"] .ws-count::after { content: ' · ' attr(data-hint); font-weight: 400; color: var(--text-soft); }
.ws-bar[data-sel="on"] [data-sel-tools] .btn { animation: kl-fade var(--t-med) var(--ease-out) backwards; }

/* Page editor on phones: the selection tools float at the bottom */
@media (max-width: 640px) {
  .ws-bar { position: static; margin: 0; padding: var(--s1) 0 var(--s2); background: none; box-shadow: none; }
  .ws-bar > .ws-group:last-child { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: 100%; min-width: 0; padding-bottom: 2px; }
  .ws-bar > .ws-group:last-child .btn { flex: none; }
  .ws-bar > .ws-group:last-child::-webkit-scrollbar { display: none; }
  .ws-bar > .ws-group:last-child, .ws-bar[data-sel="on"] [data-sel-tools] { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
  .ws-bar[data-sel="on"] [data-sel-tools] {
    position: fixed; left: 10px; right: 10px; bottom: calc(var(--dock-h, 0px) + max(10px, env(safe-area-inset-bottom))); z-index: 40;
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 2px; padding: 6px;
    background: color-mix(in srgb, var(--text) 94%, transparent);
    color: var(--paper); border-radius: var(--r-md); box-shadow: var(--e3);
    animation: kl-sheet-up .3s var(--ease-out);
  }
  .ws-bar[data-sel="on"] [data-sel-tools]::-webkit-scrollbar { display: none; }
  .ws-bar[data-sel="on"] [data-sel-tools] .ws-count { color: var(--paper); padding: 0 6px 0 8px; min-width: auto; white-space: nowrap; }
  .ws-bar[data-sel="on"] [data-sel-tools] .btn {
    flex: none; flex-direction: column; gap: 2px; min-height: 52px; min-width: 58px; padding: 4px 8px; color: var(--paper); background: transparent; font-size: .75rem;
  }
  .ws-bar[data-sel="on"] [data-sel-tools] .btn > span { display: inline !important; white-space: nowrap; }
  .ws-bar[data-sel="on"] [data-sel-tools] .btn:hover { background: rgba(127, 127, 127, .25); }
  .ws-bar[data-sel="on"] [data-sel-tools] .btn svg { width: 20px; height: 20px; }
  body:has(.ws-bar[data-sel="on"]) .toast { bottom: calc(var(--dock-h, 0px) + 92px); }
}

/* With "reduce motion", end states are shown straight away. */
@media (prefers-reduced-motion: reduce) {
  .result-tick circle, .result-tick path { stroke-dashoffset: 0; }
  .mark { background-size: 100% 100%; }
  html { scroll-behavior: auto; }
}

/* A download: a small sheet flies off the page towards the browser's downloads */
.fly-sheet {
  position: fixed; left: 0; top: 0; z-index: 90; width: 26px; height: 34px; pointer-events: none;
  background: #fff linear-gradient(#c8d2e1, #c8d2e1) 5px 9px / 14px 2px no-repeat;
  border: 1.5px solid #17213d; border-radius: 1px; box-shadow: 2px 2px 0 var(--marker);
}
.fly-sheet::before, .fly-sheet::after { content: ''; position: absolute; left: 5px; height: 2px; background: #c8d2e1; }
.fly-sheet::before { top: 15px; width: 12px; } .fly-sheet::after { top: 21px; width: 9px; }
