/* DR Dragon Chinese - Syllables Hub CSS (HSK 3.0 Standard) */

.syllables-hero {
  padding: var(--spacing-xl, 28px);
  margin-bottom: var(--spacing-lg, 20px);
  background: linear-gradient(135deg, rgba(8, 127, 109, 0.08) 0%, rgba(2, 132, 199, 0.05) 100%), var(--paper, #ffffff);
  border: 1.5px solid rgba(8, 127, 109, 0.18);
  border-radius: var(--radius-lg, 16px);
  position: relative;
  overflow: hidden;
}

.syllables-hero-badge {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.syllables-hero-badge h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--ink, #090d14);
  margin: 0;
  line-height: 1.2;
}

.syllables-hero-desc {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted, #475569);
  max-width: 860px;
  margin-bottom: 20px;
}

.syllables-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.kpi-card {
  padding: 12px 16px;
  background: var(--paper, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.kpi-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--jade, #087f6d);
  line-height: 1.2;
}

.kpi-label {
  font-size: 11.5px;
  color: var(--muted, #64748b);
  font-weight: 600;
  margin-top: 2px;
}

/* --- Mini-game: Đấu Pháp Thính Lực --- */
.syllable-ear-trainer {
  padding: 22px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.07) 0%, rgba(8, 127, 109, 0.06) 100%), var(--paper, #ffffff);
  border: 1.5px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-lg, 16px);
}

.trainer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.trainer-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.trainer-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.trainer-title-wrap h2 {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  color: var(--ink, #090d14);
}

.trainer-title-wrap p {
  font-size: 13px;
  color: var(--muted, #64748b);
  margin: 2px 0 0 0;
}

.trainer-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.trainer-streak-badge {
  font-size: 12.5px;
  font-weight: 700;
  color: #ea580c;
  background: #ffedd5;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #fed7aa;
}

.trainer-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding: 12px 0;
}

.trainer-listen-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--jade, #087f6d) 0%, #059669 100%);
  color: #ffffff;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(8, 127, 109, 0.28);
  transition: all 0.15s ease;
}

.trainer-listen-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(8, 127, 109, 0.38);
}

.trainer-listen-btn:active {
  transform: translateY(0);
}

.trainer-prompt-hint {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted, #475569);
}

.trainer-options-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 520px;
}

