:root {
  --bg-outer: #050914;
  --bg-app: #0b1120;
  --bg-surface: #131c31;
  --bg-surface-2: #1b2742;
  --bg-elevated: #223052;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.16);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --rose: #f43f5e;
  --rose-soft: rgba(244, 63, 94, 0.16);
  --violet: #8b5cf6;

  --hm-0: #1a243b;
  --hm-1: #064e3b;
  --hm-2: #047857;
  --hm-3: #10b981;
  --hm-4: #34d399;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body.theme-light {
  --bg-outer: #e2e8f0;
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-2: #f1f5f9;
  --bg-elevated: #e2e8f0;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.2);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary-soft: rgba(59, 130, 246, 0.12);
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --amber-soft: rgba(245, 158, 11, 0.14);
  --rose-soft: rgba(244, 63, 94, 0.12);

  --hm-0: #e2e8f0;
  --hm-1: #bbf7d0;
  --hm-2: #4ade80;
  --hm-3: #16a34a;
  --hm-4: #15803d;

  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI',
    'Segoe UI', Roboto, sans-serif;
  background: var(--bg-outer);
  color: var(--text-primary);
  line-height: 1.5;
}

button,
input,
select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.hidden {
  display: none !important;
}

/* ==================== APP SHELL ==================== */
.app-shell {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.45);
}

/* ==================== TOP STATUS BAR ==================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  flex-shrink: 0;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: 999px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  min-width: 0;
  transition: transform 0.15s ease;
}

.profile-chip:active {
  transform: scale(0.97);
}

.avatar-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--emerald));
  font-size: 18px;
  flex-shrink: 0;
}

.profile-chip-text {
  display: flex;
  flex-direction: column;
  text-align: left;
  min-width: 0;
}

.profile-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 76px;
}

.profile-sub {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.1;
}

.status-pills {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.icon-gear-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  font-size: 16px;
  display: grid;
  place-items: center;
  color: var(--text-primary);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.icon-gear-btn:active {
  transform: scale(0.95);
}

.icon-gear-btn.vv-active {
  border-color: var(--emerald);
  background: var(--emerald-soft);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 8px;
  border-radius: 10px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
}

.status-pill small {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
}

.points-pill {
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 4px 8px;
  min-width: 78px;
}

.points-top {
  display: flex;
  align-items: center;
  gap: 3px;
}

.pt-mini-prog {
  margin-left: auto;
  font-size: 10px;
  color: var(--emerald);
  font-weight: 700;
}

.pt-mini-track {
  height: 3px;
  background: rgba(148, 163, 184, 0.22);
  border-radius: 99px;
  overflow: hidden;
}

.pt-mini-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--emerald));
  transition: width 0.25s ease;
}

.rank-pill {
  background: var(--amber-soft);
  border-color: rgba(245, 158, 11, 0.32);
  color: var(--amber);
}

.pill-pop {
  animation: popPulse 0.45s ease;
}

@keyframes popPulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

/* ==================== MAIN TAB CONTAINER ==================== */
.tab-container {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px calc(80px + var(--safe-bottom));
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.25) transparent;
}

.tab-container::-webkit-scrollbar,
.playlist-box::-webkit-scrollbar,
.leaderboard-list::-webkit-scrollbar {
  width: 5px;
}

.tab-container::-webkit-scrollbar-track,
.playlist-box::-webkit-scrollbar-track,
.leaderboard-list::-webkit-scrollbar-track {
  background: transparent;
}

.tab-container::-webkit-scrollbar-thumb,
.playlist-box::-webkit-scrollbar-thumb,
.leaderboard-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
}

.tab-view {
  display: none;
  flex-direction: column;
  gap: 14px;
}

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

.sub-view {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.sub-view.active {
  display: flex;
}

/* ==================== CARDS & TYPOGRAPHY ==================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

.view-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.view-desc {
  margin: 4px 0 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

.card-subtitle {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.card-title-row h2,
.card-title-row h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.muted-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.small-margin {
  margin-bottom: 10px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 2px 2px 0;
}

.section-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.section-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==================== HOME TAB ==================== */
.hero-card {
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.2), rgba(16, 185, 129, 0.12)),
    var(--bg-surface);
  border-color: rgba(59, 130, 246, 0.3);
}

