/* ---------- design tokens ---------- */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #1c2233;
  --muted: #5a6378;
  --border: #d9deea;
  --accent: #3b5bdb;
  --accent-strong: #2f4ac0;
  --accent-soft: #e5eafc;
  --on-accent: #ffffff;
  --good: #2b8a3e;
  --good-soft: #e6f4ea;
  --warn: #b35c00;
  --warn-soft: #fff1e0;
  --bad: #c92a2a;
  --bad-soft: #fde8e8;
  --paper: #ffffff;
  --paper-text: #111111;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Times New Roman", Times, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151d;
    --surface: #1b1f2a;
    --surface-2: #232838;
    --text: #e7eaf2;
    --muted: #a3abbf;
    --border: #333a4d;
    --accent: #7c96ff;
    --accent-strong: #9aafff;
    --accent-soft: #263055;
    --on-accent: #0e1222;
    --good: #69db7c;
    --good-soft: #1f3326;
    --warn: #ffb057;
    --warn-soft: #3a2a16;
    --bad: #ff8787;
    --bad-soft: #3d1f22;
    --paper: #fbfbf8;
    --paper-text: #111111;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
}

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

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 10;
}
.skip-link:focus { left: 8px; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- header / nav ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--serif);
  font-size: 1.3rem;
}
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

/* ---------- hero ---------- */
.hero {
  padding: 32px 0 8px;
}
.hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  line-height: 1.15;
  margin: 0 0 8px;
}
.hero p.lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 62ch;
}
.why-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0 8px;
}
.why-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.why-card strong { display: block; margin-bottom: 2px; }
.why-card span { color: var(--muted); font-size: .95rem; }

/* ---------- cards / layout ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}
.card .sub { color: var(--muted); margin: 0 0 16px; font-size: .95rem; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin: 24px 0;
}
.workspace .preview-col {
  position: sticky;
  top: 76px;
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace .preview-col { position: static; }
}

.step-label {
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin: 18px 0 8px;
}
.step-label:first-child { margin-top: 0; }
.step-num {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .85rem;
}

/* ---------- style + type pickers ---------- */
.style-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 520px) { .style-picker { grid-template-columns: 1fr; } }
.choice {
  display: block;
  text-align: left;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
}
.choice:hover { border-color: var(--accent); }
.choice[aria-pressed="true"],
.choice[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.choice strong { display: block; font-size: 1.05rem; }
.choice[aria-pressed="true"] strong::after { content: " ✓"; }
.type-tabs .choice[aria-pressed="true"]::after { content: " ✓"; }
.choice small { color: var(--muted); }

.type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.type-tabs .choice {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
}

/* ---------- form ---------- */
.field { margin: 0 0 16px; }
.field > label,
.field > .label {
  display: block;
  font-weight: 650;
  margin-bottom: 4px;
}
.field .optional { font-weight: 400; color: var(--muted); font-size: .9rem; }
.field .style-note {
  font-weight: 500;
  font-size: .8rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: 4px;
}
.hint {
  font-size: .9rem;
  color: var(--muted);
  margin: 4px 0 0;
}
.hint::before { content: "💡 "; }

input[type="text"],
input[type="url"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  box-shadow: none;
}
/* The hidden file input shows its focus on the visible button around it. */
.file-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
textarea { min-height: 90px; resize: vertical; }

.row {
  display: grid;
  gap: 8px;
}
.row-2 { grid-template-columns: 1fr 1fr; }
.date-row { grid-template-columns: 80px 1fr 100px auto; align-items: center; }
@media (max-width: 520px) {
  .date-row { grid-template-columns: 70px 1fr 90px; }
  .date-row .btn { grid-column: 1 / -1; }
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.author-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 8px;
}
.author-mode label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.author-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}
@media (max-width: 520px) {
  .author-row { grid-template-columns: 1fr 1fr; }
  .author-row .btn { grid-column: 1 / -1; }
}