.trainer-opt-btn {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--paper, #ffffff);
  border: 1.5px solid var(--line, #cbd5e1);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink, #090d14);
  cursor: pointer;
  transition: all 0.15s ease;
}

.trainer-opt-btn:hover {
  border-color: var(--jade, #087f6d);
  background: rgba(8, 127, 109, 0.05);
  transform: scale(1.03);
}

.trainer-opt-btn.is-correct {
  background: #ecfdf5;
  border-color: #10b981;
  color: #047857;
  font-weight: 800;
}

.trainer-opt-btn.is-wrong {
  background: #fef2f2;
  border-color: #ef4444;
  color: #b91c1c;
}

.trainer-feedback {
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  animation: feedbackIn 0.2s ease;
}

.trainer-feedback.is-correct {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.trainer-feedback.is-wrong {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

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

/* --- Filter Toolbar --- */
.syllables-filter-toolbar {
  padding: 18px;
  margin-bottom: 18px;
  border-radius: var(--radius-lg, 16px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted, #64748b);
  min-width: 65px;
}

.syllables-level-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.syllables-level-tabs .btn {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line, #e2e8f0);
  background: var(--paper, #ffffff);
  color: var(--ink, #090d14);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.syllables-level-tabs .btn:hover {
  border-color: var(--jade, #087f6d);
  color: var(--jade, #087f6d);
}

.syllables-level-tabs .btn.is-active {
  background: var(--jade, #087f6d);
  color: #ffffff;
  border-color: var(--jade, #087f6d);
  box-shadow: 0 2px 6px rgba(8, 127, 109, 0.25);
}

.filter-row-secondary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.tone-filters-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.syllables-tone-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pill-chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--paper, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  color: var(--ink, #090d14);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-chip:hover {
  border-color: var(--jade, #087f6d);
}

.pill-chip.is-active {
  background: rgba(8, 127, 109, 0.12);
  color: var(--jade, #087f6d);
  border-color: var(--jade, #087f6d);
  font-weight: 700;
}

.initial-filters-wrap select {
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--paper, #ffffff);
  border: 1px solid var(--line, #cbd5e1);
  color: var(--ink, #090d14);
  font-weight: 600;
  outline: none;
}

.syllables-search-row {
  margin-top: 4px;
}

.syllable-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.syllable-search-input-wrap svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--muted, #94a3b8);
  pointer-events: none;
}

.syllable-search-input-wrap input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border-radius: 10px;
  border: 1.5px solid var(--line, #cbd5e1);
  background: var(--paper, #ffffff);
  color: var(--ink, #090d14);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}

.syllable-search-input-wrap input:focus {
  border-color: var(--jade, #087f6d);
  box-shadow: 0 0 0 3px rgba(8, 127, 109, 0.1);
}

/* --- Results Header & Speed Controls --- */
.syllables-results-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.syllables-results-heading p {
  font-size: 13px;
  color: var(--muted, #64748b);
  margin: 0;
}

.syllables-speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-label {
  font-size: 12px;
  color: var(--muted, #64748b);
  font-weight: 600;
}

.speed-toggle-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--paper, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  color: var(--ink, #090d14);
  cursor: pointer;
}

.speed-toggle-btn.is-active {
  background: var(--jade, #087f6d);
  color: #ffffff;
  border-color: var(--jade, #087f6d);
}

/* --- Syllables Grid & Cards --- */
.syllables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 24px;
}

.syllable-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--paper, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  color: var(--ink, #090d14);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 58px;
}

.syllable-card:hover {
  border-color: var(--jade, #087f6d);
  background: rgba(8, 127, 109, 0.04);
  transform: translateY(-1.5px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.syllable-card.is-speaking {
  border-color: var(--jade, #087f6d);
  background: rgba(8, 127, 109, 0.12);
  box-shadow: 0 0 0 2px var(--jade, #087f6d);
}

.syllable-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.syllable-pinyin {
  font-size: 15px;
  font-weight: 700;
  color: #0284c7;
  line-height: 1.2;
}

.syllable-tone-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
}

.syllable-tone-tag.tone-1 { background: #fee2e2; color: #dc2626; }
.syllable-tone-tag.tone-2 { background: #fef3c7; color: #d97706; }
.syllable-tone-tag.tone-3 { background: #dcfce7; color: #16a34a; }
.syllable-tone-tag.tone-4 { background: #e0f2fe; color: #0284c7; }
.syllable-tone-tag.tone-0 { background: #f3f4f6; color: #6b7280; }

.syllable-speaker-icon {
  opacity: 0.25;
  transition: opacity 0.15s ease;
  display: flex;
  align-items: center;
}

.syllable-speaker-icon svg {
  width: 12px;
  height: 12px;
}

.syllable-card:hover .syllable-speaker-icon,
.syllable-card.is-speaking .syllable-speaker-icon {
  opacity: 1;
  color: var(--jade, #087f6d);
}

.syllable-card-bottom {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 4px;
  overflow: hidden;
  white-space: nowrap;
}

.syllable-hanzi {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink, #090d14);
}

.syllable-meaning {
  font-size: 11px;
  color: var(--muted, #64748b);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Guide & Editorial --- */
.syllables-guide-panel {
  margin-top: 24px;
  padding: 24px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 16px 0 20px 0;
}

.guide-card {
  padding: 16px;
  background: var(--paper, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
}

.guide-card h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--jade, #087f6d);
  margin-top: 0;
  margin-bottom: 8px;
}

.guide-card p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted, #475569);
  margin: 0;
}

/* --- Dark Mode Styles --- */
html[data-theme="dark"] .syllables-hero {
  background: linear-gradient(135deg, rgba(8, 127, 109, 0.15) 0%, rgba(2, 132, 199, 0.1) 100%), #131d27;
  border-color: rgba(8, 127, 109, 0.35);
}

html[data-theme="dark"] .syllables-hero-badge h1 {
  color: #f1f5f9;
}

html[data-theme="dark"] .syllables-hero-desc {
  color: #94a3b8;
}

html[data-theme="dark"] .kpi-card {
  background: #0f172a;
  border-color: #1e293b;
}

html[data-theme="dark"] .kpi-value {
  color: #34d399;
}

html[data-theme="dark"] .kpi-label {
  color: #94a3b8;
}

html[data-theme="dark"] .syllable-ear-trainer {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(8, 127, 109, 0.12) 100%), #131d27;
  border-color: rgba(245, 158, 11, 0.35);
}

html[data-theme="dark"] .trainer-title-wrap h2 {
  color: #f1f5f9;
}

html[data-theme="dark"] .trainer-title-wrap p {
  color: #94a3b8;
}

html[data-theme="dark"] .trainer-streak-badge {
  background: #451a03;
  color: #fb923c;
  border-color: #7c2d12;
}

html[data-theme="dark"] .trainer-prompt-hint {
  color: #94a3b8;
}

html[data-theme="dark"] .trainer-opt-btn {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

html[data-theme="dark"] .trainer-opt-btn:hover {
  background: #1e293b;
  border-color: #10b981;
}

html[data-theme="dark"] .trainer-opt-btn.is-correct {
  background: #064e3b;
  border-color: #10b981;
  color: #6ee7b7;
}

html[data-theme="dark"] .trainer-opt-btn.is-wrong {
  background: #450a0a;
  border-color: #ef4444;
  color: #fca5a5;
}

html[data-theme="dark"] .syllables-filter-toolbar {
  background: #131d27;
  border-color: #1e293b;
}

html[data-theme="dark"] .syllables-level-tabs .btn {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}

html[data-theme="dark"] .syllables-level-tabs .btn:hover {
  border-color: #34d399;
  color: #34d399;
}

html[data-theme="dark"] .syllables-level-tabs .btn.is-active {
  background: #087f6d;
  color: #ffffff;
  border-color: #087f6d;
}

html[data-theme="dark"] .pill-chip {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}

html[data-theme="dark"] .pill-chip.is-active {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border-color: #34d399;
}

html[data-theme="dark"] .initial-filters-wrap select {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

html[data-theme="dark"] .syllable-search-input-wrap input {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

html[data-theme="dark"] .syllable-search-input-wrap input:focus {
  border-color: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15);
}

html[data-theme="dark"] .speed-toggle-btn {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}

html[data-theme="dark"] .speed-toggle-btn.is-active {
  background: #087f6d;
  color: #ffffff;
}

html[data-theme="dark"] .syllable-card {
  background: #0f172a;
  border-color: #1e293b;
  color: #f1f5f9;
}

html[data-theme="dark"] .syllable-card:hover {
  background: #1e293b;
  border-color: #34d399;
}

html[data-theme="dark"] .syllable-card.is-speaking {
  background: rgba(52, 211, 153, 0.18);
  border-color: #34d399;
  box-shadow: 0 0 0 2px #34d399;
}

html[data-theme="dark"] .syllable-pinyin {
  color: #38bdf8;
}

html[data-theme="dark"] .syllable-hanzi {
  color: #f8fafc;
}

html[data-theme="dark"] .syllable-meaning {
  color: #94a3b8;
}

html[data-theme="dark"] .syllable-tone-tag.tone-1 { background: #450a0a; color: #f87171; }
html[data-theme="dark"] .syllable-tone-tag.tone-2 { background: #451a03; color: #fbbf24; }
html[data-theme="dark"] .syllable-tone-tag.tone-3 { background: #064e3b; color: #4ade80; }
html[data-theme="dark"] .syllable-tone-tag.tone-4 { background: #0c4a6e; color: #38bdf8; }
html[data-theme="dark"] .syllable-tone-tag.tone-0 { background: #1e293b; color: #94a3b8; }

html[data-theme="dark"] .guide-card {
  background: #0f172a;
  border-color: #1e293b;
}

html[data-theme="dark"] .guide-card h3 {
  color: #34d399;
}

html[data-theme="dark"] .guide-card p {
  color: #94a3b8;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .syllables-hero {
    padding: 16px;
  }
  .syllables-hero-badge h1 {
    font-size: 20px;
  }
  .syllables-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .trainer-options-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .syllables-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .syllable-card {
    padding: 6px 8px;
    min-height: 52px;
  }
  .syllable-pinyin {
    font-size: 13.5px;
  }
  .syllables-level-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
  .syllables-tone-pills {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
}
