:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --soft: #eceee9;
  --border: #e4e1d9;
  --ink: #1f1e1c;
  --muted: #6b6862;
  --gold: #c49a2a;
  --warn-bg: #fdf1e7;
  --warn-fg: #b5541c;
  --danger: #c62828;
  --success: #2e7d4f;
  --ios: #1a6dd6;
  --re: #b5541c;
  --pa: #7a2e7f;
  --serif: "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --card: #1f1e1c; --soft: #2a2a27; --border: #34332f; --ink: #f4f1ea; --muted: #a7a39a;
    --gold: #d9b04a; --warn-bg: #3a2a1e; --warn-fg: #f0a06a; --danger: #ff7b72; --success: #6fd39a;
    --ios: #5f9ae4; --re: #d68a5f; --pa: #b57cb8; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --card: #1f1e1c; --soft: #2a2a27; --border: #34332f; --ink: #f4f1ea; --muted: #a7a39a;
  --gold: #d9b04a; --warn-bg: #3a2a1e; --warn-fg: #f0a06a; --danger: #ff7b72; --success: #6fd39a;
  --ios: #5f9ae4; --re: #d68a5f; --pa: #b57cb8; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 15px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
strong { font-weight: 700; }
code { font-size: .9em; background: var(--soft); padding: 1px 5px; border-radius: 5px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.3; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar & nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 880px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: #1f1e1c; color: #f4f1ea; display: grid; place-items: center; font-size: 17px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; gap: 6px; position: relative;
}
.nav a.active { background: var(--ink); color: var(--bg); }
.nav .badge { background: var(--danger); color: #fff; font-size: 11px; border-radius: 999px; padding: 0 6px; line-height: 18px; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; cursor: pointer; border: 0; padding: 0; }
.sync-dot.ok { background: var(--success); }
.sync-dot.busy { background: var(--gold); animation: pulse 1s infinite; }
.sync-dot.err { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 720px) {
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; margin: 0; z-index: 30; justify-content: space-around;
    background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .nav a { flex-direction: column; gap: 0; font-size: 11px; padding: 4px 8px; border-radius: 12px; }
  .nav a .ico { font-size: 18px; line-height: 1.3; }
  .nav a.active { background: var(--soft); color: var(--ink); }
  .nav .badge { position: absolute; top: 0; right: 4px; }
  main { padding-bottom: 90px !important; }
}
@media (min-width: 721px) { .nav .ico { display: none; } }

main { max-width: 880px; margin: 0 auto; padding: 22px 16px 60px; }

/* ---------- cards & common ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 14px; }
.grid2 > .card, .grid3 > .card { margin-top: 0; }
.soft { background: var(--soft); border-radius: 12px; padding: 12px 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 720px) { .grid3 { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .grid2.collapse { grid-template-columns: 1fr; } }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: color-mix(in srgb, var(--c, var(--muted)) 12%, transparent); color: var(--c, var(--muted)); white-space: nowrap; }
.pill.solid { background: var(--c, var(--ink)); color: #fff; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--card); border: 1px solid var(--border); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.chip.on { background: var(--c, var(--ink)); border-color: transparent; color: #fff; }
.chip.on .dot { background: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--c, var(--ink)); color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; color: var(--c, var(--ink)); font-weight: 600; cursor: pointer; font-size: 13px; }

input[type=text], input[type=url], input[type=password], input[type=search], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--ios); outline-offset: 2px; }
label.field { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }

/* ---------- prototype header ---------- */
.kicker { display: inline-flex; gap: 10px; align-items: center; font-size: 12px; font-weight: 700; }
.kicker .tag { background: var(--ink); color: var(--bg); border-radius: 999px; padding: 3px 10px; }
.page-title { font-size: 30px; margin: 10px 0 8px; }
@media (max-width: 720px) { .page-title { font-size: 24px; } }
.intro { max-width: 560px; color: var(--ink); opacity: .85; }

.datenav .chips { flex-wrap: wrap; overflow: visible; }
.datebtn { text-align: left; border-radius: 12px; padding: 8px 12px; border: 1px solid var(--border); background: var(--soft); cursor: pointer; text-decoration: none; display: block; }
.datebtn b { display: block; font-size: 14px; }
.datebtn span { font-size: 12px; color: var(--muted); }
.datebtn.on { background: var(--ink); color: var(--bg); border-color: transparent; }
.datebtn.on span { color: color-mix(in srgb, var(--bg) 70%, transparent); }

.dayhead { display: flex; align-items: center; gap: 10px; margin: 26px 0 4px; }
.dayhead h2 { font-size: 22px; }
.daybadge { background: var(--gold); color: #fff; font-weight: 700; font-size: 12px; padding: 3px 10px; border-radius: 999px; }

.trackcard .tag { font-size: 11px; font-weight: 800; letter-spacing: .4px; color: var(--c); }
.trackcard h3 { font-size: 20px; margin: 4px 0; }
.trackcard p { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- lesson ---------- */
.lesson { scroll-margin-top: 80px; }
.lesson-head { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.tbadge { width: 46px; height: 46px; border-radius: 11px; background: var(--c); color: #fff; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: 16px; flex: none; }
.tbadge.sm { width: 36px; height: 36px; font-size: 13px; border-radius: 9px; }
.lesson-head h2 { font-size: 21px; }
.lesson-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.lesson-head .pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.blocks > * { margin-top: 12px; }
.sec { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--c); margin-top: 20px !important; }
.sec::before { content: ""; width: 3px; height: 16px; border-radius: 2px; background: var(--c); opacity: .6; }
ul.bul, ol.num { margin: 0; padding-left: 20px; }
ul.bul li, ol.num li { margin: 6px 0; }
ol.num li::marker { color: var(--c); font-weight: 700; }
.text.muted { font-size: 13px; }

.roadmap { display: flex; flex-wrap: wrap; gap: 6px; }
.stage { border: 0; cursor: pointer; padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: color-mix(in srgb, var(--c) 12%, transparent); color: var(--c); }
.stage.past { opacity: .75; }
.stage.now { background: var(--c); color: #fff; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr 1fr; } }
.step { background: var(--soft); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; }
.step .n { font-family: var(--serif); font-size: 22px; color: var(--c); font-weight: 700; line-height: 1.2; }
.step .t { font-weight: 700; font-size: 14px; }
.step .d { font-size: 12px; color: var(--muted); flex: 1; }
.step .v { font-weight: 700; font-size: 16px; margin-top: 6px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl td:first-child { font-weight: 700; white-space: nowrap; }
.tbl .pill { margin-top: 4px; }
@media (max-width: 720px) {
  table.tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl thead { display: none; }
  .tbl tr { background: var(--soft); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
  .tbl td { border: 0; padding: 2px 0; }
  .tbl td[data-label]:not(:first-child)::before { content: attr(data-label) "："; color: var(--muted); font-size: 12px; font-weight: 600; }
}

.callout { display: flex; gap: 10px; align-items: flex-start; background: var(--soft); border-radius: 12px; padding: 11px 13px; }
.callout.warning { background: var(--warn-bg); }
.callout .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; flex: none; margin-top: 2px; }
.callout.danger .ic { background: var(--danger); }
.callout.success .ic { background: var(--success); }
.callout.step .ic { background: var(--muted); }
.callout.info .ic { background: var(--c); }
.callout.warning .ic { background: var(--warn-fg); }
.callout.warning strong { color: var(--warn-fg); }

.gloss { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 720px) { .gloss { grid-template-columns: 1fr 1fr; } }
.gloss .g { background: var(--soft); border-radius: 12px; padding: 12px; }
.gloss .g b { display: block; }
.gloss .g i { font-style: normal; color: var(--c); font-weight: 700; font-size: 12px; }
.gloss .g p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.infocards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.infocards.single { grid-template-columns: 1fr; }
@media (max-width: 720px) { .infocards { grid-template-columns: 1fr; } }
.infocards .soft b { display: block; margin-bottom: 4px; }

.question { border: 1px dashed var(--border); border-radius: 14px; padding: 14px; background: var(--card); }
.question .lab { font-size: 11px; font-weight: 800; letter-spacing: .5px; color: var(--c); }
.question .qen { font-weight: 700; font-size: 16px; margin: 4px 0; }
.question .qzh { color: var(--muted); font-size: 14px; }
.question .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.answer { background: color-mix(in srgb, var(--c) 9%, transparent); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.answer hr { border: 0; border-top: 1px solid color-mix(in srgb, var(--c) 25%, transparent); margin: 10px 0; }
.answer .zh { font-size: 14px; }
details.myanswer { margin-top: 10px; }
details.myanswer summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--c); }
details.myanswer textarea { margin-top: 8px; }

.actions { background: var(--soft); border-radius: 12px; padding: 12px 14px; }
.actions .t { font-weight: 700; margin-bottom: 4px; }
.todo { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; cursor: pointer; background: none; border: 0; text-align: left; width: 100%; }
.todo .box { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted); flex: none; margin-top: 3px; display: grid; place-items: center; font-size: 12px; color: #fff; }
.todo.done .box { background: var(--c); border-color: var(--c); }
.todo.done .tx { color: var(--muted); text-decoration: line-through; }

.donebtn { margin-top: 16px; }
.donebtn.on { background: var(--c); color: #fff; border-color: transparent; }
.footnote { text-align: center; font-size: 12px; color: var(--muted); margin: 26px 0 0; }

/* ---------- today ---------- */
.todayhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.streak { font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); color: var(--warn-fg); white-space: nowrap; }
.ring { width: 58px; height: 58px; position: relative; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; }
.lrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.lrow + .lrow { border-top: 1px solid var(--border); }
.lrow a { text-decoration: none; display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; }
.lrow .tag { font-size: 11px; font-weight: 800; color: var(--c); }
.lrow .ttl { font-weight: 600; }
.lrow .sum { font-size: 12.5px; color: var(--muted); }
.check { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); background: none; cursor: pointer; flex: none; font-size: 14px; color: #fff; }
.check.on { background: var(--c); border-color: var(--c); }
.stat { text-decoration: none; display: block; }
.stat .lab { font-size: 13px; font-weight: 700; color: var(--c); }
.stat .val { font-family: var(--serif); font-size: 30px; font-weight: 700; }
.stat .val small { font-family: var(--sans); font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.sched { width: 100%; border-collapse: collapse; font-size: 14px; }
.sched td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.sched td:first-child { font-weight: 700; white-space: nowrap; }
.sched td:last-child { color: var(--muted); white-space: nowrap; text-align: right; }

/* ---------- review ---------- */
.flash { perspective: 1200px; cursor: pointer; }
.flash-inner { position: relative; min-height: 300px; transition: transform .5s cubic-bezier(.2,.7,.2,1); transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--card); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); border-radius: 22px; padding: 22px; display: flex; flex-direction: column; box-shadow: 0 6px 20px rgba(0,0,0,.06); }
.face.back { transform: rotateY(180deg); }
.face .lab { font-size: 12px; font-weight: 800; color: var(--c); }
.face .en { font-size: 20px; font-weight: 600; margin: 10px 0; }
.face .zh { color: var(--muted); }
.face .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.grades { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.grades button { border: 0; border-radius: 12px; padding: 10px; cursor: pointer; font-weight: 700; }
.grades button small { display: block; font-weight: 400; font-size: 11px; opacity: .8; }
.grades .again { background: var(--warn-bg); }
.grades .hard { background: var(--soft); }
.grades .good { background: var(--success); color: #fff; }

/* ---------- focus ---------- */
.timer { text-align: center; }
.timer .clock { font-family: var(--serif); font-size: 64px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.bigring { width: 250px; height: 250px; margin: 14px auto; position: relative; }
.bigring svg { transform: rotate(-90deg); }
.bigring .inner { position: absolute; inset: 0; display: grid; place-content: center; }
.seg { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; justify-content: center; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.bar { height: 6px; background: var(--soft); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--c); border-radius: 999px; }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 90vw; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.result { text-decoration: none; display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
.result:last-child { border-bottom: 0; }
mark { background: color-mix(in srgb, var(--gold) 35%, transparent); color: inherit; border-radius: 3px; }
