:root {
  color-scheme: light;
  --bg: #eef0f8;
  --surface: #fdfdff;
  --ink: #293047;
  --muted: #576078;
  --line: #dce0ed;
  --accent: #545c91;
  --accent-deep: #494c77;
  --accent-pale: #ecebf9;
  --gradient: linear-gradient(118deg, #dce6f8 0%, #e2e2f5 50%, #eae0f2 100%);
  --gradient-deep: linear-gradient(122deg, #586891, #62517f);
  --miss-ink: #75462e;
  --miss-wash: #f7e8dc;
  --coral: #993d30;
  --coral-pale: #f9eae4;
  --radius: 22px;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.62 var(--sans); }
button, textarea, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: var(--accent); text-underline-offset: 4px; }
a:focus-visible, button:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid #6647a1; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.3; }
h1 { font-size: clamp(27px, 6vw, 38px); font-weight: 750; letter-spacing: -.025em; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.app-header { border-bottom: 1px solid var(--line); background: #f7f8fd; }
.header-inner { max-width: 936px; margin: auto; padding: 15px 22px; display: flex; align-items: center; justify-content: space-between; min-height: 66px; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 750; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; background: var(--gradient-deep); display: flex; flex-direction: column; gap: 4px; justify-content: center; padding-left: 8px; }
.brand-mark i { height: 2px; width: 17px; background: #f7f7ff; border-radius: 4px; }
.brand-mark i:nth-child(2) { width: 13px; background: #e3e4f8; }
.brand-mark i:nth-child(3) { width: 9px; background: #dbd9f4; }
.header-status { color: var(--muted); display: flex; gap: 13px; align-items: center; font-size: 12px; }
.header-status button { background: none; padding: 7px; border: 0; color: var(--accent); }
#main { outline: 0; width: min(100%, 936px); margin: auto; min-height: 60vh; padding: 34px 22px 114px; }
.loading, .blank { padding: 36px 20px; text-align: center; color: var(--muted); }
.stack { display: grid; gap: 19px; }
.headline { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.headline p { margin-top: 6px; }
.date-label { color: var(--accent); font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.hero { background: var(--gradient); color: #303552; border: 1px solid #ffffffa0; border-radius: 27px; padding: clamp(22px, 5.4vw, 43px); display: grid; grid-template-columns: minmax(0, 1fr) clamp(96px, 22vw, 160px); gap: clamp(13px, 4vw, 46px); align-items: center; min-height: 245px; box-shadow: 0 10px 28px #43487119; }
.hero h1 { font-size: clamp(29px, 6vw, 48px); margin: 8px 0 11px; }
.hero-meta { color: #505975; font-size: 13px; letter-spacing: .02em; }
.hero > div:first-child > p:last-of-type { color: #474e70; }
.hero .button { margin-top: 23px; background: var(--gradient-deep); color: white; }
.hero .button:hover { background: var(--accent-deep); }
.ring { width: 100%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(#676a9d calc(var(--progress) * 1%), #c9cee5 0); padding: clamp(5px, 1vw, 9px); }
.ring-center { width: 100%; height: 100%; background: #eeedf9; display: grid; border-radius: 50%; place-content: center; text-align: center; line-height: 1.4; }
.ring-center strong { font-size: clamp(21px, 4vw, 33px); font-variant-numeric: tabular-nums; }
.ring-center small { font-size: 11px; color: #474e70; }
.surface { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); padding: clamp(16px, 4vw, 27px); }
.surface h2 { margin-bottom: 14px; }
.brief { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; overflow: hidden; }
.brief-button { padding: 18px 12px; display: grid; justify-items: start; gap: 4px; text-align: left; border: 0; background: transparent; color: var(--ink); min-height: 94px; }
.brief-button + .brief-button { border-left: 1px solid var(--line); }
.brief-button:hover, .list-button:hover { background: #f1f2fb; }
.brief-button strong { font-weight: 700; font-size: 15px; }
.brief-button span { font-size: 13px; color: var(--muted); }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.chip { padding: 5px 10px; border-radius: 20px; background: var(--accent-pale); color: #494b78; font-size: 13px; display: inline-block; }
.source-details { color: var(--muted); font-size: 13px; }
.source-details summary { width: fit-content; cursor: pointer; }
.source-details a { display: block; width: fit-content; margin-top: 6px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 45px; padding: 10px 17px; border: 1px solid transparent; border-radius: 13px; text-decoration: none; font-weight: 690; line-height: 1.3; text-align: center; }
.primary { color: #fff; background: var(--accent); }
.primary:hover { background: #434876; }
.secondary { color: var(--accent); background: var(--accent-pale); }
.outline { background: var(--surface); border-color: var(--line); color: var(--ink); }
.text-button { background: transparent; color: var(--accent); border: 0; min-height: 42px; padding: 7px 0; text-align: left; }
.inline-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.navigation { position: fixed; bottom: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 12px max(9px, env(safe-area-inset-bottom)); background: #fbfbff; border-top: 1px solid var(--line); z-index: 2; }
.navigation button { border: 0; background: none; color: var(--muted); padding: 5px 8px; flex: 1; max-width: 155px; display: grid; justify-items: center; gap: 4px; font-size: 12px; border-radius: 12px; min-height: 48px; }
.navigation button[aria-current="page"] { background: var(--accent-pale); color: var(--accent-deep); font-weight: 700; }
.nav-icon { position: relative; width: 19px; height: 18px; }
.icon-today, .icon-calendar { border: 1.7px solid currentColor; border-radius: 4px; }
.icon-today { width: 15px; }
.icon-today::before { content: ""; position: absolute; left: 2px; width: 7px; top: 4px; height: 1.5px; background: currentColor; box-shadow: 0 4px currentColor, 0 8px currentColor; }
.icon-calendar::before { content: ""; position: absolute; top: 4px; left: 0; width: 100%; border-top: 1.5px solid currentColor; }
.icon-calendar::after { content: ""; position: absolute; top: 8px; left: 4px; width: 3px; height: 3px; border-radius: 100%; background: currentColor; box-shadow: 5px 0 currentColor; }
.icon-book { width: 20px; height: 16px; border: 1.7px solid currentColor; border-radius: 3px 3px 5px 5px; }
.icon-book::after { content: ""; position: absolute; left: 50%; top: 1px; bottom: 1px; border-left: 1.5px solid currentColor; }
.icon-wrong { border: 1.7px solid currentColor; border-radius: 50%; width: 17px; }
.icon-wrong::after { content: ""; position: absolute; top: 3px; right: 4px; width: 4px; height: 7px; border: solid currentColor; border-width: 0 1.7px 1.7px 0; transform: rotate(45deg); }
.quiz-layout { max-width: 710px; margin: auto; }
.quiz-layout > .stack { gap: 13px; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.quiz-top p { text-align: right; }
.tabs { display: flex; gap: 6px; overflow-x: auto; }
.tabs button { border: 1px solid var(--line); border-radius: 10px; min-height: 42px; padding: 8px 12px; background: var(--surface); white-space: nowrap; color: var(--muted); }
.tabs button[aria-pressed="true"] { background: var(--accent-pale); color: var(--accent-deep); border-color: #c4c7e6; font-weight: 700; }
.question-info { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 15px; }
.question-number { color: var(--accent); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.question-stem { white-space: pre-line; font-size: clamp(17px, 4vw, 22px); line-height: 1.58; font-weight: 680; margin-bottom: 18px; }
.options { display: grid; gap: 9px; }
.option { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; padding: 11px 12px; min-height: 51px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--surface); line-height: 1.48; }
.option span:last-child { padding-top: 3px; }
.option:not(:disabled):hover { border-color: #888bb7; }
.option[aria-pressed="true"], .option.picked { border-color: #7277a8; background: var(--accent-pale); }
.option.correct { border-color: #6a789a; background: var(--accent-pale); }
.option.incorrect { border-color: #d49588; background: var(--coral-pale); }
.option:disabled { opacity: 1; }
.letter { min-width: 27px; height: 27px; display: grid; place-items: center; background: #eff1f9; color: var(--ink); border-radius: 6px; font-size: 13px; font-weight: 740; }
.option.picked .letter, .option.correct .letter { color: white; background: var(--accent); }
.option.incorrect .letter { color: white; background: var(--coral); }
.response { width: 100%; padding: 13px; min-height: 176px; border-radius: 13px; border: 1px solid #a7afcd; background: #f8f9ff; color: var(--ink); resize: vertical; font-size: 16px; }
.recorded-answer { padding: 12px; border-radius: 12px; background: #f0f2f9; white-space: pre-wrap; overflow-wrap: anywhere; }
.save-text { text-align: right; min-height: 22px; margin-top: 8px; }
.feedback { margin-top: 16px; border-radius: 15px; padding: 15px; background: var(--accent-pale); display: grid; gap: 7px; }
.feedback.needs-work { background: #f8efe4; }
.feedback-title { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-weight: 700; }
.feedback p { overflow-wrap: anywhere; }
.feedback ul { margin: 2px 0 0; padding-left: 22px; }
.exercise-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.exercise-controls .primary { margin-left: auto; }
.map { border: 1px solid var(--line); border-radius: 13px; padding: 10px 13px; background: var(--surface); }
.map summary { cursor: pointer; color: var(--accent); }
.map-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; margin-top: 10px; }
.map-buttons button { font-size: 13px; border: 1px solid var(--line); background: var(--surface); min-height: 42px; border-radius: 8px; padding: 5px; color: var(--ink); }
.map-buttons button.filled { background: #ede7f5; }
.map-buttons button.graded { background: var(--accent-pale); }
.map-buttons button[aria-current="step"] { border: 2px solid var(--accent); font-weight: 700; }
.calendar { display: grid; gap: 10px; }
.month-controls { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.month-controls h2 { margin: 0; }
.month-controls button { min-width: 45px; padding: 7px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(3px, 1vw, 9px); }
.weekday { text-align: center; color: var(--muted); font-size: 12px; }
.date-button { min-height: clamp(43px, 9vw, 65px); border-radius: 10px; border: 1px solid transparent; display: grid; place-content: center; justify-items: center; gap: 2px; background: #eef0f8; color: var(--ink); font-variant-numeric: tabular-nums; padding: 3px; }
.date-button.current { border-color: #858ab2; }
.date-button.selected { border: 2px solid var(--accent); }
.date-button.recorded { background: var(--accent-pale); }
.date-dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.date-button.recorded .date-dot { background: var(--accent); }
.date-button.saved .date-dot { background: #a56b14; }
.record-list { display: grid; gap: 8px; padding: 0; list-style: none; margin: 10px 0 0; }
.list-button { text-align: left; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 13px; padding: 12px; display: grid; gap: 4px; width: 100%; }
.list-button .small { color: var(--muted); }
.knowledge-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; font-size: 13px; }
.knowledge-toolbar label { display: inline-flex; gap: 6px; align-items: center; min-height: 40px; cursor: pointer; }
.knowledge-toolbar input { margin: 0; width: 17px; height: 17px; accent-color: var(--accent); }
.chapter-list { display: grid; gap: 9px; padding: 0; margin: 0; list-style: none; }
.chapter-button { display: grid; grid-template-columns: 33px minmax(0, 1fr) auto 11px; align-items: center; gap: 10px; text-align: left; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; min-height: 64px; width: 100%; }
.chapter-button:hover { background: var(--accent-pale); border-color: #c4c7e6; }
.chapter-button strong, .chapter-button small { display: block; line-height: 1.4; }
.chapter-button small { color: var(--muted); margin-top: 3px; }
.chapter-index { width: 33px; height: 33px; display: grid; place-items: center; font-weight: 750; font-variant-numeric: tabular-nums; border-radius: 10px; background: var(--gradient); color: var(--accent-deep); }
.chapter-arrow { grid-column: 4; color: var(--muted); font-size: 21px; line-height: 1; }
.miss-badge { background: var(--miss-wash); color: var(--miss-ink); font-size: 12px; font-weight: 720; padding: 4px 8px; white-space: nowrap; border-radius: 22px; }
.knowledge-card { display: grid; gap: 9px; scroll-margin-block: 22px; }
.knowledge-card:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.knowledge-card.has-misses { background: #fefaf7; border-color: #dfbcaa; border-left: 3px solid #b47155; }
.knowledge-card-meta { display: flex; justify-content: space-between; align-items: center; gap: 7px; }
.knowledge-card h2 { font-size: 18px; margin: 0; }
.knowledge-card p { line-height: 1.75; }
.related-points { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.related-points .button { font-size: 13px; min-height: 39px; }
.dialog-actions { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }
dialog { width: min(93vw, 420px); border: 1px solid var(--line); border-radius: 18px; padding: 23px; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: #262942a3; }
dialog h2 { margin-bottom: 10px; }
.notice { position: fixed; z-index: 4; left: 50%; bottom: calc(77px + env(safe-area-inset-bottom)); transform: translateX(-50%); color: white; background: #36385e; border-radius: 12px; max-width: min(90vw, 540px); width: max-content; padding: 10px 16px; font-size: 13px; box-shadow: 0 5px 25px #25264030; }
.login { max-width: 420px; margin: 4vh auto; display: grid; gap: 15px; }
.login label { display: grid; gap: 7px; }
.login input { border-radius: 11px; min-height: 45px; border: 1px solid #a9b0cc; padding: 9px 12px; width: 100%; background: #f7f8ff; }
.login .error { color: var(--coral); }

@media (max-width: 560px) {
  .header-inner { padding: 11px 16px; min-height: 56px; }
  #main { padding: 21px 14px 106px; }
  .stack { gap: 13px; }
  .hero { min-height: 208px; }
  .hero .button { padding-inline: 12px; }
  .hero-meta { font-size: 12px; }
  .brief-button strong { font-size: 14px; }
  .brief-button span { font-size: 12px; }
  .hero > div:first-child > p:last-of-type { font-size: 13px; }
}

@media (min-width: 740px) {
  .today-lower { display: grid; grid-template-columns: 1.05fr .95fr; gap: 16px; }
  .calendar-layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
  .navigation { gap: 15px; }
  .chapter-list { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  .option, .button, .date-button { transition: background-color .12s, border-color .12s; }
}
