/* ─────────────────────────────────────────────────────────────
   QSets — "Red Letter" theme
   Warm paper, ink, and a single oxblood accent, after the red
   lettering of a study Bible. Serif for reading, sans for controls.
   Fonts are system stacks: the CSP only allows same-origin fonts.
   ───────────────────────────────────────────────────────────── */

:root {
  /* Follows the device setting; the theme menu pins it with data-theme (see theme.js). */
  color-scheme: light dark;

  --paper: light-dark(#f3ede2, #0b0d12);
  --sheet: light-dark(#fffdf8, #14171e);
  --sheet-2: light-dark(#eee7db, #1c2029);
  --ink: light-dark(#241f1a, #f1eee7);
  --ink-2: light-dark(#4a423a, #d0c9bc);
  --muted: light-dark(#6f665b, #a5a5a5);
  --rule: light-dark(#e1d8c9, #292e38);
  --rule-strong: light-dark(#c9bda9, #3f4653);
  --accent: light-dark(#922d2b, #e58a72);
  --accent-hover: light-dark(#75201f, #f0a18b);
  --accent-tint: light-dark(#f5e4dc, #392522);
  --on-accent: light-dark(#fffdf8, #171310);
  --gold: light-dark(#8a6a25, #d8b36b);
  --ok: light-dark(#2f6b3f, #93c99f);
  --ok-tint: light-dark(#e5f0e4, #1e2d21);
  --danger: light-dark(#b3261e, #f28b7d);
  --danger-tint: light-dark(#fbe6e3, #3b211d);
  --focus: light-dark(#c0573f, #f09b8c);
  --shadow: 0 1px 2px light-dark(rgba(60, 40, 20, 0.08), rgba(0, 0, 0, 0.36)),
    0 18px 44px -20px light-dark(rgba(60, 40, 20, 0.28), rgba(0, 0, 0, 0.82));

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --measure: 1040px;

  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

[hidden] { display: none !important; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 12% -8%, light-dark(rgba(174, 119, 76, 0.13), rgba(123, 68, 52, 0.17)), transparent 42%),
    radial-gradient(ellipse at 92% 28%, light-dark(rgba(126, 86, 45, 0.07), rgba(62, 91, 151, 0.2)), transparent 38%),
    repeating-linear-gradient(117deg, light-dark(rgba(92, 63, 38, 0.012), rgba(230, 220, 203, 0.012)) 0, light-dark(rgba(92, 63, 38, 0.012), rgba(230, 220, 203, 0.012)) 1px, transparent 1px, transparent 5px);
  color: var(--ink);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -18%;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse at 22% 36%, light-dark(rgba(155, 99, 59, 0.065), rgba(188, 75, 55, 0.16)), transparent 39%),
    radial-gradient(ellipse at 78% 68%, light-dark(rgba(91, 105, 137, 0.045), rgba(56, 99, 184, 0.26)), transparent 45%),
    radial-gradient(ellipse at 54% 8%, light-dark(rgba(202, 164, 109, 0.035), rgba(138, 104, 169, 0.075)), transparent 35%);
  background-size: 145% 145%, 155% 155%, 135% 135%;
  background-position: 0% 0%, 100% 100%, 55% 0%;
  transform-origin: center;
}

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

p { margin: 0; }

/* ── Header ── */
.site-header {
  background: var(--sheet);
  border-bottom: 1px solid var(--rule);
}

.site-header-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.7rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}

.brand:hover { color: var(--ink); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1;
}

.brand-name {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.site-nav, .account-nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: 0.9rem;
}

.site-nav a {
  color: var(--ink-2);
  text-decoration: none;
}

.site-nav a:hover { color: var(--accent); }

.account-nav {
  padding-left: 1.25rem;
  border-left: 1px solid var(--rule);
  gap: 0.6rem;
}

.account-nav a.nav-cta {
  color: var(--on-accent);
  background: var(--accent);
  padding: 0.35em 0.95em;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
}

.account-nav a.nav-cta:hover { background: var(--accent-hover); color: var(--on-accent); }

/* Light/dark button for visitors who are not signed in (signed-in users have it in the menu). */
.theme-button {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
}

.theme-button:hover { background: var(--sheet-2); color: var(--accent); }
.theme-button .icon-sun { display: none; }
.theme-button[aria-pressed="true"] .icon-sun { display: block; }
.theme-button[aria-pressed="true"] .icon-moon { display: none; }

/* ── User menu ── */
.user-menu { position: relative; }

.user-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.25rem 0.55rem 0.25rem 0.3rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.9rem;
}

.user-menu-button:hover,
.user-menu-button[aria-expanded="true"] { background: var(--sheet-2); border-color: var(--rule); }

.user-avatar {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
}

.user-avatar > span {
  text-box: trim-both cap alphabetic;
}

.user-name {
  font-weight: 600;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-button .chevron { color: var(--muted); transition: transform 0.15s; }
.user-menu-button[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 20;
  min-width: 15rem;
  padding: 0.4rem;
  background: var(--sheet);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 18px 40px -16px rgba(0, 0, 0, 0.35);
  animation: rise 0.14s ease-out;
}

.user-menu-panel[hidden] { display: none; }

.user-menu-head {
  padding: 0.55rem 0.7rem 0.6rem;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.8rem;
  color: var(--muted);
}

.user-menu-head strong {
  display: block;
  color: var(--ink);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover { background: var(--sheet-2); color: var(--ink); }
.menu-item:focus-visible { outline-offset: -2px; }

.menu-sep { height: 1px; margin: 0.3rem 0; background: var(--rule); }

.menu-item.menu-danger:hover { background: var(--danger-tint); color: var(--danger); }

/* The dark-mode row is a label wrapping a switch, so the whole row is clickable. */
.theme-switch { margin-bottom: 0; user-select: none; }

/* ── Footer ── */
.site-footer {
  margin-top: auto;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
}

.site-footer a { color: var(--ink-2); }
.site-footer a:hover { color: var(--accent); }

/* ── Layout ── */
main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

.panel {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2.25rem;
}

/* ── Typography ── */
.page-intro { margin-bottom: 1.75rem; max-width: 40rem; }

.eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.page-title {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.1;
  font-weight: 700;
  margin: 0 0 0.6rem;
  letter-spacing: -0.01em;
}

.lede {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--ink-2);
}

h2 {
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 1.25rem;
}

h3 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 2rem 0 0.85rem;
  color: var(--ink);
}

h3:first-child { margin-top: 0; }

.card-sub {
  color: var(--muted);
  margin: -0.75rem 0 1.5rem;
}

/* ── Stepper ── */
.stepper {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  padding: 0;
  counter-reset: none;
}

.stepper li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0 0.7rem;
  border-top: 3px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.stepper-num {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  border: 1.5px solid var(--rule-strong);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.stepper li.done { border-top-color: var(--ink-2); color: var(--ink-2); }
.stepper li.done .stepper-num { border-color: var(--ink-2); background: var(--ink-2); color: var(--sheet); }

.stepper li[aria-current="step"] { border-top-color: var(--accent); color: var(--ink); }
.stepper li[aria-current="step"] .stepper-num { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

/* ── Wizard ── */
.wizard-step { display: none; }
.wizard-step.active { display: block; animation: rise 0.22s ease-out; }

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

/* ── Buttons ── */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  vertical-align: middle;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.55em 1.15em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-strong);
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

button:hover, .btn:hover { border-color: var(--ink-2); color: var(--ink); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:disabled:hover { border-color: var(--rule-strong); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  padding: 0.6em 1.5em;
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-primary:disabled:hover { background: var(--accent); border-color: var(--accent); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
  padding-left: 0.6em;
  padding-right: 0.6em;
}

.btn-ghost:hover { color: var(--accent); border-color: transparent; background: var(--accent-tint); }

.btn-icon {
  background: transparent;
  border: none;
  padding: 0.3em 0.45em;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--muted);
  border-radius: var(--radius-sm);
}

.btn-icon:hover { color: var(--ink); background: var(--sheet-2); }
.btn-icon.danger:hover { color: var(--danger); background: var(--danger-tint); }

/* ── Forms ── */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 0.35rem;
}

.form-group { margin-bottom: 1.25rem; }

input[type="text"],
input:not([type]),
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.55em 0.75em;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.95rem;
  background: var(--sheet);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="file"] {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink-2);
}

input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  margin-right: 0.75rem;
  padding: 0.45em 0.9em;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

input::placeholder { color: var(--muted); opacity: 0.8; }
textarea { resize: vertical; }
fieldset { min-width: 0; }

input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  cursor: pointer;
}

.form-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Radio choices as selectable cards */
.radio-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.radio-option:hover { border-color: var(--ink-2); }
.radio-option:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }

input[type="radio"] {
  appearance: none;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  border: 1.5px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--sheet);
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

input[type="radio"]::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.12s ease-out;
}

input[type="radio"]:checked { border-color: var(--accent); }
input[type="radio"]:checked::after { transform: scale(1); }

.radio-label { user-select: none; }

.option-section { margin: 0 0 1.5rem; padding: 1.25rem; border: 1px solid var(--rule); border-radius: var(--radius); }
.option-section legend { padding: 0 0.5rem; color: var(--ink-2); font-size: 0.85rem; font-weight: 600; }
.option-section .form-group { margin-bottom: 0; }
#step-3 > #customOptions { margin: 0 0 1.5rem; }

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

.data-table th {
  text-align: left;
  padding: 0.55rem 0.75rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1.5px solid var(--ink-2);
  white-space: nowrap;
}

.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

.data-table tbody tr { transition: background-color 0.12s; }
.data-table tbody tr:hover { background: var(--sheet-2); }

.data-table .clickable { cursor: pointer; }

.data-table .clickable td:first-child {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
}

.data-table .row-selected,
.data-table .row-selected:hover {
  background: var(--accent-tint);
  box-shadow: inset 3px 0 0 var(--accent);
}

.data-table input[type="number"] {
  width: 5rem;
  padding: 0.3em 0.5em;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.data-table input[type="text"],
.data-table input[type="email"],
.data-table input[type="password"],
.data-table select {
  padding: 0.3em 0.5em;
  font-size: 0.9rem;
}

.data-table input:disabled { opacity: 0.45; }

/* Wide tables (audit log) scroll inside the panel instead of the page. */
/* Tables never push past their panel: they scroll inside it if they cannot fit. */
#audit-table, #users-table, #pools-table, #tiers-table,
#pool-section, #bookSelection { overflow-x: auto; }

/* ── Options grid ── */
.editor-question {
  min-width: 0;
  margin: 0 0 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}

.editor-question legend { padding: 0 0.5rem; font-weight: 600; font-size: 0.9rem; }
.editor-question-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.editor-question-fields .form-group { margin: 0; min-width: 0; }
.editor-field-question, .editor-field-answer { grid-column: 1 / -1; }
.editor-question textarea { width: 100%; font: inherit; }
.question-actions { display: flex; justify-content: flex-end; margin-top: 0.75rem; }
.btn-danger, .btn-danger:hover { color: var(--danger); }
.pool-editor-page { max-width: 960px; }
.form-section { padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--rule); }
.form-section .form-group { margin: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.section-heading h2, .section-heading h3, .section-heading p { margin: 0; }
#editorStatus:empty { display: none; }
#editorStatus:not(:empty) { padding: 0.85rem 1rem; margin-bottom: 1rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--sheet); }
#editorStatus.error { color: var(--danger); border-color: var(--danger); }
#editorStatus.success { color: var(--ok); }
#editorFields { border: 0; padding: 0; margin: 0; min-width: 0; }

.study-page { max-width: 880px; }
.study-page [hidden] { display: none; }
.study-page .page-intro { margin-bottom: 1.25rem; }
.study-fieldset {
  min-width: 0;
  margin: 0 0 1.5rem;
  padding: 0;
  border: 0;
}
.study-fieldset legend { margin-bottom: 0.75rem; font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.study-passage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--sheet-2);
}

.study-passage + .study-passage { margin-top: 0.5rem; }
.study-passage label { margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.study-passage label:first-child { margin-right: auto; }
.study-passage input[type="number"] { width: 5rem; }
#studyTypes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem 1rem; }
#studyTypes label { display: flex; align-items: center; gap: 0.6rem; margin: 0; padding: 0.5rem 0; font-weight: 500; }
#studyTypes input { flex-shrink: 0; }
.study-count { max-width: 10rem; }
#studySetupStatus:empty, #studyExpired:empty { display: none; }
#studySetupStatus:not(:empty) { margin-bottom: 1rem; }
.study-question-bar, .study-feedback-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.study-question-bar { margin-bottom: 1.5rem; color: var(--muted); font-size: 0.9rem; }
#studyTimer {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
#studyTimer.study-time-expired, .study-time-expired, .study-expired { color: var(--danger); }
.study-expired { margin: -0.75rem 0 1rem; font-size: 0.85rem; }
#studyPrompt { font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.4; margin-bottom: 1.5rem; overflow-wrap: anywhere; }
#studyAnswer { width: 100%; font: inherit; resize: vertical; min-height: 7rem; }
.study-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.study-feedback-bar { margin-bottom: 1rem; flex-wrap: wrap; }
#studyAssessment { font-weight: 600; }
#studyTiming { font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.study-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.study-answer-card { padding: 1rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--sheet-2); }
.study-answer-card h3 { margin: 0 0 0.65rem; font: 600 0.8rem var(--sans); color: var(--muted); }
.study-comparison:has(#studySubmittedCard[hidden]) { grid-template-columns: 1fr; }
#studyReference { margin-top: 0.75rem; color: var(--muted); font-size: 0.85rem; }
#studyStats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin: 1.5rem 0 2rem; }
#studyStats > div { padding: 1rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--sheet-2); }
#studyStats dt { color: var(--muted); font-size: 0.8rem; }
#studyStats dd { margin: 0.4rem 0 0; font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
#studyStats > div:nth-child(-n+2) dd { color: var(--accent); }
#studySummaryText { color: var(--muted); font-size: 0.9rem; }
#studyExpected, #studySubmitted { white-space: pre-wrap; overflow-wrap: anywhere; }
#studyFinish { margin-top: 1.75rem; color: var(--muted); }

@media (max-width: 600px) {
  .study-comparison { grid-template-columns: 1fr; }
  .study-passage { gap: 0.65rem; }
  .study-passage label:first-child { flex-basis: 100%; }
  .study-passage input[type="number"] { width: 4.5rem; }
  .study-feedback-bar { gap: 0.5rem; }
}

.csv-format-help {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.csv-format-help summary { cursor: pointer; }
.csv-format-help pre { overflow-x: auto; }

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 1.75rem;
}

.options-grid .form-group { margin-bottom: 0; }

#customOptions {
  margin: 1.5rem 0 0;
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}

#customOptions p {
  font-size: 0.9rem;
  color: var(--muted);
}

.custom-availability { color: var(--muted); }
.custom-availability.over-limit { color: var(--danger); font-weight: 600; }
#customCounts input[aria-invalid="true"] { border-color: var(--danger); }

#generationError {
  width: min(28rem, calc(100% - 2rem));
  max-height: 80vh;
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow);
}

#generationError::backdrop { background: rgba(0, 0, 0, 0.4); }
#generationError h2 { font-size: 1.25rem; }
#generationError form { text-align: right; }

/* ── Messages ── */
.msg-info {
  color: var(--muted);
  padding: 1.5rem 1rem;
  text-align: center;
  font-style: italic;
  font-family: var(--serif);
}

.msg-success, .msg-error {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  margin: 0 0 1rem;
  border-left: 3px solid;
  font-size: 0.93rem;
}

.msg-success { color: var(--ok); background: var(--ok-tint); }
.msg-error { color: var(--danger); background: var(--danger-tint); }

#generateStatus {
  margin-top: 0.85rem;
  text-align: right;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ── Results ── */
.results-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.results-header h2 { margin: 0; }

/* Show-answers switch */
.toggle-answers {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.toggle-answers input[type="checkbox"],
.theme-switch input[type="checkbox"] {
  appearance: none;
  width: 2.3rem;
  height: 1.3rem;
  border-radius: 999px;
  background: var(--rule-strong);
  position: relative;
  transition: background-color 0.15s;
}

.toggle-answers input[type="checkbox"]::after,
.theme-switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--sheet);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease-out;
}

.toggle-answers input[type="checkbox"]:checked,
.theme-switch input[type="checkbox"]:checked { background: var(--accent); }

.toggle-answers input[type="checkbox"]:checked::after,
.theme-switch input[type="checkbox"]:checked::after { transform: translateX(1rem); }

.set-source {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.type-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: 1.5rem;
  background: var(--sheet-2);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--muted);
}

.type-legend b { color: var(--accent); font-family: var(--serif); margin-right: 0.15rem; }

.question-set { margin-bottom: 2.25rem; }

.set-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
  border-bottom: 2px solid var(--ink);
}

.set-heading h3 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.set-count {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.question-list { list-style: none; margin: 0; padding: 0; }

.question-item {
  display: grid;
  grid-template-columns: 2.25rem 1.6rem 1fr;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid var(--rule);
}

.question-num {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  text-align: right;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums lining-nums;
}

.question-type {
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 4px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
  align-self: start;
  margin-top: 0.1rem;
  cursor: help;
}

.question-body {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.5;
}

.question-answer {
  display: none;
  margin-top: 0.3rem;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1rem;
}

.answers-visible .question-answer { display: block; }

.question-ref {
  margin-left: 0.4rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.results-toolbar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.25rem 0 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.btn-download:hover { border-color: var(--accent); color: var(--accent); }
.btn-download svg { flex-shrink: 0; }

/* ── Sign-in and account cards ── */
.login-container {
  max-width: 26rem;
  margin: 1.5rem auto 0;
  padding: 2.25rem;
}

.login-container h2 { font-size: 1.85rem; }

.login-form { display: flex; flex-direction: column; }
.login-button { width: 100%; margin-top: 0.5rem; padding: 0.75em; }

.login-status {
  margin-top: 1rem;
  font-size: 0.92rem;
  text-align: center;
  color: var(--muted);
}

.login-status:empty { display: none; }
.login-status.error { color: var(--danger); }
.login-status.success { color: var(--ok); }

.login-form .form-hint { text-align: center; margin-top: 1rem; }

.account-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; align-items: start; }
.settings-card { min-width: 0; }
.settings-card .form-hint { text-align: left; }
.settings-card .card-sub { overflow-wrap: anywhere; }
.status-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--sheet-2); color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.status-badge.verified { color: var(--ok); background: var(--ok-tint); }

/* ── Admin ── */
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: -0.5rem 0 1.75rem;
  border-bottom: 1px solid var(--rule);
}

.admin-tab {
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
  padding: 0.7em 1em;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
}

.admin-tab:hover { color: var(--ink); border-bottom-color: var(--rule-strong); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; animation: rise 0.22s ease-out; }

.management-create { margin-bottom: 1.75rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet-2); }
.management-create > summary { padding: 1rem 1.25rem; font-weight: 600; cursor: pointer; }
.management-create[open] > summary { border-bottom: 1px solid var(--rule); }
.management-create .create-form { background: transparent; margin: 0; }
.management-create > .csv-format-help { margin: 0 1.25rem 1.25rem; }
.management-create > [role="status"]:not(:empty) { margin: 0 1.25rem 1rem; }
.table-scroll { overflow-x: auto; }
.table-scroll:focus-visible { outline-offset: 4px; }
.admin-panel { min-width: 0; }
.admin-panel .data-table .admin-actions { min-width: 7rem; }
.admin-panel .data-table input[type="text"], .admin-panel .data-table input[type="email"] { min-width: 9rem; }
.admin-panel .data-table select { min-width: 7rem; }
#pools-table .data-table { min-width: 44rem; }
#users-table .data-table { min-width: 46rem; }
#tiers-table .data-table { min-width: 28rem; }
#audit-table .data-table { min-width: 58rem; }
#audit-table td:nth-child(-n+5), #pools-table td:nth-child(4) { white-space: nowrap; }
#audit-table td:last-child { min-width: 18rem; overflow-wrap: anywhere; }
#users-table .cell-email, #pools-table td:first-child { overflow-wrap: anywhere; }
.admin-panel .admin-tab { box-shadow: none; }
.admin-panel .btn-icon { box-shadow: none; }
.admin-panel .admin-actions .btn { padding: 0.25rem 0.5rem; font-size: 0.85rem; }

.create-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 1rem 1.25rem;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--sheet-2);
  border-radius: var(--radius);
}

.create-form .form-group { margin: 0; min-width: 0; }
.form-wide, .form-actions, .permission-fields { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.permission-fields { margin: 0; padding: 1rem 0 0; border: 0; border-top: 1px solid var(--rule); }
.permission-fields legend { padding: 0 0.5rem 0 0; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.permission-options { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; }
.permission-options label { margin: 0; }
#audit-filter { padding: 0; background: transparent; grid-template-columns: minmax(0, 18rem); }

/* Stays a table cell (no flex) so row borders and alignment carry through. */
.admin-actions {
  text-align: right;
  white-space: nowrap;
}

#audit-more { margin-top: 1rem; }

/* ── Responsive ── */
@media (max-width: 860px) {
  .site-nav { gap: 0.6rem; }
  .site-nav .related-tool { display: none; }
  .account-nav { padding-left: 0; border-left: none; }
  .account-layout { grid-template-columns: 1fr; max-width: 36rem; margin: 0 auto; }
}

@media (max-width: 640px) {
  .site-header-inner { padding: 0.6rem 1rem; gap: 0.75rem; }
  .user-name { display: none; }
  .user-menu-button { padding-right: 0.45rem; }

  main { padding: 1.5rem 1rem 2rem; }
  .panel, .login-container { padding: 1.35rem 1.1rem; }

  .stepper-label { display: none; }
  .stepper li { justify-content: center; }

  .options-grid { grid-template-columns: 1fr; }
  .create-form, .editor-question-fields { grid-template-columns: minmax(0, 1fr); }
  .management-create .create-form { padding: 1rem; }
  .management-create > summary { padding: 0.85rem 1rem; }
  .admin-tabs { gap: 0; }
  .admin-tab { padding: 0.65em 0.75em; font-size: 0.85rem; }
  .editor-question { padding: 1rem; }

  .data-table th, .data-table td { padding-left: 0.4rem; padding-right: 0.4rem; }

  /* Chapter inputs: drop the spinner buttons so the From/To columns fit a phone. */
  .data-table input[type="number"] { width: 3.5rem; appearance: textfield; -moz-appearance: textfield; }
  .data-table input[type="number"]::-webkit-inner-spin-button,
  .data-table input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

  .question-item { grid-template-columns: 1.75rem 1.5rem 1fr; padding-left: 0; padding-right: 0; }
  .question-ref { display: block; margin: 0.15rem 0 0; }

  .wizard-nav { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Cinematic finish: layered light, tactile surfaces, and sharper focus ── */
.site-header {
  background: linear-gradient(105deg, light-dark(rgba(255, 253, 248, 0.96), rgba(25, 28, 35, 0.97)), light-dark(rgba(246, 239, 226, 0.92), rgba(20, 23, 30, 0.96)));
  box-shadow: 0 8px 24px -20px light-dark(rgba(49, 34, 22, 0.5), rgba(0, 0, 0, 0.9));
  position: relative;
  z-index: 2;
}

.site-header::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--gold), transparent);
  opacity: 0.48;
}

.brand-mark {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 3px 9px light-dark(rgba(87, 27, 22, 0.22), rgba(0, 0, 0, 0.42));
}

main { isolation: isolate; }

.page-intro { position: relative; }

.page-intro .eyebrow {
  text-shadow: 0 1px 0 light-dark(rgba(255, 255, 255, 0.65), rgba(0, 0, 0, 0.45));
}

.page-title {
  text-shadow: 0 2px 14px light-dark(rgba(95, 62, 35, 0.1), rgba(0, 0, 0, 0.36));
}

.panel {
  position: relative;
  background:
    linear-gradient(145deg, light-dark(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.035)), transparent 38%),
    linear-gradient(160deg, var(--sheet), light-dark(#faf5eb, #171a21) 82%);
  border-color: light-dark(rgba(180, 162, 137, 0.62), rgba(96, 105, 120, 0.62));
  box-shadow: var(--shadow), inset 0 1px 0 light-dark(rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.07));
}

.panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 1.5rem;
  width: min(8rem, 24%);
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  opacity: 0.8;
}

.stepper li { transition: color 0.2s ease, border-color 0.2s ease; }
.stepper li[aria-current="step"] .stepper-num {
  box-shadow: 0 0 0 4px var(--accent-tint), 0 3px 10px light-dark(rgba(92, 31, 24, 0.24), rgba(0, 0, 0, 0.42));
}

button, .btn {
  box-shadow: 0 1px 0 light-dark(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.045)) inset,
    0 2px 5px light-dark(rgba(54, 38, 24, 0.07), rgba(0, 0, 0, 0.2));
}

button:hover, .btn:hover { transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }

.btn-primary {
  background-image: linear-gradient(135deg, light-dark(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.1)), transparent 58%);
  box-shadow: 0 3px 10px light-dark(rgba(104, 34, 27, 0.2), rgba(0, 0, 0, 0.38)), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

input[type="text"], input:not([type]), input[type="email"], input[type="password"], input[type="number"], select, textarea {
  background-image: linear-gradient(180deg, light-dark(rgba(95, 69, 39, 0.025), rgba(0, 0, 0, 0.11)), transparent 35%);
  box-shadow: inset 0 1px 3px light-dark(rgba(69, 50, 32, 0.06), rgba(0, 0, 0, 0.2));
}

.radio-option, .editor-question {
  background: linear-gradient(135deg, light-dark(rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0.025)), transparent 68%);
}

