/* =========================================
   My Flashcard v2 — Scholar's Desk
   Design tokens from DESIGN.md
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter+Variable:opsz,wght@12..18,400;12..18,500;12..18,600;12..18,700&family=JetBrains+Mono+Variable:opsz,wght@12..24,400;12..24,500;12..24,600&display=swap');

/* ----- Design Tokens ----- */
:root {
  /* Brand - Emerald (Luyện Nói inspired) */
  --brand-50:  #ecfdf5;
  --brand-100: #d1fae5;
  --brand-200: #a7f3d0;
  --brand-300: #6ee7b7;
  --brand-400: #34d399;
  --brand-500: #10b981;
  --brand-600: #059669;
  --brand-700: #047857;
  --brand-800: #065f46;
  --brand-900: #064e3b;

  /* Teal accent */
  --teal-50:   #f0fdfa;
  --teal-100:  #ccfbf1;
  --teal-200:  #99f6e4;
  --teal-300:  #5eead4;
  --teal-400:  #2dd4bf;
  --teal-500:  #14b8a6;
  --teal-600:  #0d9488;
  --teal-700:  #0f766e;

  /* Semantic */
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;
  --error-500:   #ef4444;
  --error-600:   #dc2626;
  --error-700:   #b91c1c;

  /* Light Theme (default) */
  --bg-primary:   #ffffff;
  --bg-secondary: #f0fdf4;
  --bg-tertiary:  #dcfce7;
  --bg-hover:     #bbf7d0;
  --bg-active:    #86efac;

  --fg-primary:   #052e16;
  --fg-secondary: #14532d;
  --fg-tertiary:  #166534;
  --fg-muted:     #4d7c0f;
  --fg-inverse:   #ffffff;

  --border-light:  #bbf7d0;
  --border-medium: #86efac;
  --border-strong: #4ade80;

  --shadow-1: 0 1px 2px rgba(5, 46, 22, 0.04);
  --shadow-2: 0 4px 8px rgba(5, 46, 22, 0.06), 0 1px 3px rgba(5, 46, 22, 0.04);
  --shadow-3: 0 12px 24px rgba(5, 46, 22, 0.08), 0 4px 8px rgba(5, 46, 22, 0.06);
  --shadow-4: 0 24px 48px rgba(5, 46, 22, 0.1), 0 8px 16px rgba(5, 46, 22, 0.08);

  /* Card lips — subtle, layered edge (Luyện Nói) */
  --shadow-lip: 0 1px 0 rgba(5, 46, 22, 0.02), 0 2px 4px rgba(5, 46, 22, 0.03);
  --shadow-lip-sm: 0 1px 0 rgba(5, 46, 22, 0.015), 0 1px 2px rgba(5, 46, 22, 0.025);
  --shadow-lip-lg: 0 2px 0 rgba(5, 46, 22, 0.02), 0 4px 8px rgba(5, 46, 22, 0.04);

  --card-gradient: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  --card-border: #bbf7d0;

  /* Typography */
  --font-sans: 'Inter Variable', 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono Variable', 'JetBrains Mono', monospace;

  --text-xs:    0.7rem;
  --text-sm:    0.8125rem;
  --text-base:  0.9375rem;
  --text-lg:    1.0625rem;
  --text-xl:    1.25rem;
  --text-2xl:   1.5rem;
  --text-3xl:   1.875rem;
  --text-4xl:   2.25rem;
  --text-5xl:   3rem;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* Spacing & Layout */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --sidebar-width: 280px;
  --sidebar-collapsed: 72px;
  --header-height: 60px;
  --content-max: 960px;

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

  --elev-1: var(--shadow-1);
  --elev-2: var(--shadow-2);
  --elev-3: var(--shadow-3);
  --elev-4: var(--shadow-4);

  /* Motion */
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 350ms;
  --duration-flip: 500ms;

  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-flip: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Low Power Mode (Luyện Nói inspired) */
[data-low-power] {
  --duration-fast: 1ms;
  --duration-base: 1ms;
  --duration-slow: 1ms;
  --duration-flip: 1ms;
}

[data-low-power-held] {
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-3: 0 4px 8px rgba(0, 0, 0, 0.25);
  --shadow-4: 0 8px 16px rgba(0, 0, 0, 0.3);
}

/* Dark Theme — Charcoal (Luyện Nói style) */
[data-theme="dark"] {
  --bg-primary:   #0f172a;
  --bg-secondary: #111827;
  --bg-tertiary:  #1f2937;
  --bg-hover:     #374151;
  --bg-active:    #4b5563;

  --fg-primary:   #f0fdf4;
  --fg-secondary: #dcfce7;
  --fg-tertiary:  #86efac;
  --fg-muted:     #4ade80;
  --fg-inverse:   #052e16;

  --border-light:  #1f2937;
  --border-medium: #374151;
  --border-strong: #4b5563;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 4px 8px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-3: 0 12px 24px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-4: 0 24px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.5);

  --shadow-lip: 0 1px 0 rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-lip-sm: 0 1px 0 rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-lip-lg: 0 2px 0 rgba(0, 0, 0, 0.35), 0 4px 8px rgba(0, 0, 0, 0.45);

  --card-gradient: linear-gradient(135deg, #111827 0%, #0f172a 100%);
  --card-border: #1f2937;
}

/* Button contrast fixes - ensure white text on colored backgrounds (WCAG AA) */
.btn--success {
  background: var(--success-700);
  color: var(--fg-inverse);
}
.btn--success:hover:not(:disabled) { background: var(--success-600); }

.btn--warning {
  background: var(--warning-700);
  color: var(--fg-inverse);
}
.btn--warning:hover:not(:disabled) { background: var(--warning-600); }

.btn--danger {
  background: var(--error-700);
  color: var(--fg-inverse);
}
.btn--danger:hover:not(:disabled) { background: var(--error-600); }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 1ms;
    --duration-base: 1ms;
    --duration-slow: 1ms;
    --duration-flip: 1ms;
  }
}

