/* ───────── 主题 ───────── */
:root {
  --bg: #f3f6fb;
  --bg2: #e9eef7;
  --card: #ffffff;
  --text: #182033;
  --muted: #6f7a91;
  --line: rgba(24, 40, 70, .09);
  --pri: #2f80ed;
  --pri2: #00b8a0;
  --pri-soft: rgba(47, 128, 237, .12);
  --ok: #20c997;
  --ok-soft: rgba(32, 201, 151, .14);
  --ok-text: #0b9a71;
  --warn: #fab005;
  --bad: #f25c5c;
  --bad-soft: rgba(242, 92, 92, .13);
  --shadow: 0 10px 30px rgba(30, 50, 90, .07), 0 2px 6px rgba(30, 50, 90, .05);
  --radius: 22px;
  /* 图形配色：c1…c6，深浅模式各一套，保证在背景上都看得清 */
  --v1: #3b6cf6;
  --v2: #e8384f;
  --v3: #20a35a;
  --v4: #f08c00;
  --v5: #a23ed6;
  --v6: #0d9fb8;
  --grid: rgba(24, 40, 70, .07);
  --axis: rgba(24, 40, 70, .55);
  --code-bg: #0f1729;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1220; --bg2: #151d30; --card: #172036; --text: #e8eefc; --muted: #8e9ab6; --line: rgba(255, 255, 255, .08);
    --pri: #5b9dff; --pri2: #2de0c4; --pri-soft: rgba(91, 157, 255, .16); --ok-soft: rgba(32, 201, 151, .18); --ok-text: #4fe0b0; --bad-soft: rgba(242, 92, 92, .18);
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --v1: #7c9cff; --v2: #ff6b81; --v3: #4ad485; --v4: #ffb84d; --v5: #d083ff; --v6: #3fd3ea;
    --grid: rgba(255, 255, 255, .06); --axis: rgba(255, 255, 255, .5); --code-bg: #0a0f1c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1220; --bg2: #151d30; --card: #172036; --text: #e8eefc; --muted: #8e9ab6; --line: rgba(255, 255, 255, .08);
  --pri: #5b9dff; --pri2: #2de0c4; --pri-soft: rgba(91, 157, 255, .16); --ok-soft: rgba(32, 201, 151, .18); --ok-text: #4fe0b0; --bad-soft: rgba(242, 92, 92, .18);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --v1: #7c9cff; --v2: #ff6b81; --v3: #4ad485; --v4: #ffb84d; --v5: #d083ff; --v6: #3fd3ea;
  --grid: rgba(255, 255, 255, .06); --axis: rgba(255, 255, 255, .5); --code-bg: #0a0f1c;
  color-scheme: dark;
}

/* ───────── 基础 ───────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  background-image: radial-gradient(1200px 500px at 90% -10%, var(--pri-soft), transparent 60%), radial-gradient(900px 400px at -10% 110%, rgba(0, 184, 160, .08), transparent 60%);
  background-attachment: fixed; min-height: 100vh;
}
body.noscroll { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
kbd { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 5px; border-radius: 5px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; justify-content: center; }
.left { text-align: left; }
[hidden] { display: none !important; }
.katex { font-size: 1.08em; }
.katex-display { margin: .3em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
/* 行内代码可能很长又没有空格（ctx.getTransform().inverse()…），允许任意处折行，不然手机上会把整页撑宽 */
code { overflow-wrap: anywhere; }

/* ───────── 布局 ───────── */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; padding: calc(22px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom)); max-width: 980px; margin: 0 auto; }
.view { display: none; animation: viewIn .35s ease; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }

.nav {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--card) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--line);
}
.nav .brand { display: none; }
.nav a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0 2px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; transition: color .2s; }
.ni { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 15px; transition: background .25s, transform .25s; }
.ni svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.on { color: var(--pri); font-weight: 700; }
.nav a.on .ni { background: var(--pri-soft); }
.nav a.on .ni svg { stroke-width: 2.2; }
.nav a:active .ni { transform: scale(.92); }

