/* 数学自习室 v1.0.0 — 通勤数学复习 · 深夜自习室主题 */
:root, [data-theme="dark"] {
  --bg: #0e1420;
  --panel: #161e2e;
  --panel2: #1d2739;
  --ink: #ece7da;
  --sub: #96a0b5;
  --amber: #ffb454;
  --amber-ink: #2a1a04;
  --amber-soft: rgba(255, 180, 84, .13);
  --line: #243048;
  --green: #43d19e;
  --green-soft: rgba(67, 209, 158, .13);
  --red: #ff6b6b;
  --red-soft: rgba(255, 107, 107, .13);
  --navbg: rgba(14, 20, 32, .88);
}
[data-theme="light"] {
  --bg: #f4efe4;
  --panel: #fffdf6;
  --panel2: #f0e9d8;
  --ink: #2b2822;
  --sub: #837d6f;
  --amber: #b25e00;
  --amber-ink: #fffdf6;
  --amber-soft: rgba(178, 94, 0, .10);
  --line: #e4dbc8;
  --green: #0f9d63;
  --green-soft: rgba(15, 157, 99, .12);
  --red: #d64545;
  --red-soft: rgba(214, 69, 69, .10);
  --navbg: rgba(244, 239, 228, .92);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(72px + env(safe-area-inset-bottom)); }
a { color: var(--amber); }
button { font-family: inherit; }

/* ---------- 首页头部 ---------- */
.hero { padding: 26px 2px 14px; background: radial-gradient(560px 180px at 18% -10%, var(--amber-soft), transparent 72%); }
.hero .brandrow { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 13px;
  background: var(--amber); color: var(--amber-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; font-weight: 800; flex: 0 0 42px;
}
.hero h1 { font-size: 22px; margin: 0; letter-spacing: 1px; }
.hero .sub { font-size: 12.5px; color: var(--sub); margin-top: 2px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip {
  font-size: 12px; padding: 4px 11px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); color: var(--sub);
}
.chip b { color: var(--amber); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- 卡片 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 12px 0; }
.card h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--sub); font-size: 13.5px; line-height: 1.6; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel2);
  color: var(--ink); border-radius: 12px; padding: 10px 14px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .08s ease;
}
.btn.primary { background: var(--amber); border-color: transparent; color: var(--amber-ink); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; padding: 12px; font-size: 15px; }
.btn:active { transform: scale(.985); }
.btn.danger { color: var(--red); }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row .btn { flex: 1; }

