:root{
  --bg:#f4f5f9; --card:#ffffff; --text:#1c1e26; --sub:#6b7280; --line:#e5e7ef;
  --pri:#176b67; --pri-soft:#e0f0ef; --ok:#1aa367; --ok-soft:#e2f6ec;
  --bad:#e04747; --bad-soft:#fdeaea; --warn:#d97706; --warn-soft:#fdf1e0;
  --shadow:0 2px 10px rgba(20,30,60,.06);
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#14161d; --card:#1e212b; --text:#eef0f6; --sub:#9aa1b2; --line:#2c3040;
    --pri:#4fb3ad; --pri-soft:#1e3332; --ok:#3ecf8e; --ok-soft:#17352a;
    --bad:#ff7070; --bad-soft:#3d2222; --warn:#f5a743; --warn-soft:#3a2c17;
    --shadow:0 2px 10px rgba(0,0,0,.3);
  }
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0; padding:0; background:var(--bg); color:var(--text);}
body{
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Helvetica Neue",sans-serif;
  font-size:16px; line-height:1.55;
}
#app{max-width:560px; margin:0 auto; min-height:100vh; min-height:100dvh; display:flex; flex-direction:column;}
header{
  position:sticky; top:0; z-index:10;
  padding:calc(env(safe-area-inset-top,0px) + 10px) 14px 10px;
  background:var(--card); border-bottom:1px solid var(--line);
  display:flex; align-items:center; gap:10px; min-height:56px;
}
#h-back{flex:0 0 auto; width:36px; height:36px; border:none; border-radius:10px;
  background:var(--pri-soft); color:var(--pri); font-size:18px; cursor:pointer;}
#h-title{flex:1; font-size:17px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
#h-extra{flex:0 0 auto; font-size:13px; color:var(--sub);}
main{flex:1; padding:14px 14px calc(env(safe-area-inset-bottom,0px) + 20px);}
.card{background:var(--card); border-radius:14px; padding:16px; margin-bottom:12px; box-shadow:var(--shadow);}
.sub{color:var(--sub); font-size:13px;}
.btn{display:block; width:100%; border:none; border-radius:12px; padding:13px;
  background:var(--pri); color:#fff; font-size:16px; font-weight:600; cursor:pointer; text-align:center;}
.btn.ghost{background:var(--pri-soft); color:var(--pri);}
.btn.small{width:auto; padding:8px 14px; font-size:14px; display:inline-block;}
.btnrow{display:flex; gap:8px; flex-wrap:wrap;}
.btnrow .btn{flex:1; width:auto;}
.bar{height:8px; border-radius:4px; background:var(--line); overflow:hidden;}
.bar>i{display:block; height:100%; border-radius:4px; background:var(--pri); transition:width .3s;}
.bar>i.ok{background:var(--ok);}
.big-num{font-size:34px; font-weight:700; color:var(--pri);}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:10px;}
/* 登录 */
.login-wrap{padding-top:18vh; text-align:center;}
.login-wrap input{width:100%; max-width:280px; font-size:18px; padding:13px; border:1px solid var(--line);
  border-radius:12px; background:var(--card); color:var(--text); text-align:center; letter-spacing:2px; margin:14px 0;}
/* 日历 */
.cal-grid{display:grid; grid-template-columns:repeat(7,1fr); gap:5px;}
.cal-cell{aspect-ratio:1; border-radius:8px; background:var(--card); display:flex; flex-direction:column;
  align-items:center; justify-content:center; font-size:12px; cursor:pointer; border:1px solid var(--line);}
