:root {
  color-scheme: dark;
  --bg: #070b12;
  --surface: #101722;
  --surface-soft: #151e2b;
  --text: #f5f7fb;
  --muted: #a8b4c6;
  --teal: #27dbc8;
  --teal-ink: #03110f;
  --gold: #f7c948;
  --danger: #ff8e8e;
  --line: rgba(255, 255, 255, 0.11);
  --radius-lg: 28px;
  --radius-md: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 10% -10%, rgba(39, 219, 200, 0.18), transparent 30rem),
    linear-gradient(180deg, var(--bg), #05070b 70%);
  color: var(--text);
}

button,
input,
textarea { font: inherit; }

button { color: inherit; }

button,
a { -webkit-tap-highlight-color: rgba(39, 219, 200, 0.2); }

a { color: inherit; }

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  background: var(--gold);
  color: #171201;
  font-weight: 800;
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.site-shell {
  width: min(100%, 68rem);
  min-height: 100vh;
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 18, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 900;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.55rem;
  height: 2.55rem;
  place-items: center;
  border-radius: 0.85rem;
  background: var(--teal);
  color: var(--teal-ink);
  font-size: 0.95rem;
}

.header-actions { display: flex; gap: 0.5rem; }

main { padding: clamp(1rem, 4vw, 2rem); }

main:focus { outline: none; }

.loading-card {
  min-height: 65vh;
  display: grid;
  align-content: center;
  padding: clamp(1.5rem, 6vw, 4rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(16, 23, 34, 0.96), rgba(8, 13, 21, 0.96));
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  max-width: 18ch;
  margin: 0;
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

h2,
h3,
p { margin-top: 0; }

h2 {
  margin-bottom: 0.65rem;
  font-size: clamp(1.55rem, 5vw, 2.45rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

h3 {
  margin-bottom: 0.55rem;
  font-size: 1.08rem;
  line-height: 1.3;
}

.page {
  display: grid;
  gap: clamp(1rem, 3vw, 1.5rem);
}

.surface,
.hero-card,
.lesson-shell,
.reflection-card,
.debug-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(16, 23, 34, 0.97), rgba(8, 13, 21, 0.97));
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.2);
}

.hero-card,
.lesson-shell,
.reflection-card,
.debug-panel {
  padding: clamp(1.25rem, 5vw, 3rem);
}

.hero-card {
  min-height: min(72vh, 44rem);
  display: grid;
  align-content: center;
  overflow: hidden;
  position: relative;
}

.hero-card::after {
  content: "";
  position: absolute;
  width: 18rem;
  height: 18rem;
  right: -7rem;
  bottom: -8rem;
  border: 1px solid rgba(39, 219, 200, 0.2);
  border-radius: 50%;
  box-shadow: 0 0 0 2.5rem rgba(39, 219, 200, 0.025), 0 0 0 5rem rgba(39, 219, 200, 0.018);
  pointer-events: none;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 50rem;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 43rem;
  margin: 1.1rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  line-height: 1.65;
}

.hero-actions,
.button-row,
.compare-actions,
.debug-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
}

.hero-actions { margin-top: 1.6rem; }

.btn {
  min-height: 2.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.78rem 1.05rem;
  border: 1px solid transparent;
  border-radius: 0.95rem;
  cursor: pointer;
  font-weight: 850;
  line-height: 1.2;
  text-decoration: none;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }

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

.btn-primary {
  border-color: var(--teal);
  background: var(--teal);
  color: var(--teal-ink);
}

.btn-secondary {
  border-color: rgba(39, 219, 200, 0.42);
  background: rgba(39, 219, 200, 0.08);
  color: var(--teal);
}

.btn-quiet {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.btn-danger {
  border-color: rgba(255, 142, 142, 0.35);
  background: rgba(255, 142, 142, 0.08);
  color: var(--danger);
}

.muted { color: var(--muted); }

.fa-text {
  direction: rtl;
  font-family: Tahoma, Arial, sans-serif;
  line-height: 1.9;
  text-align: right;
}

.privacy-note,
.notice,
.error-note,
.success-note {
  padding: 0.9rem 1rem;
  border: 1px solid rgba(39, 219, 200, 0.18);
  border-radius: 0.9rem;
  background: rgba(39, 219, 200, 0.055);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.error-note {
  border-color: rgba(255, 142, 142, 0.3);
  background: rgba(255, 142, 142, 0.08);
  color: #ffd0d0;
}

.success-note {
  border-color: rgba(39, 219, 200, 0.3);
  color: #c7fff8;
}

.resume-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: clamp(1rem, 3vw, 1.4rem);
  border: 1px solid rgba(247, 201, 72, 0.28);
  border-radius: var(--radius-md);
  background: rgba(247, 201, 72, 0.065);
}

.resume-card p { margin-bottom: 0; color: var(--muted); }

.journey-section { scroll-margin-top: 6rem; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
}

.section-heading p { margin: 0; color: var(--muted); }

.journey-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.8rem;
}

