/* ─────────────────────────────────────────────
   YouEnglish — design tokens + base
   ───────────────────────────────────────────── */
:root {
  /* Surface */
  --bg: #FFFEFB;
  --bg-subtle: #FAF7F1;
  --surface: #FFFFFF;
  --surface-hover: #FAF7F1;

  /* Borders */
  --border: #EAE6DC;
  --border-strong: #D8D2C5;

  /* Text */
  --text-primary: #1A1715;
  --text-secondary: #6B6560;
  --text-muted: #9A938C;
  --text-inverse: #FFFFFF;

  /* Accent */
  --accent: #FB923C;
  --accent-hover: #F97316;
  --accent-active: #EA580C;
  --accent-soft: #FFF4E6;
  --accent-soft-hover: #FFE9D1;
  --accent-fg: #B45309;

  /* Semantic */
  --success: #10B981;
  --success-soft: #D1FAE5;
  --error: #EF4444;
  --error-soft: #FEE2E2;
  --warning: #F59E0B;
  --warning-soft: #FEF3C7;

  /* Levels */
  --level-a2: #64748B; --level-a2-soft: #F1F5F9;
  --level-b1: #2563EB; --level-b1-soft: #DBEAFE;
  --level-b2: #7C3AED; --level-b2-soft: #EDE9FE;
  --level-c1: #DB2777; --level-c1-soft: #FCE7F3;

  /* Status */
  --status-new: #94A3B8;
  --status-learning: #FB923C;
  --status-mastered: #10B981;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(26, 23, 21, 0.04);
  --shadow-sm: 0 2px 4px rgba(26, 23, 21, 0.06), 0 1px 2px rgba(26, 23, 21, 0.04);
  --shadow-md: 0 8px 16px rgba(26, 23, 21, 0.06), 0 2px 4px rgba(26, 23, 21, 0.04);
  --shadow-lg: 0 16px 32px rgba(26, 23, 21, 0.08), 0 4px 8px rgba(26, 23, 21, 0.04);
  --shadow-glow: 0 0 0 4px rgba(251, 146, 60, 0.18);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Type scale */
.text-display-xl { font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: 64px; line-height: 1.15; letter-spacing: -0.02em; padding-bottom: 0.05em; }
@media (max-width: 1100px) {
  .text-display-xl { font-size: 48px; line-height: 1.15; }
}
.text-display-lg { font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: 48px; line-height: 1.1;  letter-spacing: -0.02em; }
.text-display-md { font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: 36px; line-height: 1.15; letter-spacing: -0.01em; }
.text-display-sm { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 28px; line-height: 1.2;  letter-spacing: -0.01em; }
.text-heading-lg { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 22px; line-height: 1.3; }
.text-heading-md { font-family: 'Manrope', sans-serif;     font-weight: 600; font-size: 18px; line-height: 1.4; }
.text-heading-sm { font-family: 'Manrope', sans-serif;     font-weight: 600; font-size: 16px; line-height: 1.4; }
.text-body-lg    { font-size: 18px; line-height: 1.6; }
.text-body       { font-size: 16px; line-height: 1.6; }
.text-body-sm    { font-size: 14px; line-height: 1.5; color: var(--text-secondary); }
.text-caption    { font-size: 12px; font-weight: 500; line-height: 1.4; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); }
.text-mono       { font-family: 'JetBrains Mono', monospace; font-weight: 500; font-size: 14px; line-height: 1.4; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }

/* ─────────────────────────────────────────────
   Layout shell
   ───────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 32px 12px 16px;
}
.brand {
  font-family: 'Fraunces', Georgia, serif; font-weight: 700;
  font-size: 22px; line-height: 1; letter-spacing: -0.01em;
  color: var(--text-primary); padding: 0 12px 24px;
  text-decoration: none;
}
.brand .e { color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px; height: 40px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav-item:hover { background: var(--surface); color: var(--text-primary); }
.nav-item.active { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-xs); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; }

/* main */
.main {
  flex: 1;
  min-width: 0;
}
.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 48px 80px;
}
.page { display: none; }
.page.active { display: block; animation: fadeIn 250ms var(--ease-out); }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* stagger */
.stagger > * { opacity: 0; transform: translateY(12px); animation: rise 400ms var(--ease-out) forwards; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 50ms; }
.stagger > *:nth-child(3) { animation-delay: 100ms; }
.stagger > *:nth-child(4) { animation-delay: 150ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 250ms; }
.stagger > *:nth-child(7) { animation-delay: 300ms; }
.stagger > *:nth-child(8) { animation-delay: 350ms; }
.stagger > *:nth-child(9) { animation-delay: 400ms; }
.stagger > *:nth-child(n+10) { animation-delay: 450ms; }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }

