/* qbank — one stylesheet for every page (home, quiz, login).
   Phone-first. Big touch targets (min 48px), no horizontal scroll, safe-area
   insets for iOS standalone mode, light and dark via prefers-color-scheme.
   No inline styles anywhere (the site's CSP blocks them) and no external
   fonts (system font stack only). */

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --surface: var(--panel); /* alias used by review-page SVG fragments */
  --text: #1a1d21;
  --muted: #5c636e;
  --border: #d8dce2;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --correct-bg: #e4f6e9;
  --correct-border: #35a35c;
  --correct-text: #14622f;
  --wrong-bg: #fbe6e6;
  --wrong-border: #d04545;
  --wrong-text: #8a1f1f;
  --flag-bg: #fff3d6;
  --flag-border: #e0a92b;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --panel: #1e232b;
    --text: #e8eaed;
    --muted: #9aa2ad;
    --border: #333a44;
    --accent: #5b8dff;
    --accent-text: #0b0e12;
    --correct-bg: #16311f;
    --correct-border: #3fae65;
    --correct-text: #8fe3ab;
    --wrong-bg: #3a1a1a;
    --wrong-border: #d76a6a;
    --wrong-text: #f0a9a9;
    --flag-bg: #3a3117;
    --flag-border: #d8ad3f;
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  overflow-x: hidden;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: calc(20px + var(--safe-top)) calc(16px + var(--safe-right)) calc(96px + var(--safe-bottom)) calc(16px + var(--safe-left));
}

h1 { font-size: 1.7rem; margin: 0.2em 0 0.1em; }
h2 { font-size: 1.3rem; margin: 1.2em 0 0.4em; }
h3 { font-size: 1.05rem; margin: 1em 0 0.3em; color: var(--muted); }
.subtitle { color: var(--muted); margin: 0 0 1.2em; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}

button {
  font-size: 1rem;
  font-family: inherit;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:hover { border-color: var(--accent); }
button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.05); }
button:disabled { opacity: 0.55; cursor: default; }

a { color: var(--accent); }

.btnrow { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.btnrow.end { margin-top: 6px; }

label.chk {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  min-height: 48px;
  cursor: pointer;
}
label.chk input { width: 22px; height: 22px; flex: none; }

.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 2px 14px;
}
.count { color: var(--muted); font-size: 0.85em; margin-left: auto; }
.toggle-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; min-height: 48px; }
.mini-btns { display: flex; gap: 8px; margin-bottom: 8px; }
.mini-btns button { min-height: 40px; padding: 6px 12px; font-size: 0.85rem; }

table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* ---------- home screen bank cards ---------- */
.bank-list { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.bank-card {
  display: block;
  width: 100%;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px 18px;
  cursor: pointer;
}
.bank-card:hover { border-color: var(--accent); }
.bank-card:active { transform: translateY(1px); }
.bank-card .bank-title { font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.bank-card .bank-desc { color: var(--muted); font-size: 0.95rem; margin: 6px 0 10px; }
.bank-card .bank-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 0.9rem; color: var(--muted); }
.bank-card .bank-meta .val { color: var(--text); font-weight: 600; }
.resume-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--flag-bg);
  border: 1px solid var(--flag-border);
  color: var(--text);
}

/* ---------- quiz screen ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 10px;
}
.topbar .section-label { font-weight: 600; color: var(--text); }
.topbar .score { margin-left: auto; }
.topbar .back { text-decoration: none; }
.progressbar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progressbar > div { height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }
.question {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 8px 0 18px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  width: 100%;
  min-height: 48px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 1.02rem;
  line-height: 1.4;
  cursor: pointer;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option .key {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; color: var(--muted);
}
.option .opttext { flex: 1; min-width: 0; }
.option.chosen-wrong { background: var(--wrong-bg); border-color: var(--wrong-border); color: var(--wrong-text); }
.option.chosen-wrong .key { background: var(--wrong-border); color: #fff; border-color: var(--wrong-border); }
.option.is-correct { background: var(--correct-bg); border-color: var(--correct-border); color: var(--correct-text); }
.option.is-correct .key { background: var(--correct-border); color: #fff; border-color: var(--correct-border); }
.option:disabled { cursor: default; }
.verdict { font-size: 1.15rem; font-weight: 700; margin: 16px 0 4px; min-height: 1.4em; }
.verdict.correct { color: var(--correct-text); }
.verdict.wrong { color: var(--wrong-text); }
.explain {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0 4px;
  font-size: 0.98rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}
.explain .lbl { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; display: block; margin-bottom: 4px; }
.explain-block {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 6px 0 2px;
  font-size: 0.92rem;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}
.flagbtn { border-color: var(--flag-border); }
.flagbtn.on { background: var(--flag-bg); border-color: var(--flag-border); color: var(--text); font-weight: 600; }
.bignum { font-size: 2.4rem; font-weight: 800; }

.missed-item, .review-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.missed-item .q, .review-item .q { font-weight: 600; margin-bottom: 6px; overflow-wrap: break-word; word-break: break-word; white-space: pre-wrap; }
.ans-line { margin: 3px 0; overflow-wrap: break-word; word-break: break-word; }
.ans-line.correct { color: var(--correct-text); }
.ans-line.wrong { color: var(--wrong-text); }
.ans-line .lbl { color: var(--muted); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.03em; margin-right: 6px; }
.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-left: 6px;
  vertical-align: middle;
}

/* "Saved session resumed. Start over" notice on the quiz screen — unobtrusive,
   sits just under the progress bar. */
