/* LexDecks — Minimalist Cinematic Design System
   Palette: deep dark bg, warm off-white text, muted teal accent, gold CTA
   v=20260614-cinematic */

:root {
  --bg: #0c0f14;
  --surface: #13181f;
  --surface-raised: #1a2130;
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.13);
  --text: #e4ddd2;
  --muted: rgba(228, 221, 210, 0.42);
  --accent: #6ea89e;
  --accent-bright: #8ec8bc;
  --accent-dark: #4d8a80;
  --gold: #c4a25a;
  --gold-dark: #a8892e;
  --danger: #c06060;
  --warn-color: #c49240;
  --line: rgba(255, 255, 255, 0.07);

  /* Legacy compat aliases */
  --ink: #e4ddd2;
  --paper: #0c0f14;
  --panel: #13181f;
  --review: #c49240;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: auto;
}

a {
  color: var(--text);
  text-decoration: none;
}

/* ───────────────────────────────────────────────
   TOPBAR
   ─────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 15, 20, 0.9);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 58px;
  padding: 0 max(22px, calc((100vw - 1180px) / 2));
  background: rgba(12, 15, 20, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: #fff;
  text-decoration: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
  font-weight: 700;
}

nav:empty {
  display: none;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 120ms;
}

nav a:hover {
  color: var(--text);
}

.nav-logout-btn {
  border: none;
  background: none;
  padding: 0;
  min-height: unset;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  border-radius: 0;
}

.nav-logout-btn:hover {
  color: var(--text);
  background: none;
  border: none;
}

/* ───────────────────────────────────────────────
   PAGE LAYOUT
   ─────────────────────────────────────────────── */

.page {
  width: min(1480px, calc(100vw - 80px));
  min-width: 0;
  margin: 28px auto 56px;
}

.clean-page {
  width: min(1180px, calc(100vw - 36px));
  margin-top: 28px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 56px;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 24px;
  align-items: start;
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.minimal-home-layout {
  align-items: start;
}

.copilot-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.85fr) minmax(480px, 1.15fr);
  gap: 18px;
  align-items: start;
  padding-bottom: 92px;
}

.clean-review-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.92fr) minmax(420px, 1.08fr);
  gap: 18px;
  align-items: start;
  padding-bottom: 92px;
}

.review-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(320px, 420px);
  gap: 22px;
  align-items: start;
}

.settings-shell {
  width: min(1040px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

/* ───────────────────────────────────────────────
   PANELS / CARDS
   ─────────────────────────────────────────────── */

.panel,
.flashcard,
.source-panel,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 16px 40px rgba(0, 0, 0, 0.35);
}

.panel {
  padding: 24px;
}

.flashcard {
  padding: 22px;
  min-height: 245px;
}

.flashcard.answer {
  min-height: 285px;
}

.flashcard label {
  margin-bottom: 10px;
}

.flashcard textarea {
  min-height: 160px;
  border: 0;
  padding: 0;
  font-size: 22px;
  line-height: 1.35;
  background: transparent;
  color: var(--text);
}

.flashcard.answer textarea {
  font-size: 19px;
}

.source-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.source-panel p {
  margin: 0;
}

.empty-state {
  padding: 36px;
}

.clean-empty-state {
  padding: 44px;
  text-align: center;
}

.clean-empty-state .button + .button {
  margin-left: 8px;
}

/* ───────────────────────────────────────────────
   TYPOGRAPHY
   ─────────────────────────────────────────────── */

h1,
h2 {
  margin: 0 0 16px;
  line-height: 1.15;
  color: #fff;
  letter-spacing: -0.04em;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

p {
  line-height: 1.55;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  display: inline-block;
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

/* ───────────────────────────────────────────────
   LABELS / FORMS
   ─────────────────────────────────────────────── */

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  transition: border-color 120ms;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
}

select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  transition: border-color 120ms;
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

.wide-field {
  grid-column: 1 / -1;
}

.checkbox-label {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 10px;
}

.checkbox-label input {
  width: auto;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: end;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stacked-form {
  display: grid;
  gap: 10px;
}

.compact-import {
  display: flex;
  gap: 10px;
  width: min(520px, 100%);
}

.compact-import input {
  min-width: 0;
}

.generate-form {
  display: flex;
  align-items: end;
  gap: 10px;
}

.generate-form label {
  margin: 0;
  min-width: 120px;
  font-size: 13px;
}

.generate-form input {
  width: 120px;
}

.clean-generate-form {
  display: flex;
  align-items: end;
  gap: 12px;
  min-width: 310px;
}

.clean-generate-form label {
  width: 92px;
  margin-bottom: 0;
}

.friendly-anki-form {
  display: grid;
  gap: 18px;
}

.anki-settings-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 0.6fr);
  gap: 12px;
}

.anki-settings-form label {
  margin: 0;
}

.anki-settings-form button {
  grid-column: 1 / -1;
}

.clean-settings-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.clean-settings-form label {
  margin-bottom: 0;
}

.clean-settings-form .checkbox-label,
.clean-settings-form button {
  grid-column: span 3;
}

.split-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}

