/* PaperDesk: the desk (the page where a paper is open). LockIn dark + yellow; light theme kept.
   Everything is scoped under .dk; the paper's own elements use pd- class names. */

/* Answers are typed in Arial's metrics so the downloaded PDF wraps in the same places. Where Arial is not
   installed (phones, Linux), Liberation Sans stands in: it has the same metrics, and the PDF export uses it. */
@font-face {
  font-family: "PD Arial";
  src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("LiberationSans"),
       url("/web/assets/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf") format("truetype");
  font-display: swap;
}

/* Colours come from the shared LockIn tokens (css/tokens.css, :root, dark and light). The fallbacks keep the
   desk usable on its own; desk-only values are set here. */
.dk {
  --bg: var(--desk, #0c0c0d);
  --answer: "PD Arial", Arial, Helvetica, sans-serif;
  --bar-h: 52px; --dock-w: 64px; --rail-w: 0px; --dr-w: 0px;
  --shadow-pop: 0 18px 44px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .35);
}
:root[data-theme="light"] .dk { --shadow-pop: 0 16px 40px rgba(20, 24, 32, .16), 0 2px 6px rgba(20, 24, 32, .08); }

/* ---------- frame ---------- */
.dk { position: fixed; inset: 0; z-index: 20; display: grid; overflow: hidden; background: var(--bg); color: var(--text);
  font: 13px/1.4 var(--ui); -webkit-font-smoothing: antialiased; text-align: left;
  grid-template-columns: var(--rail-w) var(--dock-w) minmax(0, 1fr) var(--dr-w);
  grid-template-rows: var(--bar-h) minmax(0, 1fr);
  grid-template-areas: "bar bar bar bar" "rail dock stage drawer"; }
.dk.rail-open:not(.rail-over) { --rail-w: 256px; }
.dk.dr-open:not(.dr-over) { --dr-w: 396px; }
.dk, .dk *, .dk *::before, .dk *::after { box-sizing: border-box; }
/* Zero-specificity resets, so the paper's own elements (answers, notes, marks) keep their fonts and colours */
:where(.dk) :where(button, input, textarea) { font: inherit; color: inherit; }
:where(.dk) :where(button) { cursor: pointer; }
:where(.dk) :where(a) { color: inherit; }
.dk [hidden] { display: none !important; }
.dk .i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.dk :focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }
.dk-bar { grid-area: bar; }
.dk-rail { grid-area: rail; }
.dk-dock { grid-area: dock; }
.dk-stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; }
.dk-drawer { grid-area: drawer; }
.dk-sp { flex: 1; min-width: 4px; }

/* ---------- buttons ---------- */
.dk-btn { height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--raised);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 650; white-space: nowrap; flex: none;
  text-decoration: none; color: var(--text); transition: background-color .12s, border-color .12s; }
.dk-btn:hover:not(:disabled) { background: var(--hover); border-color: var(--faint); }
.dk-btn .i { width: 16px; height: 16px; }
.dk-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 800; }
.dk-btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
/* dark ink on the bright dark-theme red (white on it is only 3:1), as the library's .btn.solid-danger */
.dk-btn.danger { background: var(--bad); border-color: var(--bad); color: #121212; font-weight: 750; }
:root[data-theme="light"] .dk-btn.danger { color: #fff; }
.dk-btn.danger:hover:not(:disabled) { filter: brightness(1.08); background: var(--bad); }
.dk-btn.danger-ghost { color: var(--bad); }
.dk-btn.danger-ghost:hover:not(:disabled) { background: var(--bad-bg); border-color: var(--bad-line); }
.dk-btn:disabled { opacity: .55; cursor: default; }
.dk-btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.dk-btn.sm .i { width: 14px; height: 14px; }
.dk-btn.wide { width: 100%; height: 40px; }
.dk-btn.open { background: var(--hover); }
.dk-btn.primary.open { background: var(--accent-hover); }
.dk-ib { width: 34px; height: 34px; border: 0; border-radius: 6px; background: transparent; display: inline-grid; place-items: center;
  color: var(--text-2); flex: none; padding: 0; text-decoration: none; }
.dk-ib:hover:not(:disabled), .dk-ib.open { background: var(--hover); color: var(--text); }
.dk-ib.on { color: var(--accent); background: var(--accent-soft); }
.dk-ib:disabled { opacity: .35; cursor: default; }
.dk-ib.sm { width: 28px; height: 28px; }
.dk-ib.sm .i { width: 16px; height: 16px; }
.dk-link { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 0; border: 0; background: none; color: var(--accent);
  font-size: 12.5px; font-weight: 650; text-decoration: none; }
.dk-link .i { width: 14px; height: 14px; }
.dk-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.dk-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: dk-spin .8s linear infinite; flex: none; display: inline-block; }
.dk-spin.big { width: 26px; height: 26px; border-width: 2.5px; }
.dk-spin.ink { width: 13px; height: 13px; border-color: rgba(0, 0, 0, .25); border-top-color: currentColor; }
@keyframes dk-spin { to { transform: rotate(360deg); } }
.dk-meter { display: block; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.dk-meter i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .25s; }
.dk-meter.done i { background: var(--good); }
.dk-seg { display: flex; background: var(--subtle); border: 1px solid var(--line); border-radius: 6px; padding: 2px; gap: 2px; }
.dk-seg button { flex: 1; height: 26px; border: 0; border-radius: 4px; background: transparent; font-size: 12px; font-weight: 650; color: var(--muted);
  padding: 0 7px; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.dk-seg button:hover { color: var(--text); }
.dk-seg button.on { background: var(--raised); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong); }
.dk-seg button span { color: var(--faint); font-weight: 650; font-variant-numeric: tabular-nums; }
.dk-seg button span:empty { display: none; }
.dk-seg .i { width: 15px; height: 15px; }
.dk-sw { width: 32px; height: 18px; border-radius: 9px; background: var(--line-strong); position: relative; flex: none; transition: background-color .15s; }
.dk-sw::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.dk-sw.sm { width: 26px; height: 15px; }
.dk-sw.sm::after { width: 11px; height: 11px; }
input:checked + .dk-sw { background: var(--accent); }
input:checked + .dk-sw::after { transform: translateX(14px); }
input:checked + .dk-sw.sm::after { transform: translateX(11px); }
:root[data-theme="light"] .dk input:checked + .dk-sw::after { background: var(--accent-ink); }
input:focus-visible + .dk-sw { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.dk-err { margin: 10px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--bad-bg); color: var(--bad-text); border: 1px solid var(--bad-line); font-size: 12.5px; line-height: 1.4; }
/* A notice, not a failure: for example marked without AI */
.dk-warn { display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; border-radius: 6px; background: var(--warn-bg); border: 1px solid var(--warn-line);
  color: var(--warn-text); font-size: 12.5px; line-height: 1.4; }
.dk-warn > .i { width: 16px; height: 16px; color: var(--warn); margin-top: 1px; }
.dk-warn > div { flex: 1; min-width: 0; }
.dk-warn b { display: block; font-weight: 750; }
.dk-warn span { display: block; color: var(--text-2); margin-top: 1px; }
.dk-warn .dk-btn { align-self: center; }
.dk-drbody > .dk-warn { margin: 10px 16px 0; }
.dk-badge { font-size: 11px; font-weight: 750; border-radius: 4px; padding: 1px 6px; letter-spacing: .02em; }
.dk-badge.est { color: var(--warn-text); border: 1px solid var(--warn-line); background: var(--warn-bg); }

/* ---------- top bar ---------- */
.dk-bar { display: flex; align-items: center; gap: 6px; padding: 0 10px 0 8px; background: var(--chrome); border-bottom: 1px solid var(--line);
  min-width: 0; z-index: 10; position: relative; }
.dk-home .i { width: 20px; height: 20px; }
.dk-railbtn.on { color: var(--accent); }
.dk-title { min-width: 0; flex: 0 1 360px; margin: 0 4px 0 2px; }
.dk-name { font-weight: 750; font-size: 14px; letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
.dk-sub { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; line-height: 1.3; }
.dk-subt { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dk-subt:empty { display: none; }
.dk-save { border: 0; background: none; padding: 0; color: var(--faint); font-size: 12px; display: inline-flex; align-items: center; gap: 5px; flex: none; cursor: default; }
.dk-save::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.dk-save:empty { display: none; }
.dk-save[data-state="saving"]::before { animation: dk-pulse 1s ease-in-out infinite; }
.dk-save[data-state="saved"]::before { background: var(--good); opacity: 1; }
.dk-save[data-state="bad"] { color: var(--bad); font-weight: 700; cursor: pointer; }
.dk-save[data-state="bad"]:hover { text-decoration: underline; }
@keyframes dk-pulse { 50% { opacity: .2; } }
.dk-prog { display: flex; align-items: center; gap: 8px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; flex: none; margin-right: 4px; }
.dk-prog b { color: var(--text-2); font-weight: 750; }
.dk-prog .dk-meter { width: 64px; }
.dk-vsep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; flex: none; }

.dk-timer { height: 34px; padding: 0 11px 0 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--subtle); display: flex;
  align-items: center; gap: 7px; font-weight: 750; font-size: 14px; font-variant-numeric: tabular-nums; min-width: 92px; justify-content: center;
  color: var(--muted); position: relative; overflow: hidden; flex: none; }
.dk-timer::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: var(--used, 0%); background: currentColor; opacity: .55; }
.dk-timer:hover, .dk-timer.open { background: var(--hover); color: var(--text); }
.dk-timer .i { width: 16px; height: 16px; }
.dk-timer.paused { color: var(--text-2); }
.dk-timer.run { color: var(--text); border-color: var(--faint); }
.dk-timer.run .i { color: var(--accent); }
.dk-timer.low { color: var(--warn-text); border-color: var(--warn-line); background: var(--warn-bg); }
.dk-timer.low .i { color: var(--warn); }
.dk-timer.over { color: var(--bad-text); border-color: var(--bad-line); background: var(--bad-bg); }
.dk-timer.over .i { color: var(--bad); }

