/*
 * BandUp9 Listening — light theme: white + deep blue.
 * Semantic tokens only below.
 */
:root {
  color-scheme: light;
  --bg: #f5f8fc;
  --bg-glow: rgba(11, 58, 122, 0.06);
  --side-bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef3f9;
  --surface-3: #e2eaf4;
  --card-bg: #ffffff;
  --card-border: #d7e2ef;
  --card-hover-border: #9bb6d6;
  --border: #d0dce8;
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --accent: #0b3a7a;
  --accent-2: #1565c0;
  --accent-bright: #1e4f93;
  --accent-soft: rgba(11, 58, 122, 0.08);
  --accent-glow: rgba(21, 101, 192, 0.22);
  --primary-bg: #0b3a7a;
  --primary-bg-hover: #082d5f;
  --primary-bg-2: #1565c0;
  --on-primary: #ffffff;
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.12);
  --warn: #b45309;
  --error: #dc2626;
  --error-soft: rgba(220, 38, 38, 0.1);
  --flame: #ea580c;
  --sky: #0369a1;
  --topbar-bg: linear-gradient(180deg, rgba(245, 248, 252, 0.98), rgba(245, 248, 252, 0.98) 80%, rgba(245, 248, 252, 0));
  --hero-bg:
    radial-gradient(120% 140% at 0% 0%, rgba(21, 101, 192, 0.18), transparent 55%),
    linear-gradient(135deg, #dceaf8 0%, #eef5fb 48%, #ffffff 100%);
  --hero-border: #b7cce4;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(11, 58, 122, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); }
:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}
.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  background: var(--primary-bg); color: #fff; padding: 10px 14px; border-radius: 10px;
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { left: 12px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
.btn, .card-click, .chip-btn, .rate-btn, .option, .nav-link, .bottom-nav button {
  cursor: pointer;
  touch-action: manipulation;
}

.listening-app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  background:
    radial-gradient(900px 420px at 10% -10%, var(--bg-glow), transparent 60%),
    var(--bg);
}