/* page header */
.page-header { margin-bottom: 32px; }
.page-header .eyebrow { color: var(--accent); margin-bottom: 8px; }
.page-header .desc { color: var(--text-secondary); margin-top: 6px; }

/* ─────────────────────────────────────────────
   Components
   ───────────────────────────────────────────── */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: 'Manrope', sans-serif; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 200ms var(--ease-out);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-glow); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; border-radius: var(--radius-md); }
.btn-md { height: 44px; padding: 0 18px; font-size: 15px; border-radius: var(--radius-lg); }
.btn-lg { height: 48px; padding: 0 22px; font-size: 16px; border-radius: var(--radius-lg); }

.btn-primary {
  background: var(--accent); color: white;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-primary:active { background: var(--accent-active); border-color: var(--accent-active); }

.btn-secondary {
  background: var(--surface); color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border-color: transparent;
  border-radius: var(--radius-md);
}
.btn-ghost:hover { background: var(--accent-soft); color: var(--text-primary); }

.btn-destructive {
  background: var(--surface); color: var(--error);
  border-color: var(--error);
}
.btn-destructive:hover { background: var(--error-soft); }

.btn-icon { width: 40px; padding: 0; }
.btn-icon.sm { width: 32px; height: 32px; }

/* ─────────────────────────────────────────────
   Lesson Generating state
   ───────────────────────────────────────────── */
.generating-wrap {
  max-width: 480px;
  margin: 0 auto;
  min-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  justify-content: center;
  padding: 40px 0;
}
.gen-thumb-glow {
  border-radius: var(--radius-xl);
  box-shadow: 0 0 80px rgba(251, 146, 60, 0.22);
  animation: pulse-soft 2s ease-in-out infinite;
}
.gen-thumb {
  width: 100%; aspect-ratio: 16/9;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--bg-subtle);
  box-shadow: var(--shadow-md);
}
.gen-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@keyframes pulse-soft {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.02); }
}
.gen-stages {
  list-style: none; padding: 0;
  margin: 24px 0 0;
  display: flex; flex-direction: column; gap: 12px;
}
.gen-stage {
  display: flex; align-items: center; gap: 12px;
  font-size: 15px;
  color: var(--text-muted);
}
.gen-stage.done { color: var(--text-primary); }
.gen-stage.active { color: var(--text-primary); font-weight: 600; }
.gs-marker {
  width: 24px; height: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.gen-stage.done .gs-marker { background: var(--success); color: white; }
.gen-stage.active .gs-marker { color: var(--accent); }
.gs-spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.gs-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-strong);
}
.gen-progress {
  margin-top: 32px;
  height: 4px; border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.gen-progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 999px;
  transition: width 400ms var(--ease-out);
}

/* ─────────────────────────────────────────────
   Settings (refined)
   ───────────────────────────────────────────── */
.set-section { padding: 4px 0; }
.set-section-head {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-secondary);
}
.set-divider {
  height: 1px; background: var(--border);
  margin: 40px 0;
}
.api-row {
  display: flex; gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
  align-items: stretch;
}
.api-row .input { height: 44px; }
.api-row .icon-btn.sm { width: 32px; height: 32px; }
.input-wrap .input-suffix.icon-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.input-wrap .input-suffix + .input,
.input-wrap .input { padding-right: 44px; }
.api-status {
  margin-top: 12px;
  display: flex; align-items: center; gap: 6px;
  font-size: 14px;
}
.api-status.ok  { color: var(--success); }
.api-status.err { color: var(--error); }
.set-form { margin-top: 18px; display: flex; flex-direction: column; gap: 20px; }
.set-field { display: flex; flex-direction: column; gap: 8px; }
.set-label { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.set-help { font-size: 13px; color: var(--text-secondary); }
.select:disabled { opacity: 0.6; cursor: not-allowed; }
.seg-control {
  display: inline-flex;
  padding: 4px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  gap: 2px;
}
.seg-tab {
  border: 0; background: transparent;
  padding: 8px 20px;
  border-radius: var(--radius-full);
  font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.seg-tab.active { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-xs); }
.seg-tab:disabled { opacity: 0.5; cursor: not-allowed; }
.set-actions { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

/* Source toggle (Home hero) */
.source-toggle {
  display: inline-flex;
  padding: 4px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  gap: 2px;
}
.src-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border: 0; background: transparent;
  border-radius: var(--radius-full);
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease-out);
}
.src-tab:hover { color: var(--text-primary); }
.src-tab.active {
  background: var(--surface); color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
textarea.srt-input {
  height: auto; min-height: 160px;
  padding: 14px 16px;
  line-height: 1.55;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  resize: vertical;
}

/* Inputs */
.input {
  height: 48px; width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0 16px;
  font-size: 16px; font-family: inherit;
  color: var(--text-primary);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder { color: var(--text-muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-glow); }

.input-tall { height: 56px; font-size: 17px; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input-icon { position: absolute; left: 16px; color: var(--text-muted); pointer-events: none; }
.input-wrap .input-icon + .input { padding-left: 44px; }
.input-wrap .input-suffix { position: absolute; right: 8px; }

.select {
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0 36px 0 14px;
  font-size: 15px; font-family: inherit; font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%236B6560' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.select:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-glow); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-xs);
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out);
}
.card-interactive { cursor: pointer; }
.card-interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent-soft-hover); }
.card-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.card-stat {
  background: var(--bg-subtle);
  border: 0; border-radius: var(--radius-lg);
  padding: 20px;
}
.card-stat .num { font-family: 'JetBrains Mono', monospace; font-weight: 500; font-size: 32px; line-height: 1; color: var(--text-primary);}
.card-stat .lbl { display: block; margin-top: 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); }

