:root {
  --bg: #ffffff;
  --ink: #1d2029;
  --muted: #666b76;
  --quiet: #8b9099;
  --line: #e4e5e1;
  --line-strong: #cfd2cc;
  --panel: #f6f6f2;
  --panel-warm: #f7f2eb;
  --panel-blue: #eef6fb;
  --panel-green: #edf6ef;
  --panel-pink: #f7edf1;
  --primary: #1d2029;
  --primary-ink: #ffffff;
  --secondary: #eceee8;
  --danger: #c84337;
  --success: #15825f;
  --accent: #d9f36b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 18px 42px rgba(29, 32, 41, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter Display", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  min-height: 2.75rem;
  padding: 0.7rem 1rem;
  font-weight: 650;
  line-height: 1;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 82%, white);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

a {
  color: inherit;
}

.student-shell {
  width: 100%;
  min-height: 100vh;
}

.screen {
  display: grid;
  gap: 1rem;
  width: min(1180px, calc(100% - 80px));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

#screen-login {
  width: 100%;
  min-height: 100vh;
  padding: 0 40px 2.5rem;
  gap: 0;
}

.screen.hidden,
.hidden {
  display: none !important;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  gap: 1rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.08rem;
  color: var(--ink);
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
}

.brand-mark span {
  display: inline-grid;
  place-items: center;
  width: 1rem;
  height: 1rem;
  border-radius: 0.18rem;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.75rem;
  line-height: 1;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.25rem;
  font-size: 0.95rem;
  font-weight: 650;
}

.top-nav a {
  text-decoration: none;
}

.top-nav .ghost {
  min-height: auto;
  border: 0;
  background: transparent;
  padding: 0;
}

.login-hero {
  display: grid;
  grid-template-columns: minmax(0, 660px) auto;
  align-items: end;
  gap: 2rem;
  min-height: 430px;
  padding: 7.5rem 0 2.35rem;
}

.login-copy {
  display: grid;
  gap: 1.1rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  color: var(--ink);
  font-weight: 720;
  line-height: 1.05;
}

h1 {
  max-width: 12ch;
  font-size: 4.15rem;
}

h2 {
  font-size: 2.35rem;
}

h3 {
  font-size: 1.42rem;
}

.lede {
  max-width: 42rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.start-link {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 1rem;
  align-items: center;
  justify-self: end;
  min-width: 9rem;
  padding-bottom: 1.15rem;
  color: var(--ink);
  font-size: 1.12rem;
  text-decoration: none;
}

.start-link::after {
  content: "";
  grid-column: 1 / 2;
  width: 2rem;
  height: 0.18rem;
  border-radius: 999px;
  background: var(--ink);
}

.start-link span:last-child {
  font-size: 1.55rem;
  line-height: 1;
}

.login-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(220px, 0.78fr) minmax(0, 1.05fr);
  gap: 10px;
  align-items: stretch;
}

.card,
.exercise-card,
.word-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.card,
.exercise-card {
  padding: 1.1rem;
}

.login-card,
.signup-card {
  min-height: 350px;
  align-content: start;
}

.login-card {
  background: var(--panel);
}

.signup-card {
  background: var(--panel-warm);
}

.word-card {
  position: relative;
  min-height: 350px;
  overflow: hidden;
  display: grid;
  align-content: end;
  padding: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 52%),
    var(--panel-blue);
}

.word-card::before {
  content: "";
  position: absolute;
  inset: 3rem 1.8rem auto;
  aspect-ratio: 1;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.84;
}

.word-card::after {
  content: "";
  position: absolute;
  right: -1.6rem;
  bottom: -2.6rem;
  width: 11.5rem;
  height: 11.5rem;
  border: 1px solid rgba(29, 32, 41, 0.18);
  border-radius: 999px;
}

.word-card-plus {
  position: absolute;
  top: 1rem;
  right: 1.1rem;
  font-size: 2rem;
  line-height: 1;
  z-index: 1;
}

