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

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6c757d;
  --primary: #4361ee;
  --primary-hover: #3a56d4;
  --success: #2ec4b6;
  --danger: #e63946;
  --border: #dee2e6;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

body {
  font-family: 'Inter', 'Noto Sans Thai Looped', 'Noto Sans Thai', 'Thonburi', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Ad sidebars */
.ad-sidebar {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 160px;
  z-index: 5;
}

.ad-sidebar-left {
  left: calc((100vw - 900px) / 2 - 180px);
}

.ad-sidebar-right {
  right: calc((100vw - 900px) / 2 - 180px);
}

.ad-slot {
  min-height: 600px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hide ads when viewport is too narrow for sidebars */
@media (max-width: 1340px) {
  .ad-sidebar {
    display: none;
  }
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Section toggle */
.section-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  gap: 3px;
  border: 2px solid var(--border);
}

.section-btn {
  padding: 8px 14px;
  border: none;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.2s;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.section-btn.active {
  background: var(--text);
  color: white;
  box-shadow: 0 2px 8px rgba(26, 26, 46, 0.35);
}

.section-btn:hover:not(.active) {
  color: var(--text);
  background: var(--border);
}

.mode-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  gap: 3px;
  border: 2px solid var(--border);
}

/* Desktop: show in header, hide in main */
.mode-toggle-main {
  display: none;
}

.mode-btn {
  padding: 8px 14px;
  border: none;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.2s;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.mode-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(67, 97, 238, 0.35);
}

.mode-btn:hover:not(.active) {
  color: var(--text);
  background: var(--border);
}

/* Main */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* Navigation slide animations */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}

.practice-area.slide-next > .flashcard,
.practice-area.slide-next > .canvas-container {
  animation: slideInRight 0.2s ease;
}

.practice-area.slide-prev > .flashcard,
.practice-area.slide-prev > .canvas-container {
  animation: slideInLeft 0.2s ease;
}

/* Practice area */
.practice-area {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  margin-bottom: 20px;
  position: relative;
}

/* Flashcard */
.flashcard {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

/* Flash nav buttons (inside flashcard, like canvas-nav) */
.flash-nav {
  display: none;
}

.practice-area.read-mode .flash-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  color: var(--text-secondary);
  opacity: 0.6;
  transition: all 0.15s;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.practice-area.read-mode .flash-nav:hover {
  opacity: 1;
  background: white;
  color: var(--primary);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.practice-area.read-mode .flash-nav:active {
  transform: translateY(-50%) scale(0.92);
}

.practice-area.read-mode .flash-nav svg {
  width: 24px;
  height: 24px;
}

.practice-area.read-mode .flash-nav-prev {
  left: 0;
  border-left: none;
  border-radius: 0 8px 8px 0;
}

.practice-area.read-mode .flash-nav-next {
  right: 0;
  border-right: none;
  border-radius: 8px 0 0 8px;
}

/* Flash reveal button (inside flashcard) */
.flash-reveal {
  display: none;
  margin-top: 24px;
  padding: 12px 32px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(67, 97, 238, 0.4);
  transition: background 0.15s;
}

.flash-reveal.visible {
  display: block;
}

.flash-reveal:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.5);
}

.flash-reveal:active {
  transform: scale(0.95);
}

.flashcard-emoji {
  font-size: 8rem;
  line-height: 1.1;
}

.flashcard-char {
  font-size: 5rem;
  line-height: 1.1;
  font-weight: 400;
  font-family: 'Noto Sans Thai Looped', 'Noto Sans Thai', 'Thonburi', 'Leelawadee UI', 'Tahoma', sans-serif;
  color: var(--text);
}

.flashcard-name {
  font-size: 1.25rem;
  font-family: 'Noto Sans Thai Looped', 'Noto Sans Thai', 'Thonburi', 'Leelawadee UI', 'Tahoma', sans-serif;
  color: var(--text);
  font-weight: 600;
}

.sound-btn {
  width: 32px;
  height: 32px;
  padding: 5px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sound-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef2ff;
}

.sound-btn:active {
  transform: scale(0.9);
}

.sound-btn.speaking {
  border-color: var(--primary);
  color: white;
  background: var(--primary);
}

.sound-btn svg {
  width: 16px;
  height: 16px;
}

.flashcard-romanized {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-style: italic;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.syllable {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.syllable-contour {
  width: 32px;
  height: 14px;
}

.syllable-text {
  font-size: 0.95rem;
}

.tone-contour {
  width: 36px;
  height: 18px;
  flex-shrink: 0;
}

.flashcard-meaning {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.flashcard-tone {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.tone-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tone-badge {
  display: inline-block;
  padding: 3px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tone-badge.mid { background: #dbeafe; color: #1e40af; }
.tone-badge.low { background: #fef3c7; color: #92400e; }
.tone-badge.high { background: #d1fae5; color: #065f46; }

/* Vowel info */
.flashcard-vowel-info {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.vowel-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

.position-badge, .length-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Position badge colors */
.position-badge.pos-before { background: #f3e8ff; color: #7c3aed; }
.position-badge.pos-after { background: #dbeafe; color: #2563eb; }
.position-badge.pos-above { background: #ccfbf1; color: #0d9488; }
.position-badge.pos-below { background: #fef3c7; color: #d97706; }
.position-badge.pos-multi { background: #fce7f3; color: #db2777; }

/* Length badge colors */
.length-badge.len-short {
  background: transparent;
  color: #ea580c;
  border: 1.5px solid #ea580c;
  padding: 2px 11px;
}

.length-badge.len-long {
  background: transparent;
  color: #16a34a;
  border: 1.5px solid #16a34a;
  padding: 2px 11px;
}

/* Pair link */
.vowel-pair {
  font-size: 0.75rem;
}

.pair-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s;
}

.pair-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Canvas */
.canvas-container {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  aspect-ratio: 1;
}

.canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  z-index: 10;
  transition: opacity 0.3s;
}

.canvas-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.canvas-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#drawing-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.canvas-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--border);
  font-size: 1.1rem;
  pointer-events: none;
  transition: opacity 0.3s;
}

.canvas-hint.hidden {
  opacity: 0;
}

.canvas-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  color: var(--text-secondary);
  opacity: 0.6;
  transition: all 0.15s;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.canvas-nav:hover {
  opacity: 1;
  background: white;
  color: var(--primary);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.canvas-nav:active {
  transform: translateY(-50%) scale(0.92);
}

.canvas-nav svg {
  width: 24px;
  height: 24px;
}

.canvas-nav-prev {
  left: 0;
  border-left: none;
  border-radius: 0 8px 8px 0;
}

.canvas-nav-next {
  right: 0;
  border-right: none;
  border-radius: 8px 0 0 8px;
}

.canvas-status {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 10px;
  background: #fee2e2;
  color: var(--danger);
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  pointer-events: none;
  display: none;
}

.canvas-status.visible {
  display: block;
}

.canvas-clear {
  position: absolute;
  bottom: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.canvas-clear.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.canvas-clear:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #fee2e2;
}

.canvas-clear:active {
  transform: scale(0.9);
}

.canvas-clear svg {
  width: 16px;
  height: 16px;
}

.canvas-reveal {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(67, 97, 238, 0.4);
  transition: all 0.2s;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.canvas-reveal.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.canvas-reveal:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.5);
}

.canvas-reveal:active {
  transform: scale(0.95);
}

.canvas-assess {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(transparent, rgba(255,255,255,0.95) 30%);
}

.canvas-assess.visible {
  display: flex;
  animation: slideInUp 0.25s ease;
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ctrl-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.counter {
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 56px;
  text-align: center;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.ctrl-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  flex-shrink: 0;
}

.ctrl-icon svg {
  width: 18px;
  height: 18px;
}

.ctrl-icon:hover {
  background: var(--bg);
  border-color: #adb5bd;
  color: var(--text);
}

.ctrl-icon:active {
  transform: scale(0.93);
}

.ctrl-btn {
  padding: 9px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s;
  white-space: nowrap;
}

.ctrl-btn:hover {
  background: var(--bg);
  border-color: #adb5bd;
}

.ctrl-btn:active {
  transform: scale(0.95);
}

.ctrl-btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.ctrl-btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* Self assessment */
.assess-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  transition: all 0.15s;
}

.assess-btn:active {
  transform: scale(0.97);
}

.assess-btn.correct {
  background: var(--success);
}

.assess-btn.correct:hover {
  background: #25a99d;
}

.assess-btn.incorrect {
  background: var(--danger);
}

.assess-btn.incorrect:hover {
  background: #cf2f3c;
}

/* Progress */
.progress-section {
  margin-bottom: 20px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
}

.progress-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reset-btn {
  padding: 2px 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: all 0.15s;
}

.reset-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.reset-btn:active {
  transform: scale(0.95);
}

.progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 5px;
  width: 0%;
  transition: width 0.4s ease;
}

/* Selection toolbar */
.selection-toolbar {
  margin-bottom: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.selection-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

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

.selection-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.edit-btn {
  padding: 4px 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.edit-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.edit-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.filter-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-row-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 72px;
  flex-shrink: 0;
  user-select: none;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.filter-chip {
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: #adb5bd;
  color: var(--text);
}

.filter-chip.active {
  color: white;
  border-color: transparent;
}

.filter-chip[data-filter="all"].active {
  background: var(--primary);
}

.filter-chip[data-filter="mid"].active {
  background: #1e40af;
}

.filter-chip[data-filter="high"].active {
  background: #065f46;
}

.filter-chip[data-filter="low"].active {
  background: #92400e;
}

.filter-chip[data-filter="mid-all"].active,
.filter-chip[data-filter="mid-gai"].active,
.filter-chip[data-filter="mid-dek"].active,
.filter-chip[data-filter="mid-bon"].active {
  background: #1e40af;
}

.filter-chip[data-filter="unpracticed"].active {
  background: #6c757d;
}

.filter-chip[data-filter="wrong"].active {
  background: var(--danger);
}

.filter-chip[data-filter="short"].active {
  background: #ea580c;
}

.filter-chip[data-filter="long"].active {
  background: #16a34a;
}

.filter-chip[data-filter="custom"].active {
  background: var(--primary);
}

/* Shuffle active */
.ctrl-icon.shuffle-active {
  background: #f59e0b;
  color: white;
  border-color: #f59e0b;
}

.ctrl-icon.shuffle-active:hover {
  background: #d97706;
  border-color: #d97706;
}

/* Character grid */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
}

.char-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1.2rem;
  font-family: 'Noto Sans Thai Looped', 'Noto Sans Thai', 'Thonburi', 'Leelawadee UI', 'Tahoma', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.char-cell:hover {
  border-color: var(--primary);
  transform: scale(1.08);
  z-index: 1;
  box-shadow: var(--shadow-lg);
}

.char-cell.active {
  box-shadow: 0 0 0 2.5px var(--primary);
  z-index: 1;
}

.char-cell.practiced {
  border-color: var(--success);
  background: #ecfdf5;
}

.char-cell.practiced.correct {
  border-color: var(--success);
  background: #d1fae5;
}

.char-cell.practiced.wrong {
  border-color: var(--danger);
  background: #fee2e2;
}

.char-cell.excluded {
  opacity: 0.25;
  border-style: dashed;
  border-color: var(--border);
  background: var(--bg);
  cursor: default;
  pointer-events: none;
}

/* Edit mode: show all 44 for toggling */
.char-grid.edit-mode .char-cell.deselected {
  opacity: 0.35;
  border-style: dashed;
  border-color: var(--border);
  background: var(--bg);
}

.char-grid.edit-mode .char-cell.deselected:hover {
  opacity: 0.7;
  border-color: var(--primary);
}

.char-grid.edit-mode {
  user-select: none;
  -webkit-user-select: none;
}

.char-grid.edit-mode .char-cell {
  border-width: 2.5px;
}

.char-grid.edit-mode .char-cell:not(.deselected) {
  border-color: var(--primary);
  background: #eef2ff;
}

/* Test mode: hidden Thai text */
.flashcard-char.hidden-char {
  color: var(--border);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 4rem;
}

/* Details wrapper: transparent in normal modes */
.flashcard-details {
  display: contents;
}

/* Inner wrappers: transparent in normal modes */
.details-left,
.details-right {
  display: contents;
}

/* Keep emoji first visually (it moved into details wrapper) */
.flashcard-emoji {
  order: -1;
}

/* Vowel dotted circle hint */
.vowel-hint {
  display: none;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.6;
  margin-top: 2px;
}

.vowel-hint-circle {
  font-size: 1.1rem;
  color: var(--text);
  vertical-align: middle;
}

/* Read prompt */
.read-prompt {
  display: none;
}

/* Read mode: always full-width, no canvas */
.practice-area.read-mode {
  grid-template-columns: 1fr;
}

.practice-area.read-mode .canvas-container {
  display: none;
}

.practice-area.read-mode .flashcard {
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 36px;
  min-height: 300px;
  justify-content: center;
  gap: 8px;
}

.practice-area.read-mode .flashcard-char {
  transition: font-size 0.35s ease;
}

/* Before reveal: giant character + sound + prompt */
.practice-area.read-mode.read-unrevealed .flashcard-char {
  font-size: 12rem;
  line-height: 1;
  padding-bottom: 0.15em;
}

.practice-area.read-mode.read-unrevealed .read-prompt {
  display: block;
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 8px;
  font-style: italic;
}

/* After reveal: two-column — char left, info right */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

.practice-area.read-mode.read-revealed .flashcard {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  padding: 40px 48px;
  column-gap: 48px;
  row-gap: 16px;
  min-height: auto;
}

.practice-area.read-mode.read-revealed .flashcard-char {
  font-size: 10rem;
  line-height: 1;
  flex-shrink: 0;
}

.practice-area.read-mode.read-revealed .flashcard-details {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 28px;
  animation: slideInRight 0.4s ease both;
}

/* Left inner column: emoji + romanized */
.practice-area.read-mode.read-revealed .details-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.practice-area.read-mode.read-revealed .flashcard-emoji {
  font-size: 3.5rem;
  order: 0;
}

.practice-area.read-mode.read-revealed .flashcard-romanized {
  font-size: 1rem;
  font-style: italic;
}

/* Right inner column: name, sound, meaning, tone, vowel */
.practice-area.read-mode.read-revealed .details-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.practice-area.read-mode.read-revealed .flashcard-name {
  font-size: 1.4rem;
}

.practice-area.read-mode.read-revealed .sound-btn {
  width: 36px;
  height: 36px;
}

.practice-area.read-mode.read-revealed .sound-btn svg {
  width: 18px;
  height: 18px;
}

.practice-area.read-mode.read-revealed .flashcard-meaning {
  font-size: 0.95rem;
}

.practice-area.read-mode.read-revealed .flashcard-tone {
  align-items: center;
  margin-top: 2px;
}

.practice-area.read-mode.read-revealed .tone-badge {
  padding: 4px 16px;
  font-size: 0.78rem;
}

.practice-area.read-mode.read-revealed .flashcard-vowel-info {
  align-items: center;
}

.read-assess {
  display: none;
  gap: 10px;
  justify-content: center;
  flex-basis: 100%;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.read-assess.visible {
  display: flex;
}

.char-grid.grid-hidden .char-cell {
  color: transparent;
}

.char-grid.grid-hidden .char-cell::after {
  content: "·";
  color: var(--border);
  position: absolute;
  font-size: 1.5rem;
}

/* Mobile bottom bar — hidden on desktop */
.mobile-bottom-bar {
  display: none;
}

.mobile-reveal-btn {
  display: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1a1a2e;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 100;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* SEO Content */
.seo-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 16px 48px;
  border-top: 1px solid var(--border);
}

.seo-content h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text);
}

.seo-content h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 32px 0 8px;
  color: var(--text);
}

.seo-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 20px 0 4px;
  color: var(--text);
}

.seo-content p {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.seo-content ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

.seo-content li {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.seo-content strong {
  color: var(--text);
}

/* Responsive */
@media (max-width: 640px) {
  header {
    padding: 10px 12px;
  }

  .header-left {
    gap: 10px;
  }

  .header-left h1 {
    font-size: 1.1rem;
  }

  .section-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  /* Hide mode toggle from header, show in main */
  .mode-toggle-header {
    display: none;
  }

  .mode-toggle-main {
    display: flex;
    margin-bottom: 16px;
  }

  .mode-toggle-main .mode-btn {
    flex: 1;
    text-align: center;
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  main {
    padding-top: 12px;
  }

  .practice-area {
    grid-template-columns: 1fr;
  }

  .flashcard {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 16px;
    padding: 16px;
  }

  .flashcard-emoji {
    font-size: 5rem;
  }

  .flashcard-char {
    font-size: 3rem;
  }

  .canvas-container {
    aspect-ratio: 1;
    width: 100%;
    max-height: none;
  }

  /* Hide desktop controls bar, use mobile bottom bar instead */
  .controls {
    display: none;
  }

  /* Hide internal nav arrows on mobile — bottom bar replaces them */
  .canvas-nav,
  .practice-area.read-mode .flash-nav {
    display: none;
  }

  /* Mobile bottom bar */
  .mobile-bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  }

  .mobile-nav-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
    flex-shrink: 0;
  }

  .mobile-nav-btn:active {
    transform: scale(0.9);
    background: var(--bg);
  }

  .mobile-nav-btn svg {
    width: 22px;
    height: 22px;
  }

  .mobile-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
  }

  .mobile-counter {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
  }

  .mobile-reveal-btn {
    display: none;
    flex: 1;
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(67, 97, 238, 0.35);
    transition: background 0.15s;
    text-align: center;
  }

  .mobile-reveal-btn:active {
    background: var(--primary-hover);
    transform: scale(0.95);
  }

  .mobile-reveal-btn.visible {
    display: block;
  }

  /* Canvas reveal — fixed bottom center above the bar */

  /* Canvas assess — fixed bottom above the bar */
  .canvas-assess {
    position: fixed;
    bottom: 70px;
    left: 0;
    right: 0;
    z-index: 21;
    padding: 12px 16px;
    background: linear-gradient(transparent, rgba(248, 249, 250, 0.97) 30%);
  }

  /* Hide desktop reveal buttons on mobile — mobile bar has its own */
  .flash-reveal,
  .canvas-reveal {
    display: none !important;
  }

  /* Read assess — fixed above the bar */
  .read-assess.visible {
    position: fixed;
    bottom: 70px;
    left: 0;
    right: 0;
    z-index: 21;
    padding: 12px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  }

  /* Add bottom padding to main so content isn't hidden behind bar */
  main {
    padding-bottom: 80px;
  }

  /* Toast above the bottom bar */
  .toast {
    bottom: 84px;
  }

  .char-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  }

  .filter-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .filter-row-label {
    min-width: unset;
  }

  .filter-chips {
    gap: 5px;
  }

  .filter-chip {
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  .practice-area.read-mode .flashcard {
    padding: 48px 16px 24px;
    min-height: 260px;
  }

  .practice-area.read-mode.read-unrevealed .flashcard-char {
    font-size: 8rem;
  }

  .practice-area.read-mode.read-revealed .flashcard {
    flex-direction: column;
    row-gap: 16px;
    column-gap: 16px;
    align-items: center;
  }

  .practice-area.read-mode.read-revealed .flashcard-char {
    font-size: 6rem;
  }

  .practice-area.read-mode.read-revealed .flashcard-details {
    flex-direction: column;
    text-align: center;
  }

  .practice-area.read-mode.read-revealed .details-left,
  .practice-area.read-mode.read-revealed .details-right {
    align-items: center;
  }

  .practice-area.read-mode.read-revealed .flashcard-tone {
    align-items: center;
  }

}
