/* ================================================================
   SceneSpeak — design system
   ================================================================ */

:root {
  --primary: #2563EB;
  --primary-600: #1D4ED8;
  --primary-100: #DBEAFE;
  --secondary: #0F172A;
  --accent: #14B8A6;
  --accent-100: #CCFBF1;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --muted: #64748B;
  --soft: #F1F5F9;
  --success: #16A34A;
  --warn: #F59E0B;
  --danger: #DC2626;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 40px -16px rgba(37, 99, 235, 0.18);

  --container: 1200px;
  --header-h: 72px;

  --font-head: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-head);
  color: var(--secondary);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 .5em;
  font-weight: 600;
}

h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }

p { margin: 0 0 1rem; color: var(--text); }

a { color: var(--primary); text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--primary-600); }

img { max-width: 100%; display: block; }

button { font-family: inherit; cursor: pointer; }

input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
}

::selection { background: var(--primary-100); color: var(--secondary); }

/* ================================================================
   Layout helpers
   ================================================================ */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 72px 0;
}

.section-tight { padding: 48px 0; }

.section h2 {
  text-align: center;
  margin-bottom: 8px;
}

.section .subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 48px;
  font-size: 1.05rem;
}

.eyebrow {
  display: inline-block;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--primary);
  background: var(--primary-100);
  padding: 6px 12px;
  border-radius: 999px;
  text-transform: uppercase;
}

.grid {
  display: grid;
  gap: 20px;
}
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.text-center { text-align: center; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ================================================================
   Header
   ================================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}
.site-header .container {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--secondary);
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center;
  color: white;
  font-weight: 700;
  font-size: .95rem;
  box-shadow: var(--shadow);
}
.nav {
  display: flex;
  gap: 6px;
  margin-left: 24px;
  flex: 1;
}
.nav a {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  font-size: .95rem;
  transition: all .2s ease;
}
.nav a:hover { color: var(--secondary); background: var(--soft); }
.nav a.active { color: var(--primary); background: var(--primary-100); }
.header-cta { display: flex; align-items: center; gap: 12px; }

.menu-toggle {
  display: none;
  background: transparent; border: 0;
  width: 40px; height: 40px;
  border-radius: 10px;
  align-items: center; justify-content: center;
}
.menu-toggle:hover { background: var(--soft); }
.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after {
  display: block;
  width: 20px; height: 2px;
  background: var(--secondary);
  position: relative;
  border-radius: 2px;
}
.menu-toggle span::before { content: ""; position: absolute; top: -6px; }
.menu-toggle span::after  { content: ""; position: absolute; top: 6px; }

@media (max-width: 920px) {
  .menu-toggle { display: inline-flex; }
  .nav {
    position: absolute;
    top: var(--header-h);
    left: 0; right: 0;
    flex-direction: column;
    gap: 4px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px 20px;
    margin: 0;
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px 14px; }
  .header-cta .btn { padding: 10px 16px; font-size: .9rem; }
}

/* ================================================================
   Buttons
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
  white-space: nowrap;
  font-family: inherit;
}
.btn:focus-visible {
  outline: 3px solid var(--primary-100);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-600);
  color: #fff;
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent;
  color: var(--secondary);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--soft);
  color: var(--secondary);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: #0D9488; color: #fff; }
.btn-soft {
  background: var(--soft);
  color: var(--secondary);
}
.btn-soft:hover { background: #E2E8F0; }
.btn-danger {
  background: #FEE2E2;
  color: #991B1B;
}
.btn-danger:hover { background: #FECACA; }
.btn-sm { padding: 8px 14px; font-size: .85rem; border-radius: 10px; }
.btn-lg { padding: 14px 26px; font-size: 1rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ================================================================
   Cards
   ================================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #CBD5E1;
}
.card-pad-lg { padding: 32px; }
.card-glass {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ================================================================
   Forms
   ================================================================ */
