@font-face {
  font-family: 'Seed Slab';
  src: url('fonts/seed-slab-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #efe6d2;
  --paper: #fbf7ee;
  --ink: #1f2a1c;
  --soft: #4a5045;
  --line: #c9bc9f;
  --green: #2c5a31;
  --green-ink: #ffffff;
  --rust: #8a3712;
  --warn-bg: #fbe9d9;
  --focus: #1d5fa8;
  --r: 6px;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --slab: 'Seed Slab', 'Rockwell', 'Roboto Slab', Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a14;
    --paper: #29251d;
    --ink: #efe7d4;
    --soft: #c8bfac;
    --line: #4d4536;
    --green: #9ccc94;
    --green-ink: #13200f;
    --rust: #f0a27a;
    --warn-bg: #3d2a1c;
    --focus: #8cc0ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--sans);
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-family: var(--slab); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: clamp(30px, 6vw, 46px); margin: 0 0 8px; color: var(--green); }
h2 { font-size: 24px; margin: 0 0 12px; }
h3 { font-size: 19px; margin: 24px 0 6px; }
a { color: var(--green); text-underline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 10; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.hero { padding-top: 28px; padding-bottom: 12px; }
.lede { margin: 0; max-width: 62ch; font-size: 18px; }

.bar { margin: 8px 0; padding: 10px 14px; background: var(--paper); border-radius: var(--r); border: 1px solid var(--line); }
.bar.warn, .msg.warn { background: var(--warn-bg); }
.msg { margin: 8px 0; }
.msg.warn { padding: 8px 12px; border-radius: var(--r); }
.err { color: var(--rust); font-weight: 600; }

.btn {
  font: inherit; font-size: 16px; font-weight: 600;
  min-height: 44px; padding: 8px 16px;
  border-radius: var(--r); border: 2px solid var(--green);
  background: var(--paper); color: var(--green); cursor: pointer;
}
.btn.primary { background: var(--green); color: var(--green-ink); }
.btn.quiet { border-color: var(--line); color: var(--ink); }
.btn.small { min-height: 44px; padding: 6px 12px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:hover:not(:disabled) { border-color: var(--ink); }

input, select, textarea {
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 4px;
  min-height: 44px; padding: 8px 10px; width: 100%;
}
input::placeholder, textarea::placeholder { color: #6f6a5c; font-style: italic; }
@media (prefers-color-scheme: dark) { input::placeholder, textarea::placeholder { color: #a39b88; } }
input:disabled, select:disabled { opacity: 0.8; }
label > span { display: block; font-weight: 600; font-size: 16px; margin-bottom: 2px; }

/* ---------- the list ---------- */
.tool { display: grid; gap: 28px; padding-top: 12px; padding-bottom: 28px; }
#list-sec { container-type: inline-size; }
.sec-head { display: flex; align-items: baseline; gap: 12px; }
.sec-head h2 { margin-bottom: 8px; }
.count { color: var(--soft); }
.cols { display: none; }
#rows { border-top: 2px solid var(--ink); }
.row { border-bottom: 1px solid var(--line); }
.sum {
  display: block; width: 100%; text-align: left; font: inherit; font-size: 17px; color: var(--ink);
  background: none; border: 0; padding: 10px 2px; min-height: 48px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row.ghost .sum { color: var(--soft); }
.row:not(.open) .fields { display: none; }
.row.open .sum { display: none; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 10px 0 12px; }
.f-variety, .f-sow, .f-harvest { grid-column: 1 / -1; }
.f-n input { max-width: 7em; }
.del {
  justify-self: start; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--r);
  background: none; color: var(--rust); cursor: pointer; display: grid; place-items: center;
}
.del svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.2; fill: none; }
.row.ghost .fields { padding-top: 12px; }
.list-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
#paste { margin-top: 14px; }
#paste summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; color: var(--green); }
#paste label { display: block; margin: 6px 0 4px; }
#paste textarea { min-height: 120px; font-size: 16px; resize: vertical; margin-bottom: 8px; }
.jump { margin: 12px 0 0; }

@container (min-width: 760px) {
  .cols {
    display: grid; grid-template-columns: var(--grid); gap: 6px;
    font-weight: 700; font-size: 16px; padding: 0 0 6px;
  }
  .sum { display: none !important; }
  .row .fields, .row:not(.open) .fields { display: grid; grid-template-columns: var(--grid); gap: 6px; padding: 5px 0; }
  .f-variety, .f-sow, .f-harvest { grid-column: auto; }
  .fields .lab { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fields input { padding: 6px 8px; }
  .f-n input { max-width: none; }
  .del { justify-self: center; }
  .row.ghost .fields { padding-top: 5px; }
  .row.ghost .del { visibility: hidden; display: grid !important; }
  .jump { display: none; }
}
#list-sec { --grid: minmax(0, 1.35fr) minmax(0, 0.95fr) minmax(0, 1.6fr) minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 0.9fr) 4.6em 44px; }

/* ---------- packets ---------- */
#packets-sec { display: grid; gap: 16px 32px; align-items: start; }
#packets-sec .pk-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#packets-sec .pk-head h2 { margin: 0; }
#print-top { display: none; }
.settings { display: grid; gap: 12px; }
.custom { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.summary { font-size: 19px; font-weight: 600; margin: 4px 0 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.pager { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.viewer { position: relative; overflow: hidden; width: 100%; min-height: 200px; }
#sheets { transform: scale(var(--k, 0.5)); transform-origin: 0 0; width: 193.5mm; }
@media (min-width: 900px) {
  #packets-sec { grid-template-columns: minmax(300px, 380px) 1fr; }
  #packets-sec .pk-head { grid-column: 1 / -1; }
  #print-top { display: inline-flex; }
  .side { grid-column: 1; }
  #result { margin-top: 8px; }
  .viewer { grid-column: 2; }
}

/* the printed sheet (true size; scaled on screen) */
.sheet {
  position: relative; width: 193.5mm; height: 262mm; background: #fff; color: #1b1b1b;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); overflow: hidden;
  -webkit-print-color-adjust: exact; print-color-adjust: exact; contain: strict;
}
.sheet:not(.cur) { display: none; }
.sheet-err { padding: 12mm 0; font: 14pt/1.4 var(--sans); }
@media screen { .sheet-err { display: none !important; } }
.sh-head {
  position: absolute; left: 0; right: 0; top: 0; height: 7mm;
  display: flex; align-items: center; justify-content: space-between; gap: 3mm;
  font: 8pt/1.2 var(--sans); color: #222; padding: 0 1mm;
}
.sh-check { display: flex; align-items: center; gap: 2mm; }
.sh-check svg { flex: none; }
.slot { position: absolute; }
.net { position: absolute; left: 0; top: 0; }
.net-svg { position: absolute; left: 0; top: 0; overflow: visible; }
.cut { stroke: #1b1b1b; stroke-width: 0.35; fill: none; }
.fold { stroke: #555; stroke-width: 0.3; stroke-dasharray: 2 1.4; fill: none; }
.glue { fill: #e1e1e1; }
.glue-t { font: 2.6px var(--sans); fill: #4d4d4d; letter-spacing: 0.3px; }
.frame { fill: none; stroke: #2c5a31; stroke-width: 0.18; }
.check { stroke: #000; stroke-width: 0.5; }

/* folding steps: drawings and words, on the page and on paper */
.fg { list-style: none; margin: 0; padding: 0; counter-reset: fg; }
.fg li { counter-increment: fg; display: flex; align-items: flex-start; }
.fg li > span::before { content: counter(fg) ". "; font-weight: 700; }
.fg-svg { flex: none; overflow: visible; }
.fg-paper { fill: #fff; }
.fg-cut { fill: none; stroke: #1b1b1b; stroke-width: 0.45; stroke-linejoin: round; }
.fg-fold { stroke: #555; stroke-width: 0.35; stroke-dasharray: 1.2 0.8; }
.fg-paper.fg-cut { fill: #fff; }
.fg-glue { fill: #d4d4d4; stroke: none; }
.fg-in { stroke: #555; stroke-width: 0.3; }
.fg-ghost { fill: none; stroke: #8a8a8a; stroke-width: 0.3; stroke-dasharray: 0.8 0.8; }
.fg-arrow { fill: none; stroke: #7a3416; stroke-width: 0.6; stroke-linecap: round; stroke-linejoin: round; }
.fg-seed { fill: #7a3416; }
.fg-lab { font: 2.3px var(--sans); fill: #333; }
.fg-sm { font-size: 1.6px; }
.fg-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 24px; margin: 16px 0; }
.fg-info li { gap: 12px; }
.fg-info .fg-svg { width: 88px; height: 144px; background: #fff; border-radius: var(--r); padding: 4px; box-sizing: content-box; }
/* the strip under the packets on a sheet */
.fg-strip { position: absolute; left: 0; right: 0; font: 7.5pt/1.3 var(--sans); color: #1b1b1b; }
.fg-strip .fg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3mm; height: 100%; }
.fg-strip li { gap: 1.5mm; height: 100%; }
.fg-strip .fg-svg { height: var(--gh); width: calc(var(--gh) * 22 / 36); }
/* the page of folding steps when the packets fill the sheet */
.sheet-guide { padding: 12mm 6mm 0; font: 11pt/1.4 var(--sans); }
.sheet-guide h3 { font: 700 16pt/1.2 var(--slab); color: #23452a; margin: 0 0 3mm; }
.sheet-guide p { margin: 0 0 8mm; }
.sheet-guide .fg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6mm; }
.sheet-guide li { flex-direction: column; gap: 3mm; }
.sheet-guide .fg-svg { width: 33mm; height: 54mm; }

.pc {
  position: absolute; overflow: hidden; display: flex; flex-direction: column;
  font: var(--b)/1.25 var(--sans); color: #1b1b1b; contain: strict;
  overflow-wrap: normal; word-break: normal; hyphens: manual;
}
/* a packet turned a quarter turn on the sheet: the panel box is its real place, and the text runs down it */
.pc.vert { writing-mode: vertical-rl; text-orientation: sideways; }
.pc p { margin: 0; }
.pc.front:not(.notes) { text-align: center; }
/* the name block sits in the middle of the space above the swap line, however many lines it has */
.pc.front:not(.notes)::before, .pc.front:not(.notes)::after { content: ''; flex: 1 1 0; }
.pc.front:not(.notes)::after { order: 1; }
.pc.front:not(.notes) .t-swap { order: 2; }
.t-plant { font-size: calc(var(--b) * 0.95); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #7a3416; }
.t-variety { font: 700 calc(var(--b) * 1.85)/1.08 var(--slab); color: #23452a; margin-block: 0.12em 0.18em !important; }
.t-source { font-style: italic; font-size: calc(var(--b) * 0.92); }
.t-swap { margin-block-start: auto !important; font-size: calc(var(--b) * 0.85); padding-block-start: 0.35em; border-block-start: 0.2mm solid #2c5a31; text-align: center; }
.notes .t-variety, .notes .t-plant, .notes .t-source { text-align: center; }
.t-sow, .t-harvest, .t-grower { margin-block-start: 0.45em !important; }
.t-sow b, .t-harvest b, .t-grower b { color: #7a3416; }
.notes .t-plant { margin-block-start: 0.4em !important; }
.pc.over { overflow-wrap: anywhere; }
.w { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 1.5mm; margin-block-start: 0.9em !important; text-align: start; }
.w span { font-weight: 700; color: #7a3416; font-size: calc(var(--b) * 0.9); }
.w i { flex: 1 0 40%; border-block-end: 0.25mm solid #555; block-size: 1.2em; }
.w i + i { flex-basis: 100%; block-size: 1.6em; }
.pc.blank { justify-content: center; }
.pc.blank > * { margin-block-end: 0 !important; }
.pc.blank .w { margin-block-start: 1.5em !important; }
.pc.blank .w:first-child { margin-block-start: 0 !important; }
.pc.blank.front .w-variety i { block-size: 2em; }
.blank.front { text-align: start !important; }
#measure { position: absolute; left: -10000px; top: 0; width: 200mm; height: 200mm; overflow: hidden; visibility: hidden; contain: strict; }

/* ---------- earlier lists, dialogs, info ---------- */
.earlier { margin-bottom: 28px; }
.earlier summary { cursor: pointer; font: 700 20px var(--slab); min-height: 44px; display: flex; align-items: center; gap: 6px; }
#kept, #bin { list-style: none; padding: 0; margin: 8px 0 0; }
#kept li, #bin li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
#kept p, #bin p { margin: 0; }
.when { color: var(--soft); }
.kept-act { display: flex; gap: 8px; }
.ask {
  position: fixed; left: 50%; top: 30%; transform: translateX(-50%); z-index: 20;
  width: min(92vw, 440px); background: var(--paper); border: 2px solid var(--ink); border-radius: var(--r);
  padding: 16px 18px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}
.ask p { margin: 0 0 12px; }
.ask p:last-child { margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 15;
  width: max-content; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r);
  pointer-events: none;
}
.toast.has-undo { pointer-events: auto; }
.toast .undo { font: inherit; font-weight: 700; color: inherit; background: none; border: 2px solid currentColor; border-radius: 4px; min-height: 44px; padding: 4px 14px; margin-left: 8px; cursor: pointer; }
.info { padding-top: 12px; padding-bottom: 32px; }
.info > * { max-width: 760px; }
.info h2 { margin-top: 32px; }
.steps { padding-left: 1.4em; }
.steps li { margin: 6px 0; }
.faq p { margin: 0 0 8px; }

footer { border-top: 1px solid var(--line); padding: 20px 0 32px; color: var(--soft); }
.sb-footer p { margin: 0 0 10px; font-size: 16px; }
.sb-more a { color: var(--soft); }
.sb-credit a { color: var(--green); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* ---------- print: only the sheets ---------- */
@page { margin: 8mm; }
@media print {
  html, body { background: #fff !important; color: #000; font-size: 12pt; }
  main > .hero, main > .notes-top, main > .earlier, main > .info, #list-sec, #packets-sec .pk-head, .side, .earlier, .info, footer, .skip, .toast, .ask { display: none !important; }
  main, .tool, #packets-sec, .viewer { display: block !important; margin: 0 !important; padding: 0 !important; max-width: none !important; width: auto !important; height: auto !important; overflow: visible !important; }
  #sheets { transform: none !important; }
  .sheet { display: block !important; box-shadow: none; break-after: page; page-break-after: always; }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
}
