/* 南航 820 自动控制原理 · 真题精讲
 * 设计系统 v3 · 新中式 / 学术期刊：宣纸底色、宋体标题、朱砂印点缀、细线框。
 * 只改视觉，class 与 v2 完全一致，app.js 与数据文件零改动。 */

:root {
  --paper: #f5f1e8;          /* 宣纸 */
  --paper-2: #ece6d8;        /* 深一档纸 */
  --paper-3: #e3dccb;
  --card: #fbf9f3;           /* 卡片纸 */
  --ink: #1c1a17;            /* 墨 */
  --ink-2: #4b463e;
  --ink-3: #857e70;
  --line: #d8d0bd;           /* 细线 */
  --line-2: #e7e0d1;
  --seal: #a4342a;           /* 朱砂 */
  --seal-dark: #84271f;
  --seal-soft: #f6e6df;
  --indigo: #2d4059;         /* 靛青 */
  --indigo-soft: #e6ebf0;
  --gold: #8a6d2f;
  --radius: 3px;             /* 期刊式直角/微圆 */
  --radius-sm: 2px;
  --shadow: 0 1px 0 rgba(60, 50, 30, .05);
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", "STSong", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 50% -200px, #fbf8f0 0%, transparent 70%),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(120, 100, 60, .012) 3px 4px),
    var(--paper);
  color: var(--ink);
  font: 15px/1.8 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--seal); text-underline-offset: 3px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(245, 241, 232, .93);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(60, 50, 30, .04);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 11px 22px;
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; line-height: 1.3; }
.brand b {
  font-family: var(--serif); font-size: 17px; font-weight: 700;
  letter-spacing: 1.5px; color: var(--ink);
}
.brand b::before {
  content: "印"; display: inline-block; font-family: var(--serif);
  font-size: 11px; line-height: 1; color: #fff; background: var(--seal);
  border-radius: 2px; padding: 2px 3px; margin-right: 9px;
  vertical-align: 2px; letter-spacing: 0;
}
.brand span { font-size: 11px; color: var(--ink-3); letter-spacing: 2px; }

.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a {
  padding: 5px 14px; font-size: 13.5px; color: var(--ink-2);
  border-bottom: 2px solid transparent; letter-spacing: .5px;
  transition: color .15s, border-color .15s;
}
.nav a:hover { color: var(--seal); border-color: var(--seal); text-decoration: none; }
.nav a.on { color: var(--seal); border-color: var(--seal); font-weight: 700; }