@media (min-width: 900px) {
  .nav {
    position: sticky; top: 0; height: 100vh; width: 232px; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 24px 14px; border-top: 0; border-right: 1px solid var(--line);
  }
  .nav .brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; }
  .brand .logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 22px; font-weight: 800; background: linear-gradient(135deg, var(--pri), var(--pri2)); box-shadow: 0 6px 16px var(--pri-soft); }
  .brand b { display: block; font-size: 17px; }
  .brand small { color: var(--muted); font-size: 12px; }
  .nav a { flex: none; max-width: none; flex-direction: row; gap: 10px; padding: 6px 10px; border-radius: 14px; font-size: 15px; }
  .ni { width: 30px; height: 30px; }
  .nav a:hover { background: var(--bg2); }
  .nav a.on { background: var(--pri-soft); }
  .nav a.on .ni { background: none; }
  .main { padding: 32px 36px 48px; }
}

/* ───────── 通用组件 ───────── */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.grid2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.page-title { font-size: 26px; margin: 4px 0 18px; letter-spacing: -.3px; }
.page-title small, .sec small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.sec { font-size: 18px; margin: 28px 0 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 14px; text-decoration: none;
  background: var(--bg2); font-weight: 600; transition: transform .15s, box-shadow .2s, background .2s; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.pri { background: linear-gradient(135deg, var(--pri), var(--pri2)); color: #fff; box-shadow: 0 8px 20px -6px var(--pri); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--bad); }
.btn.glow { animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--pri) 25%, transparent), 0 8px 20px -6px var(--pri); } }
.btns { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.icon-btn { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--bg2); font-size: 15px; flex: none; }
.link { color: var(--pri); font-weight: 600; font-size: 14px; }

