/* ============================================================
   Kartenmeister - German Card Generator
   Inspired by warm, playful illustration-forward design
   ============================================================ */

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

:root {
  --cream: #fdf0ce;
  --cream-dark: #f5e2ab;
  --gold: #edbe44;
  --gold-dark: #d4a420;
  --blue: #4361ee;
  --blue-light: #6b8bf5;
  --coral: #e9571f;
  --coral-light: #ff7a5c;
  --white: #fffaf0;
  --white-pure: #ffffff;
  --text: #1a1a1a;
  --text-muted: #7a6e60;
  --border: #ecdcb8;
  --green: #3cb371;
  --green-light: #e4f7ec;
  --red-light: #fde8e4;
  --radius: 20px;
  --radius-sm: 14px;
}

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

/* === Decorative clouds === */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 100px;
  background: var(--white-pure);
  opacity: 0.45;
  z-index: 0;
  pointer-events: none;
}
body::before {
  width: 180px; height: 70px;
  top: 160px; left: -40px;
}
body::after {
  width: 140px; height: 55px;
  bottom: 120px; right: -20px;
}

/* === German flag stripe === */
.flag-stripe {
  display: flex;
  height: 5px;
  position: relative;
  z-index: 1;
}
.stripe-black { flex: 1; background: var(--text); }
.stripe-red { flex: 1; background: var(--coral); }
.stripe-gold { flex: 1; background: #f5cd52; }

/* === Header === */
header {
  background: var(--white);
  color: var(--text);
  padding: 20px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 10;
  border-bottom: 2px solid var(--border);
}

header h1 {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
}

.header-home {
  color: inherit;
  text-decoration: none;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* === Navigation === */
.header-nav {
  display: flex;
  gap: 4px;
  margin-right: auto;
  margin-left: 24px;
}
.nav-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 10px;
  transition: all 0.15s;
}
.nav-link:hover {
  color: var(--text);
  background: var(--cream);
}
.nav-link.active {
  color: var(--blue);
  background: #eef2ff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cost-tracker {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 6px 14px;
  border-radius: 10px;
  background: var(--cream);
  line-height: 1.2;
}
.cost-amount {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
}
.cost-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.anki-status {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 50px;
  background: var(--cream);
  display: flex;
  align-items: center;
  gap: 7px;
}

.anki-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  display: inline-block;
  transition: all 0.3s;
}
.anki-status.connected .anki-dot { background: var(--green); box-shadow: 0 0 8px rgba(60,179,113,0.5); }
.anki-status.disconnected .anki-dot { background: var(--coral); }

/* === Settings / API Key === */
.settings-wrapper {
  position: relative;
}

.settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.key-badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 50px;
  transition: all 0.2s;
}
.key-badge.key-active {
  background: var(--green-light);
  color: var(--green);
}
.key-badge.key-inactive {
  background: var(--red-light);
  color: var(--coral);
}
.key-badge:hover {
  filter: brightness(0.95);
}

.settings-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--white-pure);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.12);
  z-index: 100;
}
.settings-panel.open {
  display: block;
}

.settings-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.settings-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}
.settings-hint a {
  color: var(--blue);
  text-decoration: underline;
}

.settings-key-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.settings-key-row input {
  flex: 1 1 140px;
  min-width: 0;
  font-size: 0.88rem;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  font-family: 'DM Sans', system-ui, sans-serif;
}
.settings-key-row input:focus {
  border-color: var(--blue);
  outline: none;
}

.btn-pill-danger {
  color: var(--coral) !important;
  border-color: var(--coral) !important;
}
.btn-pill-danger:hover {
  background: var(--red-light) !important;
}

/* === No-key feature gating === */
.no-key-notice {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--cream);
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 12px;
  line-height: 1.5;
}
body.has-api-key .no-key-notice { display: none; }
body.no-api-key .cost-tracker { display: none; }

.link-btn {
  background: none;
  border: none;
  color: var(--blue);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

input.topic-restricted {
  cursor: pointer;
  background: var(--cream) !important;
}

/* === Main === */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 36px 16px 60px;
  position: relative;
  z-index: 1;
}

/* === Controls === */
.controls {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 6px 0 var(--border);
  border: 2px solid var(--border);
}

/* Tabs - styled as chunky colored pills */
.type-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
}

.tab {
  flex: 1;
  padding: 16px 12px;
  border: 3px solid transparent;
  background: var(--cream);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tab-icon {
  font-size: 1.15rem;
  font-weight: 800;
  opacity: 0.4;
  font-family: 'DM Sans', monospace;
}

.tab-label {
  font-size: 0.8rem;
  font-weight: 700;
}

.tab:hover {
  background: var(--cream-dark);
}
.tab.active {
  border-color: var(--blue);
  background: var(--white);
  color: var(--blue);
  box-shadow: 0 4px 0 rgba(59, 95, 229, 0.2);
}
.tab.active .tab-icon { opacity: 1; }

/* Form */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1; }
.field label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.field input,
.field select,
.field textarea {
  padding: 12px 14px;
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  background: var(--cream);
  color: var(--text);
  transition: all 0.2s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(59, 95, 229, 0.1);
}
.field input::placeholder,
.field textarea::placeholder { color: #b8a88a; }

.field input[type="number"] { width: 85px; }

.field.is-disabled label { opacity: 0.5; }
.field select:disabled,
.field input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--cream);
}

/* Topic suggestions dropdown */
.topic-field { position: relative; }

.topic-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--white);
  border: 2px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.topic-suggestion {
  padding: 9px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.1s;
}
.topic-suggestion:hover, .topic-suggestion.highlighted {
  background: var(--cream);
  color: var(--blue);
}

/* Specific words */
.specific-words-section { margin-bottom: 22px; }