/* Badges (pills) */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-lv-a2 { background: var(--level-a2-soft); color: var(--level-a2); }
.badge-lv-b1 { background: var(--level-b1-soft); color: var(--level-b1); }
.badge-lv-b2 { background: var(--level-b2-soft); color: var(--level-b2); }
.badge-lv-c1 { background: var(--level-c1-soft); color: var(--level-c1); }

.badge-easy   { background: var(--success-soft); color: #047857; }
.badge-medium { background: var(--accent-soft); color: var(--accent-fg); }
.badge-hard   { background: var(--error-soft); color: #B91C1C; }

/* Status pill: tint to match the dot color so it stays distinct from
   the row hover background (which is the same token as --bg-subtle). */
.badge-status { background: #EEF2F7; color: #475569; }
.badge-status[data-status="learning"] { background: var(--accent-soft); color: var(--accent-fg); }
.badge-status[data-status="mastered"] { background: var(--success-soft); color: #047857; }
.badge-status .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-new      { background: var(--status-new); }
.dot-learning { background: var(--status-learning); }
.dot-mastered { background: var(--status-mastered); }

/* Tabs */
.tabs {
  display: flex; gap: 28px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 5;
}
.tab-btn {
  position: relative;
  background: transparent; border: 0;
  padding: 14px 0;
  font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
  display: inline-flex; align-items: center; gap: 8px;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--text-primary); }
.tab-btn::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur-base) var(--ease-out);
}
.tab-btn.active::after { transform: scaleX(1); }
.tab-btn .tab-count {
  background: var(--accent-soft); color: var(--accent-fg);
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-full);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 64px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-ico {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--bg-subtle);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.empty h3 { margin: 4px 0 0; font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 18px; color: var(--text-primary); }
.empty p { margin: 0; color: var(--text-secondary); font-size: 14px; max-width: 320px; }

/* Lesson card (history grid + continue learning) */
.lcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out);
  text-decoration: none;
  color: inherit;
  display: flex; flex-direction: column;
}
.lcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent-soft-hover); }
.lcard .thumb { position: relative; aspect-ratio: 16/9; background: var(--bg-subtle); overflow: hidden; }
.lcard .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 400ms var(--ease-out); }
.lcard:hover .thumb img { transform: scale(1.04); }
.lcard .thumb .lvl { position: absolute; top: 12px; left: 12px; backdrop-filter: blur(8px); background: rgba(255,255,255,0.85); }
.lcard .thumb .ws  { position: absolute; bottom: 12px; right: 12px; background: rgba(26, 23, 21, 0.72); backdrop-filter: blur(8px); color: white; font-size: 11px; padding: 4px 10px; border-radius: var(--radius-full); font-weight: 600; }
.lcard .thumb .play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,0.92);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 200ms var(--ease-out);
  box-shadow: var(--shadow-md);
}
.lcard:hover .thumb .play { opacity: 1; }
.lcard .thumb .play::after {
  content: ""; width: 0; height: 0;
  border-left: 12px solid var(--text-primary);
  border-top: 8px solid transparent; border-bottom: 8px solid transparent;
  margin-left: 3px;
}
.lcard .body { padding: 16px 18px 18px; }
.lcard .body h3 {
  margin: 0;
  font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 16px; line-height: 1.35;
  color: var(--text-primary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 44px;
}
.lcard .body .meta { margin-top: 12px; color: var(--text-muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.lcard .body .meta .sep { width: 3px; height: 3px; background: var(--text-muted); border-radius: 50%; }

/* Vocab card */
.vcard {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px 22px 18px;
  box-shadow: var(--shadow-xs);
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out);
  display: flex; flex-direction: column;
}
.vcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent-soft-hover); }
.vcard .bookmark {
  position: absolute; top: 14px; right: 14px;
  background: transparent; border: 0; padding: 6px;
  cursor: pointer; color: var(--text-muted);
  border-radius: var(--radius-md);
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.vcard .bookmark:hover { background: var(--accent-soft); color: var(--accent); }
.vcard .bookmark.on { color: var(--accent); }
.vcard .bookmark.on svg { fill: currentColor; }
.vcard .phrase {
  font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 18px; line-height: 1.3;
  color: var(--text-primary);
  padding-right: 32px;
}
.vcard .translation { color: var(--text-secondary); margin-top: 4px; font-size: 16px; }
.vcard .definition { color: var(--text-muted); font-size: 13px; margin-top: 8px; line-height: 1.5; }
.vcard .quote {
  background: var(--bg-subtle);
  border-left: 2px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-top: 16px;
  font-size: 13px; font-style: italic;
  color: var(--text-secondary); line-height: 1.55;
}
.vcard .quote::before {
  content: "\201C"; color: var(--accent); font-family: 'Fraunces', serif;
  font-size: 18px; font-style: normal; margin-right: 2px; line-height: 0;
}
.vcard .vfoot { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.save-btn {
  background: transparent; border: 0;
  padding: 6px 10px; border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--dur-fast) var(--ease-out);
}
.save-btn:hover { background: var(--accent-soft); color: var(--text-primary); }
.save-btn.on { color: var(--accent); }

/* Lesson hero */
.lesson-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  text-decoration: none; padding: 6px 10px; margin-left: -10px;
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.lesson-back:hover { background: var(--bg-subtle); color: var(--text-primary); }

.lesson-hero { max-width: 800px; margin: 0 auto; }
.lesson-player {
  position: relative;
  width: 100%; aspect-ratio: 16/9;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow-md);
}
.lesson-player img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lesson-player .play-big {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: var(--shadow-lg);
  transition: transform 200ms var(--ease-out);
}
.lesson-player .play-big:hover { transform: translate(-50%, -50%) scale(1.06); }
.lesson-player .play-big::after {
  content: ""; width: 0; height: 0;
  border-left: 18px solid white;
  border-top: 12px solid transparent; border-bottom: 12px solid transparent;
  margin-left: 5px;
}