.word-card-small,
.word-card-caption,
.section-label,
.kicker,
.micro {
  color: var(--muted);
}

.word-card-small {
  position: relative;
  z-index: 1;
  align-self: start;
  font-size: 0.92rem;
  font-weight: 650;
}

.word-card-word {
  position: relative;
  z-index: 1;
  font-size: 5rem;
  font-weight: 760;
  line-height: 0.95;
}

.word-card-caption {
  position: relative;
  z-index: 1;
  margin-top: 0.3rem;
  font-size: 0.88rem;
}

.family-login-example {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.family-login-example span {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff;
  padding: 0.45rem 0.65rem;
  color: var(--ink);
  font-weight: 720;
}

.stack {
  display: grid;
  gap: 0.82rem;
}

.section-label,
.kicker {
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 0.36rem;
}

label span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 560;
}

input,
select {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--ink);
  padding: 0.68rem 0.78rem;
}

select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%) calc(100% - 1.05rem) 50% / 0.42rem 0.42rem no-repeat,
    linear-gradient(135deg, var(--ink) 50%, transparent 50%) calc(100% - 0.74rem) 50% / 0.42rem 0.42rem no-repeat,
    #ffffff;
  padding-right: 2.2rem;
}

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

.secondary {
  background: var(--secondary);
  color: var(--ink);
}

.danger {
  background: var(--danger);
  color: #ffffff;
}

.ghost {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 3.2rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.8rem;
}

.meta {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
}

