:root {
  color-scheme: dark;
  --night: #17162a;
  --night-2: #24213a;
  --ink: #f7f0e8;
  --muted: #bcb5c7;
  --dawn: #ffad91;
  --dawn-soft: #ffd6c8;
  --moon: #f4e7a4;
  --mist: #8ba8c9;
  --line: rgba(255, 255, 255, 0.14);
  --panel: rgba(255, 255, 255, 0.07);
  --panel-strong: rgba(255, 255, 255, 0.11);
  --shadow: 0 22px 55px rgba(4, 4, 13, 0.28);
  --radius: 22px;
  font-family: Inter, "Noto Sans TC", "Noto Sans JP", "Yu Gothic UI", "Microsoft JhengHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 78px; }
body {
  margin: 0;
  min-width: 280px;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 5%, rgba(255, 173, 145, 0.16), transparent 28rem),
    linear-gradient(180deg, #111020 0%, var(--night) 38%, #262036 72%, #453041 100%);
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.skip-link {
  position: fixed;
  z-index: 99;
  left: 12px;
  top: -70px;
  padding: 10px 14px;
  color: #17162a;
  background: var(--moon);
  border-radius: 10px;
}
.skip-link:focus { top: 12px; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 9px max(16px, env(safe-area-inset-right)) 9px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(17, 16, 32, 0.88);
  backdrop-filter: blur(16px);
}
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #17162a;
  background: linear-gradient(145deg, var(--moon), var(--dawn));
  border-radius: 50% 50% 50% 12px;
  font: 800 12px/1 Georgia, serif;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 13px; letter-spacing: .08em; }
.brand small { color: var(--muted); font-size: 9px; letter-spacing: .13em; }
.quiet-button, .handoff-actions button {
  min-height: 44px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
}
.quiet-button { padding: 8px 13px; font-size: 12px; }

main { overflow: hidden; }
.practice, .overview, .section, footer {
  width: min(100%, 980px);
  margin-inline: auto;
  padding: 64px max(18px, env(safe-area-inset-right)) 64px max(18px, env(safe-area-inset-left));
}
.practice { padding-top: 36px; }
.sky-clock { display: flex; align-items: center; gap: 12px; margin-bottom: 42px; color: var(--muted); font-size: 11px; letter-spacing: .18em; }
.sky-clock i { position: relative; flex: 1; height: 1px; background: linear-gradient(90deg, var(--mist), var(--dawn)); }
.sky-clock i::before, .sky-clock i::after { content: ""; position: absolute; top: -4px; width: 9px; height: 9px; border-radius: 50%; }
.sky-clock i::before { left: 0; background: var(--mist); }
.sky-clock i::after { right: 0; background: var(--dawn); }
.eyebrow { margin: 0 0 8px; color: var(--dawn); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, .overview h2, .section-heading h2 { margin: 0; font-family: "Noto Serif TC", "Yu Mincho", Georgia, serif; font-weight: 650; line-height: 1.23; }
h1 { max-width: 760px; font-size: clamp(34px, 8vw, 66px); letter-spacing: -.045em; }
.practice-copy > p:last-child { max-width: 680px; margin: 18px 0 0; color: var(--muted); }

.progress-block { margin: 36px 0 16px; padding: 16px 18px; border: 1px solid var(--line); background: var(--panel); border-radius: 16px; }
.progress-copy { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; }
.progress-copy span, #dueText { color: var(--muted); }
.progress-track { height: 6px; margin: 12px 0; overflow: hidden; background: rgba(255,255,255,.1); border-radius: 999px; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--mist), var(--dawn)); transition: width .35s ease; }
#dueText { margin: 0; font-size: 12px; }