.radio-option:has(input:checked) {
  box-shadow: inset 3px 0 0 var(--accent), 0 4px 12px light-dark(rgba(84, 38, 26, 0.08), rgba(0, 0, 0, 0.2));
}

.data-table th { color: var(--ink-2); }
.data-table tbody tr:hover { box-shadow: inset 3px 0 0 light-dark(rgba(146, 45, 43, 0.5), rgba(229, 138, 114, 0.6)); }

.type-legend {
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 0 light-dark(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.035));
}

.question-type { box-shadow: 0 1px 5px light-dark(rgba(90, 37, 29, 0.08), rgba(0, 0, 0, 0.25)); }

.site-footer { background: linear-gradient(180deg, transparent, light-dark(rgba(127, 93, 58, 0.035), rgba(255, 255, 255, 0.018))); }

/* Ambient movement: diffuse light drifts slowly across the background, never the content. */
@keyframes ambient-drift {
  from { background-position: 0% 0%, 100% 0%, 0 0; }
  to { background-position: 36% 42%, 64% 58%, 0 0; }
}

@keyframes gradient-flow {
  0% {
    background-position: 0% 0%, 100% 100%, 55% 0%;
    background-size: 145% 145%, 155% 155%, 135% 135%;
    transform: translate3d(-1.5%, -1%, 0) scale(1.01);
    opacity: 0.78;
  }
  25% {
    background-position: 70% 15%, 15% 75%, 100% 55%;
    background-size: 165% 150%, 140% 165%, 150% 130%;
    transform: translate3d(1.5%, 0.5%, 0) scale(1.04);
    opacity: 0.96;
  }
  50% {
    background-position: 100% 100%, 0% 0%, 45% 100%;
    background-size: 150% 165%, 165% 140%, 130% 155%;
    transform: translate3d(2%, 1.5%, 0) scale(1.05);
    opacity: 0.9;
  }
  75% {
    background-position: 25% 60%, 80% 30%, 0% 45%;
    background-size: 140% 160%, 150% 140%, 160% 140%;
    transform: translate3d(-1%, 1%, 0) scale(1.035);
    opacity: 0.98;
  }
  100% {
    background-position: 0% 0%, 100% 100%, 55% 0%;
    background-size: 145% 145%, 155% 155%, 135% 135%;
    transform: translate3d(-1.5%, -1%, 0) scale(1.01);
    opacity: 0.78;
  }
}

