/* PaperDesk on LockIn: tokens, base elements and the shell (top bar, dialogs, menus, toasts).
   LockIn identity: warm black, one flat signal-yellow accent, Archivo (condensed caps for display).
   Dark is the default; light swaps to white with a black accent. The paper itself always stays white.
   Token names match the old static/base.css so the desk styles keep working. */
@font-face { font-family: "Archivo"; src: url("/web/assets/fonts/archivo-latin.woff2") format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }

:root {
  --desk: #0c0c0d; --chrome: #141416; --rail: #111113; --raised: #1c1c1f; --line: #26262a; --line-soft: #1f1f22; --line-strong: #37373c;
  /* --faint is still real text (card meta, counts, notes): it keeps 4.5:1 on every surface here */
  --text: #f3f2ee; --text-2: #d6d5d0; --muted: #a4a4a9; --faint: #8a8a90;
  --accent: #ffd60a; --accent-hover: #ffe14d; --accent-ink: #121212; --accent-soft: rgba(255, 214, 10, .12); --accent-line: rgba(255, 214, 10, .55);
  --good: #3fcf78; --warn: #ffb020; --bad: #ff5a4f; --ink: #1c3899;
  --good-bg: #10261a; --good-line: #1f5236;
  --subtle: #1a1a1d; --hover: #1f1f23;
  --warn-bg: #2b2108; --warn-line: #5c4610; --warn-text: #ffcf6b;
  --bad-bg: #3a1c1a; --bad-line: #6f3531; --bad-text: #ffa49b;
  --zone-rgb: 214, 160, 0;      /* answer spaces on the white paper: a gold highlighter */
  --scrim: rgba(0, 0, 0, .62);
  --shadow: 0 12px 32px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .04);
  --radius: 6px; --radius-sm: 4px; --radius-lg: 8px;
  --top-h: 52px;
  --ui: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: Consolas, "SF Mono", Menlo, "Roboto Mono", monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --desk: #eceef2; --chrome: #ffffff; --rail: #f6f7f9; --raised: #f3f4f7; --line: #e1e4ea; --line-soft: #eceef2; --line-strong: #cfd4dd;
  --text: #1b1f27; --text-2: #343a46; --muted: #4b5260; --faint: #5f6673;
  --accent: #151515; --accent-hover: #000000; --accent-ink: #ffd60a; --accent-soft: rgba(21, 21, 21, .07); --accent-line: rgba(21, 21, 21, .45);
  --good: #12773f; --warn: #885800; --bad: #c62828;
  --good-bg: #e8f5ee; --good-line: #a9d8bd;
  --subtle: #f6f7f9; --hover: #e3e6ec;
  --warn-bg: #fdf7ec; --warn-line: #e5c48f; --warn-text: #7a4c0b;
  --bad-bg: #fde8e8; --bad-line: #eab5b0; --bad-text: #8f241e;
  --scrim: rgba(20, 24, 32, .45);
  --shadow: 0 12px 32px rgba(20, 24, 32, .16), 0 0 0 1px rgba(20, 24, 32, .06);
  color-scheme: light;
}
:root[data-theme="dark"] img { color-scheme: light; }

* { box-sizing: border-box; }
/* no fixed body height: a 100% tall body is the containing block of the sticky top bar, which then
   scrolled away after one screen. The desk is position: fixed, so it needs no body height either. */
