:root {
  color-scheme: light;
  --ink: #10251f;
  --muted: #5f6e68;
  --paper: #f6f4ec;
  --surface: #fffef9;
  --line: #dcded6;
  --green: #12634b;
  --green-2: #1e8163;
  --lime: #d9ef6f;
  --coral: #ef765d;
  --blue: #276a91;
  --shadow: 0 18px 50px rgba(16, 37, 31, .1);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(217, 239, 111, .35), transparent 28rem),
    radial-gradient(circle at 90% 16%, rgba(39, 106, 145, .12), transparent 24rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }

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

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 76px;
  padding: 12px clamp(18px, 4vw, 52px);
  border-bottom: 1px solid rgba(16, 37, 31, .09);
  background: rgba(246, 244, 236, .88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 780;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 15px;
  color: #fff;
  background: var(--ink);
  letter-spacing: -2px;
}

.direction-pill {
  justify-self: center;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .66);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.top-stats { display: flex; gap: 8px; }
.mini-stat { padding: 8px 11px; border-radius: 12px; background: #fff; font-size: 13px; font-weight: 750; }

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 34px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 52px) 64px;
}

.sidebar { position: sticky; top: 104px; align-self: start; display: grid; gap: 7px; }

.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-weight: 680;
}

.nav-button:hover { background: rgba(255, 255, 255, .62); color: var(--ink); }
.nav-button.active { background: var(--ink); color: #fff; }
.nav-icon { width: 24px; text-align: center; }

.content { min-width: 0; }
.notice { margin: 0 0 16px; padding: 12px 14px; border: 1px solid #e2b5a9; border-radius: 14px; background: #fff2ee; color: #7c3025; font-weight: 680; }
.audio-notice[hidden] { display: none; }
[data-audio-state="unavailable"] { border-color: var(--coral); color: #7c3025; }
.page { animation: page-in .25s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }

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

.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 13px; font-weight: 820; letter-spacing: .11em; text-transform: uppercase; }
.page-title { margin: 0; font-size: clamp(34px, 5vw, 58px); line-height: .98; letter-spacing: -.055em; }
.page-subtitle { max-width: 720px; margin: 16px 0 30px; color: var(--muted); font-size: 17px; line-height: 1.55; }

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 26px;
  padding: clamp(26px, 5vw, 54px);
  border-radius: 34px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  width: 330px;
  height: 330px;
  right: -90px;
  top: -130px;
  border-radius: 50%;
  background: var(--lime);
  opacity: .82;
}

.hero h1 { position: relative; z-index: 1; margin: 0; max-width: 760px; font-size: clamp(38px, 6vw, 72px); line-height: .97; letter-spacing: -.06em; }
.hero p { position: relative; z-index: 1; max-width: 650px; color: rgba(255,255,255,.72); font-size: 17px; line-height: 1.55; }
.hero-actions { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.hero-progress { position: relative; z-index: 2; align-self: end; padding: 24px; border: 1px solid rgba(255,255,255,.16); border-radius: 24px; background: rgba(255,255,255,.08); }
.hero-progress strong { display: block; margin-bottom: 10px; font-size: 42px; letter-spacing: -.04em; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 760;
  text-decoration: none;
}

.button:hover { filter: brightness(1.07); transform: translateY(-1px); }
.button.secondary { border-color: var(--line); background: var(--surface); color: var(--ink); }
.button.ghost { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.1); color: white; }
.button.coral { background: var(--coral); }
.button.small { min-height: 38px; padding: 8px 12px; font-size: 13px; }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }

.grid { display: grid; gap: 18px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section { margin-top: 30px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 23px; letter-spacing: -.03em; }

.panel {
  padding: 22px;
  border: 1px solid rgba(16, 37, 31, .09);
  border-radius: var(--radius);
  background: rgba(255, 254, 249, .82);
  box-shadow: 0 10px 30px rgba(16, 37, 31, .04);
}

.stat-card strong { display: block; margin-bottom: 6px; font-size: 36px; letter-spacing: -.04em; }
.stat-card span { color: var(--muted); }

.daily-step { display: flex; gap: 14px; align-items: center; }
.step-number { display: grid; flex: 0 0 auto; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: #e7eee9; color: var(--green); font-weight: 850; }
.daily-step.done .step-number { background: var(--green); color: white; }
.daily-step h3 { margin: 0 0 4px; font-size: 16px; }
.daily-step p { margin: 0; color: var(--muted); font-size: 14px; }

.study-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
.study-card { min-height: 490px; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(24px, 5vw, 48px); }
.card-image { width: 100%; max-height: 230px; object-fit: cover; border-radius: 20px; margin-bottom: 24px; background: #e5ebe5; }
.word { margin: 0; font-size: clamp(44px, 8vw, 88px); line-height: .94; letter-spacing: -.06em; overflow-wrap: anywhere; }
.ipa { margin: 13px 0 0; color: var(--blue); font-size: 20px; }
.meaning { margin: 28px 0 10px; font-size: clamp(24px, 4vw, 38px); font-weight: 760; letter-spacing: -.03em; }
.example { margin: 0; font-size: 18px; line-height: 1.5; }
.example-translation { margin: 7px 0 0; color: var(--muted); line-height: 1.45; }
.answer { min-height: 132px; }
.answer.hidden { display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 18px; color: var(--muted); }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.track-list { display: grid; gap: 9px; }
.track-button { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: white; cursor: pointer; text-align: left; }
.track-button.active { border-color: var(--green); box-shadow: 0 0 0 2px rgba(18, 99, 75, .1); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.field { width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--ink); outline: none; }
.field:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(30, 129, 99, .12); }
.toolbar .field { width: auto; min-width: 190px; }

.word-list { display: grid; gap: 8px; }
.visual-word-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 0 0 22px; }
.visual-word-card { overflow: hidden; padding: 0; }
.visual-word-card img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #eee9dc; }
.visual-word-card-body { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 14px; }
.visual-word-card h3 { margin: 0; font-size: 18px; }
.visual-word-card p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 14px; }
.load-more { display: flex; justify-content: center; margin: 8px 0 24px; }
.word-row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(160px, 1fr) auto; gap: 16px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.76); }
.word-row strong { font-size: 17px; }
.word-row .row-ipa { color: var(--blue); font-size: 13px; }
.word-row .row-meaning { color: var(--muted); }
.status-dot { width: 28px; height: 28px; border: 8px solid transparent; border-radius: 50%; background: #c8cec9; background-clip: content-box; cursor: pointer; }
.status-dot.learned { background-color: var(--green-2); }

.foundation-progress { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: baseline; margin-bottom: 18px; }
.foundation-progress strong { font-size: 30px; letter-spacing: -.04em; }
.foundation-progress span { color: var(--muted); }
.foundation-progress-bar { grid-column: 1 / -1; overflow: hidden; height: 8px; border-radius: 999px; background: #e5e8df; }
.foundation-progress-bar span { display: block; height: 100%; border-radius: inherit; background: var(--green-2); }
.foundation-track-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 3px 0 8px; }
.foundation-track { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; font-weight: 720; }
.foundation-track small { color: var(--muted); }
.foundation-track.active { border-color: var(--green); background: var(--ink); color: #fff; }
.foundation-track.active small { color: rgba(255,255,255,.68); }
.foundation-lesson-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.foundation-lesson-card { display: flex; align-items: center; gap: 14px; width: 100%; cursor: pointer; text-align: left; }
.foundation-lesson-card strong, .foundation-lesson-card small { display: block; }
.foundation-lesson-card small { margin-top: 5px; color: var(--muted); line-height: 1.4; }
.foundation-lesson-card.done { border-color: rgba(30,129,99,.34); background: #f2f8f3; }
.foundation-lesson-number { display: grid; flex: 0 0 auto; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: #e7eee9; color: var(--green); font-weight: 850; }
.foundation-lesson-card.done .foundation-lesson-number { background: var(--green); color: #fff; }
.foundation-hero { display: grid; grid-template-columns: 1fr 190px; gap: 24px; align-items: center; margin-top: 18px; padding: clamp(26px, 5vw, 48px); background: var(--ink); color: #fff; }
.foundation-hero h1 { margin: 0; font-size: clamp(38px, 6vw, 68px); line-height: .96; letter-spacing: -.055em; }
.foundation-hero p:not(.eyebrow) { max-width: 700px; margin: 16px 0 0; color: rgba(255,255,255,.72); font-size: 17px; line-height: 1.5; }
.foundation-hero img { width: 190px; aspect-ratio: 1; border-radius: 24px; object-fit: cover; background: #eee9dc; }
.foundation-symbol { display: grid; place-items: center; width: 190px; aspect-ratio: 1; border-radius: 24px; background: var(--lime); color: var(--ink); font-size: 70px; font-weight: 900; letter-spacing: -.08em; }
.foundation-explanation { margin-top: 18px; }
.foundation-explanation p:last-child { margin-bottom: 0; font-size: 17px; line-height: 1.55; }
.foundation-visual { margin-top: 18px; overflow: hidden; background: linear-gradient(135deg, #fffdf6, #f1f7ec); }
.foundation-formula { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.foundation-formula-part { padding: 13px 16px; border-radius: 14px; font-size: clamp(20px, 3vw, 30px); font-weight: 850; letter-spacing: -.03em; }
.foundation-formula-part.tone-0 { background: #dff1e7; color: #155c49; }
.foundation-formula-part.tone-1 { background: #fff0cb; color: #7b4b00; }
.foundation-formula-part.tone-2 { background: #f8d8cf; color: #7c3025; }
.foundation-operator { color: var(--muted); font-size: 24px; font-weight: 850; }
.foundation-visual-result { display: block; margin-top: 20px; font-size: clamp(24px, 4vw, 38px); letter-spacing: -.04em; }
.foundation-visual-result + span { display: block; margin-top: 4px; color: var(--muted); }
.foundation-timeline { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); margin: 28px 0 22px; }
.foundation-timeline::before { position: absolute; top: 13px; right: 10%; left: 10%; height: 4px; border-radius: 999px; background: #d9ddd5; content: ""; }
.foundation-time-node { position: relative; display: grid; justify-items: center; gap: 10px; color: var(--muted); }
.foundation-time-node span { z-index: 1; width: 30px; height: 30px; border: 7px solid #fffdf6; border-radius: 50%; background: #b9c0b9; box-shadow: 0 0 0 1px #d9ddd5; }
.foundation-time-node.active { color: var(--ink); }
.foundation-time-node.active span { background: var(--coral); box-shadow: 0 0 0 7px rgba(242,119,89,.16); }
.foundation-time-node strong { text-transform: uppercase; letter-spacing: .08em; }
.foundation-example-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.foundation-example strong { display: block; font-size: 25px; letter-spacing: -.03em; }
.foundation-split { margin-top: 8px; color: var(--coral); font-size: 19px; font-weight: 820; letter-spacing: .04em; }
.foundation-example p { margin: 8px 0 0; color: var(--muted); }
.foundation-speak { background: #fff3dc; }
.foundation-speak h2 { margin: 0; font-size: clamp(30px, 5vw, 52px); letter-spacing: -.045em; }
.foundation-speak > p:not(.eyebrow) { color: var(--muted); font-size: 17px; }
.recording-playback { margin-top: 14px; }
.recording-playback audio { width: min(100%, 520px); }
.foundation-finish { display: flex; justify-content: center; margin-top: 24px; }

.scene-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.scene-card { overflow: hidden; width: 100%; padding: 0; cursor: pointer; text-align: left; }
.scene-card img { width: 100%; aspect-ratio: 16/8; object-fit: cover; background: linear-gradient(135deg, #d7e8df, #f2cf8f); }
.scene-card-body { display: block; padding: 20px; }
.scene-card-title { display: block; margin: 0 0 6px; font-size: 21px; font-weight: 780; }
.scene-card-meta { display: block; color: var(--muted); }
.dialogue { display: grid; gap: 12px; }
.line { max-width: 78%; padding: 13px 15px; border-radius: 17px 17px 17px 5px; background: #e7eee9; }
.line:nth-child(even) { justify-self: end; border-radius: 17px 17px 5px 17px; background: #e7e9f3; }
.line p { margin: 0; line-height: 1.42; }
.line .line-translation { margin-top: 5px; color: var(--muted); font-size: 13px; }
.line-tools { display: flex; gap: 6px; margin-top: 8px; }

.grammar-list { display: grid; gap: 12px; }
.grammar-item summary { cursor: pointer; list-style: none; font-weight: 780; }
.grammar-item summary::-webkit-details-marker { display: none; }
.grammar-item .grammar-body { padding-top: 14px; color: var(--muted); line-height: 1.55; }
.grammar-example { margin-top: 12px; padding: 13px; border-radius: 13px; background: #edf2ed; color: var(--ink); }

.chat { display: grid; gap: 12px; max-height: 430px; overflow: auto; padding: 4px; }
.chat-message { max-width: 80%; padding: 13px 15px; border-radius: 17px; background: #e7eee9; line-height: 1.45; }
.chat-message.user { justify-self: end; background: var(--ink); color: white; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 14px; }
.tutor-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.tutor-scenario { grid-column: 1 / -1; }
.tutor-submit { display: flex; gap: 8px; }
.tutor-detail { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(16, 37, 31, .12); }
.tutor-detail strong, .tutor-detail small { display: block; }
.tutor-detail small, .tutor-fallback { margin-top: 4px; color: var(--muted); }
.tutor-fallback { display: block; }
.tutor-working { padding: 10px 2px; }
.notice { padding: 14px 16px; border-radius: 14px; background: #fff2d9; color: #684b0c; line-height: 1.45; }
.fine-print { color: var(--muted); font-size: 13px; line-height: 1.5; }

.onboarding {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.onboarding-box { width: min(920px, 100%); }
.onboarding-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; font-weight: 800; }
.onboarding h1 { max-width: 800px; margin: 0; font-size: clamp(44px, 9vw, 92px); line-height: .92; letter-spacing: -.07em; }
.onboarding-lead { max-width: 680px; margin: 24px 0 34px; color: var(--muted); font-size: 18px; line-height: 1.55; }
.language-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.language-card { padding: 26px; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); cursor: pointer; text-align: left; }
.language-card:hover { transform: translateY(-3px); border-color: var(--green); }
.language-card .flag { font-size: 34px; }
.language-card h2 { margin: 28px 0 8px; font-size: 27px; letter-spacing: -.03em; }
.language-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.credit { margin-top: 34px; color: var(--muted); font-size: 13px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-grid h2 { margin-top: 0; }
.form-stack { display: grid; gap: 11px; }
.label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 680; }

.empty { padding: 42px; text-align: center; }
.empty h2 { margin-top: 0; }
.loading { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.footer { margin-top: 52px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.author-link { color: inherit; font-weight: 760; text-underline-offset: 3px; }
.author-link:hover { color: var(--green); }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding-bottom: 92px; }
  .sidebar { position: fixed; z-index: 30; left: 12px; right: 12px; bottom: 12px; top: auto; display: flex; overflow-x: auto; padding: 7px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,254,249,.95); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
  .nav-button { flex: 0 0 auto; width: auto; padding: 10px 12px; }
  .nav-button span:last-child { display: none; }
  .hero { grid-template-columns: 1fr; }
  .study-wrap { grid-template-columns: 1fr; }
  .track-list { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 680px) {
  .topbar { grid-template-columns: 1fr auto; }
  .direction-pill { display: none; }
  .top-stats .mini-stat:nth-child(2) { display: none; }
  .grid.three, .grid.two, .scene-grid, .settings-grid, .language-choice { grid-template-columns: 1fr; }
  .visual-word-grid { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 42px; }
  .hero { padding: 28px; }
  .hero h1 { font-size: 48px; }
  .word-row { grid-template-columns: 1fr auto; }
  .word-row .row-meaning { grid-column: 1 / -1; }
  .study-card { min-height: 440px; }
  .track-list { grid-template-columns: 1fr 1fr; }
  .chat-form { grid-template-columns: 1fr; }
  .tutor-controls { grid-template-columns: 1fr; }
  .tutor-scenario { grid-column: auto; }
  .foundation-lesson-grid, .foundation-example-grid { grid-template-columns: 1fr; }
  .foundation-hero { grid-template-columns: 1fr; }
  .foundation-hero img, .foundation-symbol { width: 132px; }
}

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