/* ═════════════════════════════════════════════════════════
   PYQ Anki Review — anki.css
   Self-contained. Same design tokens as quiz.css.
   ═════════════════════════════════════════════════════════ */

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bg: #f4f1ec;
  --surface: #fffdf9;
  --surface-alt: #f7f3ec;
  --surface-glass: rgba(255,253,249,0.82);
  --ink: #1a2537;
  --ink-secondary: #5a6a7e;
  --muted: #8896a7;
  --line: rgba(140,155,170,0.22);
  --accent: #1a7a6c;
  --accent-hover: #15614f;
  --accent-soft: rgba(26,122,108,0.12);
  --accent-glow: rgba(26,122,108,0.25);
  --correct: #10b981;
  --correct-soft: rgba(16,185,129,0.14);
  --correct-glow: rgba(16,185,129,0.3);
  --wrong: #ef4444;
  --wrong-soft: rgba(239,68,68,0.12);
  --wrong-glow: rgba(239,68,68,0.28);
  --warning: #f59e0b;
  --warning-soft: rgba(245,158,11,0.14);
  --hard-color: #f97316;
  --hard-soft: rgba(249,115,22,0.14);
  --easy-color: #3b82f6;
  --easy-soft: rgba(59,130,246,0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(60,50,40,0.08);
  --shadow-lg: 0 12px 40px rgba(60,50,40,0.12);
  --transition: 150ms cubic-bezier(0.4,0,0.2,1);
  --topbar-h: 56px;
}

body[data-theme="dark"] {
  --bg: #0a0f1a;
  --surface: #141c2b;
  --surface-alt: #1a2435;
  --surface-glass: rgba(20,28,43,0.88);
  --ink: #f0f4fb;
  --ink-secondary: #94a3b8;
  --muted: #64748b;
  --line: rgba(100,130,180,0.15);
  --accent: #2dd4a8;
  --accent-hover: #22b893;
  --accent-soft: rgba(45,212,168,0.12);
  --accent-glow: rgba(45,212,168,0.2);
  --correct-soft: rgba(16,185,129,0.16);
  --wrong-soft: rgba(239,68,68,0.14);
  --warning-soft: rgba(245,158,11,0.16);
  --hard-soft: rgba(249,115,22,0.16);
  --easy-soft: rgba(59,130,246,0.16);
  --shadow: 0 4px 24px rgba(0,0,0,0.28);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.38);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

button, input, select, textarea { font: inherit; color: var(--ink); }
img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

/* ── Layout ── */
.page-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
.back-btn:hover { color: var(--ink); background: var(--surface-alt); }

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

/* ── Deck selector ── */
#deck-select {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  max-width: 180px;
  transition: border-color var(--transition);
}
#deck-select:focus { outline: none; border-color: var(--accent); }

/* ── Stat strip ── */
.stat-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.stat-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.stat-chip--new { color: var(--easy-color); background: var(--easy-soft); border-color: transparent; }
.stat-chip--due { color: var(--correct); background: var(--correct-soft); border-color: transparent; }
.stat-chip--done { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition), transform var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
body[data-theme="dark"] .btn-primary { color: #022c22; font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover:not(:disabled) { background: var(--line); }

.btn-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  font-weight: 600;
}
.btn-accent:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}
body[data-theme="dark"] .btn-accent {
  background: rgba(45,212,168,0.18);
  color: #38e09d;
}
body[data-theme="dark"] .btn-accent:hover:not(:disabled) {
  color: #022c22;
}

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
}

.btn-danger {
  background: var(--wrong-soft);
  color: var(--wrong);
  border: 1px solid transparent;
}
.btn-danger:hover:not(:disabled) { background: var(--wrong); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; font-weight: 700; }