.lesson-meta { display: flex; align-items: center; gap: 12px; margin-top: 24px; color: var(--text-secondary); font-size: 14px; }
.lesson-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-muted); }
.lesson-title { margin: 8px 0 0; }
.lesson-actions-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; gap: 16px; flex-wrap: wrap;}
.lesson-actions-row .who { color: var(--text-secondary); font-size: 14px; }
.lesson-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px;
  background: transparent; border: 0;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--text-primary); }
.icon-btn.on { color: var(--accent); }
.icon-btn.on svg path { fill: currentColor; }

/* Lesson tab content wrap */
.lesson-tabs-wrap { margin-top: 40px; }
.tab-content { max-width: 1024px; margin: 0 auto; padding: 32px 0 0; }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 250ms var(--ease-out); }

/* Vocabulary grid */
.vocab-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }

/* Grammar cards */
.grammar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px 28px 26px 32px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.grammar-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent); border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}
.grammar-card .pattern { margin: 0; }
.grammar-card .explanation { margin-top: 8px; }
.grammar-card .examples-label { margin-top: 18px; }
.grammar-card .examples { margin-top: 8px; padding-left: 16px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px;}
.grammar-card .examples li { font-style: italic; color: var(--text-secondary); list-style: none; line-height: 1.5; }
.grammar-card .examples li b { color: var(--text-primary); font-style: normal; font-weight: 600; background: var(--accent-soft); padding: 0 3px; border-radius: 3px; }
.grammar-card .why-label { margin-top: 22px; }
.grammar-card .why { margin-top: 4px; color: var(--text-secondary); font-size: 14px; line-height: 1.5; }