.input,
.search input,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 1rem;
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.input:focus,
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-100);
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 500;
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.input-with-button {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px;
  box-shadow: var(--shadow);
  gap: 6px;
}
.input-with-button input {
  flex: 1;
  border: 0;
  outline: none;
  padding: 12px 14px;
  font-size: 1.05rem;
  background: transparent;
}
.input-with-button .btn { border-radius: var(--radius); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chip {
  background: var(--soft);
  border: 1px solid transparent;
  color: var(--secondary);
  padding: 8px 14px;
  font-size: .85rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 500;
  transition: all .2s ease;
}
.chip:hover {
  background: var(--primary-100);
  color: var(--primary-600);
  border-color: var(--primary-100);
}

/* ================================================================
   Hero
   ================================================================ */
.hero {
  position: relative;
  padding: 88px 0 72px;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute; inset: -120px -80px auto auto;
  width: 520px; height: 520px;
  background: radial-gradient(closest-side, var(--primary-100), transparent 70%);
  z-index: 0;
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute; left: -120px; bottom: -120px;
  width: 460px; height: 460px;
  background: radial-gradient(closest-side, var(--accent-100), transparent 70%);
  z-index: 0;
  pointer-events: none;
}
.hero .container { position: relative; z-index: 1; }

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 48px;
  align-items: center;
}
.hero h1 { font-size: clamp(2.2rem, 4.5vw, 3.4rem); font-weight: 700; }
.hero p.lead {
  color: var(--muted);
  font-size: 1.15rem;
  max-width: 560px;
  margin-bottom: 28px;
}
.hero-search { max-width: 540px; margin-bottom: 16px; }
.hero-meta {
  display: flex; gap: 24px; flex-wrap: wrap;
  margin-top: 24px;
  color: var(--muted);
  font-size: .9rem;
}
.hero-meta strong { color: var(--secondary); }

.hero-illu {
  position: relative;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--primary-100), #fff 60%, var(--accent-100));
  padding: 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-height: 380px;
  overflow: hidden;
}
.hero-illu .scene-bubble {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  animation: float 6s ease-in-out infinite;
}
.hero-illu .scene-bubble .em { font-size: 1.5rem; }
.hero-illu .b1 { top: 20px; left: 20px; }
.hero-illu .b2 { top: 80px; right: 24px; animation-delay: 1.2s; }
.hero-illu .b3 { bottom: 110px; left: 30px; animation-delay: 2.4s; }
.hero-illu .b4 { bottom: 24px; right: 30px; animation-delay: .6s; }
.hero-illu .b5 { top: 50%; left: 45%; transform: translate(-50%, -50%); animation-delay: 1.8s; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.hero-illu .b5 {
  animation: float 6s ease-in-out infinite, b5fix 0s;
}

@media (max-width: 880px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero { padding: 56px 0 40px; }
  .hero-illu { min-height: 280px; }
}

/* ================================================================
   Step cards
   ================================================================ */
.step-card .step-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-100);
  color: var(--primary);
  display: grid; place-items: center;
  font-weight: 700;
  margin-bottom: 14px;
}

/* ================================================================
   Scene grid (popular scenes / library)
   ================================================================ */
.scene-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.scene-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #CBD5E1;
}
.scene-card .em {
  font-size: 2.2rem;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--soft);
}
.scene-card .name {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--secondary);
}
.scene-card .desc { color: var(--muted); font-size: .9rem; margin: 0; }
.scene-card .difficulty {
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-100);
  color: var(--primary);
}
.scene-card .difficulty.intermediate { background: #FEF3C7; color: #92400E; }
.scene-card .difficulty.advanced { background: #FEE2E2; color: #991B1B; }

/* ================================================================
   Feature tile
   ================================================================ */
.feature {
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform .2s ease, box-shadow .2s ease;
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.feature .icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--primary-100);
  color: var(--primary);
  display: grid; place-items: center;
  font-size: 1.4rem;
  margin-bottom: 14px;
}
.feature h4 { margin-bottom: 6px; }
.feature p { color: var(--muted); font-size: .95rem; margin: 0; }

/* ================================================================
   Footer
   ================================================================ */
.site-footer {
  margin-top: 80px;
  background: var(--secondary);
  color: #CBD5E1;
  padding: 56px 0 28px;
}
.site-footer h5 {
  color: #fff;
  font-family: var(--font-head);
  margin-bottom: 14px;
  font-size: 1rem;
}
.site-footer .grid { gap: 32px; }
.site-footer a { color: #CBD5E1; display: block; padding: 6px 0; font-size: .92rem; }
.site-footer a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid #1E293B;
  margin-top: 32px;
  padding-top: 20px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: .85rem; color: #94A3B8;
  flex-wrap: wrap; gap: 12px;
}

/* ================================================================
   Generate page
   ================================================================ */
.generate-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--header-h) - 40px);
  padding: 48px 0;
}
.generate-card {
  width: 100%;
  max-width: 720px;
  text-align: center;
  padding: 48px;
}
.generate-card h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); margin-bottom: 8px; }
.generate-card .lead { color: var(--muted); margin-bottom: 32px; }

