/* 计算机导论刷题本 —— 做成一本批改过的练习册的样子：宋体印刷、蓝色圆珠笔作答、红笔批改 */

:root {
  --desk: #ddd5c2;
  --paper: #f6f1e4;
  --ink: #1c1b19;
  --ink2: #5a564b;
  --ink3: #8d8878;
  --rule: #d8d0ba;
  --rule2: #bfb69c;
  --red: #b83527;
  --blue: #263f95;
  --song: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "BiauKai", "Noto Serif CJK SC", serif;
  --line: 32px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--song);
  font-size: 17px;
  line-height: 1.7;
}

a { color: inherit; }
button { font: inherit; color: inherit; }

/* ---------- 纸张 ---------- */
.desk { padding: 22px 12px 40px; }

.sheet {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35  0 0 0 0 .3  0 0 0 0 .2  0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  border: 1px solid #c9c0a6;
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 14px 30px -22px rgba(40,30,10,.55);
  padding: 26px 44px 44px 76px;
  min-height: 78vh;
}

/* 装订线 */
.sheet::before {
  content: "";
  position: absolute; left: 44px; top: 0; bottom: 0;
  border-left: 1.5px dashed var(--rule2);
}
.sheet::after {
  content: "装　订　线";
  position: absolute; left: 14px; top: 50%;
  writing-mode: vertical-rl;
  transform: translateY(-50%);
  font-size: 12px; letter-spacing: .5em;
  color: var(--ink3);
}

/* ---------- 顶栏 ---------- */
.head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 6px 18px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 22px;
}
.head .brand { font-size: 15px; letter-spacing: .12em; color: var(--ink2); text-decoration: none; }
.head nav { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 15px; }
.head nav a {
  text-decoration: none; padding: 0 1px 1px; border-bottom: 2px solid transparent;
}
.head nav a:hover { border-bottom-color: var(--rule2); }
.head nav a.on { border-bottom-color: var(--red); }

/* ---------- 标题 ---------- */
h1 {
  font-size: 40px; line-height: 1.25; margin: 6px 0 4px;
  letter-spacing: .14em; font-weight: 900;
}
h2 {
  font-size: 22px; margin: 34px 0 10px; letter-spacing: .1em;
  display: flex; align-items: baseline; gap: 10px;
}
h2 small { font-size: 14px; font-weight: 400; color: var(--ink2); letter-spacing: 0; }
p { margin: 8px 0; }
.sub { color: var(--ink2); margin: 0 0 6px; }
.hand { font-family: var(--kai); }
.note { font-family: var(--kai); color: var(--red); font-size: 19px; line-height: 1.5; }
.dim { color: var(--ink2); }
.small { font-size: 14px; }

/* ---------- 目录 ---------- */
.toc { list-style: none; padding: 0; margin: 26px 0 0; }
.toc li { margin: 0; }
.toc a {
  display: flex; align-items: baseline; gap: 10px;
  padding: 11px 6px; text-decoration: none; font-size: 21px;
  border-bottom: 1px solid var(--rule);
}
.toc a:hover { background: rgba(184,53,39,.06); }
.toc .no { width: 2em; color: var(--ink2); font-size: 17px; }
.toc .dots { flex: 1; border-bottom: 2px dotted var(--ink3); transform: translateY(-5px); min-width: 20px; }
.toc .d { font-size: 15px; color: var(--ink2); }

