@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

:root {
  --teal: #1d6fb8;
  --teal-light: #38bdf8;
  --teal-dark: #0f4c87;
  --teal-glow: rgba(56, 189, 248, 0.2);
  --orange: #06b6d4;
  --orange-light: #22d3ee;
  --orange-glow: rgba(6, 182, 212, 0.12);
  --bg: #0a1628;
  --bg2: #0f1e35;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-teal: rgba(56, 189, 248, 0.3);
  --border-orange: rgba(6, 182, 212, 0.25);
  --border-indigo: var(--border-teal);
  --border-gold: var(--border-orange);
  --text: #dde8f8;
  --text-muted: #7a9ab8;
  --text-dim: #3a5570;
  --success: #4caf7d;
  --error: #e05a5a;
  --warning: #f0b340;
  --info: #38bdf8;
  --toast-bg: rgba(7, 12, 26, 0.95);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --radius-sm: 6px;
  --radius: 12px;
  --transition: all 0.2s ease;
}

[data-theme="light"] {
  --bg: #f0f6fc;
  --bg2: #e4eef8;
  --surface: rgba(0, 0, 0, 0.03);
  --surface-2: rgba(0, 0, 0, 0.06);
  --surface-hover: rgba(0, 0, 0, 0.06);
  --border: rgba(0, 0, 0, 0.09);
  --border-teal: rgba(29, 111, 184, 0.25);
  --border-orange: rgba(6, 182, 212, 0.2);
  --text: #0f2035;
  --text-muted: #3a6080;
  --text-dim: #7aaac8;
  --toast-bg: rgba(240, 246, 252, 0.97);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.07);
}

/* ── Impersonation Banner ── */
.impersonation-banner {
  background: rgba(139, 92, 246, 0.12);
  border-bottom: 1px solid rgba(139, 92, 246, 0.28);
  padding: 9px 24px;
  display: flex; justify-content: center; align-items: center;
}
.impersonation-banner-inner {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: #a78bfa;
  max-width: 860px; width: 100%;
}
.impersonation-banner-inner [data-lucide] { width: 14px; height: 14px; flex-shrink: 0; }
.impersonation-banner-inner strong { color: #c4b5fd; }
.impersonation-exit-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.18); border: 1px solid rgba(139, 92, 246, 0.35);
  color: #a78bfa; font-size: 12px; font-weight: 600; font-family: 'Inter', inherit;
  cursor: pointer; transition: var(--transition);
}
.impersonation-exit-btn:hover { background: rgba(139, 92, 246, 0.3); }
.impersonation-exit-btn [data-lucide] { width: 12px; height: 12px; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}

.d-none { display: none !important; }
[data-lucide] { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; }

/* ── Background ── */
.bg-decoration {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.bg-circle { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.12; }
.bg-circle-1 { width: 600px; height: 600px; background: var(--teal); top: -200px; right: -100px; opacity: 0.12; }
.bg-circle-2 { width: 450px; height: 450px; background: var(--orange); bottom: -120px; left: -100px; opacity: 0.08; }
.bg-circle-3 { width: 300px; height: 300px; background: var(--teal-light); top: 55%; left: 42%; opacity: 0.06; }

/* ── Layout ── */
.app-container {
  position: relative; z-index: 1;
  max-width: 860px; margin: 0 auto; padding: 0 24px;
}

/* ── Header ── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 56px;
  position: relative;
}
.header::after {
  content: ''; position: absolute; bottom: -1px; left: 0;
  width: 80px; height: 1px;
  background: linear-gradient(90deg, var(--teal-light), transparent);
}
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px var(--teal-glow); color: white;
}
.logo-icon [data-lucide] { width: 18px; height: 18px; }
.logo-text { display: flex; flex-direction: column; gap: 1px; }
.logo-wordmark { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.logo-wordmark span { color: var(--orange-light); }
.logo-tagline { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.theme-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.theme-btn:hover { border-color: var(--teal); color: var(--teal-light); background: var(--surface-2); }

/* ── Topbar user ── */
.topbar-user {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: 12px; font-weight: 500;
}
.topbar-user [data-lucide] { width: 14px; height: 14px; }
.role-tag {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--orange-light);
  background: var(--orange-glow); border: 1px solid var(--border-orange);
  border-radius: 8px; padding: 1px 5px;
}