.memory-card { overflow: hidden; border: 1px solid rgba(255,173,145,.34); background: linear-gradient(155deg, rgba(255,255,255,.12), rgba(255,255,255,.045)); border-radius: 28px; box-shadow: var(--shadow); }
.memory-card > header { display: flex; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; letter-spacing: .1em; }
.card-prompt { display: grid; place-items: center; min-height: 260px; padding: 32px 22px; text-align: center; }
.card-prompt small { color: var(--dawn-soft); }
.card-prompt h2 { margin: 16px 0 12px; font-size: clamp(35px, 11vw, 72px); font-weight: 650; line-height: 1.16; }
.card-prompt p { max-width: 480px; margin: 0; color: var(--muted); font-size: 14px; }
.reveal-button { width: 100%; min-height: 58px; border: 0; color: #21182a; background: linear-gradient(90deg, var(--moon), var(--dawn)); font-weight: 800; cursor: pointer; }
.answer { padding: 22px; border-top: 1px solid var(--line); }
.answer-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.answer-heading div span, .answer-heading > span { display: block; color: var(--muted); font-size: 12px; }
.answer-heading strong { display: block; font-size: 24px; }
.answer-meaning { margin-bottom: 4px; color: var(--dawn-soft); font-weight: 750; }
.example-box { margin: 20px 0; padding: 16px; border-left: 3px solid var(--dawn); background: rgba(0,0,0,.15); border-radius: 0 14px 14px 0; }
.example-box span { color: var(--dawn); font-size: 10px; font-weight: 800; letter-spacing: .15em; }
.example-box p { margin: 5px 0; }
.ratings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0; border: 0; }
.ratings legend { width: 100%; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.ratings button { min-height: 48px; padding: 7px; color: var(--ink); border: 1px solid var(--line); background: var(--panel); border-radius: 12px; cursor: pointer; }
.ratings button:last-child { color: #231b28; border-color: transparent; background: var(--dawn-soft); font-weight: 800; }

.handoff { display: grid; gap: 18px; margin-top: 18px; padding: 22px; border: 1px solid var(--line); background: linear-gradient(135deg, rgba(139,168,201,.12), rgba(255,173,145,.1)); border-radius: 22px; }
.handoff h2 { margin: 0; font-size: 22px; }
.handoff p { margin: 8px 0 0; color: var(--muted); }
.handoff-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.handoff-actions button { padding: 8px 12px; }
.handoff-actions button.is-done { color: #1d1925; border-color: var(--dawn-soft); background: var(--dawn-soft); font-weight: 800; }
.handoff .handoff-status { margin: 0; color: var(--dawn-soft); font-size: 13px; }

.jump-nav { display: flex; gap: 8px; width: min(100%, 980px); margin: 0 auto; padding: 0 18px 24px; overflow-x: auto; scrollbar-width: none; }
.jump-nav::-webkit-scrollbar { display: none; }
.jump-nav a { flex: 0 0 auto; min-width: 58px; padding: 10px 14px; text-align: center; text-decoration: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; font-size: 13px; }

.overview { padding-top: 74px; padding-bottom: 84px; }
.overview h2, .section-heading h2 { font-size: clamp(31px, 7vw, 54px); letter-spacing: -.035em; }
.overview > p:not(.eyebrow, .scope-note), .section-heading > p:last-child { max-width: 700px; color: var(--muted); }
.fact-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 32px 0; overflow: hidden; border: 1px solid var(--line); background: var(--line); border-radius: 18px; }
.fact-strip div { padding: 18px 10px; text-align: center; background: #1c1a2e; }
.fact-strip strong, .fact-strip span { display: block; }
.fact-strip strong { color: var(--dawn-soft); font: 700 25px/1 Georgia, serif; }
.fact-strip span { margin-top: 6px; color: var(--muted); font-size: 11px; }
.scope-note { padding: 14px 16px; color: var(--muted); border-left: 2px solid var(--mist); background: rgba(139,168,201,.08); font-size: 12px; }

.section { padding-top: 82px; padding-bottom: 82px; border-top: 1px solid var(--line); }
.section-heading { margin-bottom: 34px; }
.timeline { display: grid; gap: 10px; }
.day-card { display: grid; grid-template-columns: 62px 1fr; gap: 16px; padding: 20px 18px; border: 1px solid var(--line); background: var(--panel); border-radius: 18px; }
.day-label { color: var(--dawn); font: 800 13px/1.2 Georgia, serif; letter-spacing: .08em; }
.day-card h3 { margin: 0 0 5px; font-size: 17px; }
.day-card p { margin: 0; color: var(--muted); font-size: 14px; }
.day-task { display: inline-block; margin-top: 10px; color: var(--dawn-soft); font-size: 12px; }

.word-tools { position: sticky; z-index: 10; top: 64px; padding: 12px 0; background: rgba(23,22,42,.93); backdrop-filter: blur(14px); }
.word-tools input { width: 100%; min-height: 50px; padding: 10px 16px; color: var(--ink); border: 1px solid var(--line); outline: none; background: #201e33; border-radius: 14px; }
.word-tools input:focus { border-color: var(--dawn); box-shadow: 0 0 0 3px rgba(255,173,145,.14); }
.filter-row { display: flex; gap: 7px; margin-top: 9px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row button { flex: 0 0 auto; min-height: 42px; padding: 8px 12px; color: var(--muted); border: 1px solid var(--line); background: transparent; border-radius: 999px; cursor: pointer; }
.filter-row button[aria-pressed="true"] { color: #20182a; border-color: var(--dawn); background: var(--dawn); font-weight: 800; }
.result-count { color: var(--muted); font-size: 12px; }
.word-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.word-card { padding: 18px; border: 1px solid var(--line); background: var(--panel); border-radius: 18px; }
.word-card header { display: flex; justify-content: space-between; gap: 12px; }
.word-card h3 { margin: 0; font-size: 22px; }
.word-card .reading, .word-card .pos { color: var(--muted); font-size: 11px; }
.word-card .reading { margin-left: 8px; }
.word-card .meaning { margin: 9px 0 5px; color: var(--dawn-soft); font-weight: 700; }
.word-card .note { margin: 0; color: var(--muted); font-size: 13px; }
.word-card details { margin-top: 13px; border-top: 1px solid var(--line); }
.word-card summary { min-height: 44px; padding-top: 11px; color: var(--mist); cursor: pointer; }
.word-card details p { margin: 5px 0; font-size: 13px; }

.contrast-section { width: 100%; max-width: none; padding-inline: max(18px, calc((100vw - 944px) / 2)); background: rgba(5,5,15,.22); }
.contrast-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.contrast-card { padding: 20px; border: 1px solid var(--line); background: rgba(10,9,24,.42); border-radius: 18px; }
.contrast-pair { display: flex; align-items: center; gap: 10px; color: var(--dawn-soft); font-size: 20px; font-weight: 800; }
.contrast-pair i { flex: 0 0 24px; height: 1px; background: var(--dawn); }
.contrast-card p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

.pattern-stack { display: grid; gap: 10px; }
.pattern-card { border: 1px solid var(--line); background: var(--panel); border-radius: 18px; }
.pattern-card summary { min-height: 62px; padding: 17px 18px; cursor: pointer; list-style: none; }
.pattern-card summary::-webkit-details-marker { display: none; }
.pattern-card summary span { display: block; color: var(--dawn); font-size: 11px; letter-spacing: .1em; }
.pattern-card summary strong { display: block; margin-top: 4px; font-size: 18px; }
.pattern-body { padding: 0 18px 18px; border-top: 1px solid var(--line); }
.pattern-body p { margin: 12px 0 0; color: var(--muted); }
.pattern-body .formula { color: var(--ink); }
.pattern-example { padding: 12px 14px; background: rgba(0,0,0,.14); border-radius: 12px; }

.transfer-list { display: grid; gap: 10px; }
.transfer-card { border: 1px solid rgba(139,168,201,.28); background: rgba(139,168,201,.07); border-radius: 18px; }
.transfer-card summary { min-height: 58px; padding: 16px 18px; cursor: pointer; font-weight: 700; }
.transfer-card div { padding: 0 18px 18px; }
.transfer-card .model-answer { color: var(--dawn-soft); font-size: 17px; }
.transfer-card p { color: var(--muted); }

.method-list { display: grid; gap: 10px; }
.method-list article { display: grid; grid-template-columns: 44px 1fr; gap: 14px; padding: 19px; border: 1px solid var(--line); background: var(--panel); border-radius: 18px; }
.method-list article > strong { color: var(--dawn); font: 700 18px/1 Georgia, serif; }
.method-list h3 { margin: 0; }
.method-list p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.research-panel { margin-top: 20px; border: 1px solid var(--line); border-radius: 18px; }
.research-panel summary { min-height: 56px; padding: 15px 18px; cursor: pointer; font-weight: 800; }
.research-panel div { padding: 0 18px 18px; }
.research-panel ul { margin: 0; padding-left: 20px; }
.research-panel li { margin: 10px 0; color: var(--muted); }
.research-panel a { text-underline-offset: 4px; }

footer { padding-top: 48px; padding-bottom: calc(48px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); }
footer strong { color: var(--ink); }
footer p { margin: 4px 0 0; font-size: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 680px) {
  .practice, .overview, .section { padding-inline: max(16px, env(safe-area-inset-left)); }
  .fact-strip { grid-template-columns: repeat(2, 1fr); }
  .word-list, .contrast-grid { grid-template-columns: 1fr; }
  .card-prompt { min-height: 230px; }
  .ratings { grid-template-columns: 1fr; }
  .ratings button { min-height: 46px; }
}

@media (max-width: 360px) {
  .topbar { padding-inline: 12px; }
  .brand small { display: none; }
  .quiet-button { padding-inline: 10px; }
  .practice { padding-top: 26px; }
  .sky-clock { margin-bottom: 30px; }
  .handoff-actions { grid-template-columns: 1fr; }
  .day-card { grid-template-columns: 48px 1fr; padding-inline: 14px; }
  .fact-strip div { padding-inline: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media print {
  :root { color-scheme: light; }
  body { color: #18152a; background: white; }
  .topbar, .jump-nav, .practice, .word-tools { position: static; }
  .topbar, .jump-nav, .practice, .word-tools, footer { display: none; }
  .overview, .section { width: 100%; padding: 28px 0; border-color: #bbb; }
  .overview h2, .section-heading h2, .word-card, .contrast-card, .pattern-card, .transfer-card, .method-list article { color: #18152a; }
  .word-card, .contrast-card, .pattern-card, .transfer-card, .method-list article { break-inside: avoid; border-color: #bbb; background: white; }
  .word-card .note, .contrast-card p, .pattern-body p, .method-list p { color: #444; }
}
