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

:root {
  --green:       #4f46e5;
  --green-light: #eef2ff;
  --green-dark:  #3730a3;
  --bg:          #f5f5f7;
  --card:        #ffffff;
  --text:        #1a1a1a;
  --muted:       #6b7280;
  --border:      #e5e7eb;
  --success:     #16a34a;
  --error:       #dc2626;
  --radius:      14px;
  --shadow:      0 1px 3px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.05);
  --shadow-lg:   0 4px 6px rgba(0,0,0,.04), 0 10px 28px rgba(0,0,0,.1);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

button, input { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

#app {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100dvh;
}

/* ===== SCREENS ===== */
.screen { display: none; flex-direction: column; min-height: 100dvh; }
.screen.active { display: flex; }

/* ===== TOP BAR ===== */
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.back-btn {
  background: none;
  border: none;
  color: var(--green);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  flex-shrink: 0;
  font-family: inherit;
}

.ex-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  text-align: center;
}

.ex-counter {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

/* ===== HOME ===== */
.home-header {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 100%);
  color: white;
  padding: 44px 24px 36px;
  text-align: center;
  flex-shrink: 0;
}

.app-title { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.app-sub { font-size: 16px; opacity: .75; margin-top: 4px; }

.free-card {
  margin: 20px 16px 4px;
  background: var(--card);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: background .15s;
}
.free-card:hover { background: var(--green-light); }
.free-icon { font-size: 26px; }
.free-text { flex: 1; }
.free-title { font-weight: 700; font-size: 16px; color: var(--green-dark); }
.free-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.free-arrow { font-size: 22px; color: var(--green); }

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 18px 20px 8px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 40px;
}

.lesson-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.lesson-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lesson-card:active { transform: translateY(0); }
.lesson-card.started { border-color: var(--green-light); }

.lesson-num { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.lesson-title { font-size: 15px; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.lesson-roman { font-size: 12px; color: var(--muted); margin-top: 3px; }
.lesson-word-count { font-size: 12px; color: var(--green); font-weight: 600; margin-top: 10px; }
.lesson-prog { width: 100%; height: 4px; background: var(--border); border-radius: 2px; margin-top: 6px; }
.lesson-prog-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width .4s; }

/* ===== LESSON DETAIL ===== */
.lesson-body { padding: 0 0 40px; flex: 1; overflow-y: auto; }

.lesson-hero {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 100%);
  color: white;
  padding: 28px 24px;
}
.lesson-hero h2 { font-size: 26px; font-weight: 800; }
.lesson-hero p { font-size: 14px; opacity: .8; margin-top: 4px; }
.lesson-hero-meta { margin-top: 14px; font-size: 13px; opacity: .85; }

.ex-section { padding: 20px 16px 0; }
.ex-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}

.ex-btn-row { display: flex; flex-direction: column; gap: 8px; }

.ex-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px;
  cursor: pointer;
  text-align: left;
  transition: border-color .12s, background .12s;
  width: 100%;
  font-family: inherit;
  min-height: 64px;
}
.ex-btn:hover { border-color: var(--green); background: var(--green-light); }

.ex-btn-icon { font-size: 26px; width: 34px; text-align: center; flex-shrink: 0; }
.ex-btn-info { flex: 1; }
.ex-btn-title { font-weight: 700; font-size: 17px; display: block; }
.ex-btn-desc { font-size: 14px; color: var(--muted); margin-top: 3px; display: block; }
.ex-btn-arrow { color: var(--muted); font-size: 20px; }