.toggle-words {
  background: none;
  border: none;
  color: var(--blue);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 4px 0;
}
.toggle-words:hover { text-decoration: underline; }

.words-input { margin-top: 10px; }
.words-input textarea { width: 100%; resize: vertical; }

/* === Buttons === */
.btn-primary {
  width: 100%;
  padding: 16px 24px;
  background: var(--coral);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 4px 0 #c44818;
  position: relative;
  top: 0;
}
.btn-primary:hover {
  top: -2px;
  box-shadow: 0 6px 0 #c44818;
}
.btn-primary:active {
  top: 2px;
  box-shadow: 0 2px 0 #c44818;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; top: 0; }

.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-sparkle {
  font-size: 1.2rem;
  display: inline-block;
}

.btn-secondary {
  padding: 12px 20px;
  background: var(--cream);
  color: var(--text);
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 3px 0 var(--border);
  position: relative;
  top: 0;
}
.btn-secondary:hover {
  top: -1px;
  box-shadow: 0 4px 0 var(--border);
  border-color: var(--blue);
  color: var(--blue);
}
.btn-secondary:disabled,
.btn-secondary:disabled:hover {
  opacity: 0.5;
  cursor: not-allowed;
  top: 0;
  box-shadow: 0 3px 0 var(--border);
  border-color: var(--border);
  color: var(--text);
}

.btn-pill {
  padding: 7px 16px;
  background: var(--cream);
  border: 2px solid var(--border);
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-pill:hover { border-color: var(--blue); color: var(--blue); background: var(--white); }

/* === Loading === */
.loading {
  text-align: center;
  padding: 56px 24px;
}

.loading-cards {
  display: flex;
  justify-content: center;
  position: relative;
  width: 120px;
  height: 90px;
  margin: 0 auto 24px;
}

.loading-card {
  width: 72px;
  height: 90px;
  border-radius: 12px;
  position: absolute;
  top: 0;
  left: 50%;
  transform-origin: center bottom;
  animation: card-fan 2s ease-in-out infinite;
}
.lc1 { background: var(--coral); z-index: 1; animation-delay: 0s; }
.lc2 { background: var(--blue); z-index: 2; animation-delay: 0.15s; }
.lc3 { background: var(--gold); z-index: 3; animation-delay: 0.3s; }

@keyframes card-fan {
  0%, 100% { transform: translateX(-50%) rotate(0deg) translateY(0); }
  25% { transform: translateX(-80%) rotate(-12deg) translateY(-8px); }
  75% { transform: translateX(-20%) rotate(12deg) translateY(-8px); }
}

.loading-text {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.loading-subtext {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
  opacity: 0.75;
}

/* === Error === */
.error-box {
  background: var(--red-light);
  color: #9f1239;
  padding: 16px 22px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid #fda4af;
}

/* === Results === */
.results { margin-top: 32px; }

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.results-header h2 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--text);
}
.selection-count {
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.results-actions { display: flex; gap: 8px; }

/* === Card grid === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card-preview {
  background: var(--white);
  border: 2.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: 0 4px 0 var(--border);
}
.card-preview:hover {
  transform: translateY(-4px) rotate(-0.5deg);
  box-shadow: 0 8px 0 var(--border);
}
.card-preview.selected {
  border-color: var(--blue);
  background: #f5f0e0;
  box-shadow: 0 4px 0 rgba(67, 97, 238, 0.25);
}

/* Custom checkbox */
.card-check {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2.5px solid var(--border);
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.card-preview.selected .card-check {
  background: var(--blue);
  border-color: var(--blue);
}
.card-preview.selected .card-check::after {
  content: '';
  width: 7px;
  height: 11px;
  border: 2.5px solid var(--white);
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

/* Card content */
.card-word {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 400;
  margin-bottom: 4px;
  padding-right: 36px;
}

.card-english {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 10px;
}

.card-type-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

/* Badge colors - warm, flat tones */
.badge-noun { background: #dbeafe; color: #2563eb; }
.badge-verb { background: #d4f5e0; color: #16a34a; }
.badge-adjective { background: #fef3c7; color: #b45309; }
.badge-adverb { background: #fce7f3; color: #be185d; }
.badge-preposition { background: #e0e7ff; color: #4338ca; }
.badge-conjunction { background: #f3e8ff; color: #7c3aed; }
.badge-grammar { background: var(--cream); color: var(--gold-dark); border: 1.5px solid var(--gold); }

.card-example {
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 2px dashed var(--border);
  padding-top: 10px;
  margin-top: 6px;
  line-height: 1.5;
}

/* Grammar cards */
.card-sentence {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  padding-right: 36px;
  line-height: 1.45;
}

.card-sentence .blank {
  display: inline-block;
  min-width: 56px;
  border-bottom: 3px solid var(--gold);
  margin: 0 3px;
}

.card-answer {
  color: var(--blue);
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

/* Drill type label */
.card-drill-type {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Word chips for order cards */
.card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
  padding-right: 32px;
}

.word-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--gold);
  color: var(--text);
}

/* Instruction banner for transform cards */
.card-instruction {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 6px;
}

/* === Card image slots === */
.card-images {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px dashed var(--border);
}

.img-slot {
  flex: 1;
  aspect-ratio: 4/3;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.img-slot.empty {
  border: 2px dashed var(--border);
  background: var(--cream);
  display: flex;
  flex-direction: column;
  transition: all 0.15s;
}
.img-slot.empty:hover, .img-slot.dragover {
  border-color: var(--blue);
  background: #eef2ff;
}

.img-slot-inner {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.img-slot-icon {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--border);
  transition: color 0.15s;
}
.img-slot.empty:hover .img-slot-icon { color: var(--blue); }

.img-slot-label {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.img-slot-back {
  border-style: dotted;
}
.img-slot-back.empty { opacity: 0.7; }
.img-slot-back.empty:hover { opacity: 1; }

.img-url-bar {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
  background: var(--white);
  border-radius: 0 0 6px 6px;
}
.img-url-icon {
  padding-left: 5px;
  font-size: 0.6rem;
  flex-shrink: 0;
}
.img-url-input {
  width: 100%;
  border: none;
  padding: 5px 5px;
  font-size: 0.65rem;
  font-family: inherit;
  background: transparent;
  color: var(--text);
  outline: none;
}
.img-url-input::placeholder { color: #aaa; }
.img-url-input:focus { background: #f5f7ff; }
.img-slot.empty:hover .img-url-bar { background: #f5f7ff; }

.img-slot.filled {
  background: var(--cream);
}
.img-slot.filled img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.img-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}
.img-slot.filled:hover .img-remove { display: flex; }

/* Article colors */
.art-der { color: var(--blue); font-weight: 800; }
.art-die { color: var(--coral); font-weight: 800; }
.art-das { color: var(--gold-dark); font-weight: 800; }

/* === Bottom bar === */
.bottom-bar {
  display: flex;
  align-items: end;
  gap: 16px;
  padding: 24px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 4px 0 var(--border);
  border: 2px solid var(--border);
}
.bottom-bar .field { min-width: 200px; }
.bottom-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.bottom-actions .btn-primary { width: auto; }

/* === Toast === */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 100;
  box-shadow: 0 4px 0 rgba(0,0,0,0.08);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green-light); color: #166534; }
.toast.error { background: var(--red-light); color: #9f1239; }
.toast.info { background: var(--cream-dark); color: var(--text); }

/* === Card preview modal === */
.card-modal-overlay[hidden] {
  display: none;
}
.card-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card-modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  border: 2px solid var(--border);
  overflow: hidden;
}

.card-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  background: var(--cream);
  gap: 12px;
}

.card-modal-tabs {
  display: flex;
  gap: 6px;
}

.card-modal-tab {
  padding: 7px 18px;
  border: 2px solid var(--border);
  border-radius: 50px;
  background: var(--white);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.card-modal-tab:hover { border-color: var(--blue); color: var(--blue); }
.card-modal-tab.active { background: var(--blue); color: var(--white-pure); border-color: var(--blue); }

.card-modal-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.card-modal-nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
}
.card-modal-nav-btn:hover { border-color: var(--blue); color: var(--blue); }

.card-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
  flex-shrink: 0;
}
.card-modal-close:hover { background: var(--red-light); border-color: #fda4af; color: #9f1239; }

.card-modal-body {
  flex: 1;
  min-height: 70vh;
  overflow: hidden;
  background: #e8e8e8;
  display: flex;
  flex-direction: column;
}

.card-modal-body iframe {
  width: 100%;
  flex: 1;
  min-height: 0;
  border: none;
  display: block;
}

.card-modal-body iframe[hidden] { display: none; }

.img-override-strip {
  background: var(--white-pure, #fff);
  padding: 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  box-sizing: border-box;
}

.img-override-strip[hidden] { display: none; }

.img-override-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
}

.img-override-slot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.img-override-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px dashed var(--border, #cbd5e1);
  border-radius: 6px;
  background: #f8fafc;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-override-tile:hover {
  border-color: var(--blue, #2563eb);
}

.img-override-thumb {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.img-override-plus {
  font-size: 1.4rem;
  color: var(--text-muted, #94a3b8);
  font-weight: 300;
  line-height: 1;
  pointer-events: none;
}

.img-override-tile.has-image .img-override-plus { display: none; }

.img-override-url {
  width: 100%;
  font-size: 0.7rem;
  padding: 3px 6px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 4px;
  background: #fff;
  box-sizing: border-box;
}

.img-override-url:focus {
  outline: none;
  border-color: var(--blue, #2563eb);
}

.img-override-revert {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.img-override-revert:hover { background: rgba(0, 0, 0, 0.75); }

/* Hint that cards are clickable for preview */
.card-preview .card-preview-hint {
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 0.65rem;
  color: var(--border);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.card-preview:hover .card-preview-hint { opacity: 1; }

/* Make checkbox a bigger click target */
.card-check {
  z-index: 2;
}

/* === Page content (About, Setup) === */
.page-content {
  background: var(--white);
  border-radius: var(--radius);
  padding: 36px 40px;
  border: 2px solid var(--border);
}

.page-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

/* About page */
.about-section {
  margin-bottom: 28px;
}
.about-section h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}
.about-section p {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 8px;
}
.about-section a {
  color: var(--blue);
  text-decoration: underline;
}

.about-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.about-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.about-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white-pure);
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.about-step p {
  margin: 2px 0 0;
  font-size: 0.9rem;
}

.about-subheading {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 16px 0 8px;
}
.about-key-steps {
  margin: 8px 0 12px;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.8;
}
.about-key-steps a {
  color: var(--blue);
  text-decoration: underline;
}
.about-key-steps code {
  background: var(--cream);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.88rem;
}

.about-card-types {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.about-type {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  background: var(--cream);
  border-radius: var(--radius-sm);
}
.about-type-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--white);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.about-type p {
  margin: 2px 0 0;
  font-size: 0.88rem;
}

/* Setup page */
.setup-step {
  margin-bottom: 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.setup-step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--cream);
  border-bottom: 2px solid var(--border);
}
.setup-step-header h3 {
  font-size: 1rem;
  font-weight: 700;
}
.setup-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white-pure);
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.setup-step-body {
  padding: 20px;
}
.setup-step-body p {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.setup-instructions {
  margin: 12px 0;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.8;
}
.setup-instructions code {
  font-size: 0.95rem;
}

.setup-code {
  background: var(--cream);
  padding: 3px 10px;
  border-radius: 6px;
  font-family: 'DM Sans', monospace;
  font-weight: 700;
  user-select: all;
}

.setup-code-block {
  background: var(--cream);
  padding: 12px 16px;
  border-radius: 8px;
  font-family: 'DM Sans', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 8px 0 12px;
  overflow-x: auto;
  user-select: all;
}
.setup-code-block code {
  font-family: inherit;
  background: none;
  padding: 0;
}

.setup-links {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.setup-link-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Add-on list */
.addon-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}
.addon-item {
  padding: 14px 18px;
  background: var(--cream);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.addon-info p {
  font-size: 0.85rem;
  margin: 4px 0 0;
}
.addon-info .addon-hint {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--cream-dark);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}
.addon-info .addon-hint strong { color: var(--text); }
.addon-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--blue);
  color: var(--white-pure);
  margin-left: 8px;
  vertical-align: middle;
}
.addon-tag-optional {
  background: var(--gold);
  color: var(--text);
}
.addon-code-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.addon-link {
  font-size: 0.78rem;
  color: var(--blue);
  text-decoration: underline;
}

.setup-status {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--cream);
  border-radius: 10px;
}
.setup-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.setup-status-label {
  font-weight: 600;
  font-size: 0.9rem;
}
.setup-status-value {
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.setup-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  display: inline-block;
}
.dot-ok { background: var(--green); box-shadow: 0 0 8px rgba(60,179,113,0.4); }
.dot-err { background: var(--coral); }
.status-ok { color: var(--green); font-weight: 600; }
.status-err { color: var(--coral); font-weight: 600; }

.setup-names {
  margin: 16px 0;
}
.setup-names .field {
  margin-bottom: 12px;
}
.setup-names-row {
  display: flex;
  gap: 12px;
}
.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
}

.setup-actions {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}

.setup-log {
  margin-top: 16px;
  padding: 14px 18px;
  background: #faf8f4;
  border: 2px solid var(--border);
  border-radius: 10px;
}
.setup-log h4 {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.setup-log ul {
  list-style: none;
  padding: 0;
  font-size: 0.84rem;
  line-height: 1.8;
}
.setup-log li { padding-left: 16px; position: relative; }
.setup-log li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}
.log-created::before { background: var(--green); }
.log-skipped::before { background: var(--gold); }
.log-error::before { background: var(--coral); }
.log-error { color: var(--coral); }

/* === Responsive === */
@media (max-width: 640px) {
  header { padding: 16px; flex-wrap: wrap; gap: 10px; }
  header h1 { font-size: 1.35rem; }
  .header-nav { order: 3; width: 100%; justify-content: center; }
  .form-row { flex-direction: column; }
  .type-tabs { flex-direction: column; gap: 6px; }
  .tab { flex-direction: row; justify-content: center; }
  .bottom-bar { flex-direction: column; align-items: stretch; }
  .bottom-bar .field { min-width: auto; }
  .card-grid { grid-template-columns: 1fr; }
  main { padding: 20px 12px 48px; }
  .controls { padding: 20px; }
  .page-content { padding: 24px 20px; }
  .setup-names-row { flex-direction: column; }
  .setup-actions { flex-direction: column; }
}

/* ============================================================
   LESSON-FIRST UI
   ============================================================ */

.lesson-controls, .lesson-list-controls { padding-bottom: 20px; }

.lesson-intro { margin-bottom: 18px; }
.lesson-hero-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.9rem;
  line-height: 1.15;
  margin-bottom: 6px;
  color: var(--text);
}
.lesson-hero-sub { color: var(--text-muted); font-size: 1rem; max-width: 56ch; }

.lesson-actions-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.refresh-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .92rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

/* Lesson container */
.lesson {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
  margin-top: 22px;
  position: relative;
  z-index: 1;
}

.lesson-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.lesson-title {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 6px;
}
.lesson-overview {
  color: var(--text);
  max-width: 65ch;
  margin-bottom: 8px;
}
.lesson-meta {
  font-size: .88rem;
  color: var(--text-muted);
  letter-spacing: .02em;
}

.lesson-section { margin-bottom: 28px; }
.lesson-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--cream-dark);
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.lesson-section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  color: var(--text);
}
.lesson-section-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.view-toggle {
  display: inline-flex;
  background: var(--cream-dark);
  border-radius: 999px;
  padding: 3px;
}
.view-btn {
  background: transparent;
  border: 0;
  padding: 5px 14px;
  font-size: .85rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}
.view-btn.active {
  background: var(--white-pure);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.empty-section {
  color: var(--text-muted);
  font-style: italic;
  padding: 12px 0;
}

/* Lesson item (list view) */
.lesson-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.item-select {
  padding-top: 4px;
  flex-shrink: 0;
}
.item-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--blue);
}
.item-main { flex-grow: 1; min-width: 0; }
.item-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.item-de { font-size: 1.1rem; color: var(--text); }
.vocab-article { color: var(--text-muted); font-weight: 500; }
.vocab-plural { font-size: .85rem; color: var(--text-muted); margin-left: 6px; }
.item-en { color: var(--text-muted); font-size: .95rem; }

.item-literal, .item-context {
  font-size: .88rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.item-example {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--cream);
  border-radius: 10px;
  border-left: 3px solid var(--gold);
}
.item-example-de { color: var(--text); font-size: .95rem; }
.item-example-en { color: var(--text-muted); font-size: .85rem; font-style: italic; margin-top: 2px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--cream-dark);
  color: var(--text);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-type { background: #dbeafe; color: #1e40af; text-transform: capitalize; }
.badge-register { background: #ede9fe; color: #5b21b6; text-transform: capitalize; }
.badge-level { background: var(--gold); color: var(--text); }

/* Grammar item */
.grammar-item { flex-direction: row; }
.grammar-head { margin-bottom: 8px; }
.grammar-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: var(--text);
}
.grammar-topic { color: var(--text-muted); font-size: .88rem; margin-top: 2px; }
.grammar-explain { color: var(--text); margin-bottom: 10px; line-height: 1.55; }
.grammar-tip, .grammar-mistakes {
  background: var(--cream);
  padding: 8px 12px;
  border-radius: 10px;
  margin-top: 10px;
  font-size: .92rem;
  line-height: 1.5;
}

.pattern-table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: .9rem;
}
.pattern-table th, .pattern-table td {
  padding: 6px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.pattern-table th { background: var(--cream-dark); font-weight: 600; }

/* Exercise item */
.exercise-item { background: var(--white-pure); }
.exercise-answer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.exercise-answer {
  display: inline-block;
  padding: 4px 10px;
  background: var(--green-light);
  color: #065f46;
  border-radius: 8px;
  font-weight: 600;
}

/* Compact table view */
.lesson-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white-pure);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.lesson-table th, .lesson-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: .95rem;
}
.lesson-table th { background: var(--cream); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.lesson-table tr:last-child td { border-bottom: 0; }
.lesson-table tr:hover { background: var(--cream); cursor: pointer; }
.lesson-table .row-check { width: 36px; }

/* Lesson list page */
.lesson-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.lesson-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: transform .12s ease, box-shadow .12s ease;
}
.lesson-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.06); }
.lesson-card-link {
  display: block;
  padding: 20px 22px;
  text-decoration: none;
  color: inherit;
}
.lesson-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.lesson-card-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.25rem;
  line-height: 1.2;
}
.lesson-card-overview { color: var(--text-muted); font-size: .92rem; margin-bottom: 10px; line-height: 1.5; }
.lesson-card-meta { color: var(--text-muted); font-size: .82rem; }
.lesson-card-dot { margin: 0 6px; }
.lesson-card-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  opacity: 0;
  transition: opacity .15s ease;
}
.lesson-card:hover .lesson-card-delete { opacity: 1; }

/* Selection count line */
.selection-count { color: var(--text-muted); font-size: .92rem; }

/* TTS speaker button */
.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin-left: 6px;
  background: var(--cream);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: .95rem;
  line-height: 1;
  vertical-align: middle;
  transition: background .12s ease, color .12s ease;
}
.tts-btn:hover {
  background: var(--gold);
  color: var(--text);
}
.tts-btn:active { transform: scale(0.94); }

