@page { size: A4; margin: 0; }
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #f0f2f5;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Calibri, Arial, sans-serif;
  font-size: 10.5pt;
  line-height: 1.35;
  color: #1a1a1a;
}

/* ========== 顶部工具栏 ========== */
.toolbar {
  position: sticky; top: 0; z-index: 100;
  background: #2c3e50; color: #fff;
  padding: 10px 16px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.toolbar .title { font-weight: 700; }
.toolbar .actions { display: flex; gap: 8px; }
.toolbar input {
  padding: 6px 10px; border: none; border-radius: 4px;
  font-size: 13px; width: 220px; outline: none;
}
.toolbar button {
  padding: 6px 14px; border: none; border-radius: 4px;
  background: #e67e22; color: #fff; cursor: pointer; font-size: 13px;
}
.toolbar button:hover { background: #d35400; }

/* ========== 每一页 ========== */
.sheet {
  width: 210mm;
  height: 297mm;
  margin: 8mm auto;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border-radius: 6px;
  page-break-after: always;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sheet:last-child { page-break-after: auto; }

.sheet-content {
  flex: 1 1 auto;
  padding: 14mm 12mm 6mm;
  overflow: hidden;
}
.sheet-foot {
  flex: 0 0 auto;
  height: 12mm;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9pt;
  color: #aaa;
  letter-spacing: 2px;
  font-family: Consolas, "Courier New", monospace;
}
.sheet-foot .page-num { display: inline-block; }
.sheet-foot .page-num::before { content: "— "; color: #ddd; }
.sheet-foot .page-num::after  { content: " —"; color: #ddd; }

/* 封面 */
.sheet.cover .sheet-foot { display: none; }
.cover { background: #2c3e50; }
.cover .sheet-content { padding: 0; position: relative; height: 100%; overflow: hidden; }
.cover-wrap { position: relative; width: 100%; height: 100%; overflow: hidden; }
.cover-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.cover-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 22mm 18mm; color: #fff;
  background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.15) 45%, rgba(0,0,0,0.55) 100%);
}
.cover-top { text-align: center; }
.cover-series {
  font-size: 10pt; letter-spacing: 8px;
  color: #ffd27f;
  font-family: Consolas, "Courier New", monospace;
}
.cover-main { text-align: center; }
.cover-chip {
  display: inline-block; background: #e67e22; color: #fff;
  padding: 2mm 6mm; font-size: 11pt; letter-spacing: 3px;
  font-weight: 700; margin-bottom: 10mm; border-radius: 2px;
  box-shadow: 0 4px 20px rgba(230,126,34,0.6);
}
.cover-title {
  font-size: 30pt; font-weight: 800; line-height: 1.4;
  letter-spacing: 3px; margin: 0 0 5mm;
  text-shadow: 0 2px 20px rgba(0,0,0,0.6);
}
.cover-sub {
  font-size: 12pt; letter-spacing: 3px; font-style: italic;
  color: #ffd27f; text-shadow: 0 1px 10px rgba(0,0,0,0.6);
}
.cover-bottom {
  display: flex; justify-content: space-between; align-items: flex-end;
  border-top: 1px solid rgba(255,255,255,0.35);
  padding-top: 5mm;
}
.cover-author-label, .cover-year-label {
  font-size: 8pt; letter-spacing: 3px;
  font-family: Consolas, "Courier New", monospace;
  color: #ffd27f; margin-bottom: 1mm;
}
.cover-author-name { font-size: 12pt; font-weight: 700; text-shadow: 0 1px 10px rgba(0,0,0,0.6); }
.cover-year-value { font-size: 11pt; font-weight: 700; color: #ffd27f; }
.cover-year { text-align: right; }

/* ========== 标题 / 前言 ========== */
.doc-title {
  font-size: 18pt; color: #2c3e50; font-weight: 700;
  border-bottom: 2px solid #2c3e50; padding-bottom: 3mm;
  margin-bottom: 6mm;
}
.doc-title small { font-size: 10pt; color: #7f8c8d; font-weight: 400; margin-left: 6px; }

.prose { font-size: 10.5pt; line-height: 1.7; color: #333; }
.prose p { margin: 0 0 4mm; text-indent: 2em; }
.prose h3 { font-size: 12pt; color: #e67e22; margin: 6mm 0 3mm; border-left: 4px solid #e67e22; padding-left: 6px; }
.prose ul, .prose ol { margin: 0 0 4mm; padding-left: 8mm; }
.prose li { margin-bottom: 1.5mm; }

/* ========== 目录 ========== */
.toc-wrap {
  column-count: 2;
  column-gap: 10mm;
  column-rule: 1px dotted #e0e0e0;
  font-size: 10pt;
  height: 100%;
}
.toc-chapter {
  break-inside: avoid;
  margin-bottom: 4mm;
}
.toc-chapter-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: #fdf3e6;
  border-left: 3px solid #e67e22;
  padding: 1.5mm 3mm;
  margin: 2mm 0 2mm;
  font-weight: 700;
  font-size: 10.5pt;
  color: #2c3e50;
  break-after: avoid;
}
.toc-chapter-title .count {
  font-size: 9pt;
  color: #e67e22;
  font-weight: 600;
}
.toc-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.2mm 3mm 1.2mm 6mm;
  border-bottom: 1px dotted #ececec;
  color: #333;
  break-inside: avoid;
}
.toc-item .num {
  color: #b0b0b0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 9.5pt;
  margin-right: 2mm;
}
.toc-item .name { flex: 1; color: #2c3e50; }
.toc-item .page {
  color: #e67e22;
  font-family: Consolas, "Courier New", monospace;
  font-weight: 600;
  font-size: 9.5pt;
}

/* ========== 单词卡片 ========== */
.header { border-bottom: 2px solid #2c3e50; padding-bottom: 3mm; margin-bottom: 4mm; }
.header .header-top {
  display: flex; align-items: center; gap: 5mm; margin-bottom: 2mm;
}
.header .big-id {
  font-size: 42pt; font-weight: 800; color: #e67e22;
  line-height: 1; letter-spacing: -1px;
  min-width: 18mm; text-align: center;
}
.header .series { font-size: 9pt; color: #7f8c8d; letter-spacing: 1px; }
.header .word-line { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.header .word { font-size: 20pt; font-weight: 700; color: #2c3e50; cursor: pointer; }
.header .word:hover { color: #e67e22; }
.header .phonetic { font-size: 11pt; color: #e67e22; font-family: "Lucida Sans Unicode", Arial, sans-serif; }
.header .pos { font-size: 10pt; color: #7f8c8d; font-style: italic; }

.speak-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border: none; border-radius: 50%;
  background: #e67e22; color: #fff; cursor: pointer; font-size: 11px;
  padding: 0; margin-left: 4px; vertical-align: middle;
  position: relative; top: -2px;
  transition: background 0.2s, transform 0.1s;
}
.speak-btn:hover { background: #d35400; }
.speak-btn:active { transform: scale(0.9); }
.speak-btn.playing { background: #27ae60; }

.section { margin-bottom: 3.5mm; page-break-inside: avoid; }
.section-title {
  font-size: 11pt; font-weight: 700; color: #2c3e50;
  border-left: 4px solid #e67e22; padding-left: 6px;
  margin-bottom: 2mm; line-height: 1.2;
}

.def-table { width: 100%; border-collapse: collapse; font-size: 10pt; }
.def-table td { padding: 1.2mm 2mm; vertical-align: top; border-bottom: 1px dotted #ddd; }
.def-table td.label { width: 28mm; color: #555; font-weight: 600; white-space: nowrap; }
.def-table tr:last-child td { border-bottom: none; }
.def-table td[data-speak] { cursor: pointer; }
.def-table td[data-speak]:hover { color: #e67e22; }

.colloc-list { display: flex; flex-wrap: wrap; gap: 2mm 4mm; font-size: 10pt; }
.colloc-item { background: #f4f6f8; border-radius: 3px; padding: 1mm 2.5mm; white-space: nowrap; }
.colloc-item .en { color: #2c3e50; font-weight: 600; cursor: pointer; }
.colloc-item .en:hover { color: #e67e22; text-decoration: underline; }
.colloc-item .cn { color: #555; margin-left: 2px; }

.example { background: #fafafa; border-left: 3px solid #3498db; padding: 2mm 3mm; border-radius: 0 3px 3px 0; font-size: 10pt; }
.example .en { color: #2c3e50; font-weight: 600; cursor: pointer; }
.example .en:hover { color: #3498db; text-decoration: underline; }
.example .cn { color: #555; margin-top: 1mm; }

.compare-list { font-size: 10pt; }
.compare-item { padding: 1.2mm 0; border-bottom: 1px dotted #eee; display: flex; gap: 3mm; align-items: flex-start; }
.compare-item:last-child { border-bottom: none; }
.compare-item .term { min-width: 42mm; font-weight: 700; color: #2c3e50; font-family: Consolas, "Courier New", monospace; cursor: pointer; }
.compare-item .term:hover { color: #e67e22; text-decoration: underline; }
.compare-item .desc { color: #444; flex: 1; }

.tips-list { margin: 0; padding-left: 5mm; font-size: 10pt; color: #333; }
.tips-list li { margin-bottom: 1.2mm; }
.tips-list li::marker { color: #e67e22; font-weight: 700; }

.exercise { background: #fff8f0; border: 1px dashed #e67e22; border-radius: 3px; padding: 2.5mm 3mm; font-size: 10pt; }
.exercise .sentence { font-weight: 600; color: #2c3e50; cursor: pointer; }
.exercise .sentence:hover { color: #e67e22; text-decoration: underline; }
.exercise .blank { display: inline-block; border-bottom: 1px solid #999; min-width: 60mm; height: 1.1em; margin-left: 2mm; vertical-align: bottom; }
.exercise .answer { margin-top: 1.5mm; color: #27ae60; font-size: 9.5pt; }

.footer { margin-top: 4mm; padding-top: 2mm; border-top: 1px solid #ddd; font-size: 9pt; color: #888; display: flex; justify-content: space-between; }

/* ========== 索引 ========== */
.index-grid { column-count: 3; column-gap: 8mm; font-size: 10pt; }
.index-item { display: flex; justify-content: space-between; padding: 1mm 0; border-bottom: 1px dotted #eee; break-inside: avoid; }
.index-item .w { color: #2c3e50; font-weight: 600; }
.index-item .p { color: #999; }

/* ========== 打印 ========== */
@media print {
  html, body { background: #fff; }
  .toolbar { display: none !important; }
  .sheet {
    width: 210mm;
    height: 297mm;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    page-break-after: always;
  }
  .sheet:last-child { page-break-after: auto; }
  .speak-btn { display: none; }
  .header .word:hover, .colloc-item .en:hover, .example .en:hover,
  .compare-item .term:hover, .exercise .sentence:hover { color: inherit; text-decoration: none; }
  .cover-overlay {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .cover-img {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ===== 单词卡片：垂直居中 + 间距放宽，消除底部大留白 ===== */
.word-card .sheet-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.word-card .header {
  margin-bottom: 6mm;
  padding-bottom: 4mm;
}

.word-card .section {
  margin-bottom: 5mm;
}

.word-card .def-table td {
  padding: 2mm 2mm;
}

.word-card .colloc-item {
  padding: 1.5mm 3mm;
}

.word-card .example {
  padding: 3mm 4mm;
}

.word-card .exercise {
  padding: 4mm 5mm;
}

.word-card .footer {
  margin-top: 6mm;
  padding-top: 3mm;
}