/* ---------- autofill ---------- */
.optional { color: var(--muted); }
.autofill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.autofill-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
@media (max-width: 520px) { .autofill-row { grid-template-columns: 1fr; } }
.scan-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 8px; }
.scan-row[hidden] { display: none; }
.scan-row .hint { margin: 0; }
.scan-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 18px;
  box-shadow: var(--shadow);
}
.scan-dialog::backdrop { background: rgba(10, 14, 30, .6); }
.scan-dialog h2 { margin: 0 0 6px; font-size: 1.25rem; }
.scan-dialog p { margin: 0 0 10px; }
.scan-view { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; margin-bottom: 10px; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-view video.mirrored { transform: scaleX(-1); }
.scan-box { position: absolute; inset: 28% 18%; border: 3px solid #fff; border-radius: 8px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); }
.scan-status { font-weight: 600; min-height: 1.5em; }
.autofill-status { margin: 8px 0 0; font-size: .93rem; font-weight: 600; }
.autofill-status:empty { display: none; }
.autofill-status.error { color: var(--bad); }
.autofill-status.success { color: var(--good); }
.autofill .hint { margin-top: 8px; }
.autofill[aria-busy="true"] .btn-primary { opacity: .7; cursor: progress; }

.field.autofilled {
  border-left: 4px solid var(--good);
  padding-left: 10px;
  margin-left: -14px;
}
.field.autofilled > label::after,
.field.autofilled > .label::after {
  content: " ✨ autofilled: check it";
  font-size: .78rem;
  font-weight: 600;
  color: var(--good);
}

/* ---------- title capitalization helper ---------- */
.casing-helper:empty { display: none; }
.casing-helper {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  font-size: .92rem;
}
.casing-helper p { margin: 0 0 8px; }
.casing-helper p:last-child { margin-bottom: 0; }
.casing-result { font-family: var(--serif); font-size: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.chip {
  font: inherit;
  font-size: .88rem;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.chip[aria-pressed="true"]::before { content: "✓ "; }

/* ---------- assignments ---------- */
.project-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.project-bar label { font-weight: 700; }
.project-bar select { width: auto; min-width: 180px; max-width: 100%; }
.saving-to { margin: 8px 0 0; font-size: .88rem; color: var(--muted); text-align: center; }
.entry-tools select.copy-to {
  width: auto;
  padding: 3px 8px;
  font-size: .85rem;
  background: #fff;
  color: #333;
  border-color: #d0d4dc;
}

/* ---------- teacher assignments (student view) ---------- */
.assignment-card {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.assignment-card h3 { margin: 2px 0 6px; font-size: 1.2rem; }
.assignment-from { margin: 0; font-size: .85rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.assignment-due { margin: 0 0 8px; font-weight: 650; }
.assignment-due.soon { color: var(--warn); }
.assignment-due.late { color: var(--bad); }
.assignment-note { margin: 0 0 10px; white-space: pre-line; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.assignment-style { margin: 0 0 8px; font-size: .95rem; }
.assignment-style span { color: var(--muted); }
.assignment-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.assignment-checks li { padding: 6px 10px; border-radius: 8px; font-size: .95rem; }
.assignment-checks li.done { background: var(--good-soft); }
.assignment-checks li.todo { background: var(--surface-2); }
.assignment-checks li.problem { background: var(--warn-soft); border-left: 4px solid var(--warn); }
.assignment-ready { margin: 10px 0 0; font-weight: 700; color: var(--good); }
.choice:disabled { opacity: .45; cursor: not-allowed; }
.choice:disabled:hover { border-color: var(--border); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 650;
  font-size: .95rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
  text-align: center;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-danger:hover { border-color: var(--bad); color: var(--bad); }
.btn-small { padding: 4px 10px; font-size: .85rem; }
.btn-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- preview ---------- */
.citation-preview {
  background: var(--paper);
  color: var(--paper-text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 16px 16px calc(16px + .5in);
  text-indent: -.5in;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.6;
  min-height: 70px;
  overflow-wrap: anywhere;
}
.citation-preview.empty {
  text-indent: 0;
  padding-left: 16px;
  color: #6b7280;
  font-family: var(--font);
  font-style: italic;
}
.mini-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
  margin: 16px 0 6px;
}
.intext {
  display: grid;
  gap: 6px;
}
.intext-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .95rem;
}
.intext-item code {
  font-family: var(--serif);
  font-size: 1rem;
  overflow-wrap: anywhere;
}
.intext-item small { color: var(--muted); display: block; font-size: .78rem; }

.notes { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.notes li {
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .92rem;
}
.notes li.missing { background: var(--warn-soft); color: var(--text); border-left: 4px solid var(--warn); }
.notes li.tip { background: var(--accent-soft); color: var(--text); border-left: 4px solid var(--accent); }
.notes li.ok { background: var(--good-soft); border-left: 4px solid var(--good); }

.preview-actions { margin-top: 16px; }
.preview-actions .btn-primary { width: 100%; padding: 12px; font-size: 1rem; }
.preview-actions .btn-row { margin-top: 8px; }
.preview-actions .btn-row .btn { flex: 1; }

/* ---------- saved list / paper ---------- */
.list-section { margin: 32px 0; }
.list-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
}
.list-header h2 { margin: 0; }
.list-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.list-controls label { font-weight: 600; font-size: .9rem; }
.list-controls { max-width: 100%; }
.list-controls select { width: auto; max-width: 100%; }

.paper {
  background: var(--paper);
  color: var(--paper-text);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: clamp(20px, 6vw, 1in);
  font-family: var(--serif);
  font-size: 12pt;
  line-height: 2;
  max-width: 8.5in;
  margin: 0 auto;
}
.paper h3 {
  text-align: center;
  font-size: 12pt;
  font-weight: normal;
  margin: 0;
  line-height: 2;
}
.paper.apa h3 { font-weight: bold; }
/* Chicago bibliographies: single-spaced entries with a blank line between them. */
.paper.chicago { line-height: 1.3; }
.paper.chicago h3 { margin-bottom: 1.6em; line-height: 1.3; }
.paper.chicago .paper-entry { margin-bottom: 1.3em; }
.paper-entry {
  position: relative;
  padding-left: .5in;
  text-indent: -.5in;
  margin: 0;
  overflow-wrap: anywhere;
}
.paper-entry .entry-tools {
  text-indent: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 8px;
  font-family: var(--font);
  line-height: 1.4;
}
.paper-entry .entry-tools .btn { background: #fff; color: #333; border-color: #d0d4dc; }
.paper-entry .entry-tools .btn:hover { color: #2f4ac0; border-color: #2f4ac0; }
.paper-entry .annotation {
  text-indent: 0;
  margin: 0;
}
.paper-entry .annotation-editor {
  text-indent: 0;
  font-family: var(--font);
  line-height: 1.4;
  margin-bottom: 10px;
}
.paper-entry .annotation-editor textarea { background: #fff; color: #111; border-color: #ccd; }
.paper-entry.excluded { text-indent: 0; padding-left: 0; }
.excluded-note {
  margin: 0;
  font-family: var(--font);
  font-size: .9rem;
  line-height: 1.5;
  color: #4b5563;
  background: #f3f4f6;
  border-left: 4px solid #9ca3af;
  border-radius: 6px;
  padding: 8px 10px;
}
.paper-empty {
  text-align: center;
  font-family: var(--font);
  color: #6b7280;
  line-height: 1.5;
  padding: 24px 0;
}
.format-notes {
  font-size: .92rem;
  color: var(--muted);
  max-width: 8.5in;
  margin: 12px auto 0;
}

/* ---------- learn page ---------- */
.learn-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 28px;
  margin: 24px 0 48px;
  align-items: start;
}
.toc {
  position: sticky;
  top: 76px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.toc strong { display: block; margin-bottom: 6px; }
.toc ol { margin: 0; padding-left: 20px; font-size: .95rem; }
.toc li { margin: 4px 0; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }
@media (max-width: 900px) {
  .learn-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; }
}

.lesson { margin-bottom: 20px; scroll-margin-top: 80px; }
.lesson h2 { font-size: 1.4rem; }
.lesson h3 { margin: 18px 0 6px; font-size: 1.1rem; }
.lesson p, .lesson li { max-width: 72ch; }

.callout {
  border-radius: 10px;
  padding: 12px 16px;
  margin: 14px 0;
  border-left: 5px solid var(--accent);
  background: var(--accent-soft);
}
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout.good { border-color: var(--good); background: var(--good-soft); }
.callout p { margin: 4px 0; overflow-wrap: anywhere; }

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
@media (max-width: 640px) { .compare { grid-template-columns: 1fr; } }
.compare > div {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 14px;
}
.compare h3 { margin: 0 0 6px; }
.example {
  font-family: var(--serif);
  background: var(--paper);
  color: var(--paper-text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px 10px calc(12px + .5in);
  text-indent: -.5in;
  margin: 8px 0;
  overflow-wrap: anywhere;
}

.example.example-note { text-indent: 0; padding-left: 12px; font-family: var(--font); font-size: .95rem; }
.example.example-note i { font-family: var(--serif); }

.table-wrap { overflow-x: auto; }
table.simple {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: .95rem;
}
table.simple th, table.simple td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
table.simple th { background: var(--surface-2); }

.anatomy {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface-2);
  font-size: .95rem;
}
.anatomy .tag {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 999px;
  padding: 1px 8px;
  margin-right: 6px;
}
.anatomy > div { margin: 6px 0; }

/* quiz */
.quiz-q {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
  background: var(--surface);
}
.quiz-q p.q { font-weight: 650; margin: 0 0 10px; }
.quiz-q .btn-row .btn[aria-pressed="true"].right { border-color: var(--good); color: var(--good); background: var(--good-soft); }
.quiz-q .btn-row .btn[aria-pressed="true"].wrong { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.quiz-q .feedback { margin: 10px 0 0; font-size: .95rem; }
.quiz-score { font-weight: 700; }

/* ---------- toast + footer ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .9rem;
  padding: 20px 0;
  margin-top: 32px;
}
.site-footer p { margin: 4px 0; }

/* ---------- print: only the Works Cited page ---------- */
@media print {
  body { background: #fff; color: #000; }
  body:not(.teacher-page) * { visibility: hidden; }
  #paper, #paper * { visibility: visible; }
  #paper {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    max-width: none;
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  #paper .entry-tools, #paper .annotation-editor, #paper .excluded { display: none !important; }
  @page { margin: 1in; }
}

/* ---------- teacher page ---------- */
.teacher-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin: 24px 0;
}
.teacher-grid .sticky { position: sticky; top: 76px; }
@media (max-width: 900px) {
  .teacher-grid { grid-template-columns: minmax(0, 1fr); }
  .teacher-grid .sticky { position: static; }
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px 14px;
}
.check-grid label, .inline-check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.at-least-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 8px; margin-bottom: 8px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.counter { float: right; font-size: .8rem; color: var(--muted); font-weight: 400; }
.link-box { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.link-box input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.student-preview { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.student-preview li { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; font-size: .95rem; }
.student-preview li::before { content: "⬜ "; }
.privacy-note { font-size: .9rem; color: var(--muted); }
.printables { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 16px 0 32px; }
.printable-card h3 { margin: 0 0 4px; }
.printable-card p { margin: 0 0 12px; color: var(--muted); font-size: .95rem; }
.printable-card details { margin-top: 10px; }
.printable-card .sheet p { color: inherit; font-size: inherit; margin: 3px 0; }
.printable-card summary { cursor: pointer; font-weight: 650; color: var(--accent); }

/* The printable sheets themselves (shown in previews and printed) */
.sheet {
  background: #fff;
  color: #111;
  font-family: var(--font);
  font-size: 11pt;
  line-height: 1.45;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 20px;
  margin-top: 10px;
  max-height: 520px;
  overflow: auto;
}
.sheet h2 { font-size: 16pt; margin: 0 0 4px; }
.sheet h3 { font-size: 12.5pt; margin: 14px 0 4px; }
.sheet h4 { font-size: 11pt; margin: 10px 0 2px; }
.sheet p, .sheet li { margin: 3px 0; }
.sheet ul, .sheet ol { padding-left: 22px; margin: 4px 0; }
.sheet .sheet-meta { color: #555; margin: 0 0 8px; }
.sheet .name-line { display: flex; gap: 18px; margin: 0 0 10px; }
.sheet .name-line span { flex: 1; border-bottom: 1px solid #333; padding-top: 14px; font-size: 9pt; color: #555; }
.sheet .write { border-bottom: 1px solid #888; height: 24px; margin: 2px 0; }
.sheet .cite {
  font-family: var(--serif);
  font-size: 11.5pt;
  padding-left: .5in;
  text-indent: -.5in;
  margin: 4px 0;
  overflow-wrap: anywhere;
}
.sheet .mock-page { border: 1.5px dashed #888; border-radius: 6px; padding: 8px 12px; margin: 6px 0; background: #fafafa; }
.sheet .mock-page .site { font-weight: 800; }
.sheet .mock-page .headline { font-size: 13pt; font-weight: 700; margin: 4px 0; }
.sheet .mock-page small { color: #555; overflow-wrap: anywhere; }
.sheet .key { color: #0b5a2a; }
.sheet table { border-collapse: collapse; width: 100%; font-size: 10pt; }
.sheet th, .sheet td { border: 1px solid #bbb; padding: 4px 6px; text-align: left; vertical-align: top; }
.sheet .card-half { break-inside: avoid; page-break-inside: avoid; }
.sheet .card-half + .card-half { border-top: 2px dashed #999; margin-top: 14px; padding-top: 10px; }
.sheet .card-half h2 { font-size: 13pt; }
.sheet .card-half .cite { font-size: 10pt; margin: 2px 0 5px; }
.sheet .card-half h3 { margin: 6px 0 0; font-size: 9.5pt; text-transform: uppercase; letter-spacing: .04em; color: #444; }
.sheet .card-half ul { font-size: 9.5pt; }
.sheet .footer-note { margin-top: 12px; font-size: 9pt; color: #555; }
#print-root { display: none; }

/* QR codes for class links */
.qr-block { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 14px; align-items: start; margin: 0 0 16px; }
@media (max-width: 420px) { .qr-block { grid-template-columns: 1fr; } }
.qr-box svg { display: block; width: 160px; height: 160px; border: 1px solid var(--border); border-radius: 8px; }
.qr-actions { display: flex; flex-wrap: wrap; gap: 6px; align-content: start; }
.qr-actions .hint { flex-basis: 100%; }
.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #fff;
  color: #111;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: auto;
}
.qr-overlay[hidden] { display: none; }
.qr-overlay-inner { text-align: center; max-width: 100%; }
.qr-overlay h2 { font-size: clamp(1.5rem, 4vw, 2.6rem); margin: 0 0 4px; }
.qr-overlay-sub { font-size: clamp(1rem, 2.4vw, 1.4rem); margin: 0 0 12px; color: #333; }
.qr-overlay-code svg { width: min(72vh, 88vw); height: min(72vh, 88vw); display: block; margin: 0 auto 14px; }
.qr-overlay .btn { background: #fff; color: #111; border-color: #ccc; }
.sheet .poster { text-align: center; }
.sheet .poster h2 { font-size: 26pt; margin: 0 0 6px; }
.sheet .poster .poster-sub { font-size: 14pt; margin: 0 0 4px; }
.sheet .poster svg { width: 5.5in; max-width: 100%; height: auto; display: block; margin: 18px auto; }
.sheet .poster .poster-scan { font-size: 16pt; font-weight: 700; }

@media print {
  body.teacher-page > *:not(#print-root) { display: none !important; }
  body.teacher-page #print-root { display: block; }
  #print-root .sheet { border: 0; padding: 0; margin: 0; max-height: none; overflow: visible; font-size: 11pt; }
  #print-root .page-break { break-before: page; page-break-before: always; }
}

/* ---------- accessibility ---------- */
/* "What's this?" and "Undo" are small text buttons; give them a 24px tap target (WCAG 2.5.8). */
.btn-link { min-height: 24px; display: inline-flex; align-items: center; }
/* Headings that receive focus after an action don't need a ring. */
[tabindex="-1"]:focus { outline: none; }
.sheet:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

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

@media (forced-colors: active) {
  .choice[aria-pressed="true"], .chip[aria-pressed="true"] { border: 3px solid Highlight; }
  .btn-primary { border: 2px solid ButtonText; }
}

/* ---------- language toggle ---------- */
.lang-toggle {
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  margin-left: 6px;
  cursor: pointer;
  min-height: 24px;
}
.lang-toggle:hover { color: var(--text); border-color: var(--accent); }
.privacy-page { padding-top: 8px; padding-bottom: 32px; max-width: 860px; }
