/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-family, 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif);
  background: var(--bg-color, #f0f4f8);
  color: var(--text-color, #333);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ===== CSS Variables (defaults, overridden by JS) ===== */
:root {
  --bg-color: #f0f4f8;
  --bg-gradient: linear-gradient(135deg, #e8f0fe 0%, #f5f0ff 100%);
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --card-border: #e8ecf1;
  --text-color: #2d3748;
  --text-secondary: #718096;
  --text-light: #a0aec0;
  --primary: #4a90d9;
  --primary-light: #6ab0e9;
  --primary-dark: #357abd;
  --accent: #ffd700;
  --success: #48bb78;
  --warning: #ed8936;
  --danger: #e53e3e;
  --button-bg: #4a90d9;
  --button-text: #ffffff;
  --button-hover: #357abd;
  --border-radius: 16px;
  --border-radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --font-family: 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
  --sidebar-width: 220px;
  --nav-height: 64px;
}

/* ===== Layout ===== */
#app { min-height: 100vh; }

.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px 16px 12px;
  text-align: center;
  border-bottom: 1px solid var(--card-border);
}

.sidebar-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.sidebar-user {
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-color);
  cursor: pointer;
  transition: background 0.2s;
}
.user-card:hover { background: var(--primary-light); }
.user-card.active { background: var(--primary); color: var(--button-text); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700;
  flex-shrink: 0;
}

/* ===== Avatar Grid ===== */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.avatar-option {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-color, #f5f5f5);
}
.avatar-option:hover {
  transform: scale(1.1);
  border-color: var(--primary, #4a90d9);
}
.avatar-option.active {
  border-color: var(--primary, #4a90d9);
  background: color-mix(in srgb, var(--primary, #4a90d9) 15%, transparent);
  transform: scale(1.05);
}
@media (max-width: 480px) {
  .avatar-option { width: 40px; height: 40px; font-size: 1.4rem; }
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 0.9rem; }
.user-grade { font-size: 0.75rem; opacity: 0.7; }

.nav-list { flex: 1; padding: 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 2px;
  font-size: 0.9rem;
}
.nav-item:hover { background: var(--bg-color); }
.nav-item.active { background: var(--primary); color: var(--button-text); font-weight: 600; }
.nav-item .nav-icon { font-size: 1.2rem; flex-shrink: 0; width: 24px; text-align: center; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 20px;
  max-width: 100%;
  min-height: 100vh;
}

/* ===== Mobile Bottom Nav ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--sidebar-bg);
  border-top: 1px solid var(--card-border);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.7rem;
}
.bottom-nav-item.active { color: var(--primary); font-weight: 600; }
.bottom-nav-item .nav-icon { font-size: 1.3rem; }

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid var(--card-border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.module-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
.module-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.module-card:active { transform: translateY(-1px); }

.module-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 12px;
  background: var(--primary);
  color: #fff;
}

.module-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.module-desc { font-size: 0.82rem; color: var(--text-secondary); }
.module-badge {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

/* ===== Grid ===== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
  border: 2px solid transparent;
  min-height: 44px;
}
.btn-primary { background: var(--button-bg); color: var(--button-text); }
.btn-primary:hover { background: var(--button-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--bg-color); color: var(--text-color); border-color: var(--card-border); }
.btn-secondary:hover { background: var(--card-border); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.9); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: var(--button-text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; min-height: 36px; }
.btn-lg { padding: 14px 28px; font-size: 1rem; min-height: 52px; }
.btn-block { width: 100%; }

/* ===== Page Header ===== */
.page-header {
  margin-bottom: 20px;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text-color); }
.page-subtitle { font-size: 0.9rem; color: var(--text-secondary); margin-top: 4px; }

/* ===== Task Card ===== */
.task-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all 0.2s;
}
.task-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.task-card.completed { border-color: var(--success); }
.task-card.completed::after {
  content: '\2713 \5DF2\5B8C\6210';
  position: absolute;
  top: 8px; right: 8px;
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 600;
}

.task-name { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.task-meta { display: flex; gap: 12px; font-size: 0.78rem; color: var(--text-secondary); flex-wrap: wrap; }
.task-points {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--accent); color: #fff;
  padding: 2px 8px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 700;
}

/* ===== Task Detail ===== */
.task-detail-header {
  margin-bottom: 20px;
}
.task-detail-title { font-size: 1.3rem; font-weight: 700; }
.task-detail-goal {
  background: var(--bg-color);
  border-radius: var(--border-radius-sm);
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 0.9rem;
}
.task-detail-meta {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 0.82rem; color: var(--text-secondary);
  margin-bottom: 8px;
}
.task-hint {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 10px 14px;
  background: rgba(255, 215, 0, 0.12);
  border-left: 3px solid var(--accent);
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  margin: 12px 0;
}

/* ===== Quiz ===== */
.quiz-question {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}
.quiz-q-text { font-size: 0.95rem; font-weight: 600; margin-bottom: 10px; }
.quiz-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  font-size: 1rem;
  background: var(--bg-color);
  color: var(--text-color);
  transition: border-color 0.2s;
}
.quiz-input:focus { outline: none; border-color: var(--primary); }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  padding: 10px 14px;
  border: 2px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}
.quiz-option:hover { border-color: var(--primary); background: var(--bg-color); }
.quiz-option.selected { border-color: var(--primary); background: var(--primary); color: #fff; }
.quiz-option.correct { border-color: var(--success); background: var(--success); color: #fff; }
.quiz-option.wrong { border-color: var(--danger); background: var(--danger); color: #fff; }
.quiz-feedback { font-size: 0.85rem; margin-top: 8px; padding: 8px 12px; border-radius: var(--border-radius-sm); }
.quiz-feedback.correct { background: rgba(72, 187, 120, 0.15); color: var(--success); }
.quiz-feedback.wrong { background: rgba(229, 62, 62, 0.1); color: var(--danger); }

/* ===== Flashcard ===== */
.flashcard-container { perspective: 1000px; }
.flashcard {
  width: 100%;
  max-width: 400px;
  height: 240px;
  margin: 0 auto 16px;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  width: 100%; height: 100%;
  border-radius: var(--border-radius);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  backface-visibility: hidden;
  box-shadow: var(--shadow-lg);
}
.flashcard-front { background: var(--primary); color: #fff; }
.flashcard-back { background: var(--card-bg); color: var(--text-color); transform: rotateY(180deg); border: 2px solid var(--primary); }
.flashcard-content { font-size: 1.5rem; font-weight: 700; text-align: center; }
.flashcard-sub { font-size: 0.85rem; margin-top: 8px; opacity: 0.8; }

/* ===== Timer ===== */
.timer-display {
  font-size: 3rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  margin: 20px 0;
}
.timer-controls { display: flex; gap: 10px; justify-content: center; }

/* ===== Checklist ===== */
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-color);
  margin-bottom: 8px;
  transition: all 0.2s;
}
.checklist-item.checked { background: rgba(72, 187, 120, 0.12); }
.checklist-checkbox {
  width: 24px; height: 24px;
  border: 2px solid var(--card-border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.checklist-checkbox.checked { background: var(--success); border-color: var(--success); color: #fff; }
.checklist-text { flex: 1; font-size: 0.9rem; }
.checklist-item.checked .checklist-text { text-decoration: line-through; opacity: 0.6; }

/* ===== Counter ===== */
.counter-display {
  font-size: 4rem;
  font-weight: 700;
  text-align: center;
  color: var(--primary);
  margin: 20px 0;
}
.counter-controls { display: flex; gap: 12px; justify-content: center; }
.counter-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.counter-btn:hover { transform: scale(1.1); }
.counter-btn:active { transform: scale(0.95); }
.counter-target { text-align: center; color: var(--text-secondary); font-size: 0.85rem; }

/* ===== Canvas ===== */
.draw-canvas {
  width: 100%;
  max-width: 500px;
  border: 2px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  background: #fff;
  cursor: crosshair;
  touch-action: none;
  display: block;
  margin: 0 auto;
}
.color-palette { display: flex; gap: 8px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.color-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s;
}
.color-swatch.active { border-color: var(--text-color); transform: scale(1.15); }

/* ===== Input Area ===== */
.text-input-area {
  width: 100%;
  min-height: 120px;
  padding: 14px;
  border: 2px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  background: var(--bg-color);
  color: var(--text-color);
  resize: vertical;
  transition: border-color 0.2s;
}
.text-input-area:focus { outline: none; border-color: var(--primary); }

/* ===== Points Display ===== */
.points-display {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
}

/* ===== Reward Card ===== */
.reward-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border: 1px solid var(--card-border);
  text-align: center;
  transition: all 0.2s;
}
.reward-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.reward-icon { font-size: 2rem; margin-bottom: 8px; }
.reward-name { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.reward-cost { font-size: 0.85rem; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.reward-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.reward-status.available { background: rgba(72, 187, 120, 0.15); color: var(--success); }
.reward-status.insufficient { background: rgba(160, 174, 192, 0.15); color: var(--text-light); }
.reward-status.pending { background: rgba(237, 137, 54, 0.15); color: var(--warning); }
.reward-status.confirmed { background: rgba(72, 187, 120, 0.15); color: var(--success); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  transform: translateY(20px);
  transition: transform 0.3s;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 1.2rem; font-weight: 700; }
.modal-close { font-size: 1.5rem; cursor: pointer; color: var(--text-secondary); padding: 4px 8px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--text-color);
  color: var(--card-bg);
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  z-index: 300;
  transition: transform 0.3s;
  box-shadow: var(--shadow-lg);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.info { background: var(--primary); color: #fff; }

/* ===== Progress Bar ===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--card-border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ===== Home Stats ===== */
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-card {
  flex: 1;
  min-width: 120px;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--card-border);
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }

/* ===== Theme/Style Selectors ===== */
.selector-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; margin: 12px 0; }
.selector-item {
  padding: 10px;
  border: 2px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-size: 0.82rem;
}
.selector-item:hover { border-color: var(--primary); }
.selector-item.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.selector-preview {
  width: 100%; height: 40px;
  border-radius: var(--border-radius-sm);
  margin-bottom: 6px;
}

/* ===== Parent Center ===== */
.parent-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-color);
  margin-bottom: 8px;
}
.parent-user-info { flex: 1; }
.parent-user-name { font-weight: 600; }
.parent-user-stats { font-size: 0.8rem; color: var(--text-secondary); }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(0.8); opacity: 0; } 60% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }
@keyframes pointsFloat { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-40px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.fade-in { animation: fadeIn 0.4s ease; }
.slide-up { animation: slideUp 0.4s ease; }
.pop-in { animation: pop 0.4s ease; }
.pulse { animation: pulse 2s ease infinite; }

.points-float {
  position: absolute;
  font-weight: 700;
  color: var(--accent);
  pointer-events: none;
  animation: pointsFloat 1.5s ease forwards;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content {
    margin-left: 0;
    padding: 12px;
    padding-bottom: calc(var(--nav-height) + 16px);
  }
  .bottom-nav { display: flex; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .page-title { font-size: 1.2rem; }
  .stat-value { font-size: 1.4rem; }
  .flashcard { height: 200px; }
  .timer-display { font-size: 2.2rem; }
  .counter-display { font-size: 3rem; }
}

@media (max-width: 390px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .module-card { padding: 14px; }
  .module-icon { width: 44px; height: 44px; font-size: 1.3rem; }
  .module-title { font-size: 0.9rem; }
  .module-desc { font-size: 0.75rem; }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .flashcard { transition: none; }
  .tts-pulse { animation: none; }
  .tts-controller { transition: none; }
}

/* ===== Voice Settings ===== */
.voice-list { display: flex; flex-direction: column; gap: 6px; }
.voice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid var(--border, #e0e0e0);
  background: var(--surface, #fff);
  cursor: pointer;
  transition: all 0.2s ease;
}
.voice-item.active {
  border-color: var(--primary, #4a90d9);
  background: color-mix(in srgb, var(--primary, #4a90d9) 8%, transparent);
}
.voice-item:active { transform: scale(0.99); }
.voice-info { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; flex-wrap: wrap; }
.voice-name { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.voice-badge-neural { background: #e8f5e9; color: #2e7d32; }
.voice-badge-standard { background: #f5f5f5; color: #757575; }
.voice-badge-auto { background: #e3f2fd; color: #1565c0; }
.voice-badge-warn { background: #fff3e0; color: #e65100; }
.voice-badge-danger { background: #ffebee; color: #c62828; }
.voice-group-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 8px 0 4px 0;
  padding-left: 4px;
}
.voice-group-warn { color: #e65100; }
@media (max-width: 480px) {
  .voice-name { font-size: 0.78rem; }
  .voice-item { padding: 8px 10px; }
}

/* ===== TTS Controller Bar ===== */
.tts-controller {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--surface, #ffffff);
  border-top: 2px solid var(--primary, #4a90d9);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.tts-controller.tts-visible {
  transform: translateY(0);
  opacity: 1;
}
.tts-controller.tts-hiding {
  transform: translateY(100%);
  opacity: 0;
}
.tts-controller-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}
.tts-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.tts-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary, #4a90d9);
  animation: ttsPulse 1.2s ease-in-out infinite;
}
@keyframes ttsPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: 0.4; }
}
.tts-status {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-color, #333);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.tts-btn-group {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.tts-btn {
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--bg-color, #f0f4f8);
  color: var(--text-color, #333);
  border: 1.5px solid var(--border, #e0e0e0);
  transition: all 0.2s ease;
  white-space: nowrap;
}
.tts-btn:active {
  transform: scale(0.94);
}
.tts-btn-stop {
  background: var(--danger, #e74c3c);
  color: #fff;
  border-color: var(--danger, #e74c3c);
  padding: 7px 10px;
}
@media (max-width: 480px) {
  .tts-controller-inner { padding: 10px 12px; gap: 8px; }
  .tts-status { font-size: 0.78rem; }
  .tts-btn { padding: 6px 10px; font-size: 0.76rem; }
}

/* ===== Utility ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }

/* ===== Login Screen ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-gradient, linear-gradient(135deg, #e8f0fe 0%, #f5f0ff 100%));
  padding: 20px;
}
.login-card {
  background: var(--sidebar-bg, #ffffff);
  border-radius: var(--border-radius, 16px);
  box-shadow: var(--shadow-lg, 0 8px 30px rgba(0,0,0,0.12));
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-color, #333);
  margin-bottom: 6px;
}
.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary, #718096);
  margin-bottom: 24px;
}
.login-input {
  font-size: 1rem;
  padding: 12px 16px;
}
.login-hint {
  font-size: 0.78rem;
  color: var(--text-light, #a0aec0);
  margin-top: 14px;
  line-height: 1.5;
}
.login-divider {
  height: 1px;
  background: var(--card-border, #e8ecf1);
  margin: 20px 0;
}
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.relative { position: relative; }