.micro {
  font-size: 0.86rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-card,
.grade-pill,
.challenge-choice,
.practice-tile,
.decoding-switch,
.blend-chip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.mode-card {
  position: relative;
  min-height: 210px;
  display: grid;
  align-content: end;
  gap: 0.5rem;
  padding: 1rem;
  overflow: hidden;
}

.mode-card::after {
  content: "+";
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1;
}

.mode-card.vocab {
  background: var(--panel-green);
}

.mode-card.vocab-diagnostic {
  background: var(--panel-blue);
}

.mode-card.decoding {
  background: var(--panel-pink);
}

.mode-card strong {
  max-width: 11rem;
  font-size: 1.55rem;
  line-height: 1.05;
}

.mode-card span {
  color: var(--muted);
  font-size: 0.94rem;
}

.mode-card:disabled {
  color: var(--quiet);
  background: #f3f3ef;
}

.grade-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.grade-pill {
  min-height: 96px;
  display: grid;
  align-content: center;
  gap: 0.25rem;
  padding: 0.9rem;
}

.grade-pill:hover,
.challenge-choice:hover,
.practice-tile:hover,
.decoding-switch:hover,
.blend-chip:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.grade-pill.active,
.decoding-switch.current,
.decoding-switch.active,
.practice-tile.active,
.blend-chip.active {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.grade-pill-title,
.decoding-switch-label,
.practice-tile .tile-word,
.challenge-choice .choice-main {
  font-weight: 720;
}

.grade-pill-title,
.decoding-switch-label {
  font-size: 1.06rem;
}

.grade-pill-copy,
.decoding-switch-copy,
.challenge-choice .choice-sub,
.practice-tile .tile-meaning,
.practice-tile .tile-rank {
  color: var(--muted);
  font-size: 0.83rem;
}

.exercise-card {
  min-height: 184px;
  display: grid;
  align-content: center;
  gap: 0.55rem;
  background: var(--panel);
}

.exercise-card.empty {
  color: var(--muted);
}

.exercise-card .french {
  font-size: 2.3rem;
  font-weight: 760;
  line-height: 1;
}

.exercise-card .english {
  color: var(--muted);
  font-size: 1.1rem;
}

.exercise-card .emoji {
  font-size: 1.7rem;
}

.card-visual {
  position: relative;
  display: grid;
  place-items: center;
  justify-self: center;
  width: min(220px, 100%);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 0.55rem;
}

.vocab-visual {
  width: min(260px, 100%);
}

.card-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-visual.has-emoji span,
.card-visual.placeholder span {
  font-size: 5rem;
  line-height: 1;
}

.card-visual.placeholder {
  background: var(--panel-blue);
}

.vocab-visual-progress {
  position: absolute;
  right: 0.55rem;
  bottom: 0.55rem;
  left: 0.55rem;
  height: 0.42rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(29, 32, 41, 0.12);
  pointer-events: none;
}

.vocab-visual-progress span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
  transform-origin: left center;
  animation: vocab-progress-drain var(--vocab-progress-duration, 5s) linear forwards;
}

.vocab-study-card.revealed .vocab-visual-progress span {
  background: var(--success);
}

@keyframes vocab-progress-drain {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.star-row {
  color: var(--ink);
  font-size: 1.25rem;
}

.vocab-study-card,
.vocab-quiz-card,
.vocab-summary-card {
  text-align: center;
}

.vocab-countdown,
.vocab-audio-prompt {
  justify-self: center;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 760;
}

.vocab-countdown {
  width: 4.6rem;
  height: 4.6rem;
  font-size: 2rem;
}

.vocab-audio-prompt {
  width: 9rem;
  aspect-ratio: 1;
  padding-left: 0.2rem;
  font-size: 4.2rem;
}

.vocab-word-pair {
  display: grid;
  gap: 0.2rem;
  justify-items: center;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.challenge-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0.85rem 0;
}

.challenge-choice {
  min-height: 108px;
  display: grid;
  align-content: center;
  gap: 0.35rem;
  padding: 0.88rem;
}

.challenge-choice.choice-tile {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  cursor: pointer;
}

.vocab-choice.choice-tile {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  text-align: center;
}

.choice-speak-button {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0 0 0 0.16rem;
  border: 1px solid var(--line-strong);
  background: var(--panel);
}

.choice-copy {
  min-width: 0;
  display: grid;
  gap: 0.24rem;
}

.challenge-choice .choice-main {
  overflow-wrap: anywhere;
  font-size: 1.24rem;
  line-height: 1.08;
}

.challenge-choice .choice-main.emoji {
  font-size: 2.35rem;
}

.challenge-choice.correct,
.practice-tile.correct {
  border-color: color-mix(in srgb, var(--success) 72%, white);
  background: #edf8f1;
}

.challenge-choice.wrong,
.practice-tile.wrong {
  border-color: color-mix(in srgb, var(--danger) 72%, white);
  background: #fff0ed;
}

.challenge-choice.idle-dim,
.practice-tile.idle-dim {
  opacity: 0.72;
}

.practice-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 0.75rem;
}

.decoding-grid {
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.decoding-rail,
.decoding-workspace {
  min-width: 0;
}

.decoding-switcher {
  display: grid;
  gap: 10px;
  height: 100%;
}

.decoding-switch {
  min-height: 116px;
  display: grid;
  align-content: center;
  gap: 0.32rem;
  padding: 0.95rem;
}

.decoding-switch.current {
  background: var(--panel-warm);
}

.decoding-switch.active:not(.current) {
  background: var(--panel-blue);
}

.decoding-pane {
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1.1rem;
}

.decoding-pane.current {
  border-color: var(--ink);
}

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

.section-headline.compact,
.section-actions {
  align-items: center;
}

.sound-panel-actions {
  margin-top: 0.95rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.decoding-hero-card {
  min-height: 0;
  background: #ffffff;
  box-shadow: none;
}

.decoding-hero-kicker,
.decoding-hero-progress,
.decoding-hero-support {
  color: var(--muted);
}

.decoding-hero-grapheme {
  color: var(--ink);
  font-size: 4.2rem !important;
  line-height: 0.94;
}

.decoding-hero-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.18rem !important;
}

.inline-audio-button {
  min-height: 2rem;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  padding: 0.28rem 0.72rem;
  font-size: 0.82rem;
}

.challenge-prompt {
  min-height: 132px;
  display: grid;
  align-content: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 1rem;
}

.challenge-prompt .prompt-kicker {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.challenge-prompt .prompt-main {
  font-size: 1.85rem;
  font-weight: 760;
  line-height: 1.05;
}

.challenge-prompt .prompt-main.emoji {
  font-size: 3rem;
}

.practice-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.practice-tile {
  min-height: 122px;
  display: grid;
  gap: 0.3rem;
  padding: 0.85rem;
}

.practice-tile .tile-word {
  font-size: 1.18rem;
  line-height: 1.08;
}

.practice-tile .tile-emoji {
  justify-self: end;
  font-size: 1.45rem;
  line-height: 1;
}

.blend-panel {
  background: var(--panel-warm);
}

.blend-headline {
  align-items: start;
}

.blend-stage-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 1rem;
}

.blend-stage-copy {
  display: grid;
  gap: 0.35rem;
}

.blend-stage-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
  text-transform: uppercase;
}

.blend-focus {
  color: var(--ink);
  font-size: 3.8rem;
  font-weight: 780;
  line-height: 0.95;
}

.blend-stage-actions {
  display: grid;
  gap: 0.55rem;
  min-width: min(220px, 100%);
}

#blend-record.is-recording {
  background: var(--danger);
  color: #ffffff;
}

