/* Shift Pearls — petite, compact, medical. No outside fonts or libraries. */
:root {
  --bg: #f6f7f8; --panel: #fff; --ink: #1d2327; --muted: #69737c; --line: #dfe3e7;
  --accent: #1f5f8b; --accent-ink: #fff; --accent-soft: #e8f0f6;
  --again: #a2432f; --again-soft: #f7ebe8; --ok: #2d6a4f; --ok-soft: #e7f2ec;
  --radius: 4px; --ease: .25s ease;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
/* colour themes: Auto follows the device; the rest are chosen in Menu → Display */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --bg: #15191c; --panel: #1d2226; --ink: #e3e7ea; --muted: #97a1a9; --line: #2e353a;
    --accent: #6fa8d0; --accent-ink: #0f1417; --accent-soft: #22303a;
    --again: #e08b78; --again-soft: #33241f; --ok: #7cc39f; --ok-soft: #1f2e27; }
}
:root[data-theme="dark"] { --bg: #15191c; --panel: #1d2226; --ink: #e3e7ea; --muted: #97a1a9; --line: #2e353a;
    --accent: #6fa8d0; --accent-ink: #0f1417; --accent-soft: #22303a;
    --again: #e08b78; --again-soft: #33241f; --ok: #7cc39f; --ok-soft: #1f2e27; }
:root[data-theme="sepia"] { --bg: #f3ecdf; --panel: #fbf6ec; --ink: #3b2f22; --muted: #7d6b57; --line: #e2d6c2;
    --accent: #7a4f24; --accent-ink: #fff; --accent-soft: #efe2cd;
    --again: #9c3b25; --again-soft: #f5e1d8; --ok: #4d6b2f; --ok-soft: #e7eed9; }
:root[data-theme="black"] { --bg: #000; --panel: #0b0b0b; --ink: #e8e8e8; --muted: #9a9a9a; --line: #262626;
    --accent: #8fb8d8; --accent-ink: #000; --accent-soft: #16222b;
    --again: #f0917d; --again-soft: #2a1612; --ok: #86cfa6; --ok-soft: #12241a; }
:root[data-theme="contrast"] { --track: #c8c8c8; --bg: #fff; --panel: #fff; --ink: #000; --muted: #333; --line: #000;
    --accent: #003f73; --accent-ink: #fff; --accent-soft: #d6e6f5;
    --again: #8a1c05; --again-soft: #fbe3dd; --ok: #0b5a2c; --ok-soft: #dcf1e4; }

/* Two-tone: question navy, answer burnt orange — told apart at a glance (also by colour-blind eyes) */
:root[data-theme="twotone"] { --bg: #f6f7f8; --panel: #fff; --ink: #1d2327; --muted: #5f6972; --line: #d5dbe0;
    --accent: #0b3a82; --accent-ink: #fff; --accent-soft: #e4ecf7;
    --again: #a2432f; --again-soft: #f7ebe8; --ok: #2d6a4f; --ok-soft: #e7f2ec;
    --q: #0b3a82; --a: #a8420a; }
:root[data-theme="twotone"] .front { font-weight: 600; }
:root[data-theme="twotone"] .back { border-top: 0; border-left: 3px solid var(--a); padding: 2px 0 2px 10px; font-weight: 500; }

/* Emphasis (Menu → Display): one look per kind of fact — doses bold, warnings red small caps,
   answer in the device's own serif, background notes italic. Sparing on purpose. */
:root[data-emph="on"] .cue-n { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
:root[data-emph="on"] .front { font-weight: 500; }   /* keep the question light so its bold numbers stand out (also in Two-tone) */
:root[data-emph="on"] .cue-w { font-weight: 700; color: var(--again); font-variant-caps: all-small-caps; letter-spacing: .03em; }
:root[data-emph="on"] .back { font-family: ui-serif, "New York", "Iowan Old Style", Georgia, serif; }
:root[data-emph="on"] .extra p { font-style: italic; }
:root[data-emph="on"] .extra b { font-style: normal; }

/* text size: --k = card text, --u = controls (grow more gently), --w = column width */
:root { --k: 1; --u: 1; --w: 1; }
:root[data-size="l"]  { --k: 1.2;  --u: 1.1;  --w: 1.1; }
:root[data-size="xl"] { --k: 1.42; --u: 1.2;  --w: 1.2; }
:root[data-size="xxl"] { --k: 1.7; --u: 1.32; --w: 1.3; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100dvh; overflow-x: hidden; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }

/* ---- gate ---- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.gate-card { width: 100%; max-width: 320px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 20px; text-align: center; }
.brand { font-weight: 600; letter-spacing: .02em; font-size: 15px; }
.sub { color: var(--muted); font-size: 12.5px; margin: 4px 0 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 34px;
  padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  color: var(--ink); text-decoration: none; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--muted); }
.btn-google { width: 100%; }

/* ---- app shell ---- */
.wrap { max-width: calc(620px * var(--w)); margin: 0 auto; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
.bar { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
  padding: 12px 0 8px; }
.bar .brand { white-space: nowrap; font-size: calc(13.5px * var(--u)); }
.count { margin-top: 6px; color: var(--muted); font-size: calc(12px * var(--u)); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter { height: 3px; background: var(--track, var(--line)); border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--ease); }

.tools { display: flex; gap: 8px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 5px 12px; font-size: calc(12.5px * var(--u)); cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.seg button:hover { color: var(--ink); }
.tool { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 5px 10px; font-size: calc(12.5px * var(--u)); cursor: pointer; color: var(--muted); }
.tool:hover { color: var(--ink); border-color: var(--muted); }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.tools .spacer { flex: 1; }

/* ---- folds: nothing opens abruptly ---- */
.fold { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--ease); }
.fold.open { grid-template-rows: 1fr; }
.fold > div { overflow: hidden; min-height: 0; }

.menu-in { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 10px; }
.menu-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hist { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: calc(12.5px * var(--u)); font-variant-numeric: tabular-nums; }
.hist th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 4px 6px 4px 0; }
.hist td { border-bottom: 1px solid var(--line); padding: 5px 6px 5px 0; white-space: nowrap; }
.hist .n { text-align: right; width: 54px; }
.hist .r { width: 44px; }
.display { display: grid; grid-template-columns: calc(58px * var(--u)) 1fr; gap: 8px 10px; align-items: center; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid var(--line); }
.display .lab { color: var(--muted); font-size: calc(12px * var(--u)); }
.display .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.menu-in .who { color: var(--muted); font-size: calc(12px * var(--u)); margin-bottom: 8px; overflow-wrap: anywhere; }
.display .sound-note { grid-column: 2; margin: 0; }
@media (max-width: 520px) { .display { grid-template-columns: 1fr; gap: 6px; } .display .lab { margin-top: 4px; } .display .sound-note { grid-column: 1; } }
.tool.sw { display: inline-flex; align-items: center; gap: 6px; }
.sw i { width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--line); display: inline-block; }

/* ---- card ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; min-height: 180px; touch-action: pan-y; user-select: text;
  transition: opacity .12s ease; }
.card.fade { opacity: 0; }
.meta { display: flex; gap: 8px; color: var(--muted); font-size: calc(11.5px * var(--u)); margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.meta .tag { border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }
.meta { align-items: center; }
.meta .spacer { flex: 1; }
.tool.mini { padding: 1px 7px; font-size: calc(11.5px * var(--u)); line-height: 1.5; }
/* the flag note box hides behind the Flag button until wanted */
.flag-in { padding: 12px 0 2px; }
.flag-in textarea { display: block; width: 100%; font: inherit; font-size: calc(13px * var(--u)); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; resize: vertical; margin-bottom: 8px; }
.flag-in textarea:focus { outline: none; border-color: var(--accent); }
.hist td.note { white-space: normal; overflow-wrap: anywhere; }
.hist td.n .tool { margin-left: 4px; }
.dim { color: var(--muted); font-size: calc(12.5px * var(--u)); }
#flagsIn p { margin: 10px 0 0; }
.meta .tag.again { color: var(--again); border-color: currentColor; }
.front { color: var(--q, var(--ink)); font-size: calc(17px * var(--k)); line-height: 1.45; font-weight: 500; overflow-wrap: anywhere; }
.back { color: var(--a, var(--ink)); font-size: calc(15.5px * var(--k)); line-height: 1.5; padding-top: 12px; margin-top: 12px; border-top: 1px dashed var(--line); overflow-wrap: anywhere; }
.extra { margin-top: 10px; font-size: calc(12.5px * var(--k)); color: var(--muted); }
.extra p { margin: 6px 0 0; }
.extra b { color: var(--ink); font-weight: 600; }
.links { margin-top: 10px; display: flex; flex-direction: column; gap: 3px; font-size: calc(12.5px * var(--k)); }
.links a { overflow-wrap: anywhere; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.act { min-height: calc(42px * var(--u)); border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel);
  cursor: pointer; font-size: calc(13.5px * var(--u)); display: flex; align-items: center; justify-content: center; gap: 8px; }
.act kbd { font: 11px/1 ui-monospace, Menlo, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 2px 4px; }
.act.again { color: var(--again); }
.act.again:hover { background: var(--again-soft); border-color: var(--again); }
.act.go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.act.go kbd { color: var(--accent-ink); border-color: currentColor; opacity: .75; }
.act.go:hover { filter: brightness(1.08); }
.act.known { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.act.known kbd { color: var(--ok); border-color: currentColor; }
.act.known:hover { filter: brightness(.97); }
.hint { text-align: center; color: var(--muted); font-size: calc(11.5px * var(--u)); margin-top: 10px; }

.notice { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; text-align: center; }
.notice h2 { font-size: calc(15px * var(--k)); margin: 0 0 6px; }
.notice p { color: var(--muted); margin: 0 0 14px; }
.notice .menu-row { justify-content: center; }
.err { color: var(--again); font-size: calc(12.5px * var(--u)); text-align: center; margin-top: 8px; min-height: 1em; }

@media (hover: none) { .act kbd, .hint .keys { display: none; } }
@media (prefers-reduced-motion: reduce) { .fold, .meter i, .card { transition: none; } }
.sw .sw-light { background: #fff; } .sw .sw-sepia { background: #f3ecdf; } .sw .sw-dark { background: #1d2226; }
.sw .sw-black { background: #000; } .sw .sw-twotone { background: linear-gradient(90deg, #0b3a82 50%, #a8420a 50%); } .sw .sw-contrast { background: #fff; border-color: #000; }
a.tool.link { text-decoration: none; }

/* ---- going back, and erasing the history ---- */
.tool[disabled] { opacity: .45; cursor: default; }
.tool[disabled]:hover { color: var(--muted); border-color: var(--line); }
.hist-foot { display: flex; justify-content: flex-end; margin-top: 10px; }
.tool.danger { color: var(--again); border-color: var(--again); }
.tool.danger:hover { background: var(--again); color: var(--again-soft); border-color: var(--again); }
.reset-in { border: 1px solid var(--again); border-radius: var(--radius); background: var(--again-soft);
  padding: 10px 12px; margin-top: 8px; }
.reset-in p { margin: 0 0 10px; font-size: calc(12.5px * var(--u)); line-height: 1.45; }
.reset-in .tool { background: var(--panel); }