.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
}

.hero-eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.1em;
  font-weight: 800;
  color: var(--primary);
}

.hero-title {
  margin: 2px 0 0;
  font-size: 17px;
  font-weight: 800;
}

.streak-tag {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.today-stat {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.today-stat.accent {
  background: var(--emerald-soft);
  border-color: rgba(16, 185, 129, 0.35);
}

.today-val {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.today-stat.accent .today-val {
  color: var(--emerald);
}

.today-lbl {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.next-pt-box {
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.next-pt-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
}

.progress-track {
  height: 8px;
  background: rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  overflow: hidden;
}

.progress-track.thin {
  height: 5px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--emerald));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.quick-card:active {
  transform: scale(0.98);
}

.quick-badge {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.quick-card.lvl-450 .quick-badge {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
}

.quick-card.lvl-500 .quick-badge {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.quick-card.lvl-600 .quick-badge {
  background: var(--primary-soft);
  color: var(--primary);
}

.quick-card.lvl-700 .quick-badge {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
}

.quick-card.lvl-800 .quick-badge {
  background: var(--rose-soft);
  color: var(--rose);
}

.quick-card.lvl-weak .quick-badge {
  background: var(--amber-soft);
  color: var(--amber);
}

.quick-card strong {
  font-size: 14px;
}

.quick-card small {
  font-size: 11px;
  color: var(--text-secondary);
}

.listen-banner-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(59, 130, 246, 0.16));
  border: 1px solid rgba(16, 185, 129, 0.35);
  text-align: left;
}

.listen-banner-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--emerald-soft);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}

.listen-banner-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.listen-banner-text strong {
  font-size: 14px;
}

.listen-banner-text small {
  font-size: 11px;
  color: var(--text-secondary);
}

.chevron {
  font-size: 22px;
  color: var(--text-secondary);
}

.mastery-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mastery-item-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
}

/* ==================== CONTROLS & FORMS ==================== */
.setting-block {
  margin-bottom: 13px;
}

.setting-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.setting-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-group.scroll-x {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip-group.scroll-x::-webkit-scrollbar {
  display: none;
}

.chip-btn {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip-group.compact .chip-btn {
  padding: 7px 9px;
  font-size: 11px;
  flex: 1;
  text-align: center;
}

.chip-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.toggle-row strong {
  display: block;
  font-size: 13px;
}

.toggle-row small {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 999px;
  transition: 0.2s;
  border: 1px solid var(--border);
}

.slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--primary);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
  transition: transform 0.12s ease, opacity 0.15s ease;
}

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

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

.warning-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 12px;
}

.ghost-btn {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 12px;
}

.danger-ghost-btn {
  background: var(--rose-soft);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--rose);
  font-weight: 700;
  font-size: 13px;
  padding: 11px 14px;
  border-radius: 12px;
  margin-top: 10px;
}

.small-btn {
  padding: 8px 12px;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.full-width {
  width: 100%;
}

.info-note {
  margin: 8px 0 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--emerald);
  text-align: center;
}

.text-input {
  width: 100%;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

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

/* ==================== QUIZ PLAY ==================== */
.quiz-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-text-btn {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--bg-surface-2);
}

.quiz-counter {
  font-size: 14px;
  font-weight: 800;
}

.pt-pill-inline {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--emerald-soft);
  color: var(--emerald);
}

.timer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-track {
  flex: 1;
  height: 7px;
  background: var(--bg-surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald), var(--primary));
  transition: width 0.08s linear;
}

.timer-row.danger .timer-fill {
  background: var(--rose);
}

.timer-label {
  font-size: 12px;
  font-weight: 800;
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.timer-row.danger .timer-label {
  color: var(--rose);
}

.quiz-question-card {
  text-align: center;
  padding: 22px 16px;
}

.question-meta {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-surface-2);
  color: var(--text-secondary);
}

