:root {
  color-scheme: light;
  --bg: #f4f5ef;
  --card: #fffefb;
  --ink: #142924;
  --muted: #51675d;
  --line: #dce4d9;
  --deep: #132f2b;
  --deep-2: #1c4137;
  --mint: #ddeb90;
  --primary: #1b604b;
  --wash: #edf4e9;
  --danger: #9a372d;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --accent: ui-serif, "New York", Georgia, serif;
  font-family: var(--font);
  line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101c19;
    --card: #192923;
    --ink: #edf4e9;
    --muted: #b0c3b7;
    --line: #32473c;
    --primary: #c3e796;
    --wash: #23372e;
    --danger: #f5a89a;
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid #4a9a76;
  outline-offset: 3px;
}
button { cursor: pointer; }
button:disabled { opacity: .63; cursor: wait; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.75rem, 3.5vw, 2.65rem); line-height: 1.2; letter-spacing: -.038em; margin-bottom: .55em; }
h2 { font-size: clamp(1.15rem, 2vw, 1.35rem); line-height: 1.35; margin-bottom: .5em; }
h3 { font-size: 1.04rem; margin-bottom: .4em; }
p { margin-bottom: 1em; }
.muted { color: var(--muted); }
.secondary { color: var(--muted); font-size: .89rem; }
.eyebrow { color: var(--primary); font-size: .88rem; font-weight: 750; letter-spacing: .07em; margin-bottom: .48rem; }
.english { font-family: var(--accent); }
.loading { display: grid; min-height: 70svh; place-items: center; padding: 1.5rem; color: var(--muted); }