.dk-schemebtn { position: relative; }
.dk-dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--faint); flex: none; }
.dk-dot.on { background: var(--good); border-color: var(--good); }
.dk-dot.warn { background: var(--warn); border-color: var(--warn); }
.dk-split { display: flex; flex: none; }
.dk-split .dk-btn:first-child { border-radius: 6px 0 0 6px; padding-right: 12px; }
.dk-split .more { border-radius: 0 6px 6px 0; padding: 0 6px; border-left: 1px solid rgba(0, 0, 0, .28); }
:root[data-theme="light"] .dk-split .more { border-left-color: rgba(255, 214, 10, .35); }
.dk-markbtn { min-width: 132px; }
.dk-marklbl { display: inline-flex; align-items: baseline; gap: 7px; font-variant-numeric: tabular-nums; }
.dk-marklbl b { font-weight: 850; font-size: 14px; }
.dk-marklbl .pct { font-weight: 650; opacity: .72; font-size: 12px; }
.dk-marklbl .sh { display: none; }
.dk-markbtn.busy .dk-marklbl { align-items: center; }
.dk-examexit { border-color: var(--accent-line); }
.dk-hud { display: flex; align-items: center; margin-left: 4px; flex: none; }
.dk-hud:empty { display: none; }
.dk-hud #lockin-hud { display: flex; margin: 0; }
/* In the desk the yellow is kept for marking: Sign in is a quiet outline button here */
.dk-hud .li-login { background: transparent; color: var(--text); border: 1px solid var(--line-strong); height: 34px; }
.dk-hud .li-login:hover { background: var(--hover); border-color: var(--accent); }