/* ── Main area ── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
  min-height: 0;
}

/* ── Card Stage ── */
.card-stage {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ── Flip Card 3D ── */
.flip-card {
  width: 100%;
  perspective: 1200px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 0.42s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.flip-card-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotateY(180deg);
  background: var(--surface);
}


/* ── Card content ── */
.card-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-label-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.card-label-dot--back { background: var(--correct); }

.card-content {
  flex: 1;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  min-height: 160px;
  max-height: 60vh; /* Enable scroll if content is too long */
  overflow-y: auto;
  overflow-x: auto;
  word-break: break-word;
  padding-right: 4px;
}

.card-content p { margin-bottom: 0.6em; }
.card-content p:last-child { margin-bottom: 0; }
.card-content strong { font-weight: 700; }
.card-content em { font-style: italic; }
.card-content ul, .card-content ol { padding-left: 1.4em; margin: 0.4em 0; }
.card-content li { margin: 0.2em 0; }
.card-content table { border-collapse: collapse; font-size: 0.9em; width: 100%; margin: 0.5em 0; }
.card-content td, .card-content th { border: 1px solid var(--line); padding: 5px 8px; }
.card-content th { background: var(--surface-alt); font-weight: 600; }

/* ── Cloze styles ── */
.cloze-blank {
  display: inline-block;
  min-width: 60px;
  border-bottom: 2px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 3px 3px 0 0;
  padding: 0 6px;
  color: transparent;
  user-select: none;
  font-size: 0.95em;
  vertical-align: baseline;
}

.cloze-revealed {
  background: var(--correct-soft);
  color: var(--correct);
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 600;
}

/* ── Card image ── */
.card-image {
  max-height: 300px;
  width: auto;
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.card-image-wrapper {
  position: relative;
  display: inline-block;
  margin: 0 auto;
  max-width: 100%;
}
.occlusion-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.occlusion-mask {
  position: absolute;
  background: #000;
  border: 1px solid rgba(255,255,255,0.2);
  transition: opacity 0.2s;
}
.flip-card-back .occlusion-mask {
  opacity: 0.4; /* Translucent on back */
  background: var(--accent); /* Tinted to show it was a mask */
}
/* Drawing mode */
.occlusion-editor-canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  z-index: 10;
}
.drawing-rect {
  position: absolute;
  border: 2px dashed var(--accent);
  background: rgba(45, 212, 168, 0.2);
  pointer-events: none;
}

/* ── Card actions row ── */
.card-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

/* ── Show Answer button ── */
.show-answer-btn {
  width: 100%;
  max-width: 640px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  letter-spacing: 0.01em;
}
.show-answer-btn:hover { background: var(--accent-hover); }
.show-answer-btn:active { transform: scale(0.98); }

/* ── Rating bar ── */
.rating-bar {
  width: 100%;
  max-width: 640px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform var(--transition), opacity var(--transition), box-shadow var(--transition);
  background: var(--surface-alt);
}
.rating-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.rating-btn:active { transform: scale(0.97); }

.rating-btn .interval-preview {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.75;
}

.rating-btn--again {
  background: var(--wrong-soft);
  color: var(--wrong);
  border-color: var(--wrong);
}
.rating-btn--again:hover { background: var(--wrong); color: #fff; }

.rating-btn--hard {
  background: var(--hard-soft);
  color: var(--hard-color);
  border-color: var(--hard-color);
}
.rating-btn--hard:hover { background: var(--hard-color); color: #fff; }

.rating-btn--good {
  background: var(--correct-soft);
  color: var(--correct);
  border-color: var(--correct);
}
.rating-btn--good:hover { background: var(--correct); color: #fff; }

.rating-btn--easy {
  background: var(--easy-soft);
  color: var(--easy-color);
  border-color: var(--easy-color);
}
.rating-btn--easy:hover { background: var(--easy-color); color: #fff; }

/* ── Empty view ── */
.empty-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 64px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-view h2 { font-size: 22px; color: var(--ink); }
.empty-view p { font-size: 14px; max-width: 360px; line-height: 1.6; }
.empty-view .empty-icon { font-size: 52px; line-height: 1; }

/* ── Session progress ── */
.session-progress {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.progress-track {
  height: 4px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.progress-label {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

/* ── Tags ── */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.card-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Dialogs / Modals ── */
dialog {
  cursor: pointer;
  border-radius: 4px;
}

/* ── Prompt Editor ── */
.prompt-textarea {
  width: 100%;
  height: 200px;
  padding: 0.75rem;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  resize: vertical;
  color: var(--ink);
  outline: none;
  transition: border-color var(--transition);
}
.prompt-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.prompt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ── Settings Dialog Wrapper ── */
#settings-modal {
  /* Inherits centered width/positioning from dialog element */
  width: min(680px, calc(100vw - 20px));
}
#settings-modal::backdrop { background: rgba(0,0,0,0.35); }
body[data-theme="dark"] #settings-modal::backdrop { background: rgba(0,0,0,0.6); }
.modal-inner { background: var(--surface); border-radius: 20px; display: flex; flex-direction: column; overflow: hidden; max-height: 90vh; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface); flex-shrink: 0;
}
.modal-head h2 { font-size: 16px; font-weight: 700; color: var(--ink); }
.modal-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 22px; border-top: 1px solid var(--line); background: var(--surface); flex-shrink: 0;
}

/* ── Settings Dialog & Sidebar ── */
.settings-body { display: flex; height: 480px; max-height: 68vh; background: var(--surface); overflow: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.settings-sidebar { width: 155px; background: var(--surface-alt); border-right: 1px solid var(--line); padding: 10px 6px; display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.settings-nav-item { padding: 9px 12px; border: 1px solid transparent; border-radius: var(--radius-xs); background: transparent; font-size: 13px; font-weight: 600; text-align: left; cursor: pointer; color: var(--muted); transition: all var(--transition); width: 100%; }
.settings-nav-item:hover { color: var(--ink); background: var(--accent-soft); }
.settings-nav-item.active { background: var(--surface); color: var(--accent); border-color: var(--line); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.settings-nav-divider { height: 1px; background: var(--line); margin: 6px 6px; }
.settings-content { flex: 1; padding: 20px 22px; overflow-y: auto; scrollbar-width: thin; }
.settings-pane { display: none; flex-direction: column; gap: 14px; animation: fadeInSettings 0.18s ease; }
@keyframes fadeInSettings { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
.settings-pane.active { display: flex; }

.section-heading { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 12px; }
.section-heading.mt-0 { margin-top: 0; }
.form-row { display: flex; gap: 1rem; }
.form-row .field { flex: 1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span, .field label { font-size: 12px; font-weight: 600; color: var(--ink-secondary); }
.field input, .field select { padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-alt); color: var(--ink); font-size: 13px; outline: none; transition: border-color var(--transition), box-shadow var(--transition); }
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.divider { height: 1px; background: var(--line); margin: 4px 0; }
.prompt-hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
dialog {
  border: none;
  border-radius: 20px;
  padding: 0;
  background: transparent;
  width: min(700px, calc(100vw - 24px));
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  margin: auto;
  max-height: 90vh;
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}
body[data-theme="dark"] dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}


.modal-inner {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px;
  overflow: hidden;
  max-height: 90vh;
}

/* ── Searchable Model Selector ── */
.model-search-wrap { display: grid; gap: 4px; position: relative; }
.model-list-container {
  max-height: 200px; overflow-y: auto; border: 1px solid var(--line);
  background: var(--surface-alt); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 1px; margin-top: 4px;
}
.model-search-input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 2px; }
.model-item {
  padding: 8px 10px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--line); transition: all var(--transition);
  text-align: left;
}
.model-item:last-child { border-bottom: none; }
.model-item:hover { background: var(--accent-soft); color: var(--accent); }
.model-item.selected { background: var(--accent); color: #fff; }
body[data-theme="dark"] .model-item.selected { color: #022c22; font-weight: 700; }
.model-loading { padding: 12px; text-align: center; color: var(--muted); font-size: 12px; }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.modal-head h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}
.modal-head p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-alt);
}

/* ── Forms ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label, .field > span, .field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field input,
.field select,
.field textarea {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--ink);
  transition: border-color var(--transition);
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 90px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Card type tabs ── */
.type-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--line);
}
.type-tab {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: background var(--transition), color var(--transition);
}
.type-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}

/* ── Card preview in editor ── */
.card-preview-mini {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  min-height: 48px;
  color: var(--ink-secondary);
  font-style: italic;
}
.card-preview-mini:not(:empty) { font-style: normal; color: var(--ink); }

/* ── AI modal progress ── */
.ai-progress {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 12px;
  color: var(--muted);
  min-height: 80px;
  border: 1px solid var(--line);
  overflow-y: auto;
  max-height: 200px;
  white-space: pre-wrap;
  word-break: break-word;
}

.generating-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
.generating-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

/* ── Generated card preview list ── */
.generated-cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.generated-card-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color var(--transition);
}
.generated-card-item.selected { border-color: var(--accent); background: var(--accent-soft); }

.generated-card-item input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.generated-card-text { flex: 1; font-size: 12px; line-height: 1.5; color: var(--ink); }
.generated-card-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  border-radius: 99px;
  background: var(--line);
  padding: 1px 7px;
  white-space: nowrap;
}