@keyframes header-glint {
  from { background-position: 0% 50%; }
  to { background-position: 200% 50%; }
}

:root[data-theme="dark"] .site-header::after {
  background-size: 200% 100%;
  opacity: 0.62;
  animation: header-glint 24s ease-in-out infinite alternate;
}

:root[data-theme="dark"] .panel {
  background-image:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 38%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 5px),
    linear-gradient(160deg, var(--sheet), #11141b 82%);
}

:root[data-theme="dark"] button:not(.btn-primary):hover,
:root[data-theme="dark"] .btn:not(.btn-primary):hover {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 4px 14px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(229, 138, 114, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .site-header::after {
    background-size: 200% 100%;
    opacity: 0.62;
    animation: header-glint 24s ease-in-out infinite alternate;
  }

  :root:not([data-theme]) .panel {
    background-image:
      linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 38%),
      repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 5px),
      linear-gradient(160deg, var(--sheet), #11141b 82%);
  }

  :root:not([data-theme]) button:not(.btn-primary):hover,
  :root:not([data-theme]) .btn:not(.btn-primary):hover {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 4px 14px rgba(0, 0, 0, 0.3),
      0 0 0 1px rgba(229, 138, 114, 0.1);
  }
}

@media (prefers-reduced-motion: no-preference) {
  body::before {
    animation: gradient-flow 18s ease-in-out infinite;
  }

  body {
    background-size: 138% 138%, 132% 132%, auto;
    animation: ambient-drift 32s ease-in-out infinite alternate;
  }

  button, .btn { transition: transform 0.16s ease, background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s; }
}

