/* ========== Reset & Variables ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { overscroll-behavior-x: none; }

:root {
  --primary: #4F46E5;
  --primary-light: #818CF8;
  --primary-dark: #3730A3;
  --primary-bg: #EEF2FF;
  --success: #10B981;
  --success-bg: #D1FAE5;
  --warning: #F59E0B;
  --warning-bg: #FEF3C7;
  --danger: #EF4444;
  --danger-bg: #FEE2E2;
  --bg: #F1F5F9;
  --bg-secondary: #E2E8F0;
  --card-bg: #FFFFFF;
  --text: #0F172A;
  --text-secondary: #64748B;
  --text-tertiary: #94A3B8;
  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --sidebar-width: 260px;
  --header-height: 56px;
  --transition: 0.2s ease;
}

/* ========== Dark Theme ========== */
[data-theme="dark"] {
  --primary: #818CF8;
  --primary-light: #A5B4FC;
  --primary-dark: #6366F1;
  --primary-bg: #1E1B4B;
  --success: #34D399;
  --success-bg: #064E3B;
  --warning: #FBBF24;
  --warning-bg: #78350F;
  --danger: #F87171;
  --danger-bg: #7F1D1D;
  --bg: #0F172A;
  --bg-secondary: #1E293B;
  --card-bg: #1E293B;
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-tertiary: #64748B;
  --border: #334155;
  --border-light: #1E293B;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  color-scheme: dark;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

#app { display: flex; min-height: 100vh; min-height: 100dvh; }

.hidden { display: none !important; }

/* ========== Sidebar ========== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--card-bg);
  border-right: 1px solid var(--border);
  z-index: 300; display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 299;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px; border-bottom: 1px solid var(--border);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 28px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 18px; font-weight: 800; color: var(--text); }
.brand-sub { font-size: 11px; color: var(--text-tertiary); font-weight: 600; letter-spacing: 1px; }
.sidebar-close {
  background: none; border: none; font-size: 18px; color: var(--text-secondary);
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
}
.sidebar-close:hover { background: var(--bg); }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { margin-bottom: 8px; }
.nav-section-title {
  font-size: 11px; font-weight: 700; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 8px 20px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; cursor: pointer; transition: all var(--transition);
  color: var(--text-secondary); text-decoration: none; position: relative;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--primary-bg); color: var(--primary);
  font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; background: var(--primary); border-radius: 0 3px 3px 0;
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.nav-label { font-size: 14px; }
.nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--danger); color: white;
  padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center;
}
.nav-badge:empty { display: none; }

.sidebar-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
}
.sidebar-version { font-size: 12px; color: var(--text-tertiary); }

/* ========== Header ========== */
.header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 16px; height: var(--header-height);
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-title { font-size: 17px; font-weight: 700; color: var(--text); }
.header-right { display: flex; gap: 4px; align-items: center; position: relative; }
.btn-menu {
  background: none; border: none; font-size: 20px; cursor: pointer;
  padding: 6px 8px; border-radius: var(--radius-sm); color: var(--text);
  transition: background var(--transition);
}
.btn-menu:hover { background: var(--bg); }
.btn-home {
  background: none; border: none; font-size: 18px; cursor: pointer;
  padding: 4px 6px; border-radius: var(--radius-sm); transition: background var(--transition);
}
.btn-home:hover { background: var(--bg); }
.btn-back-nav {
  background: none; border: none; font-size: 20px; cursor: pointer;
  padding: 4px 8px; border-radius: var(--radius-sm); color: var(--primary);
  transition: background var(--transition); display: inline-flex; align-items: center;
}
.btn-back-nav:hover { background: var(--bg); }

/* Top banner */
/* ========== Top Banner v2 — elegant notification bar ========== */
.top-banner {
  padding: 8px 40px 8px 16px;
  font-size: 12px;
  text-align: center;
  line-height: 1.4;
  position: sticky;
  top: var(--header-height);
  z-index: 99;
  margin: 8px 12px 0;
  border-radius: 12px;
  border: 1px solid transparent;
  animation: bannerSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.top-banner a { font-weight: 600; text-decoration: none; border-bottom: 1px dashed currentColor; padding-bottom: 1px; }
.top-banner a:hover { border-bottom-style: solid; }
.top-banner .banner-close {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 14px; cursor: pointer; opacity: 0.4; color: inherit;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: all 0.2s;
}
.top-banner .banner-close:hover { opacity: 0.8; background: rgba(0,0,0,0.05); }
.banner-icon { font-size: 14px; flex-shrink: 0; }
.banner-text { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.banner-text-scroll { display: inline-block; white-space: nowrap; }
.top-banner.banner-marquee .banner-text-scroll {
  padding-left: 100%;
  animation: bannerMarquee 10s linear infinite;
}
@keyframes bannerMarquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}
.banner-cta {
  display: inline-block; padding: 4px 12px; border-radius: 16px; font-size: 11px;
  font-weight: 700; white-space: nowrap; text-decoration: none !important; border-bottom: none !important;
  transition: all 0.2s; flex-shrink: 0; letter-spacing: 0.5px;
}
.banner-cta:active { transform: scale(0.96); }
.top-banner.banner-trial {
  background: linear-gradient(135deg, rgba(255,247,237,0.95), rgba(254,243,199,0.95));
  color: #92400E; border-color: rgba(253,186,116,0.4);
}
.top-banner.banner-trial .banner-cta { background: #F59E0B; color: #fff; }
.top-banner.banner-free {
  background: linear-gradient(135deg, rgba(238,242,255,0.95), rgba(224,231,255,0.95));
  color: #3730A3; border-color: rgba(165,180,252,0.4);
}
.top-banner.banner-free .banner-cta { background: #4F46E5; color: #fff; }
.top-banner.banner-member {
  background: linear-gradient(135deg, rgba(236,253,245,0.95), rgba(209,250,229,0.95));
  color: #065F46; border-color: rgba(110,231,183,0.3);
}
.top-banner.banner-promo {
  background: linear-gradient(135deg, rgba(79,70,229,0.95), rgba(124,58,237,0.95));
  color: rgba(255,255,255,0.95); border-color: rgba(99,102,241,0.4);
}
.top-banner.banner-promo .banner-cta { background: rgba(255,255,255,0.2); color: #fff; backdrop-filter: blur(4px); }
.top-banner.banner-streak {
  background: linear-gradient(135deg, rgba(255,251,235,0.95), rgba(254,243,199,0.95));
  color: #78350F; border-color: rgba(251,191,36,0.3);
}
@keyframes bannerSlide {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
[data-theme="dark"] .top-banner.banner-trial { background: linear-gradient(135deg, rgba(69,26,3,0.9), rgba(120,53,15,0.9)); color: #FDE68A; border-color: rgba(146,64,14,0.5); }
[data-theme="dark"] .top-banner.banner-trial .banner-cta { background: #D97706; }
[data-theme="dark"] .top-banner.banner-free { background: linear-gradient(135deg, rgba(30,27,75,0.9), rgba(49,46,129,0.9)); color: #C7D2FE; border-color: rgba(67,56,202,0.5); }
[data-theme="dark"] .top-banner.banner-free .banner-cta { background: #6366F1; }
[data-theme="dark"] .top-banner.banner-member { background: linear-gradient(135deg, rgba(2,44,34,0.9), rgba(6,78,59,0.9)); color: #A7F3D0; border-color: rgba(4,120,87,0.5); }
[data-theme="dark"] .top-banner.banner-promo { background: linear-gradient(135deg, rgba(67,56,202,0.9), rgba(109,40,217,0.9)); color: rgba(255,255,255,0.95); border-color: rgba(99,102,241,0.5); }
[data-theme="dark"] .top-banner.banner-promo .banner-cta { background: rgba(255,255,255,0.15); }
[data-theme="dark"] .top-banner.banner-streak { background: linear-gradient(135deg, rgba(69,26,3,0.9), rgba(120,53,15,0.9)); color: #FDE68A; border-color: rgba(251,191,36,0.3); }
[data-theme="dark"] .top-banner .banner-close:hover { background: rgba(255,255,255,0.1); }

.btn-icon {
  background: none; border: none; font-size: 14px; cursor: pointer;
  padding: 6px 8px; border-radius: var(--radius-sm); color: var(--text-secondary);
  transition: all var(--transition); white-space: nowrap;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.audio-panel {
  position: absolute; top: 44px; right: 8px; z-index: 1000;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15); padding: 10px 14px; min-width: 180px;
}
.audio-panel.hidden { display: none; }
.audio-panel-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 13px; color: var(--text); }
.audio-panel-accent { display: flex; gap: 4px; }
.audio-panel-accent .btn-sm { font-size: 12px; padding: 3px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); cursor: pointer; }
.audio-panel-accent .btn-sm.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.toggle-switch.mini { transform: scale(0.8); }

/* ========== Main Content ========== */
.main-content {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  max-width: 100%;
}

.view { display: none; padding: 16px; flex: 1; }
.view.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ========== Buttons ========== */
.btn-primary {
  background: var(--primary); color: white; border: none;
  padding: 12px 24px; border-radius: var(--radius); font-size: 15px;
  font-weight: 600; cursor: pointer; transition: all var(--transition); width: 100%;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-large { padding: 14px 32px; font-size: 16px; }
.btn-secondary {
  background: var(--card-bg); color: var(--text); border: 1.5px solid var(--border);
  padding: 10px 20px; border-radius: var(--radius); font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all var(--transition); flex: 1;
}
@media (hover: hover) { .btn-secondary:hover { border-color: var(--primary); color: var(--primary); } }
.btn-back {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--text-secondary); padding: 4px 8px; border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.btn-back:hover { background: var(--bg); color: var(--text); }
.btn-row { display: flex; gap: 10px; }

/* ========== Sub Header ========== */
.sub-header {
  display: flex; align-items: center; gap: 8px;
  padding: 0 0 16px; font-size: 16px; font-weight: 700;
}

/* ========== Deck List ========== */
.decks-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 16px;
}
.summary-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px 10px; text-align: center; box-shadow: var(--shadow);
}
.summary-num { font-size: 22px; font-weight: 800; }
.summary-num.due { color: var(--warning); }
.summary-num.new-w { color: var(--primary); }
.summary-num.total { color: var(--text); }
.summary-num.decks { color: var(--success); }
.summary-label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.decks-section-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--text);
}
.section-header-left { display: flex; align-items: center; gap: 8px; }
.section-accent { width: 4px; height: 18px; border-radius: 2px; background: var(--primary); }
.btn-expand-all {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px 10px; font-size: 12px; color: var(--text-secondary); cursor: pointer;
}
.btn-expand-all:active { opacity: 0.7; }

/* Active Deck (正在学习) */
.active-deck-section {
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 2px solid var(--primary-bg);
}
.active-deck-label {
  font-size: 13px; font-weight: 700; color: var(--primary);
  margin-bottom: 8px; padding-left: 4px;
}
.deck-row-active {
  background: var(--primary-bg); border: 1px solid var(--primary-light);
  border-radius: var(--radius); padding: 14px 12px;
}
.deck-row-active:active { background: var(--primary-bg); }

/* Category Groups */
.cat-group { margin-bottom: 4px; }
.cat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 4px; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.cat-header:active { background: var(--bg); }
.cat-icon { font-size: 16px; }
.cat-name { font-size: 14px; font-weight: 700; color: var(--text); }
.cat-count { font-size: 12px; color: var(--text-tertiary); }
.cat-arrow { margin-left: auto; font-size: 12px; color: var(--text-tertiary); transition: transform 0.2s; }
.cat-arrow.open { transform: rotate(90deg); }
.cat-items { transition: all 0.2s; }

.deck-list-v2 { display: flex; flex-direction: column; }
.deck-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 8px; border-bottom: 1px solid var(--border-light);
  cursor: pointer; transition: background 0.15s; border-radius: var(--radius-sm);
}
.deck-row:last-child { border-bottom: none; }
.deck-row:active { background: var(--bg); }
.deck-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: white; flex-shrink: 0;
}
.deck-row-info { flex: 1; min-width: 0; }
.deck-row-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-row-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.deck-row-arrow { color: var(--text-tertiary); font-size: 16px; flex-shrink: 0; }

/* ========== Dashboard ========== */
.deck-header { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.deck-header span { font-size: 17px; font-weight: 700; }

/* Hero card: ring + stats in one card */
.dash-hero-card {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 32px 20px 24px; box-shadow: var(--shadow); margin-bottom: 20px;
}

.progress-ring { width: 170px; height: 170px; margin: 0 auto 20px; position: relative; }
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-ring .ring-bg { fill: none; stroke: #E8E8EF; stroke-width: 12; }
.progress-ring .ring-fill { fill: none; stroke: var(--primary); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.progress-ring .ring-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.progress-ring .ring-percent { font-size: 36px; font-weight: 800; color: var(--primary); }
.progress-ring .ring-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.stats-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  border-top: 1px solid var(--border-light); padding-top: 20px;
}
.stat-box { text-align: center; padding: 4px 0; }
.stat-box .stat-num { font-size: 22px; font-weight: 800; }
.stat-box .stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.stat-box.new .stat-num { color: var(--success); }
.stat-box.learning .stat-num { color: #F59E0B; }
.stat-box.review .stat-num { color: #3B82F6; }
.stat-box.mastered .stat-num { color: var(--success); }

/* Action buttons */
.dash-actions { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.btn-start { font-size: 17px; padding: 16px; border-radius: var(--radius); letter-spacing: 0.5px; }
.dash-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dash-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 12px;
  font-size: 15px; font-weight: 600; color: var(--text);
  cursor: pointer; transition: all var(--transition);
  box-shadow: var(--shadow);
}
.dash-btn:active { background: var(--bg); transform: scale(0.97); }
.dash-btn-icon { font-size: 16px; }

.dashboard-help { margin-top: 8px; }
.dashboard-help details {
  background: var(--card-bg); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.dashboard-help summary { cursor: pointer; font-size: 14px; color: var(--text-secondary); }
.dashboard-help p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; line-height: 1.6; }

/* Recall Hint */
.card-recall-hint {
  text-align: center; padding: 40px 20px;
  color: var(--text-tertiary); user-select: none;
}
.recall-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.5; }
.recall-text { font-size: 18px; font-weight: 600; color: var(--text-tertiary); }
.recall-sub { font-size: 13px; margin-top: 6px; color: var(--border); }

/* Practice Title */
.dash-practice-title {
  font-size: 14px; font-weight: 700; color: var(--text-secondary);
  margin-top: 8px; margin-bottom: -4px; padding-left: 2px;
}
.dash-btn-fun { border-style: dashed; }

/* ========== Practice Modes ========== */
#view-practice { padding: 0; }
#view-practice.active {
  display: flex; flex-direction: column;
  height: calc(100dvh - var(--header-height));
  height: calc(100vh - var(--header-height));
}
.practice-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; flex-shrink: 0;
}
.practice-title { font-size: 15px; font-weight: 700; flex: 1; }
.practice-score { font-size: 14px; font-weight: 700; color: var(--primary); }

.practice-area {
  flex: 1; overflow-y: auto; padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.practice-bottom {
  flex-shrink: 0; padding: 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
  background: var(--bg); border-top: 1px solid var(--border);
}

/* Match Game */
.match-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  max-width: 400px; margin: 0 auto;
}
.match-tile {
  background: var(--card-bg); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 16px 8px;
  text-align: center; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.2s; user-select: none;
  min-height: 60px; display: flex; align-items: center; justify-content: center;
  word-break: break-word; line-height: 1.3;
}
.match-tile:active { transform: scale(0.95); }
.match-tile.selected { border-color: var(--primary); background: var(--primary-bg); color: var(--primary); }
.match-tile.matched {
  background: var(--success-bg); border-color: var(--success); color: var(--success);
  opacity: 0.5; pointer-events: none;
}
.match-tile.wrong { border-color: var(--danger); background: var(--danger-bg); animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Speed Challenge */
.speed-timer {
  text-align: center; margin-bottom: 16px;
}
.speed-timer-bar {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.speed-timer-fill {
  height: 100%; background: var(--primary); border-radius: 3px;
  transition: width 0.1s linear;
}
.speed-timer-text { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.speed-word {
  text-align: center; font-size: 28px; font-weight: 800;
  padding: 30px 0 10px; color: var(--text);
}
.speed-meaning {
  text-align: center; font-size: 18px; color: var(--text-secondary);
  padding: 0 0 30px;
}
.speed-btns {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.speed-btn {
  padding: 18px; border-radius: var(--radius); font-size: 18px; font-weight: 700;
  border: none; cursor: pointer; transition: all 0.15s;
}
.speed-btn-wrong { background: var(--danger-bg); color: var(--danger); }
.speed-btn-wrong:active { background: var(--danger); color: #fff; }
.speed-btn-right { background: var(--success-bg); color: var(--success); }
.speed-btn-right:active { background: var(--success); color: #fff; }

/* Listen Mode */
.listen-play-btn {
  display: block; margin: 30px auto; width: 80px; height: 80px;
  border-radius: 50%; background: var(--primary); border: none;
  font-size: 36px; cursor: pointer; color: #fff;
  box-shadow: var(--shadow-md); transition: transform 0.15s;
}
.listen-play-btn:active { transform: scale(0.9); }
.listen-hint { text-align: center; font-size: 13px; color: var(--text-tertiary); margin: 12px 0 24px; }
.listen-choices { display: flex; flex-direction: column; gap: 10px; max-width: 400px; margin: 0 auto; }
.listen-choice {
  background: var(--card-bg); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  font-size: 15px; text-align: center; cursor: pointer;
  transition: all 0.2s;
}
.listen-choice:active { background: var(--bg); }
.listen-choice.correct { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.listen-choice.wrong { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }

/* Practice Result */
.practice-result {
  text-align: center; padding: 40px 20px;
}
.practice-result-icon { font-size: 48px; margin-bottom: 16px; }
.practice-result-title { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.practice-result-stat { font-size: 15px; color: var(--text-secondary); margin-bottom: 4px; }
.practice-result-btn { margin-top: 24px; }

/* ========== Study Page ========== */
#view-study { padding: 0; }
#view-study.active {
  display: flex; flex-direction: column;
  height: calc(100dvh - var(--header-height));
  height: calc(100vh - var(--header-height));
}
@supports (height: 100dvh) {
  #view-study.active { height: calc(100dvh - var(--header-height)); }
}
#view-study .study-header { padding: 12px 16px; flex-shrink: 0; }
.study-scroll-area { flex: 1; overflow-y: auto; padding: 0 16px; -webkit-overflow-scrolling: touch; }
.study-bottom-fixed {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
  background: var(--bg); border-top: 1px solid var(--border);
  z-index: 50;
}
.study-scroll-area { padding-bottom: 180px !important; }

.study-header { display: flex; align-items: center; gap: 10px; }
.study-mode-label {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 10px; white-space: nowrap; flex-shrink: 0;
}
.study-mode-label.mode-new { background: var(--primary-bg); color: var(--primary); }
.study-mode-label.mode-review { background: var(--warning-bg); color: #92400E; }
.study-mode-label.mode-mixed { background: var(--success-bg); color: #166534; }
.study-progress { flex: 1; display: flex; align-items: center; gap: 8px; }
.progress-bar { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s ease; width: 0%; }
#study-count { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* ========== Word Card ========== */
.card-area { display: flex; justify-content: center; align-items: flex-start; min-height: 180px; padding: 8px 0; }
.word-card {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 24px 20px;
  box-shadow: var(--shadow-md); text-align: center; width: 100%; max-width: 480px;
}
.word-card.flip { animation: flipIn 0.35s ease; }
@keyframes flipIn { 0% { transform: rotateY(90deg); opacity: 0; } 100% { transform: rotateY(0); opacity: 1; } }
.card-word { font-size: 28px; font-weight: 800; margin-bottom: 4px; color: var(--text); }
.card-audio-row { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.card-phonetic { font-size: 14px; color: var(--text-secondary); }
.card-phonetic.clickable { cursor: pointer; transition: color 0.2s; }
.card-phonetic.clickable:hover { color: var(--primary); }
.accent-group { cursor: pointer; display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: var(--radius-sm); transition: background 0.2s; }
.accent-group:hover { background: var(--primary-bg); }
.accent-group:active { background: var(--primary-bg); opacity: 0.7; }
.btn-audio {
  background: none; border: 1.5px solid var(--border); border-radius: 50%;
  width: 30px; height: 30px; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all var(--transition);
}
.btn-accent { font-size: 12px; width: 26px; height: 26px; }
.btn-audio:hover { border-color: var(--primary); background: var(--primary-bg); }
.card-hint { font-size: 13px; color: var(--primary-light); margin-bottom: 4px; }
.card-answer { margin-top: 12px; padding-top: 12px; border-top: 2px dashed var(--border); }
.card-pos { font-size: 13px; color: var(--primary); font-weight: 600; margin-bottom: 4px; }
.card-meaning { font-size: 18px; font-weight: 600; line-height: 1.5; }

/* ========== Hooks ========== */
.card-hooks { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border-light); text-align: left; }
.hook-title { font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.hook-play { cursor: pointer; font-size: 13px; margin-left: 6px; opacity: 0.5; transition: opacity var(--transition); flex-shrink: 0; }
.hook-play:hover { opacity: 1; }
.hook-pos { color: var(--text-tertiary); font-size: 11px; font-style: italic; }
.hook-item { display: flex; gap: 6px; margin-bottom: 5px; font-size: 13px; line-height: 1.6; align-items: flex-start; }
.hook-label {
  background: var(--primary); color: white; font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 3px; white-space: nowrap; margin-top: 3px; flex-shrink: 0;
}
.hook-item:nth-child(2) .hook-label { background: #6366F1; }
.hook-item:nth-child(3) .hook-label { background: var(--success); }
.hook-item:nth-child(4) .hook-label { background: var(--warning); }
.hook-item:nth-child(5) .hook-label { background: #8B5CF6; }
.hook-item:nth-child(6) .hook-label { background: #0EA5E9; }
.hook-item:nth-child(7) .hook-label { background: #EC4899; }
.hook-item:nth-child(8) .hook-label { background: #14B8A6; }
.hook-item:nth-child(9) .hook-label { background: #F97316; }

.phrase-line { cursor: pointer; display: inline; }
.phrase-line:active { opacity: 0.7; }
.phrase-cn { color: var(--text-secondary); }
.btn-audio-sm { font-size: 12px; cursor: pointer; opacity: 0.5; vertical-align: middle; }
.hook-word {
  color: var(--primary); cursor: pointer; text-decoration: underline;
  text-decoration-style: dotted; text-underline-offset: 3px;
}
.hook-word:hover { color: var(--primary-dark); }

/* ========== Quiz Choices ========== */
.choices-toggle { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 2px 0 6px; cursor: pointer; user-select: none; color: var(--text-tertiary); font-size: 12px; }
.choices-toggle-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; }
.choices-toggle-label { font-size: 11px; }
.quiz-choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 500px; overflow: hidden; transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.3s ease; }
.quiz-choices.collapsed { max-height: 0; opacity: 0; margin-bottom: 0; pointer-events: none; }
.choice-btn {
  background: var(--card-bg); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; font-size: 14px; text-align: left; cursor: pointer;
  transition: all var(--transition); width: 100%; outline: none;
  -webkit-tap-highlight-color: transparent;
}
.choice-btn:focus-visible { border-color: var(--primary); }
@media (hover: hover) { .choice-btn:hover { border-color: var(--primary); background: var(--primary-bg); } }
.choice-btn.correct { border-color: var(--success); background: var(--success-bg); }
.choice-btn.wrong { border-color: var(--danger); background: var(--danger-bg); }

/* ========== Spelling ========== */
.quiz-spell { margin-bottom: 12px; }
.spell-difficulty { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; }
.spell-diff-btn { padding: 4px 14px; border: 1.5px solid var(--border); border-radius: 20px; background: var(--card-bg); color: var(--text-secondary); font-size: 13px; cursor: pointer; transition: all var(--transition); }
.spell-diff-btn.active { border-color: var(--primary); background: var(--primary); color: white; }
.spell-answer { display: flex; justify-content: center; gap: 3px; margin-bottom: 14px; flex-wrap: wrap; }
.spell-slot { width: 28px; height: 36px; display: flex; align-items: center; justify-content: center; border-bottom: 2px solid var(--border); font-size: 18px; font-weight: 600; transition: all 0.15s; }
.spell-slot.filled { border-bottom-color: var(--primary); cursor: pointer; }
.spell-slot.correct { border-bottom-color: var(--success); color: var(--success); }
.spell-slot.wrong { border-bottom-color: var(--danger); color: var(--danger); }
.spell-tiles { display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.spell-tile {
  width: 36px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: var(--card-bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 17px; font-weight: 600; cursor: pointer; transition: all 0.15s; user-select: none;
}
.spell-tile:active { transform: scale(0.9); background: var(--primary); color: white; border-color: var(--primary); }
.spell-tile.used { visibility: hidden; }
.spell-hint-row { display: flex; align-items: center; gap: 8px; }
.btn-hint {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn-hint:hover { border-color: var(--warning); }
.spell-hint-text { font-size: 13px; color: var(--warning); font-weight: 600; }

/* ========== Rating ========== */
.rating-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 280px; margin: 0 auto; }
.btn-rating {
  border: none; border-radius: var(--radius); padding: 14px 10px;
  font-size: 15px; font-weight: 700; cursor: pointer; transition: all var(--transition); color: white;
}
.btn-rating:active { transform: scale(0.95); }
.btn-again { background: var(--danger); }
.btn-hard { background: var(--warning); }
.btn-good { background: var(--primary); }
.btn-easy { background: var(--success); }

.show-answer-area { text-align: center; }
.continue-btn-area { text-align: center; margin-top: 10px; }

/* ========== Word List ========== */
.word-list { display: flex; flex-direction: column; gap: 6px; }
.word-item {
  background: var(--card-bg); border-radius: var(--radius); padding: 12px 14px;
  box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; transition: background var(--transition);
}
.word-item:active { background: var(--bg); }
.word-item .wi-word { font-weight: 700; font-size: 15px; }
.word-item .wi-phonetic { font-size: 12px; color: var(--text-secondary); }
.word-item .wi-meaning { font-size: 13px; color: var(--text-secondary); text-align: right; max-width: 55%; }
.wi-badge { font-size: 10px; padding: 2px 6px; border-radius: 10px; font-weight: 600; }
.badge-new { background: var(--primary-bg); color: var(--primary); }
.badge-learning { background: var(--warning-bg); color: #92400E; }
.badge-mastered { background: var(--success-bg); color: #065F46; }
.badge-difficult { background: var(--danger-bg); color: #991B1B; }

/* ========== Search ========== */
.search-bar { margin-bottom: 16px; }
.search-bar input {
  width: 100%; padding: 12px 16px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 15px; outline: none; background: var(--card-bg); transition: border-color var(--transition);
}
.search-bar input:focus { border-color: var(--primary); }

/* ========== Stats ========== */
#stats-detail .stat-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.stat-card-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.stat-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 14px; }
.stat-row:last-child { border: none; }

/* Overview cards */
.stats-overview {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px;
}
.stats-ov-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 16px 12px;
  text-align: center; box-shadow: var(--shadow);
}
.stats-ov-num { font-size: 28px; font-weight: 800; }
.stats-ov-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* Progress bar */
.stats-progress-bar {
  display: flex; height: 12px; border-radius: 6px; overflow: hidden;
  background: var(--border-light); margin-bottom: 10px;
}
.stats-prog-seg { transition: width 0.4s ease; }
.stats-prog-legend {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px;
}
.stats-legend-item { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.stats-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.stats-detail-rows { border-top: 1px solid var(--border-light); padding-top: 8px; }

/* Bar chart */
.stats-bar-chart {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 6px;
  padding: 0 4px;
}
.stats-bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; }
.stats-bar-num { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; min-height: 16px; }
.stats-bar-stack {
  width: 100%; display: flex; flex-direction: column-reverse;
  border-radius: 4px 4px 0 0; overflow: hidden;
}
.stats-bar-seg { width: 100%; transition: height 0.4s ease; }
.stats-bar-new { background: var(--primary); }
.stats-bar-review { background: var(--warning); }
.stats-bar-label { font-size: 11px; color: var(--text-tertiary); margin-top: 6px; }
.stats-bar-legend {
  display: flex; justify-content: center; gap: 16px; margin-top: 10px;
}

/* Heatmap */
.stats-heatmap {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.heat-cell {
  aspect-ratio: 1; border-radius: 3px; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.heat-date { font-size: 9px; color: var(--text-tertiary); }
.heat-0 { background: var(--border-light); }
.heat-1 { background: #C7D2FE; }
.heat-1 .heat-date { color: #4338CA; }
.heat-2 { background: #A5B4FC; }
.heat-2 .heat-date { color: #fff; }
.heat-3 { background: #818CF8; }
.heat-3 .heat-date { color: #fff; }
.heat-4 { background: #6366F1; }
.heat-4 .heat-date { color: #fff; }
.stats-heat-legend {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 3px; margin-top: 8px; font-size: 11px; color: var(--text-tertiary);
}

/* ========== Browse ========== */
.browse-controls { margin-bottom: 12px; }
.browse-filters, .browse-display { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.browse-filter-btn {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 12px; font-size: 12px; cursor: pointer; transition: all var(--transition);
}
.browse-filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.browse-filter-btn:hover { border-color: var(--primary); }
.browse-count { font-size: 12px; color: var(--text-tertiary); }
.browse-list { display: flex; flex-direction: column; gap: 4px; }
.browse-item {
  background: var(--card-bg); border-radius: var(--radius-sm); padding: 10px 12px;
  box-shadow: var(--shadow); cursor: pointer; border-left: 3px solid var(--border);
  transition: background var(--transition);
}
.browse-item:active { background: var(--bg); }
.browse-item.badge-new { border-left-color: var(--primary-light); }
.browse-item.badge-learning { border-left-color: var(--warning); }
.browse-item.badge-mastered { border-left-color: var(--success); }
.browse-item.badge-difficult { border-left-color: var(--danger); }
.browse-word { font-size: 15px; font-weight: 700; }
.browse-phonetic { font-size: 12px; color: var(--text-secondary); font-weight: 400; }
.browse-meaning { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.browse-loading { text-align: center; padding: 40px; color: var(--text-secondary); font-size: 15px; }

/* ========== Dictionary ========== */
/* Dict hero */
.dict-hero {
  text-align: center; padding: 16px 0 12px;
}
.dict-hero-icon { font-size: 36px; margin-bottom: 4px; }
.dict-hero-title { font-size: 18px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.dict-stats { text-align: center; color: var(--text-tertiary); font-size: 12px; padding: 0 0 4px; }
.dict-search-box { padding: 0 0 10px; position: relative; }
.search-input-wrap { position: relative; }
.search-input-wrap input {
  width: 100%; padding: 12px 44px 12px 16px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 15px; background: var(--card-bg); outline: none; transition: border-color var(--transition);
}
.search-input-wrap input:focus { border-color: var(--primary); }
.search-icon {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 16px; pointer-events: none; opacity: 0.5;
}
.dict-clear-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: var(--text-tertiary); color: #fff; border: none; border-radius: 50%;
  width: 20px; height: 20px; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Quick tags */
.dict-quick-tags {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 14px;
}
.dict-qtag {
  font-size: 12px; padding: 5px 12px; border-radius: 20px;
  background: var(--primary-bg); color: var(--primary); font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.dict-qtag:active { background: var(--primary); color: #fff; }

/* Dict results */
.dict-results { display: flex; flex-direction: column; gap: 10px; }
.dict-item {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 14px 16px;
  box-shadow: var(--shadow); cursor: pointer; transition: all var(--transition);
  border-left: 3px solid transparent;
}
.dict-item:active { background: var(--bg); }
.dict-item[data-oxford="1"] { border-left-color: var(--primary); }
.dict-word {
  font-size: 18px; font-weight: 700; color: var(--primary);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.dict-phonetic { font-size: 13px; font-weight: 400; color: var(--text-secondary); }
.dict-pos { font-size: 12px; color: var(--text-tertiary); margin: 3px 0; font-style: italic; }
.dict-trans { font-size: 14px; color: var(--text); line-height: 1.6; margin: 6px 0; }
.dict-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.dict-tag {
  font-size: 10px; padding: 2px 8px; border-radius: 4px;
  font-weight: 600; letter-spacing: 0.3px;
}
.dict-tag-exam { background: var(--primary); color: #fff; }
.dict-tag-collins { background: var(--warning-bg); color: #B45309; }
.dict-tag-oxford { background: var(--success-bg); color: #047857; }
.dict-freq {
  font-size: 11px; color: var(--text-tertiary); margin-top: 4px;
  display: flex; gap: 12px;
}
.dict-freq-item { display: flex; align-items: center; gap: 3px; }
.dict-freq-bar {
  width: 40px; height: 4px; background: var(--border-light); border-radius: 2px; overflow: hidden;
}
.dict-freq-fill { height: 100%; background: var(--primary); border-radius: 2px; }
.dict-empty {
  text-align: center; color: var(--text-secondary); padding: 40px 20px; font-size: 14px;
}
.btn-audio-sm { background: none; border: none; cursor: pointer; font-size: 14px; padding: 0; }

/* ========== Settings Page ========== */
.settings-page { max-width: 480px; }
.settings-group {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.settings-group-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--text); }
.setting-row { margin-bottom: 16px; }
.setting-row:last-child { margin-bottom: 0; }
.setting-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.setting-label-row label { margin-bottom: 0; }
.setting-row label { display: block; font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.setting-value { font-size: 14px; font-weight: 700; color: var(--primary); }
.setting-hint { font-size: 11px; color: var(--text-tertiary); margin-top: 6px; line-height: 1.4; }
.setting-options { display: flex; gap: 8px; flex-wrap: wrap; }
.setting-options button {
  background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); color: var(--text);
}
.setting-options button:hover { border-color: var(--primary); }
.setting-options button.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Toggle switch */
.setting-toggle { display: flex; justify-content: space-between; align-items: center; }
.setting-toggle label { margin-bottom: 0; }
.setting-toggle-info { flex: 1; min-width: 0; }
.setting-toggle-info label { margin-bottom: 0; }
.setting-toggle-info .setting-hint { margin-top: 2px; }

.toggle-switch { cursor: pointer; flex-shrink: 0; }
.toggle-track {
  width: 48px; height: 28px; border-radius: 14px;
  background: var(--border); position: relative;
  transition: background 0.25s ease;
}
.toggle-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; position: absolute; top: 3px; left: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.25s ease;
}
.toggle-switch.active .toggle-track { background: var(--primary); }
.toggle-switch.active .toggle-thumb { transform: translateX(20px); }

/* Action buttons in settings */
.setting-action-btn {
  background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--primary); transition: all var(--transition); flex-shrink: 0;
}
.setting-action-btn:active { opacity: 0.7; }
.setting-action-danger { color: var(--danger); border-color: var(--danger-bg); }
.setting-action-danger:active { background: var(--danger-bg); }

/* Old toggle-btn compat */
.toggle-btn {
  background: var(--bg); border: 1.5px solid var(--border); border-radius: 20px;
  padding: 5px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); color: var(--text-secondary);
}
.toggle-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ========== Splash Screen ========== */
.splash-screen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, #4F46E5 0%, #6366F1 50%, #818CF8 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 9999; transition: opacity 0.4s ease;
}
.splash-screen.fade-out { opacity: 0; pointer-events: none; }
.splash-icon { font-size: 64px; margin-bottom: 12px; animation: splash-bounce 1s ease infinite; }
@keyframes splash-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.splash-name { font-size: 28px; font-weight: 800; color: #fff; letter-spacing: 2px; }
.splash-sub { font-size: 14px; color: rgba(255,255,255,0.7); margin-top: 4px; letter-spacing: 1px; }
.splash-loader {
  width: 120px; height: 3px; background: rgba(255,255,255,0.2);
  border-radius: 2px; margin-top: 24px; overflow: hidden;
}
.splash-loader-bar {
  width: 40%; height: 100%; background: #fff; border-radius: 2px;
  animation: splash-load 1s ease-in-out infinite;
}
@keyframes splash-load {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ========== About Page ========== */
/* Help page */
.help-page { padding: 16px; max-width: 600px; margin: 0 auto; }
.help-header { text-align: center; padding: 20px 0 10px; }
.help-icon { font-size: 40px; margin-bottom: 8px; }
.help-title { font-size: 20px; font-weight: 700; color: var(--text); margin: 0; }
.help-subtitle { font-size: 13px; color: var(--text-secondary); margin: 6px 0 0; }
.help-section { margin-top: 28px; }
.help-section-title {
  font-size: 15px; font-weight: 700; color: var(--primary);
  margin-bottom: 14px; padding: 8px 12px;
  background: var(--card-bg); border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.help-item {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 12px; overflow: hidden; cursor: pointer; transition: box-shadow var(--transition);
}
.help-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.help-q {
  padding: 15px 16px; font-size: 14px; font-weight: 600; color: var(--text);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.help-q::after { content: '▸'; color: var(--text-secondary); transition: transform 0.2s; font-size: 12px; flex-shrink: 0; }
.help-item.open .help-q::after { transform: rotate(90deg); }
.help-item.open .help-q { border-bottom: 1px solid var(--border); }
.help-a {
  display: none; padding: 0 16px 16px; font-size: 13px; line-height: 1.8;
  color: var(--text-secondary);
}
.help-item.open .help-a { display: block; padding-top: 14px; }
.help-a p { margin: 0 0 10px; }
.help-a ul, .help-a ol { margin: 6px 0 12px 20px; padding: 0; }
.help-a li { margin-bottom: 6px; }
.help-a b { color: var(--text); }
.help-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.help-table th, .help-table td { padding: 10px 12px; border: 1px solid var(--border); text-align: center; }
.help-table th { background: var(--bg); font-weight: 600; color: var(--text); }
.help-table td { color: var(--text-secondary); }

.about-page { text-align: center; padding: 20px 0; max-width: 400px; margin: 0 auto; }
.about-logo { font-size: 72px; margin-bottom: 12px; filter: drop-shadow(0 4px 8px rgba(79,70,229,0.3)); }
.about-title { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.about-slogan { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.about-version {
  display: inline-block; font-size: 12px; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; padding: 4px 14px; border-radius: 20px; margin-bottom: 24px;
}
.about-card {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 4px 16px;
  box-shadow: var(--shadow); margin-bottom: 14px; text-align: left;
}
.about-card-title {
  font-size: 12px; font-weight: 700; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 12px 0 4px; border-bottom: 1px solid var(--border-light);
}
.about-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--border-light); font-size: 14px;
}
.about-row:last-child { border: none; }
.about-row span:first-child { color: var(--text-secondary); }
.about-row span:last-child { font-weight: 600; color: var(--text); }
.about-link { color: var(--primary) !important; font-size: 13px; }
.about-copyright { font-size: 12px; color: var(--text-tertiary); margin-top: 24px; line-height: 1.6; }

/* ========== Word Popup ========== */
.word-popup-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 400;
  justify-content: center; align-items: center;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.word-popup-overlay.active { display: flex; }
.word-popup-card {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 24px;
  max-width: 340px; width: 90%; text-align: center;
  box-shadow: var(--shadow-lg); animation: fadeIn 0.25s ease;
}
.popup-word { font-size: 26px; font-weight: 800; margin-bottom: 4px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.popup-phonetic { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.popup-pos { font-size: 13px; color: var(--primary); font-weight: 600; margin-bottom: 4px; }
.popup-meaning { font-size: 17px; font-weight: 600; line-height: 1.5; }

/* ========== Desktop Responsive ========== */
@media (min-width: 768px) {
  .sidebar {
    transform: translateX(0);
    position: fixed;
  }
  .sidebar-overlay { display: none !important; }
  .sidebar-close { display: none; }
  .btn-menu { display: none; }

  .main-content {
    margin-left: var(--sidebar-width);
  }

  .view { padding: 24px; }
  #view-study .study-header { padding: 12px 24px; }
  .study-scroll-area { padding: 0 24px; }
  .study-bottom-fixed { padding: 12px 24px; padding-bottom: max(16px, env(safe-area-inset-bottom, 16px)); left: var(--sidebar-width); }

  .decks-summary { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .summary-card { padding: 16px 12px; }
  .summary-num { font-size: 26px; }

  .dash-hero-card { max-width: 480px; margin-left: auto; margin-right: auto; }
  .dash-actions { max-width: 480px; margin-left: auto; margin-right: auto; }
  .dashboard-help { max-width: 480px; margin-left: auto; margin-right: auto; }

  .word-card { max-width: 560px; }
  .settings-page { max-width: 560px; }
}

@media (min-width: 1024px) {
  .view { padding: 28px 32px; max-width: 900px; }
  .dash-hero-card { max-width: 500px; }
  .dash-actions { max-width: 500px; }
}

/* ========== Mobile Tweaks ========== */
@media (max-width: 767px) {
  .decks-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 380px) {
  .summary-num { font-size: 18px; }
  .summary-label { font-size: 10px; }
  .deck-icon { width: 36px; height: 36px; font-size: 14px; }
  .rating-buttons { gap: 6px; }
  .btn-rating { padding: 12px 8px; font-size: 14px; }
}

/* Small-height screens: constrain bottom area */
@media (max-height: 700px) {
  .study-bottom-fixed {
    max-height: 45vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .quiz-choices { max-height: 28vh; overflow-y: auto; }
  .quiz-choices:not(.collapsed) { margin-bottom: 8px; }
  .study-scroll-area { padding-bottom: 200px !important; }
}

/* ========== Sidebar User Section ========== */
.sidebar-user {
  padding: 12px 0; border-bottom: 1px solid var(--border-light); margin-bottom: 8px;
}
.sidebar-user-login {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; cursor: pointer; color: var(--primary);
  font-size: 14px; font-weight: 600; transition: background var(--transition);
  border-radius: var(--radius-sm);
}
.sidebar-user-login:hover { background: var(--primary-bg); }
.sidebar-user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; cursor: pointer; transition: background var(--transition);
  border-radius: var(--radius-sm);
}
.sidebar-user-info:hover { background: var(--bg); }
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ========== Auth Page ========== */
.auth-page {
  max-width: 380px; margin: 0 auto; padding: 20px 0; text-align: center;
}
.auth-logo { font-size: 56px; margin-bottom: 8px; }
.auth-title {
  font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 24px;
}
.auth-tabs {
  display: flex; background: var(--bg); border-radius: var(--radius);
  padding: 4px; margin-bottom: 20px;
}
.auth-tab {
  flex: 1; padding: 10px; border: none; background: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: var(--radius-sm); color: var(--text-secondary);
  transition: all var(--transition);
}
.auth-tab.active {
  background: var(--card-bg); color: var(--primary);
  box-shadow: var(--shadow);
}
.auth-form { text-align: left; }
.auth-input-group { margin-bottom: 14px; }
.auth-input {
  width: 100%; padding: 14px 16px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 15px; background: var(--card-bg);
  outline: none; transition: border-color var(--transition);
  -webkit-appearance: none; appearance: none;
  box-sizing: border-box;
}
/* Fix: auth-input inside flex row must shrink properly */
.auth-input-group[style*="flex"] .auth-input,
.mem-redeem-row .auth-input,
div[style*="display:flex"] > .auth-input {
  width: auto; min-width: 0; flex: 1 1 0%;
}
.auth-input:focus { border-color: var(--primary); }
.auth-input::placeholder { color: var(--text-tertiary); }
.auth-error {
  background: var(--danger-bg); color: var(--danger); padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
  text-align: center;
}
.auth-submit { margin-top: 4px; }

/* ========== Profile Page ========== */
.profile-page { max-width: 420px; margin: 0 auto; }
.profile-header-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 24px 20px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; flex-shrink: 0;
}
.profile-info { flex: 1; min-width: 0; }
.profile-nickname { font-size: 18px; font-weight: 700; color: var(--text); }
.profile-email { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.profile-membership-card {
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  border-radius: var(--radius-lg); padding: 20px;
  color: #fff; margin-bottom: 14px; position: relative; overflow: hidden;
}
.profile-membership-card::after {
  content: '👑'; position: absolute; right: 16px; top: 12px;
  font-size: 36px; opacity: 0.2;
}
.profile-mem-label { font-size: 12px; opacity: 0.8; margin-bottom: 4px; }
.profile-mem-type { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.profile-mem-expire { font-size: 12px; opacity: 0.7; margin-bottom: 12px; }
.btn-upgrade {
  background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3);
  color: #fff; padding: 8px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background var(--transition);
}
.btn-upgrade:hover { background: rgba(255,255,255,0.3); }

.profile-section {
  background: var(--card-bg); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.profile-section-title {
  font-size: 12px; font-weight: 700; color: var(--text-tertiary);
  padding: 14px 20px 8px; text-transform: uppercase; letter-spacing: 1px;
}
.profile-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-top: 1px solid var(--border-light);
  cursor: pointer; font-size: 14px; color: var(--text);
  transition: background var(--transition);
}
.profile-row:hover { background: var(--bg); }
.profile-row-arrow { color: var(--text-tertiary); font-size: 16px; }

.btn-logout {
  width: 100%; padding: 14px; border: 1.5px solid var(--danger);
  border-radius: var(--radius); background: none; color: var(--danger);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); margin-top: 8px;
}
.btn-logout:hover { background: var(--danger-bg); }

/* ========== Membership Page ========== */
.membership-page { max-width: 480px; margin: 0 auto; }
.mem-hero { text-align: center; padding: 16px 0 20px; }
.mem-hero-icon { font-size: 48px; margin-bottom: 8px; }
.mem-hero-title { font-size: 22px; font-weight: 800; color: var(--text); }
.mem-hero-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.mem-plans { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.mem-plan-card {
  background: var(--card-bg); border: 2px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  cursor: pointer; transition: all var(--transition);
  position: relative; text-align: center;
}
.mem-plan-card:hover { border-color: var(--primary); }
.mem-plan-card:active { transform: scale(0.98); }
.mem-plan-popular {
  background: var(--primary-bg);
  border-color: var(--primary); box-shadow: 0 4px 16px rgba(79,70,229,0.15);
}
.mem-plan-badge {
  position: absolute; top: -1px; right: 20px;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: #fff; font-size: 11px; font-weight: 700;
  padding: 4px 12px; border-radius: 0 0 8px 8px;
}
.mem-plan-name { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.mem-plan-price {
  font-size: 32px; font-weight: 800; color: var(--primary);
}
.mem-plan-price span { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.mem-plan-desc { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }

.mem-compare {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.mem-compare-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.mem-compare-header {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  padding: 10px 0; border-bottom: 2px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
}
.mem-compare-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--border-light);
  font-size: 13px; color: var(--text);
}
.mem-compare-row:last-child { border: none; }
.mem-vip { color: var(--primary); font-weight: 700; }

/* ========== New Membership Styles ========== */
.mem-current-status {
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  border-radius: var(--radius-lg); padding: 20px; text-align: center;
  color: #fff; margin-bottom: 20px;
}
.mem-current-label { font-size: 12px; opacity: 0.8; margin-bottom: 4px; }
.mem-current-type { font-size: 22px; font-weight: 800; }
.mem-current-expire { font-size: 13px; opacity: 0.8; margin-top: 4px; }

.mem-plan-active { border-color: var(--success) !important; box-shadow: 0 0 0 2px var(--success) !important; }

.mem-redeem-section {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.mem-redeem-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.mem-redeem-row { display: flex; gap: 8px; align-items: center; }

.mem-faq {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow); margin-top: 20px;
}
.mem-faq-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; color: var(--text); }

/* ========== Banner Expiry Styles ========== */
.banner-expired {
  background: linear-gradient(135deg, #EF4444, #DC2626) !important;
  color: #fff !important;
}
.banner-expired a { color: #FEF2F2 !important; font-weight: 700; text-decoration: underline; }

.banner-expiring {
  background: linear-gradient(135deg, #F59E0B, #D97706) !important;
  color: #fff !important;
}
.banner-expiring a { color: #FFFBEB !important; font-weight: 700; text-decoration: underline; }

/* ========== Hook Editing ========== */
.hook-edit-btn {
  cursor: pointer;
  font-size: 14px;
  margin-left: 6px;
  opacity: 0.5;
  transition: opacity 0.2s;
  display: inline-block;
  vertical-align: middle;
}
.hook-edit-btn:hover { opacity: 1; }
.hook-item { position: relative; }
.hook-custom-badge {
  display: inline-block;
  font-size: 10px;
  background: var(--primary-bg, rgba(79,70,229,0.1));
  color: var(--primary, #4F46E5);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 600;
}
.hook-edit-container {
  margin-top: 6px;
}
.hook-edit-textarea {
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 2px solid var(--primary, #4F46E5);
  border-radius: 8px;
  background: var(--card-bg, #1E293B);
  color: var(--text, #F1F5F9);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}
.hook-edit-textarea:focus {
  border-color: var(--primary, #4F46E5);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
.hook-edit-btns {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.hook-edit-save, .hook-edit-cancel, .hook-edit-delete {
  padding: 4px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.hook-edit-save {
  background: var(--primary, #4F46E5);
  color: #fff;
}
.hook-edit-save:hover { opacity: 0.85; }
.hook-edit-cancel {
  background: var(--border, #334155);
  color: var(--text-secondary, #94A3B8);
}
.hook-edit-cancel:hover { opacity: 0.85; }
.hook-edit-delete {
  background: transparent;
  color: var(--danger, #EF4444);
  border: 1px solid var(--danger, #EF4444);
  margin-left: auto;
}
.hook-edit-delete:hover { background: rgba(239,68,68,0.1); }
.hook-admin-tip {
  font-size: 11px;
  color: var(--warning, #F59E0B);
  margin-bottom: 4px;
  font-weight: 600;
}
.hook-edit-tip {
  font-size: 12px;
  color: var(--text-secondary, #888);
  margin-bottom: 6px;
  line-height: 1.5;
}

/* ========== Modal Overlay ========== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 500;
  justify-content: center; align-items: center;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal-card {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 24px; width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg); animation: fadeIn 0.25s ease;
  max-height: 90vh; overflow-y: auto;
}
.modal-title {
  font-size: 18px; font-weight: 800; color: var(--text);
  margin-bottom: 16px; text-align: center;
}
.modal-input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 14px; background: var(--bg);
  color: var(--text); outline: none; transition: border-color var(--transition);
  box-sizing: border-box;
}
.modal-input:focus { border-color: var(--primary); }
.modal-input::placeholder { color: var(--text-tertiary); }
.modal-textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 14px; background: var(--bg);
  color: var(--text); outline: none; resize: vertical; min-height: 80px;
  font-family: inherit; transition: border-color var(--transition);
  box-sizing: border-box;
}
.modal-textarea:focus { border-color: var(--primary); }
.modal-label {
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 6px; display: block;
}
.modal-field { margin-bottom: 14px; }
.modal-btns { display: flex; gap: 10px; margin-top: 18px; }
.modal-btns .btn-primary { flex: 1; }
.modal-btns .btn-secondary { flex: 1; }

/* ========== Deck Detail / Management ========== */
.deck-detail-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}
.deck-detail-title { font-size: 18px; font-weight: 800; color: var(--text); flex: 1; }
.deck-detail-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

/* Empty state */
.empty-state {
  text-align: center; padding: 48px 20px;
}
.empty-state-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.6; }
.empty-state-title {
  font-size: 18px; font-weight: 700; color: var(--text);
  margin-bottom: 8px;
}
.empty-state-desc {
  font-size: 14px; color: var(--text-secondary);
  margin-bottom: 28px; line-height: 1.6;
}
.empty-state-actions {
  display: flex; flex-direction: column; gap: 12px;
  max-width: 320px; margin: 0 auto;
}
.empty-action-btn {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-bg); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  cursor: pointer; transition: all var(--transition);
  text-align: left;
}
.empty-action-btn:hover { border-color: var(--primary); background: var(--primary-bg); }
.empty-action-btn:active { transform: scale(0.98); }
.empty-action-icon { font-size: 24px; flex-shrink: 0; }
.empty-action-info { flex: 1; }
.empty-action-title { font-size: 15px; font-weight: 700; color: var(--text); }
.empty-action-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Deck manage tabs */
.deck-manage-tabs {
  display: flex; background: var(--bg); border-radius: var(--radius);
  padding: 3px; margin-bottom: 16px; overflow-x: auto;
}
.deck-manage-tab {
  flex: 1; padding: 10px 8px; border: none; background: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border-radius: var(--radius-sm); color: var(--text-secondary);
  transition: all var(--transition); white-space: nowrap; text-align: center;
}
.deck-manage-tab.active {
  background: var(--card-bg); color: var(--primary);
  box-shadow: var(--shadow);
}

/* Word form */
.word-form { margin-bottom: 16px; }
.word-form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 10px;
}
.word-form-row.full { grid-template-columns: 1fr; }
.word-form-hint {
  font-size: 11px; color: var(--text-tertiary); margin-top: 4px;
}

/* Added words list */
.added-words-list {
  margin-top: 16px; border-top: 1px solid var(--border-light); padding-top: 12px;
}
.added-words-title {
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  margin-bottom: 8px;
}
.added-word-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.added-word-item:last-child { border-bottom: none; }
.added-word-en { font-weight: 700; color: var(--text); min-width: 80px; }
.added-word-cn { color: var(--text-secondary); flex: 1; }
.added-word-actions { display: flex; gap: 4px; }
.added-word-btn {
  background: none; border: none; cursor: pointer; font-size: 14px;
  padding: 2px 6px; border-radius: 4px; transition: background var(--transition);
}
.added-word-btn:hover { background: var(--bg); }
.added-word-btn.danger:hover { background: var(--danger-bg); }

/* Batch import */
.batch-import-area { margin-bottom: 16px; }
.batch-textarea {
  width: 100%; min-height: 150px; padding: 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 13px; font-family: 'Courier New', monospace;
  background: var(--bg); color: var(--text); resize: vertical; outline: none;
  box-sizing: border-box; line-height: 1.6;
}
.batch-textarea:focus { border-color: var(--primary); }
.batch-format-hint {
  font-size: 12px; color: var(--text-tertiary); margin-top: 8px; line-height: 1.6;
}
.batch-preview {
  margin-top: 12px; background: var(--card-bg); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow); max-height: 300px; overflow-y: auto;
}
.batch-preview-title {
  font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px;
}
.batch-preview-item {
  display: flex; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--border-light); font-size: 13px;
}
.batch-preview-item:last-child { border-bottom: none; }
.batch-preview-word { font-weight: 600; color: var(--primary); min-width: 80px; }
.batch-preview-meaning { color: var(--text-secondary); flex: 1; }
.batch-preview-status { font-size: 11px; color: var(--text-tertiary); }

/* Dict search add */
.dict-add-search {
  position: relative; margin-bottom: 16px;
}
.dict-add-results {
  display: flex; flex-direction: column; gap: 8px;
}
.dict-add-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  transition: all var(--transition);
}
.dict-add-info { flex: 1; min-width: 0; }
.dict-add-word { font-size: 15px; font-weight: 700; color: var(--text); }
.dict-add-phonetic { font-size: 12px; color: var(--text-secondary); margin-left: 6px; }
.dict-add-trans { font-size: 13px; color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dict-add-btn {
  padding: 6px 14px; border-radius: var(--radius-sm); font-size: 13px;
  font-weight: 600; border: 1.5px solid var(--primary); background: none;
  color: var(--primary); cursor: pointer; transition: all var(--transition);
  white-space: nowrap; flex-shrink: 0;
}
.dict-add-btn:hover { background: var(--primary); color: #fff; }
.dict-add-btn.added {
  border-color: var(--success); color: var(--success);
  pointer-events: none; background: var(--success-bg);
}

/* Deck word list management */
.deck-word-list { display: flex; flex-direction: column; gap: 4px; }
.deck-word-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-bg); border-radius: var(--radius-sm);
  padding: 10px 12px; box-shadow: var(--shadow);
  transition: background var(--transition);
}
.deck-word-info { flex: 1; min-width: 0; }
.deck-word-en { font-size: 15px; font-weight: 700; color: var(--text); }
.deck-word-phonetic { font-size: 12px; color: var(--text-secondary); margin-left: 6px; }
.deck-word-cn { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.deck-word-actions { display: flex; gap: 4px; flex-shrink: 0; }
.deck-word-action-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-size: 13px; cursor: pointer;
  transition: all var(--transition);
}
.deck-word-action-btn:hover { border-color: var(--primary); background: var(--primary-bg); }
.deck-word-action-btn.danger { color: var(--danger); }
.deck-word-action-btn.danger:hover { border-color: var(--danger); background: var(--danger-bg); }

/* Deck danger zone */
.deck-danger-zone {
  margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--danger-bg);
}
.deck-danger-title {
  font-size: 13px; font-weight: 700; color: var(--danger);
  margin-bottom: 10px;
}

/* Word count badge */
.word-count-badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  background: var(--primary-bg); color: var(--primary);
  padding: 2px 10px; border-radius: 12px; margin-left: 8px;
}

/* Confirm dialog */
.confirm-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 600;
  justify-content: center; align-items: center;
  backdrop-filter: blur(3px); padding: 16px;
}
.confirm-overlay.active { display: flex; }
.confirm-card {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 24px; width: 100%; max-width: 340px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.confirm-icon { font-size: 40px; margin-bottom: 12px; }
.confirm-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.confirm-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.6; }
.confirm-btns { display: flex; gap: 10px; }
.confirm-btns button { flex: 1; }
.btn-danger {
  background: var(--danger); color: white; border: none;
  padding: 12px 24px; border-radius: var(--radius); font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all var(--transition);
}
.btn-danger:hover { opacity: 0.9; }

/* Edit word modal */
.edit-word-form .modal-field { margin-bottom: 12px; }

/* ========== Onboarding Welcome ========== */
.onboarding-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10000;
  background: var(--bg); overflow: hidden;
}
.onboarding-slides {
  display: flex; width: 500%; height: 100%; transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.onboarding-slide {
  width: 20%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; padding: 60px 28px 40px; text-align: center;
  position: relative; overflow-y: auto;
}
.ob-emoji { font-size: 64px; margin-bottom: 16px; animation: obPulse 2s ease-in-out infinite; }
@keyframes obPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.ob-title {
  font-size: 28px; font-weight: 800; color: var(--text); margin-bottom: 12px;
  line-height: 1.3; letter-spacing: -0.5px;
}
.ob-subtitle {
  font-size: 15px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 24px;
  max-width: 320px;
}
.ob-highlight { color: var(--primary); font-weight: 700; }
.ob-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin: 8px 0; width: 100%; max-width: 320px; text-align: left;
}
.ob-card-title { font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.ob-card-text { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.ob-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px;
  width: 100%; max-width: 320px; margin: 16px 0;
}
.ob-stat {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 8px; text-align: center;
}
.ob-stat-num { font-size: 24px; font-weight: 800; color: var(--primary); }
.ob-stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
.ob-flow {
  display: flex; align-items: center; gap: 6px; margin: 16px 0;
  flex-wrap: wrap; justify-content: center;
}
.ob-flow-step {
  background: var(--primary-bg); color: var(--primary); padding: 6px 12px;
  border-radius: 20px; font-size: 13px; font-weight: 600;
}
.ob-flow-arrow { color: var(--text-tertiary); font-size: 16px; }
.ob-dots { display: flex; gap: 8px; margin: 24px 0; }
.ob-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--border);
  transition: all 0.3s;
}
.ob-dot.active { background: var(--primary); width: 24px; border-radius: 4px; }
.ob-btn-primary {
  background: var(--primary); color: #fff; border: none; border-radius: var(--radius);
  padding: 14px 48px; font-size: 16px; font-weight: 700; cursor: pointer;
  transition: all 0.2s; margin-top: 8px; min-width: 200px;
}
.ob-btn-primary:active { transform: scale(0.97); opacity: 0.9; }
.ob-btn-skip {
  background: none; border: none; color: var(--text-tertiary); font-size: 13px;
  cursor: pointer; margin-top: 12px; padding: 8px 16px;
}
.ob-goals {
  display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; margin: 12px 0;
}
.ob-goal {
  background: var(--card-bg); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 12px; text-align: left;
}
.ob-goal:active, .ob-goal.selected { border-color: var(--primary); background: var(--primary-bg); }
.ob-goal-emoji { font-size: 24px; }
.ob-goal-text { font-size: 14px; font-weight: 600; color: var(--text); }
.ob-goal-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ========== Onboarding Vocab Test ========== */
.ob-test-word {
  font-size: 32px; font-weight: 800; color: var(--text); margin: 16px 0 8px;
  letter-spacing: -0.5px;
}
.ob-test-progress {
  font-size: 12px; color: var(--text-tertiary); margin-bottom: 16px;
}
.ob-test-progress-bar {
  width: 200px; height: 4px; background: var(--border); border-radius: 2px;
  margin: 8px auto; overflow: hidden;
}
.ob-test-progress-fill {
  height: 100%; background: var(--primary); border-radius: 2px;
  transition: width 0.3s ease;
}
.ob-test-choices {
  display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 320px;
}
.ob-test-choice {
  background: var(--card-bg); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; cursor: pointer; transition: all 0.15s;
  font-size: 14px; color: var(--text); text-align: left;
}
.ob-test-choice:active { transform: scale(0.98); }
.ob-test-choice.correct { border-color: #10B981; background: rgba(16,185,129,0.1); }
.ob-test-choice.wrong { border-color: #EF4444; background: rgba(239,68,68,0.1); }
.ob-test-skip {
  background: none; border: none; color: var(--text-tertiary); font-size: 12px;
  cursor: pointer; margin-top: 8px; padding: 6px 12px;
}
.ob-result-level {
  font-size: 48px; font-weight: 900; color: var(--primary);
  background: var(--primary-bg); width: 80px; height: 80px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.ob-result-bar {
  width: 100%; max-width: 280px; height: 8px; background: var(--border);
  border-radius: 4px; margin: 12px auto; overflow: hidden; position: relative;
}
.ob-result-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #EF4444, #F59E0B, #10B981, #6366F1);
}
.ob-result-marker {
  position: absolute; top: -4px; width: 4px; height: 16px;
  background: var(--text); border-radius: 2px;
}
.ob-result-labels {
  display: flex; justify-content: space-between; width: 100%; max-width: 280px;
  font-size: 10px; color: var(--text-tertiary); margin-bottom: 16px;
}

/* ========== 考试模式 ========== */
.exam-countdown {
  margin-top: 16px; font-size: 18px; font-weight: 700;
  color: var(--text-secondary); transition: color 0.3s;
}
.quiz-choices-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 0 4px;
}
.quiz-choices-grid .quiz-choice-btn {
  padding: 14px 12px; border-radius: var(--radius); border: 2px solid var(--border);
  background: var(--card-bg); font-size: 15px; cursor: pointer;
  transition: all 0.2s; text-align: center; word-break: break-word;
}
.quiz-choices-grid .quiz-choice-btn:active { transform: scale(0.97); }
.quiz-choices-grid .quiz-choice-btn.correct {
  border-color: #27ae60; background: rgba(39,174,96,0.12); color: #27ae60; font-weight: 700;
}
.quiz-choices-grid .quiz-choice-btn.wrong {
  border-color: #e74c3c; background: rgba(231,76,60,0.12); color: #e74c3c;
}

/* exam setup selected state */
.exam-count-btn.active,
.exam-time-btn.active {
  border-color: var(--primary) !important;
  background: linear-gradient(135deg, var(--primary-bg), rgba(99,102,241,0.14)) !important;
  color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.18);
}

.dash-btn-exam {
  background: var(--card-bg) !important;
  border: 1px solid var(--border) !important;
}
.exam-wrong-list {
  display: flex; flex-direction: column; gap: 8px;
}
.exam-wrong-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--card-bg); border-radius: var(--radius);
  border-left: 3px solid #e74c3c;
}
.exam-wrong-word { font-weight: 700; font-size: 15px; }
.exam-wrong-meaning { font-size: 13px; color: var(--text-secondary); text-align: right; max-width: 55%; }

/* ===== exam enhancements ===== */
.exam-count-btn.active,
.exam-time-btn.active,
.exam-mode-btn.active,
.exam-diff-btn.active {
  border-color: var(--primary) !important;
  background: linear-gradient(135deg, var(--primary-bg), rgba(99,102,241,0.14)) !important;
  color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.18);
}

.exam-countdown-bar {
  margin-top: 8px;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.exam-countdown-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22c55e, #f59e0b, #ef4444);
  transition: width 1s linear;
}

.exam-adv-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--card-bg);
  border: 1px solid var(--border);
  text-align: left;
}
.exam-adv-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.exam-mode-chips, .exam-top-wrongs { display: flex; flex-wrap: wrap; gap: 8px; }
.exam-mode-chip, .exam-top-wrong-item {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(99,102,241,0.10);
  color: var(--text);
  font-size: 12px;
}
.exam-weak-hint { margin-top: 8px; font-size: 13px; color: var(--text-secondary); }

.exam-history-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.exam-history-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.exam-history-title { font-weight: 700; font-size: 15px; }
.exam-history-score { font-size: 18px; font-weight: 800; }
.exam-history-meta { margin-top: 6px; color: var(--text-secondary); font-size: 12px; }
.exam-history-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.exam-history-tag {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}


.exam-mode-btn,
.exam-diff-btn,
.exam-count-btn,
.exam-time-btn {
  min-width: 72px;
}
.exam-mode-btn.active,
.exam-diff-btn.active,
.exam-count-btn.active,
.exam-time-btn.active {
  transform: scale(1.03);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

/* ===== exam trend chart (round 3) ===== */
.exam-trend-wrap { margin-top: 10px; }
.exam-trend-title { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.exam-trend-bars {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  height: 120px;
  padding: 8px;
  background: rgba(99,102,241,0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.exam-trend-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
}
.exam-trend-bar {
  width: 100%;
  min-height: 6px;
  border-radius: 6px 6px 2px 2px;
  transition: height .2s ease;
}
.exam-trend-num {
  font-size: 10px;
  color: var(--text-tertiary);
  line-height: 1;
}

/* Listen mode karaoke highlight */
.listen-k-prefix { color: var(--text-secondary); font-weight: 600; }
.listen-k-unit { color: var(--text-secondary); opacity: 0.7; }
.listen-k-sep { color: #8aa; opacity: 0.6; }
.listen-k-active {
  color: var(--primary);
  font-weight: 800;
  background: rgba(99,102,241,0.12);
  border-radius: 8px;
  padding: 2px 6px;
}
