:root {
  color-scheme: dark;
  --bg: #0a1018;
  --panel: #111b28;
  --panel-2: #182637;
  --line: #2a3a4d;
  --text: #f6f8fb;
  --muted: #bdc8d8;
  --accent: #4ce0aa;
  --accent-2: #7db3ff;
  --danger: #ff716f;
  --warn: #f5bf55;
  --radius: 8px;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-text-size-adjust: 100%;
}
button, textarea, select, input { font: inherit; }
button { border: 0; -webkit-tap-highlight-color: transparent; }
.app-shell {
  width: min(100%, 920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 12px calc(84px + env(safe-area-inset-bottom));
}
.topbar, .split-row, .button-row, .hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar, .split-row { justify-content: space-between; }
.topbar { padding-bottom: 16px; }
.topbar > div { min-width: 0; }
.topbar h1 { overflow-wrap: anywhere; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.32rem; line-height: 1.08; }
h2 { margin-bottom: 10px; font-size: 1.28rem; }
h3 { margin-bottom: 8px; font-size: 1rem; }
p { color: var(--muted); line-height: 1.5; }
strong { color: var(--text); }
.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hero, .panel, .exercise-card, .metric-card, .level-card, .phrase-row, .medal-card, .voice-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 27, 40, 0.94);
}
.hero {
  padding: 18px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(76, 224, 170, 0.14), rgba(125, 179, 255, 0.1)), var(--panel);
  box-shadow: var(--shadow);
}
.panel, .exercise-card { padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.hero-actions, .button-row { flex-wrap: wrap; }
.hero-actions > button, .button-row > button, .button-row > a { flex: 1 1 140px; }
.primary-button, .secondary-button, .danger-button, .choice-button, .small-button, .icon-button, .nav-item, .link-button {
  min-height: 48px;
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-weight: 850;
  cursor: pointer;
  touch-action: manipulation;
  overflow-wrap: anywhere;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.primary-button { background: var(--accent); color: #04140e; }
.secondary-button, .choice-button, .small-button, .icon-button, .link-button { border: 1px solid var(--line); background: var(--panel-2); }
.danger-button { border: 1px solid rgba(255,113,111,.45); background: rgba(255,113,111,.16); }
.icon-button { flex: 0 0 44px; width: 44px; padding: 0; font-size: 1.2rem; }
button:disabled { opacity: .52; cursor: not-allowed; }
button:focus-visible, textarea:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid rgba(76, 224, 170, 0.32);
  outline-offset: 2px;
}
.metric-grid, .skill-grid, .medal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.metric-card, .medal-card, .level-card, .phrase-row {
  padding: 13px;
  overflow-wrap: anywhere;
}
.metric-card span {
  display: block;
  margin-bottom: 6px;
  font-size: 1.2rem;
  font-weight: 950;
}
.metric-card small, .fineprint, .phrase-row span { color: var(--muted); font-size: .82rem; }
.tag, .status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.045);
  color: var(--text);
  font-size: .78rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}
.progress-track { width: 100%; height: 10px; overflow: hidden; border-radius: 999px; background: #25354a; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.prompt { color: var(--text); font-size: 1.18rem; font-weight: 900; line-height: 1.3; overflow-wrap: anywhere; }
.quote-block {
  padding: 14px;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: rgba(255,255,255,.045);
  color: var(--text);
}
.logic-grid {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
.logic-grid article, .correction-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255,255,255,.035);
}
.logic-grid p, .correction-row p { margin-bottom: 0; }
.pattern {
  color: var(--accent);
  font-weight: 950;
}
.text-input, .text-field, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #09101a;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
.text-input { min-height: 112px; padding: 14px; resize: vertical; }
.text-field { min-height: 48px; padding: 12px; margin: 6px 0 12px; }
select { min-height: 48px; padding: 10px; }
.field-label { display: block; color: var(--text); font-weight: 850; }
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--muted);
}
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 140px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 850;
  text-align: center;
  cursor: pointer;
}
.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.select-grid { display: grid; gap: 10px; margin-bottom: 12px; }
.choice-button { display: block; width: 100%; margin-top: 8px; text-align: left; }
.feedback { margin-top: 12px; padding: 12px; border-radius: var(--radius); background: rgba(125,179,255,.14); color: var(--text); }
.feedback.good { background: rgba(76,224,170,.14); }
.feedback.bad { background: rgba(255,113,111,.14); }
.voice-box { padding: 12px; margin: 12px 0; }
audio { width: 100%; margin-top: 12px; }
.help-box { display: none; margin-top: 12px; padding: 12px; border: 1px solid rgba(245,191,85,.45); border-radius: var(--radius); background: rgba(245,191,85,.12); color: #ffe8b6; }
.help-box.is-visible { display: block; }
.list { display: grid; gap: 10px; }
.medal-card { opacity: .56; }
.medal-card.is-earned { opacity: 1; border-color: rgba(76,224,170,.72); }
.medal-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--accent);
  font-weight: 950;
}
.chat-box { display: grid; gap: 8px; margin-bottom: 12px; }
.coach-text { margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }
.ai-turn, .user-turn { margin: 0; padding: 10px; border-radius: var(--radius); }
.ai-turn { background: rgba(125,179,255,.12); }
.user-turn { background: rgba(76,224,170,.1); }
.vocabulary-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.vocabulary-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--panel-2);
}
.vocabulary-body { padding: 16px; }
.vocabulary-body > :last-child { margin-bottom: 0; }
.vocabulary-term { margin-bottom: 2px; font-size: 1.72rem; }
.word-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ipa { margin-bottom: 0; color: var(--accent-2); font-size: 1rem; }
.audio-button { flex: 0 0 48px; }
.full-button { width: 100%; margin-top: 10px; }
.pronunciation-box {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(76,224,170,.48);
  border-radius: var(--radius);
  background: rgba(76,224,170,.07);
}
.heard-text { margin: 12px 0 0; color: var(--text); }
.learning-steps { display: grid; gap: 8px; }
.learning-steps span { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.learning-steps strong {
  display: inline-grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--accent);
}
.rating-panel { margin-top: 16px; }
.rating-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rating-button {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}
.rating-button strong, .rating-button small { display: block; }
.rating-button small { margin-top: 3px; color: var(--muted); }
.rating-again { border-color: rgba(255,113,111,.66); }
.rating-hard { border-color: rgba(245,191,85,.66); }
.rating-good { border-color: rgba(76,224,170,.66); }
.rating-easy { border-color: rgba(125,179,255,.66); }
.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  gap: 4px;
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(7, 12, 20, .96);
  backdrop-filter: blur(12px);
}
.bottom-nav::-webkit-scrollbar { display: none; }
.nav-item { flex: 0 0 72px; min-height: 44px; padding: 8px 4px; background: transparent; color: var(--muted); font-size: .74rem; }
.nav-item.is-active { background: var(--panel-2); color: var(--text); }
@media (min-width: 680px) {
  .app-shell { padding-inline: 22px; }
  h1 { font-size: 1.7rem; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .logic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .medal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bottom-nav { display: grid; grid-template-columns: repeat(11, 1fr); overflow: visible; }
  .nav-item { min-width: 0; }
  .select-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 390px) {
  .metric-grid, .medal-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.1rem; line-height: 1.2; }
  h2 { font-size: 1.14rem; }
}