/* Word list badge */
.wl-badge {
  min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--teal); color: white;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; margin-left: 2px;
}

/* ── Word List Drawer ── */
.wl-overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(7, 8, 26, 0.6); backdrop-filter: blur(4px);
  display: flex; justify-content: flex-end;
}
.wl-drawer {
  width: 100%; max-width: 420px; height: 100%;
  background: var(--bg2); border-left: 1px solid var(--border-teal);
  display: flex; flex-direction: column;
  animation: slideInRight 0.25s ease;
  box-shadow: -8px 0 40px rgba(0,0,0,0.4);
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }

.wl-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.wl-drawer-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text);
}
.wl-drawer-title [data-lucide] { width: 15px; height: 15px; color: var(--teal-light); }

.wl-manual-add {
  display: flex; gap: 8px; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.wl-input {
  flex: 1; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 13px; font-family: 'Inter', inherit; outline: none;
  transition: var(--transition);
}
.wl-input:focus { border-color: var(--teal-light); box-shadow: 0 0 0 3px var(--teal-glow); }
.wl-input::placeholder { color: var(--text-dim); }

.wl-entries {
  flex: 1; overflow-y: auto; padding: 12px 20px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

.wl-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; height: 100%;
  color: var(--text-dim); text-align: center; padding: 40px 20px;
}
.wl-empty [data-lucide] { width: 36px; height: 36px; opacity: 0.4; }
.wl-empty p { font-size: 14px; }

.wl-entry {
  padding: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: var(--transition);
}
.wl-entry:hover { border-color: var(--border-teal); }
.wl-entry-main { width: 100%; }
.wl-entry-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 10px; gap: 8px;
}
.wl-entry-word {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px; font-weight: 600; color: var(--text);
}
.wl-origin {
  font-size: 11px; color: var(--orange-light);
  background: var(--orange-glow); border: 1px solid var(--border-orange);
  border-radius: 10px; padding: 1px 8px; font-weight: 500;
}
.wl-field {
  display: flex; gap: 8px; font-size: 12px; margin-bottom: 5px;
  align-items: baseline;
}
.wl-field:last-child { margin-bottom: 0; }
.wl-field-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--orange); flex-shrink: 0; width: 80px;
}
.wl-field-value { color: var(--text-muted); line-height: 1.5; }
.wl-remove-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); padding: 4px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition); flex-shrink: 0;
}
.wl-remove-btn:hover { color: var(--error); background: rgba(224,90,90,0.1); }
.wl-remove-btn [data-lucide] { width: 14px; height: 14px; }

/* Bookmark button on word cards */
.bookmark-btn {
  position: absolute; top: 16px; right: 16px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px;
  cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.bookmark-btn:hover { border-color: var(--border-teal); color: var(--teal-light); }
.bookmark-btn.saved { color: var(--teal-light); border-color: var(--border-teal); background: var(--teal-glow); }
.bookmark-btn [data-lucide] { width: 14px; height: 14px; }

/* ── Guide button ── */
.guide-btn {
  display: inline-flex; align-items: center; gap: 0;
  padding: 7px 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-teal); background: transparent;
  color: var(--teal-light); font-size: 12px; font-weight: 500;
  font-family: 'Inter', inherit; cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, gap 0.2s ease, padding 0.2s ease;
  text-decoration: none; overflow: hidden; white-space: nowrap;
}
.guide-btn span:not(.wl-badge) {
  display: inline-block; max-width: 0; opacity: 0; overflow: hidden;
  transition: max-width 0.25s ease, opacity 0.18s ease, margin-left 0.2s ease;
  margin-left: 0;
}
.guide-btn:hover {
  background: var(--surface-2); color: var(--text);
  gap: 6px; padding: 7px 14px;
}
.guide-btn:hover span:not(.wl-badge) {
  max-width: 120px; opacity: 1; margin-left: 0;
}
.guide-btn [data-lucide] { width: 13px; height: 13px; flex-shrink: 0; }