/* Exercises */
.exer-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;}
.exer-section + .exer-section { margin-top: 40px; }
.exer-section h2 { margin: 0 0 16px; }
.exer-list { display: flex; flex-direction: column; gap: 12px; }
.exer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  transition: border-color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.exer-card.correct { border-color: var(--success); background: #F0FDF4; }
.exer-card.wrong   { border-color: var(--error);   background: #FEF2F2; animation: shake 200ms var(--ease-out); }
@keyframes shake { 0%,100%{transform:translateX(0);} 25%{transform:translateX(-5px);} 75%{transform:translateX(5px);} }
.exer-card .q-num { color: var(--text-secondary); }
.exer-card .q-text { margin: 8px 0 16px; color: var(--text-primary); font-size: 15px; line-height: 1.5; }
.exer-card .q-text .blank { display: inline-block; min-width: 80px; height: 1.6em; border-bottom: 1.5px solid var(--accent); margin: 0 2px; vertical-align: bottom; }
.exer-card .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;}
.exer-card .row .input { flex: 1; min-width: 180px; height: 44px; }
.exer-card textarea.input { height: auto; min-height: 84px; padding: 12px 16px; line-height: 1.5; resize: vertical; }
.exer-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.exer-option {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
  transition: all var(--dur-fast) var(--ease-out);
  background: var(--surface);
  display: flex; gap: 10px; align-items: center;
}
.exer-option:hover { border-color: var(--accent); }
.exer-option.selected { border-color: var(--accent); background: var(--accent-soft); }
.exer-option .opt-key { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--text-secondary); flex-shrink: 0;}
.exer-option.selected .opt-key { background: var(--accent); border-color: var(--accent); color: white;}
.exer-card .feedback { margin-top: 12px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px;}
.feedback-ok { color: #047857; }
.feedback-bad { color: #B91C1C; }
.feedback-bad s { color: var(--text-muted); margin-right: 4px; font-weight: 500;}

/* Transcript */
.transcript {
  max-width: 680px; margin: 0 auto;
  font-size: 17px; line-height: 1.7;
  color: var(--text-primary);
}
.transcript p { margin: 0 0 18px; }
.transcript .vw {
  border-bottom: 1.5px dotted var(--accent);
  cursor: pointer;
  position: relative;
}
.transcript .vw:hover { background: var(--accent-soft); }
.tt-popover {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--text-primary); color: white;
  font-size: 13px; padding: 6px 10px;
  border-radius: var(--radius-md);
  white-space: nowrap; pointer-events: none;
  box-shadow: var(--shadow-md);
  z-index: 10;
}
.tt-popover::after {
  content: ""; position: absolute; left: 50%; top: 100%; margin-left: -5px;
  border: 5px solid transparent; border-top-color: var(--text-primary);
}

/* ─────────────────────────────────────────────
   Vocabulary page
   ───────────────────────────────────────────── */
.filter-bar {
  position: sticky; top: 0;
  background: rgba(255, 254, 251, 0.92);
  backdrop-filter: blur(12px);
  padding: 16px 0;
  z-index: 4;
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center;
}
.filter-bar .search { flex: 0 0 320px; }
.filter-bar .chip-group { display: flex; gap: 4px; padding: 4px; background: var(--bg-subtle); border-radius: var(--radius-full); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: transparent; border: 0;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease-out);
}
.chip:hover { color: var(--text-primary); }
.chip.active { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-xs); }
.chip.active.amber { background: var(--accent-soft); color: var(--accent-fg); }