.journey-card {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 0.6rem;
  padding: 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.035);
  text-align: left;
  cursor: pointer;
}

.journey-card:hover { border-color: rgba(39, 219, 200, 0.5); }

.journey-number {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: rgba(39, 219, 200, 0.12);
  color: var(--teal);
  font-weight: 900;
}

.journey-card h3 { margin: 0; }
.journey-card .fa-text { color: var(--gold); font-size: 0.9rem; }

.status-label {
  width: fit-content;
  margin-top: auto;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.status-label[data-status="completed"] {
  border-color: rgba(39, 219, 200, 0.32);
  background: rgba(39, 219, 200, 0.09);
  color: var(--teal);
}

.status-label[data-status="in-progress"] {
  border-color: rgba(247, 201, 72, 0.32);
  background: rgba(247, 201, 72, 0.07);
  color: var(--gold);
}

.confidence-card {
  max-width: 48rem;
  margin-inline: auto;
}

.confidence-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 1.3rem 0;
}

.confidence-option {
  min-height: 5.8rem;
  padding: 0.7rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}

.confidence-option:hover { border-color: var(--teal); }
.confidence-option strong { display: block; color: var(--teal); font-size: 1.35rem; }
.confidence-option span { display: block; margin-top: 0.35rem; color: var(--muted); font-size: 0.76rem; }

.progress-summary {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1.2rem;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
}

.progress-track {
  height: 0.45rem;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-fill {
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.lesson-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.lesson-number {
  display: grid;
  width: 3.2rem;
  height: 3.2rem;
  place-items: center;
  border-radius: 50%;
  background: rgba(39, 219, 200, 0.12);
  color: var(--teal);
  font-size: 1.15rem;
  font-weight: 900;
}

.lesson-heading .fa-text { margin: 0; color: var(--gold); font-size: 1.05rem; }

.stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  margin: 1.3rem 0;
  padding: 0;
  list-style: none;
}

.stepper li {
  min-width: 0;
  padding: 0.55rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-align: center;
}

.stepper li[aria-current="step"] {
  border-color: rgba(247, 201, 72, 0.5);
  background: rgba(247, 201, 72, 0.08);
  color: var(--gold);
}

.step-content { display: grid; gap: 1rem; }

.situation-card,
.prompt-card,
.dialogue-card,
.drill-card,
.speed-item,
.real-content,
.challenge-card,
.feedback-card {
  padding: clamp(1rem, 3vw, 1.35rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.035);
}

.situation-card p:last-child,
.prompt-card p:last-child { margin-bottom: 0; }

.prompt-card {
  border-color: rgba(247, 201, 72, 0.24);
  background: rgba(247, 201, 72, 0.055);
}

.speaking-prompt {
  margin-bottom: 0.65rem;
  color: var(--gold);
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 900;
}

.practice-panel {
  display: grid;
  gap: 0.8rem;
  padding: clamp(1rem, 4vw, 1.5rem);
  border: 1px solid rgba(39, 219, 200, 0.28);
  border-radius: var(--radius-md);
  background: rgba(39, 219, 200, 0.045);
}

.record-button {
  width: 100%;
  min-height: 4.2rem;
  border: 1px solid var(--teal);
  border-radius: 1.2rem;
  background: var(--teal);
  color: var(--teal-ink);
  cursor: pointer;
  font-size: clamp(1.05rem, 3vw, 1.25rem);
  font-weight: 950;
}

.record-button[data-state="recording"] {
  border-color: #ff8585;
  background: #ff8585;
  color: #240303;
  animation: pulse 1.4s ease-in-out infinite;
}

.record-button:disabled { opacity: 0.6; cursor: wait; }

@keyframes pulse {
  50% { box-shadow: 0 0 0 0.65rem rgba(255, 133, 133, 0.1); }
}

.recorder-status {
  min-height: 1.5rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.model-audio-status {
  margin: 0.65rem 0 0;
  font-size: 0.85rem;
}

.fallback-details {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
  color: var(--muted);
}

.fallback-details summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
}

.fallback-content {
  display: grid;
  gap: 0.65rem;
  padding-top: 0.7rem;
}

.compare-actions { border-top: 1px solid var(--line); padding-top: 0.8rem; }

.answer-reveal {
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(39, 219, 200, 0.09);
}

.answer-reveal strong {
  display: block;
  color: var(--teal);
  font-size: clamp(1.15rem, 4vw, 1.55rem);
  line-height: 1.4;
}

.dialogue {
  display: grid;
  gap: 0.7rem;
}

.dialogue-line {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.8rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.025);
}