/* ----- Reset & Base ----- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--fg-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
}

/* Focus Styles */
:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--brand-500), 0 0 0 4px var(--bg-primary);
}
[data-theme="dark"] :focus-visible {
  box-shadow: 0 0 0 2px var(--brand-400), 0 0 0 4px var(--bg-primary);
}

/* ----- App Shell ----- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  min-height: 100vh;
  background: var(--bg-primary);
  transition: grid-template-columns var(--duration-base) var(--ease-out);
}

/* Collapsed Sidebar */
.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}
.app-shell.sidebar-collapsed .sidebar__title,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .nav-shortcut,
.app-shell.sidebar-collapsed .sidebar__stats {
  display: none;
}
.app-shell.sidebar-collapsed .sidebar__brand {
  justify-content: center;
  padding: var(--space-3) 0;
}
.app-shell.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: var(--space-3);
}

/* ----- Sidebar ----- */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 40;
  overflow-y: auto;
  transition: width var(--duration-base) var(--ease-out);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border-light);
}

.sidebar__logo {
  width: 28px;
  height: 28px;
  color: var(--brand-700);
  flex-shrink: 0;
}

.sidebar__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--fg-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__nav {
  flex: 1;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--fg-tertiary);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--fg-primary);
}

.nav-item.active {
  background: var(--brand-50);
  color: var(--brand-700);
  border-left: none;
}
[data-theme="dark"] .nav-item.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--brand-300);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 2;
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-shortcut {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-muted);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.sidebar__footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: stretch;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  color: var(--fg-tertiary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  margin: 0 auto;
}
.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--fg-primary);
  border-color: var(--brand-400);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.theme-toggle svg { width: 20px; height: 20px; }

.sidebar__stats {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  font-size: var(--text-xs);
  color: var(--fg-muted);
}
.stat-item { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.stat-value { font-weight: var(--weight-semibold); color: var(--fg-secondary); font-size: var(--text-sm); }

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 30;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}
.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* ----- Main Content ----- */
.main-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

/* ----- Header ----- */
.header {
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
  background: rgba(var(--bg-primary-rgb, 255, 255, 255), 0.9);
}
[data-theme="dark"] .header {
  background: rgba(15, 23, 42, 0.9);
}

.header__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--fg-tertiary);
  cursor: pointer;
}
.menu-toggle:hover { background: var(--bg-tertiary); color: var(--fg-primary); }
.menu-toggle svg { width: 22px; height: 22px; }