/* ============================================================
   Interactive exercise widgets
   ============================================================ */

.ex-widget {
  padding: 12px 0 4px;
}
.ex-sentence {
  font-size: 1.08rem;
  line-height: 1.6;
  margin-bottom: 12px;
  color: var(--text);
}
.ex-blank {
  display: inline-block;
  min-width: 72px;
  padding: 0 6px;
  border-bottom: 2px solid var(--blue);
  text-align: center;
  color: var(--blue);
  font-weight: 600;
}

/* Options buttons */
.ex-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.ex-option {
  padding: 8px 14px;
  background: var(--white-pure);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  font-size: .95rem;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.ex-option:hover { background: var(--cream); border-color: var(--gold); }
.ex-option-selected { border-color: var(--blue); background: #e6eeff; }
.ex-option-correct { border-color: #065f46; background: var(--green-light); color: #065f46; }
.ex-option-wrong { border-color: #b91c1c; background: var(--red-light); color: #991b1b; }

/* Order chips */
.ex-order .ex-answer-line {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--cream);
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
}
.ex-placed {
  display: inline-block;
  padding: 4px 10px;
  background: var(--blue-light);
  color: #fff;
  border-radius: 999px;
  font-weight: 500;
  cursor: pointer;
}
.ex-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.ex-chip {
  padding: 4px 12px;
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: .92rem;
  transition: background .12s ease;
}
.ex-chip:hover { background: var(--cream); }
.ex-chip-used {
  opacity: .35;
  cursor: default;
}

.ex-actions { display: flex; gap: 8px; margin-bottom: 10px; }

/* Transform / cloze */
.ex-transform-head { margin-bottom: 8px; }
.ex-instruction { margin-bottom: 4px; color: var(--text); }
.ex-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  background: var(--white-pure);
  color: var(--text);
}
.ex-input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
textarea.ex-input { margin-bottom: 10px; resize: vertical; }

.ex-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ex-cloze .ex-input { flex: 1; min-width: 0; }
.ex-row .btn-primary { width: auto; flex: 0 0 auto; }
.ex-translation { margin-top: 6px; color: var(--text-muted); font-size: .92rem; }
.ex-hint { margin-top: 6px; font-size: .88rem; color: var(--text-muted); }
.ex-hint-label {
  display: inline-block;
  padding: 1px 8px;
  background: var(--cream-dark);
  border-radius: 999px;
  margin-right: 4px;
  font-weight: 600;
  font-size: .78rem;
  color: var(--text);
}
button.ex-hint-toggle {
  border: none;
  cursor: pointer;
  font-family: inherit;
}
button.ex-hint-toggle:hover { background: var(--cream); }
button.ex-hint-toggle[aria-expanded="true"] { background: var(--blue-light, var(--cream)); }

/* Feedback */
.ex-feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  margin-top: 6px;
  background: var(--cream);
  font-size: .95rem;
  flex-wrap: wrap;
}
.ex-feedback-ok { background: var(--green-light); color: #065f46; }
.ex-feedback-bad { background: var(--red-light); color: #991b1b; }
.ex-correct-answer { color: var(--text); font-weight: 600; }
.btn-reveal-answer { font-size: .82rem; }

/* Kind tabs (Vocabulary vs Grammar) — top-level lesson type */
.kind-tabs {
  display: inline-flex;
  background: var(--cream-dark);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 12px;
  margin-right: 12px;
}
.kind-tab {
  background: transparent;
  border: 0;
  padding: 8px 22px;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  letter-spacing: .01em;
}
.kind-tab.active {
  background: var(--white-pure);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* Mode tabs (Level vs Custom) */
.mode-tabs {
  display: inline-flex;
  background: var(--cream-dark);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 16px;
}
.mode-tab {
  background: transparent;
  border: 0;
  padding: 6px 18px;
  font-size: .92rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 500;
}
.mode-tab.active {
  background: var(--white-pure);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.custom-key-notice {
  padding: 10px 14px;
  border-radius: 10px;
  background: #fef3c7;
  color: #78350f;
  font-size: .9rem;
  border: 1px solid #fde68a;
  margin-bottom: 12px;
}

/* Source badges (seed vs custom) */
.badge-seed { background: #d1fae5; color: #065f46; }
.badge-custom { background: #e0f2fe; color: #0c4a6e; }

/* Kind badges (vocab vs grammar) */
.badge-kind { font-weight: 600; }
.badge-kind-vocab { background: #ede9fe; color: #5b21b6; }
.badge-kind-grammar { background: #fef3c7; color: #92400e; }

.lesson-card-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lesson-warning {
  margin-bottom: 18px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #fde68a;
  font-size: .92rem;
  line-height: 1.5;
}
.lesson-warning strong { font-weight: 600; }

/* My Lessons tabs (Custom vs CEFR history) */
.library-tabs {
  display: inline-flex;
  background: var(--cream-dark);
  border-radius: 12px;
  padding: 4px;
  margin: 8px 0 16px;
}
.library-tab {
  background: transparent;
  border: 0;
  padding: 8px 22px;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  letter-spacing: .01em;
}
.library-tab.active {
  background: var(--white-pure);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ============================================================
   Semantic-router match card
   ============================================================ */

.route-match-card {
  margin: 18px 0;
  padding: 18px 22px;
  border-radius: 14px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
}
.route-match-suggest {
  border-color: #fbbf24;
  background: #fffbeb;
}
.route-match-auto {
  border-color: #86efac;
  background: #f0fdf4;
}
.route-match-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.route-match-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #1f2937;
  color: white;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.route-match-suggest .route-match-pill { background: #b45309; }
.route-match-auto .route-match-pill { background: #166534; }
.route-match-orig {
  color: #64748b;
  font-size: 0.85rem;
  font-style: italic;
}
.route-match-title {
  margin: 4px 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
}
.route-match-overview {
  margin: 0 0 8px;
  color: #475569;
  font-size: 0.92rem;
  line-height: 1.45;
}
.route-match-meta {
  margin: 0 0 10px;
  color: #64748b;
  font-size: 0.82rem;
}
.route-match-reason {
  margin: 0 0 12px;
  color: #6b7280;
  font-size: 0.82rem;
  font-style: italic;
}
.route-match-line {
  margin: 0 0 12px;
  color: #1f2937;
  font-size: 0.95rem;
}
.route-match-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============================================================
   Study ↔ Cards view switch (top-level lesson tabs)
   ============================================================ */

.lesson-view-tabs {
  display: inline-flex;
  background: var(--cream-dark);
  border-radius: 999px;
  padding: 4px;
  margin: 8px 0 18px;
}
.lesson-view-tab {
  background: transparent;
  border: 0;
  padding: 7px 20px;
  font-size: .95rem;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}
.lesson-view-tab.active {
  background: var(--white-pure);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.10);
}

/* ============================================================
   Sticky in-lesson section nav
   ============================================================ */

.lesson-section-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 4px;
  margin: 0 -4px 14px;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
}
.lesson-section-nav-item {
  background: var(--cream-dark);
  border: 0;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  transition: background-color .15s, color .15s;
}
.lesson-section-nav-item:hover { color: var(--text); }
.lesson-section-nav-item.active {
  background: var(--text);
  color: var(--white-pure);
}
.lesson-section-nav-top {
  margin-left: auto;
  background: var(--cream-dark);
  border: 0;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  transition: background-color .15s, color .15s;
}
.lesson-section-nav-top:hover {
  background: var(--text);
  color: var(--white-pure);
}

/* Offset section headings so they aren't hidden under the sticky nav
   when scrolled to via the nav or a hash link. */
.study-section,
.cards-section { scroll-margin-top: 70px; }

/* ============================================================
   Study view (compact reference sheet)
   ============================================================ */

.study-section { margin-bottom: 26px; }
.study-section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.35rem;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--cream-dark);
  margin-bottom: 12px;
}

.study-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.study-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.study-row:last-child { border-bottom: 0; }

.study-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.study-de { font-size: 1.04rem; color: var(--text); }
.study-article { color: var(--text-muted); font-weight: 500; }
.study-en { color: var(--text-muted); font-size: .95rem; }
.study-type {
  font-size: .72rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--cream-dark);
  color: var(--text-muted);
  text-transform: capitalize;
  letter-spacing: .02em;
}
.study-example {
  margin-top: 4px;
  padding-left: 4px;
  color: var(--text-muted);
  font-size: .88rem;
  line-height: 1.5;
}
.study-example em { font-style: italic; opacity: .85; }
.study-note { margin-top: 4px; color: var(--text-muted); font-size: .85rem; }

/* Grammar study block */
.study-grammar {
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 10px;
}

/* Lesson prose (intro/outro for grammar lessons) */
.study-prose {
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  line-height: 1.55;
  color: var(--text-default);
}
.study-prose p { margin: 0 0 10px; }
.study-prose p:last-child { margin-bottom: 0; }
.study-prose ul, .study-prose ol { margin: 6px 0 10px 20px; padding: 0; }
.study-prose li { margin: 2px 0; }
.study-prose li > ul, .study-prose li > ol { margin: 4px 0 4px 18px; }
.study-prose strong { font-weight: 600; }
.study-prose em { font-style: italic; }
.study-prose code {
  background: var(--bg-muted, #f4f4f4);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: .92em;
}
.study-prose code strong { font-weight: 700; color: var(--coral); }
.study-prose h1, .study-prose h2, .study-prose h3 {
  margin: 14px 0 8px;
  font-weight: 600;
}
.study-prose h1 { font-size: 1.25rem; }
.study-prose h2 { font-size: 1.1rem; }
.study-prose h3 { font-size: 1rem; }
.study-prose .md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  font-size: .95em;
}
.study-prose .md-table th,
.study-prose .md-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.study-prose .md-table thead th {
  background: var(--bg-muted, #f4f4f4);
  font-weight: 600;
}
.study-prose .md-table tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.015);
}

/* Exercise study block */
.study-exercise {
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 10px;
}
.study-exercise-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.study-exercise-num {
  font-size: .8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.study-grammar-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 6px;
}
.study-grammar-explain {
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 10px;
}
.study-grammar-example {
  padding: 4px 0;
  color: var(--text);
  font-size: .95rem;
}
.study-grammar-example em {
  color: var(--text-muted);
  font-style: italic;
}
.study-grammar-tip {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--cream);
  border-radius: 10px;
  font-size: .9rem;
  line-height: 1.5;
}

/* ============================================================
   Cards view (rich grid, selectable, previewable)
   ============================================================ */

.cards-section { margin-bottom: 26px; }
.cards-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--cream-dark);
  margin-bottom: 14px;
}
.cards-section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  color: var(--text);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.card-tile {
  position: relative;
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 14px 14px 42px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  min-width: 0;
}
.card-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
  border-color: var(--gold);
}
.card-tile.card-tile-exercise {
  cursor: default;
  padding-left: 42px;
}
.card-tile.card-tile-exercise:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: none;
}

.card-tile-check {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.card-tile-check .item-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.card-tile-preview {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: 0;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  opacity: 0;
  transition: opacity .15s ease;
}
.card-tile:hover .card-tile-preview { opacity: 1; }
.card-tile-preview:hover { background: var(--cream); color: var(--text); }

.card-tile-body { min-width: 0; }
.tile-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.tile-de { color: var(--text); font-size: 1.02rem; word-break: break-word; }
.tile-en { color: var(--text-muted); font-size: .92rem; line-height: 1.4; }
.tile-badges { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.tile-note, .tile-explain { margin-top: 6px; color: var(--text-muted); font-size: .85rem; line-height: 1.5; }
.tile-example {
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--cream);
  border-radius: 8px;
  border-left: 3px solid var(--gold);
  font-size: .85rem;
  color: var(--text);
}

/* Exercise tile hosts the interactive widget */
.card-tile-exercise .exercise-mount { margin-top: 6px; }

/* ============================================================
   Study tables (compact tabular Vocab / Phrases)
   ============================================================ */

.study-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.study-table tr.study-row {
  border-bottom: 1px solid var(--border);
}
.study-table tr.study-row:last-child { border-bottom: 0; }
.study-table td {
  padding: 8px 12px;
  vertical-align: middle;
}

.study-table .col-art {
  width: 56px;
  text-align: center;
}
.study-table .col-de {
  white-space: nowrap;
  font-size: 1.05rem;
}
.study-table .col-en {
  width: 50%;
  font-size: .95rem;
}

.study-de-btn {
  background: transparent;
  border: 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  vertical-align: baseline;
  border-radius: 4px;
  transition: color .12s ease, background .12s ease;
}
.study-de-btn:hover {
  color: var(--blue);
  background: var(--cream);
}
.study-de-btn strong { font-weight: 600; }

/* Color-coded German articles */
.art {
  display: inline-block;
  min-width: 36px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: .02em;
  background: var(--cream-dark);
  color: var(--text-muted);
}
.art-masc {
  background: #dbeafe;
  color: #1e40af;
}
.art-fem {
  background: #fce7f3;
  color: #9d174d;
}
.art-neut {
  background: #d1fae5;
  color: #065f46;
}

/* Masked English (click to reveal) */
.study-en {
  color: var(--text-muted);
  font-size: .95rem;
  line-height: 1.4;
}
.study-en.masked {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 8px;
  background: var(--cream);
  border: 1px dashed var(--border);
  color: #94a3b8;
  font-size: .85rem;
  cursor: pointer;
  user-select: none;
  transition: background .12s ease;
}
.study-en.masked:hover {
  background: var(--cream-dark);
}

/* ============================================================
   Collapsible grammar items
   ============================================================ */

.study-grammar {
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.study-grammar-summary {
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  color: var(--text);
}
.study-grammar-summary::-webkit-details-marker { display: none; }
.study-grammar-summary:hover {
  background: var(--cream);
}
.study-grammar-chev {
  display: inline-block;
  transition: transform .15s ease;
  color: var(--text-muted);
  font-size: .85rem;
  width: 12px;
  flex-shrink: 0;
}
.study-grammar[open] > .study-grammar-summary .study-grammar-chev {
  transform: rotate(90deg);
}
.study-grammar-title { line-height: 1.3; }

.study-grammar-body {
  padding: 6px 14px 14px 36px;
  border-top: 1px solid var(--border);
}

/* Action hint under the primary button */
.action-hint {
  font-size: .85rem;
  color: var(--text-muted);
  font-style: italic;
  flex-basis: 100%;
  margin-top: -4px;
  line-height: 1.3;
}

/* Action variants: subtle color cue based on what the button will do */
.btn-action-open .btn-sparkle { font-size: 1.05em; }
.btn-action-generate { background: var(--coral); }
.btn-action-generate:hover { background: var(--coral-light); }
.btn-action-regenerate { background: #6b7280; }
.btn-action-regenerate:hover { background: #4b5563; }

/* ============================================================
   Dialogue + References (study view extensions)
   ============================================================ */

.study-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.study-section-header .study-section-title { margin: 0; }
.study-section-actions { display: flex; gap: 8px; align-items: center; }

.dialogue-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dialogue-turn {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--white-pure);
  border: 1px solid var(--border);
}
.dialogue-speaker {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: .85rem;
  background: var(--cream);
  color: var(--text);
  border: 1px solid var(--border);
}
.dialogue-text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dialogue-de-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.dialogue-de {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.4;
}
.dialogue-narrative {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--white-pure);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.study-reference {
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.study-reference-summary {
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  color: var(--text);
}
.study-reference-summary::-webkit-details-marker { display: none; }
.study-reference-summary:hover { background: var(--cream); }
.study-reference[open] .study-grammar-chev { transform: rotate(90deg); }
.study-reference-body {
  padding: 6px 14px 14px 36px;
  border-top: 1px solid var(--border);
}
.ref-desc {
  font-size: .9rem;
  color: var(--text-muted);
  margin: 4px 0 10px 0;
}
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.ref-table th, .ref-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.ref-table th {
  background: var(--cream);
  font-weight: 600;
}
.ref-list { padding-left: 20px; margin: 0; }
.ref-list li { padding: 2px 0; }
.ref-text { white-space: pre-wrap; line-height: 1.5; }
.ref-md > p { margin: 0 0 8px 0; line-height: 1.5; }
.ref-md > p:last-child { margin-bottom: 0; }
.ref-md > ul, .ref-md > table { margin: 4px 0 10px 0; }
.ref-md-en {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: .92rem;
}

.ref-table .ref-tts-cell {
  width: 36px;
  text-align: center;
  padding: 4px 6px;
}

/* ============================================================
   Per-section push controls (inside Cards view section headers)
   ============================================================ */
.section-push-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.section-deck-input {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white-pure);
  color: var(--text);
  min-width: 200px;
}
.section-deck-input:focus {
  outline: none;
  border-color: var(--gold);
}
.section-selection-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.section-push-btn {
  padding: 6px 14px;
  font-size: 0.9rem;
  width: auto;
}

@media (max-width: 720px) {
  .cards-section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .section-push-controls { justify-content: flex-start; }
  .section-deck-input { flex: 1 1 160px; min-width: 0; }
}

/* ============================================================
   Cards view: layout sub-toggle (Tile vs Compact)
   ============================================================ */
.cards-layout-toggle {
  display: inline-flex;
  background: var(--cream-dark);
  border-radius: 999px;
  padding: 3px;
  margin: 0 0 14px;
}
.cards-layout-btn {
  background: transparent;
  border: 0;
  padding: 5px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}
.cards-layout-btn.active {
  background: var(--white-pure);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.10);
}

/* ============================================================
   Compact-table layout (used inside Cards view when layout=compact)
   ============================================================ */
.compact-table-wrap {
  background: var(--white-pure);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.compact-table thead th {
  text-align: left;
  background: var(--cream-dark);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.compact-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.12s ease;
}
.compact-table tbody tr:last-child { border-bottom: 0; }
.compact-table tbody tr:hover { background: var(--cream); }
.compact-table td {
  padding: 8px 12px;
  vertical-align: middle;
}
.compact-table .col-check {
  width: 32px;
  padding-right: 0;
}
.compact-table .col-check .item-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}
.compact-table .col-de { color: var(--text); }
.compact-table .col-en { color: var(--text-muted); }
.compact-table .col-meta { color: var(--text-muted); font-size: 0.85rem; }
.compact-truncate {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   Mobile-only feature trims
   Hides components that don't fit at phone widths and lets
   content tables scroll within their containers instead of
   overflowing the page. Desktop layout is unchanged.
   ============================================================ */
@media (max-width: 640px) {
  .lesson-section-nav { display: none; }

  #imagesTab,
  .img-override-strip { display: none !important; }

  .study-section-body,
  .study-prose,
  .study-grammar-body,
  .study-reference-body,
  .grammar-item,
  .compact-table-wrap { overflow-x: auto; }

  .ex-row { flex-wrap: wrap; }
  .ex-cloze .ex-input { flex: 1 1 100%; }
  .ex-row .btn-primary { flex: 0 0 auto; }

  .study-table,
  .study-table tbody,
  .study-table tr,
  .study-table td { display: block; }
  .study-table tr {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
  }
  .study-table tr:last-child { border-bottom: 0; }
  .study-table td { padding: 0; }
  .study-table .col-art,
  .study-table .col-de { display: inline; }
  .study-table .col-de { white-space: normal; }
  .study-table .col-en { margin-top: 4px; }
}

/* ============================================================
   Mobile: AnkiConnect features (push, status, setup) are
   desktop-only. Anki has no mobile counterpart that the browser
   can talk to, and attempting the fetch triggers an "open another
   app" warning on iOS/Android. Hide all related UI.
   ============================================================ */
html.is-mobile .anki-status,
html.is-mobile .section-push-controls,
html.is-mobile .section-push-btn,
html.is-mobile .desktop-only {
  display: none !important;
}
html.is-mobile .mobile-only {
  display: block;
}
.mobile-only {
  display: none;
}