/* —— Shell —— */
.shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
}
.side {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 20px 16px;
  background: var(--side-bg);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100dvh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text strong { display: block; font-size: 15px; letter-spacing: -0.02em; }
.brand-text span { font-size: 12px; color: var(--text-muted); }
.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 8px 12px 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  border: 0; background: transparent; color: var(--text-muted);
  text-align: left; width: 100%; transition: background 160ms ease, color 160ms ease;
}
.nav-link:hover { background: var(--accent-soft); color: var(--accent); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link svg { width: 20px; height: 20px; flex-shrink: 0; }
.side-foot { margin-top: auto; padding: 12px; font-size: 12px; color: var(--text-faint); }

.main {
  min-width: 0;
  padding: 16px 16px calc(88px + var(--safe-bottom));
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
}
.boot-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 32px);
  max-width: 480px;
  margin: 0 auto;
}
.boot {
  width: 100%;
  text-align: center;
  padding: 28px 8px 16px;
  animation: rise 420ms ease both;
}
.boot-mark {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff;
  box-shadow: var(--shadow-sm);
}
.boot-mark.is-error { background: linear-gradient(145deg, #7f1d1d, #dc2626); }
.boot-mark svg { width: 28px; height: 28px; }
.boot-title {
  margin: 0 0 8px; font-size: 22px; letter-spacing: -0.03em; color: var(--accent);
}
.boot-hint {
  margin: 0 0 18px; color: var(--text-muted); line-height: 1.5; font-size: 14px;
}
.boot-spinner {
  width: 28px; height: 28px; margin: 0 auto 22px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.skeleton-stack { display: grid; gap: 10px; text-align: left; }
.skeleton-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.skeleton {
  border-radius: 14px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.sk-hero { height: 96px; }
.sk-tile { height: 72px; }
.sk-line { height: 16px; }
.sk-short { width: 62%; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px;
  position: sticky; top: 0; z-index: 5;
  padding: 8px 0 12px;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 4px; padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(255,255,255,0.94);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.bottom-nav button {
  border: 0; background: transparent; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border-radius: 12px; font-size: 11px; font-weight: 500;
  min-height: 48px; transition: color 160ms ease, background 160ms ease;
}
.bottom-nav button svg { width: 22px; height: 22px; }
.bottom-nav button.is-active { color: var(--accent); background: var(--accent-soft); }

@media (min-width: 960px) {
  .shell { grid-template-columns: 240px 1fr; }
  .side { display: flex; }
  .bottom-nav { display: none; }
  .main { padding: 28px 32px 48px; max-width: 880px; margin: 0; }
}

/* —— Primitives —— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid transparent; font-weight: 600; transition: background 160ms ease, transform 120ms ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary-bg); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-bg-hover); }
.btn-secondary { background: var(--surface); color: var(--accent); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent-2); background: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-icon {
  width: 44px; height: 44px; padding: 0; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--accent);
}
.btn-icon:hover { border-color: var(--accent-2); background: var(--accent-soft); }
.btn-icon svg { width: 20px; height: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.card:hover { border-color: var(--card-hover-border); }
.card-click { cursor: pointer; text-align: left; width: 100%; }
.card-click:hover { box-shadow: var(--shadow); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.grid-2 { display: grid; gap: 12px; }
.grid-4 { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* —— Home —— */
.hero {
  background: var(--hero-bg); border: 1px solid var(--hero-border);
  border-radius: 18px; padding: 22px 20px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  animation: rise 420ms ease both;
}
.hero-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-2); margin: 0 0 8px; }
.hero h2 { margin: 0 0 8px; font-size: 26px; letter-spacing: -0.03em; line-height: 1.2; color: var(--accent); }
.hero p { margin: 0 0 16px; color: var(--text-muted); max-width: 52ch; line-height: 1.5; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; min-height: 88px;
}
.stat-tile .label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-tile .value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--accent); }
.stat-tile .hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 22px 0 12px; }
.section-head h3 { margin: 0; font-size: 17px; }
.mode-card { display: flex; flex-direction: column; gap: 8px; min-height: 132px; }
.mode-card .icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.mode-card .icon svg { width: 22px; height: 22px; }
.mode-card strong { font-size: 15px; }
.mode-card span { font-size: 13px; color: var(--text-muted); line-height: 1.4; }

