/*
  方向：考生的方眼笔记本。
  纸 = 冷白方眼纸，墨 = 钢笔蓝黑，红 = 红笔考点（{{}}），黑粗 = [[ ]]。
  遮住重点时，讲义像盖上一张赤シート：红字消失，黑字留着。
  暗色 = 黑板：板面绿、粉笔白、粉笔红。
*/
:root {
  --paper: #fbfcfb;
  --grid: #e3eaf0;
  --sheet-white: #ffffff;
  --ink: #1d2742;          /* ブルーブラック */
  --ink-soft: #3c4a6b;
  --muted: #687389;
  --line: #d9e0e8;
  --rule: #b9c6d6;
  --key: #d4102b;          /* 赤ペン */
  --margin-red: #f0a7b1;   /* 笔记本左侧红线 */
  --good: #23784a;
  --good-soft: #e3f2e8;
  --bad: #b8321f;
  --bad-soft: #fbe8e3;
  --tint: #edf1f8;
  --sheet: #f4c9cf;        /* 赤シート */
  --sheet-edge: #e49aa5;
  --on-ink: #ffffff;
  --bar: #1d2742;
  --on-bar: #ffffff;
  --radius: 4px;
  --font-body: "BIZ UDPGothic", "Hiragino Sans", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-hand: "Klee One", "BIZ UDPGothic", "Hiragino Mincho ProN", "PingFang SC", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1e2b26;      /* 黒板 */
    --grid: #26352f;
    --sheet-white: #23322c;
    --ink: #eef1e8;        /* 粉笔白 */
    --ink-soft: #c9d2c4;
    --muted: #94a39a;
    --line: #34463e;
    --rule: #4a5f55;
    --key: #ff8796;        /* 粉笔红 */
    --margin-red: #6b3a40;
    --good: #8fd4a8;
    --good-soft: #233d30;
    --bad: #ffa08c;
    --bad-soft: #43282a;
    --tint: #2a3a33;
    --sheet: #4d2a31;
    --sheet-edge: #6e3943;
    --on-ink: #1e2b26;
    --bar: #121b17;        /* 黒板的木框 */
    --on-bar: #eef1e8;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  /* 5mm 方眼 */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: -1px -1px;
  font: 15.5px/1.8 var(--font-body);
  font-feature-settings: "palt" 0;
}
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--key); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { line-height: 1.4; margin: 0; font-weight: 700; }
h1 { font-family: var(--font-hand); font-weight: 600; letter-spacing: .02em; }
.wrap { max-width: 860px; margin: 0 auto; padding: 28px 16px 96px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- 顶栏：笔记本的封面带 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap;
  padding: 10px max(16px, calc((100% - 860px) / 2 + 16px));
  background: var(--bar); color: var(--on-bar);
}
.brand { font-family: var(--font-hand); font-weight: 600; font-size: 18px; color: var(--on-bar); text-decoration: none; letter-spacing: .04em; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: var(--key); vertical-align: 1px; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.topbar nav a { padding: 3px 10px; color: var(--on-bar); opacity: .72; text-decoration: none; border-bottom: 2px solid transparent; }
.topbar nav a:hover { opacity: 1; }
.topbar nav a.active { opacity: 1; border-bottom-color: var(--key); font-weight: 700; }
.theme-btn {
  margin-left: auto; padding: 2px 10px; font: inherit; font-size: 13px; cursor: pointer;
  color: var(--on-bar); background: transparent; border: 1px solid currentColor; border-radius: 999px; opacity: .72;
}
.theme-btn:hover { opacity: 1; }

/* ---------- 基本部件 ---------- */
.card {
  background: var(--sheet-white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { border-top: 3px solid var(--ink); }
.tile .num { font-family: var(--font-hand); font-weight: 600; font-size: 34px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile .label { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); border: 1.5px solid var(--ink);
  background: var(--ink); color: var(--on-ink); font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { box-shadow: 3px 3px 0 var(--key); transform: translate(-1px, -1px); }
.btn:active { box-shadow: none; transform: none; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn:disabled { opacity: .4; cursor: default; box-shadow: none; transform: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input[type=email], input[type=text], input[inputmode=numeric] {
  font: inherit; padding: 10px 12px; border-radius: var(--radius); border: 1.5px solid var(--rule);
  background: var(--sheet-white); color: var(--ink); width: 100%;
}
input:focus { outline: none; border-color: var(--ink); }

.action { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.action h3 { font-size: 16.5px; }
.action p { margin: 2px 0 0; }
.action > .btn { flex-shrink: 0; }

.pill { display: inline-block; font-size: 12px; line-height: 1.6; padding: 0 8px; border: 1px solid var(--rule); border-radius: 999px; color: var(--ink-soft); background: var(--sheet-white); }

/* ---------- 讲义 ---------- */
.crumb { color: var(--muted); font-size: 13px; }
.lesson-head {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  padding-bottom: 10px; border-bottom: 3px double var(--ink);
}
.lesson-head h1 { font-size: 30px; }
.lesson-head .en { display: inline-block; color: var(--muted); font-family: var(--font-body); font-size: 14px; font-weight: 400; margin-left: 10px; letter-spacing: 0; }
.badge { border: 1.5px solid var(--key); color: var(--key); border-radius: 2px; padding: 1px 8px; font-size: 13px; font-weight: 700; white-space: nowrap; transform: rotate(-2deg); background: var(--sheet-white); }

#lesson {
  position: relative;
  background: var(--sheet-white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px 28px 40px;
  transition: background-color .35s ease, border-color .35s ease;
}
/* 笔记本左侧红线 */
#lesson::before { content: ""; position: absolute; top: 0; bottom: 0; left: 24px; border-left: 1.5px solid var(--margin-red); }
.sec-title { display: flex; align-items: baseline; gap: 12px; margin: 30px 0 10px; }
.sec-title h2 { font-family: var(--font-hand); font-weight: 600; font-size: 19px; color: var(--ink); white-space: nowrap; }
.sec-title .rule { flex: 1; border-top: 1px solid var(--rule); transform: translateY(-4px); }
.sec-title .src { color: var(--muted); font-size: 12px; }
ul.points { margin: 0; padding-left: 0; list-style: none; }
ul.points li { position: relative; padding-left: 18px; margin: 5px 0; }
ul.points li::before { content: ""; position: absolute; left: 1px; top: .72em; width: 8px; height: 8px; border: 1.5px solid var(--ink); border-radius: 50%; }

/* 两级重点：红字下划线 > 黑色加粗 */
mark.key {
  background: none; color: var(--key); font-weight: 700;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px;
}
strong { font-weight: 700; color: var(--ink); }

/* 赤シート：盖上之后红字和底色一样，看不见；点一下偷看 */
#lesson.hide-keys { background: var(--sheet); border-color: var(--sheet-edge); }
#lesson.hide-keys::before { border-left-color: var(--sheet-edge); }
.hide-keys mark.key { color: var(--sheet); text-decoration-color: var(--sheet-edge); cursor: pointer; transition: color .2s ease; }
.hide-keys mark.key:hover { text-decoration-color: var(--key); }
.hide-keys mark.key.peek { color: var(--key); text-decoration-color: var(--key); }
.hide-keys .badge, .hide-keys .ox button, .hide-keys .trends { background: transparent; }
.hide-keys th, .hide-keys td { border-bottom-color: var(--sheet-edge); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 8px 9px; border-bottom: 1px solid var(--line); }
th { font-weight: 700; border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
.figure { border: 1.5px dashed var(--rule); border-radius: var(--radius); padding: 16px; text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }
.trends { background: var(--tint); border-left: 3px solid var(--ink); padding: 10px 14px; }
.trends b { margin-right: 8px; font-family: var(--font-hand); font-weight: 600; }
.toolbar { position: sticky; top: 50px; z-index: 5; padding: 10px 0; display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar .btn { background: var(--sheet-white); }
.hide-keys .toolbar .btn { background: var(--sheet); }
#toggleKeys { border-color: var(--key); color: var(--key); }

/* ---------- ○× ---------- */
.check { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 10px 0; border-bottom: 1px dashed var(--rule); align-items: center; }
.check .src { color: var(--muted); font-size: 12px; }
.check .feedback { grid-column: 1 / -1; font-size: 14px; }
.ox { display: flex; gap: 6px; }
.ox button {
  width: 44px; height: 38px; border-radius: var(--radius); border: 1.5px solid var(--rule);
  background: var(--sheet-white); color: var(--ink); font: 600 20px/1 var(--font-hand); cursor: pointer;
  transition: border-color .12s ease;
}
.ox button:hover:not(:disabled) { border-color: var(--ink); }
.ox button:disabled { cursor: default; }

/* ---------- 刷题 ---------- */
.choice {
  position: relative; display: block; width: 100%; text-align: left; padding: 11px 44px 11px 14px; margin: 8px 0;
  border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--sheet-white); color: var(--ink);
  font: inherit; cursor: pointer; transition: border-color .12s ease;
}
.choice:hover:not(:disabled) { border-color: var(--ink-soft); }
.choice:disabled { cursor: default; }
.choice.picked { border-color: var(--ink); background: var(--tint); }
.choice.right { border-color: var(--good); background: var(--good-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
/* 像老师批改：对的画○，错的打× */
.choice.right::after, .choice.wrong::after {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%) rotate(-6deg);
  font: 600 26px/1 var(--font-hand); animation: mark-in .28s ease-out both;
}
.choice.right::after { content: "○"; color: var(--good); }
.choice.wrong::after { content: "×"; color: var(--bad); }
@keyframes mark-in { from { opacity: 0; transform: translateY(-50%) rotate(-6deg) scale(1.6); } }
.verdict { font-family: var(--font-hand); font-weight: 600; font-size: 20px; }
.verdict.ok { color: var(--good); }
.verdict.ng { color: var(--bad); }
.progress { height: 4px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ink); transition: width .3s ease; }

.bar { height: 8px; background: var(--line); overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--ink); }

/* ---------- 换页：一次错落的载入 ---------- */
#app > *, #app > .stack > * { animation: rise .42s cubic-bezier(.2, .7, .2, 1) both; }
#app > .stack > :nth-child(2) { animation-delay: .05s; }
#app > .stack > :nth-child(3) { animation-delay: .1s; }
#app > .stack > :nth-child(4) { animation-delay: .15s; }
#app > .stack > :nth-child(5) { animation-delay: .2s; }
#app > .stack > :nth-child(n+6) { animation-delay: .25s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .wrap { padding-top: 20px; }
  .card { padding: 16px; }
  .lesson-head h1 { font-size: 24px; }
  .lesson-head .en { display: block; margin-left: 0; }
  #lesson { padding: 16px 14px 22px 26px; margin: 0 -6px; }
  #lesson::before { left: 14px; }
  .theme-btn { order: 1; }
  .topbar nav { order: 2; width: 100%; margin-left: -10px; }
  .toolbar { top: 94px; }
  .action { align-items: flex-start; flex-direction: column; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tile { padding: 12px 10px; }
  .tile .num { font-size: 26px; }
  .tile .label { font-size: 12px; line-height: 1.5; }
}

/* ---------- 打印：白纸黑字，红字考点照样红 ---------- */
@media print {
  :root { --paper: #fff; --sheet-white: #fff; --ink: #000; --muted: #444; --line: #bbb; --rule: #888; --key: #c8102e; }
  body { background: #fff; font-size: 10.5pt; }
  .topbar, .toolbar, .ox, .check .feedback { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  #lesson { border: 0; padding: 0; background: #fff !important; }
  #lesson::before { display: none; }
  #app > *, #app > .stack > * { animation: none; }
  .hide-keys mark.key { color: var(--key); text-decoration-color: var(--key); }
  section, tr, .figure { break-inside: avoid; }
  .sec-title { break-after: avoid; }
}
