:root {
  --bg: #FBFAF5;
  --bg2: #F2EFE4;
  --ink: #1C1C16;
  --muted: #6B6A5E;
  --rule: #E2DED0;
  --accent: #0A6E3F;
  --accent-dark: #07502D;
  --accent2: #C8912A;
  --accent-light: #E8F3EC;
  --card: #fff;
  --danger: #A33A2B;
  --danger-light: #FBEDEA;
  --p1: #0A6E3F;
  --p2: #2C6E9B;
  --p3: #8A5A2B;
  --p4: #6B4A8A;
  --shadow: 0 10px 30px rgba(28, 28, 22, .08);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
}

button, select, input { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 22px;
}

/* ---------- Top bar ---------- */
.topbar {
  background: rgba(251, 250, 245, .92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--rule);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand {
  font-weight: 800;
  color: var(--accent);
  font-size: .95rem;
  letter-spacing: .02em;
  text-decoration: none;
  white-space: nowrap;
}
.brand span { letter-spacing: .06em; }

.progress-mini {
  font-size: .78rem;
  color: var(--muted);
  flex: 1;
  min-width: 200px;
}
.progress-mini b { color: var(--accent); font-weight: 700; }

.top-actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
button {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: .88rem;
  transition: transform .15s, background .15s, box-shadow .15s;
}
button:hover { transform: translateY(-1px); background: var(--accent-dark); }
button:active { transform: translateY(0); }
button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
button.ghost:hover { background: var(--accent-light); }
button.danger { background: var(--danger); }
button.danger:hover { background: #86291D; }
button.small { padding: 6px 12px; font-size: .8rem; }

button.icon-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 1rem;
  line-height: 1;
}
button.icon-btn:hover { background: var(--bg2); color: var(--accent); transform: none; }

:focus-visible {
  outline: 3px solid rgba(10, 110, 63, .35);
  outline-offset: 2px;
}

/* ---------- Home ---------- */
.hero {
  padding: 42px 0 28px;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 900;
  line-height: 1.04;
  margin-bottom: 12px;
  letter-spacing: -.02em;
}
.hero .sub {
  color: var(--muted);
  max-width: 620px;
  margin: 0 auto;
  font-size: 1rem;
}
.cta-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}
.hero-note {
  margin-top: 16px;
  font-size: .8rem;
  color: var(--muted);
}
.hero-note kbd {
  background: var(--bg2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .75rem;
}

.progress-track {
  height: 8px;
  background: var(--bg2);
  border-radius: 999px;
  overflow: hidden;
  max-width: 420px;
  margin: 18px auto 0;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #2E9B61);
  border-radius: 999px;
  transition: width .4s ease;
}

.method {
  background: var(--bg2);
  border-radius: 14px;
  padding: 18px;
  margin: 22px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.method div {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--rule);
}
.method b {
  display: block;
  color: var(--accent);
  font-size: .72rem;
  margin-bottom: 4px;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: .04em;
}
.method span { font-size: .85rem; color: var(--ink); }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
}
.section-title h2 { font-size: 1.15rem; font-weight: 900; }
.section-title span { font-size: .8rem; color: var(--muted); }

/* ---------- Roadmap ---------- */
.roadmap { margin-bottom: 48px; }

.week {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
}
.week[open] { box-shadow: var(--shadow); }

.week summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.week summary::-webkit-details-marker { display: none; }
.week summary:hover { background: #FCFBF7; }
.week summary .chev {
  margin-left: auto;
  color: var(--muted);
  transition: transform .2s;
  font-size: .8rem;
}
.week[open] summary .chev { transform: rotate(90deg); }

.week-main { flex: 1; min-width: 220px; }
.week-title { font-weight: 800; font-size: .98rem; }
.week-note { color: var(--muted); font-size: .82rem; }
.week-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }

.badge {
  display: inline-block;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  font-family: ui-monospace, Consolas, monospace;
}
.badge.p1 { background: #E8F3EC; color: var(--p1); }
.badge.p2 { background: #E8F0F7; color: var(--p2); }
.badge.p3 { background: #F7EFE6; color: var(--p3); }
.badge.p4 { background: #F0EBF7; color: var(--p4); }
.badge.week-count { background: var(--bg2); color: var(--muted); }

.days {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
  padding: 0 18px 18px;
}

.day-card {
  --phase: var(--p1);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--phase);
  border-radius: 10px;
  padding: 10px 9px;
  text-align: left;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 88px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.day-card:hover {
  transform: translateY(-2px);
  border-color: var(--phase);
  box-shadow: 0 6px 16px rgba(28, 28, 22, .08);
  background: var(--bg);
}
.day-card.p1 { --phase: var(--p1); }
.day-card.p2 { --phase: var(--p2); }
.day-card.p3 { --phase: var(--p3); }
.day-card.p4 { --phase: var(--p4); }

.day-card.done { background: var(--accent-light); border-color: #CFE6D7; border-top-color: var(--p1); }
.day-card.cur { background: var(--accent); color: #fff; border-color: var(--accent); }
.day-card.cur .day-title, .day-card.cur .day-status { color: rgba(255,255,255,.9); }
.day-card.has-mistake { box-shadow: inset 0 0 0 2px rgba(200, 145, 42, .35); }

.day-num {
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
}
.day-card.cur .day-num { color: rgba(255,255,255,.75); }
.day-card.done .day-num { color: var(--accent); }
.day-title {
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.day-status {
  margin-top: auto;
  font-size: .64rem;
  color: var(--muted);
  font-weight: 700;
}

/* ---------- Lesson ---------- */
.lesson { padding: 22px 0 60px; }

.back {
  color: var(--muted);
  font-size: .82rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  background: none;
  border: none;
  padding: 0;
  font-weight: 600;
}
.back:hover { color: var(--accent); background: none; transform: none; }

.lesson-head {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 18px;
  margin-bottom: 18px;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg2);
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
}
.chip.phase { background: var(--accent-light); color: var(--accent); }
.lesson-head h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: 6px;
  letter-spacing: -.01em;
}
.objective { color: var(--muted); font-size: .94rem; }
.objective b { color: var(--ink); }

.block {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 16px;
}
.btitle {
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 800;
  margin-bottom: 14px;
  font-family: ui-monospace, Consolas, monospace;
}
.block h3 { font-size: 1.15rem; margin-bottom: 12px; font-weight: 800; }
.block h3.song-title { margin-bottom: 4px; }
.song-artist { color: var(--muted); font-size: .86rem; margin-bottom: 14px; }

.song-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 14px;
}
.song-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 14px;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 700;
  font-size: .88rem;
  color: #fff;
  background: var(--ink);
  transition: filter .15s, transform .15s;
}
.song-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.song-btn.spotify { background: #1DB954; color: #062E13; }
.song-btn.youtube { background: #C4302B; }
.song-btn.cifra { background: var(--accent2); color: #fff; }
.song-btn.translate { background: var(--p2); }

.focus {
  background: #FFFBF0;
  border: 1px solid #F0E0B8;
  border-radius: 9px;
  padding: 12px 14px;
  font-size: .88rem;
  color: #8A6A1A;
}
.focus b {
  display: block;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 3px;
  font-family: ui-monospace, Consolas, monospace;
}

details.howto {
  margin-top: 12px;
  font-size: .84rem;
  color: var(--muted);
}
details.howto summary { cursor: pointer; color: var(--accent); font-weight: 700; }
details.howto ol { padding-left: 20px; margin-top: 8px; }
details.howto li { margin-bottom: 4px; }

/* ---------- Chunks ---------- */
.chunks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.chunks-head h3 { margin-bottom: 0; }
.audio-tools { display: flex; gap: 7px; flex-wrap: wrap; }

.chunk-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}
.chunk {
  background: var(--bg2);
  border-radius: 9px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  transition: background .15s, box-shadow .15s;
}
.chunk:hover { background: #ECE8DA; }
.chunk.playing {
  background: var(--accent-light);
  box-shadow: inset 3px 0 0 var(--accent);
}
.chunk.recording {
  background: var(--danger-light);
  box-shadow: inset 3px 0 0 var(--danger);
}
.chunk .pt {
  font-weight: 700;
  color: var(--accent);
  font-family: ui-monospace, Consolas, monospace;
  font-size: .84rem;
  flex: 1;
  min-width: 0;
}
.chunk .en {
  color: var(--muted);
  font-size: .8rem;
  text-align: right;
  flex: 1;
  min-width: 0;
}
.chunk-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.chunk-actions .icon-btn { font-size: .9rem; }
.rec-btn { opacity: .55; }
.chunk:hover .rec-btn,
.chunk.recording .rec-btn { opacity: 1; }
.chunk.recording .rec-btn {
  color: #fff;
  background: var(--danger);
  animation: rec-pulse 1.2s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(163, 58, 43, .35); }
  50% { box-shadow: 0 0 0 5px rgba(163, 58, 43, 0); }
}

.chunk-take {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
  padding-top: 7px;
  border-top: 1px dashed var(--rule);
}
.chunk-take[hidden] { display: none; }
.chunk-take button {
  padding: 4px 9px;
  font-size: .72rem;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(10, 110, 63, .35);
}
.chunk-take button:hover { background: var(--accent-light); transform: none; }
.take-status {
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: ui-monospace, Consolas, monospace;
}
.fv-link {
  color: var(--muted);
  text-decoration: none;
  font-size: .8rem;
  padding: 3px 5px;
  border-radius: 5px;
}
.fv-link:hover { color: var(--accent); background: var(--accent-light); }

.audio-note {
  margin-top: 12px;
  font-size: .76rem;
  color: var(--muted);
}

/* ---------- Pattern ---------- */
.pattern { margin-bottom: 18px; }
.pattern .explain {
  background: var(--bg2);
  padding: 12px 14px;
  border-radius: 9px;
  margin-bottom: 10px;
  font-size: .9rem;
}
.pattern ul { padding-left: 20px; font-size: .88rem; }
.pattern li { margin-bottom: 4px; }

/* ---------- Output ---------- */
.out ol { padding-left: 22px; }
.out li { margin-bottom: 10px; font-size: .92rem; }
.out .after {
  font-size: .84rem;
  color: var(--muted);
  margin-top: 10px;
  border-top: 1px dashed var(--rule);
  padding-top: 10px;
}

/* ---------- Mistakes ---------- */
.mistakes { margin-top: 8px; }
.mistake-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  background: var(--bg2);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: .88rem;
}
.mistake-item button { flex-shrink: 0; }
.mistake-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.mistake-form input {
  flex: 1;
  min-width: 200px;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: .88rem;
}
.mistake-form input:focus { border-color: var(--accent); outline: none; }
.mistake-form button { flex-shrink: 0; }

/* ---------- Actions / progress ---------- */
.actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
  flex-wrap: wrap;
  padding: 16px 0 0;
  border-top: 1px solid var(--rule);
}
.progress-full {
  background: var(--accent-light);
  padding: 13px 16px;
  border-radius: 9px;
  font-size: .86rem;
  margin-top: 12px;
  color: var(--accent-dark);
}
.done-badge { color: var(--accent); font-weight: 800; font-size: .88rem; }

/* ---------- Review ---------- */
.review-day { margin-bottom: 14px; }
.review-day h3 { font-size: 1rem; margin-bottom: 8px; }
.review-day h3 a { text-decoration: none; }
.review-day h3 a:hover { text-decoration: underline; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 60px 20px;
  border: 1px dashed var(--rule);
  border-radius: 14px;
  background: var(--card);
  margin: 30px 0;
}
.empty h2 { font-size: 1.25rem; margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 18px; }

/* ---------- Dialog ---------- */
.dialog {
  border: none;
  padding: 0;
  border-radius: 16px;
  width: min(620px, 92vw);
  max-height: 88vh;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
}
.dialog::backdrop { background: rgba(28,28,22,.45); backdrop-filter: blur(2px); }

.dialog-card { padding: 0; }
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--rule);
}
.dialog-head h2 { font-size: 1.1rem; font-weight: 900; }

.dialog-section {
  padding: 18px 22px;
  border-bottom: 1px solid var(--rule);
}
.dialog-section:last-child { border-bottom: none; }
.dialog-section h3 { font-size: .9rem; margin-bottom: 12px; }

.field {
  display: block;
  margin-bottom: 14px;
  font-size: .84rem;
  color: var(--muted);
}
.field > span { display: flex; justify-content: space-between; margin-bottom: 5px; }
.field b { color: var(--accent); }
.field select,
.field input[type="range"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: .86rem;
}
.field input[type="range"] { padding: 0; accent-color: var(--accent); }

.voice-fallback {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: #FCFBF7;
}
.voice-fallback summary {
  cursor: pointer;
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
}
.voice-fallback[open] summary { margin-bottom: 12px; }
.voice-fallback .field { margin-bottom: 10px; }
.voice-fallback .hint { margin-top: 6px; }

.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

.hint { font-size: .76rem; color: var(--muted); margin-top: 8px; }

/* ---------- Phrase of the day & basics ---------- */
.phrase-block {
  background: linear-gradient(135deg, #FFF9EA, #FDF6E7);
  border-color: #F0E0B8;
}
.phrase-block .btitle { color: var(--accent2); }
.phrase-row { background: #fff; border: 1px solid #F0E0B8; }
.phrase-row:hover { background: #FFFDF6; }
.phrase-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 180px; }
.phrase-pt { font-size: 1.15rem; font-weight: 800; color: var(--ink); }
.phrase-en { font-size: .82rem; color: var(--muted); }
.phrase-note { margin-top: 10px; font-size: .82rem; color: var(--muted); }

.basics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 7px;
}
.basic-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg2);
  border-radius: 8px;
  padding: 7px 9px;
  transition: background .15s, box-shadow .15s;
}
.basic-pt { font-weight: 700; font-size: .9rem; flex: 1; }
.basic-en { font-size: .74rem; color: var(--muted); }
.basic-actions { display: flex; gap: 0; }
.basic-actions .icon-btn { font-size: .8rem; padding: 2px 3px; }
.basic-item.playing { background: var(--accent-light); box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- Session (SRS) ---------- */
.session { padding: 22px 0 60px; }
.session-bar {
  height: 8px;
  max-width: none;
  margin: 4px 0 20px;
}

.srs-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 34px 26px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}
.srs-context {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
  font-family: ui-monospace, Consolas, monospace;
}
.srs-pt {
  font-size: clamp(1.8rem, 5vw, 2.7rem);
  font-weight: 900;
  color: var(--accent);
  margin: 14px 0 6px;
  line-height: 1.15;
  letter-spacing: -.01em;
}
.srs-en { font-size: 1.05rem; color: var(--muted); margin-bottom: 4px; }
.srs-reveal { margin-top: 12px; background: var(--ink); }
.srs-reveal:hover { background: #000; }

.srs-tools {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.srs-rate {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 22px;
}
.srs-rate .rate {
  background: var(--bg2);
  color: var(--ink);
  font-size: .84rem;
  padding: 12px 6px;
  border-radius: 9px;
}
.srs-rate .rate small {
  display: block;
  font-size: .64rem;
  font-weight: 700;
  opacity: .6;
  margin-top: 2px;
  letter-spacing: .03em;
}
.srs-rate .again { background: var(--danger-light); color: var(--danger); }
.srs-rate .hard { background: #F7EFE6; color: var(--p3); }
.srs-rate .good { background: var(--accent-light); color: var(--accent); }
.srs-rate .easy { background: #E8F0F7; color: var(--p2); }
.srs-rate .rate:hover { transform: translateY(-1px); filter: brightness(.97); }

.session-stats {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 22px;
}
.session-stats .stat {
  font-size: .74rem;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
  font-family: ui-monospace, Consolas, monospace;
}
.session-stats .again { background: var(--danger-light); color: var(--danger); }
.session-stats .hard { background: #F7EFE6; color: var(--p3); }
.session-stats .good { background: var(--accent-light); color: var(--accent); }
.session-stats .easy { background: #E8F0F7; color: var(--p2); }
.session-summary { text-align: center; padding: 10px 0 20px; }

@media (max-width: 520px) {
  .srs-rate { grid-template-columns: repeat(2, 1fr); }
  .srs-card { padding: 26px 16px 22px; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .84rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Quizzes ---------- */
.quiz-home {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 44px;
}

.quiz-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  text-align: left;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 16px 18px;
  font-weight: 400;
  box-shadow: none;
}
.quiz-tile:hover {
  background: #FCFBF7;
  color: var(--ink);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.quiz-tile.lead { background: var(--accent-light); border-color: #CFE6D7; }
.quiz-tile.locked { opacity: .72; cursor: default; box-shadow: none; transform: none; }
.quiz-tile-title { font-weight: 800; font-size: .95rem; }
.quiz-tile-sub { font-size: .8rem; color: var(--muted); line-height: 1.4; }
.quiz-tile-state {
  margin-top: 4px;
  font-size: .71rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.quiz-tile-state.good { color: var(--accent); }

.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}
.quiz-grid.wide { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.week-quiz {
  border-top: 1px dashed var(--rule);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.quiz-locked { font-size: .8rem; color: var(--muted); }
.quiz-best { font-size: .74rem; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }

.quiz-page .session-bar { max-width: none; margin: 4px 0 18px; }

.quiz-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.quiz-hint {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.quiz-prompt {
  font-size: clamp(1.25rem, 4vw, 1.7rem);
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 18px;
}
.quiz-context { font-size: .86rem; color: var(--muted); margin: -10px 0 16px; }
.quiz-listen {
  width: 100%;
  padding: 20px;
  font-size: 1rem;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px dashed var(--accent);
  margin-bottom: 18px;
}
.quiz-listen:hover { background: #DCEFE3; color: var(--accent-dark); }

.quiz-choices { display: grid; gap: 9px; }
.quiz-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: var(--bg2);
  color: var(--ink);
  border: 1px solid var(--rule);
  font-weight: 600;
  padding: 13px 16px;
}
.quiz-choice:hover:not(:disabled) { background: #ECE8DA; color: var(--ink); transform: none; }
.quiz-choice .qk {
  font-size: .68rem;
  font-weight: 800;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1px 6px;
  background: #fff;
}
.quiz-choice.ok { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }
.quiz-choice.bad { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.quiz-choice:disabled { cursor: default; opacity: 1; }

.quiz-type-form { display: flex; gap: 8px; flex-wrap: wrap; }
.quiz-type-form input {
  flex: 1;
  min-width: 200px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: #fff;
  font-size: 1rem;
  color: var(--ink);
}

.quiz-answer-line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px dashed var(--rule);
  border-radius: 10px;
  background: var(--bg2);
  margin-bottom: 12px;
}
.quiz-answer-line.empty { color: var(--muted); }
.quiz-answer-chip {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 3px 9px;
  font-weight: 600;
}
.quiz-placeholder { font-size: .85rem; color: var(--muted); }
.quiz-tokens { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.quiz-token {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--rule);
  font-weight: 600;
  padding: 8px 12px;
}
.quiz-token:hover:not(:disabled) { background: var(--accent-light); color: var(--accent-dark); }
.quiz-token.used { opacity: .3; }
.quiz-token:disabled { cursor: default; }

.quiz-feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quiz-feedback.ok { background: var(--accent-light); border: 1px solid #CFE6D7; }
.quiz-feedback.bad { background: var(--danger-light); border: 1px solid #F0CFC7; }
.quiz-verdict { font-weight: 800; }
.quiz-feedback.ok .quiz-verdict { color: var(--accent-dark); }
.quiz-feedback.bad .quiz-verdict { color: var(--danger); }
.quiz-correct-answer { font-weight: 700; }
.quiz-trans { font-size: .86rem; color: var(--muted); }
.quiz-next { align-self: flex-start; margin-top: 6px; }

.quiz-result {
  text-align: center;
  padding: 26px 20px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 16px;
  margin-bottom: 18px;
}
.quiz-result.pass { border-color: #CFE6D7; }
.quiz-result.fail { border-color: #F0CFC7; }
.quiz-score { font-size: clamp(2.6rem, 9vw, 3.6rem); font-weight: 900; line-height: 1; color: var(--accent); }
.quiz-result.fail .quiz-score { color: var(--danger); }
.quiz-score small { font-size: .45em; font-weight: 700; }
.quiz-score-note { color: var(--muted); font-size: .88rem; max-width: 460px; margin: 10px auto 0; }

.quiz-block .hint { margin-top: 8px; }

/* ---------- Vocabulary ---------- */
.words-head { padding: 26px 0 8px; }
.words-head h2 { font-size: clamp(1.4rem, 4vw, 1.8rem); font-weight: 900; margin: 8px 0 4px; }
.words-head .hint { color: var(--muted); font-size: .88rem; max-width: 640px; }

.words-search {
  width: 100%;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font-size: .95rem;
}
.words-search:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(10, 110, 63, .12);
}

.word-cats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  margin: 16px 0 48px;
}

.word-cat {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.word-cat:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.word-cat-icon { font-size: 1.5rem; line-height: 1; }
.word-cat-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.word-cat-title { font-weight: 800; font-size: .95rem; }
.word-cat-sub {
  color: var(--muted);
  font-size: .76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.word-cat-chev { color: var(--accent); font-weight: 800; }

.word-list { display: flex; flex-direction: column; gap: 6px; margin: 16px 0 48px; }

.word-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  transition: border-color .15s, background .15s;
}
.word-row.playing { border-color: var(--accent); background: var(--accent-light); }
.word-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.word-pt { font-weight: 700; line-height: 1.35; }
.word-en { color: var(--muted); font-size: .82rem; }

.word-cat-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg2);
  color: var(--muted);
  font-size: .66rem;
  font-weight: 700;
  vertical-align: 1px;
}

.words-count { color: var(--muted); font-size: .8rem; margin-top: 14px; }
.words-empty {
  margin: 22px 0;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--rule);
  border-radius: 12px;
}

.words-promo {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 0;
  transition: border-color .15s, box-shadow .15s;
}
.words-promo:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.words-promo-icon { font-size: 1.8rem; line-height: 1; }
.words-promo-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.words-promo-title { font-weight: 900; font-size: 1.02rem; }
.words-promo-sub { color: var(--muted); font-size: .84rem; }
.words-promo-cta { color: var(--accent); font-weight: 800; font-size: .88rem; white-space: nowrap; }

.promo-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 48px; }

/* ---------- Progress dashboard ---------- */
.dash-head { padding: 26px 0 4px; }
.dash-head h2 { font-size: clamp(1.4rem, 4vw, 1.8rem); font-weight: 900; margin: 8px 0 4px; }
.dash-head .hint { color: var(--muted); font-size: .88rem; max-width: 640px; }

.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 18px 0 8px;
}
.dash-stats-mini { margin: 8px 0 18px; }
.dash-stats-mini .dash-num { font-size: 1.15rem; color: var(--ink); }

.dash-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
}
.dash-num { font-size: 1.65rem; font-weight: 900; line-height: 1.1; color: var(--accent); }
.dash-num small { font-size: .52em; font-weight: 700; color: var(--muted); }
.dash-label { font-size: .8rem; font-weight: 700; }
.dash-sub { font-size: .72rem; color: var(--muted); }

.dash-section { margin: 26px 0; }
.dash-section h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: .95rem;
  font-weight: 900;
  margin-bottom: 10px;
}
.dash-section h3 span { font-size: .74rem; font-weight: 600; color: var(--muted); }
.dash-section .hint { margin-top: 8px; }

.dash-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: .78rem;
}
.dash-bar-label { width: 78px; flex: none; color: var(--muted); }
.dash-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg2);
  border-radius: 999px;
  overflow: hidden;
}
.dash-bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #2E9B61);
  border-radius: 999px;
  transition: width .3s ease;
}
.dash-bar-value {
  width: 48px;
  flex: none;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.dash-week-link { text-decoration: none; color: var(--ink); border-radius: 6px; padding: 2px 0; }
.dash-week-link:hover .dash-bar-fill { background: var(--accent-dark); }
.dash-week-link:hover .dash-bar-label { color: var(--accent); }

.dash-quiz-list { display: flex; flex-direction: column; gap: 6px; }
.dash-quiz-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  font-size: .84rem;
}
.dash-quiz-title { flex: 1; font-weight: 700; }
.dash-quiz-date { color: var(--muted); font-size: .74rem; white-space: nowrap; }
.dash-score {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-size: .75rem;
  font-weight: 800;
  white-space: nowrap;
}
.dash-score.fail { background: var(--danger-light); color: var(--danger); }

.dash-empty {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: .84rem;
  background: var(--card);
  border: 1px dashed var(--rule);
  border-radius: 10px;
}
.dash-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.dash-link:hover { text-decoration: underline; }

.dash-heat { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.dash-cell { aspect-ratio: 1; border-radius: 4px; background: var(--bg2); }
.dash-cell.l1 { background: #D6EBDD; }
.dash-cell.l2 { background: #A8D5B9; }
.dash-cell.l3 { background: #58A97C; }
.dash-cell.l4 { background: var(--accent); }

@media (max-width: 680px) {
  /* The sticky header would keep two rows of nav pinned on a phone, so let it scroll away. */
  .topbar { position: static; }
  .topbar-inner { gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .progress-mini { min-width: 0; font-size: .74rem; }
  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .top-actions button { padding: 9px 6px; font-size: .8rem; }
  .word-cats { grid-template-columns: minmax(0, 1fr); }
  .words-promo { flex-wrap: wrap; }
  .dash-heat { grid-template-columns: repeat(7, 1fr); }
}

/* ---------- Responsive ---------- */
@media (max-width: 680px) {
  .app { padding: 0 16px; }
  .hero { padding: 30px 0 22px; }
  .method { grid-template-columns: 1fr; }
  .song-row { grid-template-columns: 1fr; }
  .days { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); padding: 0 14px 14px; }
  .week summary { padding: 14px; }
  .block { padding: 17px; }
  .chunk-list { grid-template-columns: 1fr; }
  .chunk { flex-wrap: wrap; }
  .chunk .en { text-align: left; }
  .top-actions { margin-left: auto; }
  .song-btn { font-size: .82rem; padding: 11px 10px; }
}

@media print {
  .topbar, .actions, .cta-row, .audio-tools, .chunk-actions, .mistake-form, .dialog { display: none !important; }
  .block { break-inside: avoid; box-shadow: none; }
  body { font-size: 11pt; }
}