html { height: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100%; }
body.pd-on-desk { height: 100%; overflow: hidden; }
body { font: 13px/1.4 var(--ui); color: var(--text); background: var(--desk); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.display { font-stretch: 68%; font-weight: 850; text-transform: uppercase; letter-spacing: .2px; line-height: .95; }
.eyebrow { font-size: 11px; font-weight: 750; letter-spacing: 1.3px; text-transform: uppercase; font-stretch: 87%; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
kbd { font: 700 11px var(--mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; color: var(--muted); background: var(--raised); line-height: 16px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ---------- */
.btn { height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--chrome);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 650; white-space: nowrap; text-decoration: none; color: var(--text); line-height: 1; }
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 780; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad-line); }
/* dark ink on the bright dark-theme red (white on it is only 3:1); the light theme's deeper red takes white */
.btn.solid-danger { background: var(--bad); border-color: var(--bad); color: #121212; font-weight: 750; }
:root[data-theme="light"] .btn.solid-danger { color: #fff; }
.btn.solid-danger:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn.lg { height: 40px; padding: 0 16px; font-size: 14px; }
.btn.caps { text-transform: uppercase; letter-spacing: .6px; font-stretch: 87%; font-weight: 800; }
.btn .i { width: 16px; height: 16px; }
.ib { width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm); background: transparent; display: inline-grid; place-items: center; color: var(--text-2); flex: none; padding: 0; }
.ib:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.ib:disabled { opacity: .35; cursor: default; }
.ib.sm { width: 28px; height: 28px; }
.ib.sm .i { width: 16px; height: 16px; }

/* ---------- inputs ---------- */
.input, .select { height: 32px; border: 1px solid var(--line-strong); background: var(--chrome); border-radius: var(--radius-sm); padding: 0 10px; color: var(--text); outline: 0; min-width: 0; }
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.select { appearance: none; padding-right: 26px; cursor: pointer; font-weight: 600;
  background: var(--chrome) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a4a4a9' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 8px center / 12px no-repeat; }
:root[data-theme="light"] .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234b5260' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.select option { background: var(--chrome); color: var(--text); }

.pbar { display: inline-block; vertical-align: middle; width: 72px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; flex: none; }
.pbar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .2s; }
.pbar.done i { background: var(--good); }

.tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 3px; font-size: 11px; font-weight: 750; white-space: nowrap;
  border: 1px solid var(--line-strong); color: var(--text-2); background: transparent; }
.tag .i { width: 12px; height: 12px; stroke-width: 2.4; }
.tag.good { color: var(--good); border-color: var(--good-line); background: var(--good-bg); }
.tag.warn { color: var(--warn-text); border-color: var(--warn-line); background: var(--warn-bg); }
.tag.bad { color: var(--bad-text); border-color: var(--bad-line); background: var(--bad-bg); }
.tag.solid { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.good-t { color: var(--good); } .warn-t { color: var(--warn); } .bad-t { color: var(--bad); }

.skel { background: var(--subtle); border-radius: var(--radius-sm); animation: pd-skel 1.3s ease-in-out infinite; }
@keyframes pd-skel { 50% { opacity: .5; } }

/* ---------- shell ---------- */
.pd-top { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 6px; padding: 0 14px 0 8px;
  background: var(--chrome); border-bottom: 1px solid var(--line); }
.pd-back { display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 0 8px 0 4px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 650; font-size: 13px; text-decoration: none; white-space: nowrap; }
.pd-back:hover { color: var(--text); background: var(--hover); }
.pd-back .i { width: 16px; height: 16px; }
.pd-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px 0 2px; flex: none; }
.pd-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; margin-right: 14px; flex: none; }
.pd-mark { width: 26px; height: 26px; border-radius: var(--radius-sm); background: var(--accent); display: grid; place-items: center; flex: none; }
.pd-mark svg { width: 15px; height: 15px; fill: none; stroke: var(--accent-ink); stroke-width: 2.4; stroke-linecap: round; }
.pd-word { font-stretch: 62%; font-weight: 900; font-size: 23px; line-height: 1; letter-spacing: .4px; text-transform: uppercase; }
.pd-nav { display: flex; align-items: stretch; height: 100%; gap: 2px; }
.pd-nav a { display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; color: var(--muted); font-weight: 700; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13px; }
.pd-nav a:hover { color: var(--text); }
.pd-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.pd-nav .i { width: 16px; height: 16px; }
.pd-nav .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--raised); color: var(--muted); font-size: 11px; font-weight: 750; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.pd-grow { flex: 1; min-width: 0; }
.pd-sync { display: inline-flex; align-items: center; gap: 6px; color: var(--faint); font-size: 12px; font-weight: 600; white-space: nowrap; margin-right: 4px; }
.pd-sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.pd-sync.ok .dot { background: var(--good); }
.pd-sync.busy .dot { background: var(--accent); animation: pd-pulse 1s ease-in-out infinite; }
.pd-sync.bad .dot { background: var(--warn); }
@keyframes pd-pulse { 50% { opacity: .35; } }
#lockin-hud { display: inline-flex; align-items: center; margin-left: 6px; min-height: 28px; }
.li-hud { display: inline-flex; align-items: center; gap: 8px; }
.li-sparks { display: inline-flex; align-items: center; gap: 6px; background: #ffd60a; color: #121212; border-radius: var(--radius-sm); padding: 5px 9px 5px 7px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; font-size: 12.5px; }
.li-sparks svg { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.li-sparks.bump { animation: li-bump .4s ease; }
@keyframes li-bump { 30% { transform: scale(1.12); } }
.li-user { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 650; text-decoration: none; }
.li-user > span:last-child { display: none; }
.li-avatar { width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--raised); border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 13px; font-weight: 800; text-transform: uppercase; }
.li-user:hover .li-avatar { border-color: var(--accent); }
.li-login { display: inline-flex; align-items: center; height: 30px; background: var(--accent); color: var(--accent-ink); font-weight: 800; padding: 0 12px; border-radius: var(--radius-sm); font-size: 12.5px; text-decoration: none; text-transform: uppercase; letter-spacing: .5px; font-stretch: 87%; white-space: nowrap; }
.li-login:hover { background: var(--accent-hover); }
#li-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px); background: #ffd60a; color: #121212; font-size: 13px; font-weight: 750; padding: 10px 16px; border-radius: var(--radius-sm); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 1000; }
#li-toast.show { opacity: 1; transform: translate(-50%, 0); }

.pd-view { min-height: calc(100vh - var(--top-h)); }
body.pd-on-desk .pd-top, body.pd-on-desk .pd-view { display: none; }
#pd-desk { display: none; }
body.pd-on-desk #pd-desk { display: block; }

/* start-up / failure screen */
.pd-fatal { max-width: 460px; margin: 12vh auto 0; padding: 24px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.pd-fatal h1 { margin: 0; font-size: 30px; }
.pd-fatal p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.pd-fatal .acts { display: flex; gap: 8px; margin-top: 6px; }

/* ---------- toasts ---------- */
.pd-toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1100; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.pd-toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; padding: 9px 10px 9px 14px; border-radius: var(--radius-sm); background: #ffd60a; color: #121212;
  font-weight: 700; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); animation: pd-toast-in .16s ease-out; }
