/* add-header-footer-to-pdf */
.tool-wrapper[data-tool="add-header-footer-to-pdf"] { width: 100%; max-width: 1000px; margin: 0 auto; padding: 0 20px; box-sizing: border-box; }
.hdf-app { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.hdf-app > * { width: 100%; max-width: 960px; margin-left: auto; margin-right: auto; box-sizing: border-box; }
.hdf-app .action-buttons { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 auto; justify-content: center; }
.hdf-app .file-box, .hdf-app .tool-settings { display: block; margin: 0 auto; }
.hdf-app .file-row { display: flex; align-items: center; gap: 12px; }
.hdf-app .file-name { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.hdf-app .file-size { color: #64748b; white-space: nowrap; }
.hdf-app .remove-file { background: none; border: 0; color: #dc2626; cursor: pointer; font-size: 1rem; padding: 4px; }
.hdf-app select, .hdf-app input[type="text"], .hdf-app input[type="number"], .hdf-app textarea { padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: inherit; box-sizing: border-box; max-width: 100%; }
.hdf-busy { text-align: center; color: #475569; font-weight: 500; }
.hdf-result { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 14px 16px; }
.hdf-result p { margin: 0 0 8px; }
.hdf-done { font-weight: 600; color: #067647; }
.tool-wrapper[data-tool="add-header-footer-to-pdf"] .info-note { margin-top: 18px; }
html[data-theme="dark"] .hdf-app select, html[data-theme="dark"] .hdf-app input[type="text"], html[data-theme="dark"] .hdf-app input[type="number"], html[data-theme="dark"] .hdf-app textarea,
html[data-theme="dark-contrast"] .hdf-app select, html[data-theme="dark-contrast"] .hdf-app input[type="text"], html[data-theme="dark-contrast"] .hdf-app input[type="number"], html[data-theme="dark-contrast"] .hdf-app textarea { background: #0f172a; border-color: #334155; }
html[data-theme="dark"] .hdf-busy, html[data-theme="dark-contrast"] .hdf-busy, html[data-theme="dark"] .hdf-app .file-size, html[data-theme="dark-contrast"] .hdf-app .file-size { color: #cbd5e1; }
html[data-theme="dark"] .hdf-result, html[data-theme="dark-contrast"] .hdf-result { background: #052e16; border-color: #166534; color: #dcfce7; }
html[data-theme="dark"] .hdf-done, html[data-theme="dark-contrast"] .hdf-done { color: #86efac; }
html[data-theme="dark"] .hdf-result a, html[data-theme="dark-contrast"] .hdf-result a { color: #93c5fd; }
.hdf-presets, .hdf-tokens { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.hdf-presets > span, .hdf-tokens > span { font-weight: 600; margin-inline-end: 4px; }
.hdf-chip { border: 1px solid #c7d2fe; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .88rem; cursor: pointer; }
.hdf-chip:hover { background: #e0e7ff; }
.hdf-zone h3 { font-size: 1rem; margin: 0 0 6px; }
.hdf-zone + .hdf-zone { margin-top: 12px; }
.hdf-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 4px; }
.hdf-row input { width: 100%; }
.hdf-tokens { margin-top: 12px; }
.hdf-bates { border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px 14px 14px; margin: 0 0 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; opacity: .7; }
.hdf-bates.is-used { opacity: 1; border-color: #a5b4fc; }
.hdf-bates legend { font-weight: 600; padding: 0 4px; }
.hdf-bates label, .hdf-style label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.hdf-bates input, .hdf-style input, .hdf-style select { width: 100%; }
.hdf-style { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.hdf-style input[type="color"] { height: 38px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; }
.hdf-preview { margin: 16px auto 0; max-width: 360px; aspect-ratio: 210 / 297; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; display: flex; flex-direction: column; justify-content: space-between; padding: 10px 12px; box-shadow: 0 2px 8px rgba(0,0,0,.06); color: #111827; }
.hdf-pv-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; font-size: .68rem; min-height: 1.2em; }
.hdf-pv-row span:nth-child(2) { text-align: center; }
.hdf-pv-row span:nth-child(3) { text-align: end; }
.hdf-pv-body { flex: 1; margin: 10px 0; background: repeating-linear-gradient(#f1f5f9 0 6px, transparent 6px 14px); }
.hdf-note { color: #a15c07; }
@media (max-width: 600px) { .hdf-row { grid-template-columns: 1fr; } }
html[data-theme="dark"] .hdf-chip, html[data-theme="dark-contrast"] .hdf-chip { background: #312e81; border-color: #4338ca; color: #e0e7ff; }
html[data-theme="dark"] .hdf-bates, html[data-theme="dark-contrast"] .hdf-bates { border-color: #334155; }
html[data-theme="dark"] .hdf-note, html[data-theme="dark-contrast"] .hdf-note { color: #fcd34d; }
/* several header/footer sets, each for its own page range */
.hdf-sections { display: flex; flex-direction: column; gap: 14px; }
.hdf-sec { border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px 14px 14px; background: #fafbff; }
.hdf-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.hdf-sec-title { font-size: 1.02rem; margin: 0; }
.hdf-sec-remove { background: none; border: 0; color: #dc2626; cursor: pointer; font-size: 1rem; padding: 4px 6px; border-radius: 6px; }
.hdf-sec-remove:hover { background: #fee2e2; }
.hdf-sec-pages { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 10px; }
.hdf-sec-pages label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.hdf-sec-pages input, .hdf-sec-pages select { width: 100%; }
.hdf-sec-hint { min-height: 1.2em; margin: 4px 0 8px; font-size: .85rem; color: #475569; }
.hdf-sec-hint.is-bad { color: #b42318; font-weight: 600; }
.hdf-zone h4 { font-size: .95rem; margin: 0 0 6px; }
.hdf-sec-actions { margin: 12px 0 6px; }
.hdf-add { display: inline-flex; align-items: center; gap: 6px; }
.hdf-add:disabled { opacity: .5; cursor: not-allowed; }
.hdf-overlap { font-size: .85rem; color: #475569; margin: 6px 0 12px; }
.hdf-prev-ctl { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; font-size: .9rem; }
.hdf-prev-ctl input { width: 90px; }
.hdf-prev-note { text-align: center; color: #64748b; font-size: .85rem; min-height: 1.2em; margin: 8px 0 0; }
.hdf-prev-ctl + .hdf-preview { margin-top: 8px; }
@media (max-width: 600px) { .hdf-sec-pages { grid-template-columns: 1fr; } }
html[data-theme="dark"] .hdf-sec, html[data-theme="dark-contrast"] .hdf-sec { background: #111c33; border-color: #334155; }
html[data-theme="dark"] .hdf-sec-hint, html[data-theme="dark-contrast"] .hdf-sec-hint, html[data-theme="dark"] .hdf-overlap, html[data-theme="dark-contrast"] .hdf-overlap, html[data-theme="dark"] .hdf-prev-note, html[data-theme="dark-contrast"] .hdf-prev-note { color: #cbd5e1; }
html[data-theme="dark"] .hdf-sec-hint.is-bad, html[data-theme="dark-contrast"] .hdf-sec-hint.is-bad { color: #fca5a5; }
html[data-theme="dark"] .hdf-sec-remove:hover, html[data-theme="dark-contrast"] .hdf-sec-remove:hover { background: #450a0a; }
/* style (colour, font, size) of each single text */
.hdf-cell { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hdf-cell-main { display: flex; gap: 4px; align-items: stretch; }
.hdf-cell-main input { flex: 1 1 auto; min-width: 0; }
.hdf-st-toggle { flex: 0 0 auto; border: 1px solid #cbd5e1; background: #fff; color: #334155; border-radius: 8px; padding: 0 8px; font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; }
.hdf-st-toggle:hover { background: #eef2ff; }
.hdf-st-toggle.is-set { border-color: #6366f1; color: #3730a3; background: #eef2ff; }
.hdf-st { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; padding: 8px; border: 1px dashed #cbd5e1; border-radius: 8px; background: #fff; }
.hdf-st[hidden] { display: none; }
.hdf-st label { display: flex; flex-direction: column; gap: 3px; font-size: .8rem; }
.hdf-st input, .hdf-st select { width: 100%; }
.hdf-st input[type="color"] { height: 32px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; }
.hdf-st .hdf-st-bold { flex-direction: row; align-items: center; gap: 6px; }
.hdf-st .hdf-st-bold input { width: auto; }
.hdf-st-reset { grid-column: 1 / -1; background: none; border: 0; color: #4338ca; cursor: pointer; font: inherit; font-size: .8rem; text-decoration: underline; padding: 2px 0; text-align: start; }
html[data-theme="dark"] .hdf-st-toggle, html[data-theme="dark-contrast"] .hdf-st-toggle, html[data-theme="dark"] .hdf-st, html[data-theme="dark-contrast"] .hdf-st, html[data-theme="dark"] .hdf-st input[type="color"], html[data-theme="dark-contrast"] .hdf-st input[type="color"] { background: #0f172a; border-color: #334155; color: #e2e8f0; }
html[data-theme="dark"] .hdf-st-toggle.is-set, html[data-theme="dark-contrast"] .hdf-st-toggle.is-set { background: #312e81; border-color: #6366f1; color: #e0e7ff; }
html[data-theme="dark"] .hdf-st-reset, html[data-theme="dark-contrast"] .hdf-st-reset { color: #a5b4fc; }

/* v4: form on one side, page preview beside it */
.tool-wrapper[data-tool="add-header-footer-to-pdf"] { max-width: 1280px; }
.hdf-app > .hdf6-cols { max-width: 1240px; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.hdf6-side { position: sticky; top: 12px; min-width: 0; }
.hdf6-board { background: #cbd5e1; border: 1px solid #94a3b8; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; align-items: center; }
.hdf6-board .hdf-prev-ctl { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: #0f172a; font-weight: 600; }
.hdf6-board .hdf-preview { width: 100%; max-width: 100%; margin-top: 8px; box-shadow: 0 0 0 1px rgba(15,23,42,.3), 0 6px 20px rgba(15,23,42,.35); }
.hdf6-board .hdf-prev-note { color: #0f172a; font-size: .8rem; text-align: center; margin: 10px 0 0; }
@media (max-width: 980px) { .hdf-app > .hdf6-cols { grid-template-columns: minmax(0, 1fr); } .hdf6-side { position: static; } .hdf6-board .hdf-preview { max-width: 420px; } }
html[data-theme^="dark"] .hdf6-board { background: #0b0e16; border-color: var(--border-dark, #3a3f52); }
html[data-theme^="dark"] .hdf6-board .hdf-prev-ctl, html[data-theme^="dark"] .hdf6-board .hdf-prev-note { color: var(--text, #e7e9f0); }
html[data-theme^="dark"] .hdf6-board .hdf-preview { box-shadow: 0 0 0 1px rgba(255,255,255,.28), 0 6px 20px rgba(0,0,0,.7); }
.hdf-app > * { max-width: 1240px; }
.hdf-app > .info-note, .hdf-app > .hdf-busy, .hdf-app > .hdf-result { max-width: 960px; }