.badge.level {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge.pos {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.question-prompt {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.25;
  word-break: break-word;
}

.question-phonetic {
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-secondary);
}

.audio-pill-btn {
  margin-top: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
}

.choices-grid {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.choice-btn {
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.choice-btn:active:not(:disabled) {
  transform: scale(0.99);
}

.choice-num {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--bg-surface-2);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.choice-btn.correct {
  background: var(--emerald-soft);
  border-color: var(--emerald);
  color: var(--emerald);
}

.choice-btn.correct .choice-num {
  background: var(--emerald);
  color: #fff;
}

.choice-btn.wrong {
  background: var(--rose-soft);
  border-color: var(--rose);
  color: var(--rose);
}

.choice-btn.wrong .choice-num {
  background: var(--rose);
  color: #fff;
}

.choice-btn.dimmed {
  opacity: 0.5;
}

.feedback-card {
  border-color: var(--border-strong);
  animation: slideUp 0.2s ease;
}

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

.feedback-banner {
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 10px;
}

.feedback-banner.correct {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.feedback-banner.wrong {
  background: var(--rose-soft);
  color: var(--rose);
}

.fb-word-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.fb-en {
  font-size: 17px;
  font-weight: 800;
}

.fb-phonetic {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 6px;
}

.fb-ja {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.fb-example-box {
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.fb-example-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.mini-audio-btn {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
}

.fb-ex-en {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 600;
}

.fb-ex-ja {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.fb-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.weak-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* ==================== QUIZ RESULT ==================== */
.result-hero-card {
  text-align: center;
}

.result-title {
  margin: 0 0 12px;
  font-size: 18px;
}

.ring-wrapper {
  position: relative;
  width: 128px;
  height: 128px;
  margin: 0 auto 16px;
}

.accuracy-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--bg-surface-2);
  stroke-width: 10;
}

.ring-fg {
  fill: none;
  stroke: var(--emerald);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 314.16;
  stroke-dashoffset: 314.16;
  transition: stroke-dashoffset 0.7s ease;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-pct {
  font-size: 26px;
  font-weight: 900;
}

.ring-center small {
  font-size: 11px;
  color: var(--text-secondary);
}

.result-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.res-stat {
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
}

.res-stat.accent {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.res-stat strong {
  font-size: 14px;
}

.res-stat small {
  font-size: 10px;
  color: var(--text-secondary);
}

.result-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
}

.review-item-main {
  min-width: 0;
  flex: 1;
}

.review-item-main strong {
  font-size: 14px;
}

.review-item-main small {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
}

.review-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==================== LISTENING TAB ==================== */
.listen-player-card {
  text-align: center;
}

.listen-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.listen-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.star-btn {
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  padding: 2px 4px;
}

.star-btn.active {
  color: var(--amber);
}

.listen-word-block,
.listen-meaning-block,
.listen-example-block {
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: background 0.2s ease, border-color 0.2s ease;
  border: 1px solid transparent;
}

.listen-word-block.speaking,
.listen-meaning-block.speaking {
  background: var(--primary-soft);
  border-color: rgba(59, 130, 246, 0.45);
}

.listen-en {
  font-size: 28px;
  font-weight: 900;
}

.listen-phonetic {
  font-size: 13px;
  color: var(--text-secondary);
}

.listen-meaning-block {
  margin-top: 6px;
}

.listen-ja {
  font-size: 18px;
  font-weight: 700;
  color: var(--emerald);
}

.listen-example-block {
  margin-top: 8px;
  background: var(--bg-surface-2);
  text-align: left;
}

.listen-example-block.speaking {
  border-color: var(--emerald);
  background: var(--emerald-soft);
}

.listen-ex-en {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 600;
}

.listen-ex-ja {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.listen-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 18px 0 10px;
}

.ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  font-size: 18px;
  display: grid;
  place-items: center;
}

.ctrl-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  font-size: 16px;
  opacity: 0.55;
  display: grid;
  place-items: center;
}

.ctrl-icon-btn.active {
  opacity: 1;
  border-color: var(--primary);
  background: var(--primary-soft);
}

.play-main-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--emerald));
  color: #fff;
  font-size: 24px;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 22px rgba(59, 130, 246, 0.4);
}

.listen-pt-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
}