/* ---------- 章节 ---------- */
.chap-head { display: flex; align-items: center; gap: 11px; }
.chap-idx {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  background: var(--panel2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--amber); font-size: 15px;
}
.chap-name { font-weight: 700; font-size: 16px; line-height: 1.3; }
.chap-tag { font-size: 11px; color: var(--sub); margin-top: 2px; }
.chap-head .stars { margin-left: auto; color: var(--amber); font-size: 13px; letter-spacing: 2px; white-space: nowrap; }
.chap-blurb { font-size: 13px; color: var(--sub); margin-top: 8px; }
.chap-meta { font-size: 12px; color: var(--sub); margin-top: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- 顶栏 / 进度 ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: 14px 0 4px; }
.back {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.top h2 { font-size: 16.5px; margin: 0; font-weight: 700; }
.top .cnt { margin-left: auto; color: var(--sub); font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.progress { height: 4px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin: 8px 0 14px; }
.progress i { display: block; height: 100%; width: 0; background: var(--amber); border-radius: 99px; transition: width .25s ease; }

/* ---------- 题目 ---------- */
.qchips { display: flex; gap: 6px; flex-wrap: wrap; }
.qchip {
  font-size: 11px; color: var(--sub); background: var(--panel2);
  border: 1px solid var(--line); padding: 2px 9px; border-radius: 99px; display: inline-block;
}
.qchip.adv { color: var(--amber); }
.qtext { font-size: 19px; line-height: 1.62; font-weight: 650; margin: 12px 0 16px; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; text-align: left; width: 100%;
  padding: 13px 14px; border-radius: 14px; background: var(--panel);
  border: 1.5px solid var(--line); color: var(--ink);
  font-size: 16px; line-height: 1.5; cursor: pointer;
  transition: transform .08s ease;
}
.opt:active { transform: scale(.99); }
.opt .key {
  flex: 0 0 26px; height: 26px; border-radius: 8px; margin-top: 1px;
  background: var(--panel2); color: var(--sub);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.opt.ok { border-color: var(--green); background: var(--green-soft); }
.opt.ok .key { background: var(--green); color: #fff; }
.opt.bad { border-color: var(--red); background: var(--red-soft); }
.opt.bad .key { background: var(--red); color: #fff; }
.opt.dim { opacity: .5; }
.opt.shake { animation: shake .3s ease; }

.feedback {
  margin-top: 14px; border-left: 3px solid var(--amber);
  background: var(--panel2); border-radius: 12px; padding: 14px;
  animation: rise .25s ease;
}
.feedback.ok { border-color: var(--green); }
.feedback.bad { border-color: var(--red); }
.fb-head { font-weight: 700; margin-bottom: 6px; font-size: 14.5px; }
.fb-head.ok { color: var(--green); }
.fb-head.bad { color: var(--red); }
.fb-expl { font-size: 14.5px; line-height: 1.68; }
.hist {
  margin-top: 10px; font-size: 12.5px; color: var(--sub); line-height: 1.65;
  border-top: 1px dashed var(--line); padding-top: 8px;
}
#view .next-wrap { margin-top: 14px; }

/* ---------- 结算 ---------- */
.result { text-align: center; padding: 28px 0 8px; animation: rise .3s ease; }
.result .big { font-size: 46px; font-weight: 800; font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--amber); line-height: 1.1; }
.result .lbl { color: var(--sub); font-size: 13.5px; margin-top: 6px; }

/* ---------- 考点 / 史话 ---------- */
.pts { margin: 10px 0 0; padding: 0; list-style: none; }
.pts li { position: relative; padding: 9px 0 9px 22px; font-size: 14.5px; line-height: 1.66; border-bottom: 1px dashed var(--line); }
.pts li:last-child { border-bottom: 0; }
.pts li::before {
  content: ''; position: absolute; left: 4px; top: 17px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--amber);
}
.story h2 { font-size: 20px; margin: 10px 0 12px; line-height: 1.4; }
.story .body { font-size: 16px; line-height: 1.95; text-align: justify; }
.story .src { font-size: 12px; color: var(--sub); margin-top: 16px; }

.empty { text-align: center; padding: 40px 18px; color: var(--sub); font-size: 14px; line-height: 1.9; }

/* ---------- 每日典故 ---------- */
.lore-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mini-btn {
  font-size: 12px; color: var(--amber); background: none;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; cursor: pointer; white-space: nowrap;
}
.lore-txt { font-size: 14px; line-height: 1.78; margin-top: 8px; }

/* ---------- 我的 ---------- */
.title-name { font-size: 23px; font-weight: 800; color: var(--amber); }
.bar { height: 6px; background: var(--panel2); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--amber); border-radius: 99px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; padding: 10px 0; background: transparent; border: 0; color: var(--sub); font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--amber); color: var(--amber-ink); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { font-size: 21px; display: block; font-family: ui-monospace, Menlo, Consolas, monospace; }
.stat span { font-size: 12px; color: var(--sub); }
.about p { font-size: 12.5px; color: var(--sub); line-height: 1.7; margin: 6px 0; }

/* ---------- 底部导航 ---------- */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 560px; margin: 0 auto; display: flex;
  background: var(--navbg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; background: none; border: 0; color: var(--sub);
  padding: 9px 0 7px; font-size: 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative;
}
.nav-btn svg { width: 21px; height: 21px; }
.nav-btn.on { color: var(--amber); }
.nav-badge {
  position: absolute; top: 3px; right: calc(50% - 20px);
  min-width: 16px; height: 16px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 10px; line-height: 16px;
  padding: 0 4px; font-weight: 700;
}

/* ---------- 动画 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

@media (min-width: 600px) {
  .hero { padding-top: 38px; }
}
