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

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --blue-light: #eff6ff;
  --blue-border: #bfdbfe;
  --red: #ef4444;
  --red-hover: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}

/* ── Shared ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

input[type="text"], textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}
input[type="text"]:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
label .required { color: var(--red); margin-left: 2px; }

/* ── Page header ──────────────────────────────── */
.page-header {
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.back-link:hover { color: var(--text); }

/* ── Dashboard ────────────────────────────────── */
#view-dashboard { padding: 32px; max-width: 1100px; margin: 0 auto; }

.dashboard-top {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: "title button streak";
  align-items: end;
  gap: 0 16px;
  margin-bottom: 28px;
}
.dashboard-top h1 { grid-area: title; font-size: 28px; font-weight: 700; }
.dashboard-top-right { display: contents; }
#btn-create { grid-area: button; }
.streak-widget { grid-area: streak; }
.streak-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: var(--radius);
  padding: 10px 18px;
  min-width: 110px;
  color: white;
  background: #9ca3af;
}
.streak-widget.streak-color-none     { background: #9ca3af; }
.streak-widget.streak-color-low      { background: #f87171; }
.streak-widget.streak-color-quarter  { background: #fbbf24; }
.streak-widget.streak-color-half     { background: #60a5fa; }
.streak-widget.streak-color-high     { background: #86efac; color: #1a1a1a; }
.streak-widget.streak-color-mastered { background: #f59e0b; }
.streak-number { font-size: 36px; font-weight: 800; line-height: 1; }
.streak-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.85; margin-top: 2px; }
.streak-flavor { font-size: 11px; font-weight: 600; margin-top: 4px; }

.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.deck-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  position: relative;
  border-left: 4px solid #9ca3af;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
}
.deck-card.progress-none     { border-left-color: #9ca3af; } /* gray — not started */
.deck-card.progress-low      { border-left-color: #f87171; } /* red — < 25% */
.deck-card.progress-quarter  { border-left-color: #fbbf24; } /* yellow — 25–49% */
.deck-card.progress-half     { border-left-color: #60a5fa; } /* blue — 50–74% */
.deck-card.progress-high     { border-left-color: #86efac; } /* light green — 75–99% */
.deck-card.progress-mastered { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.08); } /* gold — 100% mastered */
.deck-card:hover { box-shadow: var(--shadow); }
.deck-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; padding-right: 52px; }
.deck-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.deck-card .card-count {
  display: inline-block;
  font-size: 12px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 20px;
  padding: 2px 10px;
  font-weight: 600;
}
.due-badge {
  display: inline-block;
  font-size: 12px;
  border-radius: 20px;
  padding: 2px 10px;
  font-weight: 600;
}
.due-badge-overdue {
  background: #fee2e2;
  color: #dc2626;
}
.due-badge-today {
  background: #fef3c7;
  color: #b45309;
}
.due-badge-future {
  background: #f3f4f6;
  color: #6b7280;
}
.total-progress {
  margin-bottom: 24px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.total-progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.total-progress-level {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue);
}
.deck-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.deck-progress-bar-wrap {
  margin-top: 6px;
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.deck-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #d97706, #f59e0b);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.deck-card .deck-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
}
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.btn-edit-deck:hover  { color: var(--blue) !important; }
.btn-delete-deck:hover { color: var(--red) !important; }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state p { font-size: 16px; margin-bottom: 20px; }

/* ── Create Set ───────────────────────────────── */
#view-create { max-width: 1100px; margin: 0 auto; padding: 0 32px 120px; }

#view-create h1 { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
#view-create .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

.create-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.form-group { margin-bottom: 20px; }

.char-count { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-left: 4px; }

.tip-box {
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--blue-dark);
  margin-top: 20px;
}
.tip-box strong { color: var(--blue-dark); }

/* Preview */
.preview-section { margin-top: 24px; }
.preview-section h4 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.preview-card {
  border: 1.5px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  padding: 18px;
}
.preview-card .preview-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; color: var(--text-muted); }
.preview-card .preview-count {
  display: inline-block;
  font-size: 12px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 20px;
  padding: 2px 10px;
  font-weight: 600;
}

/* Cards panel */
.cards-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.cards-panel-header h2 { font-size: 16px; font-weight: 700; }

.format-hint {
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.6;
}
.format-hint strong { color: var(--blue-dark); }
.format-hint code {
  background: #dbeafe;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--blue-dark);
}
.format-hint .examples { color: var(--blue); margin-top: 4px; }

.bulk-textarea {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 14px;
  min-height: 220px;
  color: var(--text);
}

.parse-status {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  min-height: 18px;
}
.parse-status.valid { color: #16a34a; }
.parse-status.error { color: var(--red); }

.import-btn-row { margin-top: 14px; }

/* Footer bar */
.create-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  z-index: 10;
}

/* ── Study Mode ───────────────────────────────── */
#view-study { max-width: 700px; margin: 0 auto; padding: 0 24px 40px; }

.study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  margin-bottom: 20px;
}
.study-header h2 { font-size: 20px; font-weight: 700; }
.study-counter { font-size: 14px; color: var(--text-muted); }

.progress-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 4px;
  margin-bottom: 40px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 99px;
  transition: width 0.3s ease;
}

/* Flip card */
.flip-scene {
  perspective: 1000px;
  height: 280px;
  margin-bottom: 32px;
  cursor: pointer;
}
.flip-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.flip-card.flipped { transform: rotateY(180deg); }

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  box-shadow: var(--shadow);
}
.flip-face.back { transform: rotateY(180deg); }

.flip-face .face-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.flip-face .face-text {
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}
.flip-face.back .face-text { font-size: 26px; color: var(--blue-dark); }

.flip-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.rating-btns {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
#app > .rating-btns {
  margin-left: 24px;
  margin-right: 24px;
}
.rating-btns-placeholder {
  height: 52px;
  margin-top: 8px;
}
.btn-again {
  flex: 1;
  padding: 16px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  background: #ef4444;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-again:hover { background: #dc2626; }
.btn-hard {
  flex: 1;
  padding: 16px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  background: #f59e42;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-hard:hover { background: #e08825; }
.btn-easy {
  flex: 1;
  padding: 16px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  background: #4caf82;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-easy:hover { background: #3a9a6e; }

.study-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.nav-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  color: var(--text);
}
.nav-btn:hover:not(:disabled) { background: var(--bg); border-color: var(--blue); color: var(--blue); }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.shuffle-btn { margin-left: 8px; }

/* Completion state */
.study-complete {
  text-align: center;
  padding: 60px 20px;
}
.study-complete h3 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.study-complete p { color: var(--text-muted); margin-bottom: 28px; }
.study-complete .complete-actions { display: flex; gap: 12px; justify-content: center; }

/* ── Fill-in-blank ────────────────────────────── */
.fill-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  overflow: hidden;
}
.fill-card-body {
  padding: 36px 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}
.fill-prompt-label { font-size: 14px; color: var(--text-muted); }
.fill-prompt-word { font-size: 36px; font-weight: 800; color: var(--text); line-height: 1.2; }
.fill-input-wrap {
  width: 100%;
  max-width: 480px;
}
.fill-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border: 2px solid var(--blue);
  border-radius: 12px;
  outline: none;
  background: #fafbff;
}
.fill-input:focus { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,0.12); }
.fill-hint { font-size: 13px; color: var(--text-muted); margin: 0; }

.char-accordion {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.char-accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.char-accordion-open .char-accordion-header { color: #f59e0b; }
.char-accordion-icon {
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  color: var(--text);
}
.char-accordion-open .char-accordion-icon { color: var(--text); }
.char-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 18px 14px;
}
.char-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.char-row-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
  margin-right: 4px;
}
.char-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  color: var(--text);
}
.char-btn:hover { background: var(--blue-light); border-color: var(--blue); color: var(--blue-dark); }