.playlist-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.playlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  border: 1px solid transparent;
  text-align: left;
  width: 100%;
}

.playlist-item.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.playlist-item-text {
  min-width: 0;
  flex: 1;
}

.playlist-item-text strong {
  font-size: 13px;
}

.playlist-item-text span {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 8px;
}

/* ==================== WORDS TAB ==================== */
.sticky-filter-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.search-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-add-row .text-input {
  flex: 1;
  min-width: 0;
}

.words-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.word-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
}

.word-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.word-card-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}

.word-card-en {
  font-size: 17px;
  font-weight: 800;
}

.word-card-phonetic {
  font-size: 12px;
  color: var(--text-secondary);
}

.word-card-ja {
  font-size: 14px;
  font-weight: 700;
  color: var(--emerald);
  margin: 4px 0 6px;
}

.word-card-ex {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.word-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.word-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.status-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-tag.unlearned {
  background: var(--bg-surface-2);
  color: var(--text-muted);
}

.status-tag.learning {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-tag.mastered {
  background: var(--emerald-soft);
  color: var(--emerald);
}

/* ==================== RANKING & ANALYTICS ==================== */
.my-rank-banner {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-soft), var(--emerald-soft));
  border: 1px solid rgba(59, 130, 246, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  border: 1px solid transparent;
}

.lb-row.self {
  border-color: var(--emerald);
  background: var(--emerald-soft);
}

.lb-rank {
  width: 26px;
  text-align: center;
  font-weight: 900;
  font-size: 13px;
}

.lb-avatar {
  font-size: 20px;
}

.lb-info {
  flex: 1;
  min-width: 0;
}

.lb-name {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-sub {
  font-size: 10px;
  color: var(--text-secondary);
}

.lb-points {
  font-size: 14px;
  font-weight: 900;
  color: var(--primary);
}

.lb-row.self .lb-points {
  color: var(--emerald);
}

/* GitHub-style Heatmap */
.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px 0 8px;
}

.hm-cell {
  width: 100%;
  aspect-ratio: 1;
  min-width: 11px;
  min-height: 11px;
  border-radius: 3px;
  background: var(--hm-0);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.hm-cell.lvl-0 { background: var(--hm-0); }
.hm-cell.lvl-1 { background: var(--hm-1); }
.hm-cell.lvl-2 { background: var(--hm-2); }
.hm-cell.lvl-3 { background: var(--hm-3); }
.hm-cell.lvl-4 { background: var(--hm-4); }

.hm-cell.today {
  outline: 1.5px solid var(--primary);
}

.heatmap-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 3px;
}

.heatmap-legend .hm-cell {
  width: 11px;
  height: 11px;
}

/* 7-day Bar Chart */
.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  align-items: end;
  height: 130px;
  padding-top: 16px;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 4px;
}

.bar-val {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
}

.bar-track {
  width: 100%;
  max-width: 24px;
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--bg-surface-2);
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--emerald), var(--primary));
  border-radius: 6px 6px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
}

.bar-day {
  font-size: 10px;
  color: var(--text-secondary);
}

.data-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ==================== BOTTOM NAV ==================== */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 30;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

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

.nav-icon {
  font-size: 19px;
  line-height: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
}

/* ==================== MODALS & TOASTS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

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

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.icon-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-surface-2);
  font-size: 14px;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.avatar-opt {
  height: 42px;
  border-radius: 10px;
  background: var(--bg-surface-2);
  border: 1.5px solid var(--border);
  font-size: 20px;
}

.avatar-opt.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.toast-container {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border: 1px solid rgba(16, 185, 129, 0.5);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.25s ease;
}

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

/* ==================== COMMUNITY TOTAL POINTS ==================== */
.community-card {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.16), rgba(59, 130, 246, 0.1)),
    var(--bg-surface);
  border-color: rgba(16, 185, 129, 0.32);
}