/* ---------- tool dock ---------- */
.dk-dock { background: var(--rail); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 10px; gap: 2px; min-height: 0; overflow: hidden auto; z-index: 5; scrollbar-width: none; }
.dk-tools { display: flex; flex-direction: column; gap: 2px; align-items: center; }
.dk-tool { width: 52px; height: 50px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; padding: 0; position: relative; flex: none; }
.dk-tool .i { width: 20px; height: 20px; }
.dk-tool span { font-size: 10.5px; font-weight: 650; letter-spacing: .01em; line-height: 1; }
.dk-tool:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.dk-tool.on { background: var(--accent-soft); color: var(--accent); }
.dk-tool.on::before { content: ""; position: absolute; left: -6px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 2px 2px 0; background: var(--accent); }
.dk-tool:disabled { opacity: .3; cursor: default; }
.dk-tool.sq { height: 40px; }
.dk-symbtn b { font: 750 14px/1 var(--ui); }
.dk-inks { display: flex; gap: 6px; padding: 8px 0 4px; flex: none; }
.dk-ink { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; padding: 0; background: transparent; display: grid; place-items: center; }
.dk-ink::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(255, 255, 255, .22); }
.dk-ink[data-ink="blue"] { --c: #1c3899; }
.dk-ink[data-ink="black"] { --c: #17171b; }
.dk-ink.on { border-color: var(--text-2); }
.dk.t-hl .dk-inks, .dk.t-erase .dk-inks { opacity: .4; }
.dk-dsep { width: 28px; height: 1px; background: var(--line); margin: 6px 0; flex: none; }
.dk-dfill { flex: 1; min-height: 8px; }

/* ---------- the paper ---------- */
.dk-scroller { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; scrollbar-gutter: stable; }
.dk-scroller:focus { outline: none; }   /* holds focus after Esc so the arrow keys scroll the paper */
.dk-hint { position: relative; z-index: 4; display: flex; align-items: center; gap: 10px; width: fit-content; max-width: calc(100% - 32px);
  margin: 14px auto 0; padding: 6px 6px 6px 14px; background: var(--chrome); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; font-size: 12.5px; }
.dk-hint b { color: var(--text); font-weight: 700; }
.dk-sheets { --k: 1.33; --ink: #1c3899; padding: 22px 40px 104px; display: flex; flex-direction: column; align-items: center; gap: 30px; width: max-content; min-width: 100%; }
.dk.is-empty .dk-sheets, .dk.is-empty .dk-zoombar, .dk.is-empty .dk-hint { display: none; }
/* A paper that could not be opened: only the way back, the error and the LockIn HUD stay */
.dk.is-error { --rail-w: 0px !important; --dock-w: 0px !important; --dr-w: 0px !important; }
.dk.is-error :is(.dk-prog, .dk-timer, .mk, .dk-split, .dk-vsep, .dk-morebtn, .dk-railbtn, .dk-rail, .dk-dock, .dk-drawer, .dk-sub) { display: none !important; }
.dk-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 24px; color: var(--muted); }
.dk-state b { color: var(--text); font-size: 16px; }
.dk-state p { margin: 0; max-width: 380px; line-height: 1.5; }
.dk-state .dk-btn { margin-top: 6px; }
.dk-state-ic { width: 46px; height: 46px; border-radius: 8px; background: var(--bad-bg); color: var(--bad); display: grid; place-items: center; }
.dk-state-ic .i { width: 24px; height: 24px; }

.pd-sheet { scroll-margin-top: 16px; position: relative; background: #fff no-repeat center / 100% 100%; flex: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 10px 28px rgba(0, 0, 0, .35); content-visibility: auto; }
:root[data-theme="light"] .pd-sheet { box-shadow: 0 0 0 1px rgba(20, 24, 32, .08), 0 4px 18px rgba(20, 24, 32, .1); }
.pd-sheet > img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; visibility: hidden; }
.pd-sheet > img.ok { visibility: visible; }
.pd-pnum { position: absolute; right: 0; bottom: -21px; font: 650 11px/1 var(--ui); color: var(--faint); font-variant-numeric: tabular-nums; pointer-events: none; }
.pd-hl-layer, .pd-ink-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.pd-hl-layer { z-index: 1; mix-blend-mode: multiply; }
.pd-layer { position: absolute; inset: 0; z-index: 2; }
.pd-ink-layer { z-index: 3; }
.pd-ink-layer path, .pd-hl-layer path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pd-hl-layer path { stroke: #ffd400; stroke-opacity: .42; stroke-linecap: butt; }
.pd-mk-layer { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.dk.t-type .pd-layer { cursor: text; }
.dk.t-pen .pd-ink-layer, .dk.t-hl .pd-ink-layer { pointer-events: all; cursor: crosshair; touch-action: none; }
.dk.t-pen .pd-layer, .dk.t-hl .pd-layer { pointer-events: none; }
.dk.t-erase .pd-sheet { cursor: cell; touch-action: none; }

/* Answer spaces: a soft tint and a thin gold edge say "write here" without hiding the print.
   .pd-fz is the hit zone: ZONE px of clickable margin around each answer space. */
.pd-fz { position: absolute; padding: 9px; cursor: text; }
.pd-ans, .pd-nt { display: block; position: relative; border: 0; margin: 0; resize: none; overflow: hidden; outline: none;
  font-family: var(--answer); color: var(--ink); white-space: pre-wrap; overflow-wrap: break-word; background: transparent;
  -webkit-text-size-adjust: none; text-size-adjust: none; }
.pd-ans { z-index: 2; background: rgba(var(--zone-rgb), .075); border-radius: 0 2px 2px 0; transition: background-color .12s, box-shadow .12s;
  box-shadow: inset 2px 0 0 rgba(var(--zone-rgb), .75), inset 0 0 0 1px rgba(var(--zone-rgb), .2); }
.pd-ans.filled { background: rgba(var(--zone-rgb), .022); box-shadow: inset 2px 0 0 rgba(var(--zone-rgb), .25); }
.pd-fz:hover > .pd-ans { background: rgba(var(--zone-rgb), .12); box-shadow: inset 2px 0 0 rgb(var(--zone-rgb)), inset 0 0 0 1px rgba(var(--zone-rgb), .38); }
.pd-fz:hover > .pd-ans.filled { background: rgba(var(--zone-rgb), .06); box-shadow: inset 2px 0 0 rgb(var(--zone-rgb)); }
.pd-ans:focus, .pd-fz:hover > .pd-ans:focus { background: rgba(var(--zone-rgb), .045); box-shadow: inset 2px 0 0 rgb(var(--zone-rgb)), 0 0 0 1.5px rgba(var(--zone-rgb), .75); }
.pd-ans::selection, .pd-nt::selection { background: rgba(var(--zone-rgb), .3); color: inherit; }
.pd-tick { position: absolute; z-index: 2; padding: 0; border: 0; border-radius: 1px; background: rgba(var(--zone-rgb), .08);
  box-shadow: inset 0 0 0 1px rgba(var(--zone-rgb), .5); transition: background-color .12s, box-shadow .12s; }
.pd-tick::before { content: ""; position: absolute; inset: -6px; }
.pd-tick:hover { background: rgba(var(--zone-rgb), .18); box-shadow: inset 0 0 0 1.5px rgb(var(--zone-rgb)); }
.pd-tick svg { position: relative; width: 100%; height: 100%; display: block; fill: none; stroke: var(--ink); stroke-width: 1.15; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.pd-tick.on { background: transparent; box-shadow: none; }
.pd-tick.on:hover { background: rgba(var(--zone-rgb), .06); }
.pd-tick.on svg { opacity: 1; }
.pd-tick.ring { border-radius: 50%; }
.pd-tick.ring svg { display: none; }
.pd-tick.ring.on { box-shadow: inset 0 0 0 1.5px var(--ink); }
.pd-tick:focus-visible { outline: 2px solid rgb(var(--zone-rgb)); outline-offset: 1px; }
.pd-ans.flash, .pd-tick.flash { animation: dk-flash 1.6s ease-out; }
@keyframes dk-flash {
  0%, 35% { background-color: rgba(var(--zone-rgb), .3); box-shadow: inset 2px 0 0 rgb(var(--zone-rgb)), 0 0 0 2px rgb(var(--zone-rgb)); }
  100% { background-color: rgba(var(--zone-rgb), .06); }
}

/* Notes: small boxes of your own working that grow as you type */
.pd-note { position: absolute; z-index: 3; }
.pd-nt { border-radius: 2px; cursor: text; }
.pd-note:hover .pd-nt { box-shadow: 0 0 0 1px rgba(0, 0, 0, .22); }
.pd-nt:focus, .pd-note:hover .pd-nt:focus { background: rgba(255, 255, 255, .75); box-shadow: 0 0 0 1px rgba(var(--zone-rgb), .6); }
.pd-grip { position: absolute; left: -10px; top: 50%; width: 8px; height: 15px; margin-top: -7.5px; border-radius: 2px; cursor: move; opacity: 0;
  background-image: radial-gradient(circle, #6b6b70 1px, transparent 1.3px); background-size: 4px 4px; touch-action: none; }
.pd-rsz { position: absolute; right: -4px; top: 0; bottom: 0; width: 8px; cursor: ew-resize; opacity: 0; touch-action: none; }
.pd-rsz::after { content: ""; position: absolute; left: 2px; top: 50%; height: 9px; margin-top: -4.5px; width: 3px; border-radius: 1.5px;
  background: #fff; box-shadow: 0 0 0 1px rgba(var(--zone-rgb), .7); }
.pd-note:hover .pd-grip, .pd-note:focus-within .pd-grip, .pd-note.dragging .pd-grip, .pd-note:hover .pd-rsz, .pd-note.dragging .pd-rsz { opacity: 1; }
.pd-note.dragging .pd-nt { box-shadow: 0 0 0 1px rgba(var(--zone-rgb), .6); background: rgba(255, 255, 255, .75); }

.dk.t-erase .pd-fz { pointer-events: none; }
.dk.t-erase .pd-ans, .dk.t-erase .pd-nt, .dk.t-erase .pd-tick { cursor: cell; pointer-events: auto; }
.dk.t-erase .pd-tick::before { display: none; }
.dk.t-erase .pd-ans:hover, .dk.t-erase .pd-note:hover .pd-nt, .dk.t-erase .pd-tick.on:hover { box-shadow: 0 0 0 1px #d0342c; background: rgba(208, 52, 44, .07); }
.dk.t-erase .pd-grip, .dk.t-erase .pd-rsz { display: none; }

/* Examiner marks (always red, like a real examiner's pen) */
.pd-xm { position: absolute; pointer-events: auto; border: 0; padding: 0; background: transparent; cursor: pointer; color: #d0342c; }
.pd-xm.sym { width: calc(var(--k) * 12px); height: calc(var(--k) * 12px); }
.pd-xm.sym svg { width: 100%; height: 100%; display: block; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* Score badges scale with the paper but never below readable text (marks.js spaces them to match), and
   their tap area reaches past the drawn box without moving it */
.pd-xm.badge { font: 700 max(9px, calc(var(--k) * 9px))/1 Arial, Helvetica, sans-serif;
  padding: max(2px, calc(var(--k) * 2px)) max(3px, calc(var(--k) * 3px));
  border: 1px solid currentColor; border-radius: 3px; background: rgba(255, 255, 255, .94); font-variant-numeric: tabular-nums; }
.pd-xm.badge::before { content: ""; position: absolute; inset: -6px -8px; }
.pd-xm:hover { color: #9e1f19; }
.pd-xm.badge:hover { background: #fff; }

/* ---------- zoom and page bar ---------- */
.dk-zoombar { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 1px; transition: opacity .25s;
  padding: 3px; background: var(--chrome); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-pop); white-space: nowrap; }
.dk-stage.scrolling .dk-zoombar:not(:hover):not(:focus-within) { opacity: .18; }
.dk-zb { width: 32px; height: 32px; border: 0; border-radius: 5px; background: transparent; display: grid; place-items: center; color: var(--text-2); padding: 0; }
.dk-zb:hover:not(:disabled) { background: var(--hover); color: var(--text); }

/* ---------- merged with another device (account sync): floats at the top of the paper until closed ---------- */
.dk-merge { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 7; display: flex; align-items: center; gap: 10px;
  width: max-content; max-width: calc(100% - 32px); padding: 6px 6px 6px 12px; background: var(--chrome); border: 1px solid var(--line-strong);
  border-radius: 8px; box-shadow: var(--shadow-pop); font-size: 12.5px; line-height: 1.35; }
.dk-merge > .i { width: 17px; height: 17px; color: var(--accent); }
.dk-merge[data-kind="swapped"] > .i { color: var(--good); }
.dk-mtxt { min-width: 0; }
.dk-mtxt b { display: block; font-weight: 750; color: var(--text); }
.dk-mtxt small { display: block; color: var(--muted); font-size: 12px; }
.dk-merge .dk-btn { height: 30px; }
.dk.is-empty .dk-merge, .dk.exam .dk-merge { display: none !important; }
.dk-zb:disabled { opacity: .3; cursor: default; }
.dk-zb .i { width: 17px; height: 17px; }
.dk-zpage, .dk-zval { height: 32px; border: 0; border-radius: 5px; background: transparent; padding: 0 8px; font-variant-numeric: tabular-nums; font-weight: 700; }
.dk-zpage:hover, .dk-zval:hover { background: var(--hover); }
.dk-zpage { display: flex; align-items: baseline; flex-wrap: wrap; align-content: center; gap: 4px; min-width: 64px; justify-content: center; }
.dk-zpage span { color: var(--muted); font-weight: 600; }
.dk-zval { min-width: 54px; }
.dk-zsep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; }

/* ---------- rail: pages and questions ---------- */
.dk-rail { background: var(--rail); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; z-index: 6; }
.dk:not(.rail-open) .dk-rail:not(:focus-within) { visibility: hidden; }
.dk-rhead { display: flex; align-items: center; gap: 6px; padding: 10px 10px 8px; flex: none; }
.dk-rtabs { flex: 1; }
.dk-rtabs button { height: 28px; font-size: 12.5px; }
.dk-railx { display: none; }
.dk-rbody { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.dk-pagelist { padding: 4px 12px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; align-content: start; }
.dk-thumb { display: block; width: 100%; border: 0; background: transparent; padding: 0; text-align: left; border-radius: 4px; min-width: 0; }
.dk-tp { position: relative; display: block; width: 100%; aspect-ratio: var(--ar); background: #fff; border-radius: 2px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--line-strong); transition: box-shadow .12s; }
.dk-thumb img { display: block; width: 100%; height: 100%; }
.dk-thumb:hover .dk-tp { box-shadow: 0 0 0 1px var(--faint); }
.dk-thumb.on .dk-tp { box-shadow: 0 0 0 2px var(--accent); }
.dk-ta { position: absolute; right: 4px; top: 4px; font: 750 10px/1 var(--ui); padding: 3px 5px; border-radius: 3px; background: rgba(18, 18, 20, .82); color: #f3f2ee;
  font-variant-numeric: tabular-nums; }
.dk-ta:empty { display: none; }
.dk-ta.done { background: #178a4c; }
.dk-tl { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-top: 5px; font-size: 11.5px; padding: 0 1px; }
.dk-tl b { font-weight: 750; font-variant-numeric: tabular-nums; }
.dk-thumb.on .dk-tl b { color: var(--accent); }
.dk-tl span { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dk-qpane { display: flex; flex-direction: column; overflow: hidden; }
.dk-qpane[hidden] { display: none; }
.dk-qhead { padding: 2px 12px 10px; flex: none; display: grid; gap: 8px; border-bottom: 1px solid var(--line-soft); }
.dk-qsum { display: flex; align-items: center; gap: 0; color: var(--muted); font-size: 12px; min-height: 26px; font-variant-numeric: tabular-nums; }
.dk-qsum b { color: var(--text); font-weight: 800; font-size: 13px; margin-right: 4px; }
.dk-qsum b:empty { margin: 0; }
.dk-qnext { margin-left: auto; height: 26px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--raised); display: inline-flex; align-items: center;
  gap: 4px; padding: 0 7px 0 9px; font-size: 12px; font-weight: 700; color: var(--text); }
.dk-qnext:hover:not(:disabled) { border-color: var(--accent); }
.dk-qnext:disabled { opacity: .45; cursor: default; }
.dk-qnext .i { width: 14px; height: 14px; }
.dk-qlist { flex: 1; overflow-y: auto; padding: 6px 6px 24px; scrollbar-width: thin; }
/* Two lines of each question; the dot, number, marks and flag line up with the first one */
.dk-qrow { display: flex; align-items: flex-start; gap: 8px; min-height: 32px; padding: 7px 4px 7px 9px; border-radius: 5px; cursor: pointer; position: relative; line-height: 17px; }
.dk-qrow:hover { background: var(--hover); }
.dk-qrow.on { background: var(--hover); }
.dk-qrow.on::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 2px 2px 0; background: var(--accent); }
.dk-qs { width: 9px; height: 9px; margin-top: 4px; border-radius: 50%; border: 1.5px solid var(--faint); flex: none; }
.dk-qrow.done .dk-qs { background: var(--accent); border-color: var(--accent); }
.dk-qrow.nospace .dk-qs { border-style: dotted; }
.dk-qn { font-weight: 750; font-variant-numeric: tabular-nums; flex: none; min-width: 38px; font-size: 12.5px; }
.dk-qt { flex: 1; min-width: 0; overflow: hidden; white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  color: var(--muted); font-size: 12px; }
.dk-qm { flex: none; color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.dk-qm.sc { font-weight: 800; color: var(--st); }
.dk-qf { width: 24px; height: 24px; margin: -4px 0; border: 0; border-radius: 4px; background: transparent; display: grid; place-items: center; padding: 0; color: var(--faint); opacity: 0; flex: none; }
.dk-qf .i { width: 14px; height: 14px; }
.dk-qrow:hover .dk-qf, .dk-qf:focus-visible { opacity: 1; }
.dk-qf:hover { background: var(--line-strong); color: var(--text); }
.dk-qrow.flagged .dk-qf { opacity: 1; color: var(--warn); }
.dk-qrow.flagged .dk-qf .i { fill: currentColor; }
.dk-qrow.stem { min-height: 28px; padding-top: 5px; padding-bottom: 5px; margin-top: 6px; }
.dk-qrow.stem .dk-qs, .dk-qrow.stem .dk-qf { visibility: hidden; }
.dk-qrow.stem .dk-qt { color: var(--faint); -webkit-line-clamp: 1; }
.dk-qrow.stem + .dk-qrow.stem { margin-top: 0; }
.dk-qempty { padding: 18px 16px; color: var(--muted); font-size: 12.5px; text-align: center; }
.dk-qnote { padding: 10px 12px; color: var(--faint); font-size: 12px; border-top: 1px solid var(--line-soft); flex: none; line-height: 1.45; }
.dk .st-correct { --st: var(--good); }
.dk .st-partial { --st: var(--warn); }
.dk .st-wrong, .dk .st-blank { --st: var(--bad); }
.dk .st-unmarked, .dk .st-skipped { --st: var(--faint); }
/* optional questions: the choice above its first question, and the options not taken */
.dk-qchoice { display: flex; align-items: flex-start; gap: 6px; margin: 8px 4px 2px 9px; padding: 5px 8px; border-left: 2px solid var(--accent);
  color: var(--muted); font-size: 11.5px; font-weight: 600; line-height: 1.35; background: var(--hover); border-radius: 0 5px 5px 0; }
.dk-qchoice .i { width: 13px; height: 13px; flex: none; margin-top: 1px; color: var(--faint); }
.dk-qrow.spare .dk-qn, .dk-qrow.spare .dk-qt { color: var(--faint); }
.dk-qrow.spare .dk-qs { border-style: dotted; opacity: .6; }
.dk-rrow.st-skipped { opacity: .7; }
.dk-drchoice b { color: var(--text); font-weight: 600; }

/* ---------- popovers, menus, sheets ---------- */
.dk-pop { position: fixed; left: 0; top: 0; width: 290px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto;
  background: var(--chrome); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-pop); padding: 12px; z-index: 60; }
.dk-pop.wide { width: 340px; }
.dk-pophead { display: flex; align-items: center; gap: 8px; margin: -2px -4px 10px 0; min-height: 28px; }
.dk-pophead b { font-size: 14px; font-weight: 800; flex: 1; }
.dk-poptext { color: var(--muted); margin: -2px 0 12px; line-height: 1.45; }
.dk-popnote { color: var(--muted); font-size: 12px; margin: 10px 0 12px; line-height: 1.45; }
.dk-popnote.bad { color: var(--bad-text); }
.dk-popacts { display: flex; gap: 8px; margin-top: 12px; }
.dk-popacts .dk-btn { flex: 1; }
.dk-busy { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 8px 0 6px; }

.dk-pop.menu { width: 300px; padding: 5px; }
.dk-mi { display: grid; grid-template-columns: 20px 1fr; column-gap: 11px; align-items: center; width: 100%; text-align: left; border: 0; background: transparent;
  border-radius: 5px; padding: 8px 10px; text-decoration: none; color: var(--text); }
.dk-mi .i { grid-row: span 2; width: 18px; height: 18px; color: var(--muted); }
.dk-mi:hover:not(:disabled) { background: var(--hover); }
.dk-mi:hover:not(:disabled) .i { color: var(--text); }
.dk-mi b { font-weight: 700; display: block; }
.dk-mi span { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; }
.dk-mi:disabled { cursor: default; }
.dk-mi:disabled b, .dk-mi:disabled span, .dk-mi:disabled .i { color: var(--faint); }
.dk-mi.danger b, .dk-mi.danger .i { color: var(--bad); }
.dk-mi.ph, .dk-msep.ph { display: none; }
.dk-msep { display: block; height: 1px; background: var(--line); margin: 5px 6px; }
.dk-mtheme { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 41px; }
.dk-mtheme > span { color: var(--muted); font-size: 12px; font-weight: 650; }
.dk-mtheme .dk-seg { flex: 1; }
.dk-mtheme .dk-seg button { height: 26px; padding: 0 6px; }
.dk-mtheme .i { width: 13px; height: 13px; }

.dk-scheme { display: flex; gap: 11px; align-items: flex-start; padding: 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--subtle); }
.dk-scheme-ic { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; flex: none; background: var(--warn-bg); color: var(--warn); }
.dk-scheme-ic.ok { background: var(--good-bg); color: var(--good); }
.dk-scheme-ic .i { width: 17px; height: 17px; stroke-width: 2; }
.dk-scheme div { min-width: 0; }
.dk-scheme b { display: block; font-weight: 750; overflow-wrap: anywhere; line-height: 1.3; }
.dk-scheme span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.dk-scheme span.dk-scheme-note { color: var(--warn); margin-top: 5px; }
.dk-drop { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 20px 14px; border: 1.5px dashed var(--line-strong); border-radius: 8px;
  background: var(--subtle); cursor: pointer; text-align: center; transition: border-color .12s, background-color .12s; }
.dk-drop .i { width: 24px; height: 24px; color: var(--accent); margin-bottom: 4px; }
.dk-drop b { font-weight: 750; }
.dk-drop span { color: var(--muted); font-size: 12px; line-height: 1.4; max-width: 250px; }
.dk-drop u { color: var(--accent); text-underline-offset: 2px; }
.dk-drop:hover, .dk-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.dk.dropping .dk-stage::after { content: ""; position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 10px; pointer-events: none; z-index: 7; }

.dk-aitog { display: flex; gap: 11px; align-items: flex-start; padding: 10px 11px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; background: var(--subtle); }
.dk-aitog input { position: absolute; opacity: 0; pointer-events: none; }
.dk-aitog .dk-sw { margin-top: 1px; }
.dk-aitog b { display: block; font-weight: 700; }
.dk-aitog small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 2px; }
.dk-aitog.off { cursor: default; }
.dk-aitog.off b { color: var(--muted); }
.dk-aitog.compact { padding: 7px 9px; align-items: center; }
.dk-aitog.compact small { display: none; }
.dk-aitog.compact b { font-size: 12.5px; }
.dk-acct { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: var(--accent-soft); color: var(--text-2); font-size: 12px; line-height: 1.4; }
.dk-acct .i { width: 15px; height: 15px; color: var(--accent); margin-top: 1px; }
.dk-acct a { color: var(--accent); font-weight: 750; }
.dk-mstat { display: flex; align-items: baseline; gap: 6px; margin: 12px 0 2px; }
.dk-mstat b { font: 850 22px/1 var(--ui); font-stretch: 80%; font-variant-numeric: tabular-nums; }
.dk-mstat span { color: var(--muted); }
.dk-notes { margin: 8px 0 0; padding: 0 0 0 16px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.dk-notes li + li { margin-top: 4px; }

.dk-pop[data-pop="timer"] { width: 300px; }
.dk-tstate { font-size: 12px; color: var(--muted); font-weight: 650; }
.dk-tbig { font: 850 40px/1 var(--ui); font-stretch: 75%; font-variant-numeric: tabular-nums; letter-spacing: .01em; margin: 2px 0 10px; }
.dk-tbig.over { color: var(--bad); }
.dk-meter.wide { height: 5px; }
.dk-trow { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.dk-trow label { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.dk-trow input { width: 62px; height: 30px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 8px; background: var(--subtle); color: var(--text); font-variant-numeric: tabular-nums; }
.dk-trow input:focus { outline: 2px solid var(--accent-line); outline-offset: -1px; border-color: transparent; }
.dk-presets { display: flex; gap: 3px; }
.dk-presets button { height: 26px; min-width: 32px; border: 1px solid var(--line); border-radius: 4px; background: transparent; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 0 5px; font-variant-numeric: tabular-nums; }
.dk-presets button:hover { color: var(--text); border-color: var(--line-strong); }
.dk-presets button.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

.dk-pop.go { width: 360px; padding: 10px 12px; }
.dk-gorow { display: flex; align-items: center; gap: 10px; }
.dk-gorow .i { color: var(--muted); }
.dk-gorow input { flex: 1; min-width: 0; height: 36px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 10px; background: var(--subtle); color: var(--text); font-size: 14px; }
.dk-gorow input:focus { outline: 2px solid var(--accent-line); outline-offset: -1px; border-color: transparent; }
.dk-gorow span { color: var(--faint); font-size: 12px; white-space: nowrap; }
.dk-pop.go .dk-popnote { margin: 8px 0 2px; }

.dk-pop.keys { width: 640px; }
.dk-kgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; }
.dk-kgh { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin: 2px 0 6px; font-stretch: 87%; }
.dk-krow { display: grid; grid-template-columns: 104px 1fr; gap: 10px; align-items: start; padding: 5px 0; border-top: 1px solid var(--line-soft); }
.dk-kk { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; }
.dk-kk i { font-style: normal; color: var(--faint); font-size: 11px; }
.dk kbd { display: inline-block; min-width: 22px; padding: 2px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--subtle);
  font: 700 11.5px/1.3 var(--ui); text-align: center; color: var(--text); white-space: nowrap; }
.dk-kw b { display: block; font-weight: 650; font-size: 12.5px; }
.dk-kw small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.35; }

.dk-pop.fb { width: 330px; padding: 10px 12px 12px; z-index: 62; }
.dk-fbhead { display: flex; align-items: center; gap: 8px; margin: -2px -4px 8px 0; }
.dk-fbmeta { color: var(--faint); font-size: 11.5px; margin-top: 8px; }
.dk-fbmeta:empty { display: none; }

/* Phone sheets: popovers rise from the bottom */
.dk-pop.sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto !important; max-width: none; max-height: 84dvh; border-radius: 12px 12px 0 0;
  border-left: 0; border-right: 0; border-bottom: 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); animation: dk-rise .18s ease-out; }
.dk-pop.sheet::before { content: ""; position: absolute; left: 50%; top: 6px; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line-strong); }
.dk-pop.menu.sheet { padding: 16px 8px calc(10px + env(safe-area-inset-bottom)); }
.dk-pop.keys.sheet .dk-kgrid { grid-template-columns: 1fr; }
@keyframes dk-rise { from { transform: translateY(24px); opacity: .4; } }
.dk-scrim { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .5); }
.dk-scrim.below { top: var(--bar-h); }
:root[data-theme="light"] .dk-scrim { background: rgba(20, 24, 32, .3); }

/* ---------- results drawer ---------- */
.dk-drawer { background: var(--chrome); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; z-index: 6; }
.dk-drhead { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 16px; height: 48px; border-bottom: 1px solid var(--line); flex: none; }
.dk-drhead b { font-size: 15px; font-weight: 850; letter-spacing: .02em; text-transform: uppercase; font-stretch: 80%; }
.dk-drbody { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.dk-score { padding: 16px 16px 14px; border-bottom: 1px solid var(--line-soft); }
.dk-big { display: flex; align-items: baseline; gap: 7px; font-variant-numeric: tabular-nums; }
.dk-big b { font: 850 44px/.9 var(--ui); font-stretch: 72%; letter-spacing: 0; }
.dk-big span { font-size: 18px; color: var(--muted); font-weight: 700; }
.dk-big em { margin-left: auto; font-style: normal; font: 850 26px/1 var(--ui); font-stretch: 80%; color: var(--accent); }
.dk-stack { display: flex; height: 8px; border-radius: 3px; overflow: hidden; background: var(--line); margin: 14px 0 8px; gap: 2px; }
.dk-stack i { display: block; height: 100%; }
.dk-stack .ok, .dk-legend .ok { background: var(--good); }
.dk-stack .part { background: var(--warn); }
.dk-stack .lost, .dk-legend .lost { background: var(--bad); }
.dk-stack .hand, .dk-legend .hand { background: var(--faint); }
.dk-legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.dk-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dk-legend i { width: 8px; height: 8px; border-radius: 2px; }
.dk-drmeta { color: var(--faint); font-size: 12px; margin-top: 8px; }
.dk-drhand { display: flex; gap: 7px; margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.dk-drhand .i { width: 15px; height: 15px; margin-top: 1px; color: var(--faint); }
.dk-drbody > .dk-err { margin: 10px 16px 0; }
.dk-stale { display: flex; align-items: center; gap: 8px; margin: 10px 16px 0; padding: 7px 7px 7px 10px; border-radius: 6px;
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text); font-size: 12.5px; }
.dk-stale .i { width: 16px; height: 16px; color: var(--warn); }
.dk-stale span { flex: 1; }
.dk-stale[hidden] { display: none; }
.dk-drctl { display: flex; align-items: center; gap: 10px; padding: 12px 16px 8px; flex: none; position: sticky; top: 0; background: var(--chrome); z-index: 1; }
.dk-drctl .dk-seg { flex: 1; }
.dk-chk { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; cursor: pointer; font-weight: 650; }
.dk-chk input { position: absolute; opacity: 0; pointer-events: none; }
.dk-drlist { flex: 1 0 auto; padding: 2px 10px 14px; }
.dk-drnone { color: var(--faint); padding: 22px 8px; text-align: center; }
.dk-rrow { padding: 10px 10px 11px 14px; border-radius: 6px; cursor: pointer; position: relative; margin-bottom: 2px; }
.dk-rrow::before { content: ""; position: absolute; left: 4px; top: 11px; bottom: 11px; width: 3px; border-radius: 2px; background: var(--st); }
.dk-rrow:hover { background: var(--hover); }
.dk-rtop, .dk-fbhead { display: flex; align-items: center; gap: 8px; }
.dk-rq { font-weight: 800; font-variant-numeric: tabular-nums; }
.dk-rst { font-size: 12px; font-weight: 650; color: var(--st); }
.dk-rs { margin-left: auto; font-weight: 850; font-variant-numeric: tabular-nums; color: var(--st); }
.dk-lowc { font-size: 11px; font-weight: 700; color: var(--warn-text); border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: 4px; padding: 0 5px; }
.dk-rl { display: grid; grid-template-columns: 84px 1fr; gap: 8px; margin-top: 5px; font-size: 12.5px; line-height: 1.4; }
.dk-rl i { font-style: normal; color: var(--faint); font-size: 11.5px; padding-top: 1px; }
.dk-rl span { overflow-wrap: anywhere; color: var(--text); }
.dk-rfb { margin-top: 7px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.dk-pop.fb .dk-rfb { padding: 8px 10px; background: var(--subtle); border-radius: 6px; }
.dk-xslot { margin-top: 9px; }
.dk-xbtn .spin, .dk-xbtn .dk-spin { width: 12px; height: 12px; }
.dk-rex { background: var(--accent-soft); border-left: 2px solid var(--accent); border-radius: 0 6px 6px 0; padding: 8px 10px; }
.dk-rex b { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--accent); margin-bottom: 4px; font-weight: 800; }
.dk-rex b .i { width: 13px; height: 13px; }
.dk-rex p { margin: 0; white-space: pre-line; line-height: 1.5; color: var(--text); font-size: 12.5px; }
.dk-xrun { display: flex; gap: 6px; flex-wrap: wrap; }
/* AI marking is off: one line instead of an Explain button on every row */
.dk-xoff { display: flex; align-items: flex-start; gap: 7px; margin: 2px 16px 6px; padding: 7px 10px; border-radius: 6px; background: var(--subtle);
  color: var(--muted); font-size: 12px; line-height: 1.45; }
.dk-xoff > .i { width: 14px; height: 14px; margin-top: 1px; color: var(--faint); }
.dk-xoff span { flex: 1; min-width: 0; }
.dk-xoff .dk-link { margin: 0; font-weight: 700; flex: none; }
.dk-xoff.sm { margin: 9px 0 0; padding: 0; background: none; }
.dk-drfoot { border-top: 1px solid var(--line); padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: stretch; flex: none;
  position: sticky; bottom: 0; background: var(--chrome); margin-top: auto; }
.dk-drfoot .dk-aitog { flex: 1; min-width: 0; }
.dk-drfoot .dk-btn { height: auto; }
.dk-drempty { padding: 26px 18px; display: flex; flex-direction: column; gap: 12px; }
.dk-drempty-ic { width: 42px; height: 42px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.dk-drempty-ic .i { width: 22px; height: 22px; }
.dk-drempty b { font-size: 16px; font-weight: 800; }
.dk-drempty p { margin: 0; color: var(--muted); line-height: 1.5; }
.dk-drempty .dk-err, .dk-drempty .dk-acct { margin: 0; }
.dk-drbusy { padding: 40px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.dk-drbusy b { font-size: 14px; }
.dk-drbusy span { color: var(--muted); font-size: 12.5px; min-height: 18px; }
.dk-drbusy .dk-btn { margin-top: 8px; }
/* The AI is slow: a calm note, not a warning (marking carries on, and stops waiting by itself) */
.dk-slow { display: flex; align-items: flex-start; gap: 8px; max-width: 320px; margin-top: 6px; padding: 9px 11px; border-radius: 6px; text-align: left;
  background: var(--subtle); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.45; }
.dk-drbusy .dk-slow span { color: var(--text-2); min-height: 0; }
.dk-slow span { color: var(--text-2); }
.dk-slow b { color: var(--text); font-weight: 700; }
.dk-slow > .i { width: 15px; height: 15px; margin-top: 1px; color: var(--muted); }
.dk-slow.sm { max-width: none; margin-top: 7px; padding: 7px 9px; font-size: 12px; }
.dk-ind { width: 180px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-bottom: 10px; }
.dk-ind i { display: block; width: 40%; height: 100%; background: var(--accent); border-radius: 2px; animation: dk-ind 1.1s ease-in-out infinite; }
.dk-ind.det i { animation: none; transition: width .3s; }
@keyframes dk-ind { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* ---------- toast and dialog ---------- */
.dk-toast { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 80; max-width: calc(100vw - 32px); width: max-content;
  background: var(--accent); color: var(--accent-ink); font-weight: 750; padding: 9px 14px; border-radius: 6px; font-size: 13px; box-shadow: var(--shadow-pop);
  animation: dk-toast .16s ease-out; }
.dk-toast.bad { background: var(--bad); color: #121212; }
:root[data-theme="light"] .dk-toast.bad { color: #fff; }
@keyframes dk-toast { from { transform: translate(-50%, 8px); opacity: 0; } }
.dk-dialog { border: 1px solid var(--line-strong); border-radius: 10px; padding: 0; width: 420px; max-width: calc(100vw - 32px); background: var(--chrome); color: var(--text);
  box-shadow: var(--shadow-pop); font: 13px/1.45 var(--ui); }
.dk-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dk-dlg-body { display: flex; gap: 14px; padding: 20px 20px 6px; }
.dk-dlg-ic { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.dk-dlg-ic.bad { background: var(--bad-bg); color: var(--bad); }
.dk-dlg-ic .i { width: 20px; height: 20px; }
.dk-dialog h3 { margin: 2px 0 6px; font-size: 16px; font-weight: 800; }
.dk-dialog p { margin: 0; color: var(--muted); line-height: 1.5; }
.dk-dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 18px; }

/* ---------- exam mode: only the paper, the tools and the timer ---------- */
.dk.exam { --rail-w: 0px !important; --dr-w: 0px !important; }
.dk.exam .dk-rail, .dk.exam .dk-drawer, .dk.exam .dk-prog, .dk.exam .mk, .dk.exam .dk-home, .dk.exam .dk-railbtn,
.dk.exam .dk-morebtn, .dk.exam .dk-hint, .dk.exam .dk-dkeys, .dk.exam .dk-scrim, .dk.exam .dk-hud { display: none !important; }
.dk.exam .dk-bar { background: var(--rail); }
.dk.exam .dk-title { flex-basis: auto; }
.dk.exam .dk-timer { order: 5; height: 36px; font-size: 16px; min-width: 110px; }
.dk.exam .dk-examexit { order: 6; }
.dk-dex.on { color: var(--accent); background: var(--accent-soft); }

/* ---------- narrower screens ---------- */
@media (max-width: 1360px) {
  .dk-prog .dk-meter { display: none; }
  .dk-dlbtn .lbl, .dk-insbtn .lbl { display: none; }
  .dk-dlbtn, .dk-insbtn { padding: 0 9px; }
}
@media (max-width: 1180px) {
  .dk-hud { display: none; }
  .dk-schemebtn .lbl { display: none; }
  .dk-schemebtn { padding: 0 10px; }
  .dk-markbtn { min-width: 0; }
}
@media (max-width: 1060px) {
  .dk-prog, .dk-vsep { display: none; }
}
/* The rail slides over the paper */
.dk.rail-over .dk-rail { position: fixed; top: var(--bar-h); bottom: 0; left: 0; width: min(320px, 88vw); z-index: 50; transform: translateX(-104%);
  transition: transform .2s ease, visibility 0s .2s; box-shadow: var(--shadow-pop); visibility: hidden; }
.dk.rail-over.rail-open .dk-rail { transform: none; visibility: visible; transition: transform .2s ease; }
.dk.rail-over .dk-railx { display: inline-grid; }
/* The results drawer slides over the paper */
.dk.dr-over .dk-drawer { position: fixed; top: var(--bar-h); right: 0; bottom: 0; width: min(396px, 100vw); z-index: 50; box-shadow: var(--shadow-pop); animation: dk-slide .18s ease-out; }
@keyframes dk-slide { from { transform: translateX(24px); opacity: .5; } }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .dk { --bar-h: 50px; --dock-w: 0px; grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--bar-h) minmax(0, 1fr) auto;
    grid-template-areas: "bar" "stage" "dock"; }
  .dk-bar { gap: 2px; padding: 0 6px 0 4px; padding-left: max(4px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
  .dk-title { flex: 1 1 auto; margin: 0 4px 0 0; }
  .dk-name { font-size: 13.5px; }
  .dk-sub { font-size: 11.5px; }
  .dk-schemebtn, .dk-dlbtn, .dk-insbtn, .dk-vsep, .dk-prog { display: none; }
  .dk-bar .dk-sp { display: none; }
  .dk-timer { min-width: 0; padding: 0 8px; height: 34px; font-size: 13px; gap: 5px; margin-right: 2px; }
  .dk-timer .i { display: none; }
  .dk-markbtn { padding: 0 10px; min-width: 0; }
  .dk-markbtn > .i { display: none; }
  .dk-marklbl b { font-size: 13px; }
  .dk-marklbl .pct { display: none; }
  .dk-split .more { padding: 0 4px; }
  .dk-split .more .i { width: 15px; height: 15px; }
  .dk-mi.ph { display: grid; }
  .dk-msep.ph { display: block; }
  .dk-mi.nt { display: none; }
  .dk-examexit span { display: none; }
  .dk-examexit { padding: 0 9px; }

  .dk-dock { flex-direction: row; justify-content: space-between; align-items: stretch; height: calc(56px + env(safe-area-inset-bottom)); padding: 3px 4px env(safe-area-inset-bottom);
    border-right: 0; border-top: 1px solid var(--line); overflow: hidden; gap: 0; }
  .dk-tools { flex-direction: row; gap: 0; flex: 4 1 0; justify-content: space-around; }
  .dk-tool { width: auto; flex: 1 1 0; height: 50px; min-width: 0; }
  .dk-tool.sq { height: 50px; }
  .dk-tool.on::before { left: 22%; right: 22%; top: auto; bottom: -3px; width: auto; height: 3px; border-radius: 2px 2px 0 0; }
  .dk-tool[data-tool="pen"]::after { content: ""; position: absolute; top: 7px; right: calc(50% - 15px); width: 7px; height: 7px; border-radius: 50%; background: var(--pen, #1c3899);
    box-shadow: 0 0 0 1.5px var(--rail); }
  .dk-inks, .dk-dex, .dk-dkeys, .dk-dfill { display: none; }
  .dk-dsep { width: 1px; height: 26px; margin: 12px 1px; }
  .dk-dock > .dk-tool { flex: 1 1 0; }

  .dk-sheets { padding: 10px 8px 84px; gap: 26px; }
  .dk-hint { margin: 8px 8px 0; max-width: none; font-size: 12px; }
  .dk-merge { left: 8px; right: 8px; top: 8px; transform: none; width: auto; max-width: none; flex-wrap: wrap; row-gap: 6px; padding: 7px 6px 8px 10px; }
  .dk-mtxt { flex: 1 1 calc(100% - 70px); }
  .dk-merge > .i { align-self: flex-start; margin-top: 1px; }
  .dk-merge [data-merge-x] { order: 2; align-self: flex-start; margin: -2px 0 0; }
  .dk-merge .dk-btn { order: 3; margin-left: 27px; }
  .dk-zoombar { bottom: 10px; padding: 2px; }
  .dk-zb { width: 34px; height: 34px; }
  .dk-zval { min-width: 50px; padding: 0 4px; }
  .dk-zpage { min-width: 54px; padding: 0 4px; }
  .dk-toast { bottom: calc(118px + env(safe-area-inset-bottom)); }
  .dk.dr-over .dk-drawer { width: 100vw; border-left: 0; }
  .dk-pop.keys { width: auto; }
  .dk.exam .dk-dock { display: flex; }
}
/* Narrow phones: the paper's name gets the room. The timer shrinks to its clock (the time is in its
   popover; exam mode still shows it) and the mark button says just Mark. */
@media (max-width: 600px) {
  .dk-timer { width: 34px; padding: 0; gap: 0; }
  .dk-timer .i { display: block; width: 17px; height: 17px; }
  .dk-timer span { display: none; }
  .dk.exam .dk-timer { width: auto; padding: 0 10px; }
  .dk.exam .dk-timer span { display: inline; }
  .dk.exam .dk-timer .i { display: none; }
  .dk-marklbl .lg { display: none; }
  .dk-marklbl .sh { display: inline; }
  .dk-subt, .dk-nlvl { display: none; }
  .dk-name { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    font-size: 13px; line-height: 1.15; }
  .dk-sub { font-size: 11px; line-height: 1.25; margin-top: 1px; }
  .dk-sub:not(:has(.dk-save:not(:empty))) { display: none; }
}
@media (max-width: 380px) {
  .dk-tool span { font-size: 9.5px; }
  .dk-railbtn, .dk-home, .dk-morebtn { width: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .dk *, .dk *::before, .dk *::after { animation-duration: .01ms !important; transition-duration: 0s !important; transition-delay: 0s !important; }
}

/* ---------- a paper that came in through someone's link (index.js showShareNote): who shared it ----------
   Above the zoom bar on wide screens, clear of the first-visit hint at the top; at the top on phones. */
.dk-shnote { top: auto; bottom: 72px; }
@media (max-width: 760px) {
  .dk-shnote { top: 8px; bottom: auto; }
}