#blend-record.is-busy {
  opacity: 0.88;
}

.blend-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 0.95rem;
}

.blend-chip {
  padding: 0.82rem 0.45rem;
  color: var(--ink);
  text-align: center;
  font-size: 1.16rem;
  font-weight: 720;
}

.blend-result {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 0.95rem;
  line-height: 1.55;
}

.decoding-actions {
  justify-content: flex-start;
  margin-top: 0.2rem;
}

.diagnostic-table {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius);
  background: #ffffff;
}

.diagnostic-table th,
.diagnostic-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.62rem 0.68rem;
  text-align: left;
}

.diagnostic-table th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.diagnostic-table tr:last-child td {
  border-bottom: 0;
}

.toast {
  position: fixed;
  right: 0.8rem;
  bottom: 0.8rem;
  z-index: 20;
  max-width: min(28rem, calc(100vw - 1.6rem));
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #ffffff;
  padding: 0.62rem 0.8rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  #screen-login {
    padding: 0 20px 2rem;
  }

  .screen {
    width: min(100% - 40px, 880px);
  }

  .login-hero {
    min-height: 360px;
    grid-template-columns: 1fr;
    align-items: start;
    padding-top: 4rem;
  }

  .start-link {
    justify-self: start;
  }

  .login-strip,
  .mode-grid,
  .decoding-grid {
    grid-template-columns: 1fr;
  }

  .word-card {
    min-height: 260px;
  }

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

@media (max-width: 700px) {
  .site-header {
    min-height: 44px;
  }

  .top-nav {
    font-size: 0.9rem;
  }

  h1 {
    font-size: 3rem;
  }

  h2 {
    font-size: 2rem;
  }

  .login-hero {
    min-height: 270px;
    padding-top: 2.8rem;
  }

  .login-card,
  .signup-card {
    min-height: 0;
  }

  .challenge-choices,
  .blend-stage-card {
    grid-template-columns: 1fr;
  }

  .challenge-choice.choice-tile {
    grid-template-columns: minmax(0, 1fr);
  }

  .choice-speak-button {
    justify-self: start;
  }

  .blend-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .blend-stage-actions {
    min-width: 0;
  }

  .decoding-hero-grapheme {
    font-size: 3.4rem !important;
  }
}

@media (max-width: 460px) {
  #screen-login {
    padding-inline: 10px;
  }

  .screen {
    width: calc(100% - 20px);
    padding-bottom: 2.5rem;
  }

  .top-nav {
    gap: 0.8rem;
  }

  h1 {
    font-size: 2.6rem;
  }

  .login-hero {
    min-height: 250px;
    gap: 1.1rem;
  }

  .word-card-word {
    font-size: 4.1rem;
  }

  .mode-card {
    min-height: 180px;
  }

  .practice-tiles,
  .blend-grid {
    grid-template-columns: 1fr;
  }
}

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