.frame { display: grid; grid-template-columns: 14.6rem minmax(0, 1fr); min-height: 100svh; }
.rail {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem 1rem;
  background: var(--deep);
  color: #f4f9ed;
}
.brand { display: flex; align-items: center; gap: .72rem; width: max-content; max-width: 100%; }
.brand img { width: 2.6rem; height: 2.6rem; border-radius: .68rem; }
.brand strong, .brand small { display: block; line-height: 1.15; }
.brand strong { font-size: 1.04rem; letter-spacing: .02em; }
.brand small { color: inherit; opacity: .72; font-size: .75rem; margin-top: .25rem; }
.rail .brand { margin: .35rem .5rem 2.55rem; }
.nav { display: grid; gap: .42rem; }
.nav-link { min-height: 2.85rem; display: flex; align-items: center; gap: .72rem; border-radius: .65rem; padding: .46rem .65rem; font-weight: 650; color: #bcd1c5; }
.nav-link:hover { background: #ffffff10; color: #fff; }
.nav-link[aria-current] { background: #ddeb90; color: #1a352a; }
.nav-icon { width: 1.48rem; text-align: center; font: 700 1.28rem/1 var(--accent); }
.rail-footer { margin-top: auto; border-top: 1px solid #ffffff23; padding: .9rem .55rem 0; }
.rail-footer p { color: #b9cec1; font-size: .86rem; margin: 0 0 .45rem; }
.rail-footer button { border: 0; padding: .3rem 0; background: transparent; color: #e4efd9; font-size: .86rem; }
.main { padding: 0 clamp(1.25rem, 4vw, 4.3rem) 3.6rem; min-width: 0; }
.container { max-width: 73rem; margin: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; border-bottom: 1px solid var(--line); min-height: 4.8rem; margin-bottom: clamp(1.35rem, 4vw, 2.5rem); }
.topbar-title { font-weight: 750; }
.topbar-mobile, .mobile-nav, .topbar .mobile-logout { display: none; }
.date-stamp { font-size: .88rem; color: var(--muted); }
.today-title { margin-bottom: 1.1rem; }
.today-title h1 { margin-bottom: .28em; }
.today-title p { margin-bottom: 0; }

.overview { display: grid; grid-template-columns: minmax(0, 2.35fr) minmax(13rem, 1fr); gap: 1rem; }
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 1.2rem;
  min-height: 18rem;
  background: linear-gradient(122deg, #102e28, #1b4236);
  color: #f7f8ec;
  display: flex;
  align-items: center;
  padding: clamp(1.25rem, 3.3vw, 2.3rem);
}
.hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 23rem;
  aspect-ratio: 1;
  right: -9rem;
  top: -3rem;
  border-radius: 50%;
  background: repeating-radial-gradient(circle at center, #ddeb9033 0 1px, transparent 1px 25px);
  opacity: .8;
}
.hero-content { max-width: 35rem; }
.hero .eyebrow { color: #ddeb90; }
.hero h2 { margin: .15rem 0 .28rem; color: #f8f9ec; font-size: clamp(1.65rem, 3.6vw, 2.4rem); }
.hero .english { font-size: clamp(1.22rem, 2.4vw, 1.65rem); color: #d8e7a6; margin-bottom: .72rem; }
.hero .summary { color: #ccded1; max-width: 35rem; margin-bottom: 1.25rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 1rem; padding: clamp(1rem, 2.6vw, 1.5rem); min-width: 0; }
.journey { display: flex; flex-direction: column; justify-content: center; }
.journey .count { font-family: var(--accent); font-size: 2.7rem; line-height: 1.05; margin: .36rem 0 .65rem; font-variant-numeric: tabular-nums; }
.journey .count small { font: 500 1rem var(--font); color: var(--muted); }
progress { width: 100%; height: .56rem; color: var(--primary); accent-color: var(--primary); margin: .4rem 0 .75rem; }
.journey .secondary { margin-bottom: .55rem; }
.journey .secondary:last-child { margin-bottom: 0; }
.section { margin-top: 1.8rem; }
.section-head { display: flex; justify-content: space-between; gap: .9rem; align-items: baseline; margin-bottom: .65rem; }
.section-head h2 { margin: 0; }
.text-link { color: var(--primary); font-weight: 700; text-decoration: underline; text-underline-offset: .2em; }
.module-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .78rem; }
.module { display: block; min-height: 8.25rem; padding: .98rem; transition: border-color .15s, transform .15s; }
.module:hover, .lesson-row:hover { border-color: #7aa185; }
.module h3, .module p { margin: .28rem 0 0; }
.module p { font-size: .88rem; color: var(--muted); }
.module-icon { display: inline-grid; place-items: center; width: 2.3rem; height: 2.3rem; background: var(--wash); color: var(--primary); border-radius: .62rem; font: 700 1.14rem var(--accent); }
.done-label { color: var(--primary); display: block; font-size: .82rem; font-weight: 700; margin-top: .42rem; }
.list { display: grid; gap: .55rem; }
.lesson-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: .8rem; align-items: center; padding: .78rem .95rem; }
.lesson-row strong, .lesson-row small { display: block; }
.lesson-row small { color: var(--muted); font-size: .86rem; }
.day-id { min-width: 3.85rem; text-align: center; background: var(--wash); color: var(--primary); padding: .37rem .48rem; font-weight: 750; border-radius: .46rem; font-size: .86rem; }

.btn {
  min-height: 2.65rem; display: inline-flex; gap: .35rem; align-items: center; justify-content: center;
  padding: .53rem .94rem; border-radius: .64rem; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 700;
}
.btn:hover { border-color: var(--primary); }
.btn-main { background: var(--deep-2); border-color: var(--deep-2); color: #f7fbeb; }
.btn-lime { background: var(--mint); border-color: var(--mint); color: #183227; }
.btn-main:hover, .btn-lime:hover { filter: brightness(1.07); }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.lesson-intro { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .7rem 1rem; margin-bottom: 1rem; }
.lesson-intro h1 { margin-bottom: .22rem; }
.lesson-intro p { margin-bottom: .12rem; }
.lesson-intro .english { font-size: 1.35rem; color: var(--primary); }
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; border: 1px solid var(--line); background: var(--card); border-radius: .8rem; padding: .31rem; margin-bottom: 1.05rem; }
.tab { text-align: center; border-radius: .53rem; padding: .55rem .33rem; font-weight: 700; color: var(--muted); }
.tab[aria-current] { background: var(--wash); color: var(--primary); }
.practice-layout { display: grid; grid-template-columns: minmax(0, 2.5fr) minmax(12rem, 1fr); gap: 1rem; align-items: start; }
.practice-layout aside p:last-child { margin-bottom: 0; }
.flash-card { display: grid; place-items: center; text-align: center; min-height: 12rem; margin: .85rem 0; width: 100%; border-radius: .8rem; padding: 1rem; background: var(--wash); color: var(--ink); border: 1px solid var(--line); }
.flash-card .word { color: var(--primary); font: 700 clamp(1.45rem, 4vw, 2.2rem)/1.16 var(--accent); display: block; }
.flash-card .meaning { display: block; margin: .6rem 0 .25rem; }
.flash-card em, .flash-card small { display: block; margin-top: .5rem; color: var(--muted); }
.stack { display: grid; gap: .9rem; }
.voice-box { background: var(--wash); border-radius: .8rem; padding: .9rem; margin-bottom: 1rem; }
.voice-box label { font-size: .9rem; font-weight: 700; }
select { padding: .42rem .7rem; border: 1px solid var(--line); border-radius: .5rem; color: var(--ink); background: var(--card); }
details { margin-top: .9rem; }
summary { cursor: pointer; color: var(--primary); font-weight: 700; }
details p { margin: .55rem 0 0; }
.questions { margin-top: .98rem; }
fieldset { margin: 0 0 .9rem; border: 1px solid var(--line); border-radius: .7rem; padding: .7rem; min-width: 0; }
legend { font-weight: 750; padding: 0 .26rem; }
.option { display: flex; gap: .5rem; align-items: baseline; margin-top: .25rem; min-height: 2.35rem; padding: .35rem; cursor: pointer; border-radius: .45rem; }
.option:has(input:checked) { background: var(--wash); }
.option input { accent-color: #29775c; }
.result { margin: .6rem 0 .12rem; background: var(--wash); padding: .75rem; border-radius: .5rem; }
.speaking-prompt { margin: .65rem 0 .4rem; font: 700 1.45rem/1.26 var(--accent); color: var(--primary); }
.practice-form textarea, .auth-form input { display: block; width: 100%; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: .65rem; padding: .73rem .82rem; }
.practice-form textarea { resize: vertical; min-height: 7.5rem; margin: .4rem 0 .72rem; }
.practice-form > label, .auth-form label { font-weight: 700; }
.practice-form audio { max-width: 100%; height: 2.6rem; margin: .45rem 0; width: 100%; }
.prompt-nav { display: flex; flex-wrap: wrap; gap: .45rem; }
.prompt-nav a[aria-current] { background: var(--wash); color: var(--primary); border-color: #81a385; }
.review { padding: .8rem 0; border-top: 1px solid var(--line); }
.review p { margin: .25rem 0; white-space: pre-line; overflow-wrap: anywhere; }
.article { overflow-wrap: anywhere; }
.article h1 { font-size: 1.45rem; }
.article h2 { margin-top: 1.7rem; color: var(--primary); }
.article h3, .article h4, .article h5 { margin-top: 1rem; }
.article blockquote { border-left: 3px solid #82ad89; margin-left: 0; padding: .6rem .9rem; background: var(--wash); }
.article table { display: block; overflow: auto; max-width: 100%; border-collapse: collapse; margin: .6rem 0 1.2rem; }
.article th, .article td { padding: .48rem .52rem; text-align: left; border: 1px solid var(--line); }
.article th { background: var(--wash); }
.article pre { max-width: 100%; white-space: pre-wrap; }
.article hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.empty { color: var(--muted); padding: .75rem 0 .25rem; }
.stats-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .8rem; }
.stat-value { font: 700 1.9rem/1.1 var(--accent); color: var(--primary); margin: .35rem 0; }
.stat-label { margin: 0; color: var(--muted); }
.auth-layout { min-height: 100svh; max-width: 68rem; margin: auto; padding: 1.25rem 1.1rem; display: grid; grid-template-columns: 1.1fr .9fr; align-items: stretch; gap: 1rem; align-content: center; }
.auth-hero { min-height: 28rem; align-items: flex-end; }
.auth-hero .brand { position: absolute; top: 1.4rem; left: clamp(1.25rem, 3.3vw, 2.3rem); }
.auth-hero h1 { font-size: clamp(2.1rem, 6vw, 3.5rem); }
.auth-hero p { margin-bottom: .45rem; }
.auth-card { display: flex; flex-direction: column; justify-content: center; padding: clamp(1.15rem, 3.6vw, 2.6rem); }
.auth-form input { margin: .45rem 0 .85rem; }
.auth-form .btn { width: 100%; }
.auth-form .error { color: var(--danger); margin: .7rem 0 0; min-height: 1.4rem; }
#notice { position: fixed; z-index: 6; bottom: 1rem; right: 1rem; max-width: min(27rem, calc(100% - 2rem)); padding: 0; }
#notice:not(:empty) { background: var(--deep); color: #eef7e8; border: 1px solid #7da88b; padding: .7rem .95rem; border-radius: .62rem; }

@media (max-width: 1050px) {
  .frame { grid-template-columns: 12rem minmax(0, 1fr); }
  .main { padding-left: 1.35rem; padding-right: 1.35rem; }
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 730px) {
  .frame { display: block; }
  .rail, .topbar-title, .date-stamp { display: none; }
  .main { padding: 0 1rem calc(5.5rem + env(safe-area-inset-bottom)); }
  .topbar { min-height: calc(3.7rem + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); margin-bottom: 1.15rem; }
  .topbar-mobile { display: flex; }
  .topbar-mobile img { width: 2.15rem; height: 2.15rem; }
  .topbar .mobile-logout { display: inline-flex; }
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 5;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding: .3rem max(.4rem,env(safe-area-inset-right)) calc(.3rem + env(safe-area-inset-bottom)) max(.4rem,env(safe-area-inset-left));
  }
  .mobile-nav .nav-link { color: var(--muted); flex-direction: column; justify-content: center; gap: .24rem; min-height: 3.1rem; padding: .35rem .2rem; font-size: .82rem; }
  .mobile-nav .nav-link[aria-current] { color: var(--primary); background: var(--wash); }
  .overview, .practice-layout { grid-template-columns: minmax(0, 1fr); }
  .overview { gap: .75rem; }
  .hero { min-height: 15.5rem; }
  .hero::after { width: 18rem; right: -10rem; top: -4rem; }
  .journey .count { font-size: 2rem; }
  .module { min-height: 7.6rem; }
  .auth-layout { grid-template-columns: minmax(0,1fr); padding-top: calc(1rem + env(safe-area-inset-top)); align-content: start; }
  .auth-hero { min-height: 16rem; }
  .auth-card { min-height: 11rem; }
  #notice { bottom: calc(4.55rem + env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .lesson-row .row-time { display: none; }
  .lesson-row { grid-template-columns: auto minmax(0,1fr); }
  .module { padding: .72rem; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

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