:root {
  color-scheme: light;
  --ink: #212d48;
  --dim: #53627b;
  --stone: #dce4ee;
  --paper: #fff;
  --green: #28555b;
  --blue: #3655a4;
  font: 16px/1.55 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: #f2f6fb;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .44; }
button:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .upload:focus-within {
  outline: 2px solid #518174;
  outline-offset: 3px;
}
.masthead {
  max-width: 1440px;
  margin: auto;
  min-height: 64px;
  padding: 0 clamp(16px, 4vw, 56px);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--stone);
}
.brand {
  display: inline-flex;
  align-items: center;
  border: 1px solid #c4d6cc;
  border-radius: 11px 11px 11px 4px;
  overflow: hidden;
  background: #fbfdf9;
  color: #254b45;
  line-height: 1;
}
.brand-school {
  padding: .45rem .7rem .5rem;
  background: #dceacb;
  font-size: 1.25rem;
  font-weight: 800;
  font-style: italic;
  letter-spacing: -.055em;
}
.brand-class {
  display: flex;
  align-items: baseline;
  gap: 2px;
  padding: 0 .66rem;
  font-size: .81rem;
  font-weight: 730;
}
.brand-class strong { font-size: 1.24rem; font-weight: 820; letter-spacing: -.04em; }
main { max-width: 1440px; margin: auto; padding: clamp(16px, 2.5vw, 28px) clamp(16px, 4vw, 56px) 0; }
h1 { margin: 0; color: var(--dim); font-size: .9375rem; line-height: 1.25; font-weight: 670; }
p { margin: 0; }
.workspace { display: grid; grid-template-columns: minmax(320px, 430px) minmax(0, 1fr); gap: clamp(16px, 2.6vw, 32px); align-items: start; }
.sidebar { min-width: 0; display: grid; gap: 14px; }
.editor, .preview, .template-library { border: 1px solid var(--stone); border-radius: 16px; background: var(--paper); overflow: hidden; }
.editor, .template-library { padding: clamp(14px, 2vw, 22px); }
.template-categories { display: flex; flex-wrap: wrap; gap: 5px; padding: 5px; margin: 12px 0; border-radius: 10px; background: #edf2fa; }
.template-categories button { flex: 1 1 auto; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); font-size: .875rem; padding: 5px 6px; white-space: nowrap; }
.template-categories button[aria-pressed="true"] { background: #fff; border-color: #d8e0ef; color: var(--blue); font-weight: 700; }
.template-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; align-content: start; max-height: 220px; overflow: auto; padding: 3px; margin: -3px; scrollbar-width: thin; }
.template-list button { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 9px 11px; min-height: 47px; border: 1px solid var(--stone); border-radius: 10px; background: #f8faff; color: var(--ink); text-align: start; font-size: .875rem; line-height: 1.35; }
.template-list button:hover { background: #eef4ff; }
.template-list button[aria-pressed="true"] { border-color: #9eb3e3; background: #e8efff; color: #274590; }
.template-list small { color: var(--dim); font-size: .75rem; font-variant-numeric: tabular-nums; }
.template-load { display: grid; gap: 7px; margin-top: 12px; color: var(--green); font-size: .8125rem; }
.load-heading { display: flex; justify-content: space-between; gap: 9px; }
#load-percent { font-variant-numeric: tabular-nums; }
#load-progress { width: 100%; height: 7px; accent-color: var(--green); }
#retry-template { justify-self: start; border: 1px solid var(--stone); background: #fff; color: var(--green); border-radius: 7px; padding: 3px 9px; }
.template-options { border-top: 1px solid var(--stone); padding-top: 10px; }
.gloss-option { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.gloss-option select { min-width: 0; max-width: 100%; padding: 4px 7px; border: 1px solid var(--stone); border-radius: 7px; background: #fff; color: var(--ink); }
.gloss-option select:disabled { color: var(--dim); background: #f2f6fb; }
.editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; }
.editor-heading::-webkit-details-marker { display: none; }
.editor-heading::after { content: ""; width: 8px; height: 8px; margin-right: 3px; border: solid var(--dim); border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.editor[open] .editor-heading::after { transform: translateY(2px) rotate(225deg); }
.editor > .upload { width: fit-content; margin-top: 12px; }
h2 { margin: 0; font-size: 17px; font-weight: 720; }
.upload {
  position: relative;
  display: grid;
  justify-items: start;
  gap: 3px;
  cursor: pointer;
  padding: 6px 10px;
  border: 1px solid #c9dedc;
  border-radius: 9px;
  background: #f0f8f5;
  color: #274e43;
}
.upload:hover, .upload.drag { background: #e3ede2; border-color: var(--green); }
.upload input { position: absolute; width: 100%; height: 100%; inset: 0; cursor: pointer; opacity: 0; }
.upload small { color: #52685d; font-size: 12px; }
.upload strong { font-size: .875rem; }
.field { display: grid; gap: 8px; margin-top: 18px; }
.field label { font-weight: 650; }
.field input, .page-fields input:not([type=checkbox]), textarea {
  background: #fff;
  width: 100%;
  border: 1px solid var(--stone);
  border-radius: 8px;
  color: var(--ink);
  padding: 10px 12px;
}
.page-fields { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 10px; font-size: 13px; }
.page-fields label { display: flex; align-items: center; gap: 5px; }
.page-fields input[type=checkbox] { margin: 0; accent-color: var(--green); }
.page-fields input:not([type=checkbox]) { min-width: 0; flex: 1 0 100%; }
.field-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; justify-content: space-between; }
.edit-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; }
.text-button { color: #3c6859; background: transparent; padding: 1px 4px; border: 0; font-size: 12px; }
.text-button:hover { text-decoration: underline; }
.find-panel { display: grid; gap: 6px; padding: 8px; border-radius: 8px; background: #edf2e9; }
.find-panel input { padding: 6px 9px; font-size: 13px; }
.find-actions { justify-content: flex-end; }
textarea { min-height: 225px; line-height: 1.6; resize: vertical; tab-size: 4; }
#count { justify-self: end; font-variant-numeric: tabular-nums; color: var(--dim); font-size: 11px; }
.settings { display: flex; align-items: center; gap: 12px; margin-top: 14px; min-height: 30px; }
.settings label { font-size: 13px; font-weight: 650; white-space: nowrap; }
.settings input { min-width: 40px; width: 100%; accent-color: var(--green); }
.settings span { min-width: 45px; text-align: end; font-size: 12px; font-variant-numeric: tabular-nums; color: #466357; }
.editor select { min-width: 0; padding: 5px 8px; border: 1px solid var(--stone); border-radius: 7px; color: var(--ink); background: #fff; }
.status { color: var(--dim); font-size: 12px; overflow-wrap: anywhere; }
.status:not(:empty) { margin-top: 12px; }
.status.error { color: #9b392d; }
.preview-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; min-height: 69px; padding: 12px clamp(16px, 3vw, 25px); }
.output-button { display: grid; place-items: center; padding: 0; width: 38px; height: 38px; border: 1px solid #d6dcd0; border-radius: 8px; background: #fffefa; color: var(--green); }
.output-button svg { width: 19px; height: 19px; }
.output-button:hover:not(:disabled) { background: #edf2e9; }
.preview-area { background: #e9eff7; border-top: 1px solid var(--stone); padding: clamp(15px, 3vw, 30px) clamp(8px, 2.5%, 24px); text-align: center; }
#paper { display: block; width: min(100%, 624px); height: auto; margin: auto; background: #fff; box-shadow: 0 3px 18px #283c3122; border-radius: 2px; touch-action: pan-y pinch-zoom; }
#empty { display: grid; place-items: center; min-height: 225px; color: var(--dim); }
.preview-actions { display: flex; align-items: center; gap: clamp(10px, 2vw, 20px); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; }
.pagination button { width: 31px; height: 31px; border-radius: 7px; border: 1px solid #d6dcd0; background: #fffefa; color: var(--green); }
.pagination button:hover:not(:disabled) { background: #f3f6ef; }
#pages { text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; min-width: 35px; }
footer { margin: 18px auto; max-width: 1440px; padding: 0 clamp(16px, 5vw, 77px); color: var(--dim); font-size: 12px; }
#print-pages { display: none; }
@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  textarea { min-height: 155px; }
  .masthead { min-height: 54px; }
  .preview-bar { min-height: 57px; }
}
@media print {
  @page { size: A4; margin: 0; }
  html, body { margin: 0; padding: 0; background: #fff; }
  body.printing-worksheet > :not(#print-pages) { display: none !important; }
  body.printing-worksheet #print-pages { display: block; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-sheet { display: block; width: 210mm; height: 296.9mm; break-after: page; break-inside: avoid; }
  .print-sheet:last-child { break-after: auto; }
  .print-sheet text { white-space: pre; font-kerning: none; font-variant-ligatures: none; }
}