/* ---------- 成绩戳 ---------- */
.stamp {
  display: inline-block;
  border: 3px solid var(--red); color: var(--red);
  padding: 2px 14px; font-weight: 900; letter-spacing: .15em;
  transform: rotate(-7deg);
  outline: 1px solid var(--red); outline-offset: 2px;
  font-size: 26px; line-height: 1.35;
  opacity: .88; mix-blend-mode: multiply;
  background: transparent;
  user-select: none;
}
.stamp.sm { font-size: 17px; border-width: 2px; padding: 0 8px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; cursor: pointer;
  background: transparent; border: 2px solid var(--ink);
  padding: 5px 18px; margin: 4px 8px 4px 0;
  letter-spacing: .15em; font-size: 17px;
  text-decoration: none;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn.red { border-color: var(--red); color: var(--red); }
.btn.red:hover { background: var(--red); color: var(--paper); }
.btn.ghost { border-color: var(--rule2); color: var(--ink2); }
.btn.ghost:hover { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.linkbtn { white-space: nowrap; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; color: var(--ink2); }
.linkbtn:hover { color: var(--red); }

/* ---------- 表单：像填表 ---------- */
.field { margin: 14px 0; }
.field > .lab { display: block; font-size: 15px; color: var(--ink2); letter-spacing: .1em; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  cursor: pointer; user-select: none;
  border: 1.5px solid var(--rule2); padding: 2px 14px; background: transparent;
}
.chip:hover { border-color: var(--ink); }
.chip.on { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin-right: 18px; }
.check input { appearance: none; width: 18px; height: 18px; border: 2px solid var(--ink); margin: 0; background: transparent; cursor: pointer; position: relative; }
.check input:checked::after {
  content: ""; position: absolute; left: 3px; top: -5px; width: 7px; height: 14px;
  border: solid var(--blue); border-width: 0 3px 3px 0; transform: rotate(38deg);
}

/* ---------- 表格 ---------- */
table.t { width: 100%; border-collapse: collapse; margin: 8px 0; }
table.t th, table.t td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.t th { font-weight: 700; font-size: 14px; color: var(--ink2); letter-spacing: .1em; border-bottom: 2px solid var(--ink); }
table.t td:last-child { white-space: nowrap; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.pick { cursor: pointer; }
table.t tr.pick:hover { background: rgba(0,0,0,.035); }
table.t tr.sel { background: rgba(38,63,149,.08); }

.pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.pips i { width: 11px; height: 11px; border: 1.5px solid var(--ink); display: block; }
.pips i.on { background: var(--ink); }
.pips.edit i { cursor: pointer; }
.pips.edit i:hover { border-color: var(--red); }

.bar {
  height: 14px; border: 1.5px solid var(--ink); position: relative; min-width: 80px;
  background: repeating-linear-gradient(135deg, transparent 0 4px, rgba(0,0,0,.14) 4px 5px);
}
.bar > b { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); }
.bar.weak > b { background: var(--red); }
.bar.none { border-style: dashed; border-color: var(--ink3); background: none; }
.lvl { font-family: var(--kai); font-size: 18px; white-space: nowrap; }
.lvl.weak { color: var(--red); }
.lvl.ok { color: var(--blue); }

/* ---------- 答题页 ---------- */
.qhead {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px;
  font-size: 14px; color: var(--ink2); letter-spacing: .08em;
  border-bottom: 1px solid var(--ink); padding-bottom: 4px;
}
.qhead .no { font-size: 24px; color: var(--ink); font-weight: 900; letter-spacing: 0; }
.qhead .grow { flex: 1; }
.qhead .kp { border: 1px solid var(--rule2); padding: 0 8px; }

.qbody {
  margin-top: 6px;
  line-height: var(--line);
  font-size: 19px;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px), var(--rule) var(--line));
  padding: 0 4px;
}
.qbody .stem { padding-top: 0; }
.qbody sub, .qbody sup { line-height: 0; }