.community-main-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.community-big-pt {
  font-size: 28px;
  font-weight: 900;
  color: var(--emerald);
  line-height: 1.1;
}

.community-sub-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-size: 12px;
  color: var(--text-secondary);
}

.community-sub-stats strong {
  color: var(--text-primary);
}

.progress-fill.community-fill {
  background: linear-gradient(90deg, var(--emerald), #38bdf8);
}

.community-rank-banner {
  margin: 12px 0 8px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-2);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.comm-banner-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.comm-banner-pt {
  font-size: 20px;
  font-weight: 900;
  color: var(--emerald);
}

.comm-banner-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.comm-mini-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  text-align: center;
}

.comm-mini-box small {
  display: block;
  font-size: 10px;
  color: var(--text-secondary);
}

.comm-mini-box strong {
  font-size: 12px;
}

/* ==================== VOICEVOX SETTINGS ==================== */
.voice-pill {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  max-width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-group.vertical {
  flex-direction: column;
}

.chip-group.vertical .chip-btn {
  text-align: left;
  width: 100%;
}

.voicevox-panel {
  margin-top: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
}

.vv-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.vv-status-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
}

.vv-status-badge.online {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.vv-status-badge.offline {
  background: var(--amber-soft);
  color: var(--amber);
}

.current-speaker-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.speaker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
  padding-right: 2px;
}

.speaker-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 9px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
}

.speaker-opt span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speaker-opt.active {
  border-color: var(--emerald);
  background: var(--emerald-soft);
  color: var(--emerald);
}

.vv-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cors-guide-box {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  font-size: 11px;
  color: var(--text-secondary);
}

.cors-guide-box strong {
  display: block;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.cors-guide-box p {
  margin: 0;
  line-height: 1.45;
}

.cors-guide-box code {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ==================== JAPANESE / ZUNDAMON AUDIO BUTTONS & CREDIT ==================== */
.mini-audio-btn.ja-btn {
  border-color: rgba(16, 185, 129, 0.35);
  color: var(--emerald);
}

.fb-en-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.fb-ja-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.fb-ex-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.word-card-ja-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 6px;
}

.word-card-ja-row .word-card-ja {
  margin: 0;
}

.word-card-ex-block {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.word-card-ex-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.word-card-ex-ja {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.vv-credit-box {
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.vv-credit-box strong {
  color: var(--text-primary);
}

.home-credit-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 2px;
}

/* ==================== MONETIZATION UI (PR / SUPPORT / ADS) & LEGAL FOOTER ==================== */
.promo-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 2px;
}

.promo-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}

.promo-head-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-secondary);
}

.promo-head-note {
  font-size: 10px;
  color: var(--text-muted);
}

.promo-pr-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.promo-pr-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.promo-pr-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.promo-pr-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.pr-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--amber-soft);
  color: var(--amber);
  letter-spacing: 0.4px;
}

.promo-draft-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-surface-2);
  color: var(--text-muted);
}

.promo-pr-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}

.promo-pr-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.promo-pr-cta {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  margin-top: 2px;
}

.support-banner-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(59, 130, 246, 0.12)),
    var(--bg-surface);
  border: 1px solid rgba(16, 185, 129, 0.34);
}

.support-banner-text strong {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 3px;
}

.support-banner-text p {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.support-action-btn {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--emerald);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.ad-slot-wrapper {
  width: 100%;
}

.ad-slot-shell {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
}

.ad-slot-shell.live {
  border-style: solid;
  border-color: var(--border);
  text-align: center;
}

.ad-placeholder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.ad-slot-caption {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.ad-placeholder-text {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
}

.home-legal-footer {
  margin-top: 4px;
  padding: 12px 8px 10px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.legal-links-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 6px;
}

.legal-links-row a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 700;
}

.legal-links-row a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.home-trademark-note {
  margin: 2px 0 0;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}

.settings-sub-links {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-sub-links a {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
}

.settings-sub-links a.admin-subtle-link {
  margin-left: auto;
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.35);
}
