/* ============================================================
   矿业权价值评估 · 网页学习资料 公共样式
   全课程统一配色 / 字号 / 卡片 / 表格 / 公式 / 闪卡 / 测验
   支持浅色（默认）与深色主题，适配电脑与手机
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --bg-card: #ffffff;
  --bg-code: #f0f3fa;
  --text: #1f2733;
  --text-soft: #54607a;
  --text-faint: #8a96ad;
  --border: #e2e8f4;
  --border-strong: #c9d4ea;
  --accent: #2f6df0;
  --accent-soft: #e9f0fe;
  --accent-deep: #1c4fb0;
  --green: #1f9d6b;
  --green-soft: #e4f6ee;
  --red: #e0455a;
  --red-soft: #fdeaed;
  --amber: #d98a1a;
  --amber-soft: #fdf2df;
  --purple: #7b54d6;
  --purple-soft: #efeafc;
  --shadow: 0 2px 10px rgba(31,39,51,.06);
  --shadow-strong: 0 6px 24px rgba(31,39,51,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 920px;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --font: "PingFang SC","Microsoft YaHei","Hiragino Sans GB","Source Han Sans SC",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --mono: "SF Mono","JetBrains Mono","Fira Code",Consolas,"Courier New",monospace;
}
[data-theme="dark"] {
  --bg: #14181f;
  --bg-soft: #1b212b;
  --bg-card: #1e2530;
  --bg-code: #161b23;
  --text: #e6ebf3;
  --text-soft: #aab4c6;
  --text-faint: #7c879a;
  --border: #2c3543;
  --border-strong: #3a4658;
  --accent: #5b8dff;
  --accent-soft: #1f2c47;
  --accent-deep: #8fb0ff;
  --green: #41c98a;
  --green-soft: #16352a;
  --red: #ff6b80;
  --red-soft: #3a1f25;
  --amber: #f0b24a;
  --amber-soft: #3a2e16;
  --purple: #a98bf0;
  --purple-soft: #2c2342;
  --shadow: 0 2px 10px rgba(0,0,0,.3);
  --shadow-strong: 0 6px 24px rgba(0,0,0,.45);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { line-height: 1.35; color: var(--text); margin: 0 0 .5em; }
h2 { font-size: 1.45rem; border-left: 5px solid var(--accent); padding-left: 12px; margin-top: 1.8em; }
h3 { font-size: 1.15rem; color: var(--accent-deep); margin-top: 1.4em; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: .92em; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 700; color: var(--accent-deep); white-space: nowrap; }
.topbar .chap-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .nav-btns { display: flex; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-card);
  color: var(--text); font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-deep); color:#fff; }
.icon-btn { width: 38px; height: 38px; justify-content: center; padding: 0; font-size: 18px; }

/* ---------- 布局 ---------- */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  position: sticky; top: var(--topbar-h);
  width: var(--sidebar-w); flex-shrink: 0;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
}
.sidebar h4 { font-size: 12px; color: var(--text-faint); letter-spacing: .08em; margin: 14px 8px 6px; text-transform: uppercase; }
.sidebar a {
  display: block; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-size: 14px; margin-bottom: 2px;
}
.sidebar a:hover { background: var(--accent-soft); color: var(--accent-deep); text-decoration: none; }
.sidebar a.active { background: var(--accent); color: #fff; font-weight: 600; }
.main {
  flex: 1; min-width: 0;
  padding: 24px 28px 80px;
  max-width: calc(100% - var(--sidebar-w));
}
.wrap { max-width: var(--maxw); margin: 0 auto; }

/* 进度条 */
.progress-row { display:flex; align-items:center; gap:12px; margin: 4px 0 18px; }
.progress-bar { flex:1; height: 10px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg,var(--accent),var(--green)); transition: width .4s; }
.progress-label { font-size: 13px; color: var(--text-soft); white-space: nowrap; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.card.learned { border-color: var(--green); }
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-head .kp-title { font-weight: 700; font-size: 1.05rem; flex: 1; }
.kp-master { display: inline-flex; align-items:center; gap:6px; font-size:13px; color: var(--text-soft); cursor:pointer; user-select:none; }
.kp-master input { width:16px; height:16px; }
.one-liner { background: var(--accent-soft); color: var(--accent-deep); padding: 8px 12px; border-radius: var(--radius-sm); font-weight:600; margin: 10px 0; font-size: .96rem; }
.core ul { margin: .4em 0; padding-left: 1.2em; }
.core li { margin: .35em 0; }
.core li::marker { color: var(--accent); }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 99px; font-weight: 600; }
.tag.mem { background: var(--green-soft); color: var(--green); }
.tag.und { background: var(--amber-soft); color: var(--amber); }
.tag.cal { background: var(--accent-soft); color: var(--accent-deep); }
.tag.law { background: var(--purple-soft); color: var(--purple); }
.wrong-point { margin-top: 10px; padding: 10px 12px; background: var(--red-soft); border-left: 4px solid var(--red); border-radius: var(--radius-sm); font-size: .94rem; }
.wrong-point b { color: var(--red); }
.memory-tip { margin-top: 10px; padding: 10px 12px; background: var(--amber-soft); border-left: 4px solid var(--amber); border-radius: var(--radius-sm); font-size: .94rem; }
.memory-tip b { color: var(--amber); }
.ref { font-size: 12px; color: var(--text-faint); margin-top: 8px; }