.loader {
  display: none;
  flex-direction: column; align-items: center; gap: 16px;
  margin-top: 24px;
  padding: 24px;
}
.loader.active { display: flex; }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--primary-100);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { color: var(--muted); min-height: 1.5em; }

/* ================================================================
   Result page (learning dashboard)
   ================================================================ */
.dashboard {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
  padding: 32px 0 64px;
  align-items: flex-start;
}
.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar nav a {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: .92rem;
  font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}
.sidebar nav a:hover { background: var(--soft); color: var(--secondary); }
.sidebar nav a.active {
  background: var(--primary-100);
  color: var(--primary);
}
.sidebar nav a .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .6;
}

.scene-header {
  display: flex; align-items: center; gap: 20px;
  padding: 24px 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary-100), #fff 70%, var(--accent-100));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
.scene-header .scene-em {
  font-size: 3rem;
  width: 80px; height: 80px;
  border-radius: 18px;
  background: #fff;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.scene-header h1 {
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  margin: 0 0 4px;
  text-transform: capitalize;
}
.scene-header p { margin: 0; color: var(--muted); }

.progress-bar {
  height: 10px;
  background: var(--soft);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  width: 0%;
  border-radius: 999px;
  transition: width .8s ease;
}

.section-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.section-block h2 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}
.section-block .section-sub {
  color: var(--muted);
  font-size: .92rem;
  margin-bottom: 20px;
}

.obj-card {
  text-align: center;
  padding: 18px 14px;
}
.obj-card .em {
  font-size: 1.8rem;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--soft);
  margin: 0 auto 10px;
}
.obj-card .word {
  font-family: var(--font-head);
  font-weight: 600;
  text-transform: capitalize;
  margin-bottom: 4px;
}
.obj-card .def { color: var(--muted); font-size: .85rem; line-height: 1.45; }

/* Flip card (verbs) */
.flip {
  perspective: 1000px;
  height: 160px;
}
.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform .6s ease;
  transform-style: preserve-3d;
  border-radius: var(--radius);
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 18px; text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backface-visibility: hidden;
  cursor: pointer;
  -webkit-backface-visibility: hidden;
}
.flip-front .word {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--secondary);
  margin-bottom: 4px;
}
.flip-front .hint { color: var(--muted); font-size: .8rem; }
.flip-back {
  background: var(--primary);
  color: #fff;
  transform: rotateY(180deg);
  font-size: .95rem;
  line-height: 1.5;
}

/* Phrase card */
.phrase-card {
  padding: 18px 20px;
  border-left: 4px solid var(--primary);
  background: var(--soft);
  border-radius: var(--radius);
}
.phrase-card .p { font-weight: 600; margin-bottom: 4px; color: var(--secondary); }
.phrase-card .ctx { color: var(--muted); font-size: .9rem; }

.sentence {
  font-size: 1.1rem;
  padding: 18px 22px;
  border-radius: var(--radius);
  background: var(--soft);
  margin-bottom: 12px;
  line-height: 1.5;
}