.cal-cell .d{font-weight:600;}
.cal-cell.full{background:var(--ok-soft); border-color:var(--ok);}
.cal-cell.part{background:var(--warn-soft); border-color:var(--warn);}
.cal-cell.today{outline:2px solid var(--pri);}
.cal-cell.future{opacity:.45; cursor:default;}
.cal-cell.exam{background:var(--bad-soft); border-color:var(--bad); font-weight:700;}
.cal-head{font-size:11px; color:var(--sub); text-align:center; padding:4px 0;}
/* 章节 */
.ch-item{display:flex; align-items:center; gap:10px; padding:13px 0; border-bottom:1px solid var(--line); cursor:pointer;}
.ch-item:last-child{border-bottom:none;}
.ch-badge{flex:0 0 44px; height:44px; border-radius:12px; background:var(--pri-soft); color:var(--pri);
  display:flex; align-items:center; justify-content:center; font-weight:700;}
.ch-info{flex:1; min-width:0;}
.tabs{display:flex; gap:8px; margin-bottom:12px;}
.tabs button{flex:1; border:1px solid var(--line); background:var(--card); color:var(--sub);
  border-radius:10px; padding:9px; font-size:15px; cursor:pointer;}
.tabs button.on{background:var(--pri); color:#fff; border-color:var(--pri); font-weight:600;}
/* 答题 */
.q-badge{display:inline-block; font-size:12px; padding:2px 8px; border-radius:6px; background:var(--pri-soft); color:var(--pri); margin-right:6px;}
.q-stem{font-size:17px; font-weight:600; margin:10px 0 16px;}
.opt{display:flex; gap:10px; align-items:flex-start; padding:13px; border:1.5px solid var(--line);
  border-radius:12px; margin-bottom:10px; cursor:pointer; background:var(--card);}
.opt .k{flex:0 0 26px; height:26px; border-radius:50%; border:1.5px solid var(--line);
  display:flex; align-items:center; justify-content:center; font-size:13px; color:var(--sub);}
.opt.sel{border-color:var(--pri); background:var(--pri-soft);}
.opt.sel .k{background:var(--pri); color:#fff; border-color:var(--pri);}
.opt.right{border-color:var(--ok); background:var(--ok-soft);}
.opt.right .k{background:var(--ok); color:#fff; border-color:var(--ok);}
.opt.wrong{border-color:var(--bad); background:var(--bad-soft);}
.opt.wrong .k{background:var(--bad); color:#fff; border-color:var(--bad);}
.verdict{border-radius:12px; padding:12px 14px; margin:12px 0; font-weight:600;}
.verdict.ok{background:var(--ok-soft); color:var(--ok);}
.verdict.no{background:var(--bad-soft); color:var(--bad);}
.analysis{background:var(--bg); border-radius:12px; padding:13px; font-size:14px; margin:10px 0;}
.ref-box{background:var(--bg); border-radius:12px; padding:13px; margin:10px 0; font-size:14px;}
.ref-box h4{margin:0 0 8px; font-size:14px; color:var(--pri);}
.video-item{padding:8px 0; border-bottom:1px dashed var(--line); font-size:14px;}
.video-item:last-child{border-bottom:none;}
.q-foot{display:flex; gap:8px; margin-top:14px;}
.icon-btn{flex:0 0 auto; border:1px solid var(--line); background:var(--card); border-radius:10px;
  padding:10px 14px; font-size:15px; cursor:pointer; color:var(--text);}
.icon-btn.on{background:var(--warn-soft); border-color:var(--warn); color:var(--warn);}
/* 笔记（借鉴 Typora / GitHub 主题排版） */
.note-html{font-size:16px; line-height:1.9;}
.note-html h1,.note-html h2{font-size:18px; font-weight:700; margin:28px 0 14px; padding-bottom:8px; border-bottom:1px solid var(--line);}
.note-html h3,.note-html h4{font-size:16.5px; font-weight:700; margin:22px 0 10px;}
.note-html p{margin:17px 0;}
.note-html strong{color:var(--pri); font-weight:700;}
.note-html ul,.note-html ol{padding-left:1.6em; margin:16px 0;}
.note-html li{margin:11px 0;}
.note-html li>p{margin:6px 0;}
.note-html li>ul,.note-html li>ol{margin:6px 0;}
.note-html blockquote{margin:16px 0; padding:10px 16px; border-left:3px solid var(--pri);
  background:var(--bg); border-radius:0 10px 10px 0; color:var(--sub);}
.note-html blockquote>p{margin:6px 0;}
.note-html code{background:var(--bg); border-radius:5px; padding:2px 6px; font-size:14px;}
.note-html hr{border:none; border-top:1px solid var(--line); margin:24px 0;}
.note-html table{border-collapse:collapse; width:100%; font-size:14px; margin:18px 0;}
.note-html th,.note-html td{border:1px solid var(--line); padding:9px 10px; text-align:left; line-height:1.6;}
.note-html th{background:var(--bg); font-weight:600;}
.sec-item{padding:13px 0; border-bottom:1px solid var(--line); cursor:pointer; font-weight:600;}
.sec-item:last-child{border-bottom:none;}
.toast{position:fixed; left:50%; bottom:calc(env(safe-area-inset-bottom,0px) + 30px); transform:translateX(-50%);
  background:rgba(20,22,30,.88); color:#fff; padding:9px 18px; border-radius:20px; font-size:14px; z-index:99;}
.empty{text-align:center; color:var(--sub); padding:40px 0;}
.dot{display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:3px;}
.dot.g{background:var(--ok);} .dot.y{background:var(--warn);}
nav{position:sticky; bottom:0; display:flex; background:var(--card); border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom,0px);}
nav button{flex:1; border:none; background:none; padding:9px 0 7px; font-size:11px; color:var(--sub); cursor:pointer;}
nav button .i{font-size:20px; display:block;}
nav button.on{color:var(--pri); font-weight:600;}
/* 笔记阅读器 */
.note-bar{position:fixed; left:0; right:0; bottom:0; z-index:20; display:flex; gap:8px;
  padding:10px 14px calc(env(safe-area-inset-bottom,0px) + 10px);
  background:var(--card); border-top:1px solid var(--line); max-width:560px; margin:0 auto;}
.note-bar button{flex:1; border:1px solid var(--line); background:var(--bg); color:var(--text);
  border-radius:10px; padding:11px 6px; font-size:14px; cursor:pointer;}
.note-bar #nb-toc{flex:1.2; background:var(--pri-soft); color:var(--pri); border-color:transparent; font-weight:600;}
.note-drawer{position:fixed; left:0; right:0; bottom:70px; z-index:21; padding:0 14px; max-width:560px; margin:0 auto;}
.drawer-card{background:var(--card); border-radius:14px; padding:6px 16px; max-height:52vh; overflow:auto;
  border:1px solid var(--line); box-shadow:0 -8px 30px rgba(15,23,60,.22);}
.note-drawer .sec-item.on{color:var(--pri);}
.note-overlay{position:fixed; inset:0; z-index:20; background:rgba(10,12,20,.35);}
/* 刷题模式切换 */
.mode-chips{display:flex; gap:8px; margin-bottom:10px;}
.mode-chips button{flex:1; border:1px solid var(--line); background:var(--card); color:var(--sub);
  border-radius:10px; padding:8px; font-size:13px; cursor:pointer;}
.mode-chips button.on{background:var(--pri-soft); color:var(--pri); border-color:var(--pri); font-weight:600;}
/* 高频考点 */
.kp-chip{display:inline-block; background:var(--pri-soft); color:var(--pri); border-radius:8px;
  padding:5px 10px; margin:3px 4px 3px 0; font-size:13px;}
.excerpt{background:var(--card); border-left:3px solid var(--pri); border-radius:8px;
  padding:10px 12px; margin:8px 0; font-size:14px;}
.note-html .hl{background:var(--warn-soft); border-radius:6px; padding:2px 4px; margin:-2px -4px;
  box-shadow:0 0 0 2px var(--warn-soft); transition:background 1s;}
.cal-month{font-weight:700; margin:14px 0 6px;}