.vocab-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px;}
.vocab-row {
  display: grid; grid-template-columns: 1fr auto; gap: 24px;
  align-items: center;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  transition: background var(--dur-fast) var(--ease-out);
  border: 1px solid transparent;
}
.vocab-row:hover { background: var(--surface-hover); border-color: var(--border); }
.vocab-row .col-text .phrase { font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 16px; color: var(--text-primary); }
.vocab-row .col-text .tr { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }
.vocab-row .col-text .ex { color: var(--text-muted); font-size: 13px; margin-top: 4px; font-style: italic; max-width: 540px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.vocab-row .col-meta { display: flex; align-items: center; gap: 14px; flex-wrap: nowrap; min-width: 0;}
.vocab-row .source { color: var(--text-secondary); font-size: 13px; text-decoration: none; transition: color var(--dur-fast) var(--ease-out); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px;}
.vocab-row .source:hover { color: var(--accent); text-decoration: underline; }
.vocab-row .trash { color: var(--text-muted); }
.vocab-row .trash:hover { color: var(--error); background: var(--error-soft); }

/* ─────────────────────────────────────────────
   History page (variant C)
   ───────────────────────────────────────────── */
.history-shell { display: grid; grid-template-columns: 360px 1fr; gap: 32px; align-items: start; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.hl-item {
  display: grid; grid-template-columns: 96px 1fr; gap: 14px;
  padding: 12px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--dur-fast) var(--ease-out);
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.hl-item:hover { background: var(--surface-hover); border-color: var(--border); }
.hl-item.active { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.hl-thumb { aspect-ratio: 16/9; border-radius: var(--radius-md); overflow: hidden; background: var(--bg-subtle); position: relative;}
.hl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block;}
.hl-info h3 { margin: 0; font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 14px; line-height: 1.35; color: var(--text-primary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;}
.hl-info .row { display: flex; align-items: center; gap: 8px; margin-top: 6px;}
.hl-info .row .meta { color: var(--text-muted); font-size: 12px;}
.history-preview { position: sticky; top: 32px; }
.preview-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-2xl); overflow: hidden; box-shadow: var(--shadow-md);}
.preview-card .player { aspect-ratio: 16/9; position: relative; background: #000;}
.preview-card .player img { width: 100%; height: 100%; object-fit: cover; display: block;}
.preview-card .player .play-big {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: var(--shadow-lg);
}
.preview-card .player .play-big::after {
  content: ""; width: 0; height: 0; border-left: 14px solid white;
  border-top: 9px solid transparent; border-bottom: 9px solid transparent; margin-left: 4px;
}
.preview-card .player .lvl { position: absolute; top: 16px; left: 16px; backdrop-filter: blur(8px); background: rgba(255,255,255,0.85);}
.preview-body { padding: 24px 28px 28px;}
.preview-body h2 { margin: 0; font-family: 'Fraunces'; font-weight: 600; font-size: 24px; line-height: 1.25; letter-spacing: -0.01em;}
.preview-body .meta-row { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 14px; margin-top: 8px;}
.preview-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 20px;}
.preview-section { margin-top: 24px;}
.preview-section .lbl { color: var(--accent); }
.phrase-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px;}
.phrase-list-item { display: flex; align-items: baseline; gap: 12px; padding: 8px 12px; border-radius: var(--radius-md); transition: background var(--dur-fast) var(--ease-out); cursor: pointer; }
.phrase-list-item:hover { background: var(--bg-subtle); }
.phrase-list-item .arr { color: var(--accent); font-size: 14px; flex-shrink: 0;}
.phrase-list-item .ph { font-weight: 600; color: var(--text-primary); font-size: 14px; flex: 0 0 auto;}
.phrase-list-item .tr { color: var(--text-secondary); font-size: 13px; margin-left: auto; text-align: right;}
.preview-actions { display: flex; gap: 8px; margin-top: 28px;}

/* ─────────────────────────────────────────────
   Settings page (variant C — dashboard)
   ───────────────────────────────────────────── */