/* Q&A bubbles */
.qa-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: .95rem;
  line-height: 1.5;
}
.bubble.q {
  background: var(--soft);
  color: var(--secondary);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.bubble.a {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* Story */
.story-card {
  padding: 28px;
  background: linear-gradient(180deg, #fff, #F8FAFC);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--secondary);
}

/* Quiz */
.quiz-item {
  background: var(--soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.quiz-item .q-text {
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--secondary);
}
.quiz-options {
  display: grid; gap: 8px;
}
.quiz-option {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
  font-size: .95rem;
}
.quiz-option:hover { border-color: var(--primary); background: var(--primary-100); }
.quiz-option.selected { border-color: var(--primary); background: var(--primary-100); color: var(--primary-600); font-weight: 600; }
.quiz-option.correct { border-color: var(--success); background: #DCFCE7; color: #166534; }
.quiz-option.wrong { border-color: var(--danger); background: #FEE2E2; color: #991B1B; }
.quiz-result {
  margin-top: 12px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--primary-100);
  color: var(--primary-600);
  font-weight: 600;
  display: none;
  align-items: center;
  gap: 12px;
}
.quiz-result.active { display: flex; }

/* Mistakes */
.mistake {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--soft);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.mistake .wrong { color: var(--danger); text-decoration: line-through; }
.mistake .arrow { color: var(--muted); }
.mistake .correct { color: var(--success); font-weight: 600; }

/* Pronunciation */
.pron-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--soft);
  border-radius: 999px;
  margin: 4px 6px 4px 0;
  font-size: .92rem;
}
.pron-pill .ph {
  font-family: ui-monospace, monospace;
  color: var(--primary);
  font-size: .85rem;
}

/* Mindmap */
.mindmap {
  text-align: center;
  padding: 24px;
}
.mindmap .center {
  display: inline-block;
  padding: 14px 26px;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-family: var(--font-head);
  font-weight: 600;
  margin-bottom: 28px;
  text-transform: capitalize;
}
.mindmap-branches {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
}
.branch {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 140px;
  box-shadow: var(--shadow-sm);
}
.branch .label {
  font-family: var(--font-head);
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--secondary);
}
.branch ul {
  margin: 0; padding: 0;
  list-style: none;
  display: flex; flex-direction: column; gap: 4px;
}
.branch li {
  font-size: .85rem;
  color: var(--muted);
}

/* Roleplay */
.chat {
  background: var(--soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex; flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
}
.chat-line {
  display: flex; gap: 10px; align-items: flex-end;
}
.chat-line.right { flex-direction: row-reverse; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 600; font-size: .85rem;
  flex-shrink: 0;
}
.chat-line.left .avatar { background: var(--accent); }
.chat-bubble {
  background: #fff;
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .95rem;
  max-width: 80%;
}
.chat-line.right .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.chat-line .speaker {
  font-size: .72rem;
  color: var(--muted);
  margin-bottom: 2px;
  font-weight: 500;
}
.chat-line.right .speaker { text-align: right; }

/* Revision cards on result page */
.rev-card {
  background: var(--soft);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.rev-card .front { font-weight: 600; color: var(--secondary); margin-bottom: 6px; }
.rev-card .back { color: var(--muted); font-size: .92rem; }

@media (max-width: 920px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    overflow-x: auto;
  }
  .sidebar nav {
    flex-direction: row;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .sidebar nav a { white-space: nowrap; }
}

/* ================================================================
   History page
   ================================================================ */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.toolbar .search {
  flex: 1;
  min-width: 220px;
}
.search input {
  background: var(--card);
}

.history-table {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border-collapse: collapse;
}
.history-table th, .history-table td {
  padding: 14px 16px;
  text-align: left;
  font-size: .92rem;
  border-bottom: 1px solid var(--border);
}
.history-table th {
  background: var(--soft);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .06em;
}
.history-table tr:last-child td { border-bottom: 0; }
.history-table tr:hover td { background: #FAFBFC; }
.history-table .scene-cell {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600;
  text-transform: capitalize;
}
.history-table .em { font-size: 1.4rem; }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--primary-100);
  color: var(--primary-600);
}
.badge.success { background: #DCFCE7; color: #166534; }
.badge.warn { background: #FEF3C7; color: #92400E; }
.badge.muted { background: var(--soft); color: var(--muted); }

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

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.empty-state .em { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { margin-bottom: 4px; }

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
}
.pagination button {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: .9rem;
  cursor: pointer;
  color: var(--secondary);
}
.pagination button.active,
.pagination button:hover:not(:disabled) {
  background: var(--primary);
  color: #fff; border-color: var(--primary);
}
.pagination button:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 720px) {
  .history-table thead { display: none; }
  .history-table, .history-table tbody, .history-table tr, .history-table td {
    display: block; width: 100%;
  }
  .history-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 8px 12px;
  }
  .history-table td {
    border: 0;
    padding: 8px 4px;
    display: flex; justify-content: space-between; gap: 12px;
  }
  .history-table td::before {
    content: attr(data-label);
    font-size: .72rem;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: .06em;
  }
}

/* ================================================================
   Progress page
   ================================================================ */
.stat-card {
  padding: 24px;
}
.stat-card .label {
  color: var(--muted);
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
  font-weight: 600;
}
.stat-card .value {
  font-family: var(--font-head);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--secondary);
  line-height: 1.1;
}
.stat-card .delta { font-size: .85rem; color: var(--success); margin-top: 6px; }

.chart-card {
  padding: 24px;
}
.chart-card h3 { margin-bottom: 12px; }
.chart-wrap {
  position: relative;
  height: 280px;
}

.badge-wall {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}
.achv {
  text-align: center;
  padding: 22px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform .2s ease;
}
.achv.locked { opacity: .45; }
.achv:hover { transform: translateY(-2px); }
.achv .ring {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center;
  font-size: 1.7rem;
  margin: 0 auto 10px;
  color: #fff;
}
.achv h4 { margin-bottom: 4px; font-size: 1rem; }
.achv p { color: var(--muted); font-size: .82rem; margin: 0; }

/* ================================================================
   Revision page (flashcards)
   ================================================================ */
.revision-wrap {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}
.flashcard {
  perspective: 1200px;
  height: 320px;
  margin: 24px 0;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.4,0,.2,1);
  border-radius: var(--radius-lg);
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard .face {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
}
.flashcard .front { background: linear-gradient(135deg, #fff, var(--primary-100)); }
.flashcard .back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}
.flashcard .face .text {
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 600;
}
.flashcard .face .text.body {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.15rem;
  line-height: 1.5;
}

.review-actions {
  display: flex; gap: 12px; justify-content: center;
  margin-top: 20px;
}
.tracker {
  margin-top: 28px;
  padding: 18px 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; justify-content: space-around;
  text-align: center;
}
.tracker .t-cell .v {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--secondary);
}
.tracker .t-cell .l {
  font-size: .8rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .06em;
}

/* ================================================================
   Library page
   ================================================================ */
.cat-tabs {
  display: flex; gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.cat-tab {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  transition: all .2s ease;
}
.cat-tab:hover { background: var(--soft); color: var(--secondary); }
.cat-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ================================================================
   Toast
   ================================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 30px);
  background: var(--secondary);
  color: #fff;
  padding: 14px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: .92rem;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.active { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ================================================================
   Animations
   ================================================================ */
.fade-in   { animation: fadeIn .5s ease both; }
.slide-up  { animation: slideUp .5s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
[data-stagger] > * { animation: slideUp .5s ease both; }
[data-stagger] > *:nth-child(1) { animation-delay: .04s; }
[data-stagger] > *:nth-child(2) { animation-delay: .08s; }
[data-stagger] > *:nth-child(3) { animation-delay: .12s; }
[data-stagger] > *:nth-child(4) { animation-delay: .16s; }
[data-stagger] > *:nth-child(5) { animation-delay: .20s; }
[data-stagger] > *:nth-child(6) { animation-delay: .24s; }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