.opts { list-style: none; padding: 0; margin: 0; }
.opt {
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%; text-align: left; background: transparent; border: 0; cursor: pointer;
  padding: 0 6px 0 2px; line-height: var(--line); font-size: 19px; position: relative;
}
.opt:hover { background: rgba(38,63,149,.06); }
.opt .lt { flex: none; width: 2.1em; position: relative; text-align: center; }
.opt .lt::before { content: attr(data-l); }
.opt.sel { color: var(--blue); font-family: var(--kai); font-size: 21px; }
.opt.sel .lt::after {
  content: ""; position: absolute; left: -2px; right: -2px; top: 4px; bottom: 3px;
  border: 2px solid var(--blue); border-radius: 52% 48% 55% 45% / 58% 50% 50% 42%;
  transform: rotate(-4deg);
}
.opt.right .lt::after, .opt.wrong .lt::after { border-color: var(--red); }
.opt.right { color: var(--red); }
.opt.right .tx { text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 5px; text-decoration-thickness: 2px; }
.opt.wrong { color: var(--ink2); }
.opt.wrong .tx { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.opt[disabled] { cursor: default; }
.opt[disabled]:hover { background: transparent; }

/* 红笔打钩/打叉 */
.mark { display: inline-block; width: 30px; height: 30px; vertical-align: middle; margin-right: 4px; }
.mark svg { width: 100%; height: 100%; overflow: visible; }
.mark path { stroke: var(--red); fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.tf { display: flex; gap: 22px; padding: 6px 0 8px; }
.tfbtn {
  cursor: pointer; background: transparent; border: 2px solid var(--ink);
  font-size: 24px; padding: 4px 30px; letter-spacing: .2em; line-height: 1.5;
}
.tfbtn:hover { background: rgba(38,63,149,.08); }
.tfbtn.sel { border-color: var(--blue); color: var(--blue); font-family: var(--kai); box-shadow: inset 0 0 0 2px var(--blue); }
.tfbtn.right { border-color: var(--red); color: var(--red); box-shadow: inset 0 0 0 2px var(--red); }
.tfbtn.wrong { border-style: dashed; color: var(--ink3); }
.tfbtn[disabled] { cursor: default; }

input.blank {
  font-family: var(--kai); font-size: 21px; color: var(--blue);
  background: transparent; border: 0; border-bottom: 2px solid var(--ink);
  padding: 0 4px; margin: 0 3px; height: 30px; line-height: 30px; text-align: center; outline: 0;
  vertical-align: baseline; max-width: 100%;
}
input.blank:focus { border-bottom-color: var(--blue); background: rgba(38,63,149,.07); }
input.blank.ok { color: var(--ink); border-bottom-color: var(--ink); }
input.blank.bad { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; color: var(--ink2); border-bottom-color: var(--red); }

.fix { font-family: var(--kai); color: var(--red); font-size: 20px; line-height: 1.5; margin-top: 6px; }
.fix .ln { display: block; }
.why {
  margin-top: 10px; padding: 6px 0 6px 14px; border-left: 3px solid var(--red);
  font-size: 16px; line-height: 1.7; color: var(--ink);
  font-family: var(--kai);
}
.why .doubt { color: var(--red); display: block; margin-top: 4px; }
.fig { margin: 8px 0 10px; }
.fig table { border-collapse: collapse; font-size: 17px; line-height: 1.6; background: var(--paper); }
.fig td, .fig th { border: 1.5px solid var(--ink); padding: 1px 12px; text-align: left; }

.qfoot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 18px; }
.qfoot .grow { flex: 1; }

.palette { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.palette button {
  width: 34px; height: 30px; background: transparent; border: 1.5px solid var(--rule2); cursor: pointer; font-size: 14px; padding: 0;
}
.palette button.done { border-color: var(--blue); color: var(--blue); background: rgba(38,63,149,.07); }
.palette button.cur { border-color: var(--ink); outline: 2px solid var(--ink); outline-offset: 1px; }
.palette button.r { border-color: var(--ink); }
.palette button.w { border-color: var(--red); color: var(--red); }

.prog { height: 6px; border: 1px solid var(--ink); margin: 14px 0 0; }
.prog b { display: block; height: 100%; background: var(--ink); }

/* ---------- 成绩单 ---------- */
.score { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 36px; margin: 8px 0 4px; }
.score .big { font-family: var(--kai); color: var(--red); font-size: 76px; line-height: 1.1; }
.score .big small { font-size: 26px; }

.wrongitem { border-top: 1px solid var(--rule2); padding: 10px 0; }
.wrongitem .q { font-size: 17px; }
.wrongitem .me { color: var(--ink2); }
details.wi > summary { cursor: pointer; list-style: none; }
details.wi > summary::-webkit-details-marker { display: none; }
details.wi > summary::before { content: "▸ "; color: var(--red); }
details.wi[open] > summary::before { content: "▾ "; }

.callout { border: 1.5px solid var(--ink); padding: 8px 14px; margin: 14px 0; }
.callout.red { border-color: var(--red); }

footer.foot { max-width: 900px; margin: 14px auto 0; text-align: center; font-size: 13px; color: var(--ink2); }

.hide { display: none !important; }

@media (max-width: 640px) {
  .desk { padding: 0; }
  .sheet { padding: 18px 16px 36px 22px; border-left: 0; border-right: 0; min-height: 100vh; }
  .sheet::before { left: 8px; }
  .sheet::after { display: none; }
  h1 { font-size: 30px; }
  .toc a { font-size: 18px; flex-wrap: wrap; }
  .toc .d { width: 100%; padding-left: 3em; }
  .toc .dots { display: none; }
  .qbody, .opt { font-size: 18px; }
  .score .big { font-size: 56px; }
  table.t { font-size: 15px; }
  .hide-sm { display: none; }
  table.t td.kpn { min-width: 6.5em; }
  table.t th, table.t td { padding: 7px 5px; }
  h2 { flex-wrap: wrap; }
}

@media print {
  body { background: #fff; }
  .head nav, .qfoot, .btn { display: none; }
  .sheet { box-shadow: none; border: 0; }
}