.header__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--fg-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.header__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: var(--space-3);
  width: 18px;
  height: 18px;
  color: var(--fg-muted);
  pointer-events: none;
}
.search-input {
  width: 280px;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-10);
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--fg-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-out);
}
.search-input::placeholder {
  color: var(--fg-tertiary);
  opacity: 1;
}
.search-input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
  background: var(--bg-primary);
  width: 360px;
}
[data-theme="dark"] .search-input:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
.search-shortcut {
  display: none;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-muted);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  margin-left: var(--space-2);
}

/* ----- Views ----- */
.view {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}
.view.hidden { display: none !important; }

/* =========================================
   VIEW: DOCUMENTS (Editor)
   ========================================= */
.document-editor {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: var(--space-6);
  height: calc(100vh - var(--header-height) - var(--space-6) * 2);
  max-height: calc(100vh - var(--header-height) - var(--space-6) * 2);
}

.editor-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary);
  flex-wrap: wrap;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--fg-tertiary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.toolbar-btn:hover {
  background: var(--bg-tertiary);
  color: var(--fg-primary);
}
.toolbar-btn:active { transform: scale(0.95); }
.toolbar-btn svg { width: 18px; height: 18px; }
.toolbar-btn[data-insert] {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  width: auto;
  padding: 0 var(--space-3);
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-light);
  margin: 0 var(--space-2);
}

.editor-textarea {
  flex: 1;
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--fg-primary);
  background: var(--bg-primary);
  border: none;
  outline: none;
  resize: none;
  tab-size: 2;
}
.editor-textarea::placeholder { color: var(--fg-muted); }

.editor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border-light);
  background: var(--bg-primary);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}
.saved-indicator { color: var(--success-700); }
.saved-indicator.dirty { color: var(--warning-700); }

/* Preview Panel */
.preview-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary);
}

.preview-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--fg-primary);
  margin: 0;
}

.preview-actions {
  display: flex;
  gap: var(--space-2);
}

.preview-cards {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Preview Card — Luyện Nói card lip */
.preview-card {
  background: var(--card-gradient);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  box-shadow: var(--shadow-lip);
  transition: all var(--duration-fast) var(--ease-out);
}
.preview-card:hover {
  box-shadow: var(--shadow-lip-sm);
  border-color: var(--brand-300);
}
[data-theme="dark"] .preview-card:hover {
  border-color: var(--brand-700);
}

.preview-card__front {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--fg-primary);
  margin: 0 0 var(--space-2);
}

.preview-card__separator {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-3) 0;
}

.preview-card__back {
  font-size: var(--text-base);
  color: var(--fg-secondary);
  line-height: var(--leading-relaxed);
  margin: 0;
}

/* =========================================
   VIEW: FLASHCARDS (Review)
   ========================================= */
.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.review-progress {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--fg-secondary);
}
.review-progress #review-current { color: var(--brand-700); font-weight: var(--weight-bold); }

.review-filters {
  display: flex;
  gap: var(--space-1);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-1);
}

.filter-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--fg-tertiary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.filter-btn:hover { color: var(--fg-primary); background: var(--bg-tertiary); }
.filter-btn.active,
.filter-btn[aria-pressed="true"] {
  background: var(--bg-primary);
  color: var(--brand-700);
  box-shadow: var(--elev-1);
}
[data-theme="dark"] .filter-btn.active {
  background: var(--bg-secondary);
  color: var(--brand-400);
}

/* Review Card Container */
.review-card-container {
  perspective: 1000px;
  max-width: 700px;
  margin: 0 auto var(--space-8);
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.review-flashcard {
  position: relative;
  width: 100%;
  max-width: 600px;
  height: 380px;
  transform-style: preserve-3d;
  transition: transform var(--duration-flip) var(--ease-flip);
  cursor: pointer;
  transform-origin: center center;
}

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

.review-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  border-radius: var(--radius-2xl);
  background: var(--card-gradient);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-lip-lg);
  text-align: center;
  transition: all var(--duration-base) var(--ease-out);
}

.review-flashcard:hover .review-card-face {
  box-shadow: var(--shadow-3), var(--shadow-lip-lg);
}

.review-card-back {
  transform: rotateY(180deg);
}

.review-card-content { width: 100%; max-width: 480px; }

.review-card-word {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  color: var(--fg-primary);
  line-height: var(--leading-tight);
  margin: 0 0 var(--space-3);
  word-break: break-word;
}