/* ── Guide Modal ── */
.guide-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(7, 8, 26, 0.8); backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
}
.guide-modal {
  background: var(--bg2); border: 1px solid var(--border-teal);
  border-radius: var(--radius); width: 100%; max-width: 700px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: fadeIn 0.25s ease;
}
.guide-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.guide-modal-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; color: var(--text);
}
.guide-modal-title [data-lucide] { width: 16px; height: 16px; color: var(--teal-light); }
.guide-close {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.guide-close:hover { color: var(--error); border-color: rgba(224,90,90,0.3); }
.guide-close [data-lucide] { width: 14px; height: 14px; }

/* Guide tabs */
.guide-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  padding: 0 24px; gap: 4px;
}
.guide-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 16px; background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  font-family: 'Inter', inherit; cursor: pointer; transition: var(--transition);
}
.guide-tab:hover { color: var(--text); }
.guide-tab.active { color: var(--teal-light); border-bottom-color: var(--teal-light); }
.guide-tab [data-lucide] { width: 13px; height: 13px; }

/* Guide content */
.guide-tab-content { padding: 24px; display: flex; flex-direction: column; gap: 24px; }
.guide-section {}
.guide-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--orange);
  margin-bottom: 12px; display: flex; align-items: center; gap: 6px;
}
.guide-section-title::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border-orange), transparent);
}
.guide-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.guide-list li {
  font-size: 13px; color: var(--text-muted); line-height: 1.65;
  padding-left: 16px; position: relative;
}
.guide-list li::before {
  content: '›'; position: absolute; left: 0;
  color: var(--teal-light); font-weight: 700;
}
.guide-list li strong { color: var(--text); }
.guide-list li em { color: var(--teal-light); font-style: normal; }

/* ── Hero / Search ── */
.hero {
  text-align: center; margin-bottom: 48px;
  position: sticky; top: 0; z-index: 100;
  padding-top: 16px;
  transition: background 0.3s, padding 0.3s, border-color 0.3s;
}
.hero--compact {
  background: rgba(10, 22, 40, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  padding-bottom: 16px;
}
[data-theme="light"] .hero--compact {
  background: rgba(240, 245, 248, 0.92);
}
.hero--compact .hero-eyebrow,
.hero--compact .hero-title,
.hero--compact .hero-sub,
.hero--compact .upload-toggle-row,
.hero--compact #upload-area,
.hero--compact #ai-area {
  display: none !important;
}
.hero--compact .search-card { box-shadow: none; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--orange-light); margin-bottom: 16px;
  padding: 4px 12px; border: 1px solid var(--border-gold);
  border-radius: 20px; background: var(--orange-glow);
}
.hero-eyebrow [data-lucide] { width: 11px; height: 11px; }
.hero-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(32px, 5vw, 48px); font-weight: 700;
  color: var(--text); letter-spacing: -0.5px; margin-bottom: 12px;
  line-height: 1.15;
}
.hero-title em { font-style: italic; color: var(--teal-light); }
.hero-sub {
  font-size: 15px; color: var(--text-muted); max-width: 480px;
  margin: 0 auto 32px; line-height: 1.7;
}