.search {
  display: flex; align-items: center; gap: 6px;
  border: 0; border-bottom: 1px solid var(--line-2);
  padding: 5px 2px; background: transparent;
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--seal); }
.search::before { content: "⌕"; color: var(--ink-3); font-size: 16px; line-height: 1; }
.search input {
  border: 0; outline: 0; width: 156px; font-size: 13.5px;
  background: transparent; color: var(--ink); font-family: inherit;
}
.search input::placeholder { color: #aaa394; }

/* ---------- 布局 ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 32px 22px 100px; }

.hero {
  position: relative; overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 44px 30px; margin-bottom: 30px;
  box-shadow: var(--shadow);
}
.hero::before {
  content: ""; position: absolute; inset: 7px;
  border: 1px solid var(--line-2); pointer-events: none;
}
.hero::after {
  content: "南航·自动控制"; position: absolute; right: 28px; top: 26px;
  font-family: var(--serif); font-size: 13px; letter-spacing: 6px;
  color: var(--ink-3); writing-mode: vertical-rl; pointer-events: none;
}
.hero h1 {
  position: relative; margin: 0 0 12px; font-family: var(--serif);
  font-size: 31px; font-weight: 700; letter-spacing: 3px; line-height: 1.4;
}
.hero h1::after {
  content: ""; display: block; width: 52px; height: 2px;
  background: var(--seal); margin-top: 14px;
}
.hero p { position: relative; margin: 0; color: var(--ink-2); font-size: 14px; max-width: 640px; }
.hero .stats {
  position: relative; display: flex; gap: 0; margin-top: 26px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 18px;
}
.hero .stats div {
  font-size: 11.5px; color: var(--ink-3); padding: 0 28px;
  border-right: 1px solid var(--line); letter-spacing: 1px;
}
.hero .stats div:first-child { padding-left: 0; }
.hero .stats div:last-child { border-right: 0; }
.hero .stats b {
  display: block; font-family: var(--serif); font-size: 25px;
  color: var(--seal); font-weight: 700; line-height: 1.35; letter-spacing: 0;
}

.section-title {
  display: flex; align-items: baseline; gap: 12px;
  margin: 38px 0 18px; font-family: var(--serif);
  font-size: 19px; font-weight: 700; letter-spacing: 2px;
}
.section-title::before {
  content: ""; width: 7px; height: 7px; background: var(--seal);
  transform: rotate(45deg); margin-right: 4px; flex-shrink: 0;
}
.section-title small { font-family: var(--font); font-size: 12px; font-weight: 400; color: var(--ink-3); letter-spacing: 0; }

/* ---------- 年份卡片 ---------- */
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.year-card {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px 18px;
  box-shadow: var(--shadow); display: block; color: inherit;
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.year-card::after {
  content: "•"; position: absolute; top: 14px; right: 16px;
  font-size: 15px; color: var(--line); transition: color .16s;
}
.year-card:hover {
  border-color: var(--seal); transform: translateY(-2px);
  box-shadow: 0 4px 14px -8px rgba(120, 50, 30, .3); text-decoration: none;
}
.year-card:hover::after { color: var(--seal); }
.year-card h3 { margin: 0; font-family: var(--serif); font-size: 23px; font-weight: 700; letter-spacing: 2px; }
.year-card .code {
  display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 700;
  color: var(--seal); border: 1px solid var(--seal); border-radius: 2px;
  padding: 0 6px; vertical-align: 4px; letter-spacing: .5px;
}
.year-card .meta { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); padding-top: 9px; border-top: 1px dashed var(--line-2); }
.year-card .tags { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-size: 11.5px; padding: 2px 9px; border-radius: 2px;
  background: #f0ebdf; color: var(--ink-2); border: 1px solid var(--line);
  white-space: nowrap; line-height: 1.6;
}
.chip.b { background: var(--indigo-soft); color: var(--indigo); border-color: #c8d2de; }
.chip.g { background: #e9efe8; color: #3f6042; border-color: #ccd9cb; }
.chip.a { background: #f5eeda; color: var(--gold); border-color: #e2d3aa; }
.chip.r { background: var(--seal-soft); color: var(--seal); border-color: #e8c9c1; }
a.chip { text-decoration: none; transition: border-color .15s, color .15s; }
a.chip:hover { border-color: var(--seal); color: var(--seal); }
.chip.on { background: var(--seal); color: #fff; border-color: var(--seal); }

/* ---------- 试卷页 ---------- */
.paper-head {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 26px; margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.paper-head h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 21px; letter-spacing: 2px; }
.paper-head .sub { color: var(--ink-3); font-size: 13px; }
.paper-head .files { margin-top: 10px; font-size: 13px; }
.paper-head .files a { margin-right: 12px; }

.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin: 0 0 18px; }
.toolbar button {
  font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  padding: 7px 15px; border-radius: 2px; letter-spacing: .5px; transition: all .15s;
}
.toolbar button:hover { border-color: var(--seal); color: var(--seal); }
.toolbar button.on { background: var(--seal); border-color: var(--seal); color: #fff; }

/* ---------- 题目卡 ---------- */
.q {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 17px; box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: 84px;
}
.q.flash { animation: flash 1.4s ease; }
@keyframes flash {
  0%, 100% { box-shadow: var(--shadow); }
  30% { box-shadow: 0 0 0 3px rgba(164, 52, 42, .25), var(--shadow); }
}
.q-head {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 22px; border-bottom: 1px solid var(--line-2);
  background: #f2ede2; flex-wrap: wrap;
}
.q-no {
  font-family: var(--serif); font-size: 13px; font-weight: 700; color: #fff;
  background: var(--seal); width: 27px; height: 27px; border-radius: 2px;
  display: inline-flex; align-items: center; justify-content: center;
}
.q-title { font-size: 13px; color: var(--ink-3); margin-right: auto; letter-spacing: .5px; }

.q-body { padding: 20px 22px 6px; }
.q-stem { font-size: 15.5px; }
.q-stem p { margin: .3em 0; }
.q-imgs { margin: 14px 0 4px; }
.q-imgs img {
  display: block; width: 100%; max-width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
.q-imgs .cap { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

details.q-text {
  margin: 12px 0 0; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: #f7f3ea; padding: 0 15px;
}
details.q-text > summary {
  font-size: 13px; color: var(--ink-2); cursor: pointer; padding: 10px 0;
  list-style: none; display: flex; align-items: center; gap: 7px; letter-spacing: .5px;
}
details.q-text > summary::-webkit-details-marker { display: none; }
details.q-text > summary::before { content: "▸"; font-size: 10px; color: var(--seal); transition: transform .15s; }
details.q-text[open] > summary::before { transform: rotate(90deg); }
details.q-text > summary:hover { color: var(--seal); }
details.q-text .q-stem { padding: 2px 0 14px; font-size: 14.5px; color: var(--ink-2); }

.btn-ans {
  display: flex; align-items: center; gap: 8px;
  width: calc(100% - 44px); margin: 16px 22px 20px;
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  color: var(--seal); background: transparent;
  border: 1px solid var(--seal); border-radius: 2px; padding: 10px 17px;
  letter-spacing: 1px; transition: background .15s, color .15s;
}
.btn-ans:hover { background: var(--seal); color: #fff; }
.btn-ans .arrow { margin-left: auto; transition: transform .18s; font-size: 11px; }
.btn-ans.open { color: var(--ink-2); border-color: var(--line); background: #f5f1e8; }
.btn-ans.open .arrow { transform: rotate(180deg); }

.q-ans { border-top: 1px dashed var(--line); padding: 4px 22px 22px; background: #faf7ef; }
.q-ans[hidden] { display: none; }
.q-ans h4 {
  font-family: var(--serif); font-size: 13px; letter-spacing: 3px; color: var(--seal);
  margin: 22px 0 12px; font-weight: 700;
  display: flex; align-items: center; gap: 12px;
}
.q-ans h4::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.kp-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 0; }
.kp-row .lbl { font-size: 12.5px; color: var(--ink-3); align-self: center; margin-right: 2px; }

ol.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: st; }
ol.steps > li {
  counter-increment: st; position: relative; padding: 11px 0 11px 42px;
  border-bottom: 1px dashed var(--line-2);
}
ol.steps > li:last-child { border-bottom: 0; }
ol.steps > li::before {
  content: counter(st); position: absolute; left: 0; top: 12px;
  width: 25px; height: 25px; border-radius: 50%;
  background: transparent; color: var(--seal);
  border: 1px solid var(--seal); font-family: var(--serif);
  font-size: 12.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
ol.steps .s-t { font-weight: 700; color: var(--ink); }
ol.steps .s-d { color: var(--ink-2); font-size: 14.5px; }
ol.steps .s-d p { margin: .25em 0; }

.final {
  margin-top: 17px; padding: 14px 18px; border-radius: var(--radius-sm);
  background: #f0f4ee; border: 1px solid #d2ddcf;
  border-left: 3px solid #557049; color: #2f4a2b;
}
.final b { color: #243d20; }
.tip {
  margin-top: 11px; padding: 13px 18px; border-radius: var(--radius-sm);
  background: var(--seal-soft); border: 1px solid #e8c9c1;
  border-left: 3px solid var(--seal); color: #6e2b23; font-size: 14px;
}
.tip b { color: var(--seal-dark); }

/* ---------- 题型页 ---------- */
.type-block {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 13px; box-shadow: var(--shadow); overflow: hidden;
}
.type-head {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  padding: 15px 22px; background: #f2ede2; transition: background .15s;
}
.type-head:hover { background: #ece5d6; }
.type-head h3 { margin: 0; font-family: var(--serif); font-size: 15.5px; letter-spacing: 1px; }
.type-head .cnt { font-size: 12.5px; color: var(--ink-3); margin-right: auto; }
.type-head .arrow { font-size: 11px; color: var(--ink-3); transition: transform .18s; }
.type-block.open .type-head .arrow { transform: rotate(180deg); }
.type-body { display: none; padding: 8px 14px 14px; }
.type-block.open .type-body { display: block; }

.qline {
  display: flex; align-items: baseline; gap: 11px;
  padding: 9px 11px; border-radius: 2px; color: inherit; transition: background .12s;
}
.qline:hover { background: #f2ede2; text-decoration: none; }
.qline .y {
  font-size: 12.5px; font-weight: 700; color: var(--seal);
  border: 1px solid #e0bdb5; border-radius: 2px; padding: 1px 8px; white-space: nowrap;
}
.qline .tx { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 知识点页 ---------- */
.kp-layout { display: grid; grid-template-columns: 214px 1fr; gap: 22px; align-items: start; }
.kp-side {
  position: sticky; top: 78px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px; box-shadow: var(--shadow);
  max-height: calc(100vh - 100px); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: #c9c0ac transparent;
}
.kp-side::-webkit-scrollbar { width: 7px; }
.kp-side::-webkit-scrollbar-thumb { background: #c9c0ac; border-radius: 4px; }
.kp-side::-webkit-scrollbar-thumb:hover { background: #ad9f84; }
.kp-side::-webkit-scrollbar-track { background: transparent; }
.kp-side .g { font-family: var(--serif); font-size: 11px; color: var(--ink-3); margin: 12px 7px 5px; letter-spacing: 2px; font-weight: 700; }
.kp-side a {
  display: block; font-size: 13.5px; color: var(--ink-2); padding: 6px 9px;
  border-left: 2px solid transparent; border-radius: 0; line-height: 1.45; transition: all .12s;
}
.kp-side a:hover { background: #f2ede2; color: var(--seal); text-decoration: none; }
.kp-side a.on { border-left-color: var(--seal); background: #f2ede2; color: var(--seal); font-weight: 700; }

.kp-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 21px 25px; margin-bottom: 14px; box-shadow: var(--shadow); scroll-margin-top: 84px;
}
.kp-card h3 { margin: 0 0 4px; font-family: var(--serif); font-size: 17px; letter-spacing: 1px; }
.kp-card .cat { font-size: 12px; color: var(--seal); font-weight: 600; letter-spacing: 1px; }
.kp-card .body { margin-top: 11px; font-size: 14.5px; color: var(--ink-2); }
.kp-card .body p { margin: .4em 0; }
.kp-card ul { margin: .4em 0; padding-left: 1.3em; }
.kp-card li { margin: .2em 0; }
.kp-card .formula {
  margin: 12px 0; padding: 11px 15px; background: #f5f1e8;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
}
.refs { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.refs .lbl { font-size: 12.5px; color: var(--ink-3); align-self: center; margin-right: 2px; }
.ref {
  font-size: 12px; padding: 2px 10px; border-radius: 2px;
  background: transparent; border: 1px solid var(--line); color: var(--ink-2);
  transition: border-color .12s, color .12s;
}
.ref:hover { border-color: var(--seal); color: var(--seal); text-decoration: none; }

/* ---------- 其它 ---------- */
.empty { color: var(--ink-3); font-size: 14px; padding: 30px 0; text-align: center; }
.katex { font-size: 1.02em; }
.katex-display { margin: .55em 0; }
.katex-display > .katex { white-space: normal; }
.note {
  font-size: 13px; color: var(--ink-2); background: #f2ede2;
  border-left: 3px solid var(--seal); padding: 9px 13px; border-radius: 0 2px 2px 0;
  margin: 10px 0;
}
footer {
  text-align: center; font-size: 12.5px; color: var(--ink-3);
  padding: 34px 20px 56px; border-top: 1px solid var(--line);
  max-width: 1120px; margin: 0 auto;
}

@media (max-width: 820px) {
  .kp-layout { grid-template-columns: 1fr; }
  .kp-side { position: static; max-height: none; }
  .search input { width: 112px; }
  .topbar-inner { gap: 14px; padding: 10px 14px; }
  main { padding: 18px 14px 70px; }
  .hero { padding: 28px 22px 24px; }
  .hero::after { display: none; }
  .hero h1 { font-size: 24px; letter-spacing: 2px; }
  .hero .stats div { padding: 0 16px; }
  .q-body, .q-ans, .q-head { padding-left: 15px; padding-right: 15px; }
  .btn-ans { width: calc(100% - 30px); margin-left: 15px; margin-right: 15px; }
}

@media (max-width: 480px) {
  .brand span { display: none; }
  .nav a { padding: 5px 9px; font-size: 12.5px; }
  .search input { width: 80px; }
  .hero .stats div { padding: 0 12px 0 0; border-right: 0; }
  .year-card h3 { font-size: 21px; }
}

/* ---------------- 打印 / 存 PDF ---------------- */
@media print {
  @page { margin: 12mm 10mm 14mm; }
  html, body { background: #fff !important; }
  .topbar, .toolbar, .site-foot, .kp-row, .btn-ans, .flash-ring { display: none !important; }
  main { max-width: none; padding: 0 !important; }
  .hero::before, .hero::after { display: none; }
  .hero { border: 1px solid #ccc; }
  .paper-head { border: 0; padding: 0 0 6px; margin-bottom: 8px; }
  .paper-head .tags { display: none !important; }
  .q { break-inside: auto; box-shadow: none !important; border: 1px solid #ccc !important; margin: 0 0 10px !important; }
  .q-head { break-after: avoid; break-inside: avoid; background: #fff !important; }
  .q-imgs img { break-inside: avoid; max-height: 135mm; width: auto; max-width: 100%; margin: 0 auto 6px; }
  .steps li, .final, .tip, .q-text { break-inside: avoid; }
  .steps li { margin: 5px 0 !important; }
  .q-ans { padding: 8px 14px 12px !important; background: #fff !important; }
  .final, .tip { background: #fff !important; border-left-width: 2px !important; }
  a { color: inherit !important; text-decoration: none !important; }
  .katex { font-size: 1em; }
}
  .year-card { break-inside: avoid; }