.advanced-settings {
  border: 1px dashed rgba(255, 255, 255, 0.10);
  border-radius: 18px;
  background: var(--surface-raised);
}

.advanced-settings summary {
  cursor: pointer;
  padding: 16px 18px;
  color: var(--text);
  font-weight: 800;
}

.advanced-settings-body {
  padding: 0 18px 18px;
}

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.field-help.warn {
  color: var(--warn-color);
}

.deck-select-field {
  margin: 4px 0 18px;
}

.deck-select-field > span {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.anki-target-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

/* ───────────────────────────────────────────────
   BUTTONS
   ─────────────────────────────────────────────── */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 999px;
  padding: 0 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}

button:hover,
.button:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.18);
}

.primary,
.accept,
.accept-action {
  border-color: var(--gold);
  color: #0c0f14;
  background: var(--gold);
  font-weight: 800;
}

.primary:hover,
.accept:hover,
.accept-action:hover {
  background: var(--gold-dark);
  border-color: var(--gold-dark);
  color: #0c0f14;
}

.accept-action {
  font-size: 16px;
}

.review {
  border-color: var(--warn-color);
  color: #0c0f14;
  background: var(--warn-color);
}

.review:hover {
  background: #a87e35;
  border-color: #a87e35;
}

.subtle {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.subtle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.large-action {
  min-height: 52px;
  padding: 0 24px;
  font-size: 17px;
}

.review-secondary {
  border-color: rgba(196, 146, 64, 0.35);
  color: var(--warn-color);
  background: rgba(196, 146, 64, 0.10);
}

.review-secondary:hover {
  background: rgba(196, 146, 64, 0.18);
}

/* ───────────────────────────────────────────────
   BOOK LIST
   ─────────────────────────────────────────────── */

.book-list {
  display: grid;
  gap: 10px;
}

.book-row {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  background: var(--surface-raised);
  transition: border-color 120ms, background 120ms;
}

.book-row:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.04);
}

.book-row span,
.book-row small {
  color: var(--muted);
}

.clean-book-list {
  gap: 12px;
}

.clean-book-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-radius: 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: border-color 120ms, background 120ms;
}

.clean-book-row:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.04);
}

.clean-book-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
  color: var(--text);
}

.clean-book-row span {
  color: var(--muted);
  font-size: 13px;
}

.clean-book-row small {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

/* ───────────────────────────────────────────────
   HEADERS / HEROES
   ─────────────────────────────────────────────── */

.book-header,
.review-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.book-header p,
.review-top p {
  margin: 0;
  color: var(--muted);
}

.home-hero,
.review-page-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 20px;
}

.home-hero h1,
.review-page-header h1,
.project-hero h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: -0.045em;
}

.project-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 18px;
  padding: 30px;
}