/* Search card */
.search-card {
  background: var(--surface);
  border: 1px solid var(--border-indigo);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  overflow: hidden;
  box-shadow: 0 0 0 4px var(--teal-glow), var(--shadow);
  transition: var(--transition);
  text-align: left;
}
.search-card:focus-within {
  border-color: var(--teal-light);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.25), var(--shadow);
}
.search-input {
  width: 100%; padding: 18px 20px 12px;
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 15px; font-family: 'Inter', inherit;
  resize: none; line-height: 1.6; min-height: 100px;
}
.search-input::placeholder { color: var(--text-dim); }
.search-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 14px; border-top: 1px solid var(--border);
  gap: 12px;
}
.search-hint { font-size: 11px; color: var(--text-dim); }
.search-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px;
  background: linear-gradient(135deg, var(--teal-light), var(--teal-dark));
  border: none; border-radius: var(--radius-sm); color: white;
  font-size: 13px; font-weight: 600; font-family: 'Inter', inherit;
  cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.search-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px var(--teal-glow); }
.search-btn:active { transform: translateY(0); }
.search-btn [data-lucide] { width: 14px; height: 14px; }

/* Upload toggle */
.upload-toggle-row { margin-top: 20px; }
.upload-toggle {
  background: none; border: none; cursor: pointer;
  font-family: 'Inter', inherit; font-size: 13px; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 6px;
  transition: var(--transition); padding: 4px 8px; border-radius: var(--radius-sm);
}
.upload-toggle:hover { color: var(--teal-light); }
.upload-toggle [data-lucide] { width: 13px; height: 13px; }
#upload-chevron { transition: transform 0.25s ease; }
#upload-chevron.open { transform: rotate(180deg); }

.upload-area {
  margin-top: 16px; padding: 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); text-align: left;
  animation: slideDown 0.25s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.upload-zone {
  border: 2px dashed var(--border-indigo); border-radius: var(--radius);
  padding: 28px 20px; text-align: center; cursor: pointer;
  transition: var(--transition); background: var(--teal-glow);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--teal-light); background: rgba(79,70,229,0.1);
  transform: translateY(-1px);
}
.upload-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(79,70,229,0.12); border: 1px solid var(--border-indigo);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px; color: var(--teal-light);
}
.upload-icon [data-lucide] { width: 20px; height: 20px; }
.upload-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.upload-sub { font-size: 12px; color: var(--text-muted); }
.upload-input { display: none; }

.file-info {
  margin-top: 12px; padding: 10px 14px;
  background: rgba(79,70,229,0.08); border: 1px solid var(--border-indigo);
  border-radius: var(--radius-sm); font-size: 12px;
  display: flex; align-items: flex-start; gap: 8px; color: var(--text-muted);
}
.file-info [data-lucide] { width: 14px; height: 14px; color: var(--teal-light); flex-shrink: 0; margin-top: 1px; }
.upload-search-btn { margin-top: 14px; }

.ai-count-select {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 12px; font-family: 'Inter', inherit;
  padding: 4px 8px; outline: none; cursor: pointer;
  transition: var(--transition);
}
.ai-count-select:focus, .ai-count-select:hover { border-color: var(--teal); color: var(--text); }
#ai-chevron { transition: transform 0.25s ease; }
#ai-chevron.open { transform: rotate(180deg); }

/* ── Results Section ── */
.results-section { margin-top: 16px; animation: fadeIn 0.3s ease; }

.results-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  position: relative;
}
.results-header::after {
  content: ''; position: absolute; bottom: -1px; left: 0;
  width: 60px; height: 1px;
  background: linear-gradient(90deg, var(--orange), transparent);
}

.results-stats {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
}
.results-stats strong { color: var(--text); }
.stat-sep { color: var(--text-dim); }

/* View toggle */
.view-toggle {
  display: flex; border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.view-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 14px; background: var(--surface);
  border: none; color: var(--text-muted);
  font-size: 12px; font-weight: 500; font-family: 'Inter', inherit;
  cursor: pointer; transition: var(--transition);
}
.view-btn:first-child { border-right: 1px solid var(--border); }
.view-btn:hover { background: var(--surface-2); color: var(--text); }
.view-btn.active { background: var(--teal-glow); color: var(--teal-light); }
.view-btn [data-lucide] { width: 13px; height: 13px; }