.vocab-section { padding: 20px 16px 0; }
.vocab-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
  gap: 14px;
}
.vocab-item:last-child { border-bottom: none; }
.vocab-roman { font-size: 19px; font-weight: 600; }
.vocab-english { font-size: 16px; color: var(--muted); text-align: right; }
.vocab-note { font-size: 12px; color: var(--green-dark); background: var(--green-light); padding: 3px 9px; border-radius: 10px; margin-top: 5px; display: inline-block; }
.vocab-note--female { background: #fce7f3; color: #be185d; }
.vocab-note--male   { background: #dbeafe; color: #1d4ed8; }
.card-back.gender-female { background: #fdf2f8; }
.card-back.gender-male   { background: #eff6ff; }
.card-note.gender-female { color: #be185d; background: rgba(236,72,153,.1); }
.card-note.gender-male   { color: #1d4ed8; background: rgba(59,130,246,.1); }

/* ===== PROGRESS BAR ===== */
.ex-progress { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.prog-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; min-width: 0; }
.prog-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width .3s; }
.prog-label { font-size: 13px; color: var(--muted); white-space: nowrap; font-weight: 600; }

/* ===== FLASHCARD ===== */
.fc-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  gap: 28px;
}

.card-scene { width: 100%; perspective: 1000px; }

.card {
  width: 100%;
  min-height: 260px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4, 0, .2, 1);
  cursor: pointer;
}
.card.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  min-height: 260px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  text-align: center;
}

.card-front { background: var(--card); }
.card-back  { background: var(--card); transform: rotateY(180deg); }

.card-main { font-size: 36px; font-weight: 700; line-height: 1.3; color: var(--text); }
.card-sub  { font-size: 18px; color: var(--muted); margin-top: 10px; }
.card-note {
  font-size: 15px;
  color: var(--green-dark);
  margin-top: 14px;
  background: rgba(79,70,229,.12);
  padding: 6px 16px;
  border-radius: 20px;
}
.card-hint { font-size: 15px; color: var(--muted); margin-top: 18px; opacity: .7; }

.fc-btns { display: flex; gap: 12px; width: 100%; }
.fc-btns.hidden { display: none; }

.btn-again {
  flex: 1; padding: 20px;
  border: none; border-radius: 14px;
  font-size: 18px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  background: #fee2e2; color: var(--error);
  transition: opacity .12s;
}
.btn-got {
  flex: 1; padding: 20px;
  border: none; border-radius: 14px;
  font-size: 18px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  background: #dcfce7; color: var(--success);
  transition: opacity .12s;
}
.btn-again:active, .btn-got:active { opacity: .7; }

/* ===== QUIZ ===== */
.quiz-meta { display: flex; justify-content: space-between; flex: 1; font-size: 14px; color: var(--muted); font-weight: 600; }
.quiz-wrap  { flex: 1; display: flex; flex-direction: column; padding: 20px 16px; gap: 18px; }

.quiz-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.quiz-dir  { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 14px; }
.quiz-word { font-size: 32px; font-weight: 700; line-height: 1.3; }

.quiz-opts { display: flex; flex-direction: column; gap: 10px; }

.quiz-opt {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  text-align: left;
  font-size: 18px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  font-family: inherit;
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--green); background: var(--green-light); }
.quiz-opt.correct  { border-color: var(--success) !important; background: #dcfce7 !important; color: var(--success); font-weight: 700; }
.quiz-opt.wrong    { border-color: var(--error)   !important; background: #fee2e2 !important; color: var(--error);   font-weight: 700; }
.quiz-opt:disabled { cursor: default; }

/* ===== WORD BANK / SENTENCE BUILDER ===== */
.wb-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 14px;
  overflow-y: auto;
}

.wb-english {
  background: var(--card);
  border-radius: var(--radius);
  padding: 26px 20px;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  line-height: 1.4;
}

.wb-answer-label, .wb-bank-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.wb-answer-row {
  min-height: 72px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--card);
  transition: border-color .15s;
}
.wb-answer-row.has-items { border-color: var(--green); }

.wb-bank { display: flex; flex-wrap: wrap; gap: 8px; }

.tile {
  background: var(--green-light);
  border: 2px solid var(--green);
  color: var(--green-dark);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s, transform .08s;
  font-family: inherit;
  line-height: 1.2;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tile:hover  { background: var(--green); color: white; }
.tile:active { transform: scale(.96); }
.tile.in-answer { background: var(--green); color: white; }

.wb-actions { display: flex; gap: 10px; margin-top: auto; }

.wb-feedback {
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.4;
}
.wb-feedback.correct { background: #dcfce7; color: var(--success); }
.wb-feedback.wrong   { background: #fee2e2; color: var(--error); }

/* ===== FREE TYPE ===== */
.ft-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 16px;
}

.ft-dir {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.ft-question {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 24px;
  font-size: 30px;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow);
  line-height: 1.4;
}

.ft-input {
  width: 100%;
  padding: 18px 20px;
  font-size: 20px;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  outline: none;
  transition: border-color .15s;
}
.ft-input:focus   { border-color: var(--green); }
.ft-input.correct { border-color: var(--success); background: #f0fdf4; }
.ft-input.wrong   { border-color: var(--error);   background: #fef2f2; }

.ft-feedback {
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
}
.ft-feedback.correct { background: #dcfce7; color: var(--success); }
.ft-feedback.wrong   { background: #fee2e2; color: var(--error); }

.ft-answer { font-size: 15px; color: var(--muted); }
.ft-answer strong { color: var(--green-dark); }

.ft-actions { display: flex; gap: 10px; }

/* ===== DIALOGUE WORD BANK ===== */
.dlg-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  overflow-y: auto;
}

.dlg-lines { display: flex; flex-direction: column; gap: 10px; }

.dlg-line {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.dlg-speaker {
  font-size: 11px;
  font-weight: 700;
  color: white;
  background: var(--green);
  padding: 3px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}

.dlg-content { flex: 1; }
.dlg-roman { font-size: 18px; font-weight: 600; line-height: 1.6; }
.dlg-english { font-size: 15px; color: var(--muted); margin-top: 6px; }

.dlg-blank {
  display: inline-block;
  min-width: 120px;
  padding: 4px 10px;
  border-bottom: 2px solid var(--green);
  cursor: pointer;
  text-align: center;
  vertical-align: baseline;
  transition: background .12s;
}
.dlg-blank.selected  { background: var(--green-light); border-radius: 4px 4px 0 0; }
.dlg-blank.filled    { color: var(--green-dark); font-weight: 700; }
.dlg-blank.correct   { color: var(--success); border-color: var(--success); background: #f0fdf4; border-radius: 4px; border-style: solid; }
.dlg-blank.incorrect { color: var(--error);   border-color: var(--error);   background: #fef2f2; border-radius: 4px; border-style: solid; }
.dlg-blank.revealed  { color: var(--green-dark); border-style: solid; border-radius: 4px; background: var(--green-light); }

.dlg-actions { display: flex; gap: 10px; margin-top: auto; padding-top: 8px; }

/* ===== DIALOGUE FREE TYPE ===== */
.dlg-ft-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 0;
  overflow-y: auto;
}

.dlg-ft-lines { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-bottom: 16px; }

.dlg-ft-line {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.dlg-ft-line.is-prompt { border-left: 4px solid var(--green); }

.dlg-ft-speaker { font-size: 11px; font-weight: 700; color: var(--green); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.dlg-ft-prompt  { font-size: 19px; font-weight: 600; margin-bottom: 12px; line-height: 1.4; }
.dlg-ft-sub     { font-size: 15px; color: var(--muted); margin-bottom: 10px; }

.dlg-ft-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 17px;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s;
}
.dlg-ft-input:focus   { border-color: var(--green); }
.dlg-ft-input.correct { border-color: var(--success); background: #f0fdf4; }
.dlg-ft-input.wrong   { border-color: var(--error);   background: #fef2f2; }

.dlg-ft-reveal-answer {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  display: none;
}
.dlg-ft-reveal-answer.visible { display: block; }
.dlg-ft-reveal-answer strong  { color: var(--green-dark); }

.dlg-ft-actions { display: flex; gap: 10px; padding: 12px 0 8px; flex-shrink: 0; }

/* ===== BUTTONS ===== */
.btn-primary {
  flex: 1;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 22px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .12s;
  min-height: 52px;
}
.btn-primary:hover  { opacity: .9; }
.btn-primary:active { opacity: .75; }

.btn-secondary {
  flex: 1;
  background: var(--card);
  color: var(--green);
  border: 2px solid var(--green);
  border-radius: 12px;
  padding: 16px 22px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s;
  min-height: 52px;
}
.btn-secondary:hover { background: var(--green-light); }

.btn-next {
  width: 100%;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 22px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .12s;
  min-height: 52px;
}
.btn-next:hover { opacity: .9; }

/* ===== RESULTS ===== */
.results-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  gap: 14px;
  text-align: center;
}

.results-emoji { font-size: 72px; line-height: 1; }
.results-title { font-size: 28px; font-weight: 800; }
.results-score { font-size: 18px; color: var(--muted); font-weight: 600; }
.results-msg   { font-size: 16px; color: var(--text); max-width: 300px; line-height: 1.5; }
.results-actions { display: flex; gap: 12px; margin-top: 16px; width: 100%; }

/* ===== STATS HOME BUTTON ===== */
.stats-home-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 16px 0;
  width: calc(100% - 32px);
  padding: 11px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.stats-home-btn:hover {
  border-color: var(--green);
  color: var(--green-dark);
  background: var(--green-light);
}

/* ===== STATS SCREEN ===== */
.stats-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 60px;
}

.stats-section { padding-top: 24px; }

.stats-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
}

.stats-kpi-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.stats-kpi {
  flex: 1;
  background: var(--card);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stats-kpi-val { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stats-kpi-lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }

.trend-up   .stats-kpi-val { color: var(--success); }
.trend-down .stats-kpi-val { color: var(--error); }
.trend-flat .stats-kpi-val { color: var(--muted); }

.stats-prog-track {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.stats-prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-dark), var(--green));
  border-radius: 4px;
  transition: width .5s;
}
.stats-prog-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  text-align: right;
}

/* Lesson overview grid */
.stats-lesson-overview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stats-lesson-cell {
  background: var(--card);
  border-radius: 10px;
  padding: 12px;
  border-left: 4px solid var(--border);
  box-shadow: var(--shadow);
}
.cell-good { border-color: var(--success); }
.cell-mid  { border-color: #d97706; }
.cell-poor { border-color: var(--error); }
.cell-none { border-color: var(--border); opacity: .6; }

.cell-num  { font-size: 11px; font-weight: 700; color: var(--muted); }
.cell-name { font-size: 13px; font-weight: 700; margin-top: 2px; line-height: 1.2; }
.cell-pct  { font-size: 20px; font-weight: 800; margin-top: 6px; }
.cell-good .cell-pct { color: var(--success); }
.cell-mid  .cell-pct { color: #d97706; }
.cell-poor .cell-pct { color: var(--error); }
.cell-none .cell-pct { color: var(--muted); }

/* Exercise select */
.stats-select {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  margin-bottom: 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.stats-select:focus { border-color: var(--green); }

/* Chart containers */
.stats-chart-wrap {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stats-chart-wrap canvas { display: block; }

.stats-empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 20px 0;
}

/* ===== TONE GRAPHICS ===== */
.roman-token { display: inline-flex; align-items: flex-end; gap: 2px; }
.syl { display: inline-flex; flex-direction: column; align-items: center; }
.syl-text { line-height: 1.1; }
.syl-sep { align-self: flex-end; line-height: 1.1; color: var(--muted); }
.tone-svg-wrap { line-height: 0; }
.tone-svg { color: var(--green); display: block; width: 28px; height: 18px; }
.card-main .tone-svg { width: 42px; height: 27px; }
.quiz-word .tone-svg { width: 36px; height: 23px; }

/* White SVGs on dark gradient backgrounds */
.home-header .tone-svg,
.lesson-hero .tone-svg { color: rgba(255,255,255,.9); }

/* Smaller SVGs in compact label contexts */
.lesson-roman .tone-svg,
.lesson-hero p .tone-svg { width: 24px; height: 15px; }
.app-sub .tone-svg { width: 26px; height: 16px; color: rgba(255,255,255,.9); }

/* ===== TONE KEY FAB ===== */
.tone-key-fab {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 50;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 3px 12px rgba(79,70,229,.45);
  transition: opacity .12s, transform .12s;
  white-space: nowrap;
}
.tone-key-fab:active { opacity: .85; transform: scale(.97); }

/* ===== TONE KEY MODAL ===== */
.tone-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.tone-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.tone-modal-overlay.hidden { display: none; }

.tone-modal {
  background: var(--card);
  border-radius: 22px;
  width: 100%;
  max-width: 460px;
  max-height: 82dvh;
  overflow-y: auto;
  padding-bottom: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  transform: scale(0.05);
  transform-origin: 80% 108%;
  transition: transform 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tone-modal-overlay.open .tone-modal {
  transform: scale(1);
}

.tone-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

.tone-modal-title {
  font-size: 19px;
  font-weight: 800;
}

.tone-modal-close {
  background: var(--bg);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 15px;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tone-modal-body { padding: 0 20px; }

.tone-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.tone-row:last-child { border-bottom: none; }

.tone-row-svg { flex-shrink: 0; color: var(--green); }

.tone-svg-large { display: block; width: 80px; height: 52px; }

.tone-row-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.tone-row-thai {
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}
.tone-row-desc {
  font-size: 15px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.45;
}

/* ===== TIPS ===== */
.screen-tip {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 10px 28px 20px;
  line-height: 1.6;
  min-height: 40px;
  transition: opacity .3s;
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
