/* 408 计算机网络做题本 —— 单页应用样式 */
:root {
  --primary: #7c3aed;
  --primary-deep: #6d28d9;
  --primary-light: #f5f3ff;
  --bg: #f6f4fc;
  --card: #ffffff;
  --text: #2a2438;
  --text-light: #6f6a80;
  --text-dim: #9a94ab;
  --border: #e6e1f2;
  --green: #059669;
  --green-light: #ecfdf5;
  --red: #dc2626;
  --red-light: #fef2f2;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(60, 40, 100, .06), 0 4px 14px rgba(60, 40, 100, .05);
  --sidebar-w: 272px;
  --topbar-h: 58px;
}
html[data-theme="dark"] {
  --primary: #c4b5fd;
  --primary-deep: #a78bfa;
  --primary-light: #3b2a63;
  --bg: #161226;
  --card: #241d3d;
  --text: #ece7f8;
  --text-light: #a89ec4;
  --text-dim: #7e7499;
  --border: #3d3459;
  --green: #34d399;
  --green-light: #064e3b66;
  --red: #f87171;
  --red-light: #7f1d1d55;
  --amber-light: #78350f55;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.8;
  font-size: 15.5px;
}

/* ========== 顶栏 ========== */
.topbar {
  position: sticky; top: 0; z-index: 200;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: linear-gradient(90deg, #5b21b6 0%, #7c3aed 45%, #a78bfa 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(124, 58, 237, .3);
}
.topbar .brand {
  color: #fff; text-decoration: none; font-weight: 800; font-size: 1.06rem;
  letter-spacing: .4px; white-space: nowrap;
}
.topbar .tagline {
  font-size: .78rem; padding: 2px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .18); white-space: nowrap;
}
.topbar .spacer { flex: 1; }
.burger {
  display: none; width: 34px; height: 34px; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: 17px; cursor: pointer;
}
.searchbox { position: relative; display: flex; align-items: center; }
.searchbox .s-ico { position: absolute; left: 11px; font-size: .8rem; opacity: .8; pointer-events: none; }
.searchbox input {
  width: min(300px, 30vw); height: 34px; padding: 0 12px 0 30px;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: .85rem; outline: none;
  transition: background .15s, border-color .15s;
}
.searchbox input::placeholder { color: rgba(255, 255, 255, .7); }
.searchbox input:focus { background: rgba(255, 255, 255, .26); border-color: #fff; }
.tb-btn {
  height: 32px; padding: 0 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .14); color: #fff;
  font-size: .82rem; font-family: inherit; white-space: nowrap;
  transition: background .15s;
}
.tb-btn:hover { background: rgba(255, 255, 255, .28); }
.tb-btn.on { background: #fff; color: var(--primary-deep); border-color: #fff; font-weight: 700; }

/* ========== 布局 ========== */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  position: sticky; top: var(--topbar-h);
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 14px 12px 24px;
  background: linear-gradient(180deg, #32265e 0%, #281d4e 100%);
  color: #ddd3f2;
}
.side-head {
  font-size: .74rem; letter-spacing: .12em; text-transform: uppercase;
  color: #a99ccf; padding: 4px 8px 10px;
}
.chapters { display: flex; flex-direction: column; gap: 3px; }
.ch-item {
  width: 100%; text-align: left; cursor: pointer; font-family: inherit;
  background: transparent; border: 0; border-radius: 10px;
  padding: 8px 10px; color: #ddd3f2; font-size: .88rem;
  display: flex; align-items: center; gap: 8px; transition: background .15s;
}
.ch-item:hover { background: rgba(255, 255, 255, .08); }
.ch-item.active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 700; }
.ch-item .ch-no {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 6px;
  background: rgba(255, 255, 255, .14); font-size: .72rem;
  display: flex; align-items: center; justify-content: center;
}
.ch-item .ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-item .ch-cnt { font-size: .72rem; color: #a99ccf; font-variant-numeric: tabular-nums; }
.ch-item.active .ch-cnt { color: #ddd3f2; }
.ch-item.done .ch-no { background: var(--green); color: #fff; }
.sec-list { display: flex; flex-direction: column; gap: 1px; margin: 0 0 6px 10px; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .14); }
.sec-item {
  cursor: pointer; font-family: inherit; text-align: left;
  background: transparent; border: 0; border-radius: 8px; padding: 5px 8px;
  color: #bdaee0; font-size: .8rem; display: flex; gap: 6px; align-items: baseline;
}
.sec-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sec-item.active { background: rgba(255, 255, 255, .14); color: #fff; }
.sec-item .sec-cnt { margin-left: auto; font-size: .7rem; color: #9688c4; font-variant-numeric: tabular-nums; }
.side-foot { margin-top: 16px; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .12); }
.side-stat { font-size: .8rem; line-height: 1.9; color: #bdaee0; }
.side-stat b { color: #fff; }
.side-actions { display: flex; gap: 6px; margin-top: 10px; }
.mini {
  flex: 1; cursor: pointer; font-family: inherit; font-size: .76rem;
  padding: 5px 0; border-radius: 7px; color: #ddd3f2;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .07);
}
.mini:hover { background: rgba(255, 255, 255, .16); }
.mini.danger { color: #fecaca; border-color: rgba(254, 202, 202, .35); }
.hint { margin: 10px 0 0; font-size: .72rem; color: #8e82b3; line-height: 1.6; }

.content { flex: 1; min-width: 0; padding: 16px 22px 60px; max-width: 980px; margin: 0 auto; }

/* ========== 工具条 ========== */
.toolbar {
  position: sticky; top: var(--topbar-h); z-index: 50;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 0 12px; background: var(--bg);
}
.chips { display: flex; gap: 6px; }
.chip {
  cursor: pointer; font-family: inherit; font-size: .82rem;
  padding: 5px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--text-light);
  transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.statline { margin-left: auto; font-size: .8rem; color: var(--text-light); font-variant-numeric: tabular-nums; }
.statline b { color: var(--text); }
.crumb { font-size: .8rem; color: var(--text-dim); margin: 0 0 10px; min-height: 1em; }

/* ========== 题目卡片 ========== */
.list { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px 12px; box-shadow: var(--shadow);
  scroll-margin-top: 120px;
}
.q-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.q-no { font-weight: 800; color: var(--primary); font-size: .9rem; }
.badge {
  font-size: .72rem; padding: 1px 8px; border-radius: 999px;
  background: var(--primary-light); color: var(--primary-deep); border: 1px solid var(--border);
}
html[data-theme="dark"] .badge { color: #ddd6fe; }
.badge.year { background: var(--amber-light); color: var(--amber); border-color: transparent; }
.badge.essay { background: #f1f5f9; color: #475569; border-color: transparent; }
html[data-theme="dark"] .badge.essay { background: #334155; color: #cbd5e1; }
.q-status { margin-left: auto; font-size: .76rem; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); }
.q-status.right { background: var(--green-light); color: var(--green); border-color: transparent; font-weight: 700; }
.q-status.wrong { background: var(--red-light); color: var(--red); border-color: transparent; font-weight: 700; }
.q-status.seen { background: var(--primary-light); color: var(--primary-deep); border-color: transparent; }
.q-status.multi { color: var(--amber); }

.q-stem { color: var(--text); }
.q-stem p { margin: 0 0 8px; }
.q-stem img, .ans-body img, .opt img, .bopt img {
  max-width: 100%; height: auto; border-radius: 8px;
  border: 1px solid var(--border); margin: 8px 0; background: #fff;
}

.opts { display: flex; flex-direction: column; gap: 7px; margin: 10px 0 4px; }
.opt, .bopt {
  display: flex; gap: 10px; align-items: flex-start; width: 100%;
  text-align: left; cursor: pointer; font-family: inherit; font-size: .9rem;
  padding: 8px 12px; border-radius: 10px; color: var(--text);
  border: 1px solid var(--border); background: var(--card);
  transition: border-color .15s, background .15s, transform .08s;
}
.opt:hover:not(.locked), .bopt:hover:not(.locked) { border-color: var(--primary); background: var(--primary-light); }
.opt:active:not(.locked) { transform: scale(.995); }
.opt .k, .bopt .k {
  flex: 0 0 22px; height: 22px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .76rem; font-weight: 700; color: var(--text-light); margin-top: 2px;
}
.opt .t, .bopt .t { flex: 1; min-width: 0; }
.opt .mark, .bopt .mark { font-size: .9rem; font-weight: 800; margin-left: 4px; }
.opt.locked, .bopt.locked { cursor: default; }
.opt.pick { border-color: var(--primary); background: var(--primary-light); }
.opt.pick .k { background: var(--primary); border-color: var(--primary); color: #fff; }
.opt.right { border-color: var(--green); background: var(--green-light); }
.opt.right .k { background: var(--green); border-color: var(--green); color: #fff; }
.opt.right .mark { color: var(--green); }
.opt.wrong { border-color: var(--red); background: var(--red-light); }
.opt.wrong .k { background: var(--red); border-color: var(--red); color: #fff; }
.opt.wrong .mark { color: var(--red); }
.opt.dim, .bopt.dim { opacity: .55; }

.blank { margin: 10px 0; }
.blank-title { font-size: .8rem; color: var(--text-light); margin-bottom: 5px; }
.blank-title b { color: var(--primary); }
.blank-opts { display: flex; flex-direction: column; gap: 6px; }
.bopt { font-size: .86rem; padding: 6px 10px; }
.bopt .k { flex: 0 0 19px; height: 19px; font-size: .68rem; }
.bopt.pick { border-color: var(--primary); background: var(--primary-light); }
.bopt.pick .k { background: var(--primary); border-color: var(--primary); color: #fff; }
.bopt.right { border-color: var(--green); background: var(--green-light); }
.bopt.right .k { background: var(--green); border-color: var(--green); color: #fff; }
.bopt.wrong { border-color: var(--red); background: var(--red-light); }
.bopt.wrong .k { background: var(--red); border-color: var(--red); color: #fff; }

.q-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 2px; }
.btn {
  cursor: pointer; font-family: inherit; font-size: .84rem; font-weight: 600;
  padding: 6px 16px; border-radius: 9px; border: 1px solid var(--primary);
  background: var(--primary); color: #fff; transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.sm { font-size: .78rem; padding: 4px 11px; font-weight: 500; }
.ansline { font-size: .82rem; color: var(--text-light); }
.ansline b { color: var(--green); }

details.ans { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 8px; }
details.ans summary {
  cursor: pointer; font-size: .82rem; color: var(--primary-deep); font-weight: 600;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
html[data-theme="dark"] details.ans summary { color: var(--primary); }
details.ans summary::-webkit-details-marker { display: none; }
details.ans summary::before { content: "▸"; transition: transform .15s; display: inline-block; }
details.ans[open] summary::before { transform: rotate(90deg); }
.ans-body {
  margin-top: 8px; font-size: .88rem; color: var(--text-light);
  background: var(--bg); border-radius: 10px; padding: 10px 14px;
}
.ans-body p { margin: 0 0 6px; }
.ans-body p:last-child { margin-bottom: 0; }
.ans-body strong { color: var(--text); }

.q-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.link-btn {
  cursor: pointer; font-family: inherit; font-size: .76rem; color: var(--text-dim);
  background: none; border: 0; padding: 2px 4px;
}
.link-btn:hover { color: var(--red); text-decoration: underline; }

/* ========== 其它 ========== */
.more { display: flex; justify-content: center; padding: 22px 0; }
.more-btn {
  cursor: pointer; font-family: inherit; font-size: .85rem;
  padding: 8px 26px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--text-light);
}
.more-btn:hover { border-color: var(--primary); color: var(--primary); }
.empty { text-align: center; color: var(--text-dim); font-size: .88rem; padding: 60px 0; }
.empty .big { font-size: 2rem; display: block; margin-bottom: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px);
  background: rgba(35, 25, 60, .93); color: #fff; font-size: .85rem;
  padding: 9px 20px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.katex { font-size: 1.02em; }
.katex-display { margin: .4em 0; }

@media (max-width: 900px) {
  .burger { display: block; }
  .tagline { display: none; }
  .searchbox input { width: 34vw; }
  .tb-btn { padding: 0 8px; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 150;
    transform: translateX(-101%); transition: transform .2s;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 12px 12px 60px; }
  .statline { margin-left: 0; width: 100%; }
}

/* ========== 顶部总进度条 ========== */
.progress {
  position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 300;
  background: rgba(255, 255, 255, .16); pointer-events: none;
}
.progress i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #fde047, #34d399);
  transition: width .3s ease;
}
.badge.multi { background: var(--amber-light); color: var(--amber); border-color: transparent; }

/* ========== 页脚 ========== */
.foot {
  margin: 26px 0 8px; padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: .76rem; color: var(--text-dim); line-height: 1.7;
}
.foot a { color: var(--primary); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* ========== 移动端抽屉遮罩 ========== */
.scrim { display: none; }
@media (max-width: 900px) {
  .scrim.show {
    display: block; position: fixed; left: 0; right: 0;
    top: var(--topbar-h); bottom: 0; z-index: 140;
    background: rgba(20, 12, 40, .45);
  }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .brand { font-size: .92rem; }
  .searchbox input { width: 30vw; }
}
@media (max-width: 560px) {
  .topbar .brand { display: none; }
  .searchbox input { width: 40vw; }
}

/* 综合题的「源自 x.x」小标 */
.badge.src {
  background: transparent; color: var(--text-dim);
  border: 1px dashed var(--border); font-weight: 400;
}
