/* ---------- Tokens ---------- */
:root {
  --header-h: 88px;
  --bg: #ffffff;
  --bg-soft: #f5f6fb;
  --surface: #ffffff;
  --text: #14172f;
  --muted: #5a6080;
  --border: #e3e6f1;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --on-primary: #ffffff;
  --primary-soft: #eceeff;
  --link: #4338ca;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --info-soft: #eaf1ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 23, 47, .05), 0 10px 30px rgba(20, 23, 47, .07);
  --shadow-lg: 0 2px 4px rgba(20, 23, 47, .06), 0 18px 40px rgba(20, 23, 47, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
/* Theme: day mode is the default. Night mode applies only when the visitor picks it (data-theme="dark" on <html>, saved by the toggle). */
:root[data-theme="dark"] {
  --bg: #0d0f20;
  --bg-soft: #141730;
  --surface: #1a1d3a;
  --text: #eceefb;
  --muted: #a4a9c9;
  --border: #2b2f55;
  --primary: #5b5ff0;
  --primary-hover: #6d71f5;
  --primary-soft: #23275a;
  --link: #a9b4ff;
  --danger: #f87171;
  --danger-soft: #3a1c26;
  --ok: #4ade80;
  --ok-soft: #14301f;
  --info-soft: #1b2650;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .3);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 18px 40px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55;
  color: var(--text); background: var(--bg);
}
img, svg, canvas { max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.container { width: min(1180px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.ico { display: inline-flex; line-height: 0; }
.ico svg:not([width]) { width: 1em; height: 1em; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px; padding: 10px 18px;
  font-weight: 600; text-decoration: none; background: transparent; line-height: 1.2;
  transition: background .15s, transform .05s, box-shadow .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-soft { background: var(--primary-soft); color: var(--link); }
.btn-soft:hover:not(:disabled) { background: color-mix(in srgb, var(--primary-soft) 70%, var(--primary) 12%); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-soft); color: var(--text); }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; border-radius: 14px; }
.btn-sm { padding: 6px 12px; font-size: .875rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-sub { font-weight: 500; font-size: .8rem; opacity: .8; margin-left: 4px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 0;
}
.icon-btn:hover:not(:disabled) { background: var(--bg-soft); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: 24px; height: var(--header-h); }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; letter-spacing: -0.03em; text-decoration: none; }
.logo-mark { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 10px; background: #fff; border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(20, 23, 47, .12); }
.logo-mark img { display: block; width: 28px; height: 28px; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 0; border-radius: 10px; background: none; font-weight: 600; font-size: .95rem; text-decoration: none; color: var(--text); }
.nav-link:hover, .menu-btn.open { background: var(--bg-soft); }
.nav-link[aria-current="page"] { color: var(--link); }
.nav-all { display: none; }
.menu-btn .ico { transition: transform .2s; }
.menu-btn.open .ico { transform: rotate(180deg); }
.nav-toggle { display: none; margin-left: auto; border: 0; background: none; padding: 8px; border-radius: 10px; }
.mega { position: absolute; inset-inline: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.mega-inner { display: grid; grid-template-columns: repeat(5, 1fr); gap: 24px; padding: 24px 0 28px; }
.mega-col h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.mega-col li a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; margin-inline: -8px; border-radius: 10px; text-decoration: none; font-weight: 500; font-size: .95rem; }
.mega-col li a:hover { background: var(--bg-soft); }
.mega-col li a[aria-current="page"] { color: var(--link); }

.tool-ico { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.mega .tool-ico { width: 28px; height: 28px; border-radius: 8px; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: 72px 0 56px; text-align: center; background:
  radial-gradient(60% 50% at 20% 0%, color-mix(in srgb, #8b5cf6 22%, transparent), transparent 70%),
  radial-gradient(50% 60% at 90% 10%, color-mix(in srgb, #06b6d4 18%, transparent), transparent 70%), var(--bg); }
.hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 800; letter-spacing: -0.035em; max-width: 16ch; margin-inline: auto; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, #6366f1, #d946ef); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { max-width: 56ch; margin: 18px auto 0; font-size: clamp(1rem, 2vw, 1.2rem); color: var(--muted); }
.searchbox { display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 32px auto 0; padding: 6px 8px 6px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.searchbox:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent), var(--shadow); }
.searchbox .ico { color: var(--muted); font-size: 20px; }
.searchbox input { flex: 1; border: 0; outline: 0; background: none; padding: 12px 0; font-size: 1.05rem; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .9rem; font-weight: 500; }
.chip .ico { color: var(--ok); }

/* ---------- Sections ---------- */
.section { padding: 64px 0; }
.section.soft { background: var(--bg-soft); }
.section-head { text-align: center; margin-bottom: 36px; }
.section-head h2 { font-size: clamp(1.6rem, 3.2vw, 2.25rem); font-weight: 800; }
.section-head p { margin-top: 10px; color: var(--muted); max-width: 60ch; margin-inline: auto; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 28px; }
.tab { border: 1px solid var(--border); background: var(--surface); padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: .92rem; color: var(--muted); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.tool-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
.tool-card .tool-ico { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 4px; }
.tool-card h3 { font-size: 1.1rem; }
.tool-card p { color: var(--muted); font-size: .93rem; }
.tool-grid.compact .tool-card { padding: 18px; }
.tool-grid.compact .tool-ico { width: 40px; height: 40px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; }
.feature { padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.feature .tool-ico { margin-bottom: 14px; }
.feature h3 { font-size: 1.05rem; margin-bottom: 6px; }
.feature p { color: var(--muted); font-size: .95rem; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; counter-reset: s; }
.steps li { display: flex; gap: 14px; align-items: flex-start; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.step-n { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-weight: 800; }
.steps p { padding-top: 4px; }

.faq { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 10px; }
.faq summary { padding: 16px 20px; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--muted); transition: transform .2s; }
.faq[open] summary::after { transform: rotate(45deg); }
.faq p { padding: 0 20px 18px; color: var(--muted); }
.faq-wrap { max-width: 800px; margin-inline: auto; }

/* ---------- Tool page ---------- */
.tool-hero { padding: 32px 0 8px; text-align: center; }
.crumbs { font-size: .875rem; color: var(--muted); margin-bottom: 18px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.tool-hero .tool-ico { width: 60px; height: 60px; border-radius: 18px; margin-bottom: 14px; }
.tool-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; }
.tool-hero .lead { color: var(--muted); max-width: 60ch; margin: 12px auto 0; font-size: 1.08rem; }
.tool-app-wrap { padding: 28px 0 8px; }
#tool-how h2, #tool-faq h2, #tool-related h2 { text-align: center; margin-bottom: 24px; font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 800; }
#tool-app { position: relative; min-height: 340px; border: 1px solid var(--border); border-radius: 20px; background: var(--bg-soft); padding: 20px; }
#tool-app.is-dragging::after { content: "Drop to add"; position: absolute; inset: 8px; z-index: 5; display: grid; place-items: center; border: 3px dashed var(--primary); border-radius: 16px; background: color-mix(in srgb, var(--primary-soft) 88%, transparent); color: var(--link); font-size: 1.4rem; font-weight: 700; pointer-events: none; }

.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 300px; padding: 32px 16px; border: 2px dashed color-mix(in srgb, var(--primary) 40%, var(--border)); border-radius: 16px; background: var(--surface); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover { border-color: var(--primary); }
.drop-icon { color: var(--link); }
.drop-hint { color: var(--muted); }
.drop-privacy { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; margin-top: 6px; }
.dropzone .notice { max-width: 480px; margin-top: 8px; }

.work { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.work-main { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; min-height: 300px; }
.work-side { position: sticky; top: calc(var(--header-h) + 20px); display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.side-title { font-size: 1.05rem; }
.run-hint { text-align: center; color: var(--muted); font-size: .85rem; min-height: 1.2em; margin-top: -4px; }

.main-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.main-title { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.main-actions, .grid-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.grid-tools { margin-bottom: 16px; }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 10px; }
.file-card { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); transition: box-shadow .15s, border-color .15s; }
.file-card[draggable="true"] { cursor: grab; }
.file-card.dragging { opacity: .4; }
.file-card.drop-target { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.file-card.has-error { border-color: var(--danger); background: var(--danger-soft); }
.file-thumb { display: grid; place-items: center; height: 170px; border-radius: 8px; background: var(--bg-soft); overflow: hidden; color: var(--danger); }
.thumb-canvas, .thumb-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
.file-badge { display: flex; flex-direction: column; align-items: center; gap: 6px; color: #2b579a; font-weight: 800; font-size: .8rem; letter-spacing: .06em; }
.file-index { position: absolute; top: 16px; left: 16px; display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--primary); color: var(--on-primary); font-size: .78rem; font-weight: 700; }
.file-remove { position: absolute; top: 16px; right: 16px; width: 28px; height: 28px; border-radius: 50%; }
.file-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }
.file-meta { font-size: .8rem; color: var(--muted); }
.file-meta.err { color: var(--danger); font-weight: 600; }
.file-move { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }

.grid-loading { display: grid; place-items: center; gap: 12px; padding: 60px 0; }
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.page-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 8px; border-radius: 12px; border: 2px solid transparent; }
.page-grid.selectable .page-card { cursor: pointer; }
.page-grid.selectable .page-card:hover { background: var(--bg-soft); }
.page-frame { position: relative; display: grid; place-items: center; width: 150px; height: 190px; max-width: 100%; }
.page-canvas { background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .2); transition: transform .2s; }
.page-num { font-size: .82rem; font-weight: 600; color: var(--muted); }
.page-actions { display: flex; gap: 8px; }
.page-badge { position: absolute; top: 4px; right: 4px; display: none; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.page-card.selected .page-badge { display: grid; }
.style-remove .page-badge { background: var(--danger); }
.style-keep .page-badge { background: var(--primary); }
.style-remove .page-card.selected { border-color: var(--danger); background: var(--danger-soft); }
.style-keep .page-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.style-remove .page-card.selected .page-canvas { opacity: .45; }
.page-card.rotated .page-num::after { content: " \21BB"; color: var(--link); }

/* Options */
.options { display: flex; flex-direction: column; gap: 16px; }
.opt { display: flex; flex-direction: column; gap: 6px; }
.opt-label { font-weight: 600; font-size: .9rem; }
.opt-help { font-size: .8rem; color: var(--muted); }
.opt input[type="text"], .opt input[type="number"], .opt select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); min-height: 42px;
}
.opt input:focus, .opt select:focus { border-color: var(--primary); outline: 3px solid color-mix(in srgb, var(--primary) 25%, transparent); }
.opt input.invalid { border-color: var(--danger); }
.opt input[type="color"] { width: 64px; height: 42px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input { flex: 1; accent-color: var(--primary); }
.range-row output { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--bg); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice input { margin-top: 4px; accent-color: var(--primary); }
.choice-body { display: flex; flex-direction: column; }
.choice-body small { color: var(--muted); font-size: .8rem; line-height: 1.35; margin-top: 2px; }

.notice { padding: 12px 14px; border-radius: 10px; font-size: .9rem; }
.notice-error { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.notice-info { background: var(--info-soft); color: var(--link); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); }

/* Progress / result */
.stage-card { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 56px 20px; background: var(--surface); border-radius: 16px; border: 1px solid var(--border); min-height: 300px; justify-content: center; }
.stage-card h2 { font-size: 1.7rem; font-weight: 800; }
.bar { width: min(420px, 100%); height: 10px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #6366f1, #d946ef); transition: width .2s; }
.busy-text { color: var(--muted); max-width: 46ch; overflow-wrap: anywhere; }
.busy-note { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; }
.spinner.sm { width: 26px; height: 26px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.done-icon { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.done-icon.err { background: var(--danger-soft); color: var(--danger); }
.done-msg { color: var(--muted); max-width: 52ch; }
.done-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; }
.result-list { width: min(560px, 100%); text-align: left; margin-top: 10px; }
.result-list summary { cursor: pointer; color: var(--link); font-weight: 600; text-align: center; }
.result-list ul { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.result-list li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.rl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Prose pages */
.prose { max-width: 760px; margin: 0 auto; padding: 48px 0 72px; }
.prose h1 { font-size: 2.2rem; font-weight: 800; margin-bottom: 8px; }
.prose h2 { font-size: 1.35rem; margin: 32px 0 8px; }
.prose p, .prose li { color: var(--muted); }
.prose p + p { margin-top: 12px; }
.prose ul { list-style: disc; padding-left: 22px; }
.prose a { color: var(--link); }

/* ---------- PDF editor ---------- */
#tool-app.is-editor { padding: 0; min-height: 0; overflow: hidden; background: var(--surface); }
.pe { position: relative; display: flex; flex-direction: column; height: min(84vh, 900px); min-height: 520px; background: var(--surface); }
.pe-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.pe-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid transparent; border-radius: 10px; background: none; color: var(--text); padding: 0; }
.pe-btn:hover:not(:disabled) { background: var(--bg-soft); }
.pe-btn.active { background: var(--primary-soft); color: var(--link); border-color: color-mix(in srgb, var(--primary) 35%, transparent); }
.pe-btn:disabled { opacity: .35; cursor: not-allowed; }
.pe-sep { width: 1px; height: 24px; margin: 0 6px; background: var(--border); }
.pe-spacer { flex: 1; }
.pe-zoom { min-width: 3.2em; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; font-size: .9rem; }
.pe-pagelabel { margin-right: 8px; white-space: nowrap; }
.pe-props { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 8px 12px; min-height: 52px; border-bottom: 1px solid var(--border); background: var(--bg-soft); font-size: .88rem; }
.pe-field { display: inline-flex; align-items: center; gap: 8px; }
.pe-flabel { font-weight: 600; color: var(--muted); }
.pe-props input[type="color"] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.pe-props select, .pe-num { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.pe-num { width: 68px; }
.pe-range { display: inline-flex; align-items: center; gap: 8px; }
.pe-range input { width: 110px; accent-color: var(--primary); }
.pe-range output { min-width: 3.4em; font-variant-numeric: tabular-nums; font-weight: 600; }
.pe-toggle { display: inline-flex; gap: 4px; }
.pe-tbtn { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.pe-tbtn.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.pe-warn { max-width: 46ch; }
.pe-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 132px minmax(0, 1fr); }
.pe-thumbs { overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 12px 8px; border-right: 1px solid var(--border); background: var(--bg-soft); }
.pe-thumb { cursor: pointer; text-align: center; padding: 6px; border-radius: 10px; border: 2px solid transparent; }
.pe-thumb.active { border-color: var(--primary); background: var(--primary-soft); }
.pe-thumb-canvas { display: block; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .25); }
.pe-thumb-num { font-size: .78rem; font-weight: 600; color: var(--muted); margin-top: 4px; }
.pe-thumb-actions { display: flex; justify-content: center; gap: 4px; margin-top: 4px; }
.pe-thumb-actions .icon-btn { width: 26px; height: 26px; border-radius: 8px; }
.pe-scroll { position: relative; overflow: auto; padding: 20px; background: color-mix(in srgb, var(--text) 14%, var(--bg-soft)); }
.pe-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; width: max-content; min-width: 100%; }
.pe-page { position: relative; flex: none; background: #fff; box-shadow: 0 2px 14px rgba(0, 0, 0, .35); }
.pe-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pe-overlay { position: absolute; inset: 0; user-select: none; -webkit-user-select: none; }
.pe:not([data-tool="select"]) .pe-overlay { touch-action: none; cursor: crosshair; }
.pe[data-tool="text"] .pe-overlay { cursor: text; }
.pe-ann { position: absolute; box-sizing: border-box; touch-action: none; }
.pe[data-tool="select"] .pe-box, .pe[data-tool="select"] .pe-text { cursor: move; }
.pe-box img { width: 100%; height: 100%; display: block; pointer-events: none; }
.pe-highlight { mix-blend-mode: multiply; }
.pe-text { white-space: pre; line-height: 1.2; min-width: 1ch; min-height: 1.2em; margin: 0; padding: 0; outline: none; }
.pe-text.editing { cursor: text !important; outline: 1.5px solid var(--primary); background: rgba(255, 255, 255, .55); user-select: text; -webkit-user-select: text; }
.pe-svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.pe-svg .vis { pointer-events: none; }
.pe-svg .hit { pointer-events: stroke; fill: none; stroke: transparent; }
.pe:not([data-tool="select"]) .pe-svg .hit { pointer-events: none; }
.pe-selbox { position: absolute; z-index: 5; border: 1.5px dashed var(--primary); pointer-events: none; }
.pe-handle { position: absolute; z-index: 6; width: 12px; height: 12px; border: 2px solid var(--primary); border-radius: 50%; background: #fff; transform: translate(-50%, -50%); pointer-events: auto; touch-action: none; }
.pe-handle.h-nw { left: 0; top: 0; cursor: nwse-resize; }
.pe-handle.h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.pe-handle.h-sw { left: 0; top: 100%; cursor: nesw-resize; }
.pe-handle.h-se { left: 100%; top: 100%; cursor: nwse-resize; }
.pe-handle.pt { cursor: move; }
.pe-toast { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 20; max-width: min(90%, 460px); padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: .9rem; box-shadow: var(--shadow-lg); }
.pe-modal-bg { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 30, .55); }
.pe-modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 24px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); }
.pe-modal h2 { font-size: 1.3rem; margin-bottom: 14px; }
.pe-modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.pe-busy { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 0; text-align: center; }
.pe-sigcanvas { display: block; width: 100%; height: 190px; margin-top: 10px; border: 1px dashed var(--border); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.pe-modal .err { color: var(--danger); }
@media (max-width: 760px) {
  .pe { height: 82vh; }
  .pe-body { grid-template-columns: minmax(0, 1fr); }
  .pe-thumbs { display: none; }
  .pe-scroll { padding: 10px; }
  .pe-btn { width: 36px; height: 36px; }
  .pe-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .pe-toolbar > * { flex: none; }
  .pe-spacer { display: none; }
  .pe-props { gap: 6px 14px; }
}

.tool-about { max-width: 800px; }
.tool-about h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 800; margin-bottom: 14px; }
.tool-about h3 { font-size: 1.05rem; margin: 20px 0 8px; }
.tool-about p { color: var(--muted); }
.tool-about p + p { margin-top: 12px; }
.tool-about ul { list-style: disc; padding-left: 22px; color: var(--muted); }
.tool-about li { margin-bottom: 6px; }
.tool-about a, .guide-list a { color: var(--link); }
.guide-list { display: flex; flex-direction: column; gap: 18px; margin: 24px 0; }
.guide-list a { font-weight: 700; font-size: 1.1rem; }
.guide-list p { margin-top: 2px; }
.prose ol { list-style: decimal; padding-left: 22px; color: var(--muted); }
.prose li { margin-bottom: 6px; }
.prose .crumbs { margin-bottom: 8px; }
.guide-card { text-decoration: none; transition: transform .15s, box-shadow .15s; }
.guide-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); margin-top: 32px; }
.footer-grid { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 32px; padding: 48px 0 32px; }
.footer-brand p { margin-top: 12px; color: var(--muted); font-size: .92rem; max-width: 32ch; }
.footer-col h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 12px; }
.footer-col li { margin-bottom: 8px; }
.footer-col a { text-decoration: none; font-size: .93rem; }
.footer-col a:hover { color: var(--link); text-decoration: underline; }
.footer-bottom { padding: 18px 0 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .work { grid-template-columns: 1fr; }
  .work-side { position: static; }
  .mega-inner { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .nav-toggle { display: inline-grid; }
  .nav { display: none; position: absolute; top: var(--header-h); inset-inline: 0; flex-direction: column; align-items: stretch; margin: 0; padding: 12px 16px 16px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); }
  .nav.open { display: flex; }
  .nav-link { padding: 12px; }
  .menu-btn, .mega { display: none !important; }
  .nav-all { display: inline-flex; }
  .hero { padding: 48px 0 40px; }
  .section { padding: 44px 0; }
  #tool-app { padding: 12px; border-radius: 16px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .file-thumb { height: 140px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Theme toggle ---------- */
.theme-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; margin-left: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 0; }
.theme-btn:hover { background: var(--bg-soft); }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (max-width: 760px) {
  .theme-btn { margin-left: auto; }
  .nav-toggle { margin-left: 4px; }
}

/* ---------- Advertising (placed only by scripts/build.ps1 when an AdSense slot is configured) ---------- */
.ad-wrap { max-width: 800px; margin: 32px auto; padding: 0 16px; text-align: center; }
.ad-label { margin: 0 0 6px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ad-wrap .adsbygoogle { min-height: 250px; } /* reserve space so the page doesn't jump when the ad loads */
@media print { .ad-wrap, .theme-btn { display: none !important; } }
/* If AdSense has no ad for a slot, don't leave an empty gap */
.ad-wrap:has(.adsbygoogle[data-ad-status="unfilled"]) { display: none; }

/* About page logo: sits on a white card so the black wordmark stays readable in night mode */
.about-logo { display: block; width: min(260px, 70%); height: auto; margin: 0 0 24px; padding: 14px; background: #fff; border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }

/* Reserve the header's space so the page doesn't jump when js/layout.js fills it in (Core Web Vitals: CLS) */
#site-header { min-height: calc(var(--header-h) + 1px); }

.seo-intro p { color: var(--muted); max-width: 800px; margin-inline: auto; }
.seo-intro p + p { margin-top: 14px; }
.seo-intro a { color: var(--link); font-weight: 600; }

/* Header brand: the full logo on a white tile (the black wordmark would vanish on the dark theme otherwise) */
.logo-full { flex: none; display: inline-flex; align-items: center; justify-content: center; height: 78px; padding: 0 10px; border-radius: 12px; background: #fff; border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(20, 23, 47, .12); }
.logo-full img { display: block; width: 88px; height: 75px; }
@media (max-width: 760px) {
  :root { --header-h: 76px; }
  .logo-full { height: 66px; padding: 0 8px; }
  .logo-full img { width: 70px; height: 60px; }
}