/* 术语与数字高亮 */
.term { color: var(--accent-deep); font-weight: 600; border-bottom: 1px dotted var(--accent); cursor: help; }
.num { color: var(--red); font-weight: 700; }
.num.g { color: var(--green); font-weight: 700; }

/* ---------- 公式 ---------- */
.formula-block { background: var(--bg-code); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 14px 0; }
.formula { font-family: var(--mono); font-size: 1.02rem; color: var(--text); background: var(--bg-card); padding: 12px 14px; border-radius: var(--radius-sm); border: 1px dashed var(--border-strong); margin: 8px 0; overflow-x: auto; }
.formula .v { color: var(--accent-deep); font-weight: 700; }
.params { font-size: .92rem; }
.params li { margin: .3em 0; }
.params .v { color: var(--accent-deep); font-weight: 700; font-family: var(--mono); }
.example { margin-top: 10px; padding: 12px 14px; background: var(--green-soft); border-radius: var(--radius-sm); font-size: .94rem; }
.example b { color: var(--green); }
.trap { margin-top: 10px; padding: 10px 14px; background: var(--red-soft); border-radius: var(--radius-sm); font-size: .94rem; }
.trap b { color: var(--red); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 14px 0; }
table.compare { width: 100%; border-collapse: collapse; font-size: .92rem; background: var(--bg-card); box-shadow: var(--shadow); }
table.compare th, table.compare td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; vertical-align: top; }
table.compare thead th { background: var(--accent); color: #fff; font-weight: 600; }
table.compare tbody tr:nth-child(even) { background: var(--bg-soft); }
table.compare td.k { font-weight: 600; color: var(--accent-deep); background: var(--accent-soft); white-space: nowrap; }

/* ---------- 速记清单（可折叠遮挡） ---------- */
.quick-list { margin: 14px 0; }
.quick-item { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; overflow: hidden; }
.quick-q { padding: 10px 14px; background: var(--bg-soft); cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.quick-q:hover { background: var(--accent-soft); }
.quick-a { padding: 0 14px; max-height: 0; overflow: hidden; transition: max-height .3s, padding .3s; }
.quick-item.open .quick-a { padding: 12px 14px; max-height: 600px; }
.quick-q .arrow { transition: transform .3s; color: var(--text-faint); }
.quick-item.open .arrow { transform: rotate(90deg); }

/* ---------- 测验 ---------- */
.quiz { margin: 16px 0; }
.q-block { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 14px 0; box-shadow: var(--shadow); }
.q-type { font-size: 12px; color: #fff; background: var(--purple); padding: 2px 9px; border-radius: 99px; margin-right: 8px; }
.q-stem { font-weight: 600; margin: 8px 0 12px; }
.q-options { display: flex; flex-direction: column; gap: 8px; }
.q-opt { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; transition: .15s; }
.q-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.q-opt .mark { font-weight: 700; color: var(--text-faint); }
.q-opt.correct { background: var(--green-soft); border-color: var(--green); }
.q-opt.correct .mark { color: var(--green); }
.q-opt.wrong { background: var(--red-soft); border-color: var(--red); }
.q-opt.wrong .mark { color: var(--red); }
.q-opt.locked { cursor: default; }
.q-judge { margin-top: 10px; font-weight: 700; }
.q-judge.ok { color: var(--green); }
.q-judge.no { color: var(--red); }
.q-answer { margin-top: 10px; padding: 10px 12px; background: var(--bg-code); border-radius: var(--radius-sm); font-size: .94rem; display: none; }
.q-answer.show { display: block; }
.q-answer .expl { color: var(--text-soft); margin-top: 6px; font-size: .9rem; }
.q-answer .expl b { color: var(--accent-deep); }
.q-toggle { margin-top: 10px; font-size: 13px; }
.fill-blank { border: none; border-bottom: 1px solid var(--border-strong); background: transparent; color: var(--text); font-size: 1rem; width: 90px; text-align: center; font-family: var(--mono); }
.judge-btns { display: flex; gap: 8px; }
.judge-btns .btn { flex: 1; justify-content: center; }

/* ---------- 闪卡 ---------- */
.flash-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.flash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 14px; margin-top: 10px; }
.flashcard { perspective: 1000px; height: 160px; cursor: pointer; }
.flashcard .inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flashcard.flip .inner { transform: rotateY(180deg); }
.flashcard .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.flashcard .front { background: var(--bg-card); justify-content: center; }
.flashcard .back { background: var(--accent-soft); transform: rotateY(180deg); justify-content: center; color: var(--accent-deep); }
.flashcard .fc-tag { font-size: 11px; color: var(--text-faint); margin-bottom: 6px; }
.flashcard .fc-text { font-size: .98rem; }
.flashcard .fc-foot { margin-top: auto; display: flex; gap: 6px; }
.flashcard .fc-foot .btn { font-size: 12px; padding: 4px 8px; }
.flashcard.mastered .front { border-color: var(--green); }
.flashcard.mastered .back { background: var(--green-soft); color: var(--green); }

/* ---------- 一页纸总结 ---------- */
.onepager { background: var(--bg-card); border: 2px solid var(--accent); border-radius: var(--radius); padding: 20px 24px; margin: 16px 0; }
.onepager h3 { margin-top: .6em; }
.onepager ul { margin: .3em 0; padding-left: 1.2em; }
.print-only { display: none; }

/* ---------- 思维导图 / 速览 ---------- */
.mindmap { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 14px 0; }
.mindmap ul { list-style: none; padding-left: 18px; margin: .3em 0; position: relative; }
.mindmap ul::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: var(--border-strong); }
.mindmap li { position: relative; padding: 3px 0; }
.mindmap li::before { content: ""; position: absolute; left: -14px; top: 14px; width: 12px; height: 2px; background: var(--border-strong); }
.mindmap .node { font-weight: 600; }
.mindmap .lv1 > .node { color: var(--accent-deep); }
.level-badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-weight: 700; font-size: .9rem; }
.level-3 { background: var(--red-soft); color: var(--red); }
.level-2 { background: var(--amber-soft); color: var(--amber); }
.level-1 { background: var(--green-soft); color: var(--green); }