.resume-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  font-size: 0.85rem;
  color: var(--muted);
  margin: -8px 0 14px;
}
.linklike {
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.linklike:hover { border: none; filter: brightness(1.05); }

/* Persistent banner shown when localStorage cannot be written on this device.
   Created from JS (no inline styles). Appears on both the home and quiz pages. */
.storage-banner {
  background: var(--flag-bg);
  border: 1px solid var(--flag-border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 14px;
  font-size: 0.92rem;
  line-height: 1.45;
}

/* results-save status card */
.save-status { font-size: 0.98rem; }
.save-status.ok { color: var(--correct-text); }
.save-status.pending { color: var(--muted); }
.save-status.err { color: var(--wrong-text); }

.footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 8px 16px calc(8px + var(--safe-bottom));
  text-align: center;
  overflow-wrap: break-word;
}
.footer kbd {
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.85em;
  margin: 0 1px;
}
.muted { color: var(--muted); }
.warn { color: var(--wrong-text); }
.hidden { display: none !important; }

/* error card, shown when a manifest or bank fails to load — never a blank page */
.error-card {
  background: var(--wrong-bg);
  border: 1px solid var(--wrong-border);
  color: var(--wrong-text);
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
}
.error-card h2 { color: var(--wrong-text); margin-top: 0; }
.error-card .btnrow button { color: var(--text); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(64px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 0.96; }

@media (max-width: 480px) {
  body { font-size: 17px; }
  .wrap { padding: calc(14px + var(--safe-top)) calc(12px + var(--safe-right)) calc(92px + var(--safe-bottom)) calc(12px + var(--safe-left)); }
  h1 { font-size: 1.45rem; }
  .question { font-size: 1.15rem; }
}

/* ---------- flagged review pages ---------- */
/* The review card (home screen extra card + the review list cards) gets an
   accent edge so it reads as a different kind of destination from a bank. */
.bank-card.review-card { border-left: 4px solid var(--accent); }

.review-nav { margin-top: -0.4em; }

/* Table of contents at the top of a built review page. */
.toc h2 { margin-top: 0; }
.toc ol { margin: 0.4em 0 0; padding-left: 1.4em; }
.toc li { margin: 4px 0; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* Each question block on a built review page is a direct child of .wrap, so
   this styling never touches the .review-item blocks reused on the quiz end
   screen (those are nested inside a .panel). */
.wrap > .review-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 16px 0;
  scroll-margin-top: 14px;
}
.review-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.review-section { font-weight: 700; color: var(--text); }
.review-q {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 10px 0 14px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}
.review-options { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.review-options li {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  overflow-wrap: break-word;
  word-break: break-word;
}
.review-options li.correct { background: var(--correct-bg); border-color: var(--correct-border); color: var(--correct-text); font-weight: 600; }
.review-options li.wrong { background: var(--wrong-bg); border-color: var(--wrong-border); color: var(--wrong-text); }
.review-answered { margin: 4px 0 12px; overflow-wrap: break-word; word-break: break-word; }
.review-answered .lbl { color: var(--muted); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.03em; margin-right: 6px; }
.review-answered.correct { color: var(--correct-text); }
.review-answered.wrong { color: var(--wrong-text); }
.explain-block .lbl { display: block; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.deep-title { color: var(--text); font-size: 1rem; margin: 16px 0 6px; }

/* The writer's deeper-dive fragment. Everything below keeps its content on the
   phone: images and SVG never overflow, tables scroll rather than blow out. */
.deep { font-size: 1rem; line-height: 1.55; overflow-wrap: break-word; word-break: break-word; }
.deep p { margin: 0.6em 0; }
.deep ul, .deep ol { padding-left: 1.4em; }
.deep li { margin: 4px 0; }
.deep figure { margin: 16px 0; }
.deep img { display: block; max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); }
.deep figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
/* Inline SVG the writers draw uses currentColor and the CSS variables directly
   (fill="var(--accent)" etc.), so a sensible default color makes it legible in
   both light and dark mode. */
.deep svg { max-width: 100%; height: auto; color: var(--text); }
.deep table { border-collapse: collapse; width: 100%; font-size: 0.9rem; margin: 12px 0; display: block; overflow-x: auto; }
.deep th, .deep td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; vertical-align: top; }
/* .deep's word-break: break-word lets a narrow column split a long word at 375 px.
   Hyphenation makes those splits land at syllables with a visible hyphen
   ("Border-line") instead of mid-letter ("Borderlin|e"), without making the
   tables wide enough to scroll sideways. */
.deep th, .deep td { -webkit-hyphens: auto; hyphens: auto; }
.deep th { color: var(--text); background: var(--bg); font-weight: 600; }

/* Pattern groups: several flagged questions that miss the same concept, built
   as one section at the top of the page (shared dive, then the questions). */
.review-part { font-size: 1.1rem; margin: 24px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.toc .toc-count { color: var(--muted); font-size: 0.88em; }
.wrap > .review-group { border-left: 4px solid var(--accent); }
.group-title { font-size: 1.2rem; margin: 10px 0 4px; overflow-wrap: break-word; word-break: break-word; }
.review-member {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 12px;
  scroll-margin-top: 14px;
}
.review-member .review-q { font-size: 1.05rem; margin: 8px 0 12px; }
/* "Question <id>" heading on each member (the shared dive refers to them by id). */
.member-title { color: var(--accent); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 4px; }
/* Members come first; the shared dive after the last member gets a rule. */
.review-member + .deep-title { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; font-size: 1.1rem; }
.group-note {
  background: var(--bg);
  border-left: 3px solid var(--flag-border);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0 2px;
  font-size: 0.95rem;
  overflow-wrap: break-word;
  word-break: break-word;
}
.group-note .lbl { display: block; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.note-body p { margin: 0.4em 0; }
.note-body svg, .note-body img { max-width: 100%; height: auto; }

.review-sources { margin: 4px 0 8px; padding-left: 1.4em; }
.review-sources li { margin: 5px 0; overflow-wrap: break-word; word-break: break-word; }
.review-credits { color: var(--muted); font-size: 0.82rem; margin: 10px 0 0; overflow-wrap: break-word; word-break: break-word; }
.review-credits .lbl { text-transform: uppercase; letter-spacing: 0.03em; margin-right: 4px; }

/* ---------- login page ---------- */
.login-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 30px 24px 26px;
  text-align: center;
}
.login-title { font-size: 1.7rem; font-weight: 800; margin: 0 0 6px; }
.login-label {
  margin-top: 18px;
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  margin-bottom: 8px;
}
.login-card input[type="password"] {
  width: 100%;
  font-family: inherit;
  font-size: 16px; /* 16px keeps iOS from zooming the field on focus */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 48px;
  padding: 13px 14px;
}
.login-card input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(47,111,237,0.2);
}
.login-btn {
  width: 100%;
  margin-top: 14px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  min-height: 48px;
  padding: 13px 14px;
}
.login-btn:active { transform: translateY(1px); }
.login-error {
  display: none;
  margin-top: 16px;
  font-size: 13px;
  color: var(--wrong-text);
  background: var(--wrong-bg);
  border: 1px solid var(--wrong-border);
  border-radius: 10px;
  padding: 10px 12px;
}
.login-error.show { display: block; }
.login-footnote { margin-top: 20px; font-size: 12px; color: var(--muted); }

/* Initial states formerly set as inline style attributes (blocked by the CSP). JS shows them with element.style.display, which the CSP allows. */
#resume-panel, #history-panel { display: none; }
#start-count { margin: 10px 0 0; }
/* Back and Next sit together on the right of their row (Flag stays on the left).
   The first auto-margin element (Back) absorbs the free space, so Next lands
   directly beside it. */
#btn-back { margin-left: auto; }
#btn-next { margin-left: auto; }

/* Copy + Build flashcard buttons on a built review page: Copy + Build flashcard
   per individual question, Build flashcard alone on each pattern-group member,
   Copy + "Mark all N" on a group, right-aligned in the .review-head row.
   A compact version of the site button, 40px touch target. */
.review-actions { margin-left: auto; align-self: center; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.review-head .copy-btn,
.review-head .fc-btn {
  min-height: 40px;
  min-width: 5.5em;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  border-color: var(--border);
  white-space: nowrap;
}
.review-head .copy-btn:active,
.review-head .fc-btn:active { transform: translateY(1px); }
.review-head .fc-btn.is-marked { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
/* A pattern group's "Mark all N" toggle (2026-10-05): outlined in the accent
   while only some of its member questions are marked. */
.review-head .fc-all[aria-pressed="mixed"] { border-color: var(--accent); }
/* The optional "what should the card test?" note (Joe, 2026-10-04): its own
   full-width line under the head row, one line until focused or filled, 16px
   text so iOS does not zoom on focus. Revealed by review-page.js. */
.fc-note { margin: 8px 0 2px; }
.fc-note[hidden] { display: none; }
.fc-note-input {
  display: block;
  width: 100%;
  min-height: 44px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.35;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  resize: vertical;
}
.fc-note-input::placeholder { color: var(--muted); opacity: 1; }
.fc-note-input:focus,
.fc-note-input.has-text { min-height: 5.5em; }
.fc-note-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.fc-note.is-marked .fc-note-input { border-color: var(--accent); }
/* Build flashcard + Copy on the quiz screen (Joe, 2026-10-06): a row under the
   explanation, shown once the question is answered. Same look as the review
   page's buttons (accent text; pressed = accent fill), at the site's 48px
   button height; side by side at 375px, wrapping if ever needed. */
.fc-row .fc-btn,
.fc-row .copy-btn {
  flex: 1 1 9em;
  min-height: 48px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.fc-row .fc-btn:active,
.fc-row .copy-btn:active { transform: translateY(1px); }
.fc-row .fc-btn.is-marked { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
/* Off-screen textarea used by the execCommand('copy') fallback. */
.copy-offscreen { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; font-size: 16px; }
/* Last-resort manual copy panel, shown only when both copy methods fail. */
.copy-panel {
  margin: 10px 0 4px;
  padding: 10px;
  border: 1px solid var(--flag-border);
  background: var(--flag-bg);
  border-radius: 10px;
}
.copy-hint { margin: 0 0 8px; font-size: 0.9rem; color: var(--text); }
.copy-text {
  display: block;
  width: 100%;
  height: 12em;
  font-family: inherit;
  font-size: 16px; /* 16px keeps iOS from zooming the field on focus */
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
}
.copy-close { margin-top: 8px; min-height: 40px; padding: 6px 14px; font-size: 0.85rem; }

/* Flashcard send bar on a built review page (created by review-page.js): fixed
   to the bottom, safe-area aware; the page gets extra bottom padding so the
   last section is never hidden behind it. */
.wrap.review-page { padding-bottom: calc(210px + var(--safe-bottom)); }
.fc-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  padding: 10px calc(16px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(16px + var(--safe-left));
}
.fc-bar-row { max-width: 820px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.fc-count { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 0.92rem; line-height: 1.3; }
.fc-send { flex: none; min-height: 44px; padding: 8px 12px; font-size: 0.88rem; }
.fc-status { max-width: 820px; margin: 6px auto 0; font-size: 0.88rem; overflow-wrap: break-word; }

/* ---------- flashcard picker (flashcards/<set>.html, built by
   scripts/build-flashcards.py, driven by flashcards.js). Prefix pk- so it
   never collides with the review page's fc- send bar. ---------- */
.wrap.pk-page { padding-bottom: calc(190px + var(--safe-bottom)); }
.pk-howto p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.pk-src-btns { margin: 10px 0 4px; }
.pk-context { margin: 6px 0 4px; }
.pk-context summary { cursor: pointer; color: var(--accent); font-size: 0.92rem; min-height: 40px; display: flex; align-items: center; }
.pk-q { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; margin: 6px 0 10px; }
.pk-q .review-q { font-size: 1rem; margin: 0 0 6px; }
.pk-key { margin: 0; color: var(--correct-text); font-weight: 600; overflow-wrap: break-word; word-break: break-word; }
.pk-key .lbl { color: var(--muted); font-weight: 400; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; margin-right: 6px; }
.pk-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0 0;
  background: var(--panel);
}
.pk-card.is-picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pk-face .lbl { display: block; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.pk-text { font-size: 1.02rem; line-height: 1.45; overflow-wrap: break-word; word-break: break-word; }
.pk-face:first-child .pk-text { font-weight: 600; }
.pk-back { border-top: 1px dashed var(--border); margin-top: 10px; padding-top: 8px; }
.pk-diagram { margin: 10px 0 0; padding: 6px; border-radius: 10px; background: var(--bg); color: var(--text); }
.pk-diagram svg { display: block; max-width: 100%; height: auto; color: var(--text); }
.pk-pick {
  display: flex; align-items: center; gap: 12px;
  margin-top: 12px;
  min-height: 52px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.pk-pick input { width: 26px; height: 26px; flex: none; margin: 0; accent-color: var(--accent); }
.pk-card.is-picked .pk-pick { border-color: var(--accent); color: var(--accent); }
.pk-sendbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  padding: 10px calc(16px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(16px + var(--safe-left));
}
.pk-sendrow { max-width: 820px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.pk-count { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 0.95rem; }
.pk-sendbar .save-status, .pk-sendbar .btnrow { max-width: 820px; margin: 6px auto 0; font-size: 0.9rem; overflow-wrap: break-word; }