.project-primary-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.compact-project-hero,
.compact-review-header {
  margin-bottom: 16px;
}

.compact-project-hero h1,
.compact-review-header h1,
.compact-source-heading h2 {
  margin-bottom: 4px;
}

.compact-project-hero .project-primary-actions {
  align-items: center;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.review-page-header h1 {
  font-size: clamp(24px, 3vw, 40px);
}

/* ───────────────────────────────────────────────
   STATS
   ─────────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stats div {
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
}

.stats strong {
  font-size: 28px;
  color: #fff;
}

.stats span {
  color: var(--muted);
  font-size: 13px;
}

.simple-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.simple-stats div {
  border-color: var(--border);
  border-radius: 16px;
  background: var(--surface-raised);
}

/* ───────────────────────────────────────────────
   TABLES
   ─────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  color: var(--text);
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
}

/* ───────────────────────────────────────────────
   ACTIONS
   ─────────────────────────────────────────────── */

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions.inline {
  display: flex;
}

.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.review-actions-bar {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(180px, 1fr) 120px 100px minmax(180px, 1fr);
  gap: 12px;
  align-items: center;
  max-width: 820px;
  width: 100%;
  margin: 2px auto 0;
}

.review-actions-bar button {
  min-height: 54px;
  border-radius: 12px;
}

.clean-review-actions {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 30;
  display: flex;
  gap: 10px;
  width: min(920px, calc(100vw - 36px));
  transform: translateX(-50%);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(12, 15, 20, 0.92);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
}

.clean-review-actions button {
  flex: 1;
}

/* ───────────────────────────────────────────────
   NEXT STEP PANEL
   ─────────────────────────────────────────────── */

.next-step-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.next-step-panel h2,
.next-step-panel p {
  margin-bottom: 6px;
}

/* ───────────────────────────────────────────────
   REVIEW PROGRESS
   ─────────────────────────────────────────────── */

.review-progress-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
}

.review-progress-pills span {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 13px;
  font-weight: 750;
}

/* ───────────────────────────────────────────────
   CARD REVIEW SHELL
   ─────────────────────────────────────────────── */

.card-review-shell {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 16px 40px rgba(0, 0, 0, 0.35);
}

.generated-card-editor,
.review-source-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-raised);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.generated-card-editor {
  background: rgba(26, 33, 48, 0.8);
}