.review-card-meaning {
  font-size: var(--text-2xl);
  font-weight: var(--weight-medium);
  color: var(--fg-secondary);
  line-height: var(--leading-snug);
  margin: 0 0 var(--space-4);
  word-break: break-word;
}

.review-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.review-card-tag {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--brand-700);
  background: var(--brand-100);
  padding: var(--space-1) var(--space-2.5);
  border-radius: var(--radius-full);
}
[data-theme="dark"] .review-card-tag {
  color: var(--brand-300);
  background: rgba(16, 185, 129, 0.2);
}

.review-card-hint {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin: 0;
}

.review-card-ease {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
}
.review-card-ease span { display: flex; align-items: center; gap: var(--space-1); }
.review-card-ease kbd {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

/* Review Actions */
.review-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
  max-width: 700px;
  margin: 0 auto var(--space-4);
}

.btn--lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  min-width: 110px;
}

.btn-label { display: block; font-weight: var(--weight-semibold); }
.btn-interval { display: block; font-size: var(--text-xs); color: var(--fg-inverse); }
.btn-key {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  margin-top: var(--space-1);
  display: inline-block;
}

.btn--success {
  background: var(--success-700);
  color: var(--fg-inverse);
}
.btn--success:hover:not(:disabled) { background: var(--success-600); }

.btn--warning {
  background: var(--warning-700);
  color: var(--fg-inverse);
}
.btn--warning:hover:not(:disabled) { background: var(--warning-600); }

.btn--danger {
  background: var(--error-700);
  color: var(--fg-inverse);
}
.btn--danger:hover:not(:disabled) { background: var(--error-600); }

.review-shortcuts {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--fg-muted);
}
.review-shortcuts kbd {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  margin: 0 var(--space-1);
}

/* =========================================
   VIEW: STATS
   ========================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: all var(--duration-fast) var(--ease-out);
}
.stat-card:hover {
  border-color: var(--brand-300);
  box-shadow: var(--elev-2);
}
[data-theme="dark"] .stat-card:hover { border-color: var(--brand-700); }

.stat-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--brand-100);
  color: var(--brand-700);
  flex-shrink: 0;
}
.stat-card:nth-child(2) .stat-icon { background: var(--teal-100); color: var(--teal-600); }
.stat-card:nth-child(3) .stat-icon { background: #fef3c7; color: var(--warning-600); }
.stat-card:nth-child(4) .stat-icon { background: #e0e7ff; color: #4f46e5; }
[data-theme="dark"] .stat-icon {
  background: rgba(16, 185, 129, 0.15);
  color: var(--brand-400);
}
[data-theme="dark"] .stat-card:nth-child(2) .stat-icon { background: rgba(20, 184, 166, 0.15); color: var(--teal-400); }
[data-theme="dark"] .stat-card:nth-child(3) .stat-icon { background: rgba(245, 158, 11, 0.15); color: var(--warning-400); }
[data-theme="dark"] .stat-card:nth-child(4) .stat-icon { background: rgba(79, 70, 229, 0.15); color: #818cf8; }
.stat-icon svg { width: 24px; height: 24px; }

.stat-info { display: flex; flex-direction: column; }
.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--fg-primary);
  line-height: var(--leading-tight);
  margin: 0;
}
.stat-label {
  font-size: var(--text-sm);
  color: var(--fg-tertiary);
  margin: 0;
}

/* Charts Row */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.chart-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--fg-primary);
  margin: 0 0 var(--space-4);
}

/* Weekly Chart */
.weekly-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 180px;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}

.weekly-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  max-width: 50px;
}

.weekly-bar__value {
  height: 0;
  width: 100%;
  background: var(--brand-500);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height var(--duration-slow) var(--ease-spring);
  min-height: 4px;
}

.weekly-bar__label {
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
  font-weight: var(--weight-medium);
}

.weekly-bar__count {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-family: var(--font-mono);
}

/* Heatmap */
.heatmap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: 0;
  line-height: 0;
}

