:root {
  --ink: #111;
  --paper: #fff;
  --muted: #667085;
  --line: #d0d5dd;
  --panel: #f6f7f9;
  --accent: #1f6feb;
  --font-hei: Arial, SimHei, "Heiti SC", "Microsoft YaHei", sans-serif;
  --font-song: "Times New Roman", SimSun, "Songti SC", "STSong", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #e9edf2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
  padding: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgb(16 24 40 / 12%);
}

.controls {
  align-self: start;
  padding: 22px;
  position: sticky;
  top: 24px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-family: var(--font-hei);
  font-size: 12px;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-family: var(--font-hei);
  font-size: 22px;
  line-height: 1.25;
}

form {
  display: grid;
  gap: 13px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.one {
  grid-template-columns: 1fr;
}

.grid.two {
  grid-template-columns: 1fr 1fr;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-family: var(--font-hei);
  font-size: 13px;
  font-weight: 600;
}

input {
  width: 100%;
  height: 38px;
  padding: 7px 10px;
  border: 1px solid #c8ced8;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: 15px/1.25 var(--font-song);
}

select {
  width: 100%;
  height: 38px;
  padding: 7px 9px;
  border: 1px solid #c8ced8;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: 15px/1.25 var(--font-song);
}

input:focus,
select:focus {
  outline: 2px solid rgb(31 111 235 / 22%);
  border-color: var(--accent);
}

.date-picker {
  display: grid;
  grid-template-columns: 1.15fr 0.9fr 0.9fr;
  gap: 8px;
}

.hint {
  margin: -7px 0 0;
  color: var(--muted);
  font-family: var(--font-hei);
  font-size: 12px;
  line-height: 1.4;
}

.hint.error {
  color: #b42318;
}

button {
  height: 38px;
  padding: 0 14px;
  border: 1px solid #b8c0cc;
  border-radius: 6px;
  background: #fff;
  color: #1d2939;
  font-family: var(--font-hei);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  border-color: #98a2b3;
}

.primary {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}

.switch {
  display: inline-flex;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 8px;
  font-family: var(--font-hei);
  font-weight: 600;
}

.switch input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.preview-wrap {
  display: grid;
  gap: 18px;
  place-items: start center;
  overflow: auto;
  padding-bottom: 32px;
}

.cover-page {
  width: 210mm;
  height: 297mm;
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  background: var(--paper);
  box-shadow: 0 18px 60px rgb(16 24 40 / 20%);
  font-family: var(--font-song);
}

.cover-page.guides {
  background-image:
    linear-gradient(rgb(31 111 235 / 16%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(31 111 235 / 16%) 1px, transparent 1px);
  background-size: 10mm 10mm;
}

.top-caption {
  position: absolute;
  top: 28.1mm;
  left: 31.6mm;
  width: 124mm;
  height: 8mm;
  display: flex;
  align-items: center;
  gap: 2.2mm;
  font-family: var(--font-song);
  font-size: 15pt;
  font-weight: 700;
  line-height: 1;
}

.top-caption [data-field="year"] {
  min-width: 13.5mm;
  padding-left: 6mm;
  padding-right: 6mm;
  text-align: center;
  font-family: "Times New Roman", Times, serif;
  border-bottom: 0.28mm solid #111;
  padding-bottom: 0.8mm;
}

.title-block {
  position: absolute;
  top: 62.7mm;
  left: 27mm;
  width: 156mm;
  text-align: center;
  font-family: var(--font-hei);
  font-weight: 800;
}

.title-block.center-between {
  top: 85mm;
  transform: translateY(-50%);
}

.title-block.single-title {
  top: 87mm;
}

.title-block.two-main-titles {
  top: 87mm;
}

.title-line {
  min-height: 17.6mm;
  font-size: 24pt;
  font-weight: 700;
  line-height: 1.45;
  white-space: nowrap;
}

.title-line.is-empty {
  display: none;
}

.subtitle-line {
  margin-top: 1.2mm;
  font-size: 21pt;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.subtitle-line.is-empty {
  display: none;
}

.title-block.compact-subtitle .subtitle-line {
  margin-top: 0;
}

.meta-block {
  position: absolute;
  top: 132.5mm;
  left: 60.1mm;
  width: 90mm;
  font-family: var(--font-song);
}

.meta-row {
  height: 12.95mm;
  position: relative;
  display: grid;
  grid-template-columns: 27.5mm 62.1mm;
  align-items: center;
}

.label {
  font-family: var(--font-song);
  font-size: 15pt;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.value {
  height: 8mm;
  width: calc(100% + 2mm);
  margin-left: -2mm;
  padding-left: 1.5mm;
  border-bottom: 0.28mm solid #111;
  font-size: 15pt;
  font-family: var(--font-song);
  font-weight: 400;
  line-height: 7.8mm;
  white-space: nowrap;
}

.school-logo {
  position: absolute;
  left: 83.6mm;
  top: 259.5mm;
  width: 40mm;
  height: auto;
}

.minimal-page .caption-text,
.minimal-page .label {
  visibility: hidden;
}

.minimal-page .top-caption [data-field="year"],
.minimal-page .value {
  border-bottom-color: transparent;
}

.minimal-page .school-logo {
  display: none;
}

@media (max-width: 1020px) {
  .app {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .preview-wrap {
    place-items: start center;
  }
}

@media (max-width: 760px) {
  .app {
    padding: 14px;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .cover-page {
    transform: scale(0.58);
    transform-origin: top center;
    margin-bottom: -125mm;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body {
    width: 210mm;
    min-height: 297mm;
    height: auto;
    margin: 0;
    background: #fff;
  }

  .controls {
    display: none;
  }

  .app {
    display: block;
    min-height: 0;
    padding: 0;
  }

  .preview-wrap {
    display: block;
    width: 210mm;
    height: auto;
    padding: 0;
    overflow: visible;
  }

  .cover-page {
    width: 210mm;
    height: 297mm;
    margin: 0;
    box-shadow: none;
    transform: none;
    page-break-after: always;
    break-after: page;
  }

  .cover-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  .cover-page.guides {
    background-image: none;
  }
}