/* —— Practice —— */
.practice-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.player {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.player-main { flex: 1; min-width: 0; display: grid; gap: 8px; }
.player-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.player-wave {
  height: 40px; border-radius: 10px; overflow: hidden;
  background:
    repeating-linear-gradient(90deg, var(--surface-3) 0 3px, transparent 3px 7px),
    linear-gradient(180deg, var(--surface-2), #fff);
  position: relative;
}
.player-wave::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(21,101,192,0.28), transparent);
  transform: translateX(-100%);
}
.player.is-playing .player-wave::after { animation: sweep 1.4s ease-in-out infinite; }
.chip-quiet { background: var(--surface-2); color: var(--text-muted); font-weight: 600; }
.chip-accent { background: rgba(180, 83, 9, 0.12); color: #b45309; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.rate-group { display: inline-flex; gap: 4px; padding: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.rate-btn {
  min-height: 28px; min-width: 40px; padding: 0 8px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 700;
}
.rate-btn.is-on { background: #fff; color: var(--accent); box-shadow: var(--shadow-sm); }
.tip-line { font-size: 13px; color: var(--text-muted); margin: 0 0 10px; }
.transcript-card { margin-bottom: 14px; line-height: 1.55; }
.source-note { font-size: 12px; line-height: 1.45; max-width: 70ch; margin-top: 18px; }
.blank-sentence {
  font-size: 18px; line-height: 1.7; padding: 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px;
}
.blank-input {
  display: inline-block; min-width: 88px; margin: 0 4px; padding: 4px 8px;
  border: 0; border-bottom: 2px solid var(--accent-2); background: var(--accent-soft);
  border-radius: 6px 6px 0 0; text-align: center; color: var(--accent);
  font-weight: 600;
}
.blank-input.is-correct { border-bottom-color: var(--success); background: var(--success-soft); color: var(--success); }
.blank-input.is-wrong { border-bottom-color: var(--error); background: var(--error-soft); color: var(--error); }
.qa-list { display: grid; gap: 12px; }
.qa-item { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.qa-item h4 { margin: 0 0 10px; font-size: 14px; }
.options { display: grid; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); text-align: left; color: var(--text);
}
.option:hover { border-color: var(--accent-2); }
.option.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.option.is-correct { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.option.is-wrong { border-color: var(--error); background: var(--error-soft); color: var(--error); }
.feedback {
  margin-top: 14px; padding: 14px; border-radius: var(--radius);
  background: var(--success-soft); border: 1px solid #bbf7d0; color: #166534;
}
.feedback.is-partial { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.dock {
  position: sticky; bottom: calc(64px + var(--safe-bottom)); z-index: 4;
  display: flex; gap: 10px; padding: 12px 0 4px;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
}
@media (min-width: 960px) { .dock { bottom: 0; } }

/* —— Topic chips / mock toolbar —— */
.topic-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px;
}
.chip-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  cursor: pointer; transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}
.chip-btn:hover, .chip-btn.is-on {
  border-color: var(--accent-2); background: var(--accent-soft); color: var(--accent);
}
.mock-toolbar {
  display: grid; gap: 10px; margin: 0 0 14px;
}
.mock-search {
  width: 100%; min-height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
}
.mock-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.mock-pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 16px 0 4px; flex-wrap: wrap;
}

/* —— Mock —— */
.mock-ready { text-align: left; }
.mock-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.answer-sheet { display: grid; gap: 10px; }
.sheet-q {
  display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
}
.sheet-q label { font-size: 13px; font-weight: 600; }
.sheet-q input[type="text"] {
  min-height: 44px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff;
}
.progress-bar {
  height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 10px 0 16px;
}
.progress-bar > span {
  display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit; transition: width 240ms ease;
}
.result-ring {
  width: 120px; height: 120px; border-radius: 50%; margin: 8px auto 16px;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) var(--p, 0%), var(--surface-3) 0);
  box-shadow: var(--shadow);
}
.result-ring > div {
  width: 92px; height: 92px; border-radius: 50%; background: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 28px; color: var(--accent);
}

/* —— History —— */
.history-list { display: grid; gap: 10px; }
.history-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
}
.badge {
  font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.empty p { margin: 0; line-height: 1.5; }
.empty .empty-title {
  margin: 0 0 6px; font-size: 16px; font-weight: 700; color: var(--text);
}
.empty .empty-icon {
  width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 14px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.empty .empty-icon svg { width: 24px; height: 24px; }
.section-sub {
  margin: 4px 0 0; font-size: 13px; color: var(--text-muted); line-height: 1.4;
}
.back-link {
  padding: 8px 10px; min-height: 44px;
}
.tf-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.text-answer {
  display: block; width: 100%; min-width: 0; min-height: 44px;
  margin: 0; padding: 10px 12px; text-align: left;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); font-weight: 500;
}
.field-hint { margin: 8px 0 0; font-size: 12px; color: var(--text-faint); }
.result-card { text-align: center; }
.result-card h2 { margin: 0 0 8px; letter-spacing: -0.02em; }
.result-actions { justify-content: center; margin-top: 16px; }
.mock-ready h2 { margin: 12px 0 8px; letter-spacing: -0.02em; }
.badge.is-miss {
  background: var(--error-soft); color: var(--error);
}
.btn:disabled, .chip-btn:disabled, .rate-btn:disabled {
  opacity: 0.45; cursor: not-allowed;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes sweep {
  to { transform: translateX(100%); }
}

.seo-fallback { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