.results-actions { display: flex; gap: 8px; }
.action-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: 12px; font-weight: 500;
  font-family: 'Inter', inherit; cursor: pointer; transition: var(--transition);
}
.action-btn:hover { border-color: var(--border-indigo); color: var(--text); }
.action-btn [data-lucide] { width: 13px; height: 13px; }
.action-btn-save-all {
  background: var(--surface-2); border-color: var(--border-teal);
  color: var(--teal-light);
}
.action-btn-save-all:hover { background: var(--teal-glow); }
.action-btn-save-all:disabled { opacity: 0.5; cursor: not-allowed; }
.action-btn-primary {
  background: linear-gradient(135deg, var(--teal-light), var(--teal-dark));
  border-color: transparent; color: white;
}
.action-btn-primary:hover { opacity: 0.88; color: white; border-color: transparent; }

/* ── Word Cards ── */
.results-cards { display: flex; flex-direction: column; gap: 20px; }

.word-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  overflow: hidden;
  transition: var(--transition);
  animation: fadeIn 0.3s ease both;
}
.word-card:hover {
  border-color: var(--border-indigo);
  border-left-color: var(--orange-light);
  box-shadow: var(--shadow-sm);
}

.word-card-header {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  position: relative;
}
.word-number {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--orange-glow); border: 1px solid var(--border-gold);
  color: var(--orange-light); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 6px;
}
.word-title-group { flex: 1; }
.word-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.word-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 28px; font-weight: 700; color: var(--text);
  letter-spacing: -0.3px; line-height: 1.1;
}
.more-entries-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 6px 0 10px; padding: 6px 14px;
  background: none; border: 1px dashed var(--border);
  border-radius: 20px; color: var(--text-muted);
  font-size: 12px; font-family: inherit; cursor: pointer;
  transition: var(--transition);
}
.more-entries-btn:hover { color: var(--teal-light); border-color: var(--teal); }
.more-entries-btn [data-lucide] { width: 13px; height: 13px; }
.extra-entries { display: flex; flex-direction: column; gap: 16px; }

.audio-play-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex-shrink: 0;
  background: none; border: 1px solid var(--border);
  border-radius: 50%; color: var(--text-muted);
  cursor: pointer; transition: var(--transition);
}
.audio-play-btn:hover { color: var(--teal-light); border-color: var(--teal); background: var(--teal-glow); }
.audio-play-btn.playing { color: var(--teal-light); border-color: var(--teal); background: var(--teal-glow); animation: pulse 1s infinite; }
.audio-play-btn [data-lucide] { width: 13px; height: 13px; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
.word-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.pill-pos {
  background: var(--teal-glow); color: var(--teal-light);
  border: 1px solid var(--border-indigo);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.pill-pron {
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border); font-style: italic; font-weight: 400;
  font-size: 12px;
}
.pill-origin {
  background: var(--orange-glow); color: var(--orange-light);
  border: 1px solid var(--border-gold);
}

.word-card-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }

.word-section {}
.word-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--orange);
  margin-bottom: 6px; display: flex; align-items: center; gap: 5px;
}
.word-section-label::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border-gold), transparent);
}
.word-section-content {
  font-size: 14px; color: var(--text-muted); line-height: 1.7;
}
.word-section-content.usage {
  font-style: italic; color: var(--text-muted);
  padding-left: 12px; border-left: 2px solid var(--border-indigo);
}
.word-na { color: var(--text-dim); font-style: italic; }

