:root {
  color-scheme: light;
  font: 100%/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1d2e25;
  background: #edf2ea;
  --accent: #225c45;
  --muted: #52665a;
  --line: #d7e2d7;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.workspace { max-width: 1140px; margin: auto; padding: 3rem 1.5rem 2.5rem; }
.intro { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.65rem; }
.brand-mark {
  display: grid; place-items: center; width: 3.55rem; height: 3.55rem; flex-shrink: 0;
  border-radius: 1rem; background: #d6e7d6; color: #214e3a;
  font: italic 600 1.8rem Georgia, serif;
}
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 4vw, 2.25rem); line-height: 1.16; letter-spacing: .02em; }
.intro p { color: var(--muted); margin-top: .3rem; }
.columns { display: grid; grid-template-columns: minmax(0, .86fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.panel { min-width: 0; padding: 1.35rem; border: 1px solid var(--line); border-radius: 1.25rem; background: #fff; }
.label-row, .preview-heading, .repetitions { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.section-title, h2, .repetitions label { font-weight: 700; font-size: 1rem; }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #318260; outline-offset: 3px; }
textarea, input[type="text"], select {
  color: inherit; background: #f8faf7; border: 1px solid var(--line); border-radius: .65rem;
  padding: .65rem .8rem; min-width: 0;
}
textarea { width: 100%; resize: vertical; min-height: 8.5rem; margin-top: .45rem; }
::placeholder { color: #697e70; opacity: 1; }
.text-button { color: var(--accent); border: 0; padding: .35rem 0; background: none; font-size: .9rem; font-weight: 650; }
.hint { margin-top: .3rem; color: var(--muted); font-size: .875rem; }
fieldset { padding: 0; margin: 1.15rem 0 0; min-width: 0; border: 0; }
legend { padding: 0; margin-bottom: .5rem; }
.grid-options, .fields, .file-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.grid-options label { position: relative; cursor: pointer; }
.grid-options input { opacity: 0; position: absolute; }
.grid-options span {
  display: flex; gap: .4rem; align-items: center; justify-content: center;
  min-height: 3rem; padding: .45rem .3rem; border: 1px solid var(--line); border-radius: .7rem;
  font-size: .875rem; font-weight: 600; text-align: center;
}
.grid-options input:checked + span { background: #e6f0e6; border-color: #47785c; color: #194633; }
.grid-options input:focus-visible + span { outline: 2px solid #318260; outline-offset: 3px; }
.rule-icon {
  display: inline-block; flex: 0 0 1.3rem; height: .8rem;
  background: repeating-linear-gradient(to bottom, #6b9677 0 1px, transparent 1px 4px);
}
.rule-icon.cells { background-image: repeating-linear-gradient(to right,#6b9677 0 1px,transparent 1px 5px), repeating-linear-gradient(to bottom,#6b9677 0 1px,transparent 1px 4px); }
.repetitions { margin-top: .8rem; }
select {
  appearance: none; padding-right: 2rem; min-height: 2.75rem;
  background-image: linear-gradient(45deg, transparent 50%, #52665a 50%), linear-gradient(135deg, #52665a 50%, transparent 50%);
  background-repeat: no-repeat; background-size: 5px 5px; background-position: right 15px center, right 10px center;
}
small { color: var(--muted); font-size: .82rem; font-weight: 400; margin-left: .25rem; }
.fields label { display: grid; gap: .3rem; font-size: .875rem; }
.fields input { width: 100%; min-height: 2.75rem; }
.primary, .secondary {
  display: flex; justify-content: center; align-items: center; min-height: 3rem;
  padding: .55rem .8rem; border: 1px solid var(--accent); border-radius: .7rem;
  font-weight: 700; text-align: center; text-decoration: none;
}
.primary { background: var(--accent); color: #fff; }
.secondary { background: white; color: var(--accent); }
.primary:hover { background: #194735; }
.primary:disabled, .pagination button:disabled { opacity: .56; cursor: default; }
.editor > .primary { width: 100%; margin-top: 1.15rem; }
.error { color: #942d35; margin-top: .75rem; font-size: .92rem; }
.preview-heading { margin-bottom: .85rem; }
.preview-heading span { color: var(--muted); font-size: .875rem; }
.paper-stage { padding: clamp(.65rem, 2vw, 1.3rem); background: #e8efe7; border-radius: .8rem; }
.paper { background: white; width: 100%; aspect-ratio: 210 / 297; box-shadow: 0 2px 11px #263b2b21; }
canvas { display: block; width: 100%; height: auto; }
.empty-preview { display: grid; align-content: center; justify-items: center; gap: 1rem; height: 100%; color: var(--muted); font-size: .9rem; }
.empty-rule { width: 36%; height: 31px; background: repeating-linear-gradient(to bottom,#a1c2a3 0 1px,transparent 1px 10px); }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .7rem; font-size: .875rem; }
.pagination button { border: 1px solid var(--line); border-radius: .55rem; padding: .4rem .6rem; background: white; color: var(--accent); }
.file-actions { margin-top: .85rem; }
.open-pdf { display: inline-block; margin-top: .35rem; }
.secondary:disabled { opacity: .56; cursor: default; }
.print-hint { margin-top: .6rem; }
@media (max-width: 740px) {
  .workspace { padding: 1.4rem .8rem 1.7rem; }
  .intro { margin: 0 .2rem 1rem; }
  .columns { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .panel { padding: 1rem; }
  .paper-stage { padding: .65rem; }
}