.fill-card-footer {
  border-top: 1px solid var(--border);
  background: #f0f4ff;
  padding: 16px;
  display: flex;
  justify-content: center;
}
.fill-card-footer:not(.fill-rating-footer) button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 700;
  color: var(--blue);
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}
.fill-card-footer:not(.fill-rating-footer) button:hover { background: #dbeafe; }

.fill-result {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 8px;
  width: 100%;
  max-width: 480px;
  justify-content: center;
}
.fill-result.correct { background: #dcfce7; color: #15803d; }
.result-icon { font-size: 18px; }

.answer-contrast {
  width: 100%;
  max-width: 480px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--border);
}
.ac-row {
  display: grid;
  grid-template-columns: 24px 90px 1fr;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
}
.ac-row + .ac-row { border-top: 1px solid var(--border); }
.ac-wrong   { background: #fef2f2; }
.ac-correct { background: #f0fdf4; }
.ac-icon { font-size: 16px; font-weight: 700; text-align: center; }
.ac-wrong   .ac-icon { color: #dc2626; }
.ac-correct .ac-icon { color: #16a34a; }
.ac-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.ac-wrong   .ac-value { font-size: 18px; font-weight: 600; color: #dc2626; }
.ac-correct .ac-value { font-size: 18px; font-weight: 700; color: #15803d; }
.fill-answer-reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 20px;
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
}
.reveal-label { font-size: 12px; color: var(--blue-dark); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.reveal-word { font-size: 22px; font-weight: 700; color: var(--blue-dark); }

/* ── Listen + Multiple Choice ────────────────── */
.listen-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.listen-card-body {
  padding: 36px 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.play-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 4px 14px rgba(59,130,246,0.4);
}
.play-btn:hover  { background: var(--blue-dark); transform: scale(1.05); }
.play-btn:active { transform: scale(0.97); }
.listen-quiet-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}
.listen-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  min-height: 18px;
}
.mc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 520px;
}
.mc-btn {
  padding: 18px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.3;
}
.mc-btn:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-light); }
.mc-btn:disabled { cursor: default; }
.mc-correct { background: #dcfce7 !important; border-color: #16a34a !important; color: #15803d !important; }
.mc-wrong   { background: #fee2e2 !important; border-color: #dc2626 !important; color: #dc2626 !important; }
.mc-dim     { opacity: 0.4; }

/* ── Confirm dialog ───────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.dialog {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.dialog h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.dialog p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.dialog-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 4px;
}
.dialog-close:hover { color: var(--text); }

/* ── Recording ────────────────────────────────── */
.record-panel { margin-top: 16px; margin-bottom: 40px; }
.record-hint { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; }
.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.record-row:last-child { border-bottom: none; }
.record-viet { font-size: 15px; font-weight: 600; flex: 1; }
.record-controls { display: flex; gap: 6px; align-items: center; }
.rec-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.rec-btn:hover { border-color: var(--blue); color: var(--blue); }
.rec-record { border-color: #ef4444; color: #ef4444; }
.rec-record:hover { background: #ef4444; color: white; }
.rec-recording { background: #ef4444 !important; color: white !important; animation: pulse-rec 1s infinite; }
.rec-rerecord { border-color: var(--border); color: var(--text-muted); }
.rec-play { border-color: #22c55e; color: #22c55e; }
.rec-play:hover { background: #22c55e; color: white; }
.rec-delete { border-color: var(--border); color: var(--text-muted); }
.rec-delete:hover { border-color: #ef4444; color: #ef4444; }
@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.listen-no-audio { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; font-style: italic; }
.play-btn-disabled { opacity: 0.35; cursor: not-allowed !important; }

/* ── Images ───────────────────────────────────────── */
.image-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.image-row:last-child { border-bottom: none; }
.image-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.img-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}
.img-upload { border-color: var(--blue); color: var(--blue); }
.img-upload:hover { background: var(--blue); color: white; }
.img-delete:hover { border-color: #ef4444; color: #ef4444; }

/* Image on study card */
.card-face-img {
  width: 100%;
  max-width: 220px;
  max-height: 140px;
  object-fit: contain;
  border-radius: 8px;
  margin: 4px 0;
}

/* ── Passcode ─────────────────────────────────── */
.passcode-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.passcode-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.passcode-box h1 { font-size: 22px; font-weight: 700; }
.passcode-box p { color: var(--text-muted); font-size: 14px; margin: 0; }
.passcode-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  text-align: center;
  letter-spacing: 0.1em;
}
.passcode-input:focus { border-color: var(--blue); outline: none; }
.passcode-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 0; }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 768px) {
  #view-dashboard { padding: 20px; }
  .dashboard-top {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "title streak" "button streak";
    align-items: start;
    gap: 8px 16px;
  }
  .dashboard-top h1 { grid-area: title; }
  #btn-create { grid-area: button; align-self: start; justify-self: stretch; }
  .streak-widget { grid-area: streak; min-width: 0; align-self: stretch; justify-content: center; }
  #view-create { padding: 0 16px 120px; }
  .create-layout { grid-template-columns: 1fr; }
  .create-footer { padding: 12px 16px; }
  .flip-face .face-text { font-size: 24px; }
  .flip-face.back .face-text { font-size: 20px; }
  .flip-scene { height: 220px; }
  .page-header { padding: 16px 20px; }
}