/* ── Table View ── */
.results-table-wrap {
  border-radius: var(--radius); border: 1px solid var(--border);
  overflow-x: auto; overflow-y: auto; max-height: 640px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.results-table th {
  padding: 11px 16px; text-align: left;
  background: rgba(79,70,229,0.12);
  color: var(--orange-light); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700;
  position: sticky; top: 0; white-space: nowrap;
  border-bottom: 1px solid var(--border-indigo);
}
.results-table td {
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: top;
  line-height: 1.5; max-width: 220px; word-wrap: break-word;
}
.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover td { background: var(--surface-hover); }
.results-table td:first-child {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 16px; font-weight: 600; white-space: nowrap;
}
.pos-badge {
  display: inline-block; padding: 2px 9px;
  background: var(--teal-glow); color: var(--teal-light);
  border: 1px solid var(--border-indigo); border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}
.text-muted-cell { color: var(--text-muted); }
.text-origin-cell { color: var(--orange-light); }

/* ── Loading overlay ── */
.loading-overlay-fullscreen {
  position: fixed; inset: 0; z-index: 9998;
  background: var(--bg, #07081a);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.loading-spinner {
  width: 44px; height: 44px; border: 3px solid var(--border);
  border-top-color: var(--teal-light); border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.loading-text { font-size: 14px; font-weight: 600; color: var(--text); }

/* ── Toasts ── */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999; pointer-events: none;
}
.toast {
  padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; pointer-events: auto;
  max-width: 320px; min-width: 200px;
  display: flex; align-items: center; gap: 9px;
  animation: slideIn 0.25s ease; box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.toast [data-lucide] { width: 14px; height: 14px; flex-shrink: 0; }
.toast.success { background: var(--toast-bg); color: var(--success); border: 1px solid rgba(76,175,125,0.25); }
.toast.error   { background: var(--toast-bg); color: var(--error);   border: 1px solid rgba(224,90,90,0.25); }
.toast.info    { background: var(--toast-bg); color: var(--info);    border: 1px solid rgba(74,159,212,0.25); }
.toast-msg { color: var(--text); }
.toast.hide { animation: slideOut 0.25s ease forwards; }

/* ── Animations ── */
@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOut { from { opacity: 1; transform: translateX(0); }    to { opacity: 0; transform: translateX(40px); } }

/* ── Responsive ── */
@media (max-width: 768px) {
  /* Header */
  .header { padding: 14px 0; }
  .logo-tagline { display: none; }
  .topbar-user span { display: none; }

  /* Hero */
  .hero-title { font-size: 26px; }
  .hero-sub { font-size: 13px; }

  /* Results header */
  .results-header { flex-wrap: wrap; gap: 10px; }
  .results-actions { width: 100%; display: flex; gap: 8px; }
  .action-btn { flex: 1; justify-content: center; }

  /* Word cards */
  .word-title { font-size: 22px; }
  .word-card-header { padding: 14px 16px 12px; gap: 10px; }
  .word-card-body { padding: 14px 16px; }
  .word-number { width: 24px; height: 24px; font-size: 11px; }

  /* Table: horizontal scroll */
  .results-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .results-table { min-width: 700px; }

  /* Guide page tabs */
  .gp-tabs { overflow-x: auto; gap: 0; }
  .gp-tab { white-space: nowrap; padding: 10px 14px; font-size: 12px; }

  /* Mat cards */
  .mat-card { flex-wrap: wrap; }
  .mat-card-actions { width: 100%; justify-content: flex-end; margin-top: 6px; }

  /* Upload area */
  .upload-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .app-container { padding: 0 12px; }
  .header { gap: 8px; }
  .logo-wordmark { font-size: 14px; }
  .hero-title { font-size: 22px; }
  .search-footer { flex-direction: column; align-items: stretch; gap: 8px; }
  .search-btn { width: 100%; justify-content: center; }
  .search-hint { display: none; }
  .view-toggle { order: -1; }
  .word-title { font-size: 20px; }
  .word-title-row { gap: 6px; }
  .gp-tab { padding: 9px 11px; font-size: 11px; }
  .gp-tab [data-lucide] { display: none; }
}

/* Pagination */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 0 8px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.page-btn:hover:not(:disabled) {
  background: var(--surface-hover, rgba(255,255,255,0.07));
  border-color: var(--teal-light);
  color: var(--teal-light);
}
.page-btn.active {
  background: var(--teal-light);
  border-color: var(--teal-light);
  color: #0d1117;
  font-weight: 700;
}
.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.page-ellipsis {
  color: var(--text-muted);
  font-size: 14px;
  padding: 0 4px;
  user-select: none;
}
