:root {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-elevated: #ffffff;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --accent: #0ea5e9;
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 40px -10px rgba(15, 23, 42, 0.14);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

[data-theme="dark"] {
  --bg-body: #0b1120;
  --bg-card: #131c31;
  --bg-subtle: #1e293b;
  --bg-elevated: #1e293b;
  --text-main: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #1e293b;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-soft: rgba(99, 102, 241, 0.16);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 44px -10px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Header & Desktop Navigation */
.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .top-header {
  background: rgba(19, 28, 49, 0.85);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  min-width: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand-title {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: block;
  white-space: nowrap;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-subtle);
  padding: 0.3rem;
  border-radius: 12px;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.48rem 0.95rem;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  color: var(--text-main);
}

.nav-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.badge-due {
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge-due.empty {
  background: var(--success);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.icon-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  padding: 0.45rem 0.8rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

#nav-user-name {
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
}

.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}

.ai-status-dot.online {
  background: var(--success);
}

/* Main Container */
.main-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

/* Due Review Alert Banner */
.due-alert-banner {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(14, 165, 233, 0.12));
  border: 1px solid rgba(79, 70, 229, 0.3);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.2rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.due-alert-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.92rem;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Tab Views */
.tab-view {
  display: none;
  animation: fadeIn 0.2s ease;
}

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

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

/* Search Box Hero */
.search-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.search-bar-wrapper {
  display: flex;
  gap: 0.65rem;
  position: relative;
}

.search-input {
  flex: 1;
  min-width: 0;
  font-size: 1.05rem;
  padding: 0.85rem 1.15rem;
  border-radius: 12px;
  border: 2px solid var(--border-color);
  background: var(--bg-body);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--primary);
}

.primary-btn {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 0 1.4rem;
  border-radius: 12px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: background 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.primary-btn:hover {
  background: var(--primary-hover);
}

.primary-btn:active {
  transform: scale(0.98);
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.quick-chips {
  margin-top: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.word-chip {
  font-size: 0.82rem;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.word-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* Dictionary Result Card */
.dict-result-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  width: 100%;
}

.dict-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.dict-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.15rem;
  margin-bottom: 1.25rem;
}

.dict-word-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.phonetics-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.phonetic-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-subtle);
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.phonetic-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tags-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.tag-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.18rem 0.6rem;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
}

.add-vocab-btn {
  padding: 0.65rem 1.15rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.92rem;
  border: 2px solid var(--primary);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.15s;
}

.add-vocab-btn.saved {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

/* Bilingual Definitions Section */
.section-heading {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.def-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.def-item {
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 0.95rem 1.1rem;
  border-left: 4px solid var(--primary);
}

.def-pos {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--primary);
  margin-right: 0.5rem;
  font-style: italic;
}

.def-zh {
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text-main);
}

.def-en {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Daily Usage Grid */
.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.15rem;
  margin-top: 1.25rem;
}

.usage-box {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  border: 1px solid var(--border-color);
  min-width: 0;
  max-width: 100%;
}

.tone-banner {
  background: linear-gradient(90deg, var(--primary-soft), rgba(14, 165, 233, 0.08));
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.15rem;
  font-size: 0.93rem;
}

.collocation-item {
  padding: 0.65rem 0;
  border-bottom: 1px dashed var(--border-color);
}

.collocation-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.collocation-phrase {
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}

.dialogue-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0.95rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--border-color);
}

