/* ===== CSS Variables & Reset ===== */
:root {
  --primary: #C41E3A;
  --primary-dark: #9B1830;
  --primary-light: #E8354F;
  --accent: #D4A843;
  --bg: #FAFAF8;
  --bg-card: #FFFFFF;
  --bg-nav: #FFFFFF;
  --text: #1A1A1A;
  --text-secondary: #5A5A5A;
  --text-muted: #999999;
  --border: #E8E8E8;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --success: #2ECC71;
  --error: #E74C3C;
  --warning: #F39C12;
  --transition: 0.25s ease;
  --chinese-font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ui-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #E8354F;
    --primary-dark: #C41E3A;
    --primary-light: #FF5C73;
    --bg: #121212;
    --bg-card: #1E1E1E;
    --bg-nav: #1A1A1A;
    --text: #F0F0F0;
    --text-secondary: #B0B0B0;
    --text-muted: #666666;
    --border: #2A2A2A;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.3);
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--ui-font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Navigation ===== */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
}

.nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.app-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
}

.app-brand-chinese {
  font-family: var(--chinese-font);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.app-brand-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  background: linear-gradient(135deg, #FFF3E0, #FFE0B2);
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
  color: #E65100;
}

@media (prefers-color-scheme: dark) {
  .streak-badge {
    background: linear-gradient(135deg, #3E2700, #5C3D00);
    color: #FFB74D;
  }
}

.streak-flame {
  font-size: 1.1rem;
  display: inline-block;
  animation: flicker 1.5s ease-in-out infinite alternate;
}

@keyframes flicker {
  0% { transform: scale(1) rotate(-3deg); opacity: 0.9; }
  50% { transform: scale(1.15) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(-2deg); opacity: 0.85; }
}

.daily-timer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.daily-timer .timer-icon {
  font-size: 1rem;
}

.nav-tabs {
  display: flex;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  padding: 0.65rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  font-family: var(--ui-font);
}

.nav-tab:hover {
  color: var(--primary);
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ===== Main Content ===== */
.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

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

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

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  transform: translateY(-2px);
}

/* ===== Dashboard ===== */
.dashboard-welcome {
  margin-bottom: 1.5rem;
}

.dashboard-welcome h1 {
  font-size: 1.6rem;
  font-weight: 700;
}

.dashboard-welcome .date {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.progress-ring-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.progress-ring-wrapper {
  position: relative;
  width: 140px;
  height: 140px;
  margin-bottom: 1rem;
}

.progress-ring {
  width: 140px;
  height: 140px;
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 377;
  stroke-dashoffset: 377;
  transition: stroke-dashoffset 1s ease;
}

.progress-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.progress-ring-text .minutes {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.progress-ring-text .label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.progress-ring-container .goal-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.quick-stats {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.stat-icon.learned { background: #E8F5E9; color: #2E7D32; }
.stat-icon.streak { background: #FFF3E0; color: #E65100; }
.stat-icon.review { background: #E3F2FD; color: #1565C0; }

@media (prefers-color-scheme: dark) {
  .stat-icon.learned { background: #1B3A1B; color: #66BB6A; }
  .stat-icon.streak { background: #3E2700; color: #FFB74D; }
  .stat-icon.review { background: #0D2137; color: #64B5F6; }
}

.stat-info .stat-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.stat-info .stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.quick-start {
  margin-bottom: 1.5rem;
}

.quick-start h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.quick-start-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.quick-start-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--ui-font);
  color: var(--text);
}

.quick-start-btn:hover {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.quick-start-btn .qs-icon {
  font-size: 1.5rem;
}

.quick-start-btn .qs-label {
  font-size: 0.85rem;
  font-weight: 500;
}

.wotd-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  padding: 2rem;
}

.wotd-card .wotd-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.85;
  margin-bottom: 0.75rem;
}

.wotd-card .wotd-chinese {
  font-family: var(--chinese-font);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
}

.wotd-card .wotd-pinyin {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-top: 0.25rem;
}

.wotd-card .wotd-german {
  font-size: 1rem;
  margin-top: 0.5rem;
  opacity: 0.85;
}

.wotd-card .wotd-example {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.9rem;
  opacity: 0.8;
}

/* ===== HSK Level Selector ===== */
.hsk-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.hsk-tab {
  padding: 0.4rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--ui-font);
}

.hsk-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.hsk-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===== Search & Filters ===== */
.filters-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-input, .filter-select {
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--ui-font);
  transition: border-color var(--transition);
  outline: none;
}

.search-input {
  flex: 1;
  min-width: 200px;
}

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

.search-input::placeholder {
  color: var(--text-muted);
}

/* ===== Vocabulary Grid ===== */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.vocab-card {
  text-align: center;
  padding: 1.5rem 1rem;
  cursor: pointer;
  position: relative;
}

.vocab-card .vocab-chinese {
  font-family: var(--chinese-font);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.vocab-card .vocab-pinyin {
  font-size: 0.9rem;
  color: var(--primary);
  margin-top: 0.25rem;
  font-style: italic;
}

.vocab-card .vocab-german {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.vocab-card .vocab-sound {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all var(--transition);
}

.vocab-card .vocab-sound:hover {
  background: var(--primary);
  color: white;
}

.vocab-card .hsk-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  background: var(--primary);
  color: white;
}

/* Vocabulary favorites button */
.vocab-fav {
  position: absolute;
  top: 0.4rem;
  right: 2.2rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.vocab-fav:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(212, 168, 67, 0.1);
}

.vocab-fav.saved {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(212, 168, 67, 0.15);
}

.vocab-card {
  position: relative;
}

/* Loading indicator */
.load-more-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== Flashcard ===== */
.flashcard-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.mode-toggle {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.mode-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--ui-font);
}

.mode-btn.active {
  background: var(--primary);
  color: white;
}

.flashcard-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 0;
}

.flashcard-perspective {
  perspective: 1000px;
  width: 100%;
  max-width: 480px;
  height: 320px;
  margin-bottom: 1.5rem;
}

.flashcard {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.flashcard-front, .flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.flashcard-front {
  background: var(--bg-card);
}

.flashcard-back {
  background: var(--bg-card);
  transform: rotateY(180deg);
}

.flashcard-front .fc-text {
  font-size: 1.6rem;
  font-weight: 600;
  text-align: center;
}

.flashcard-front .fc-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

.flashcard-back .fc-chinese {
  font-family: var(--chinese-font);
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.flashcard-back .fc-pinyin {
  font-size: 1.1rem;
  color: var(--primary);
  margin-top: 0.5rem;
  font-style: italic;
}

.flashcard-back .fc-german {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.flashcard-back .fc-sound-btn {
  margin-top: 1rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: none;
  color: var(--primary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.flashcard-back .fc-sound-btn:hover {
  background: var(--primary);
  color: white;
}

.flashcard-actions {
  display: flex;
  gap: 1.25rem;
}

.fc-btn {
  padding: 0.75rem 2.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--ui-font);
}

.fc-btn.correct {
  background: var(--success);
  color: white;
}

.fc-btn.correct:hover {
  background: #27AE60;
  transform: translateY(-1px);
}

.fc-btn.wrong {
  background: var(--error);
  color: white;
}

.fc-btn.wrong:hover {
  background: #C0392B;
  transform: translateY(-1px);
}

.flashcard-progress {
  width: 100%;
  max-width: 480px;
  margin-top: 1.5rem;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.flashcard-session-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.flashcard-session-stats span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.flashcard-session-stats .fc-correct-count { color: var(--success); }
.flashcard-session-stats .fc-wrong-count { color: var(--error); }

/* ===== Writing Practice ===== */
.writing-area {
  max-width: 600px;
  margin: 0 auto;
}

.writing-display {
  text-align: center;
  margin-bottom: 2rem;
}

.writing-display .wd-pinyin {
  font-size: 1rem;
  color: var(--primary);
  font-style: italic;
  margin-bottom: 0.25rem;
}

.writing-display .wd-chinese {
  font-family: var(--chinese-font);
  font-size: 4rem;
  font-weight: 700;
  line-height: 1.2;
}

.writing-display .wd-german {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.pinyin-input-group {
  margin-bottom: 1.25rem;
}

.pinyin-input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.pinyin-input {
  width: 100%;
  padding: 0.85rem 1.1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-family: var(--ui-font);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
  text-align: center;
  letter-spacing: 0.5px;
}

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

.pinyin-input.success {
  border-color: var(--success);
  background: #F0FFF4;
}

.pinyin-input.error {
  border-color: var(--error);
  background: #FFF5F5;
}

@media (prefers-color-scheme: dark) {
  .pinyin-input.success { background: #0A2A0A; }
  .pinyin-input.error { background: #2A0A0A; }
}

.writing-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--ui-font);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

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

.writing-answer {
  margin-top: 1.5rem;
  text-align: center;
  padding: 1.25rem;
  background: var(--bg);
  border-radius: var(--radius);
  display: none;
}

.writing-answer.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

.writing-answer .wa-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.writing-answer .wa-pinyin {
  font-size: 1.3rem;
  color: var(--primary);
  font-weight: 600;
}

/* ===== Sentence Practice ===== */
.sentence-area {
  max-width: 700px;
  margin: 0 auto;
}

.complexity-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.complexity-btn {
  padding: 0.45rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--ui-font);
}

.complexity-btn:hover { border-color: var(--primary); color: var(--primary); }
.complexity-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

.sentence-prompt {
  text-align: center;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.sentence-prompt .sp-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.sentence-prompt .sp-text {
  font-size: 1.3rem;
  font-weight: 600;
}

.sentence-textarea {
  width: 100%;
  min-height: 100px;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-family: var(--chinese-font);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  resize: vertical;
  transition: border-color var(--transition);
  margin-bottom: 1rem;
}

.sentence-textarea:focus { border-color: var(--primary); }

.sentence-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.sentence-result {
  padding: 1.5rem;
  border-radius: var(--radius);
  background: var(--bg);
  display: none;
}

.sentence-result.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

.sentence-result .sr-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.sentence-result .sr-chinese {
  font-family: var(--chinese-font);
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.sentence-result .sr-pinyin {
  font-size: 0.95rem;
  color: var(--primary);
  font-style: italic;
  margin-bottom: 0.25rem;
}

.sentence-result .sr-german {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.char-comparison {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.75rem;
}

.char-comparison .char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  font-family: var(--chinese-font);
  font-size: 1.1rem;
  font-weight: 600;
}

.char-comparison .char.correct { background: #E8F5E9; color: #2E7D32; }
.char-comparison .char.wrong { background: #FFEBEE; color: #C62828; }
.char-comparison .char.missing { background: #FFF8E1; color: #F57F17; }

@media (prefers-color-scheme: dark) {
  .char-comparison .char.correct { background: #1B3A1B; color: #66BB6A; }
  .char-comparison .char.wrong { background: #3A1B1B; color: #EF9A9A; }
  .char-comparison .char.missing { background: #3A3500; color: #FFD54F; }
}

.sentence-sound-btn {
  margin-top: 1rem;
  padding: 0.5rem 1.25rem;
  border: 1.5px solid var(--primary);
  border-radius: 20px;
  background: none;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--ui-font);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.sentence-sound-btn:hover {
  background: var(--primary);
  color: white;
}

/* ===== Statistics ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stats-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stats-overview-item {
  text-align: center;
  padding: 1.25rem 1rem;
}

.stats-overview-item .so-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.stats-overview-item .so-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.streak-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.streak-display .sd-flame {
  font-size: 3.5rem;
  animation: flicker 1.5s ease-in-out infinite alternate;
  margin-bottom: 0.75rem;
}

.streak-display .sd-count {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
}

.streak-display .sd-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* CSS Bar Chart */
.chart-container {
  padding: 1.5rem;
}

.chart-container h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 140px;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.bar-chart .bar {
  flex: 1;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
  position: relative;
  opacity: 0.7;
}

.bar-chart .bar:hover {
  opacity: 1;
}

.bar-chart .bar::after {
  content: attr(data-label);
  position: absolute;
  bottom: -1.25rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* HSK Progress Bars */
.hsk-progress-list {
  padding: 1.5rem;
}

.hsk-progress-list h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hsk-progress-item {
  margin-bottom: 1rem;
}

.hsk-progress-item .hpi-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.hsk-progress-item .hpi-label {
  font-weight: 500;
}

.hsk-progress-item .hpi-count {
  color: var(--text-secondary);
}

.hsk-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.hsk-progress-bar .hpb-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.hsk-progress-bar .hpb-fill.hsk1 { background: #E74C3C; }
.hsk-progress-bar .hpb-fill.hsk2 { background: #E67E22; }
.hsk-progress-bar .hpb-fill.hsk3 { background: #F1C40F; }
.hsk-progress-bar .hpb-fill.hsk4 { background: #2ECC71; }
.hsk-progress-bar .hpb-fill.hsk5 { background: #3498DB; }

.recent-sessions {
  margin-top: 1.5rem;
}

.recent-sessions h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.session-item .si-info {
  display: flex;
  flex-direction: column;
}

.session-item .si-type {
  font-size: 0.85rem;
  font-weight: 500;
}

.session-item .si-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.session-item .si-duration {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease;
}

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

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--error);
  color: white;
}

.modal-body {
  padding: 1.5rem;
}

.modal-chinese {
  text-align: center;
  margin-bottom: 1.25rem;
}

.modal-chinese .mc-char {
  font-family: var(--chinese-font);
  font-size: 4rem;
  font-weight: 700;
  line-height: 1.2;
}

.modal-chinese .mc-pinyin {
  font-size: 1.15rem;
  color: var(--primary);
  font-style: italic;
  margin-top: 0.25rem;
}

.modal-chinese .mc-german {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

.modal-category {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  background: var(--bg);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.modal-sound-btns {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.modal-sound-btn {
  padding: 0.45rem 1rem;
  border: 1.5px solid var(--primary);
  border-radius: 20px;
  background: none;
  color: var(--primary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--ui-font);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.modal-sound-btn:hover {
  background: var(--primary);
  color: white;
}

.modal-example {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}

.modal-example .me-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.modal-example .me-chinese {
  font-family: var(--chinese-font);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.modal-example .me-pinyin {
  font-size: 0.85rem;
  color: var(--primary);
  font-style: italic;
  margin-bottom: 0.2rem;
}

.modal-example .me-german {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.modal-progress {
  margin-top: 0.5rem;
}

.modal-progress .mp-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.modal-progress .mp-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.modal-progress .mp-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ===== Section Headings ===== */
.section-heading {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-overview {
    grid-template-columns: 1fr;
  }

  .nav-top {
    padding: 0.3rem 0.75rem;
  }

  .app-brand-chinese {
    font-size: 1rem;
  }

  .app-brand-sub {
    display: none;
  }

  .nav-status {
    gap: 0.5rem;
  }

  .streak-badge {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 12px;
  }

  .streak-flame {
    font-size: 0.8rem;
  }

  .daily-timer {
    font-size: 0.7rem;
  }

  .daily-timer .timer-icon {
    font-size: 0.8rem;
  }

  .user-profile {
    font-size: 0.7rem;
    gap: 0.3rem;
  }

  .user-avatar {
    font-size: 1rem;
  }

  .btn-sm {
    padding: 0.15rem 0.4rem;
    font-size: 0.65rem;
  }

  .nav-tabs {
    padding: 0 0.5rem;
  }

  .nav-tab {
    padding: 0.4rem 0.6rem;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .app-main {
    padding: 0.75rem;
  }

  .flashcard-perspective {
    height: 280px;
  }

  .flashcard-back .fc-chinese {
    font-size: 2.5rem;
  }

  .writing-display .wd-chinese {
    font-size: 3rem;
  }

  .vocab-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
  }

  .vocab-card {
    padding: 0.6rem;
  }

  .vocab-chinese {
    font-size: 1.8rem;
  }

  .wotd-card .wotd-chinese {
    font-size: 2.5rem;
  }

  .modal {
    max-width: 100%;
    margin: 0.5rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  .view-subtitle {
    font-size: 0.8rem;
  }

  .hsk-tab, .auto-cat-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.72rem;
  }

  .search-input {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 480px) {
  .quick-start-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .flashcard-perspective {
    height: 260px;
  }

  .fc-btn {
    padding: 0.65rem 1.5rem;
    font-size: 0.9rem;
  }

  .vocab-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }
}

/* ===== Utility ===== */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ===== Onboarding Banner ===== */
.onboarding-banner {
  background: linear-gradient(135deg, #1a5276 0%, #2471a3 100%);
  color: #fff;
  padding: 1.2rem 1.5rem;
  border-radius: var(--radius);
  margin: 1rem;
}

.onboarding-content h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.onboarding-content p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  opacity: 0.9;
}

.onboarding-content ul {
  margin: 0.3rem 0 0.5rem;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  opacity: 0.85;
}

.onboarding-content li {
  margin: 0.15rem 0;
}

.btn-outline {
  border: 1px solid rgba(255,255,255,0.4);
  background: transparent;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-outline:hover {
  background: rgba(255,255,255,0.1);
}

/* ===== Pinyin Character Tooltip ===== */
/* Enhanced Pinyin Tooltip */
.pinyin-tooltip {
  position: fixed;
  z-index: 10000;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  max-width: 420px;
  min-width: 200px;
  animation: tooltip-in 0.15s ease-out;
  overflow: hidden;
}

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

.tooltip-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
}

.tooltip-stroke-area {
  flex-shrink: 0;
}

.tooltip-stroke-target {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  background: rgba(0,0,0,0.03);
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (prefers-color-scheme: dark) {
  .tooltip-stroke-target {
    background: rgba(255,255,255,0.05);
  }
}

.tooltip-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.tooltip-context {
  border-top: 1px solid var(--border);
  padding: 0.4rem 0.8rem 0.5rem;
}

.tooltip-context-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.3rem;
}

.tooltip-context-words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.context-word {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.2rem 0.45rem;
  background: rgba(196, 30, 58, 0.06);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  min-width: 0;
}

.context-word:hover {
  background: rgba(196, 30, 58, 0.15);
}

.context-cn {
  font-family: var(--chinese-font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.context-py {
  font-size: 0.65rem;
  color: var(--primary);
  font-style: italic;
  line-height: 1.1;
}

.context-de {
  font-size: 0.6rem;
  color: var(--text-secondary);
  line-height: 1.1;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tooltip-actions {
  display: flex;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem 0.4rem;
  border-top: 1px solid var(--border);
}

.tooltip-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
}

.tooltip-action-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pinyin-tooltip-chars {
  font-family: var(--chinese-font);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.pinyin-tooltip-pinyin {
  font-size: 1rem;
  color: var(--primary);
  font-style: italic;
  font-weight: 500;
  white-space: nowrap;
}

.pinyin-tooltip-german {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pinyin-tooltip-speak {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--primary);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.pinyin-tooltip-speak:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Make Chinese text interactive for tooltip */
.cn-interactive {
  cursor: default;
}

.cn-interactive .cn-char {
  display: inline-block;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  border-radius: 3px;
  padding: 0 1px;
}

.cn-interactive .cn-char:hover {
  color: var(--primary);
  background: rgba(196, 30, 58, 0.08);
}

.cn-interactive .cn-char.highlighted {
  color: var(--primary);
  background: rgba(196, 30, 58, 0.15);
}

@media (prefers-color-scheme: dark) {
  .cn-interactive .cn-char:hover {
    background: rgba(232, 53, 79, 0.15);
  }
  .cn-interactive .cn-char.highlighted {
    background: rgba(232, 53, 79, 0.2);
  }
}

/* ===== Login Banner ===== */
.login-banner {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  padding: 1.5rem;
  text-align: center;
}

.login-content { max-width: 500px; margin: 0 auto; }
.login-content h2 { margin: 0 0 0.5rem; font-size: 1.3rem; }
.login-content p { margin: 0 0 1rem; opacity: 0.9; font-size: 0.9rem; }

.btn-telegram {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: #2AABEE; color: #fff; border: none;
  padding: 0.75rem 1.5rem; border-radius: 8px;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
.btn-telegram:hover { background: #229ED9; }

.login-skip { margin-top: 0.75rem; }
.login-skip a { color: rgba(255,255,255,0.7); font-size: 0.85rem; text-decoration: none; }
.login-skip a:hover { color: #fff; }

/* ===== User Profile in Nav ===== */
.user-profile {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem;
}
.user-avatar { font-size: 1.3rem; }
.user-name { font-weight: 500; }
.btn-sm {
  padding: 0.25rem 0.6rem; font-size: 0.75rem;
  border: 1px solid var(--border); border-radius: 4px;
  background: transparent; color: var(--text-secondary); cursor: pointer;
}
.btn-sm:hover { background: var(--border); }

/* ===== Automotive Category Tabs ===== */
.auto-categories {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0;
}
.auto-cat-btn {
  padding: 0.4rem 0.8rem; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-card);
  font-size: 0.8rem; cursor: pointer; transition: all 0.2s;
  color: var(--text-secondary); font-family: var(--ui-font);
}
.auto-cat-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.auto-cat-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

.auto-badge {
  background: #1a6b3c !important; font-size: 0.65rem !important;
}

/* ===== View Subtitle ===== */
.view-subtitle { color: var(--text-secondary); margin: -0.5rem 0 1rem; font-size: 0.9rem; }

/* ===== Results Info ===== */
.results-info { color: var(--text-muted); font-size: 0.85rem; margin: 0.5rem 0; }

/* ===== Load More ===== */
.load-more-container { text-align: center; margin: 2rem 0; }

/* ===== Dictionary Search ===== */
.search-input-lg { font-size: 1.1rem; padding: 1rem; }
.dict-results-count { color: var(--text-muted); font-size: 0.85rem; margin: 0.75rem 0; }

/* ===== Vocab/Dict Mode Toggle ===== */
.vocab-mode-toggle {
  display: flex; gap: 0; margin: 1rem 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--border);
  width: fit-content;
}
.vocab-mode-btn {
  padding: 0.5rem 1.2rem; border: none; background: var(--bg-card);
  cursor: pointer; font-size: 0.85rem; color: var(--text-secondary);
  transition: all 0.2s; font-family: var(--ui-font);
}
.vocab-mode-btn.active { background: var(--primary); color: #fff; }

/* ===== Search Row ===== */
.search-row { margin: 1rem 0; }