.pd-toast.bad { background: #ff5a4f; color: #121212; }
.pd-toast.warn { background: #ffb020; color: #121212; }
.pd-toast.info { background: var(--text); color: var(--desk); }
.pd-toast .msg { line-height: 1.35; }
.pd-toast button { border: 0; background: transparent; color: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 2px; padding: 2px 4px; white-space: nowrap; }
.pd-toast .x { width: 22px; height: 22px; display: grid; place-items: center; text-decoration: none; opacity: .7; border-radius: 3px; }
.pd-toast .x:hover { opacity: 1; background: rgba(0, 0, 0, .1); }
.pd-toast .x .i { width: 14px; height: 14px; stroke-width: 2.2; }
.pd-toast.out { opacity: 0; transform: translateY(6px); transition: opacity .15s, transform .15s; }
@keyframes pd-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- dialogs ---------- */
.pd-dlg { border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: 0; background: var(--chrome); color: var(--text); width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.pd-dlg::backdrop { background: var(--scrim); }
.pd-dlg[open] { animation: pd-dlg-in .14s ease-out; }
@keyframes pd-dlg-in { from { opacity: 0; transform: translateY(6px) scale(.985); } }
.pd-dlg form { margin: 0; }
.pd-dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 18px 0; }
.pd-dlg-head .badge { width: 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.pd-dlg-head .badge.danger { background: var(--bad-bg); color: var(--bad); }
.pd-dlg-head h3 { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.3; }
.pd-dlg-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.pd-dlg-body { padding: 14px 18px 0; }
.pd-dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 18px; }

/* ---------- popover menus ---------- */
.pd-menu { position: fixed; z-index: 1050; min-width: 210px; max-width: calc(100vw - 16px); padding: 5px; border-radius: var(--radius); background: var(--chrome); border: 1px solid var(--line-strong); box-shadow: var(--shadow); animation: pd-menu-in .1s ease-out; }
@keyframes pd-menu-in { from { opacity: 0; transform: translateY(-3px); } }
.pd-menu button, .pd-menu a { width: 100%; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); font-weight: 600; text-align: left; text-decoration: none; white-space: nowrap; }
.pd-menu button:hover:not(:disabled), .pd-menu button:focus-visible, .pd-menu a:hover, .pd-menu a:focus-visible { background: var(--hover); color: var(--text); outline: 0; }
.pd-menu button:disabled { opacity: .45; cursor: default; }
.pd-menu .i { width: 16px; height: 16px; color: var(--muted); }
.pd-menu .danger, .pd-menu .danger .i { color: var(--bad); }
.pd-menu .hint { margin-left: auto; color: var(--faint); font-size: 11.5px; font-weight: 600; padding-left: 12px; }
.pd-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }
.pd-menu .label { padding: 6px 10px 4px; font-size: 10.5px; font-weight: 750; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); }

/* ---------- phone ---------- */
@media (max-width: 720px) {
  .pd-top { padding: 0 8px 0 4px; gap: 2px; }
  .pd-back span, .pd-sync .txt { display: none; }
  .pd-back { padding: 0 4px; }
  .pd-sep { margin: 0 6px 0 0; }
  .pd-brand { margin-right: 6px; gap: 7px; }
  .pd-word { font-size: 20px; }
  .pd-nav a { padding: 0 9px; }
  .pd-nav .lbl-long { display: none; }
}
@media (max-width: 420px) {
  .pd-word { display: none; }
  .pd-nav a .i { display: none; }
  .pd-sync { display: none; }
  /* signed in, the LockIn HUD (Sparks + avatar) needs the room: no gaps to spare at 360 px */
  .pd-sep { display: none; }
  .pd-brand { margin-right: 2px; }
  .pd-nav a { padding: 0 7px; gap: 5px; }
  #lockin-hud { margin-left: 2px; }
  .li-hud { gap: 6px; }
  .li-sparks { padding: 5px 7px 5px 6px; gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  /* transitions off outright: a .01ms duration on every element turns on transitions of every property (the
     initial transition-property is all), so sizes read straight after a change came back as the old ones */
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: 0s !important; transition-delay: 0s !important; }
}