.set-status-card {
  background: linear-gradient(180deg, #F0FDF4 0%, #FFFFFF 100%);
  border: 1px solid #86EFAC;
  border-radius: var(--radius-2xl);
  padding: 28px 32px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  box-shadow: var(--shadow-sm);
}
.set-status-card .left { display: flex; align-items: center; gap: 18px;}
.set-status-card .ring {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--success); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
  box-shadow: 0 8px 16px rgba(16, 185, 129, 0.25);
}
.set-status-card h3 { margin: 0; font-family: 'Manrope'; font-weight: 600; font-size: 18px; }
.set-status-card .sub { color: var(--text-secondary); font-size: 14px; margin-top: 4px;}
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px;}
.set-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  cursor: pointer;
}
.set-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.set-card .lbl { color: var(--text-secondary); }
.set-card h3 { margin: 6px 0 4px; font-family: 'Manrope'; font-weight: 600; font-size: 17px; }
.set-card .sub { color: var(--text-muted); font-size: 13px; }
.set-card .edit { margin-top: 14px; color: var(--accent); font-size: 13px; font-weight: 600; }
.set-card .actions { margin-top: 14px; display: flex; gap: 4px;}
.set-danger { background: #FEF2F2; border-color: #FECACA; grid-column: span 2;}
.set-danger:hover { border-color: var(--error); }
.set-danger h3 { color: #B91C1C; }

/* tooltip + small utilities */
.flex { display: flex; }
.row { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; } .gap-32 { gap: 32px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; } .mt-10 { margin-top: 40px; } .mt-12 { margin-top: 48px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.muted { color: var(--text-muted); }

/* responsive */
@media (max-width: 1100px) {
  .vocab-grid { grid-template-columns: 1fr 1fr; }
  .history-shell { grid-template-columns: 1fr; }
  .history-preview { position: static; }
}
@media (max-width: 720px) {
  .vocab-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .set-grid { grid-template-columns: 1fr; }
  .set-danger { grid-column: span 1; }
  .page-wrap { padding: 24px 16px 64px; }
  .filter-bar .search { flex: 1 1 100%; }
}

/* ─────────── Toast (added for MVP) ─────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 18px;
  background: var(--text-primary);
  color: #fff;
  border-radius: 10px;
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 9999;
  max-width: 92vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[data-kind="success"] { background: var(--success, #16a34a); }
.toast[data-kind="error"] { background: #dc2626; }

/* Empty state used by JS-rendered history list */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
  gap: 8px;
  color: var(--text-secondary);
}
.empty-state .empty-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bg-subtle);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.empty-state h3 { margin: 0; font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 18px; color: var(--text-primary); }

/* Status badge button (clickable to cycle) */
.badge-status {
  border: none;
  cursor: pointer;
  font: inherit;
}

/* Generation error muted utility */
.text-muted { color: var(--text-muted); }

/* Quick Review overlay */
.review-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 17, 21, 0.78);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.review-overlay[hidden] { display: none; }
.review-shell {
  width: 100%; max-width: 640px;
  background: var(--bg);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  max-height: 88vh;
}
.review-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.review-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.review-meta #review-left {
  color: var(--accent);
  font-weight: 700;
}
.review-body {
  padding: 32px 24px 28px;
  display: flex; flex-direction: column; gap: 20px;
}
.review-card {
  display: flex; flex-direction: column; gap: 24px;
  align-items: center;
}
.review-phrase {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 32px;
  line-height: 1.2;
  text-align: center;
  color: var(--text-primary);
  padding: 16px 0;
}
.review-options {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%;
}
.review-option {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  font-size: 15px; font-family: inherit;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.review-option:hover { border-color: var(--accent); background: var(--accent-soft); }
.review-option.correct { background: var(--success-soft); border-color: #10B981; color: #047857; }
.review-option.wrong { background: var(--error-soft); border-color: #EF4444; color: #B91C1C; }
.review-done { text-align: center; padding: 32px 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.review-done-icon { font-size: 48px; }
.review-done h2 { margin: 0; font-family: 'Fraunces', serif; font-size: 28px; }
.review-done p { margin: 0; color: var(--text-secondary); }

/* Lesson API cost display */
.lesson-cost, .lesson-cost-mini {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}
.lesson-cost-mini { font-size: 11px; }

/* Fill in the blanks — text input + Check + Hint */
.fill-row {
  display: flex; gap: 8px; margin-top: 12px;
  flex-wrap: wrap;
}
.fill-row .input {
  flex: 1 1 240px;
  height: 44px;
}
.fill-hint {
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  display: inline-block;
}
.exer-card.correct .fill-row .input { border-color: #10B981; background: var(--success-soft); }
.exer-card.wrong   .fill-row .input { border-color: #EF4444; background: var(--error-soft); }

/* Match exercise — two-column pairing */
.match-meta { margin-bottom: 12px; color: var(--text-secondary); }
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.match-col { display: flex; flex-direction: column; gap: 8px; }
.match-card {
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.match-card:hover:not(.matched):not(:disabled) { border-color: var(--accent); }
.match-card.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 600;
}
.match-card.matched {
  background: var(--success-soft);
  border-color: #10B981;
  color: #047857;
  cursor: default;
  opacity: 0.7;
}
.match-card.wrong {
  background: var(--error-soft);
  border-color: #EF4444;
  color: #B91C1C;
  animation: matchShake 280ms var(--ease-out);
}
@keyframes matchShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
@media (max-width: 720px) {
  .match-grid { grid-template-columns: 1fr; }
}

/* Exercise timestamp-link (shown on wrong answer / revealed sample) */
.exercise-timestamp-link {
  display: inline-block;
  margin-left: 8px;
  color: var(--accent-fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px dashed var(--accent);
}
.exercise-timestamp-link:hover { color: var(--accent); border-bottom-style: solid; }

/* Sync status line */
.sync-status {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 0;
}
.sync-status.muted { color: var(--text-muted); }
.sync-status.ok    { color: #047857; }
.sync-status.err   { color: #B91C1C; }

/* Watch tab — video + live transcript */
.watch-empty {
  text-align: center; padding: 48px 24px;
  border: 1px dashed var(--border); border-radius: var(--radius-xl);
  background: var(--surface);
}
.watch-empty h3 { margin: 0 0 8px; font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 18px; color: var(--text-primary); }
.watch-empty p { margin: 0; color: var(--text-secondary); font-size: 14px; max-width: 480px; margin: 0 auto; }

.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.watch-video {
  position: sticky; top: 12px;
}
.watch-video #watch-player,
.watch-video iframe {
  width: 100%; aspect-ratio: 16/9;
  border-radius: var(--radius-xl);
  background: #000; border: 0;
  overflow: hidden;
}
.watch-side {
  display: flex; flex-direction: column; gap: 12px;
  min-height: 0;
}
.watch-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}
.watch-toolbar-info {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 13px;
}
.watch-toolbar-info #watch-selected-count {
  font-weight: 600; color: var(--text-primary);
}
.watch-toolbar-info .watch-hint {
  color: var(--text-muted); font-size: 12px;
}
.watch-toolbar-actions { display: flex; gap: 8px; align-items: center; }

.watch-segments {
  max-height: 70vh;
  overflow-y: auto;
  padding: 8px 4px 24px;
  border-top: 1px solid var(--border);
  scroll-behavior: smooth;
}
.watch-segments .seg {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 15px; line-height: 1.55;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  margin: 2px 0;
}
.watch-segments .seg:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}
.watch-segments .seg.active {
  background: var(--accent-soft);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: inset 3px 0 0 var(--accent);
}
.watch-segments .seg .seg-en { display: block; }
.watch-segments .seg .seg-ru {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  line-height: 1.4;
  font-family: 'Manrope', sans-serif;
  font-weight: 400;
}
.watch-segments .seg.active .seg-ru { color: var(--text-secondary); }
.watch-segments.ru-hidden .seg-ru { display: none; }
.watch-segments .w {
  cursor: pointer;
  border-radius: 3px;
  padding: 0 1px;
  transition: background var(--dur-fast) var(--ease-out);
}
.watch-segments .w:hover {
  background: rgba(251, 146, 60, 0.18);
}
.watch-segments .w.selected {
  background: #FDE68A;
  color: #78350F;
  font-weight: 600;
  box-shadow: 0 0 0 1px #F59E0B inset;
}
.watch-segments .seg.active .w.selected {
  background: #FBBF24;
  color: #78350F;
}
/* Phrase selection (Cmd/Ctrl-click) — distinct color from single-word yellow. */
.watch-segments .w.phrase {
  background: #C7D2FE;          /* indigo-200 */
  color: #1E1B4B;               /* indigo-950 */
  font-weight: 600;
  box-shadow: 0 0 0 1px #6366F1 inset;
}
.watch-segments .seg.active .w.phrase {
  background: #A5B4FC;
  color: #1E1B4B;
}
/* Pending phrase anchor — first Cmd-click, waiting for the closing click. */
.watch-segments .w.phrase-anchor {
  outline: 2px dashed #6366F1;
  outline-offset: 1px;
  border-radius: 4px;
}

@media (max-width: 980px) {
  .watch-layout { grid-template-columns: minmax(0, 1fr); }
  .watch-video { position: static; }
  .watch-segments { max-height: 60vh; }
}

/* All Words tab */
.aw-section { margin-bottom: 32px; }
.aw-section:last-child { margin-bottom: 0; }
.aw-section-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.aw-section-title {
  margin: 0; font-family: 'Fraunces', serif; font-weight: 600;
  font-size: 22px; line-height: 1.2; color: var(--text-primary);
}
.aw-section-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 3px 8px; border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}
.aw-section-count {
  margin-left: auto;
  font-size: 13px; color: var(--text-muted); font-weight: 500;
}
.aw-section[data-level="C"] .aw-section-tag { background: #fef2f2; color: #b91c1c; }
.aw-section[data-level="B"] .aw-section-tag { background: var(--accent-soft); color: var(--accent-fg); }
.aw-section[data-level="A"] .aw-section-tag { background: #ecfdf5; color: #047857; }
.aw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.aw-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 36px 12px 14px;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.aw-card:hover {
  border-color: var(--accent-soft-hover);
  box-shadow: var(--shadow-xs);
}
.aw-card .bookmark {
  position: absolute; top: 8px; right: 8px;
  background: transparent; border: 0; padding: 4px;
  cursor: pointer; color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.aw-card .bookmark:hover { background: var(--accent-soft); color: var(--accent); }
.aw-card .bookmark.on { color: var(--accent); }
.aw-card .bookmark.on svg { fill: currentColor; }
.aw-word {
  font-family: 'Manrope', sans-serif;
  font-weight: 600; font-size: 15px;
  color: var(--text-primary);
  line-height: 1.3;
}
.aw-tr {
  margin-top: 2px;
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.4;
}
