:root {
  color-scheme: light;
  --ink: #11162f;
  --ink-2: #1a2145;
  --muted: #697087;
  --paper: #f3f5f8;
  --card: #ffffff;
  --line: #dfe3eb;
  --lime: #d8ff72;
  --lime-deep: #a8db28;
  --coral: #ff665a;
  --coral-dark: #e9473e;
  --blue: #586cff;
  --sky: #dfe5ff;
  --shadow: 0 20px 55px rgba(17, 22, 47, .10);
  --shadow-soft: 0 8px 24px rgba(17, 22, 47, .07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 4%, rgba(88, 108, 255, .14), transparent 25rem),
    radial-gradient(circle at 4% 38%, rgba(216, 255, 114, .18), transparent 22rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

button, input, select, audio { font: inherit; }
button { color: inherit; }
.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; }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 64px);
  color: white;
  background: rgba(17, 22, 47, .96);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: white; text-decoration: none; font-size: 1.45rem; font-weight: 850; letter-spacing: -.05em; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 11px; color: var(--ink); background: var(--lime); font-size: 1.3rem; font-weight: 900; transform: rotate(-5deg); box-shadow: 4px 4px 0 var(--blue); }
.brand-dot { color: var(--coral); }
.session-meta { display: flex; align-items: center; gap: 13px; font-size: .82rem; }
.session-pulse { display: inline-flex; align-items: center; gap: 7px; color: #ccd0df; }
.session-pulse i { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px rgba(216, 255, 114, .12); }
.level-pill { padding: 7px 11px; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; color: var(--lime); font-weight: 800; }
.attempt-label { color: #aeb5cd; font-weight: 650; }

main {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 90px;
  display: grid;
  grid-template-columns: 214px minmax(0, 820px);
  justify-content: center;
  gap: clamp(36px, 6vw, 84px);
}
.journey { position: sticky; top: 110px; align-self: start; padding: 18px 0; }
.journey-heading { display: flex; align-items: center; justify-content: space-between; }
.journey-heading .eyebrow { margin: 0; }
.journey-heading strong { font-size: .78rem; color: var(--muted); }
.eyebrow, .stage-kicker { margin: 0 0 10px; text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; font-weight: 850; color: var(--blue); }
.flow-progress { height: 5px; margin: 14px 0 21px; overflow: hidden; border-radius: 99px; background: #dfe3ea; }
.flow-progress span { display: block; width: 14.285%; height: 100%; border-radius: inherit; background: var(--blue); transition: width .45s cubic-bezier(.2,.8,.2,1); }
.journey ol { list-style: none; margin: 0; padding: 0; position: relative; }
.journey ol::before { content: ''; position: absolute; left: 17px; top: 18px; bottom: 18px; width: 1px; background: var(--line); }
.journey li { min-height: 56px; display: grid; grid-template-columns: 35px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-content: center; color: #747b8e; position: relative; transition: color .25s, transform .25s; }
.journey li > span { grid-row: 1 / 3; width: 35px; height: 35px; display: grid; place-items: center; align-self: center; border-radius: 11px; border: 1px solid var(--line); background: var(--paper); font-size: .75rem; font-weight: 850; transition: all .25s; }
.journey li b { align-self: end; font-size: .9rem; line-height: 1.15; }
.journey li small { font-size: .75rem; line-height: 1.25; }
.journey li.is-current { color: var(--ink); transform: translateX(4px); }
.journey li.is-current > span { color: var(--ink); border-color: var(--lime-deep); background: var(--lime); box-shadow: 0 0 0 5px rgba(216,255,114,.28); }
.journey li.is-done > span { color: white; border-color: var(--blue); background: var(--blue); }
.journey-note { margin: 20px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: rgba(255,255,255,.5); font-size: .75rem; line-height: 1.4; }
.journey-note span { color: var(--blue); font-weight: 900; }

.practice-column { min-width: 0; }
.learner-panel { padding: 16px 20px; margin-bottom: 22px; }
.learner-panel summary { cursor: pointer; }
.learner-panel summary span { display: block; margin-top: 5px; color: var(--muted); font-size: .875rem; }
.account-form { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; align-items: end; }
.account-form label { flex: 1 1 180px; font-size: .875rem; }
.account-form input { display: block; width: 100%; padding: 11px; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; }
.account-form p, #learnerDashboard > p, #saveStatus { color: var(--muted); font-size: .875rem; line-height: 1.5; }
.practice-history { padding-left: 20px; }
.practice-history li { margin-block: 16px; }
.practice-history p { color: var(--muted); font-size: .875rem; margin: 5px 0; }
.next-exercise { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; margin: 24px 0 0; padding: 26px; }
.next-exercise h2 { margin: 0 0 8px; font-size: 1.5rem; letter-spacing: -.035em; }
.next-exercise p:last-child { margin: 0; color: var(--muted); font-size: .875rem; }
.next-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.change-theme-link { color: var(--ink); font-size: .875rem; text-underline-offset: 4px; padding: 12px 4px; }
.change-theme-link:focus-visible { outline: 3px solid var(--lime-deep); outline-offset: 3px; }
#themeInput { scroll-margin-top: 110px; }
.intro { margin-bottom: 25px; display: flex; justify-content: space-between; gap: 26px; align-items: end; }
.intro h1 { margin: 0; max-width: 600px; font-size: clamp(2.45rem, 6vw, 4.4rem); line-height: .95; letter-spacing: -.07em; font-weight: 900; }
.intro h1 em { color: var(--blue); font-style: normal; }
.intro > p { width: 190px; margin: 0 0 5px; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.card { border: 1px solid rgba(17,22,47,.10); border-radius: 20px; background: var(--card); box-shadow: var(--shadow-soft); }

.exercise-controls { margin-bottom: 14px; padding: 14px; display: grid; grid-template-columns: 88px 1fr 1.3fr auto; gap: 10px; align-items: end; }
.exercise-controls label { min-width: 0; }
.theme-help { grid-column: 1 / -1; margin: 2px 3px 0; font-size: .875rem; color: var(--muted); line-height: 1.4; }
.exercise-controls label > span { display: block; margin: 0 0 6px 3px; color: var(--muted); font-size: .8rem; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.exercise-controls small { font-weight: 550; text-transform: none; letter-spacing: 0; }
.exercise-controls input, .exercise-controls select { width: 100%; height: 45px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #f8f9fb; outline: none; font-size: .9rem; }
.exercise-controls input:focus, .exercise-controls select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(88,108,255,.14); background: white; }
.generate-button { height: 45px; padding: 0 17px; border: 0; border-radius: 10px; color: var(--ink); background: var(--lime); cursor: pointer; font-weight: 850; white-space: nowrap; box-shadow: inset 0 -2px 0 rgba(17,22,47,.13); transition: transform .2s, background .2s; }
.generate-button:hover { background: #caff42; transform: translateY(-2px); }
.generate-button:disabled { cursor: wait; opacity: .65; transform: none; }

.sentence-card { min-height: 190px; display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 22px; padding: 28px 30px; margin-bottom: 14px; color: white; border: 0; background: linear-gradient(125deg, var(--ink) 0%, var(--ink-2) 64%, #313c83 100%); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.sentence-card::after { content: '“'; position: absolute; right: 78px; top: -70px; color: rgba(255,255,255,.055); font: 900 260px/1 Georgia, serif; pointer-events: none; }
.sentence-number { align-self: stretch; display: flex; flex-direction: column; justify-content: space-between; position: relative; z-index: 1; }
.sentence-number span { color: var(--lime); font-size: .75rem; font-weight: 850; letter-spacing: .13em; writing-mode: vertical-rl; transform: rotate(180deg); }
.sentence-number strong { color: rgba(255,255,255,.45); font-size: .8rem; }
.sentence-copy { position: relative; z-index: 1; }
.sentence { margin: 0; font-size: clamp(1.65rem, 4vw, 2.55rem); line-height: 1.13; letter-spacing: -.035em; font-weight: 780; text-wrap: balance; }
.translation { margin: 11px 0 0; color: #b7bfd8; font-size: .9rem; }
.sentence-focus { display: inline-block; margin: 15px 0 0; padding: 6px 10px; border-radius: 7px; color: var(--ink); background: var(--lime); font-size: .78rem; font-weight: 800; }
.sentence-card.is-loading .sentence, .sentence-card.is-loading .translation { color: transparent; border-radius: 6px; background: linear-gradient(90deg, #293052 25%, #353e68 50%, #293052 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.sentence-card.is-loading .sentence { max-width: 520px; }
.sentence-card.is-loading .translation { max-width: 260px; }
.icon-button:disabled, .record-button:disabled { cursor: not-allowed; filter: grayscale(.5); opacity: .45; }
.icon-button { width: 53px; height: 62px; border: 1px solid rgba(255,255,255,.13); border-radius: 14px; display: grid; place-items: center; align-content: center; gap: 3px; color: white; background: rgba(255,255,255,.08); cursor: pointer; position: relative; z-index: 1; transition: transform .2s, background .2s; }
.icon-button:hover { transform: translateY(-2px); background: rgba(216,255,114,.16); }
.icon-button svg, .secondary-button svg, .privacy-note svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-label { font-size: .75rem; color: #ccd2e5; font-weight: 750; }

.record-stage { min-height: 285px; padding: 36px 42px; display: grid; grid-template-columns: 1fr 240px; align-items: center; position: relative; overflow: hidden; }
.record-stage::before { content: ''; position: absolute; inset: 0; opacity: .42; background-image: linear-gradient(rgba(88,108,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(88,108,255,.08) 1px, transparent 1px); background-size: 26px 26px; mask-image: linear-gradient(90deg, transparent 35%, black); pointer-events: none; }
.record-copy { max-width: 410px; position: relative; z-index: 1; }
.record-copy h2, .playback-card h2, .feedback-content h2, .improvement-card h2 { margin: 0 0 9px; font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.15; letter-spacing: -.035em; }
.record-copy p:last-of-type, .playback-card p:last-child { margin: 0; color: var(--muted); line-height: 1.55; font-size: .9rem; }
.record-cues { display: flex; align-items: center; gap: 8px; margin-top: 25px; color: #737a8d; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 750; }
.record-cues i { width: 18px; height: 1px; background: var(--line); }
.record-zone { min-height: 210px; display: grid; place-items: center; position: relative; z-index: 1; }
.record-orbit { position: absolute; width: 196px; height: 196px; border: 1px solid #e2e5ec; border-radius: 50%; }
.record-orbit::before, .record-orbit::after { content: ''; position: absolute; inset: 18px; border: 1px dashed #d6dae5; border-radius: 50%; }
.record-orbit::after { inset: -11px; border-style: solid; border-color: transparent transparent var(--sky) var(--sky); transform: rotate(-30deg); }
.record-button { width: 128px; height: 128px; border: 0; border-radius: 50%; background: var(--coral); color: white; display: grid; place-content: center; gap: 7px; cursor: pointer; position: relative; z-index: 2; box-shadow: 0 16px 36px rgba(233,71,62,.27), inset 0 0 0 7px rgba(255,255,255,.14); transition: transform .2s, background .2s; }
.record-button:hover { transform: scale(1.045); background: var(--coral-dark); }
.record-button:focus-visible, button:focus-visible { outline: 3px solid var(--lime-deep); outline-offset: 3px; }
.record-core { width: 25px; height: 25px; justify-self: center; border: 2px solid white; border-radius: 50%; }
.record-text { font-size: .875rem; font-weight: 850; }
.record-stage.is-recording .record-button { animation: pulse 1.4s infinite; }
.record-stage.is-recording .record-core { width: 20px; height: 20px; border-radius: 4px; background: white; }
.record-stage.is-recording .record-orbit { animation: spin 7s linear infinite; border-color: var(--coral); }
.timer { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: .08em; }
.level-bars { position: absolute; left: 50%; top: 7px; transform: translateX(-50%); display: flex; gap: 3px; align-items: center; height: 18px; opacity: .3; }
.level-bars i { display: block; width: 3px; height: 4px; border-radius: 3px; background: var(--coral); transition: height .1s; }
.record-stage.is-recording .level-bars { opacity: 1; }

.playback-card { margin-top: 14px; padding: 28px 32px; display: grid; grid-template-columns: 1fr minmax(230px, 42%); align-items: center; gap: 28px; border-left: 5px solid var(--blue); }
audio { width: 100%; accent-color: var(--blue); }
.feedback-card { margin-top: 14px; display: grid; grid-template-columns: 215px 1fr; overflow: hidden; }
.score-block { padding: 32px 26px; background: var(--ink); color: white; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.score-ring { --score: 0; width: 132px; height: 132px; border-radius: 50%; display: grid; place-content: center; background: radial-gradient(circle closest-side, var(--ink) 76%, transparent 78% 99%), conic-gradient(var(--lime) calc(var(--score) * 1%), #303752 0); }
.score-ring strong { font-size: 2.35rem; line-height: 1; letter-spacing: -.05em; }
.score-ring span { margin-top: 5px; color: #c3c8d9; font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; }
.score-block p { margin: 18px 0 0; color: #c3c8d9; font-size: .75rem; line-height: 1.5; }
.feedback-content { padding: 34px; }
.heard-text { margin: 15px 0; padding: 11px 13px; border-left: 3px solid var(--blue); background: #f1f3ff; color: var(--muted); font-size: .875rem; }
.feedback-list { list-style: none; padding: 0; margin: 20px 0 27px; display: grid; gap: 13px; }
.feedback-list li { display: grid; grid-template-columns: 29px 1fr; gap: 11px; }
.feedback-list .tip-index { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--lime); color: var(--ink); font-size: .75rem; font-weight: 850; }
.feedback-list strong { display: block; margin-bottom: 3px; font-size: .95rem; }
.feedback-list p { margin: 0; color: var(--muted); font-size: .875rem; line-height: 1.45; }
.feedback-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.word-practice { margin: 20px 0; padding: 18px; background: #f1f3ff; border-radius: 14px; }
.word-practice h3 { margin: 0 0 10px; font-size: 1rem; }
.word-practice p { font-size: .875rem; line-height: 1.5; color: #505976; }
.word-alignment { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.word-alignment span, .word-alignment button { padding: 10px 8px; }
.word-alignment button { min-height: 44px; border: 1px solid #586cff; border-radius: 8px; background: white; color: #273bba; font-weight: 750; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.word-alignment button:hover { background: var(--lime); }
.primary-button, .secondary-button { min-height: 48px; border-radius: 11px; padding: 0 20px; border: 1px solid var(--ink); cursor: pointer; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 9px; transition: transform .2s, background .2s; }
.primary-button { color: white; background: var(--blue); border-color: var(--blue); }
.primary-button:hover { background: var(--ink); border-color: var(--ink); transform: translateY(-2px); }
.primary-button:disabled { cursor: not-allowed; opacity: .4; transform: none; }
.secondary-button { background: transparent; }
.secondary-button:hover { background: #f2f4f8; transform: translateY(-2px); }

.improvement-card { margin-top: 14px; padding: 32px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; color: var(--ink); border: 0; background: var(--lime); box-shadow: 0 18px 45px rgba(168,219,40,.18); }
.improvement-card:not(.is-hidden) { animation: reward-in .55s cubic-bezier(.18,.9,.24,1.25); }
.improvement-card p { margin: 0; color: #4b572d; }
.improvement-card .stage-kicker { color: #42511d; }
.celebration { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: var(--ink); color: var(--lime); font-size: 1.8rem; font-weight: 900; transform: rotate(-4deg); }
.attempt-comparison { display: flex; align-items: center; gap: 10px; }
.attempt-comparison div:not(.comparison-line) { min-width: 65px; text-align: center; }
.attempt-comparison span { display: block; color: #4f5a33; font-size: .75rem; text-transform: uppercase; font-weight: 750; }
.attempt-comparison strong { font-size: 1.8rem; line-height: 1.2; }
.comparison-line { width: 34px; height: 2px; background: rgba(17,22,47,.3); }
.text-button { grid-column: 2 / -1; justify-self: start; padding: 3px 0; border: 0; border-bottom: 2px solid var(--ink); color: var(--ink); background: none; cursor: pointer; font-weight: 850; }
.privacy-note { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 20px auto 0; max-width: 590px; color: var(--muted); font-size: .75rem; text-align: center; }
.privacy-note svg { width: 15px; flex: 0 0 auto; }
.toast { position: fixed; left: 50%; bottom: 25px; transform: translateX(-50%); max-width: min(460px, calc(100% - 32px)); padding: 14px 18px; border-radius: 11px; color: white; background: var(--ink); box-shadow: var(--shadow); z-index: 20; font-size: .82rem; }
.is-hidden { display: none !important; }

@keyframes pulse { 0%,100% { box-shadow: 0 16px 36px rgba(233,71,62,.27), 0 0 0 0 rgba(255,102,90,.32); } 50% { box-shadow: 0 16px 36px rgba(233,71,62,.27), 0 0 0 18px rgba(255,102,90,0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes reward-in { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 860px) {
  .topbar { height: 65px; }
  .session-pulse, .attempt-label { display: none; }
  main { width: min(100% - 28px, 720px); padding-top: 30px; display: block; }
  .journey { position: static; padding: 0; margin-bottom: 28px; }
  .journey-heading, .journey-note { display: none; }
  .flow-progress { margin: 0 0 13px; }
  .journey ol { display: flex; }
  .journey ol::before { left: 18px; right: 18px; top: 17px; bottom: auto; width: auto; height: 1px; }
  .journey li { min-height: 45px; flex: 1; display: flex; justify-content: center; }
  .journey li > span { flex: 0 0 35px; }
  .journey li b, .journey li small { display: none; }
  .journey li.is-current { transform: translateY(-3px); }
  .intro { align-items: end; }
  .intro > p { width: 175px; }
  .exercise-controls { grid-template-columns: 88px 1fr; }
  .vocabulary-control, .generate-button { grid-column: 1 / -1; }
  .record-stage { grid-template-columns: 1fr 210px; padding: 30px; }
  .record-zone { transform: scale(.9); }
  .playback-card, .feedback-card, .improvement-card { grid-template-columns: 1fr; }
  .score-block { padding: 28px; }
  .improvement-card { text-align: center; justify-items: center; }
  .text-button { grid-column: 1; justify-self: center; }
}

@media (max-width: 560px) {
  .topbar { padding-inline: 16px; }
  main { width: min(100% - 20px, 520px); padding-top: 23px; }
  .intro { display: block; }
  .intro h1 { font-size: clamp(2.4rem, 14vw, 3.7rem); }
  .intro > p { width: auto; margin-top: 14px; }
  .exercise-controls { grid-template-columns: 82px 1fr; padding: 11px; }
  .sentence-card { min-height: 210px; grid-template-columns: 30px 1fr; padding: 23px 19px; gap: 13px; }
  .sentence-number { grid-row: 1 / 3; }
  .sentence-card .icon-button { grid-column: 2; width: auto; height: 42px; display: flex; flex-direction: row; }
  .record-stage { min-height: 440px; grid-template-columns: 1fr; padding: 30px 24px; text-align: center; }
  .record-cues { justify-content: center; }
  .record-zone { transform: none; }
  .playback-card, .feedback-content { padding: 26px 22px; }
  .feedback-actions { display: grid; }
  .primary-button, .secondary-button { width: 100%; }
  .improvement-card { padding: 28px 22px; }
  .attempt-comparison { flex-wrap: wrap; justify-content: center; }
}

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