/* ---------- 搜索高亮 ---------- */
mark.hl { background: var(--amber); color: #1a1a1a; padding: 0 2px; border-radius: 3px; }
mark.hl.cur { background: var(--red); color: #fff; }

.search-box { display: flex; gap: 8px; margin: 12px 0; }
.search-box input { flex: 1; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text); font-size: 15px; }
.search-box .btn { flex-shrink: 0; }
.search-stat { font-size: 13px; color: var(--text-soft); }

/* ---------- 首页 / 整合页 ---------- */
.index-hero { background: linear-gradient(135deg,var(--accent),var(--accent-deep)); color: #fff; border-radius: var(--radius); padding: 28px 26px; margin: 18px 0; box-shadow: var(--shadow-strong); }
.index-hero h1 { color: #fff; margin: 0 0 6px; }
.index-hero p { color: rgba(255,255,255,.9); margin: 0; }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: 14px; margin: 18px 0; }
.ch-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); transition: .15s; display: block; color: var(--text); }
.ch-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-strong); }
.ch-card .ch-no { font-size: 12px; color: var(--text-faint); }
.ch-card .ch-name { font-weight: 700; font-size: 1.05rem; margin: 4px 0 8px; }
.ch-card .ch-meta { font-size: 12px; color: var(--text-soft); }
.ch-card .ch-prog { margin-top: 10px; height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.ch-card .ch-prog > i { display: block; height: 100%; background: linear-gradient(90deg,var(--accent),var(--green)); width: 0; }

/* ---------- 错题本 ---------- */
.wrong-item { background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--red); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; box-shadow: var(--shadow); }
.wrong-item .w-ch { font-size: 12px; color: var(--red); font-weight: 700; }
.wrong-item .w-q { font-weight: 600; margin: 6px 0; }
.wrong-item .w-a { font-size: .92rem; color: var(--text-soft); }
.wrong-item .w-a b { color: var(--green); }
.empty-tip { padding: 30px; text-align: center; color: var(--text-faint); background: var(--bg-soft); border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main { max-width: 100%; padding: 18px 14px 70px; }
  .topbar .chap-title { font-size: 14px; }
  .topbar .brand { display: none; }
  h2 { font-size: 1.25rem; }
  .flash-grid { grid-template-columns: 1fr; }
  .btn { padding: 6px 9px; font-size: 13px; }
}
/* 移动端侧栏折叠按钮 */
.menu-toggle { display: none; }
@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .sidebar.mobile-open { display: block; position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 78%; max-width: 300px; z-index: 60; box-shadow: var(--shadow-strong); }
}

/* ---------- 打印 ---------- */
@media print {
  .topbar, .sidebar, .flash-controls, .quiz .q-options, .search-box, .progress-row, .nav-btns, .menu-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .main { max-width: 100%; padding: 0; }
  .card, .onepager, .q-block, .formula-block { box-shadow: none; break-inside: avoid; }
  .quick-a { max-height: none !important; padding: 12px 14px !important; }
  .print-only { display: block; }
  a { color: #000; }
}