.heatmap-month {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.heatmap-month__label {
  width: 40px;
  font-size: var(--text-xs);
  color: var(--fg-muted);
  text-align: right;
  padding-top: 2px;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.heatmap-week {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.heatmap-day {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  transition: all var(--duration-fast) var(--ease-out);
}
.heatmap-day[data-level="1"] { background: var(--brand-100); border-color: var(--brand-200); }
.heatmap-day[data-level="2"] { background: var(--brand-300); border-color: var(--brand-300); }
.heatmap-day[data-level="3"] { background: var(--brand-500); border-color: var(--brand-500); }
.heatmap-day[data-level="4"] { background: var(--brand-700); border-color: var(--brand-700); }
[data-theme="dark"] .heatmap-day { background: var(--bg-primary); }
[data-theme="dark"] .heatmap-day[data-level="1"] { background: rgba(16, 185, 129, 0.15); }
[data-theme="dark"] .heatmap-day[data-level="2"] { background: rgba(16, 185, 129, 0.3); }
[data-theme="dark"] .heatmap-day[data-level="3"] { background: rgba(16, 185, 129, 0.5); }
[data-theme="dark"] .heatmap-day[data-level="4"] { background: var(--brand-500); }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
}
.heatmap-legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.heatmap-legend__color {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

/* =========================================
   VIEW: VOCABULARY LIST
   ========================================= */
.vocab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.vocab-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--fg-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.vocab-search {
  position: relative;
  min-width: 280px;
  flex: 1;
  max-width: 400px;
}

.vocab-search .search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--fg-muted);
  pointer-events: none;
}

.vocab-search .input {
  padding-left: var(--space-10);
  width: 100%;
}

.vocab-table-wrapper {
  overflow-x: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.vocab-table thead {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-medium);
}

.vocab-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--weight-semibold);
  color: var(--fg-secondary);
  white-space: nowrap;
  user-select: none;
}

.vocab-table th:first-child { border-top-left-radius: var(--radius-lg); }
.vocab-table th:last-child { border-top-right-radius: var(--radius-lg); }

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.sort-btn:hover { color: var(--fg-primary); }
.sort-btn .sort-icon { width: 14px; height: 14px; opacity: 0.4; transition: opacity var(--duration-fast); }
.sort-btn:hover .sort-icon,
.sort-btn.sorted .sort-icon { opacity: 1; }
.sort-btn.sorted { color: var(--brand-700); }
[data-theme="dark"] .sort-btn.sorted { color: var(--brand-300); }

.vocab-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--duration-fast);
}

.vocab-table tbody tr:last-child { border-bottom: none; }
.vocab-table tbody tr:hover { background: var(--bg-hover); }
.vocab-table tbody tr.editing { background: var(--brand-50); }
[data-theme="dark"] .vocab-table tbody tr.editing { background: rgba(16, 185, 129, 0.1); }

.vocab-cell {
  padding: var(--space-3) var(--space-4);
  vertical-align: middle;
}

.vocab-word__text,
.vocab-meaning__text {
  display: block;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vocab-edit-input {
  width: 100%;
  max-width: 280px;
  padding: var(--space-1) var(--space-2);
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--fg-primary);
  background: var(--bg-primary);
  border: 1px solid var(--brand-400);
  border-radius: var(--radius-sm);
  outline: none;
}
.vocab-edit-input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
[data-theme="dark"] .vocab-edit-input:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.vocab-tags { min-width: 100px; }
.tag {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  background: var(--brand-100);
  color: var(--brand-700);
  margin-right: var(--space-1);
  margin-bottom: var(--space-1);
}
.tag--empty { color: var(--fg-muted); background: transparent; }
[data-theme="dark"] .tag { background: rgba(16, 185, 129, 0.2); color: var(--brand-300); }

.vocab-interval,
.vocab-due,
.vocab-repetitions,
.vocab-ease {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--fg-secondary);
  white-space: nowrap;
}

.vocab-actions {
  display: flex;
  gap: var(--space-1);
  white-space: nowrap;
}

.vocab-actions .btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vocab-actions .btn svg { width: 16px; height: 16px; }

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--fg-tertiary);
}
.empty-state__icon {
  width: 64px;
  height: 64px;
  color: var(--fg-muted);
  margin-bottom: var(--space-4);
}
.empty-state__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--fg-primary);
  margin: 0 0 var(--space-2);
}
.empty-state__desc {
  font-size: var(--text-base);
  max-width: 400px;
  margin: 0;
  line-height: var(--leading-relaxed);
}
.empty-state__desc kbd {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--fg-secondary);
}

