:root {
  --theme: #1e3a8a;
  --primary: #1e3a8a;
  --primary-light: #eff6ff;
  --primary-border: #93c5fd;
  --accent: #b91c1c;
  --teal: #0f766e;
  --amber: #b45309;
  --purple: #6d28d9;
  --text: #111827;
  --muted: #4b5563;
  --border: #cbd5e1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Heiti SC", sans-serif;
  background: #e2e8f0;
  color: var(--text);
  font-size: 8.75pt;
  line-height: 1.24;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 28px;
}

.toolbar {
  width: min(210mm, calc(100vw - 16px));
  background: #0f172a;
  color: #f8fafc;
  padding: 8px 14px;
  border-radius: 8px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 12px;
}
.toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-badge {
  background: var(--theme);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
}
.toolbar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn {
  border: 1px solid #475569;
  background: #1e293b;
  color: #fff;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn:hover { background: #334155; }
.btn-primary { background: #2563eb; border-color: #3b82f6; }
.btn-primary:hover { background: #1d4ed8; }
.cloze-tip { font-size: 11px; color: #fca5a5; display: none; }

.page-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.a4-page {
  width: 210mm;
  height: 297mm;
  flex-shrink: 0;
  background: #ffffff;
  padding: 5.2mm 6.2mm;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.key {
  color: var(--accent);
  font-weight: 700;
  border-bottom: 1px dashed rgba(185, 28, 28, 0.45);
  padding: 0 1px;
}
body.cloze-mode .key {
  color: transparent !important;
  border-bottom: 1.2px solid #1e293b !important;
  background: #f8fafc;
  user-select: none;
  cursor: pointer;
}
body.cloze-mode .key * {
  color: transparent !important;
  border-color: transparent !important;
}
body.cloze-mode .key.revealed {
  color: var(--accent) !important;
  border-bottom: 1px dashed rgba(185, 28, 28, 0.55) !important;
  background: #fef2f2;
  user-select: text;
}
body.cloze-mode .key.revealed * {
  color: var(--accent) !important;
}

.m { font-family: "Cambria Math", "Times New Roman", serif; font-style: italic; font-weight: 700; }
.m-rm { font-family: "Cambria Math", "Times New Roman", serif; font-style: normal; font-weight: 700; }
.formula { font-family: "Cambria Math", "Times New Roman", serif; font-weight: 700; color: #1e3a8a; font-size: 8.1pt; }
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  font-size: 6.7pt;
  line-height: 1.02;
  margin: 0 1.5px;
  font-family: "Cambria Math", "Times New Roman", serif;
  font-weight: 700;
}
.frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 1.5px; }
.frac > span:last-child { padding: 0 1.5px; }
.bar { text-decoration: overline; }

.header {
  border-bottom: 2px solid var(--theme);
  padding-bottom: 2.5px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.header-title-wrap { display: flex; align-items: baseline; gap: 8px; }
.region-tag {
  background: var(--theme);
  color: #fff;
  font-size: 7.4pt;
  font-weight: 700;
  padding: 1.5px 6px;
  border-radius: 3px;
}
.header h1 { font-size: 12.6pt; font-weight: 800; color: #0f172a; }
.header-meta { font-size: 7.3pt; color: var(--muted); }

.section { border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: #fff; }
.sec-head {
  background: var(--primary);
  color: #fff;
  padding: 2px 6px;
  font-size: 7.9pt;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sec-head.teal { background: var(--teal); }
.sec-head.amber { background: #92400e; }
.sec-head.red { background: #991b1b; }
.sec-head.purple { background: var(--purple); }
.sec-head.slate { background: #334155; }
.sec-head span.sub { font-size: 6.8pt; font-weight: 400; opacity: 0.92; }
.sec-body { padding: 2.8px 5px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4.5px; }
.grid-left-wide { display: grid; grid-template-columns: 1.14fr 0.86fr; gap: 4.5px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4.5px; }

table.dense-table { width: 100%; border-collapse: collapse; font-size: 7.15pt; line-height: 1.18; }
table.dense-table th, table.dense-table td { border: 1px solid #cbd5e1; padding: 1.6px 4px; vertical-align: middle; }
table.dense-table th { background: #f1f5f9; color: #0f172a; font-weight: 700; text-align: center; }
.center { text-align: center; }
.bold { font-weight: 700; }

.kv-list { list-style: none; font-size: 7.2pt; line-height: 1.24; }
.kv-list li { margin-bottom: 2px; }
.kv-list li:last-child { margin-bottom: 0; }

.tag {
  display: inline-block;
  background: #e0e7ff;
  color: #1e3a8a;
  font-weight: 700;
  padding: 0 3.5px;
  border-radius: 2px;
  font-size: 6.7pt;
  margin-right: 2px;
}
.tag-red { background: #fee2e2; color: #991b1b; }
.tag-teal { background: #ccfbf1; color: #115e59; }
.tag-amber { background: #fef3c7; color: #92400e; }
.tag-purple { background: #ede9fe; color: #5b21b6; }

.footer-bar {
  background: #0f172a;
  color: #fff;
  border-radius: 3px;
  padding: 2.6px 8px;
  font-size: 7pt;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.footer-bar strong { color: #fbbf24; }

@page { size: A4 portrait; margin: 0; }
@media screen and (max-width: 820px) {
  body { padding: 8px 8px 20px; }
  .toolbar { padding: 8px 10px; }
}
@media print {
  body { background: #fff; padding: 0; margin: 0; }
  .toolbar { display: none !important; }
  .page-wrap { height: auto !important; display: block !important; overflow: visible !important; }
  .a4-page {
    box-shadow: none;
    width: 210mm;
    height: 297mm;
    transform: none !important;
    page-break-after: avoid;
    break-after: avoid;
  }
  body.cloze-mode .key.revealed {
    color: transparent !important;
    border-bottom: 1.2px solid #1e293b !important;
    background: #f8fafc !important;
  }
  body.cloze-mode .key.revealed * {
    color: transparent !important;
  }
}