.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; color: var(--c, var(--pri)); background: color-mix(in srgb, var(--c, var(--pri)) 14%, transparent); white-space: nowrap; }
.tag.task { --c: var(--pri); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span { font-size: 13px; padding: 6px 11px; border-radius: 99px; background: var(--bg2); }
.chips b { color: var(--pri); }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { padding: 8px 14px; border-radius: 12px; background: var(--bg2); font-size: 14px; transition: .2s; border: 1.5px solid transparent; }
.seg button.on { background: var(--pri-soft); color: var(--pri); border-color: var(--pri); font-weight: 600; }
.scroller { overflow-x: auto; margin: 0 -16px 10px; padding: 2px 16px; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.scroller .seg { flex-wrap: nowrap; }
.scroller .seg button { white-space: nowrap; }

.pbar { position: relative; height: 7px; border-radius: 9px; background: var(--bg2); overflow: hidden; }
.pbar i { position: absolute; inset: 0 auto 0 0; border-radius: 9px; background: var(--c, var(--pri)); transition: width .6s ease; }

.empty { text-align: center; padding: 24px 0 8px; color: var(--muted); }
.big-emo { font-size: 64px; line-height: 1.1; }
.bounce-in { animation: bounceIn .7s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bounceIn { from { transform: scale(0) rotate(-30deg); } }
@keyframes a-pulse { 50% { transform: scale(1.15); } }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.toast {
  position: fixed; z-index: 200; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(20, 24, 36, .9); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; transition: .25s; backdrop-filter: blur(10px); max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 300; }

.howto { margin-top: 24px; }
.howto summary { cursor: pointer; font-weight: 700; list-style: none; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: "›"; float: right; transition: .2s; color: var(--muted); }
.howto[open] summary::after { transform: rotate(90deg); }
.howto ul { padding-left: 20px; margin: 14px 0 4px; }
.howto li { margin: 8px 0; }

/* ───────── 首页 ───────── */
.hello { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.hello h1 { margin: 0; font-size: 28px; letter-spacing: -.4px; }
.hello p { margin: 4px 0 0; color: var(--muted); }
.wave { display: inline-block; animation: wave 2.4s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wave { 0%, 60%, 100% { transform: none; } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-8deg); } }
.streak { flex: none; display: flex; flex-direction: column; align-items: center; padding: 8px 14px; border-radius: 18px; background: linear-gradient(160deg, #fff4e6, #ffe8cc); color: #d9480f; box-shadow: var(--shadow); }
.streak .fire { font-size: 22px; animation: a-pulse 1.6s ease-in-out infinite; }
.streak b { font-size: 22px; line-height: 1; }
.streak small { font-size: 11px; }

.today { display: flex; gap: 20px; align-items: center; }
.today-info { flex: 1; min-width: 0; }
.ring { position: relative; width: 120px; height: 120px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring .bg { stroke: var(--bg2); }
.ring .fg { stroke: var(--pri); stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: calc(326.7 * (1 - var(--p))); transition: stroke-dashoffset 1s ease; animation: ringIn 1.2s ease; }
@keyframes ringIn { from { stroke-dashoffset: 326.7; } }
.ring-txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-txt b { font-size: 30px; line-height: 1; }
.ring-txt small { color: var(--muted); font-size: 12px; margin-top: 4px; }
@media (max-width: 480px) {
  .today { flex-direction: column; text-align: center; }
  .today .chips, .today .btns { justify-content: center; }
}
.cshome h3 { margin: 12px 0 6px; }
.cs-scene { margin: 0; color: var(--muted); }
.cs-from { font-size: 12px; }

.books { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 700px) { .books { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.bookc {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow);
  border: 1px solid var(--line); overflow: hidden; text-decoration: none; transition: transform .2s;
}
.bookc::before { content: ""; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: var(--c); opacity: .13; transition: transform .4s; }
.bookc:hover { transform: translateY(-3px); }
.bookc:hover::before { transform: scale(1.4); }
.bookc b { font-size: 15px; }
.bookc small { font-size: 16px; letter-spacing: 2px; margin-bottom: 6px; }
.bookc em { font-style: normal; font-size: 12px; color: var(--muted); }

.pick3 { display: grid; gap: 12px; }
@media (min-width: 700px) { .pick3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pick1 { display: flex; flex-direction: column; gap: 4px; padding: 16px; text-decoration: none; border-top: 4px solid var(--c); transition: transform .2s; }
.pick1:hover { transform: translateY(-2px); }
.pick1 span { font-size: 28px; }
.pick1 small { color: var(--muted); font-size: 12px; }

/* ───────── 课程地图 ───────── */
.wtabs { display: flex; gap: 6px; padding: 4px; border-radius: 14px; background: var(--bg2); margin-bottom: 14px; width: fit-content; }
.wtabs a { padding: 7px 16px; border-radius: 10px; text-decoration: none; font-size: 14px; font-weight: 600; color: var(--muted); }
.wtabs a.on { background: var(--card); color: var(--text); box-shadow: 0 2px 6px rgba(0, 0, 0, .06); }
.wtabs { max-width: 100%; overflow-x: auto; }
.wtabs a { white-space: nowrap; }
@media (max-width: 480px) { .wtabs a { padding: 7px 10px; font-size: 13px; } }
.bdesc { margin: 4px 0 0; font-size: 14px; }
.legend { font-size: 12px; margin-top: 24px; }

.gpath { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.gpath::before { content: ""; position: absolute; left: 31px; top: 20px; bottom: 20px; border-left: 3px dotted color-mix(in srgb, var(--c) 45%, transparent); }
@media (min-width: 760px) {
  .gpath { display: grid; grid-template-columns: 1fr 1fr; }
  .gpath::before { display: none; }
}
.gnode {
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left; padding: 8px 14px 8px 8px; border-radius: 22px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .2s;
}
.gnode:hover { transform: translateY(-2px); }
.gn-bub { position: relative; z-index: 1; flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: var(--bg2); border: 3px solid var(--bg2); transition: .3s; }
.gn-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gn-txt b { font-size: 15px; }
.gn-txt small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gnode.st-done .gn-bub, .gnode.st-master .gn-bub, .gnode.st-due .gn-bub { background: color-mix(in srgb, var(--c) 18%, var(--card)); border-color: var(--c); }
.gnode.st-soon { opacity: .55; box-shadow: none; }
.gnode.st-soon .gn-bub { filter: grayscale(.8); }
.gnode.next { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent), var(--shadow); }
.gnode.next .gn-bub { background: var(--c); border-color: var(--c); animation: a-pulse 1.8s ease-in-out infinite; }
.gstars { flex: none; font-style: normal; color: #fcc419; letter-spacing: 1px; font-size: 14px; }
.gbadge { flex: none; font-style: normal; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.gbadge.go { color: #fff; background: var(--c); }
.gbadge.due { color: #e67700; background: #fff3bf; }
.gbadge.soon { color: var(--muted); background: var(--bg2); font-weight: 500; }
div.gnode { cursor: pointer; }
.gn-from { color: var(--c); font-weight: 600; text-decoration: none; }
.gn-from:hover { text-decoration: underline; }
.gnode.flash { animation: flash 1.1s ease 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 45%, transparent), var(--shadow); } }
.backlink { display: inline-block; margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--pri); text-decoration: none; }

/* ───────── 学习路线 ───────── */
.phead { margin-bottom: 6px; }
.phead-top { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.phead-e { flex: none; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; background: color-mix(in srgb, var(--c) 15%, var(--card)); }
.phead h2 { margin: 2px 0 4px; font-size: 20px; }
.phead-top p { margin: 0; font-size: 14px; }
.phead .small { margin: 8px 0 14px; font-size: 13px; }
.pathhome { display: block; text-decoration: none; color: inherit; margin-bottom: 16px; border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line)); }
.ph-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ph-top em { font-style: normal; font-size: 13px; color: var(--muted); }
.pathhome h3 { margin: 10px 0 8px; }
.ph-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; }
.ph-steps span { padding: 4px 10px; border-radius: 99px; background: var(--bg2); }
.ph-steps span.now { background: var(--c); color: #fff; font-weight: 600; }
.ph-steps span.soon { opacity: .6; }
.ph-steps i { font-style: normal; color: var(--muted); }

/* ───────── 弹窗 ───────── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-bg { position: absolute; inset: 0; background: rgba(8, 12, 25, .45); backdrop-filter: blur(4px); animation: fadeIn .25s; }
.modal-card {
  position: relative; width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 28px 28px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; animation: sheetIn .35s cubic-bezier(.2, 1, .3, 1);
}
@media (min-width: 700px) { .modal { align-items: center; } .modal-card { border-radius: 28px; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetIn { from { transform: translateY(60px); opacity: 0; } }
.dtop { display: flex; align-items: center; gap: 8px; }
.dtop .icon-btn { margin-left: auto; }
.sheet-hero { display: flex; align-items: center; gap: 14px; }
.sheet-hero h2 { margin: 0; font-size: 22px; }
.sheet-emo { font-size: 44px; }
.sheet-pre { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sheet-pre b { font-size: 13px; color: var(--muted); margin-right: 4px; }
.sheet-warn { margin: 0; padding: 10px 14px; border-radius: 14px; background: #fff9db; color: #7c5e10; font-size: 14px; }
.mini-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; }
.mini-list.left { justify-content: flex-start; }
.mini { padding: 5px 10px; border-radius: 10px; background: var(--bg2); font-size: 13px; text-decoration: none; }
.mini em { font-style: normal; font-size: 11px; color: var(--muted); margin-left: 6px; }
.mini.st-new em, .mini.st-due em { color: #e67700; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sheet-warn { background: rgba(250, 176, 5, .14); color: #ffe066; } }
:root[data-theme="dark"] .sheet-warn { background: rgba(250, 176, 5, .14); color: #ffe066; }

/* ───────── 数学 × 编程 ───────── */
.cslist { display: grid; gap: 12px; margin-top: 12px; }
.cslist > * { min-width: 0; } /* 网格里的卡片默认不会比内容窄，一张卡片里有长内容会把整列撑宽 */
@media (min-width: 700px) { .cslist { grid-template-columns: 1fr 1fr; } }
.csitem { text-align: left; display: flex; flex-direction: column; gap: 6px; border-top: 4px solid var(--c); transition: transform .2s; }
.csitem:hover { transform: translateY(-2px); }
.csitem b { font-size: 16px; }
.csitem p { margin: 0; color: var(--muted); font-size: 14px; }
.csitem small { color: var(--muted); font-size: 12px; }
.cs-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-tags em { font-style: normal; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: rgba(12, 166, 120, .12); color: var(--ok-text); }
.cs-title { margin: 0; font-size: 20px; }
.cs-note { margin: 0; font-size: 14px; color: var(--muted); }

/* ───────── 上课 ───────── */
.learn { max-width: 640px; margin: 0 auto; }
.ltop { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.lbar { flex: 1; height: 10px; border-radius: 9px; background: var(--bg2); overflow: hidden; }
.lbar i { display: block; height: 100%; border-radius: 9px; background: linear-gradient(90deg, var(--pri), var(--pri2)); transition: width .4s ease; }
.lcount { font-size: 13px; font-weight: 600; color: var(--muted); min-width: 44px; text-align: right; }
.lcard { display: flex; flex-direction: column; gap: 14px; padding: 18px 16px; border-radius: 28px; animation: cardIn .4s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes cardIn { from { transform: translateY(24px) scale(.97); opacity: 0; } }
.lcard.pop { animation: qpop .4s ease; }
.lcard.shake { animation: qshake .45s ease; }
@keyframes qpop { 50% { transform: scale(1.015); } }
@keyframes qshake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.fhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ltitle { margin: 2px 0 0; font-size: 22px; letter-spacing: -.3px; }
.lhook { margin: 0; font-size: 16px; }
.gtip { margin: 0; text-align: center; font-size: 13px; color: var(--muted); }
.gq { margin: 4px 0 0; font-size: 18px; font-weight: 700; text-align: center; }
.gfrom { font-size: 13px; color: var(--muted); margin-top: -6px; }
.iq { font-size: 17px; font-weight: 600; }
.iq:empty { display: none; }
.lviz { margin: 0 -4px; }

.opts { display: grid; gap: 10px; }
@media (min-width: 520px) { .opts { grid-template-columns: 1fr 1fr; } }
.opt { display: flex; align-items: center; gap: 10px; text-align: left; padding: 13px 14px; border-radius: 16px; background: var(--bg2); font-size: 16px; font-weight: 600; border: 2px solid transparent; transition: .15s; min-width: 0; }
.opt > span { min-width: 0; overflow-wrap: anywhere; }
.opt:hover:not(:disabled) { border-color: var(--pri); }
.opt kbd { flex: none; }
.opt.sm { padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.opt.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok-text); animation: qpop .35s ease; opacity: 1; }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); animation: qshake .4s ease; opacity: 1; }
.opt:disabled:not(.right):not(.wrong) { opacity: .5; }
.opts.tf { grid-template-columns: 1fr 1fr; }
.opts.tf .opt { justify-content: center; font-size: 18px; padding: 16px; }

.reveal { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 20px; animation: viewIn .35s ease; }
.reveal.ok { background: var(--ok-soft); }
.reveal.bad { background: var(--bad-soft); }
.fb-title { font-size: 17px; }
.reveal.ok .fb-title { color: var(--ok-text); }
.reveal.bad .fb-title { color: var(--bad); }
.gans { font-size: 16px; font-weight: 600; }
.gwhy { font-size: 15px; }
#fb { scroll-margin-bottom: calc(160px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { #fb { scroll-margin-bottom: 100px; } }
#fb:empty { display: none; }

.lnext {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 5; display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 12px; padding: 8px;
  border-radius: 22px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.lnext:empty { display: none; }
.lnext .btn.pri { min-width: 130px; }
.nexttime { margin-right: auto; font-size: 13px; color: var(--muted); padding: 0 8px; }
@media (min-width: 900px) { .lnext { bottom: 16px; } }

/* 规律与原理 */
.lformula { padding: 14px 12px; border-radius: 18px; background: var(--pri-soft); text-align: center; font-size: 17px; overflow-x: auto; }
@media (max-width: 480px) { .lformula { font-size: 14px; padding: 12px 6px; } }
.lrule { font-size: 16px; }
.lrule p { margin: 0 0 8px; }
.lwhy { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 18px; background: var(--bg2); }
.lwhy > b { font-size: 14px; }
.gtrap { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 18px; background: #fff9db; color: #5c3d00; }
.gtrap small { color: #8a6100; font-size: 14px; }
.gt { display: flex; align-items: baseline; gap: 8px; font-size: 15px; }
.gt.bad > div { color: #c92a2a; }
.gt.good > div { color: #087f5b; font-weight: 600; }
:root[data-theme="dark"] .gtrap { background: rgba(250, 176, 5, .12); color: #ffe8a1; }
:root[data-theme="dark"] .gtrap small { color: #f2cc60; }
:root[data-theme="dark"] .gt.bad > div { color: #ff8787; }
:root[data-theme="dark"] .gt.good > div { color: #63e6be; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gtrap { background: rgba(250, 176, 5, .12); color: #ffe8a1; }
  :root:not([data-theme="light"]) .gtrap small { color: #f2cc60; }
  :root:not([data-theme="light"]) .gt.bad > div { color: #ff8787; }
  :root:not([data-theme="light"]) .gt.good > div { color: #63e6be; }
}

/* 例题 */
.exq { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 18px; background: var(--bg2); font-size: 16px; }
.exq > b { font-size: 13px; color: var(--muted); }
.exsteps { display: flex; flex-direction: column; gap: 10px; }
.exs { display: flex; gap: 10px; animation: viewIn .35s ease; }
.exn { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--bg2); color: var(--muted); }
.exs.cur .exn { background: var(--uc, var(--pri)); color: #fff; }
.exb { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.exm { font-size: 17px; overflow-x: auto; }
.exq2 { font-weight: 600; }
.exwhy small { display: block; color: var(--muted); margin-bottom: 6px; }
.exfb { font-size: 14px; font-weight: 600; }
.exfb.ok { color: var(--ok-text); }
.exfb.bad { color: var(--bad); }
.vs-opts { display: flex; flex-wrap: wrap; gap: 8px; }

/* 填空 + 符号键盘 */
.ansbox { display: flex; flex-direction: column; gap: 8px; }
.ansrow { display: flex; gap: 8px; }
input.ans { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg2); font-size: 18px; outline: none; transition: .2s; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
input.ans:focus { border-color: var(--pri); }
input.ans.right { border-color: var(--ok); background: var(--ok-soft); }
input.ans.wrong { border-color: var(--bad); background: var(--bad-soft); text-decoration: line-through; }
.kpad { display: grid; grid-template-columns: repeat(auto-fit, minmax(34px, 1fr)); gap: 6px; }
.kpad button { min-width: 0; height: 38px; padding: 0 4px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-size: 16px; font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .05); }
.kpad button:active:not(:disabled) { transform: scale(.94); }
.anspv { color: var(--muted); min-height: 1em; }

/* 排步骤 */
.sslot { display: flex; flex-direction: column; gap: 8px; min-height: 56px; padding: 10px; border-radius: 16px; border: 2px dashed var(--line); }
.sbank { display: flex; flex-direction: column; gap: 8px; }
.srow { display: flex; align-items: center; gap: 8px; }
.stile { flex: 1; text-align: left; padding: 10px 14px; border-radius: 14px; background: var(--bg2); border: 2px solid transparent; font-size: 15px; animation: viewIn .25s ease; }
.stile:not(:disabled):hover { border-color: var(--pri); }
.stile:disabled { opacity: 1; cursor: default; }
.stile.ok { border-color: var(--ok); background: var(--ok-soft); }
.stile.bad { border-color: var(--bad); background: var(--bad-soft); }
.gslot-hint { align-self: center; color: var(--muted); font-size: 14px; margin: auto; }
.sorder { margin: 0; padding-left: 22px; font-weight: 500; }

/* 练习：连对进度、提示、不会 */
.streak3 { margin-left: auto; display: flex; gap: 5px; }
.streak3 i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ok); transition: .3s; }
.streak3 i.on { background: var(--ok); animation: qpop .4s ease; }
.itools { display: flex; gap: 16px; align-items: center; }
.itools .idk { color: var(--muted); font-weight: 500; }
.hintbox div + div { margin-top: 6px; }
.gans.miss { color: var(--bad); font-weight: 500; font-size: 15px; }
.cshook { margin: -4px 0 0; padding: 8px 12px; border-radius: 12px; background: rgba(12, 166, 120, .1); color: var(--ok-text); font-size: 14px; }
.csread { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; border-left: 4px solid #0ca678; }
.csread small { color: var(--muted); }

/* 公式卡 */
.flip { display: flex; flex-direction: column; gap: 12px; padding: 22px 16px; border-radius: 20px; background: linear-gradient(135deg, var(--pri-soft), rgba(0, 184, 160, .1)); text-align: center; font-size: 18px; }
.flip-b { padding-top: 12px; border-top: 1px dashed var(--line); animation: viewIn .35s ease; }
.hint { align-self: flex-start; }
.hintbox { padding: 10px 14px; border-radius: 14px; background: #fff9db; color: #7c5e10; font-size: 14px; }
:root[data-theme="dark"] .hintbox { background: rgba(250, 176, 5, .14); color: #ffe066; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hintbox { background: rgba(250, 176, 5, .14); color: #ffe066; } }

/* 完成 */
.done { text-align: center; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.done h2 { margin: 6px 0 0; }
.done h3 { margin: 8px 0 0; }

/* ───────── 图形引擎 ───────── */
.viz { display: flex; flex-direction: column; gap: 10px; }
.viz-stage { display: flex; flex-direction: column; gap: 8px; }
.viz-stage.row { flex-direction: row; align-items: center; }
.viz-stage.row > .viz-panel:first-child { flex: 0 0 38%; }
.viz-stage.row > .viz-panel { flex: 1; min-width: 0; }
.pl { position: relative; width: 100%; border-radius: 16px; background: var(--card); border: 1px solid var(--line); overflow: hidden; user-select: none; -webkit-user-select: none; }
.pl-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.pl-svg * { vector-effect: non-scaling-stroke; }
.pl-lab { position: absolute; inset: 0; pointer-events: none; }
.pl-grid { stroke: var(--grid); stroke-width: 1; fill: none; }
.pl-axis { stroke: var(--axis); stroke-width: 1.4; fill: none; }
.pl-arrow { fill: var(--axis); }
.pl-curve { stroke-linecap: round; stroke-linejoin: round; }
.pl-hit { fill: transparent; cursor: grab; touch-action: none; }
.dragging .pl-hit { cursor: grabbing; }
.pl-halo { opacity: .22; animation: halo 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes halo { 50% { opacity: .08; transform: scale(1.35); } }
.dragging .pl-halo { animation: none; opacity: .3; }
.pl-l { position: absolute; white-space: nowrap; font-size: 14px; font-weight: 600; line-height: 1.2; text-shadow: 0 0 3px var(--card), 0 0 3px var(--card), 0 0 6px var(--card); }
.pl-l small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); text-align: center; }
.pl-l.mid, .pl-l.a-mid { transform: translate(-50%, -50%); }
.pl-l.a-ne { transform: translate(6px, calc(-100% - 4px)); }
.pl-l.a-nw { transform: translate(calc(-100% - 6px), calc(-100% - 4px)); }
.pl-l.a-se { transform: translate(6px, 4px); }
.pl-l.a-sw { transform: translate(calc(-100% - 6px), 4px); }
.pl-l.a-n { transform: translate(-50%, calc(-100% - 6px)); }
.pl-l.a-s { transform: translate(-50%, 6px); }
.pl-l.a-e { transform: translate(8px, -50%); }
.pl-l.a-w { transform: translate(calc(-100% - 8px), -50%); }
.pl-l.tick { font-size: 11px; font-weight: 500; color: var(--muted); }
.pl-l.tx { transform: translate(-50%, 3px); }
.pl-l.ty { transform: translate(calc(-100% - 4px), -50%); }
.pl-l.tx.in { transform: translate(-50%, calc(-100% - 3px)); }
.pl-l.ty.in { transform: translate(5px, -50%); }
.pl-l.to { transform: translate(calc(-100% - 3px), 2px); }
.pl-l.tn { transform: translate(-50%, 0); }
.pl-l.axn { font-size: 13px; color: var(--muted); }
.pl-l.ax-x { transform: translate(calc(-100% - 2px), 2px); }
.pl-l.ax-y { transform: translate(6px, 0); }
.viz-live { text-align: center; font-size: 17px; padding: 4px 8px; overflow-x: auto; }
.viz-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 12px; border-radius: 16px; background: var(--bg2); }
.viz-sl { flex: 1 1 200px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.viz-k { flex: none; color: var(--c); font-weight: 700; }
.viz-v { flex: none; min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--c); }
.viz-sl input[type=range] { flex: 1; min-width: 0; accent-color: var(--c); height: 28px; }
.viz-play { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--pri), var(--pri2)); box-shadow: 0 6px 14px -6px var(--pri); }
.viz-play.on { background: var(--muted); }

/* 韦恩图 */
.vr { fill: var(--v4); fill-opacity: 0; transition: fill-opacity .35s ease; }
.vr.on { fill-opacity: .42; }
:root[data-theme="dark"] .vr.on { fill-opacity: .6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .vr.on { fill-opacity: .6; } }
.vu { fill: none; stroke: var(--axis); stroke-width: 1.5; }
.vc { fill: none; stroke-width: 2.5; }
.venn.pick .pl-svg { cursor: pointer; }
.pl-l.vn { font-size: 18px; text-align: center; }
.pl-l.ve { font-size: 16px; font-weight: 600; color: var(--text); }

/* 分步舞台 */
.vsteps { display: flex; flex-direction: column; gap: 12px; }
.vs-say { font-size: 16px; min-height: 1.6em; }
.vs-ask { display: flex; flex-direction: column; gap: 8px; }
.vs-ask:empty { display: none; }
.vs-q { font-weight: 600; }
.vs-fb { font-size: 14px; padding: 8px 12px; border-radius: 12px; animation: viewIn .3s ease; }
.vs-fb.ok { background: var(--ok-soft); }
.vs-fb.bad { background: var(--bad-soft); }
.vs-nav { display: flex; align-items: center; justify-content: center; gap: 10px; }
.gv-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 0 4px; }
.gv-dots i { width: 8px; height: 8px; border-radius: 99px; background: var(--line); cursor: pointer; transition: .3s; }
.gv-dots i.on { width: 22px; background: var(--uc, var(--pri)); }
.gv-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--card); font-size: 22px; font-weight: 700; box-shadow: 0 2px 8px rgba(0, 0, 0, .1); border: 1px solid var(--line); transition: transform .15s; flex: none; }
.gv-btn:active:not(:disabled) { transform: scale(.9); }
.gv-btn.pri { width: 52px; height: 52px; font-size: 28px; color: #fff; border: 0; background: linear-gradient(135deg, var(--pri), var(--pri2)); box-shadow: 0 8px 20px -6px var(--pri); }

/* ───────── 代码块 ───────── */
.code { border-radius: 16px; overflow: hidden; background: var(--code-bg); color: #dbe4ff; border: 1px solid rgba(255, 255, 255, .06); }
.code-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: rgba(255, 255, 255, .05); }
.code-lang { margin-right: auto; font-size: 12px; font-weight: 700; color: #f7d354; letter-spacing: .3px; }
.code-b { padding: 5px 10px; border-radius: 8px; font-size: 13px; color: #c5d0f0; background: rgba(255, 255, 255, .07); }
.code-b.run { color: #0b1a12; background: #4ad485; font-weight: 700; }
.code-pre, .code-edit { margin: 0; padding: 12px 14px; font: 13.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-x: auto; tab-size: 2; }
.code-edit { display: block; width: 100%; border: 0; outline: 0; resize: none; background: rgba(255, 255, 255, .03); color: #fff; white-space: pre; }
.code-out { padding: 10px 14px; border-top: 1px solid rgba(255, 255, 255, .08); font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; color: #b9f6ca; background: rgba(0, 0, 0, .25); max-height: 260px; overflow: auto; white-space: pre-wrap; }
.code-err { color: #ff8a8a; }
.code-wait { color: #8d99b8; }
.code-ms { display: block; color: #6c7894; font-size: 11px; margin-top: 4px; }
.c-kw { font-style: normal; color: #c792ea; }
.c-str { font-style: normal; color: #c3e88d; }
.c-num { font-style: normal; color: #f78c6c; }
.c-cm { color: #6c7894; }
.c-fn { font-style: normal; color: #82aaff; }
.c-obj { font-style: normal; color: #ffcb6b; }

/* ───────── 复习 ───────── */
.fsheet { display: grid; gap: 10px; }
@media (min-width: 700px) { .fsheet { grid-template-columns: 1fr 1fr; } }
.fitem { padding: 14px; text-decoration: none; display: flex; flex-direction: column; gap: 6px; overflow-x: auto; }
.fitem small { color: var(--muted); }

/* ───────── 我的 ───────── */
.stats4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 640px) { .stats4 { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 16px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); border: 1px solid var(--line); display: flex; flex-direction: column; }
.stat b { font-size: 30px; line-height: 1.1; background: linear-gradient(135deg, var(--pri), var(--pri2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { color: var(--muted); font-size: 13px; }
.bars { display: flex; gap: 10px; align-items: flex-end; height: 150px; padding-top: 18px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; position: relative; }
.bar i { display: block; width: 100%; max-width: 30px; min-height: 3px; border-radius: 8px; background: linear-gradient(180deg, var(--pri), var(--pri2)); transition: height .8s ease; }
.bar b { position: absolute; top: -2px; font-size: 12px; color: var(--muted); }
.bar small { font-size: 11px; color: var(--muted); }
.setting { margin-top: 16px; }
.setting h3 { margin-top: 18px; }
.setting h3:first-child { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