/* =========================================
   VIEW: SETTINGS
   ========================================= */
.settings-container {
  max-width: 720px;
  margin: 0 auto;
}

.settings-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
}

.settings-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--fg-primary);
  margin: 0 0 var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-light);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-light);
}
.setting-row:last-child { border-bottom: none; }

.setting-info { flex: 1; min-width: 0; }
.setting-info h3 {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--fg-primary);
  margin: 0 0 var(--space-1);
}
.setting-info p {
  font-size: var(--text-sm);
  color: var(--fg-tertiary);
  margin: 0;
}

/* Theme Options */
.theme-options {
  display: flex;
  gap: var(--space-3);
}
.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  transition: all var(--duration-fast) var(--ease-out);
}
.theme-option:hover { border-color: var(--border-medium); }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option:has(input:checked) {
  border-color: var(--brand-500);
  background: var(--brand-50);
}
[data-theme="dark"] .theme-option:has(input:checked) {
  background: rgba(16, 185, 129, 0.1);
}
.theme-option__preview {
  width: 60px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}
.theme-option__preview.light { background: #ffffff; }
.theme-option__preview.dark { background: #0f172a; }
.theme-option__preview.system {
  background: linear-gradient(135deg, #ffffff 50%, #0f172a 50%);
}
.theme-option__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--fg-secondary);
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__thumb {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  transition: all var(--duration-fast) var(--ease-out);
}
.toggle__thumb::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--fg-tertiary);
  border-radius: var(--radius-full);
  box-shadow: var(--elev-1);
  transition: transform var(--duration-fast) var(--ease-spring);
}
.toggle input:checked + .toggle__thumb {
  background: var(--brand-500);
  border-color: var(--brand-500);
}
.toggle input:checked + .toggle__thumb::before {
  transform: translateX(20px);
  background: var(--fg-inverse);
}

/* Inputs */
.input {
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--fg-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  width: 100%;
}
.input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
[data-theme="dark"] .input:focus { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }

.input--sm { width: auto; min-width: 80px; }
.input--range { width: 200px; accent-color: var(--brand-500); }
.range-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--fg-tertiary);
  min-width: 50px;
  text-align: right;
}

.setting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

/* Shortcuts List */
.shortcuts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.shortcut-item kbd {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--fg-secondary);
  min-width: 70px;
  text-align: center;
}
.shortcut-item span { color: var(--fg-primary); }

/* =========================================
   BUTTONS (Base)
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--brand-500), 0 0 0 4px var(--bg-primary);
}
[data-theme="dark"] .btn:focus-visible {
  box-shadow: 0 0 0 2px var(--brand-400), 0 0 0 4px var(--bg-primary);
}

.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Primary */
.btn--primary {
  background: var(--brand-700);
  color: var(--fg-inverse);
}
.btn--primary:hover:not(:disabled) { background: var(--brand-800); }

/* Secondary */
.btn--secondary {
  background: var(--bg-tertiary);
  color: var(--fg-secondary);
  border: 1px solid var(--border-medium);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--brand-400);
  color: var(--fg-primary);
}

/* Ghost */
.btn--ghost {
  background: transparent;
  color: var(--fg-tertiary);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--fg-primary);
}

/* Danger */
.btn--danger {
  background: transparent;
  color: var(--error-600);
  border: 1px solid var(--error-500);
}
.btn--danger:hover:not(:disabled) {
  background: var(--error-500);
  color: var(--fg-inverse);
}

/* =========================================
   TOAST CONTAINER
   ========================================= */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--fg-primary);
  pointer-events: auto;
  animation: toastIn var(--duration-base) var(--ease-out);
  max-width: 360px;
}

.toast.success { border-left: 4px solid var(--success-500); }
.toast.error { border-left: 4px solid var(--error-500); }
.toast.warning { border-left: 4px solid var(--warning-500); }
.toast.info { border-left: 4px solid var(--brand-500); }

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.toast.success .toast-icon { color: var(--success-500); }
.toast.error .toast-icon { color: var(--error-500); }
.toast.warning .toast-icon { color: var(--warning-500); }
.toast.info .toast-icon { color: var(--brand-600); }

.toast-message { flex: 1; }