@media (prefers-reduced-motion: reduce) {
  button:hover, .btn:hover, button:active, .btn:active { transform: none; }
}

/* ── Print: just the sets, in ink on white ── */
@media print {
  :root {
    --paper: #fff; --sheet: #fff; --sheet-2: #fff;
    --ink: #000; --ink-2: #222; --muted: #555;
    --rule: #ccc; --accent: #000;
  }

  .site-header, .site-footer, .page-intro, .stepper, .wizard-nav,
  .results-toolbar, .toggle-answers, .type-legend, .pool-notice { display: none !important; }

  main { padding: 0; max-width: none; }
  .panel { border: none; box-shadow: none; padding: 0; }
  .panel::before { display: none; }
  .wizard-step { animation: none; }
  .question-set { break-after: page; }
  .question-set:last-child { break-after: auto; }
  .question-item { break-inside: avoid; }
  .question-type { border-color: #000; color: #000; }
}

/* The installed app draws edge to edge (viewport-fit=cover), so the page's own background shows
   behind Android's navigation buttons. Keep content clear of the system bars and display cutouts. */
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.site-header { padding-top: env(safe-area-inset-top); }
.site-footer { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }

/* ── Pool pop-up message ── */
.pool-notice {
  max-width: min(32rem, calc(100vw - 2rem));
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.pool-notice::backdrop { background: rgba(0, 0, 0, 0.5); }
.pool-notice h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.pool-notice-body { margin: 0 0 1.25rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.pool-notice-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.set-note { font-style: italic; color: var(--muted); margin: 0 0 1rem; white-space: pre-wrap; }

/* A question type the selected pool does not have. */
.radio-option.unavailable, .form-group.unavailable, #studyTypes label.unavailable { opacity: 0.45; cursor: not-allowed; }
.radio-option.unavailable *, .form-group.unavailable *, #studyTypes label.unavailable * { cursor: not-allowed; }

/* ── Pool editor: sticky toolbar and windowed question list ── */
.editor-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  gap: 0.6rem;
  margin: 0 -0.5rem 0.75rem;
  padding: 0.75rem 0.5rem;
  background: var(--sheet);
  border-bottom: 1px solid var(--rule);
}
.editor-bar-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.editor-bar-row input[type="search"] { flex: 1 1 14rem; min-width: 0; }
.editor-bar-row select { flex: 0 1 12rem; }
.editor-count { color: var(--muted); margin-right: auto; }
.editor-save-status { font-size: 0.9rem; }
.editor-save-status.error { color: var(--danger); }
/* Only the rows near the screen exist; each sits at its place in the full-height list. */
.editor-list { position: relative; }
.editor-row { position: absolute; left: 0; right: 0; box-sizing: border-box; }
button.editor-row-summary {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; height: 100%;
  padding: 0 0.75rem; text-align: left; font: inherit; color: var(--ink);
  background: transparent; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; cursor: pointer;
}
button.editor-row-summary:hover { background: var(--accent-tint); }
.editor-row-num { flex: 0 0 3.2rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.editor-row-type { flex: 0 0 auto; font-size: 0.75rem; padding: 0.1rem 0.45rem; border: 1px solid var(--rule); border-radius: 999px; color: var(--muted); }
.editor-row-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-row-ref { flex: 0 0 auto; color: var(--muted); font-size: 0.9rem; }
.editor-row-open .editor-question { margin: 0.25rem 0 0.5rem; background: var(--sheet-2); }
@media (max-width: 640px) { .editor-row-ref { display: none; } }

/* Question sets kept on this device */
.local-heading { margin: 1.5rem 0 0.25rem; }
.local-new { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.local-new .form-group { flex: 1 1 16rem; margin: 0; }
.local-files { list-style: none; margin: 0.5rem 0 1rem; padding: 0; }
.local-files li { display: flex; gap: 0.5rem; align-items: center; justify-content: space-between; padding: 0.25rem 0; }
.local-drop {
  border: 2px dashed var(--rule-strong);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.5rem 0 1rem;
  text-align: center;
}
.local-drop.dragging { background: var(--accent-tint); }
.local-drop label { display: block; cursor: pointer; margin-bottom: 0.5rem; }