.dialogue-line[data-speaker="you"] {
  border-color: rgba(39, 219, 200, 0.32);
  background: rgba(39, 219, 200, 0.055);
}

.speaker-label {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.drill-list,
.speed-list,
.real-link-grid { display: grid; gap: 0.75rem; }

.drill-card .practice-panel { margin-top: 0.8rem; }

.drill-label {
  display: inline-block;
  margin-bottom: 0.55rem;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.speed-item {
  display: grid;
  gap: 0.75rem;
}

.speed-item .fa-text { margin-bottom: 0; font-size: 1.12rem; }

.speed-answer {
  padding: 0.8rem;
  border-radius: 0.8rem;
  background: rgba(39, 219, 200, 0.075);
  color: var(--teal);
  font-size: 1.05rem;
  font-weight: 850;
}

.real-content details {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.025);
}

.real-content summary {
  padding: 1rem;
  cursor: pointer;
  font-weight: 850;
}

.real-content-body { padding: 0 1rem 1rem; }

.real-link-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.real-link {
  display: grid;
  gap: 0.3rem;
  padding: 1rem;
  border: 1px solid rgba(39, 219, 200, 0.24);
  border-radius: 1rem;
  background: rgba(39, 219, 200, 0.05);
  text-decoration: none;
}

.real-link strong { color: var(--teal); }

.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.challenge-model {
  margin: 0.8rem 0;
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(39, 219, 200, 0.075);
}

label { font-weight: 800; }

.field-label { display: grid; gap: 0.5rem; }

textarea,
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: #090f18;
  color: var(--text);
  padding: 0.85rem;
  line-height: 1.55;
}

textarea { min-height: 7rem; resize: vertical; }

.phrase-results { min-height: 1.5rem; margin: 0.65rem 0 0; color: var(--muted); }

.feedback-card { display: grid; gap: 1rem; }

.rating-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
}

.rating-button {
  min-height: 3.2rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  font-weight: 900;
}

.rating-button[aria-pressed="true"] {
  border-color: var(--teal);
  background: rgba(39, 219, 200, 0.12);
  color: var(--teal);
}

.character-count { color: var(--muted); font-size: 0.75rem; text-align: right; }

.confidence-comparison {
  width: fit-content;
  margin: 1rem 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(247, 201, 72, 0.28);
  border-radius: 0.85rem;
  background: rgba(247, 201, 72, 0.065);
  color: var(--gold);
  font-weight: 800;
}

.debug-panel pre {
  max-height: 24rem;
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #05080d;
  color: #d7e4f5;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

.site-footer {
  padding: 1rem 2rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

@media (max-width: 42rem) {
  .site-header { position: static; flex-wrap: wrap; }
  .header-actions { width: 100%; justify-content: flex-end; }
  .site-footer { padding-inline: 1rem; }
  .hero-card { min-height: auto; }
  .journey-grid { grid-template-columns: 1fr; }
  .journey-card { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
  .journey-card .fa-text { grid-column: 2 / -1; }
  .status-label { grid-column: 3; grid-row: 1; }
  .confidence-grid { grid-template-columns: repeat(5, minmax(3.2rem, 1fr)); gap: 0.35rem; }
  .confidence-option { min-height: 4.2rem; }
  .confidence-option span { display: none; }
  .stepper li { min-height: 0.4rem; padding: 0; border: 0; border-radius: 99px; background: rgba(255,255,255,0.08); color: transparent; font-size: 0; }
  .stepper li[aria-current="step"] { background: var(--gold); }
  .dialogue-line { grid-template-columns: 1fr; }
  .real-link-grid { grid-template-columns: 1fr; }
  .resume-card { grid-template-columns: 1fr; }
  .lesson-nav {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin-inline: -0.5rem;
    padding: 0.8rem 0.5rem calc(0.8rem + env(safe-area-inset-bottom));
    border-radius: 1rem 1rem 0 0;
    background: rgba(8, 13, 21, 0.94);
    backdrop-filter: blur(14px);
  }
  .lesson-nav .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