.toast-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.toast-close:hover { background: var(--bg-tertiary); color: var(--fg-primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* =========================================
   DICTIONARY MODAL
   ========================================= */
.dict-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.dict-modal.hidden { display: none !important; }

.dict-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn var(--duration-base) var(--ease-out);
}

.dict-modal__content {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--elev-4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp var(--duration-base) var(--ease-out);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.dict-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}
.dict-modal__header h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--fg-primary);
  margin: 0;
}
.dict-modal__close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--fg-tertiary);
  font-size: var(--text-2xl);
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-md);
}
.dict-modal__close:hover { background: var(--bg-tertiary); color: var(--fg-primary); }

.dict-modal__body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dict-search {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-light);
}
.dict-search .input { width: 100%; }
.dict-search-loading {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--fg-muted);
  text-align: center;
}

.dict-results {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
}

.dict-result {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.dict-result:last-child { border-bottom: none; }
.dict-result:hover { background: var(--bg-tertiary); }

.dict-result__header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}
.dict-result__word {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--fg-primary);
}
.dict-result__pos {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--brand-700);
  background: var(--brand-100);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  text-transform: capitalize;
}
[data-theme="dark"] .dict-result__pos {
  color: var(--brand-300);
  background: rgba(16, 185, 129, 0.2);
}
.dict-result__source {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--warning-600);
  background: var(--warning-500);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--fg-inverse);
}

.dict-result__meaning {
  font-size: var(--text-base);
  color: var(--fg-secondary);
  line-height: var(--leading-relaxed);
  margin: 0 0 var(--space-2);
}

.dict-result__meaning--vi {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--fg-primary);
  margin-bottom: var(--space-1);
}

.dict-result__meaning--en {
  font-size: var(--text-base);
  color: var(--fg-secondary);
  margin-bottom: var(--space-2);
}

.dict-result__examples {
  font-size: var(--text-sm);
  color: var(--fg-tertiary);
  font-style: italic;
}

/* =========================================
   EMPTY STATE
   ========================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-4);
  text-align: center;
  color: var(--fg-muted);
  flex: 1;
}
.empty-state__icon {
  width: 64px;
  height: 64px;
  color: var(--fg-muted);
  opacity: 0.5;
  margin-bottom: var(--space-4);
}
.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--fg-tertiary);
  margin: 0 0 var(--space-2);
}
.empty-state__desc {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin: 0;
  max-width: 320px;
}
.empty-state__desc kbd {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--fg-secondary);
}

/* =========================================
   AUTOCOMPLETE (Inline in Editor)
   ========================================= */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--elev-3);
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}
.autocomplete-dropdown.visible { display: block; }

.autocomplete-item {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--duration-fast);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.highlighted { background: var(--bg-tertiary); }

.autocomplete-item__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
  flex-wrap: wrap;
}
.autocomplete-item__word {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--fg-primary);
}
.autocomplete-item__pos {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--brand-700);
  background: var(--brand-100);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  text-transform: capitalize;
}
[data-theme="dark"] .autocomplete-item__pos {
  color: var(--brand-300);
  background: rgba(16, 185, 129, 0.2);
}
.autocomplete-item__source {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--warning-600);
  background: var(--warning-500);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--fg-inverse);
}

.autocomplete-item__meaning {
  font-size: var(--text-sm);
  color: var(--fg-secondary);
  line-height: var(--leading-normal);
}

.autocomplete-item__example {
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
  font-style: italic;
  margin-top: var(--space-1);
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
  .document-editor { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .preview-panel { max-height: 300px; }
  .charts-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: var(--header-height) 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    width: var(--sidebar-width);
    box-shadow: var(--elev-4);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.visible { display: block; }
  .menu-toggle { display: flex; }
  .search-input { width: 180px; }
  .search-input:focus { width: 220px; }
  .review-actions { flex-direction: column; align-items: stretch; }
  .btn--lg { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  :root { --header-height: 52px; }
  .view { padding: var(--space-4); }
  .header__title { font-size: var(--text-lg); }
  .search-box { display: none; }
  .header__right .btn--primary span { display: none; }
  .editor-toolbar { gap: var(--space-1); }
  .toolbar-btn { width: 32px; height: 32px; }
  .review-card-container { min-height: 300px; }
  .review-flashcard { height: 300px; }
  .review-card-word { font-size: var(--text-3xl); }
  .review-card-meaning { font-size: var(--text-xl); }
}