:root {
  --bg: #0b0f17;
  --surface: #131926;
  --surface-2: #192234;
  --surface-3: #202c42;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-bg: rgba(56, 189, 248, 0.14);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.14);
  --ok: #10b981;
  --ok-bg: rgba(16, 185, 129, 0.14);
  --bad: #f43f5e;
  --bad-bg: rgba(244, 63, 94, 0.14);
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  touch-action: manipulation;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Header */
.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 15, 23, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 14px 10px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}

h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.progress-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

/* Tabs */
.tabs-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 8px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.16s ease;
}

.tab-btn .tab-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: var(--surface-3);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.tab-btn.active {
  background: var(--accent-bg);
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--ink);
}

.tab-btn.active .tab-num {
  background: var(--accent);
  color: #08101c;
}

/* Main */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 14px 48px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Common cards & pills */
.card-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.pill-btn {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s ease;
}

.pill-btn.active {
  background: var(--accent-bg);
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--accent);
}

.pill-btn.amber.active {
  background: var(--amber-bg);
  border-color: rgba(245, 158, 11, 0.5);
  color: var(--amber);
}

.pill-btn.ok.active {
  background: var(--ok-bg);
  border-color: rgba(16, 185, 129, 0.5);
  color: var(--ok);
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.toggle-chip.active {
  background: var(--amber-bg);
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--amber);
}

/* Audio Player */
.player-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.player-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.voice-switch {
  display: inline-flex;
  background: var(--bg);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.voice-switch button {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.voice-switch button.active {
  background: var(--surface-3);
  color: var(--ink);
}

.speed-switch {
  display: inline-flex;
  gap: 4px;
}

.speed-btn {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.speed-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.loop-btn {
  min-height: 32px;
  padding: 5px 11px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  transition: all 0.15s ease;
}

.loop-btn.mode-one {
  border-color: rgba(245, 158, 11, 0.55);
  color: var(--amber);
  background: var(--amber-bg);
}

.loop-btn.mode-all {
  border-color: rgba(16, 185, 129, 0.55);
  color: var(--ok);
  background: var(--ok-bg);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.play-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: #06101c;
  font-size: 17px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.seek-btn {
  min-width: 40px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
}

.seek-wrap {
  flex: 1;
  min-width: 0;
}

.seek-slider {
  width: 100%;
  accent-color: var(--accent);
  height: 6px;
  cursor: pointer;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* Text & Sentences */
.full-text {
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
  margin: 0;
}

.sentence-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sentence-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
}

.sentence-es {
  font-size: 16px;
  font-weight: 550;
  color: var(--ink);
}

.sentence-ru {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 14px;
  color: #cbd5e1;
}

.sentence-ru.hidden {
  display: none;
}

/* LATAM vs España */
.latam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.latam-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.latam-pair {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 5px;
}

.tag-es {
  color: #fda4af;
}

.tag-latam {
  color: #6ee7b7;
}

.latam-note {
  font-size: 13px;
  color: var(--muted);
}

/* Flashcards */
.cards-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

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

.flashcard-stage {
  perspective: 1200px;
  margin: 10px 0 14px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 310px;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
}

.flashcard-inner.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 22px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.card-front {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
}

.card-badge-top {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.status-badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.status-badge.known {
  background: var(--ok-bg);
  color: var(--ok);
}

.status-badge.learning {
  background: var(--amber-bg);
  color: var(--amber);
}

.status-badge.new {
  background: var(--surface-3);
  color: var(--muted);
}

.front-emoji {
  font-size: 56px;
  line-height: 1;
}

.front-word {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.tap-hint {
  position: absolute;
  bottom: 14px;
  font-size: 12px;
  color: var(--muted);
}

.card-back {
  transform: rotateY(180deg);
  justify-content: flex-start;
  gap: 10px;
  overflow-y: auto;
}

.back-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.back-word {
  font-size: 25px;
  font-weight: 800;
  color: var(--accent);
}

.back-phonetics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.syllables-chip {
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--surface-3);
  font-weight: 700;
  color: var(--ink);
}

.ipa-chip {
  font-family: "SF Mono", Menlo, monospace;
  color: #cbd5e1;
}

.back-block {
  padding: 9px 11px;
  border-radius: 11px;
  background: rgba(11, 15, 23, 0.55);
  border: 1px solid var(--border);
  font-size: 13.5px;
}

.back-block strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 3px;
}

.phrase-es-line {
  font-weight: 650;
  color: var(--ink);
  margin-bottom: 2px;
}

.phrase-ru-line {
  color: var(--muted);
  font-size: 13px;
}

/* Exactly 7 card control buttons */
.card-controls-7 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.ctrl-btn {
  min-height: 46px;
  padding: 8px 6px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: transform 0.08s ease, background 0.15s ease;
}

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

.ctrl-btn.audio {
  background: var(--accent-bg);
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--accent);
}

.ctrl-btn.know {
  background: var(--ok-bg);
  border-color: rgba(16, 185, 129, 0.45);
  color: var(--ok);
  grid-column: span 2;
}

.ctrl-btn.dont-know {
  background: var(--amber-bg);
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--amber);
  grid-column: span 2;
}

.ctrl-btn.playing {
  box-shadow: 0 0 0 2px var(--accent);
}

/* Quiz */
.quiz-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.quiz-score {
  font-size: 15px;
  font-weight: 750;
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 12px;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.quiz-q {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-opt-btn {
  width: 100%;
  text-align: left;
  min-height: 44px;
  padding: 10px 13px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14.5px;
  font-weight: 550;
  color: var(--ink);
  transition: all 0.14s ease;
}

.quiz-opt-btn:hover {
  border-color: var(--border-strong);
}

.quiz-opt-btn.correct {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: #a7f3d0;
}

.quiz-opt-btn.wrong {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: #fecdd3;
}

.quiz-feedback {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
}

.quiz-feedback.ok {
  background: var(--ok-bg);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.quiz-feedback.bad {
  background: var(--bad-bg);
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.quiz-feedback .teacher-line {
  font-weight: 700;
  margin-bottom: 3px;
}

/* Oral prep */
.retell-box {
  background: linear-gradient(150deg, rgba(56, 189, 248, 0.1), rgba(19, 25, 38, 0.95));
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.retell-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mini-btn {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mini-btn.accent {
  background: var(--accent-bg);
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--accent);
}

.mini-btn.playing {
  box-shadow: 0 0 0 2px var(--accent);
}

.oq-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.oq-card.ready {
  border-color: rgba(16, 185, 129, 0.45);
}

.oq-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.oq-title {
  font-size: 16px;
  font-weight: 700;
}

.ready-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.ready-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--ok);
}

.oq-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.oq-drawer {
  margin-top: 10px;
  padding: 11px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
}

.kw-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.kw-chip {
  padding: 5px 10px;
  border-radius: 9px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: 13px;
}

.kw-chip b {
  color: var(--amber);
}

.answer-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

@media (max-width: 520px) {
  h1 { font-size: 18px; }
  .tab-btn { font-size: 12px; padding: 6px 4px; gap: 4px; }
  .front-word { font-size: 24px; }
  .back-word { font-size: 22px; }
  .flashcard-inner { min-height: 340px; }
}