/* ── Deck list in manage modal ── */
.deck-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.deck-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.deck-item-info { flex: 1; min-width: 0; }
.deck-item-name { font-size: 14px; font-weight: 600; }
.deck-item-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.deck-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Import bookmarks list ── */
.import-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}
.import-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-alt);
  cursor: pointer;
  transition: border-color var(--transition);
}
.import-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.import-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; }
.import-item-info { flex: 1; min-width: 0; }
.import-item-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.import-item-meta { font-size: 11px; color: var(--muted); }

/* ── Slider ── */
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  background: none;
  border: none;
  padding: 4px 0;
}

/* ── Checkbox list for AI types ── */
.checkbox-group {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.checkbox-group input[type="checkbox"] { accent-color: var(--accent); }

/* ── Error / status messages ── */
.status-msg {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 6px 0;
}
.status-msg.error { color: var(--wrong); }
.status-msg.success { color: var(--correct); }

/* ── Topbar select all ── */
.select-all-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 0;
  flex-wrap: wrap;
}
.select-all-bar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
}

/* ── Empty bookmarks in import ── */
.empty-import {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 13px;
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

/* ── Section heading in modal ── */
.section-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ── New deck form ── */
.new-deck-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 12px;
    gap: 8px;
  }
  .topbar-center {
    order: 3;
    width: 100%;
    flex-wrap: wrap;
  }
  .topbar-right {
    flex-wrap: wrap;
    gap: 6px;
  }
  .topbar-right .btn span { display: none; }
  .topbar-right .btn { padding: 7px; }
  .stat-strip { flex-wrap: wrap; }

  .rating-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .flip-card-front,
  .flip-card-back {
    padding: 18px;
    min-height: 180px;
  }

  dialog { width: 100vw; max-height: 100vh; border-radius: var(--radius) var(--radius) 0 0; align-self: flex-end; margin-bottom: 0; }

  .form-row { grid-template-columns: 1fr; }

  .modal-head { padding: 14px 16px 12px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px; }

  .main-area { padding: 16px 12px 32px; }
}

/* ── Utility ── */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
