:root {
  color-scheme: light;
  font-family: "Segoe UI", Arial, sans-serif;
  color: #1a2821;
  background: #f4f7f4;
  --ink: #1a2821;
  --muted: #4c5f55;
  --border: #d9e3dc;
  --green: #216445;
  --dark: #184d34;
  --tint: #edf5ef;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
.top { background: #fff; border-bottom: 1px solid var(--border); }
.top-inner { margin: 0 auto; max-width: 1144px; padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: flex; align-items: center; }
.brand img { width: min(194px, 52vw); display: block; }
.nav-link { font-size: .9rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.nav-link span { margin-left: 4px; color: var(--green); }
.nav-link:hover { text-decoration: underline; }
main { max-width: 1144px; margin: auto; padding: 39px 28px 58px; }
.intro { margin-bottom: 26px; }
.intro p { color: var(--muted); margin: 8px 0 0; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2.1rem, 5vw, 3.25rem); line-height: 1.06; letter-spacing: -.045em; margin-bottom: 0; }
h2 { font-size: 1.16rem; letter-spacing: -.018em; margin-bottom: 15px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(255px, 1fr); gap: 20px; align-items: start; }
.editor { display: grid; gap: 16px; }
.card { background: #fff; padding: 21px; border: 1px solid var(--border); border-radius: 15px; min-width: 0; }
.drop { display: flex; align-items: center; gap: 12px; padding: 16px 13px; border: 1px dashed #94ab9b; border-radius: 10px; background: #f7faf7; }
.drop.active { border-color: var(--green); background: #ddf0e3; }
.file-symbol { display: grid; place-items: center; flex: 0 0 36px; height: 36px; border-radius: 9px; background: #dfeee3; color: var(--dark); font-size: 1.16rem; }
.drop-copy { flex: 1; overflow-wrap: anywhere; }
.drop-copy strong { display: block; font-size: .91rem; }
.drop-copy small { display: block; color: var(--muted); margin-top: 3px; }
button, input, select { font: inherit; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 10px; min-height: 40px; border-radius: 8px; padding: 8px 12px; font-size: .87rem; font-weight: 650; text-decoration: none; border: 1px solid transparent; cursor: pointer; }
.button:disabled { opacity: .5; cursor: wait; }
.secondary { background: #fff; border-color: #b7cbbd; color: var(--dark); }
.secondary:hover { background: var(--tint); }
.primary { background: var(--green); color: #fff; }
.primary:hover { background: var(--dark); }
.danger { background: #ac302d; color: #fff; }
.danger:hover { background: #882523; }
.file-label { position: relative; white-space: nowrap; }
.file-label input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.file-label:focus-within, :focus-visible { outline: 3px solid #3a805f; outline-offset: 3px; }
.fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 13px 14px; }
.fields label { display: block; min-width: 0; font-size: .86rem; font-weight: 650; }
.wide { grid-column: 1 / -1; }
.optional { color: var(--muted); font-weight: 400; }
input:not([type=checkbox], [type=file]), select { display: block; width: 100%; min-width: 0; min-height: 40px; color: var(--ink); padding: 8px 10px; border: 1px solid #bfcfc4; border-radius: 8px; background: #fff; }
.fields input, .fields select { margin-top: 5px; font-size: .9rem; }
input::placeholder { color: #586b60; }
.card-head, .add, .roster-bar { display: flex; align-items: center; gap: 9px; }
.card-head { justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.count { font-size: .79rem; font-weight: 650; color: var(--dark); background: var(--tint); border-radius: 999px; padding: 5px 9px; white-space: nowrap; }
.add input { flex: 1; font-size: .9rem; }
.empty { margin: 12px 0 0; color: var(--muted); font-size: .88rem; }
.roster-bar { margin: 9px -3px 4px; flex-wrap: wrap; }
.text-button { background: transparent; border: 0; color: var(--dark); cursor: pointer; font-size: .83rem; text-decoration: underline; text-underline-offset: 3px; padding: 6px; }
#roster, #history-list { list-style: none; padding: 0; margin: 0; }
#roster { max-height: 350px; overflow: auto; scrollbar-gutter: stable; }
#roster li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-top: 1px solid #e5ece7; gap: 4px; }
#roster label { display: flex; align-items: center; padding: 8px 2px; gap: 8px; font-size: .86rem; min-height: 40px; overflow-wrap: anywhere; }
input[type=checkbox] { flex: 0 0 auto; width: 17px; height: 17px; accent-color: var(--green); }
.summary { position: sticky; top: 14px; }
.preview { padding: 15px; background: #f9fbf9; border: 1px solid var(--border); border-radius: 9px; overflow-wrap: anywhere; }
.preview img { display: block; width: 164px; max-width: 100%; margin-bottom: 14px; }
.preview h3 { font-size: 1rem; margin-bottom: 7px; }
.preview p { margin: 0; font-size: .83rem; line-height: 1.45; }
.preview-meta { color: var(--muted); }
.preview-line { height: 1px; background: var(--border); margin: 13px 0 9px; }
.preview-prof { font-weight: 650; }
.hint { margin: 14px 0; font-size: .85rem; color: var(--muted); line-height: 1.45; }
.generate { width: 100%; justify-content: space-between; }
.status { margin: 10px 0 0; font-size: .86rem; color: var(--dark); line-height: 1.4; overflow-wrap: anywhere; }
.status.error { color: #9d2d2a; }
.history { margin-top: 20px; scroll-margin-top: 12px; }
.history h2 { margin-bottom: 7px; }
.history li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.history li:last-child { border-bottom: 0; padding-bottom: 0; }
.history li strong { display: block; font-size: .93rem; }
.history li small { display: block; color: var(--muted); margin-top: 4px; }
.history .actions { display: flex; align-items: center; gap: 6px; }
.dialog-head, .dialog-foot, .confirm div { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
dialog { color: var(--ink); border: 1px solid var(--border); border-radius: 13px; }
dialog::backdrop { background: #15251dcc; }
#pdf-dialog { width: min(920px, 95vw); height: min(880px, 94vh); padding: 14px; }
#pdf-dialog[open] { display: flex; flex-direction: column; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 1rem; }
.dialog-foot, .confirm div { justify-content: flex-end; flex-wrap: wrap; }
#pdf-frame { flex: 1; width: 100%; border: 1px solid var(--border); border-radius: 7px; }
#delete-dialog { max-width: min(400px, 94vw); padding: 22px; }
.confirm p { font-size: .92rem; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 780px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .summary { position: static; }
}
@media (max-width: 510px) {
  main { padding: 27px 14px 42px; }
  .top-inner { padding: 10px 14px; }
  .card { padding: 15px; }
  .drop { display: grid; grid-template-columns: 36px minmax(0, 1fr); }
  .file-label { grid-column: 2; justify-self: start; }
  .history li { align-items: flex-start; flex-direction: column; }
}

#pdf-frame { background: #e9efeb; min-height: 0; overflow: auto; padding: 9px; }
#pdf-frame canvas { display: block; width: min(100%, 620px); height: auto; margin: 0 auto 10px; background: #fff; }
#print-pages { display: none; }
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #fff; margin: 0; }
  body.printing > :not(#print-pages) { display: none !important; }
  body.printing #print-pages { display: block; }
  body.printing #print-pages canvas { display: block; width: 210mm; height: 297mm; break-after: page; }
  body.printing #print-pages canvas:last-child { break-after: auto; }
  body.printing ::backdrop { display: none; }
}