.review-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.review-card-header .muted {
  max-width: 55%;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-workspace,
.clean-source-panel {
  padding: 22px;
}

/* ───────────────────────────────────────────────
   CARD FIELDS (ANKI STACK)
   ─────────────────────────────────────────────── */

.card-field,
.feedback-box {
  display: grid;
  gap: 8px;
  margin: 0;
}

.card-field span,
.feedback-box span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-field textarea {
  min-height: 150px;
  border: 0;
  border-radius: 0;
  padding: 26px 4px 4px;
  font-size: 22px;
  line-height: 1.35;
  text-align: center;
  background: transparent;
  color: var(--text);
  box-shadow: none;
}

.answer-field textarea {
  min-height: 230px;
  font-size: 18px;
  line-height: 1.5;
  text-align: left;
  white-space: pre-wrap;
}

.front-note textarea {
  display: block;
  align-content: center;
  min-height: 170px;
  font-weight: 650;
}

.back-note textarea {
  min-height: 260px;
}

.card-field textarea:focus {
  outline: 0;
  background: rgba(255, 255, 255, 0.03);
}

.feedback-box textarea {
  min-height: 110px;
  border-radius: 12px;
  background: var(--surface-raised);
}

.anki-card-stack {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.anki-note {
  position: relative;
  gap: 0;
  padding: 22px 22px 20px;
  background: var(--surface);
}

.anki-field-label {
  position: absolute;
  top: 12px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 9px;
  color: var(--muted) !important;
  background: var(--surface-raised);
  font-size: 11px !important;
  letter-spacing: 0.06em !important;
}

.anki-card-divider {
  height: 1px;
  margin: 0 22px;
  background: var(--border);
}

/* ───────────────────────────────────────────────
   JURA BASIC PREVIEW (CARD PREVIEW)
   ─────────────────────────────────────────────── */

.jura-basic-preview {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.jura-basic-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(110, 168, 158, 0.18);
  border-radius: 20px;
  background: linear-gradient(180deg, #1a2130 0%, #13181f 100%);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.jura-basic-card::before {
  content: "";
  display: block;
  height: 6px;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
}

.jura-basic-label {
  margin: 16px 20px 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.jura-basic-content {
  padding: 18px 22px 24px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  line-height: 1.55;
}

.front-preview .jura-basic-content {
  display: grid;
  place-items: center;
  min-height: 150px;
  text-align: center;
  font-size: 23px;
  font-weight: 700;
}

.back-preview .jura-basic-content {
  min-height: 230px;
}

.jura-basic-content b,
.jura-basic-content strong {
  color: var(--accent-bright);
  font-weight: 850;
}

.jura-basic-content ul,
.jura-basic-content ol {
  padding-left: 1.25em;
}

.editable-card-content {
  cursor: text;
  outline: none;
  border-radius: 14px;
  transition: box-shadow 120ms ease, background 120ms ease;
}

.editable-card-content:focus {
  background: rgba(110, 168, 158, 0.06);
  box-shadow: inset 0 0 0 2px rgba(110, 168, 158, 0.22);
}

.hidden-card-field {
  display: none;
}

/* ───────────────────────────────────────────────
   SOURCE / PDF
   ─────────────────────────────────────────────── */

.source-label {
  display: inline-flex;
  margin: 12px 2px 0;
  color: var(--accent);
  font-weight: 800;
  font-size: 12px;
}

.review-source-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.source-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.source-heading h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.compact-source-heading h2 {
  font-size: 16px;
  margin-bottom: 4px;
}

.source-excerpt {
  position: relative;
  margin: 4px 0 0;
  padding: 18px 20px 18px 24px;
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface-raised);
  font-size: 17px;
  line-height: 1.62;
  white-space: pre-wrap;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.source-excerpt::before {
  content: "„";
  position: absolute;
  top: -10px;
  left: 10px;
  color: rgba(110, 168, 158, 0.25);
  font-family: Georgia, serif;
  font-size: 54px;
  line-height: 1;
}

.source-excerpt mark {
  border-radius: 5px;
  padding: 1px 3px;
  background: rgba(196, 162, 90, 0.28);
  color: var(--text);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.pdf-page-preview {
  display: block;
  width: 100%;
  max-width: 100%;
  height: min(58vh, 640px);
  max-height: 640px;
  min-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #1a1a1a;
}

.pdf-page-preview img {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto;
  object-fit: contain;
  background: #1a1a1a;
}

.clean-source-panel .pdf-page-preview {
  display: block;
  max-height: calc(100vh - 250px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #1a1a1a;
}

.clean-source-panel .pdf-page-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.full-document-pages {
  height: calc(100vh - 148px);
  min-height: 720px;
  overflow: auto;
  border: 0;
  border-radius: 18px;
  padding: 18px;
  background: #111418;
}

.full-document-page {
  display: block;
  width: min(100%, 980px);
  height: auto;
  margin: 0 auto 18px;
  border-radius: 4px;
  background: #1a1e24;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.full-document-page.current-source-page {
  outline: 4px solid rgba(110, 168, 158, 0.7);
  outline-offset: 4px;
}

/* ───────────────────────────────────────────────
   ANKI SETTINGS PANEL
   ─────────────────────────────────────────────── */

.anki-settings-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(360px, 1.3fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 22px;
}

.anki-settings-panel h2 {
  margin-bottom: 8px;
}

.anki-status,
.anki-sync-note {
  margin: 10px 0 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 750;
}

.anki-status.ok,
.anki-sync-note.ok {
  color: var(--accent-bright);
  background: rgba(110, 168, 158, 0.12);
}

.anki-status.warn,
.anki-sync-note.warn {
  color: var(--warn-color);
  background: rgba(196, 146, 64, 0.12);
}

/* ───────────────────────────────────────────────
   CALIBRATION / SWIPE
   ─────────────────────────────────────────────── */

.calibration-header p {
  max-width: 720px;
}

.calibration-stats {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.calibration-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -6px 0 22px;
}

.filter-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
  transition: background 120ms, border-color 120ms, color 120ms;
}

.filter-pill.active,
.filter-pill:hover {
  border-color: var(--accent);
  color: var(--bg);
  background: var(--accent);
}

.swipe-review {
  display: grid;
  justify-items: center;
  margin: 14px 0 24px;
}

.match-card {
  width: 100%;
  min-width: 0;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.match-card-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.match-columns {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.candidate-card,
.source-match-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  padding: 22px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-raised);
}

.candidate-card {
  transform: none;
  border-color: rgba(110, 168, 158, 0.18);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  justify-content: flex-start;
}

.source-match-card {
  min-width: 0;
  transform: none;
  padding: 18px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.candidate-card h2,
.source-match-card h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  color: #fff;
}

.candidate-answer {
  margin-top: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.candidate-answer p,
.source-match-card p {
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.source-match-card p {
  font-size: 17px;
}

.candidate-card small {
  margin-top: auto;
  color: var(--muted);
}

.source-match-card h2 {
  margin-bottom: 0;
  font-size: 18px;
  color: var(--accent);
}

.source-card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.source-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: 62%;
}

.source-meta-row span {
  display: inline-flex;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-meta-row span:first-child {
  max-width: 100%;
  color: var(--accent);
  background: rgba(110, 168, 158, 0.10);
  border-color: rgba(110, 168, 158, 0.20);
}

.swipe-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 14px;
  margin: 20px auto 6px;
  max-width: 680px;
  clear: both;
  position: relative;
  z-index: 1;
}

.calibration-actions {
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  max-width: 520px;
}

.swipe-button {
  min-height: 58px;
  border-radius: 12px;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.swipe-button span {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-right: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  font-size: 20px;
}

.swipe-button.reject {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.swipe-button.reject:hover {
  background: #a04040;
  border-color: #a04040;
}

.swipe-button.unsure {
  border-color: var(--warn-color);
  color: #0c0f14;
  background: var(--warn-color);
}

.swipe-button.unsure:hover {
  background: #a87e35;
  border-color: #a87e35;
}

.swipe-button.confirm {
  border-color: var(--accent);
  color: #0c0f14;
  background: var(--accent);
}

.swipe-button.confirm:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.match-navigation {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  font-weight: 750;
  font-size: 14px;
}

.match-navigation a {
  color: var(--accent);
  text-decoration: none;
}

.calibration-profile {
  margin-top: 24px;
}

.calibration-profile summary {
  cursor: pointer;
  font-weight: 800;
}

.calibration-empty {
  width: min(100%, 720px);
}

.calibration-header,
.calibration-stats,
.calibration-filters,
.calibration-profile {
  opacity: 0.92;
}

/* ───────────────────────────────────────────────
   COPILOT SPECIFIC
   ─────────────────────────────────────────────── */

.copilot-document-panel {
  position: sticky;
  top: 78px;
  overflow: hidden;
  padding: 0;
}

.duplicate-hints {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(196, 162, 90, 0.25);
  border-radius: 14px;
  background: rgba(196, 162, 90, 0.07);
}

.duplicate-hints summary {
  cursor: pointer;
  font-weight: 850;
  color: var(--warn-color);
}

.duplicate-hints article {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(196, 162, 90, 0.20);
}

.duplicate-hints p {
  margin: 6px 0;
}

.quality-check-panel {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(110, 168, 158, 0.18);
  border-radius: 14px;
  background: rgba(110, 168, 158, 0.05);
}

.quality-check-panel ul {
  display: grid;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 0;
  list-style: none;
}

.quality-check {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--accent-bright);
  font-size: 13px;
  font-weight: 750;
}

.quality-check::before {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  content: "✓";
  color: #0c0f14;
  background: var(--accent);
  font-size: 12px;
  flex-shrink: 0;
}

.quality-check.warn {
  color: var(--warn-color);
}

.quality-check.warn::before {
  content: "!";
  background: var(--warn-color);
  color: #0c0f14;
}

.quality-check-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
}

/* ───────────────────────────────────────────────
   RATIONALE / GUIDANCE
   ─────────────────────────────────────────────── */

.rationale-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface-raised);
}

.rationale-box summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

.rationale-box p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.guidance pre {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.55;
}

/* ───────────────────────────────────────────────
   STYLE EXAMPLES
   ─────────────────────────────────────────────── */

.style-list {
  display: grid;
  gap: 14px;
}

.style-example {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 0.85fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
}

.style-card,
.style-source {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.style-card p,
.style-source p {
  margin: 0;
  white-space: pre-wrap;
}

.style-card small,
.style-source span {
  color: var(--muted);
}

/* ───────────────────────────────────────────────
   FLASH MESSAGES / BADGES
   ─────────────────────────────────────────────── */

.flash-message {
  display: block;
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(110, 168, 158, 0.25);
  background: rgba(110, 168, 158, 0.10);
  color: var(--accent-bright);
  font-size: 14px;
  font-weight: 750;
}

.flash-error {
  border-color: rgba(192, 96, 96, 0.30);
  background: rgba(192, 96, 96, 0.10);
  color: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.internal-note {
  margin: -8px 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.shortcut-hint {
  max-width: 420px;
  text-align: right;
  font-size: 14px;
  color: var(--muted);
}

/* ───────────────────────────────────────────────
   SETTINGS HERO PAGE
   ─────────────────────────────────────────────── */

.settings-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: stretch;
  padding: 34px;
  border: 1px solid rgba(110, 168, 158, 0.14);
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 0%, rgba(110, 168, 158, 0.10), transparent 34%),
    linear-gradient(135deg, var(--surface) 0%, var(--surface-raised) 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

.settings-hero h1 {
  max-width: 720px;
  margin-bottom: 14px;
  font-size: clamp(34px, 5vw, 56px);
  letter-spacing: -0.04em;
}

.hero-copy {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.connection-card {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 190px;
  padding: 24px;
  border-radius: 24px;
  background: var(--surface-raised);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.connection-card strong {
  font-size: 22px;
  color: #fff;
}

.connection-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--warn-color);
  box-shadow: 0 0 0 7px rgba(196, 146, 64, 0.14);
}

.connection-card.is-connected .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 7px rgba(110, 168, 158, 0.14);
}

.setup-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.setup-step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-raised);
}

.step-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #0c0f14;
  background: var(--accent);
  font-weight: 850;
  flex-shrink: 0;
}

.setup-step.is-upcoming .step-number {
  background: var(--warn-color);
}

.setup-step h2 {
  margin-bottom: 6px;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.setup-step p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.anki-default-card,
.product-note-card {
  border-radius: 24px;
  padding: 28px;
}

.product-note-card p {
  margin-bottom: 0;
}

.relaxed-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.toggle-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(110, 168, 158, 0.16);
  border-radius: 18px;
  background: rgba(110, 168, 158, 0.05);
}

.toggle-card input {
  width: auto;
  margin-top: 4px;
}

.toggle-card strong,
.toggle-card small {
  display: block;
}

.toggle-card strong {
  color: var(--text);
}

.toggle-card small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.45;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

/* ───────────────────────────────────────────────
   SETUP BANNER (onboarding cards on home page)
   ─────────────────────────────────────────────── */

.setup-banner {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 20px 24px;
  border-radius: 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  background: var(--surface);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03), 0 8px 24px rgba(0, 0, 0, 0.30);
}

.setup-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(196, 162, 90, 0.12);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 20px;
}

.setup-banner-body {
  flex: 1;
  min-width: 0;
}

.setup-banner-body strong {
  display: block;
  font-size: 15px;
  color: #fff;
  margin-bottom: 4px;
}

.setup-banner-body p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.setup-banner-action {
  flex-shrink: 0;
}

/* ───────────────────────────────────────────────
   MISC COMPONENTS
   ─────────────────────────────────────────────── */

.review-pdf-preview {
  height: min(64vh, 760px);
  max-height: 760px;
  min-height: 520px;
}

.review-header-clean {
  align-items: flex-end;
}

.feedback-details {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.feedback-details:not([open]) {
  margin-top: 4px;
}

.feedback-details summary,
.settings-panel summary {
  cursor: pointer;
}

.feedback-details summary {
  color: var(--muted);
  font-weight: 800;
}

.card-stack {
  display: grid;
  gap: 16px;
}

.settings-panel {
  margin-top: 18px;
}

.settings-panel summary {
  cursor: pointer;
  font-weight: 850;
  color: var(--text);
}

/* ───────────────────────────────────────────────
   RESPONSIVE
   ─────────────────────────────────────────────── */

@media (max-width: 820px) {
  .topbar,
  .book-header,
  .review-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .split,
  .review-grid,
  .style-example,
  .stats {
    grid-template-columns: 1fr;
  }

  .compact-import {
    display: grid;
  }

  .anki-settings-panel,
  .anki-settings-form {
    grid-template-columns: 1fr;
  }

  .page {
    width: min(100% - 20px, 1160px);
    margin-top: 18px;
  }

  .actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 940px) {
  .home-layout,
  .clean-review-layout,
  .simple-stats,
  .clean-settings-form {
    grid-template-columns: 1fr;
  }

  .home-hero,
  .review-page-header,
  .project-hero,
  .next-step-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .project-primary-actions,
  .review-progress-pills {
    justify-content: start;
  }

  .clean-generate-form {
    min-width: 0;
    width: 100%;
  }

  .clean-settings-form .checkbox-label,
  .clean-settings-form button {
    grid-column: auto;
  }

  .clean-review-actions {
    flex-wrap: wrap;
    border-radius: 24px;
  }

  .clean-review-actions button {
    flex: 1 1 42%;
  }
}

@media (max-width: 860px) {
  .settings-hero,
  .setup-steps,
  .two-columns {
    grid-template-columns: 1fr;
  }

  .settings-hero {
    padding: 24px;
    border-radius: 22px;
  }

  .settings-hero h1 {
    font-size: 36px;
  }
}

@media (max-width: 1000px) {
  .copilot-layout {
    grid-template-columns: 1fr;
  }

  .copilot-document-panel {
    position: static;
  }
}

@media (max-width: 1120px) {
  .card-review-shell,
  .review-actions-bar {
    grid-template-columns: 1fr;
  }

  .shortcut-hint {
    text-align: left;
  }

  .review-card-header .muted {
    max-width: 100%;
    text-align: left;
  }

  .match-columns {
    grid-template-columns: 1fr;
  }

  .source-card-header {
    flex-direction: column;
  }

  .source-meta-row {
    justify-content: flex-start;
    max-width: 100%;
  }
}

@media (max-width: 820px) {
  .match-card {
    padding: 16px;
    border-radius: 18px;
  }

  .match-card-topline,
  .match-navigation {
    flex-direction: column;
  }

  .match-columns,
  .swipe-actions {
    grid-template-columns: 1fr;
  }

  .candidate-card,
  .source-match-card {
    min-height: unset;
    transform: none;
  }
}

@media (max-width: 760px) {
  .anki-target-grid {
    grid-template-columns: 1fr;
  }
}
