:root {
  color-scheme: light;
  --paper: #f4eddd;
  --paper-deep: #e9ddc7;
  --card: rgba(255, 251, 241, 0.86);
  --ink: #292620;
  --muted: #756c5f;
  --line: rgba(70, 57, 41, 0.16);
  --rust: #b34b2f;
  --rust-dark: #7f311f;
  --moss: #556b4f;
  --amber: #e3a725;
  --amber-soft: #f8dfa0;
  --shadow: 0 22px 70px rgba(75, 51, 25, 0.11);
  --display: "Iowan Old Style", "Baskerville", "Songti TC", serif;
  --body: "Avenir Next", "PingFang TC", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 7%, rgba(227, 167, 37, 0.15), transparent 23rem),
    radial-gradient(circle at 93% 30%, rgba(85, 107, 79, 0.11), transparent 28rem),
    linear-gradient(145deg, #f7f1e5 0%, var(--paper) 56%, #eee4d3 100%);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(74, 59, 40, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 59, 40, 0.018) 1px, transparent 1px);
  background-size: 32px 32px;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }

:focus-visible {
  outline: 3px solid rgba(179, 75, 47, 0.34);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  transform: translateY(-150%);
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-height: 78px;
  padding: 12px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 241, 229, 0.86);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 15px 8px 15px 8px;
  background: var(--rust);
  color: #fff8e9;
  font-family: var(--display);
  font-size: 26px;
  box-shadow: 4px 5px 0 rgba(127, 49, 31, 0.18);
}
.brand b { display: block; font-family: var(--display); font-size: 22px; line-height: 1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }

.desktop-nav { display: flex; justify-content: center; gap: 5px; }
.desktop-nav a {
  position: relative;
  padding: 11px 15px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.desktop-nav a:hover, .desktop-nav a.active { background: rgba(179, 75, 47, 0.09); color: var(--rust-dark); }
.desktop-nav a span { display: inline-grid; min-width: 19px; height: 19px; margin-left: 3px; place-items: center; border-radius: 50%; background: var(--rust); color: white; font-size: 10px; }

.header-tools { display: flex; align-items: center; justify-content: flex-end; gap: 14px; color: var(--muted); font-size: 12px; }
.header-tools strong { color: var(--moss); white-space: nowrap; }
.rate-control, .direction-control { display: flex; align-items: center; gap: 6px; }
.rate-control select, .direction-control select { border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.5); padding: 5px; color: var(--ink); }
body.is-playing #audio-status { color: var(--rust); font-weight: 800; }

#app {
  width: min(1180px, calc(100% - 40px));
  min-height: calc(100vh - 78px);
  margin: 0 auto;
  padding: clamp(42px, 7vw, 92px) 0 110px;
}

.loading-state, .fatal {
  display: grid;
  min-height: 50vh;
  place-items: center;
  align-content: center;
  text-align: center;
}
.loading-state span { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--rust); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-state p { color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

.eyebrow {
  margin: 0 0 10px;
  color: var(--rust);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}
.page-title h1 { max-width: 820px; margin: 0; font-family: var(--display); font-size: clamp(39px, 5vw, 70px); font-weight: 600; letter-spacing: -.045em; line-height: 1.02; }
.page-actions { display: flex; gap: 8px; }

.button, .audio-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 19px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 252, 245, 0.62);
  cursor: pointer;
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover:not(:disabled), .audio-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 9px 25px rgba(74, 48, 21, .1); }
.button.primary, .audio-button.primary { border-color: var(--rust); background: var(--rust); color: #fffaf0; }
.button.ghost { background: transparent; }
.button.compact { min-height: 38px; padding-inline: 14px; font-size: 12px; }
.button.wide { width: 100%; }
.button:disabled, .audio-button:disabled { cursor: not-allowed; opacity: .38; }

.today-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1.35fr .65fr;
  min-height: 535px;
  overflow: hidden;
  border: 1px solid rgba(102, 70, 41, .14);
  border-radius: 38px 16px 38px 16px;
  background:
    linear-gradient(125deg, rgba(255,255,255,.43), rgba(255,255,255,0)),
    var(--card);
  box-shadow: var(--shadow);
}
.today-hero::after { position: absolute; right: -110px; bottom: -120px; width: 380px; height: 380px; content: ""; border: 1px solid rgba(179, 75, 47, .16); border-radius: 50%; box-shadow: 0 0 0 42px rgba(179,75,47,.035), 0 0 0 88px rgba(85,107,79,.025); }
.today-copy { display: flex; flex-direction: column; justify-content: center; padding: clamp(42px, 7vw, 90px); }
.today-copy h1 { max-width: 740px; margin: 0; font-family: var(--display); font-size: clamp(50px, 6.2vw, 86px); font-weight: 500; letter-spacing: -.06em; line-height: .96; }
.today-copy > p:not(.eyebrow) { max-width: 570px; margin: 28px 0 0; color: var(--muted); font-size: 17px; line-height: 1.8; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }

.today-ticket {
  position: relative;
  z-index: 2;
  align-self: center;
  width: calc(100% + 22px);
  min-height: 360px;
  margin-left: -22px;
  padding: 38px;
  border-radius: 30px 0 0 30px;
  background: #302c25;
  color: #f8f0df;
  transform: rotate(1.5deg);
  box-shadow: -14px 20px 45px rgba(41, 33, 24, .2);
}
.ticket-number { color: var(--amber); font-family: var(--display); font-size: 58px; }
.today-ticket p { margin: 20px 0 7px; color: #b7ac99; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; }
.today-ticket h2 { margin: 0; font-family: var(--display); font-size: 34px; line-height: 1.16; }
.ticket-lines { display: grid; gap: 11px; margin-top: 30px; }
.ticket-lines > span { padding-top: 11px; border-top: 1px dashed rgba(255,255,255,.14); color: #d9cfbd; font-size: 13px; }

.today-task-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 22px 0 76px; }
.today-task { position: relative; min-height: 250px; padding: 28px 28px 76px; border: 1px solid var(--line); border-radius: 28px 11px 28px 11px; background: rgba(255,251,242,.64); }
.today-task > div { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.today-task > div strong { color: var(--rust); font-family: var(--display); font-size: 40px; font-weight: 500; }
.today-task h2 { margin: 30px 0 10px; font-family: var(--display); font-size: clamp(27px, 3vw, 39px); font-weight: 550; line-height: 1.12; }
.today-task > p { max-width: 520px; margin: 0; color: var(--muted); line-height: 1.7; }
.today-task > a { position: absolute; right: 27px; bottom: 25px; color: var(--rust); font-size: 12px; font-weight: 900; }
.review-task { background: #302c25; color: #f8f0df; }
.review-task .eyebrow, .review-task > div strong, .review-task > a { color: var(--amber); }
.review-task > p { color: #c9beac; }

.section-block { margin-top: 70px; }
.learning-loop { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.learning-loop article { min-height: 220px; padding: 21px; border: 1px solid var(--line); border-radius: 22px 9px 22px 9px; background: rgba(255,251,242,.48); }
.learning-loop article > span { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--paper-deep); color: var(--muted); font-family: var(--display); }
.learning-loop article.active { border-color: rgba(179,75,47,.48); background: rgba(255,251,242,.86); box-shadow: 0 14px 36px rgba(78,52,25,.07); }
.learning-loop article.active > span { background: var(--rust); color: white; }
.learning-loop article.done { background: rgba(85,107,79,.1); }
.learning-loop article.done > span { background: var(--moss); color: white; }
.learning-loop small { display: block; min-height: 31px; margin-top: 30px; color: var(--rust); font-size: 9px; font-weight: 900; line-height: 1.45; letter-spacing: .08em; }
.learning-loop h3 { margin: 8px 0; font-family: var(--display); font-size: 23px; line-height: 1.1; }
.learning-loop p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.route-map { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.route-map article { min-height: 178px; padding: 23px; border: 1px solid var(--line); border-radius: 22px 9px 22px 9px; opacity: .58; background: rgba(255,251,242,.4); }
.route-map article.available { border-color: rgba(85,107,79,.35); opacity: 1; background: rgba(85,107,79,.1); }
.route-map span { color: var(--rust); font-size: 9px; font-weight: 900; letter-spacing: .15em; }
.route-map h3 { margin: 25px 0 8px; font-family: var(--display); font-size: 26px; }
.route-map p { margin: 0; color: var(--muted); font-size: 12px; }
.route-map a { display: inline-block; margin-top: 18px; color: var(--moss); font-size: 11px; font-weight: 900; }

.lesson-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.lesson-card { position: relative; min-height: 290px; overflow: hidden; padding: 30px 30px 58px; border: 1px solid var(--line); border-radius: 28px 12px 28px 12px; background: var(--card); box-shadow: 0 12px 35px rgba(78,52,25,.06); transition: transform .2s ease, border-color .2s ease; }
.lesson-card:hover { transform: translateY(-5px) rotate(-.25deg); border-color: rgba(179,75,47,.36); }
.lesson-card.completed::after { position: absolute; top: 20px; right: -34px; width: 130px; padding: 6px; content: "完成"; background: var(--moss); color: white; text-align: center; transform: rotate(35deg); font-size: 10px; letter-spacing: .18em; }
.lesson-card-top { display: flex; justify-content: space-between; color: var(--rust); font-size: 11px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.lesson-card h2 { max-width: 520px; margin: 50px 0 10px; font-family: var(--display); font-size: clamp(28px, 3.5vw, 43px); font-weight: 500; line-height: 1.1; }
.lesson-card > p { margin: 0; color: var(--muted); }
.lesson-card-cta { position: absolute; right: 28px; bottom: 27px; color: var(--rust); font-size: 11px; font-weight: 900; }
.lesson-card-cta:hover { text-decoration: underline; text-underline-offset: 3px; }
.topic-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 27px; }
.topic-row > span { padding: 7px 10px; border-radius: 999px; background: var(--paper-deep); font-size: 11px; }

.lesson-overview { display: grid; max-width: 900px; grid-template-columns: 1.1fr repeat(3, 1fr); gap: 8px; margin: 0 auto 20px; }
.lesson-overview > div, .lesson-overview > article { min-height: 116px; padding: 17px; border: 1px solid var(--line); border-radius: 18px 8px 18px 8px; background: rgba(255,251,242,.48); text-align: left; }
.lesson-overview > div { display: flex; flex-direction: column; justify-content: end; }
.lesson-overview > div h2 { margin: 0; font-family: var(--display); font-size: 22px; line-height: 1.12; }
.lesson-overview > article { display: grid; grid-template-columns: auto 1fr; gap: 9px; }
.lesson-overview > article > button { display: grid; width: 28px; height: 28px; place-items: center; border: 0; border-radius: 50%; background: var(--paper-deep); color: var(--muted); cursor: pointer; font-family: var(--display); }
.lesson-overview > article > div { display: grid; align-content: start; gap: 6px; }
.lesson-overview > article b { font-size: 12px; line-height: 1.4; }
.lesson-overview > article small { overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.35; }
.lesson-overview > article.active { border-color: var(--rust); background: rgba(179,75,47,.08); }
.lesson-overview > article.active > button { background: var(--rust); color: white; }

.sentence-stage { max-width: 900px; margin: 0 auto; padding: clamp(28px, 5vw, 62px); border: 1px solid rgba(90,62,34,.17); border-radius: 38px 16px 38px 16px; background: var(--card); box-shadow: var(--shadow); }
.topic-badge { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 30px; color: var(--rust-dark); font-family: var(--display); font-size: clamp(30px, 5vw, 56px); font-weight: 600; text-align: center; }
.topic-badge > .topic-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--amber); box-shadow: 0 0 20px var(--amber); }
.topic-badge small { color: var(--muted); font-family: var(--body); font-size: 13px; font-weight: 700; }

.sentence-block { position: relative; display: grid; min-height: 130px; place-items: center; margin: 12px 0; padding: 24px 54px; border: 1px solid var(--line); border-radius: 22px 8px 22px 8px; text-align: center; }
.sentence-block.zh { background: linear-gradient(135deg, rgba(227,167,37,.18), rgba(255,255,255,.24)); }
.sentence-block.vi { background: linear-gradient(135deg, rgba(85,107,79,.15), rgba(255,255,255,.28)); }
.sentence-block p { margin: 0; font-family: var(--display); font-size: clamp(25px, 3.6vw, 42px); font-weight: 600; line-height: 1.35; }
.sentence-block.vi p { font-family: var(--body); font-weight: 750; }
.sentence-block mark { padding: 0 .08em; border-radius: 5px; background: linear-gradient(transparent 55%, rgba(247,190,42,.62) 55%); color: inherit; box-shadow: 0 8px 20px rgba(227,167,37,.12); }
.language-flag { position: absolute; top: 12px; left: 14px; font-size: 16px; filter: saturate(.9); }

.audio-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 22px 0 30px; }
.audio-button { min-height: 41px; padding-inline: 14px; font-size: 12px; }
.audio-button.icon { min-height: 38px; flex: 0 0 auto; padding-inline: 12px; }

.focus-panel { margin-top: 22px; padding: 22px; border-radius: 20px; background: #302c25; color: white; }
.focus-panel > p { margin: 0 0 13px; color: var(--amber); font-size: 10px; font-weight: 900; letter-spacing: .17em; text-transform: uppercase; }
.focus-panel > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; }
.focus-panel > div > span { display: flex; min-height: 72px; flex-direction: column; align-items: center; justify-content: center; padding: 10px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; background: rgba(255,255,255,.035); text-align: center; }
.focus-panel b { color: #ffd35e; font-size: 15px; }
.focus-panel small { margin-top: 4px; color: #e5dccb; }

.insight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 900px; margin: 18px auto 0; }
.insight-card { min-height: 190px; padding: 25px; border: 1px solid var(--line); border-radius: 22px 9px 22px 9px; background: rgba(255,251,242,.55); }
.insight-card h3 { margin: 0 0 19px; font-family: var(--display); font-size: 24px; }
.word-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.word-chips span { display: inline-flex; flex-direction: column; padding: 8px 11px; border-radius: 10px; background: var(--amber-soft); font-size: 10px; }
.word-chips b { font-size: 13px; }
.block-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.block-grid > span { display: grid; gap: 3px; padding: 9px 11px; border-radius: 10px; background: var(--amber-soft); }
.block-grid small { color: var(--rust); font-size: 8px; font-weight: 900; letter-spacing: .12em; }
.block-grid b { font-size: 13px; }
.block-grid em { color: var(--muted); font-size: 10px; font-style: normal; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--rust); cursor: pointer; font-weight: 800; }
.feynman-answer { padding: 12px; border-left: 3px solid var(--rust); color: var(--muted); line-height: 1.6; }
.feynman-note { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.55); padding: 11px 12px; color: var(--ink); line-height: 1.5; }
.feynman-note:focus { outline: 2px solid rgba(179,75,47,.22); border-color: var(--rust); }
.step-feedback { margin: 12px 0 0; color: var(--moss); font-size: 11px; font-weight: 900; }
.locked-step { color: var(--muted); }
.self-check-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.self-check-actions button { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; background: transparent; cursor: pointer; color: var(--muted); font-size: 11px; font-weight: 900; }
.self-check-actions button:hover, .self-check-actions button.active { border-color: var(--moss); background: var(--moss); color: white; }
.recall-check { grid-column: 1 / -1; min-height: 0; }
.recall-check h3 { margin-bottom: 8px; }
.recall-check > p:not(.eyebrow) { color: var(--muted); }
.lesson-footer { display: flex; max-width: 900px; justify-content: space-between; gap: 12px; margin: 24px auto 0; }

.word-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,251,242,.5); }
.word-toolbar label { display: grid; flex: 1; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.word-toolbar input { width: 100%; border: 0; border-bottom: 1px solid var(--line); outline: none; background: transparent; color: var(--ink); font-family: var(--display); font-size: 25px; }
.filter-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-pills button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; background: transparent; cursor: pointer; color: var(--muted); font-size: 11px; font-weight: 800; }
.filter-pills button.active { border-color: var(--rust); background: var(--rust); color: white; }
.result-count { margin: 24px 0 12px; color: var(--muted); font-size: 12px; }
.word-results { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 20px 0 12px; }
.word-results .result-count { margin: 0; }
.word-pager { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.word-pager button, .word-pager select { min-height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.word-pager button { padding: 0 12px; cursor: pointer; }
.word-pager button:disabled { cursor: default; opacity: .42; }
.word-pager select { padding: 0 8px; }
.word-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; }
.word-card { position: relative; min-height: 172px; padding: 28px 18px 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 20px 8px 20px 8px; background: var(--card); cursor: pointer; text-align: left; transition: transform .18s ease, border-color .18s ease; }
.word-card:hover { transform: translateY(-3px); border-color: rgba(179,75,47,.38); }
.word-card strong { display: block; margin: 25px 0 5px; font-family: var(--display); font-size: 31px; font-weight: 600; }
.word-card > span:not(.word-rank) { color: var(--muted); }
.word-card small { display: block; margin-top: 17px; color: var(--muted); font-size: 10px; }
.word-rank { position: absolute; top: 15px; left: 17px; color: var(--rust); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.word-card::after { position: absolute; right: 15px; bottom: 15px; width: 8px; height: 8px; content: ""; border-radius: 50%; background: #c9bfaf; }
.word-card.status-learning::after { background: var(--amber); }
.word-card.status-known::after { background: var(--moss); }
.word-card.status-ignored { opacity: .55; }
.word-card.status-ignored::after { background: #8e887e; }
.reviewed-word-note, .lexeme-review-note { color: var(--muted); font-size: 12px; line-height: 1.6; }
.reviewed-word-note { margin: 16px 0; padding: 12px 14px; border-radius: 12px; background: rgba(227,167,37,.1); }
.lexeme-review-note { margin: 8px 0 0; color: #c9bfaf; }

.capture-inbox { display: grid; grid-template-columns: minmax(210px, .7fr) 1.3fr; gap: 24px; margin-bottom: 22px; padding: 24px; border: 1px solid rgba(179,75,47,.2); border-radius: 26px 10px 26px 10px; background: linear-gradient(135deg, rgba(232,170,65,.14), rgba(255,253,247,.82)); }
.capture-inbox h2 { margin: 4px 0 7px; font-family: var(--display); font-size: 28px; font-weight: 600; }
.capture-inbox > div > p:last-child { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.capture-list { display: grid; gap: 7px; }
.capture-list article { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; align-items: center; padding: 11px 13px; border-radius: 12px; background: rgba(255,255,255,.7); }
.capture-list span { overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.capture-list small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.capture-list button { grid-column: 2; grid-row: 1 / 3; border: 0; background: transparent; color: var(--rust); cursor: pointer; font-size: 11px; font-weight: 800; }

.word-dialog { width: min(480px, calc(100% - 32px)); max-height: min(460px, calc(100vh - 48px)); padding: 18px; overflow-y: auto; border: 1px solid rgba(255,255,255,.15); border-radius: 20px 9px 20px 9px; background: #2d2a24; color: #f8f0e2; box-shadow: 0 26px 65px rgba(37,27,19,.38); }
.word-dialog::backdrop { background: rgba(46,37,27,.55); backdrop-filter: blur(7px); }
.dialog-close { position: absolute; top: 12px; right: 13px; width: 32px; height: 32px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; background: transparent; color: white; cursor: pointer; font-size: 19px; }
.dialog-rank { color: var(--amber); font-size: 10px; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; }
.dialog-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.1); }
.dialog-title-row h2 { margin: 0; font-family: var(--display); font-size: clamp(34px, 6vw, 44px); font-weight: 500; }
.dialog-title-row p { margin: 6px 0 0; color: #c5baa9; }
.word-dialog .audio-button { border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: white; }
.status-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin: 10px 0; }
.status-actions button { min-height: 34px; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; background: transparent; color: #c5baa9; cursor: pointer; font-size: 12px; }
.status-actions button.active { border-color: var(--amber); color: var(--amber); }
.example-list { display: grid; gap: 6px; margin-top: 12px; }
.example-list article { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,.045); }
.example-list article div { display: grid; gap: 5px; }
.example-list article b { line-height: 1.5; }
.example-list article div > span { color: #c5baa9; font-size: 13px; }

.review-layout { display: grid; grid-template-columns: 250px 1fr; gap: 18px; max-width: 950px; margin: 0 auto; }
.review-mode-tabs { display: flex; max-width: 950px; gap: 7px; margin: -20px auto 18px; }
.review-mode-tabs button { min-height: 38px; padding: 0 15px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,253,247,.65); color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 800; }
.review-mode-tabs button.active { border-color: var(--rust); background: var(--rust); color: white; }
.review-queue { display: flex; min-height: 360px; flex-direction: column; justify-content: end; padding: 28px; border-radius: 28px 10px 28px 10px; background: var(--moss); color: #f8f2e4; }
.review-queue .eyebrow { color: #d8e2d5; }
.review-queue strong { font-family: var(--display); font-size: 80px; font-weight: 500; line-height: 1; }
.review-queue > span { font-size: 12px; }
.review-queue > p:last-child { margin-top: 35px; color: #d8e2d5; font-size: 13px; line-height: 1.65; }
.review-card { min-height: 480px; padding: clamp(32px, 6vw, 64px); border: 1px solid var(--line); border-radius: 34px 14px 34px 14px; background: var(--card); box-shadow: var(--shadow); text-align: center; }
.review-status { color: var(--rust); font-size: 10px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.review-card h2 { margin: 50px 0 22px; font-family: var(--display); font-size: clamp(65px, 11vw, 112px); font-weight: 500; line-height: .9; }
.review-card .listen-symbol { margin: 28px 0 8px; color: var(--rust); }
.listen-exercise > p { margin: 0 0 18px; color: var(--muted); }
.listen-choices { display: grid; gap: 8px; margin-top: 24px; }
.listen-choices button { min-height: 48px; padding: 10px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-deep); cursor: pointer; color: var(--ink); font-weight: 700; }
.order-exercise { margin-top: 28px; }
.order-prompt { font-family: var(--display); font-size: 25px; }
.order-answer { display: flex; min-height: 86px; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 20px 0; padding: 15px; border: 1px dashed var(--line); border-radius: 16px; }
.order-answer span, .order-tokens button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--amber-soft); color: var(--ink); font-weight: 800; }
.order-answer em { color: var(--muted); font-size: 12px; font-style: normal; }
.order-tokens { display: flex; min-height: 55px; flex-wrap: wrap; justify-content: center; gap: 7px; }
.order-tokens button { cursor: pointer; }
.answer-placeholder { min-height: 120px; margin: 25px 0; padding: 45px 20px; border: 1px dashed var(--line); border-radius: 18px; color: var(--muted); }
.review-answer { min-height: 150px; margin: 25px 0; padding: 26px; border-radius: 18px; background: var(--paper-deep); }
.review-answer strong { display: block; font-family: var(--display); font-size: 34px; }
.review-answer p { margin: 20px 0 4px; font-weight: 800; }
.review-answer > span { color: var(--muted); }
.review-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.review-actions button { min-height: 44px; border: 1px solid var(--line); border-radius: 11px; background: transparent; cursor: pointer; font-size: 11px; font-weight: 800; }
.review-actions button:nth-child(2) { border-color: var(--moss); background: var(--moss); color: white; }
.review-complete { min-height: 470px; padding: 80px 25px; border: 1px solid var(--line); border-radius: 34px 14px; background: var(--card); box-shadow: var(--shadow); text-align: center; }
.review-complete > span { display: grid; width: 72px; height: 72px; place-items: center; margin: 0 auto 25px; border-radius: 50%; background: var(--moss); color: white; font-size: 32px; }
.review-complete h2 { margin: 0; font-family: var(--display); font-size: clamp(36px, 7vw, 62px); }
.review-complete p { margin: 12px 0 28px; color: var(--muted); }

.pattern-list { display: grid; gap: 12px; }
.pattern-list details { overflow: hidden; border: 1px solid var(--line); border-radius: 24px 9px 24px 9px; background: var(--card); }
.pattern-list summary { display: flex; align-items: center; gap: 24px; padding: 25px 30px; cursor: pointer; list-style: none; }
.pattern-list summary::-webkit-details-marker { display: none; }
.pattern-list summary > span { color: var(--rust); font-family: var(--display); font-size: 30px; }
.pattern-list h2 { margin: 0; font-family: var(--display); font-size: 28px; font-weight: 600; }
.pattern-list summary p { margin: 5px 0 0; color: var(--muted); }
.pattern-guide { display: grid; grid-template-columns: minmax(220px, .8fr) 1.6fr; gap: 10px; padding: 0 30px 18px 82px; }
.pattern-guide article { border-radius: 16px; }
.pattern-formula { display: grid; align-content: center; gap: 8px; padding: 20px; background: var(--ink); color: #fff9ef; }
.pattern-formula span, .pattern-example-label { color: var(--amber); font-size: 10px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.pattern-formula strong { line-height: 1.55; }
.pattern-explanation { padding: 20px; background: #f4ead7; }
.pattern-explanation p { margin: 0; line-height: 1.75; }
.pattern-explanation aside { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.65; }
.pattern-explanation aside b { margin-right: 8px; color: var(--rust); }
.pattern-example-label { margin: 0; padding: 0 30px 10px 82px; color: var(--rust); }
.pattern-examples { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; padding: 0 30px 30px 82px; }
.pattern-examples article { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 16px; border-radius: 14px; background: var(--paper-deep); }
.pattern-examples article > div { display: grid; gap: 7px; }
.pattern-examples b { line-height: 1.5; }
.pattern-examples article > div > span { color: var(--muted); font-size: 13px; }

.lexeme-token {
  display: inline;
  border-radius: .22em;
  cursor: pointer;
  text-decoration: underline dotted rgba(117, 108, 95, .55) .08em;
  text-underline-offset: .17em;
  transition: color .16s ease, background .16s ease, opacity .16s ease, box-shadow .16s ease;
}
.lexeme-token:hover, .lexeme-token:focus-visible { background: rgba(227, 167, 37, .16); }
.lexeme-token.focus-hit { padding: 0 .08em; background: linear-gradient(transparent 55%, rgba(247,190,42,.62) 55%); box-shadow: 0 8px 20px rgba(227,167,37,.12); text-decoration: none; }
.lexeme-token.status-learning { color: #a75a00; text-decoration-color: var(--amber); }
.lexeme-token.status-known { color: #3f6846; text-decoration-color: var(--moss); }
.lexeme-token.status-ignored { color: #8e887e; opacity: .58; text-decoration: line-through; }
.focus-panel .lexeme-token { color: #f5e7c9; }
.focus-panel .lexeme-token.status-learning { color: #ffd35e; }
.focus-panel .lexeme-token.status-known { color: #a8d5a0; }
.focus-panel .lexeme-token.status-ignored { color: #9e978c; }

.lexeme-popover {
  position: fixed;
  inset: auto;
  z-index: 75;
  display: none;
  width: min(250px, calc(100vw - 24px));
  margin: 0;
  padding: 11px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 16px 7px 16px 7px;
  background: #302c25;
  color: #fff8ea;
  box-shadow: 0 24px 70px rgba(35, 28, 20, .32);
}
.lexeme-popover:popover-open, .lexeme-popover.is-open { display: block; }
.lexeme-popover::before { position: absolute; inset: 0 auto 0 0; width: 3px; content: ""; border-radius: 16px 0 0 7px; background: #bdb3a3; }
.lexeme-popover.status-learning::before { background: var(--amber); }
.lexeme-popover.status-known::before { background: #7e9b75; }
.lexeme-popover.status-ignored::before { background: #8e887e; }
.lexeme-close { position: absolute; top: 6px; right: 7px; width: 27px; height: 27px; border: 0; background: transparent; color: #c9bfaf; cursor: pointer; font-size: 18px; }
.lexeme-source { margin: 0 0 4px; color: var(--amber); font-size: 8px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.lexeme-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-right: 22px; }
.lexeme-heading h2 { margin: 0; font-family: var(--display); font-size: 24px; font-weight: 500; line-height: 1; }
.lexeme-heading span { color: #c9bfaf; font-size: 10px; font-weight: 800; white-space: nowrap; }
.lexeme-meaning { margin: 5px 0 7px; color: #ded4c2; font-size: 10px; }
.lexeme-play { width: 100%; min-height: 30px; border: 1px solid rgba(255,255,255,.13); border-radius: 8px; background: rgba(255,255,255,.055); color: white; cursor: pointer; font-size: 10px; font-weight: 800; }
.lexeme-play:disabled { cursor: not-allowed; opacity: .42; }
.lexeme-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 7px; }
.lexeme-actions button { min-height: 28px; padding: 3px; border: 1px solid rgba(255,255,255,.11); border-radius: 7px; background: transparent; color: #c9bfaf; cursor: pointer; font-size: 8px; font-weight: 800; }
.lexeme-actions button:hover, .lexeme-actions button.active { border-color: var(--amber); background: rgba(227,167,37,.1); color: var(--amber); }

.empty-state, .fatal { grid-column: 1 / -1; padding: 70px 20px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 22px; bottom: 25px; z-index: 80; max-width: 320px; padding: 13px 18px; border-radius: 12px; background: var(--ink); color: white; box-shadow: 0 15px 35px rgba(32,25,18,.25); font-size: 13px; }
.mobile-nav { display: none; }

.reveal { animation: reveal .55s cubic-bezier(.2,.7,.2,1) both; }
.delay-1 { animation-delay: .08s; }
.delay-2 { animation-delay: .16s; }
@keyframes reveal { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 980px) {
  .site-header { grid-template-columns: auto 1fr; }
  .desktop-nav { display: none; }
  .header-tools { justify-self: end; }
  #audio-status, .header-tools strong { display: none; }
  .today-hero { grid-template-columns: 1fr; }
  .today-ticket { width: auto; margin: 0 28px 30px; border-radius: 28px 10px 28px 10px; transform: none; }
  .learning-loop { grid-template-columns: repeat(3, 1fr); }
  .lesson-overview { grid-template-columns: 1fr 1fr; }
  .lesson-overview > div { grid-column: 1 / -1; }
  .word-grid { grid-template-columns: repeat(3, 1fr); }
  .review-layout { grid-template-columns: 1fr; }
  .review-queue { min-height: 160px; }
}

@media (max-width: 720px) {
  .site-header { min-height: 66px; padding: 10px 16px; }
  .brand small { display: none; }
  .brand-mark { width: 38px; height: 38px; }
  .rate-control { font-size: 0; }
  .rate-control select, .direction-control select { max-width: 145px; font-size: 12px; }
  .direction-control { font-size: 0; }
  #app { width: min(100% - 24px, 620px); padding: 34px 0 110px; }
  .mobile-nav { position: fixed; right: 10px; bottom: 10px; left: 10px; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); min-height: 65px; padding: 7px; border: 1px solid rgba(255,255,255,.15); border-radius: 19px; background: rgba(45,42,36,.94); color: #cfc5b5; box-shadow: 0 18px 50px rgba(34,27,19,.26); backdrop-filter: blur(16px); }
  .mobile-nav a { display: grid; place-items: center; align-content: center; gap: 2px; border-radius: 12px; font-size: 9px; }
  .mobile-nav a span { font-family: var(--display); font-size: 16px; }
  .mobile-nav a.active { background: var(--rust); color: white; }
  .page-title { align-items: start; flex-direction: column; margin-bottom: 24px; }
  .page-title h1 { font-size: 42px; }
  .page-actions { width: 100%; }
  .page-actions .button { flex: 1; }
  .today-hero { min-height: 0; border-radius: 28px 10px 28px 10px; }
  .today-copy { padding: 42px 25px 34px; }
  .today-copy h1 { font-size: clamp(49px, 14vw, 67px); }
  .today-copy > p:not(.eyebrow) { font-size: 14px; }
  .today-ticket { min-height: 300px; margin: 0 14px 14px; padding: 27px; }
  .today-ticket h2 { font-size: 28px; }
  .today-task-grid, .learning-loop, .route-map, .lesson-grid, .insight-grid, .pattern-guide, .pattern-examples { grid-template-columns: 1fr; }
  .today-task-grid { margin-bottom: 50px; }
  .learning-loop article { display: grid; min-height: 0; grid-template-columns: auto 1fr; gap: 15px; }
  .learning-loop small { min-height: 0; margin-top: 0; }
  .learning-loop h3 { margin: 4px 0; }
  .recall-check { grid-column: auto; }
  .lesson-overview { grid-template-columns: 1fr; }
  .lesson-overview > div { grid-column: auto; }
  .lesson-card { min-height: 250px; padding: 23px; }
  .sentence-stage { padding: 24px 14px; border-radius: 28px 10px 28px 10px; }
  .topic-badge { flex-wrap: wrap; font-size: 38px; }
  .topic-badge small { width: 100%; }
  .sentence-block { min-height: 125px; padding: 35px 18px 22px; }
  .sentence-block p { font-size: 25px; }
  .audio-row .audio-button { flex: 1; }
  .lesson-footer .button { flex: 1; }
  .word-toolbar { align-items: stretch; flex-direction: column; }
  .word-results { align-items: flex-start; flex-direction: column; }
  .capture-inbox { grid-template-columns: 1fr; padding: 19px; }
  .word-grid { grid-template-columns: 1fr 1fr; }
  .word-card { min-height: 150px; }
  .word-dialog { padding: 20px 16px; }
  .dialog-title-row { align-items: center; flex-direction: row; }
  .review-actions { grid-template-columns: 1fr 1fr; }
  .example-list article { align-items: center; flex-direction: row; }
  .review-card { min-height: 450px; padding: 35px 18px; }
  .review-card h2 { margin-top: 44px; }
  .pattern-list summary { gap: 14px; padding: 22px 18px; }
  .pattern-guide { padding: 0 18px 16px; }
  .pattern-example-label { padding: 0 18px 10px; }
  .pattern-examples { padding: 0 18px 20px; }
  .toast { right: 16px; bottom: 90px; left: 16px; text-align: center; }
}

@media (max-width: 420px) {
  .brand b { font-size: 19px; }
  .word-grid { grid-template-columns: 1fr; }
  .hero-actions .button { width: 100%; }
}

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