.dialogue-scene {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.dialogue-line {
  margin-bottom: 0.55rem;
  font-size: 0.92rem;
}

.dialogue-zh {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.dialogue-note {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-color);
  font-size: 0.82rem;
  color: var(--warning);
  font-weight: 500;
}

/* Review Flashcard Arena */
.review-arena {
  max-width: 680px;
  margin: 0 auto;
}

.review-progress-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.flashcard {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.75rem;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: transform 0.2s ease;
}

.flashcard-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.flashcard-front {
  text-align: center;
  padding: 2.2rem 0.5rem;
}

.flashcard-word {
  font-size: 2.4rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
}

.flashcard-answer {
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
  margin-top: 1rem;
  text-align: left;
  animation: fadeIn 0.2s ease;
}

.rating-buttons-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.rate-btn {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.75rem 0.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: var(--bg-card);
  color: var(--text-main);
  transition: all 0.15s ease;
}

.rate-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.rate-btn.rate-1 { border-bottom: 4px solid var(--danger); }
.rate-btn.rate-2 { border-bottom: 4px solid var(--warning); }
.rate-btn.rate-3 { border-bottom: 4px solid var(--primary); }
.rate-btn.rate-4 { border-bottom: 4px solid var(--success); }

.rate-title {
  font-weight: 700;
  font-size: 0.92rem;
}

.rate-interval {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* Vocabulary Book List & Filters */
.vocab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
}

.filter-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-pill {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
  gap: 1rem;
}

.vocab-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
  max-width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.vocab-item-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.retention-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.3rem;
}

.retention-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Stats & Curve Dashboard */
.stats-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  min-width: 0;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 1.25rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  min-width: 0;
  max-width: 100%;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-body);
  color: var(--text-main);
  font-size: 0.92rem;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
}

/* Mobile Bottom Tab Bar */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 0.45rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom));
  z-index: 50;
  justify-content: space-around;
}

.mobile-nav-item {
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
  position: relative;
  padding: 0.25rem 0.75rem;
}

.mobile-nav-item.active {
  color: var(--primary);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--text-main);
  color: var(--bg-card);
  padding: 0.75rem 1.15rem;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.2s ease;
}

/* Reorganized Dictionary Hero, Sub-Tabs & On-Demand Etymology Layout */
.alert-warning {
  background: var(--warning-soft);
  color: var(--warning);
  padding: 0.65rem 0.95rem;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.dict-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border-color);
}

.dict-hero-main {
  flex: 1;
  min-width: min(100%, 240px);
}

.dict-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.source-pill {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
}

.dict-summary {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-subtle);
  border-radius: 12px;
  border-left: 4px solid var(--primary);
}

