/* PDF tools UI (built by assets/pdf/pdf-core.js). Uses the site tokens from assets/style.css
   and the colour tones (.tone-1 to .tone-6) from assets/tools-grid.css. */

/* ---------- page hero (PdfTool.cshtml): centred title on a soft band, the tool's coloured icon ---------- */
/* No overflow on the band: the sticky action bar of the tool must keep working inside it. */
.tool-band {
  position: relative; isolation: isolate; padding-bottom: 8px;
  background:
    radial-gradient(36% 60% at 6% 10%, rgba(240, 100, 60, .07), transparent 70%),
    radial-gradient(32% 60% at 96% 6%, rgba(124, 58, 237, .07), transparent 70%),
    linear-gradient(180deg, var(--accent-soft) 0, rgba(235, 240, 255, .55) 260px, var(--bg) 520px);
}
.tool-band::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 420px; z-index: -1; pointer-events: none;
  background-image: radial-gradient(rgba(29, 67, 200, .12) 1px, transparent 1.3px); background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent); mask-image: linear-gradient(180deg, #000, transparent);
}
.tool-hero { padding: 26px 0 26px; text-align: center; }
.tool-hero .breadcrumbs { margin-bottom: 18px; }
.tool-hero-icon {
  width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 17px;
  background: linear-gradient(140deg, var(--tone-a, #3550d6), var(--tone-b, #0b2a8f));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 14px 26px -12px var(--tone-b, #0b2a8f);
}
.tool-hero-icon svg { width: 30px; height: 30px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-hero h1 { max-width: 20ch; margin: 0 auto 10px; }
.tool-hero .lead { max-width: 60ch; margin: 0 auto; }
@media (max-width: 559.98px) {
  .tool-hero { padding: 18px 0 18px; }
  .tool-hero .breadcrumbs { margin-bottom: 12px; }
  .tool-hero-icon { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 10px; }
  .tool-hero-icon svg { width: 25px; height: 25px; }
  .tool-hero .lead { font-size: 1.0625rem; }
}

#pdf-app { min-height: 300px; }
.pdf-app {
  --pdf-danger: #b42318;
  --pdf-danger-soft: #fbe9e7;
  --pdf-danger-ink: #8a1f11;
  --pdf-warn-soft: #fff4db;
  --pdf-warn-ink: #7a4a00;
  --pdf-side: 340px;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.pdf-app [hidden] { display: none !important; }
.pdf-ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pdf-app .segbtn { gap: 6px; }
.pdf-app .segbtn .pdf-ico { width: 16px; height: 16px; }
.pdf-app.is-dragover { outline: 3px dashed var(--accent); outline-offset: 4px; }

/* ---------- drop zone ---------- */
.pdf-drop {
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  margin: 12px; padding: clamp(36px, 7vw, 76px) 18px clamp(28px, 5vw, 52px);
  border: 2px dashed color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: 16px;
  background: linear-gradient(180deg, var(--accent-soft), var(--surface) 78%);
  transition: border-color .15s, background .15s;
}
.pdf-app.is-dragover .pdf-drop { border-color: var(--accent); background: var(--accent-soft); }
.pdf-app.is-dragover { outline-color: transparent; }
.pdf-drop-icon { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 20px; background: var(--surface); box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 10px 26px rgba(29, 67, 200, .14); }
.pdf-drop-icon .pdf-ico { width: 34px; height: 34px; stroke: var(--accent); stroke-width: 1.7; }
.pdf-drop-title { margin: 6px 0 0; font-family: var(--serif); font-weight: 600; font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem); line-height: 1.2; letter-spacing: -0.01em; }
.pdf-choose { padding: 15px 28px; font-size: 1.0625rem; border-radius: 12px; box-shadow: 0 8px 20px rgba(29, 67, 200, .24); }
.pdf-choose .pdf-ico { width: 20px; height: 20px; stroke-width: 2.4; }
.pdf-drop-hint { margin: 0; font-size: .9063rem; color: var(--muted); max-width: 46ch; }
.pdf-drop .pdf-notice { max-width: 560px; margin: 4px 0 0; text-align: left; }
/* 1.1.1 "button first" layout (.is-cta): one big button, then "or drop PDF files here" */
.pdf-drop.is-cta {
  gap: 10px; padding: clamp(36px, 6vw, 64px) 18px clamp(30px, 4.5vw, 46px);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border)); border-radius: 18px;
  background:
    radial-gradient(70% 85% at 50% 0%, var(--accent-soft) 0%, rgba(235, 240, 255, .4) 55%, transparent 85%),
    var(--surface);
}
.pdf-drop.is-cta .pdf-drop-icon { margin-bottom: 8px; }
.pdf-drop.is-cta .pdf-choose {
  min-width: min(100%, 320px); padding: 19px 34px; gap: 10px; font-size: 1.25rem; border-radius: 14px;
  background: linear-gradient(180deg, #2a52d8, var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 16px 30px -12px rgba(29, 67, 200, .65);
  transition: background .15s, transform .15s, box-shadow .15s;
}
.pdf-drop.is-cta .pdf-choose:hover { background: linear-gradient(180deg, #2449cc, var(--accent-hover)); transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 20px 34px -12px rgba(29, 67, 200, .7); }
.pdf-drop.is-cta .pdf-choose:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.pdf-drop.is-cta .pdf-choose .pdf-ico { width: 22px; height: 22px; }
.pdf-drop.is-cta .pdf-drop-title { margin: 4px 0 0; font-family: var(--font); font-size: 1.0625rem; font-weight: 500; letter-spacing: 0; color: var(--text-2); }
.pdf-drop.is-cta .pdf-drop-hint { font-size: .875rem; }
.pdf-drop.is-cta .pdf-badge { margin-top: 10px; }
.pdf-app.is-dragover .pdf-drop.is-cta { border-style: solid; }
@media (max-width: 559.98px) {
  .pdf-drop.is-cta { margin: 10px; padding: 30px 14px 26px; }
  .pdf-drop.is-cta .pdf-drop-icon { display: none; }
  .pdf-drop.is-cta .pdf-choose { width: 100%; min-width: 0; padding: 17px 20px; font-size: 1.125rem; }
}
@media (prefers-reduced-motion: reduce) { .pdf-drop.is-cta .pdf-choose:hover { transform: none; } }
/* extra buttons in the drop view (ui.addDropButton) */
.pdf-drop-btn { padding: 11px 20px; font-size: .9688rem; border-radius: 12px; background: var(--surface); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: none; }
.pdf-drop-btn:hover { background: var(--accent-soft); }

/* ---------- privacy badge ---------- */
.pdf-badge {
  display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 0; padding: 6px 12px 6px 10px;
  border-radius: 999px; background: var(--good-soft); color: var(--good);
  font-size: .8438rem; font-weight: 600; line-height: 1.35; text-align: left;
}
.pdf-badge .pdf-ico { width: 17px; height: 17px; }
.pdf-badge.is-server { background: var(--surface-2); color: var(--text-2); }

/* ---------- work area ---------- */
.pdf-work { display: grid; grid-template-columns: minmax(0, 1fr); border-radius: 19px; }
.pdf-main { min-width: 0; padding: 16px; }
.pdf-side { padding: 18px 16px 6px; border-top: 1px solid var(--border); }
.pdf-side.is-empty .pdf-side-title { display: none; }
.pdf-action { padding: 14px 16px 16px; }
.pdf-badge-mobile { margin-top: 14px; }
@media (min-width: 900px) {
  .pdf-work {
    grid-template-columns: minmax(0, 1fr) var(--pdf-side);
    grid-template-rows: auto 1fr;
    grid-template-areas: "main side" "main action";
    background: linear-gradient(to left, var(--surface-2) var(--pdf-side), var(--border) var(--pdf-side), var(--border) calc(var(--pdf-side) + 1px), transparent calc(var(--pdf-side) + 1px));
    min-height: 420px;
  }
  .pdf-main { grid-area: main; padding: 20px 22px 22px; }
  .pdf-side { grid-area: side; border-top: 0; padding: 22px 22px 4px; }
  .pdf-side.is-empty { padding-top: 10px; }
  .pdf-action { grid-area: action; align-self: start; position: sticky; top: 84px; padding: 14px 22px 22px; }
  .pdf-badge-mobile { display: none !important; }
}
@media (max-width: 899.98px) {
  .pdf-action {
    position: sticky; bottom: 0; z-index: 6;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    border-radius: 0 0 19px 19px;
    box-shadow: 0 -8px 20px rgba(15, 23, 42, .06);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .pdf-action .pdf-badge { display: none; }
  .pdf-side.is-empty { padding-top: 4px; padding-bottom: 4px; }
  .pdf-side.is-empty .pdf-badge-mobile { margin: 6px 0; }
}

.pdf-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 0 0 14px; }
.pdf-summary { margin: 0; min-width: 0; font-weight: 650; overflow-wrap: anywhere; }
.pdf-bar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pdf-notice { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--pdf-warn-soft); color: var(--pdf-warn-ink); font-size: .9375rem; line-height: 1.45; overflow-wrap: anywhere; }
.pdf-notice a, .pdf-error a, .pdf-card-error a { color: inherit; font-weight: 600; text-decoration: underline; }
.pdf-notice-list { margin: 0; padding-left: 1.2em; }
.pdf-notice-list li + li { margin-top: 4px; }
.pdf-custom:empty { display: none; }
.pdf-custom { margin-top: 16px; }
.pdf-custom.is-above { margin: 0 0 14px; }

/* ---------- small icon buttons ---------- */
.pdf-ctl {
  width: 30px; height: 30px; padding: 0; display: inline-grid; place-items: center; flex: none;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.pdf-ctl .pdf-ico { width: 16px; height: 16px; }
.pdf-ctl:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.pdf-ctl:disabled { opacity: .35; cursor: default; }
.pdf-ctl.pdf-remove:hover:not(:disabled), .pdf-ctl.pdf-del:hover:not(:disabled) { color: var(--pdf-danger); border-color: var(--pdf-danger); background: var(--pdf-danger-soft); }

/* ---------- thumbnails ---------- */
.pdf-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.pdf-thumb > * { grid-area: 1 / 1; }
.pdf-thumb img { display: block; max-width: 88%; max-height: 88%; width: auto; height: auto; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .12), 0 3px 10px rgba(15, 23, 42, .10); transition: transform .2s ease; }
.pdf-thumb img:not([src]) { display: none; }
.pdf-thumb-icon { width: 40px; height: 40px; stroke: var(--muted); stroke-width: 1.5; }
.pdf-thumb-ext { align-self: end; margin-bottom: 18%; font-size: .75rem; font-weight: 700; letter-spacing: .06em; color: var(--text-2); }
.pdf-spin { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: pdf-spin .8s linear infinite; }
.pdf-spin-lg { width: 38px; height: 38px; border-width: 4px; }
.pdf-card:not(.is-loading) .pdf-thumb .pdf-spin, .pdf-page:not(.is-loading) .pdf-thumb .pdf-spin { display: none; }
@keyframes pdf-spin { to { transform: rotate(360deg); } }

/* ---------- file cards ---------- */
.pdf-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); }
.pdf-files.is-single { grid-template-columns: minmax(0, 280px); }
.pdf-card {
  position: relative; display: flex; flex-direction: column; min-width: 0; padding: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  transition: border-color .15s, box-shadow .15s;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.pdf-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: var(--shadow); }
@media (hover: hover) and (pointer: fine) { .pdf-files:not(.is-single) .pdf-card { cursor: grab; } }
.pdf-card .pdf-remove { position: absolute; top: 4px; right: 4px; z-index: 2; width: 28px; height: 28px; border-radius: 50%; box-shadow: 0 1px 3px rgba(15, 23, 42, .16); }
.pdf-card-body { display: grid; gap: 1px; min-width: 0; padding: 8px 2px 0; }
.pdf-card-name { font-size: .875rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-card-meta { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pdf-card-error { margin: 8px 0 0; padding: 7px 9px; border-radius: 8px; background: var(--pdf-danger-soft); color: var(--pdf-danger-ink); font-size: .8125rem; line-height: 1.4; overflow-wrap: anywhere; }
.pdf-card.is-error { border-color: #eab0a7; }
.pdf-card.is-error .pdf-thumb { background: var(--pdf-danger-soft); }
.pdf-card.is-error .pdf-thumb-icon { stroke: var(--pdf-danger); }
.pdf-card-move { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.pdf-card-pos { min-width: 2.2em; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); text-align: center; font-size: .8125rem; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pdf-files.has-one .pdf-card-move { display: none; }
/* labels on file cards and chips (ui.labelFile) */
.pdf-file-tag { display: inline-block; justify-self: start; max-width: 100%; margin-top: 4px; padding: 1px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: .75rem; font-weight: 700; letter-spacing: .02em; }
.pdf-chip .pdf-file-tag { margin-top: 0; }
.pdf-file-tag[data-tone] { background: color-mix(in srgb, var(--tone) 14%, var(--surface)); color: color-mix(in srgb, var(--tone) 80%, var(--text)); }
.pdf-file-tag[data-tone="0"] { --tone: var(--series-1); }
.pdf-file-tag[data-tone="1"] { --tone: var(--series-2); }
.pdf-file-tag[data-tone="2"] { --tone: var(--series-3); }
.pdf-file-tag[data-tone="3"] { --tone: var(--series-4); }
.pdf-file-tag[data-tone="4"] { --tone: var(--series-5); }
.pdf-add-tile { display: flex; }
.pdf-add-btn {
  flex: 1; min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed var(--border); border-radius: 14px; background: transparent; color: var(--accent);
  font: inherit; font-weight: 600; font-size: .9375rem; cursor: pointer; transition: border-color .15s, background .15s;
}
.pdf-add-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.pdf-add-btn .pdf-ico { width: 30px; height: 30px; stroke-width: 1.8; }

/* ---------- drag and drop reordering ---------- */
.pdf-dragging { opacity: .35; }
.pdf-dragging.pdf-card, .pdf-dragging .pdf-page-main { outline: 2px dashed var(--accent); outline-offset: 2px; }
.pdf-ghost { position: fixed !important; left: 0; top: 0; z-index: 80; margin: 0; pointer-events: none; opacity: .97; box-shadow: 0 20px 44px rgba(15, 23, 42, .24); border-radius: 14px; background: var(--surface); }
html.pdf-is-dragging, html.pdf-is-dragging * { cursor: grabbing !important; }

/* ---------- page grid ---------- */
.pdf-chips { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pdf-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 4px 3px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: .875rem; }
.pdf-chip-name { min-width: 0; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-chip .pdf-ctl { width: 24px; height: 24px; border: 0; border-radius: 50%; }
.pdf-chip.is-error { border-color: #eab0a7; background: var(--pdf-danger-soft); }
.pdf-grid-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 12px; }
.pdf-grid-count { margin-right: auto; font-size: .875rem; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pdf-sel { display: flex; align-items: center; gap: 8px; }
.pdf-sel label { font-size: .875rem; font-weight: 600; white-space: nowrap; }
.pdf-sel-input.text-input { width: 140px; padding: 6px 10px; font-size: .9375rem; }
.pdf-rot-group { display: inline-flex; align-items: center; gap: 4px; }
.pdf-grid-wrap > .pdf-field-error { margin: -4px 0 10px; }
.pdf-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px 10px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.pdf-page { position: relative; display: flex; flex-direction: column; min-width: 0; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.pdf-page-main { display: block; width: 100%; padding: 5px; margin: 0; border: 2px solid transparent; border-radius: 12px; background: transparent; color: inherit; font: inherit; text-align: center; }
button.pdf-page-main { cursor: pointer; }
.pdf-grid.is-editable .pdf-page-main:hover { border-color: var(--border); background: var(--surface); }
@media (hover: hover) and (pointer: fine) { .pdf-grid.is-editable .pdf-page-main { cursor: grab; } }
.pdf-page .pdf-thumb { border-radius: 8px; }
.pdf-page.is-broken .pdf-thumb::after { content: "Preview not available"; padding: 8px; font-size: .75rem; color: var(--muted); text-align: center; }
.pdf-page-foot { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 28px; margin-top: 2px; }
.pdf-page-foot .pdf-ctl { width: 26px; height: 26px; border-radius: 7px; }
.pdf-page-num { min-width: 2.2em; text-align: center; font-size: .8125rem; font-weight: 650; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pdf-page-ctl { position: absolute; top: 9px; right: 9px; z-index: 2; display: flex; flex-direction: column; gap: 4px; opacity: 0; transition: opacity .15s; }
.pdf-page-ctl .pdf-ctl { width: 28px; height: 28px; box-shadow: 0 1px 3px rgba(15, 23, 42, .16); }
.pdf-page:hover .pdf-page-ctl, .pdf-page:focus-within .pdf-page-ctl { opacity: 1; }
@media (hover: none) { .pdf-page-ctl { opacity: 1; } }
.pdf-page-mark { position: absolute; top: 9px; left: 9px; z-index: 2; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 2px solid var(--baseline); color: transparent; pointer-events: none; }
.pdf-page-mark .pdf-ico { width: 14px; height: 14px; stroke-width: 3; }
.pdf-page.is-selected .pdf-page-main { border-color: var(--accent); background: var(--accent-soft); }
.pdf-page.is-selected .pdf-page-mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.sel-remove .pdf-page.is-selected .pdf-page-main { border-color: #c0392b; background: var(--pdf-danger-soft); }
.sel-remove .pdf-page.is-selected .pdf-page-mark { background: #c0392b; border-color: #c0392b; }
.sel-remove .pdf-page.is-selected img { opacity: .4; }
.pdf-page-tag { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; padding: 2px 8px; border-radius: 999px; background: var(--tone, var(--accent)); color: #fff; font-size: .6875rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; pointer-events: none; }
.pdf-page.is-dim .pdf-thumb img { opacity: .35; }
.pdf-page.is-dim .pdf-page-num { color: var(--muted); }
.pdf-page[data-tone] .pdf-page-main { border-color: color-mix(in srgb, var(--tone) 70%, transparent); }
.pdf-page[data-tone="0"] { --tone: var(--series-1); }
.pdf-page[data-tone="1"] { --tone: var(--series-2); }
.pdf-page[data-tone="2"] { --tone: var(--series-3); }
.pdf-page[data-tone="3"] { --tone: var(--series-4); }
.pdf-page[data-tone="4"] { --tone: var(--series-5); }
.is-multi .pdf-page[data-file="0"] .pdf-page-num { color: var(--series-1); }
.is-multi .pdf-page[data-file="1"] .pdf-page-num { color: var(--series-2); }
.is-multi .pdf-page[data-file="2"] .pdf-page-num { color: var(--series-3); }
.is-multi .pdf-page[data-file="3"] .pdf-page-num { color: #b07800; }
.is-multi .pdf-page[data-file="4"] .pdf-page-num { color: #c2457a; }
.pdf-page.is-blank .pdf-thumb img { outline: 1px dashed var(--baseline); outline-offset: -1px; }
@media (max-width: 560px) {
  .pdf-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px 6px; }
  .pdf-page-main { padding: 3px; }
  .pdf-page-ctl { top: 6px; right: 6px; }
  .pdf-page-mark { top: 6px; left: 6px; }
  .pdf-sel { flex: 1 1 100%; min-width: 0; }
  .pdf-sel-input.text-input { flex: 1 1 0; width: 0; min-width: 0; }
}
/* Narrow cards and touch screens (page buttons always shown): the label goes to the bottom of the
   picture, clear of the selection tick (top left) and the page buttons (top right). */
@media (max-width: 560px), (hover: none) {
  .pdf-page-tag { top: auto; bottom: 40px; max-width: calc(100% - 14px); }
}

/* ---------- options ---------- */
.pdf-side-title { margin: 0 0 12px; font-family: var(--font); font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pdf-instructions { margin: 0 0 16px; font-size: .9375rem; color: var(--text-2); line-height: 1.55; }
.pdf-options { display: flex; flex-wrap: wrap; gap: 16px 12px; }
.pdf-options:empty { display: none; }
.pdf-options > .pdf-field { flex: 1 1 100%; min-width: 0; }
.pdf-options > .pdf-field.is-half { flex: 1 1 calc(50% - 6px); }
.pdf-field .input-wrap input { width: 100%; }
.pdf-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.pdf-fieldset legend { padding: 0; margin: 0 0 6px; font-weight: 600; font-size: .9375rem; }
.pdf-choices { display: grid; gap: 8px; }
.pdf-choice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.pdf-choice:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.pdf-choice.is-checked { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.pdf-choice.is-disabled { opacity: .5; cursor: not-allowed; }
.pdf-choice input { flex: none; margin: 4px 0 0; accent-color: var(--accent); }
.pdf-choice-text { display: grid; gap: 1px; min-width: 0; }
.pdf-choice-text strong { font-size: .9375rem; font-weight: 600; }
.pdf-choice-text small { font-size: .8125rem; line-height: 1.4; color: var(--text-2); }
.pdf-check { color: var(--text); font-weight: 500; cursor: pointer; }
.pdf-check input { width: 18px; height: 18px; flex: none; margin-top: 3px; accent-color: var(--accent); }
.pdf-field-error { margin: 2px 0 0; font-size: .8438rem; line-height: 1.4; color: var(--pdf-danger); }
.pdf-field.has-error .text-input, .pdf-field.has-error .input-wrap { border-color: #d92d20; }
.pdf-range-info:empty { display: none; }
.pdf-range-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pdf-range-head label { font-weight: 600; font-size: .9375rem; }
.pdf-range-out { font-weight: 650; color: var(--accent); font-variant-numeric: tabular-nums; }
.pdf-field input[type=range] { width: 100%; margin: 4px 0; accent-color: var(--accent); }
.pdf-color { display: flex; align-items: center; gap: 10px; }
.pdf-color input[type=color] { width: 46px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.pdf-color-hex { font-family: var(--mono); font-size: .875rem; color: var(--text-2); }
.pdf-pos { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2px; width: 126px; aspect-ratio: 3 / 4; padding: 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); box-shadow: 0 2px 8px rgba(15, 23, 42, .08); }
.pdf-pos-cell { display: grid; place-items: center; border-radius: 5px; cursor: pointer; }
.pdf-pos-cell:hover { background: var(--surface-2); }
.pdf-pos-cell:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.pdf-pos-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--baseline); transition: background .15s, border-color .15s; }
.pdf-pos-cell.is-checked .pdf-pos-dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.pdf-pos-cell.is-disabled { opacity: .3; cursor: not-allowed; }
/* password option */
.pdf-pw { position: relative; }
.pdf-pw .text-input { width: 100%; padding-right: 72px; }
.pdf-pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 32px; padding: 4px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--accent); font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer; }
.pdf-pw-toggle:hover { background: var(--accent-soft); }
.pdf-pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 2px 0 0; }
.pdf-pw-meter span { height: 5px; border-radius: 3px; background: var(--border); }
.pdf-pw-meter[data-level="0"] span:nth-child(-n+1) { background: var(--pdf-danger); }
.pdf-pw-meter[data-level="1"] span:nth-child(-n+2) { background: #c27c0e; }
.pdf-pw-meter[data-level="2"] span:nth-child(-n+3) { background: var(--good); }
.pdf-pw-meter[data-level="3"] span { background: var(--good); }
.pdf-pw-note { margin: 0; font-size: .8438rem; color: var(--text-2); }
/* file / image option */
.pdf-file-label { display: block; font-weight: 600; font-size: .9375rem; }
.pdf-file-pick { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px 10px; padding: 8px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface); }
.pdf-file-pick.is-over { border-color: var(--accent); background: var(--accent-soft); }
.pdf-file-thumb { width: 48px; height: 48px; display: grid; place-items: center; overflow: hidden; border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.pdf-file-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pdf-file-name { min-width: 0; font-size: .875rem; color: var(--text-2); overflow-wrap: anywhere; }
.pdf-filefield.has-file .pdf-file-name { color: var(--text); font-weight: 600; }
.pdf-file-btns { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.pdf-filefield.has-error .pdf-file-pick { border-color: #d92d20; }

/* ---------- action ---------- */
.pdf-go { width: 100%; padding: 15px 20px; font-size: 1.0625rem; border-radius: 12px; box-shadow: 0 8px 20px rgba(29, 67, 200, .22); }
.pdf-go .pdf-ico { width: 19px; height: 19px; stroke-width: 2.3; }
.pdf-go:disabled { box-shadow: none; }
.pdf-need { margin: 8px 0 0; font-size: .875rem; color: var(--text-2); text-align: center; line-height: 1.4; }
.pdf-error { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--pdf-danger-soft); color: var(--pdf-danger-ink); font-size: .9375rem; line-height: 1.45; overflow-wrap: anywhere; }
.pdf-error .pdf-ico { width: 18px; height: 18px; margin-top: 2px; }
@media (min-width: 900px) { .pdf-action .pdf-badge { display: flex; width: fit-content; margin: 14px auto 0; } }
.pdf-name { display: flex; min-width: 0; max-width: 100%; overflow: hidden; }
.pdf-name-head { min-width: 3.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-name-tail { flex: none; white-space: nowrap; }

/* ---------- progress overlay ---------- */
.pdf-progress { position: absolute; inset: 0; z-index: 30; border-radius: 19px; background: color-mix(in srgb, var(--surface) 80%, transparent); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.pdf-progress-box {
  position: sticky; top: max(96px, 28vh); margin: 48px auto; width: min(380px, calc(100% - 32px));
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 24px 22px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 50px rgba(15, 23, 42, .16);
}
.pdf-progress-text { margin: 4px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.pdf-progress-track { width: 100%; height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.pdf-progress-bar { width: 0; height: 100%; border-radius: 999px; background: var(--accent); transition: width .2s; }
.pdf-progress-track.is-busy .pdf-progress-bar { width: 35% !important; animation: pdf-slide 1.1s ease-in-out infinite; }
@keyframes pdf-slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
.pdf-progress-pct { margin: 0; min-height: 1.3em; font-size: .875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pdf-cancel { margin-top: 2px; }

/* ---------- result ---------- */
.pdf-result { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: clamp(30px, 5vw, 56px) 18px clamp(24px, 4vw, 40px); text-align: center; }
.pdf-result:focus { outline: none; }
.pdf-result-icon { width: 84px; height: 84px; display: grid; place-items: center; margin-bottom: 6px; border-radius: 50%; background: var(--good-soft); }
.pdf-result-icon .pdf-ico { width: 52px; height: 52px; stroke: var(--good); stroke-width: 1.7; }
.pdf-result-title { margin: 0; font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); }
.pdf-result-title:focus { outline: none; }
.pdf-result-meta { margin: 0; color: var(--text-2); overflow-wrap: anywhere; }
.pdf-result-note { margin: 4px 0 0; color: var(--text-2); font-size: .9375rem; text-align: center; overflow-wrap: anywhere; }
.pdf-result-slot { width: 100%; display: flex; flex-direction: column; align-items: center; }
.pdf-result-slot:empty { display: none; }
.pdf-out-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.pdf-out-main .pdf-out-name { flex: none; }
.pdf-out-note { font-size: .8125rem; color: var(--text-2); overflow-wrap: anywhere; }
.pdf-result-time { margin: 0; font-size: .875rem; color: var(--muted); }
.pdf-result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 18px 0 4px; }
.pdf-download { padding: 15px 28px; font-size: 1.0625rem; border-radius: 12px; box-shadow: 0 8px 20px rgba(29, 67, 200, .24); }
.pdf-download .pdf-ico { width: 20px; height: 20px; stroke-width: 2.3; }
.pdf-result-actions .btn-ghost { padding: 15px 20px; border-radius: 12px; }
.pdf-outputs { width: 100%; max-width: 580px; margin: 16px 0 4px; padding: 0; list-style: none; text-align: left; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.pdf-outputs li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.pdf-outputs li:last-child { border-bottom: 0; }
.pdf-out-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9375rem; font-weight: 600; }
.pdf-out-meta { font-size: .8438rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pdf-out-dl { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 8px; font-size: .9063rem; font-weight: 600; text-decoration: none; }
.pdf-out-dl:hover { background: var(--accent-soft); }
.pdf-out-dl .pdf-ico { width: 16px; height: 16px; }
.pdf-outputs-wrap { width: 100%; max-width: 580px; margin-top: 14px; text-align: left; }
.pdf-outputs-wrap > summary { cursor: pointer; font-weight: 600; color: var(--accent); text-align: center; }
.pdf-result .pdf-badge { margin-top: 18px; }
@media (max-width: 480px) {
  .pdf-bar .pdf-summary { flex: 1 1 100%; }
  .pdf-bar-actions { gap: 4px; }
  .pdf-bar .segbtn { padding: 6px 8px; font-size: .8125rem; }
  .pdf-out-meta { display: none; }
  .pdf-out-dl span { display: none; }
  .pdf-result-actions { flex-direction: column; align-items: stretch; width: 100%; max-width: 320px; }
  .pdf-files { gap: 10px; }
  .pdf-card { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .pdf-spin, .pdf-progress-track.is-busy .pdf-progress-bar { animation-duration: 2.4s; }
  .pdf-thumb img { transition: none; }
}
@media print { .pdf-app { display: none; } }