.dict-summary-zh {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.dict-summary-en {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.tag-freq {
  background: var(--warning-soft);
  color: var(--warning);
}

.dict-hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.vocab-status-line {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.note-bar {
  margin-top: 1rem;
  background: var(--bg-subtle);
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.note-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.note-bar .form-input {
  flex: 1;
  min-width: min(100%, 180px);
  padding: 0.45rem 0.75rem;
  background: var(--bg-card);
}

/* Dictionary Section Tabs */
.dict-tabs {
  display: flex;
  gap: 0.4rem;
  margin-top: 1.2rem;
  padding: 0.35rem;
  background: var(--bg-subtle);
  border-radius: 12px;
  overflow-x: auto;
}

.dict-tab {
  flex: 1;
  min-width: 120px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.58rem 0.9rem;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.dict-tab:hover {
  color: var(--text-main);
}

.dict-tab.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.dict-panel {
  display: none;
  margin-top: 1.15rem;
  animation: fadeIn 0.18s ease;
}

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

.def-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.def-index {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.def-body {
  flex: 1;
}

.panel-subsection {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px dashed var(--border-color);
}

.subsection-title {
  font-size: 0.93rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.7rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.family-chip,
.cognate-chip {
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-main);
  padding: 0.38rem 0.75rem;
  border-radius: 10px;
  font-size: 0.83rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.family-chip:hover,
.cognate-chip:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.family-chip em,
.cognate-chip em {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.collocation-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.collocation-phrase {
  border: none;
  background: none;
  font-weight: 700;
  font-size: 0.93rem;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.collocation-zh {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
}

.example-en {
  font-size: 0.87rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-style: italic;
}

.example-zh {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dialogue-line {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.speaker {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.speaker-a {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.speaker-b {
  background: var(--primary-soft);
  color: var(--primary);
}

.mini-audio,
.mini-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.72rem;
  cursor: pointer;
}

.pitfall {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.86rem;
  margin-bottom: 0.45rem;
}

.pitfall-bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.pitfall-good {
  background: var(--success-soft);
  color: var(--success);
}

.memory-banner {
  margin-top: 1rem;
  padding: 1rem 1.15rem;
  background: var(--bg-subtle);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.body-text {
  font-size: 0.91rem;
  color: var(--text-main);
  line-height: 1.65;
}

.link-btn {
  margin-top: 0.55rem;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 0.86rem;
}

/* Etymology & Word-Root Visual Breakdown */
.ety-placeholder,
.ety-loading {
  background: var(--bg-subtle);
  border: 1px dashed var(--border-color);
  border-radius: 14px;
  padding: 1.8rem 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.ety-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  animation: etySpin 0.8s linear infinite;
}

@keyframes etySpin {
  to { transform: rotate(360deg); }
}

.ety-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.ety-meta-spacer {
  flex: 1;
}

.morph-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.morph-plus {
  align-self: center;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-muted);
}

.morph {
  flex: 1;
  min-width: 135px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-top-width: 4px;
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
}

.morph-prefix { border-top-color: #0ea5e9; }
.morph-root   { border-top-color: #4f46e5; }
.morph-suffix { border-top-color: #10b981; }
.morph-word   { border-top-color: #f59e0b; }

.morph-type {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.morph-part {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0.1rem 0;
}

.morph-zh {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
}

.morph-en {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.morph-origin {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.ety-formula {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.92rem;
}

.ety-shift {
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border-color);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.ety-timeline {
  list-style: none;
  border-left: 2px solid var(--primary);
  margin-left: 0.4rem;
  padding-left: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ety-timeline li {
  position: relative;
}

.ety-timeline li::before {
  content: "";
  position: absolute;
  left: -1.32rem;
  top: 0.35rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
}

.tl-stage {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.tl-form {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-main);
}

.tl-meaning {
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.ety-hook {
  margin-top: 0.9rem;
  padding: 0.65rem 0.95rem;
  border-radius: 10px;
  background: var(--success-soft);
  color: var(--success);
  font-weight: 700;
  font-size: 0.88rem;
}

.ety-compact {
  background: var(--bg-subtle);
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

/* Responsive Breakpoints (Mobile & PWA Standalone Mode) */
@media (max-width: 768px) {
  .desktop-nav {
    display: none;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .brand-subtitle {
    display: none;
  }
  .header-inner {
    padding: 0.6rem 0.85rem;
    gap: 0.4rem;
  }
  .brand {
    gap: 0.45rem;
  }
  .brand-icon {
    width: 32px;
    height: 32px;
  }
  .brand-title {
    font-size: 1.02rem;
    gap: 0.3rem;
  }
  .header-actions {
    gap: 0.35rem;
  }
  .icon-btn {
    padding: 0.36rem 0.6rem;
    font-size: 0.78rem;
    border-radius: 8px;
  }
  #nav-user-name {
    max-width: 64px;
  }
  .main-container {
    padding: 0.9rem 0.75rem;
  }
  .search-hero {
    padding: 1rem 0.9rem;
    margin-bottom: 1rem;
    border-radius: 14px;
  }
  .search-bar-wrapper {
    gap: 0.45rem;
  }
  .search-input {
    font-size: 0.95rem;
    padding: 0.7rem 0.85rem;
  }
  .primary-btn {
    padding: 0 0.95rem;
    font-size: 0.88rem;
  }
  .dict-card {
    padding: 1.05rem 0.95rem;
    border-radius: 14px;
  }
  .dict-word-title {
    font-size: 1.55rem;
  }
  .dict-hero {
    gap: 0.95rem;
  }
  .dict-hero-actions {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
  }
  .dict-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.35rem;
  }
  .dict-tab {
    min-width: 0;
    font-size: 0.84rem;
    padding: 0.5rem 0.4rem;
  }
  .usage-grid,
  .vocab-grid,
  .charts-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .stats-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }
  .flashcard {
    padding: 1.25rem 1rem;
    min-height: 300px;
    border-radius: 16px;
  }
  .flashcard-word {
    font-size: 1.9rem;
  }
  .rating-buttons-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .morph {
    min-width: calc(50% - 1rem);
  }
  .mobile-nav-item {
    padding: 0.2rem 0.35rem;
    font-size: 0.7rem;
  }
}

@media (max-width: 420px) {
  .brand-en {
    display: none;
  }
}
