/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --border: #e4e6ef;
  --border-strong: #cbceda;
  --text: #14162b;
  --text-muted: #5b5f75;
  --text-faint: #8b8fa3;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;

  --success: #16a34a;
  --success-soft: #e7f8ee;
  --error: #dc2626;
  --error-soft: #fdecec;
  --warning: #b45309;
  --warning-soft: #fef3e2;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(20, 22, 43, 0.06);
  --shadow: 0 4px 16px rgba(20, 22, 43, 0.08);
  --shadow-lg: 0 16px 48px rgba(20, 22, 43, 0.14);

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  --header-h: 64px;
  --container: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117;
    --bg-soft: #161824;
    --surface: #191c29;
    --surface-2: #20232f;
    --border: #2b2f40;
    --border-strong: #3a3f54;
    --text: #f2f3f8;
    --text-muted: #a4a8bd;
    --text-faint: #767b94;
    --accent-soft: #23234a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1117;
  --bg-soft: #161824;
  --surface: #191c29;
  --surface-2: #20232f;
  --border: #2b2f40;
  --border-strong: #3a3f54;
  --text: #f2f3f8;
  --text-muted: #a4a8bd;
  --text-faint: #767b94;
  --accent-soft: #23234a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; }
ul, ol { list-style: none; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 1.25rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--text); color: var(--bg);
  z-index: 9999; border-radius: 8px; font-weight: 600; transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }
.section { padding-block: clamp(3rem, 6vw, 5.5rem); }
.section-soft { background: var(--bg-soft); }
.eyebrow {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .8rem; font-weight: 700; color: var(--accent-text);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .75rem;
}
.section-head { max-width: 640px; margin-bottom: 2.5rem; }
.section-head p { color: var(--text-muted); margin-top: .6rem; font-size: 1.05rem; }
.center { text-align: center; margin-inline: auto; }

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(2rem, 4.4vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); }
h3 { font-size: 1.2rem; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }

/* =============================================================
   5. Components
   ============================================================= */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.4rem; border-radius: var(--radius-sm); font-weight: 600; font-size: .95rem;
  transition: transform .18s var(--ease-out), background .18s var(--ease-out), box-shadow .18s var(--ease-out), border-color .18s var(--ease-out);
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-text); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-lg { padding: 1rem 1.8rem; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .3rem .6rem; border-radius: 100px;
}
.badge-live { background: var(--success-soft); color: var(--success); }
.badge-soon { background: var(--surface-2); color: var(--text-faint); }
.badge-beta { background: var(--warning-soft); color: var(--warning); }
.badge-new { background: var(--accent-soft); color: var(--accent-text); }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* Header / nav */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h); display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.logo { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; color: var(--text); }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; color: #fff; flex: none;
}
.logo-mark svg { width: 18px; height: 18px; }
.main-nav { display: none; align-items: center; gap: 1.8rem; }
.main-nav a { font-size: .93rem; font-weight: 600; color: var(--text-muted); transition: color .15s var(--ease-out); }
.main-nav a:hover { color: var(--text); }
.header-actions { display: flex; align-items: center; gap: .6rem; }
.nav-toggle { display: flex; padding: .5rem; }
.nav-toggle svg { width: 22px; height: 22px; }
.mobile-nav {
  position: fixed; inset: var(--header-h) 0 0 0; background: var(--bg); z-index: 90;
  padding: 1.5rem; display: none; overflow-y: auto;
}
.mobile-nav.is-open { display: block; }
.mobile-nav a { display: block; padding: .9rem 0; font-weight: 600; font-size: 1.05rem; border-bottom: 1px solid var(--border); }
.mobile-nav .header-actions { flex-direction: column; margin-top: 1.5rem; }
.mobile-nav .header-actions .btn { width: 100%; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding-block: 3rem 2rem; background: var(--bg-soft); }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: 1fr; margin-bottom: 2rem; }
.footer-col h4 { font-size: .85rem; margin-bottom: .9rem; }
.footer-col ul { display: flex; flex-direction: column; gap: .55rem; }
.footer-col a, .footer-col p { color: var(--text-muted); font-size: .92rem; }
.footer-col a:hover { color: var(--accent-text); }
.footer-bottom {
  display: flex; flex-direction: column; gap: .75rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  font-size: .85rem; color: var(--text-faint);
}
.footer-bottom-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; align-items: center; }
.footer-legal-links { display: flex; gap: 1rem; flex-wrap: wrap; }
.footer-credits { font-size: .78rem; color: var(--text-faint); }

/* Hero */
.hero { padding-block: clamp(2.5rem, 6vw, 4rem) clamp(2rem, 4vw, 3rem); }
.hero-inner { max-width: 780px; margin-inline: auto; text-align: center; }
.hero h1 { margin-bottom: .9rem; }
.hero-sub { font-size: clamp(1.02rem, 1.6vw, 1.2rem); color: var(--text-muted); max-width: 560px; margin-inline: auto 1.75rem; margin-bottom: 1.75rem; }
.hero-ctas { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; margin-bottom: 1.1rem; }
.hero-microcopy {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  font-size: .85rem; color: var(--text-faint); font-weight: 600;
}
.hero-microcopy svg { width: 15px; height: 15px; color: var(--success); flex: none; }

/* Tool card (upload/config/result) */
.tool-card {
  max-width: 880px; margin-inline: auto; border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 3vw, 2.25rem); box-shadow: var(--shadow); position: relative;
}
.tool-card[data-state] > * { display: none; }
.tool-card[data-state="idle"] [data-panel="idle"],
.tool-card[data-state="loading-engine"] [data-panel="loading-engine"],
.tool-card[data-state="configure"] [data-panel="configure"],
.tool-card[data-state="working"] [data-panel="working"],
.tool-card[data-state="done"] [data-panel="done"],
.tool-card[data-state="error"] [data-panel="error"],
.tool-card[data-state="no-text"] [data-panel="no-text"] { display: block; }
.tool-card noscript { display: block; margin-top: 1rem; text-align: center; color: var(--text-muted); font-size: .85rem; }

/* Dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: .9rem; padding: clamp(2.2rem, 6vw, 3.4rem) 1.5rem; border: 2px dashed var(--border-strong);
  border-radius: var(--radius); cursor: pointer; transition: border-color .18s var(--ease-out), background .18s var(--ease-out);
  background: var(--bg-soft);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon {
  width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.dropzone-icon svg { width: 28px; height: 28px; }
.dropzone-title { font-weight: 700; font-size: 1.05rem; }
.dropzone-hint { color: var(--text-muted); font-size: .88rem; }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.drop-overlay {
  position: fixed; inset: 0; z-index: 999; background: color-mix(in srgb, var(--accent) 14%, var(--bg) 86%);
  backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; flex-direction: column; gap: 1rem;
  border: 4px dashed var(--accent);
}
.drop-overlay.is-active { display: flex; }
.drop-overlay-icon { width: 88px; height: 88px; color: var(--accent); animation: dropPulse 1.4s var(--ease-soft) infinite; }
@keyframes dropPulse { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.drop-overlay p { font-size: 1.3rem; font-weight: 700; }

.privacy-badge {
  display: flex; align-items: center; gap: .55rem; justify-content: center; text-align: center;
  margin-top: 1.1rem; font-size: .85rem; color: var(--text-muted); flex-wrap: wrap;
}
.privacy-badge svg { width: 16px; height: 16px; color: var(--success); flex: none; }
.limits-note { text-align: center; font-size: .78rem; color: var(--text-faint); margin-top: .4rem; }

/* File list (merge etc) */
.file-list { display: flex; flex-direction: column; gap: .6rem; margin-block: 1.25rem; }
.file-row {
  display: flex; align-items: center; gap: .85rem; padding: .7rem .8rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: grab;
}
.file-row.is-dragging { opacity: .4; }
.file-row.drag-over-top { border-top: 2px solid var(--accent); }
.file-row.drag-over-bottom { border-bottom: 2px solid var(--accent); }
.file-thumb {
  width: 42px; height: 54px; flex: none; border-radius: 4px; background: var(--surface-2);
  border: 1px solid var(--border); overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.file-thumb img, .file-thumb canvas { width: 100%; height: 100%; object-fit: cover; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { font-size: .78rem; color: var(--text-faint); }
.file-actions { display: flex; align-items: center; gap: .3rem; flex: none; }
.icon-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text-muted); transition: background .15s, color .15s;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--error-soft); color: var(--error); }
.drag-handle { cursor: grab; color: var(--text-faint); }
.drag-handle:active { cursor: grabbing; }

/* Config panels (forms) */
.config-grid { display: grid; gap: 1.4rem; }
.field { display: flex; flex-direction: column; gap: .45rem; }
.field label, .field legend { font-size: .85rem; font-weight: 700; padding: 0; }
.field-hint { font-size: .78rem; color: var(--text-faint); }
.input, select.input, textarea.input {
  width: 100%; padding: .7rem .85rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-size: .92rem; color: var(--text);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: .55rem; }
.option-card {
  position: relative; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: .7rem .6rem; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
  display: flex; flex-direction: column; align-items: center; gap: .4rem; font-size: .82rem; font-weight: 600;
}
.option-card svg { width: 22px; height: 22px; color: var(--text-muted); }
.option-card input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.option-card:hover { border-color: var(--accent); }
.option-card.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.option-card.is-selected svg { color: var(--accent); }
.segmented { display: inline-flex; padding: .25rem; background: var(--surface-2); border-radius: 10px; gap: .2rem; flex-wrap: wrap; }
.segmented button {
  padding: .5rem 1rem; border-radius: 8px; font-size: .85rem; font-weight: 600; color: var(--text-muted);
  transition: background .15s, color .15s;
}
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.checkbox-row { display: flex; align-items: center; gap: .6rem; font-size: .9rem; font-weight: 500; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Progress */
.progress-wrap { text-align: center; padding-block: 1.5rem; }
.progress-title { font-weight: 700; margin-bottom: 1rem; }
.progress-bar { height: 10px; border-radius: 100px; background: var(--surface-2); overflow: hidden; margin-bottom: .6rem; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 100px; transition: width .25s var(--ease-out); width: 0%; }
.progress-sub { font-size: .85rem; color: var(--text-muted); }
.progress-cancel { margin-top: 1.1rem; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Result / done */
.result-wrap { text-align: center; padding-block: 1rem; }
.result-icon {
  width: 64px; height: 64px; border-radius: 50%; background: var(--success-soft); color: var(--success);
  display: flex; align-items: center; justify-content: center; margin-inline: auto 1rem; margin-bottom: 1rem;
}
.result-icon svg { width: 32px; height: 32px; }
.result-title { font-size: 1.3rem; margin-bottom: .3rem; }
.result-meta { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.4rem; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem; }
.result-secondary { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.2rem; margin-top: 1.1rem; }
.result-secondary button, .result-secondary a { font-size: .88rem; font-weight: 600; color: var(--text-muted); }
.result-secondary button:hover, .result-secondary a:hover { color: var(--accent-text); }
.result-stats { display: flex; justify-content: center; gap: 1.6rem; margin: 1.2rem 0; flex-wrap: wrap; }
.result-stat { text-align: center; }
.result-stat .num { font-size: 1.4rem; font-weight: 800; }
.result-stat .lbl { font-size: .76rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }

/* Error */
.error-wrap { text-align: center; padding-block: 1rem; }
.error-icon {
  width: 60px; height: 60px; border-radius: 50%; background: var(--error-soft); color: var(--error);
  display: flex; align-items: center; justify-content: center; margin-inline: auto; margin-bottom: 1rem;
}
.error-icon svg { width: 30px; height: 30px; }
.error-title { font-weight: 700; font-size: 1.1rem; margin-bottom: .4rem; }
.error-msg { color: var(--text-muted); font-size: .92rem; margin-bottom: 1.3rem; max-width: 420px; margin-inline: auto 1.3rem; }

/* Page grid (thumbnails, extract/delete/rearrange) */
.page-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-toolbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.page-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .9rem;
  max-height: 560px; overflow-y: auto; padding: .3rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft);
}
.page-item {
  position: relative; border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--surface);
  border: 2px solid transparent; box-shadow: var(--shadow-sm); transition: transform .15s var(--ease-out), border-color .15s;
  aspect-ratio: 3/4;
}
.page-item:hover { transform: translateY(-2px); }
.page-item canvas, .page-item img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.page-item .page-num {
  position: absolute; left: 6px; bottom: 6px; background: rgba(20,22,43,.72); color: #fff;
  font-size: .68rem; font-weight: 700; padding: .15rem .4rem; border-radius: 5px;
}
.page-item .page-check {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 6px;
  background: rgba(255,255,255,.9); border: 1.5px solid var(--border-strong); display: flex; align-items: center; justify-content: center;
  color: transparent; transition: all .12s;
}
.page-item .page-check svg { width: 13px; height: 13px; }
.page-item.is-selected { border-color: var(--accent); }
.page-item.is-selected .page-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-item.is-marked-delete { border-color: var(--error); }
.page-item.is-marked-delete::after {
  content: ""; position: absolute; inset: 0; background: rgba(220,38,38,.38);
}
.page-item .page-trash {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center; color: #fff; z-index: 1;
}
.page-item .page-trash svg { width: 26px; height: 26px; filter: drop-shadow(0 1px 3px rgba(0,0,0,.5)); }
.page-item.is-marked-delete .page-trash { display: flex; }
.page-item[data-rotate="90"] canvas, .page-item[data-rotate="90"] img { transform: rotate(90deg); }
.page-item[data-rotate="180"] canvas, .page-item[data-rotate="180"] img { transform: rotate(180deg); }
.page-item[data-rotate="270"] canvas, .page-item[data-rotate="270"] img { transform: rotate(270deg); }
.page-item.is-dragging { opacity: .35; }
.page-item .page-rotate-btn {
  position: absolute; bottom: 6px; right: 6px; width: 24px; height: 24px; border-radius: 6px;
  background: rgba(20,22,43,.72); color: #fff; display: flex; align-items: center; justify-content: center;
}
.page-item .page-rotate-btn svg { width: 13px; height: 13px; }
.page-item .page-delete-btn {
  position: absolute; bottom: 6px; left: 6px; width: 24px; height: 24px; border-radius: 6px;
  background: rgba(220,38,38,.85); color: #fff; display: flex; align-items: center; justify-content: center;
}
.page-item .page-delete-btn svg { width: 13px; height: 13px; }
.page-count-note { text-align: center; font-weight: 600; margin: 1rem 0; font-size: .95rem; }
.page-count-note .arrow { color: var(--text-faint); margin: 0 .4rem; }
.page-count-note .before { color: var(--text-faint); }
.page-count-note .after { color: var(--accent-text); }

/* Print preview */
.print-layout { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.print-panel-title { font-size: .95rem; font-weight: 700; margin-bottom: .9rem; }
.print-config { display: flex; flex-direction: column; gap: 1.3rem; }
.print-preview-wrap { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; }
.sheet-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: .6rem; flex-wrap: wrap; }
.sheet-nav-label { font-weight: 700; font-size: .92rem; }
.sheet-stage { display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.sheet-side { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.sheet-side-label { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.sheet-paper {
  background: #fff; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  display: grid; gap: 2px; position: relative; overflow: hidden;
}
.sheet-paper .slot {
  background: #f3f4f8; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
}
.sheet-paper .slot canvas, .sheet-paper .slot img { width: 100%; height: 100%; object-fit: contain; }
.sheet-paper .slot .slot-num {
  position: absolute; bottom: 2px; right: 3px; font-size: .58rem; background: rgba(20,22,43,.6); color: #fff;
  padding: 0 .25rem; border-radius: 3px;
}
.sheet-paper .slot.empty { background: repeating-linear-gradient(45deg, #f3f4f8, #f3f4f8 6px, #e9eaf1 6px, #e9eaf1 12px); }
.print-zoom-controls { display: flex; align-items: center; gap: .5rem; justify-content: center; }
.print-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .8rem; margin-top: 1.2rem; }
.print-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem; text-align: center; }
.print-stat-card .num { font-size: 1.5rem; font-weight: 800; }
.print-stat-card .lbl { font-size: .74rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; margin-top: .15rem; }
.color-pages-toggle { margin-top: .9rem; }
.cost-calc { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px dashed var(--border); }
.cost-calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
.cost-result { margin-top: 1rem; padding: 1rem; background: var(--accent-soft); border-radius: var(--radius-sm); text-align: center; }
.cost-result .num { font-size: 1.7rem; font-weight: 800; color: var(--accent-text); }

@media (min-width: 960px) {
  .print-layout { grid-template-columns: 380px 1fr; align-items: start; }
}

/* Edit PDF canvas tool */
.editor-shell { display: flex; flex-direction: column; gap: 1rem; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .4rem; padding: .6rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.editor-toolbar button {
  display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .5rem .7rem; border-radius: 8px;
  font-size: .68rem; font-weight: 700; color: var(--text-muted); min-width: 58px;
}
.editor-toolbar button svg { width: 19px; height: 19px; }
.editor-toolbar button:hover { background: var(--surface); color: var(--text); }
.editor-toolbar button.is-active { background: var(--accent); color: #fff; }
.editor-stage-wrap { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; background: var(--bg-soft); max-height: 620px; }
.editor-stage { position: relative; margin-inline: auto; }
.editor-stage canvas.page-canvas { display: block; }
.editor-obj {
  position: absolute; border: 1.5px dashed transparent; cursor: move; user-select: none; touch-action: none;
}
.editor-obj:hover, .editor-obj.is-active { border-color: var(--accent); }
.editor-obj.is-active { box-shadow: 0 0 0 3px var(--accent-soft); }
.editor-obj .resize-handle {
  position: absolute; width: 12px; height: 12px; background: var(--accent); border-radius: 3px; right: -6px; bottom: -6px; cursor: nwse-resize;
  display: none;
}
.editor-obj.is-active .resize-handle { display: block; }
.editor-page-nav { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.sig-pad-wrap { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; touch-action: none; }
.sig-tabs { display: flex; gap: .4rem; margin-bottom: .8rem; }

/* Extract text */
.text-output-wrap { position: relative; }
.text-output {
  width: 100%; min-height: 320px; max-height: 480px; resize: vertical; font-family: var(--mono); font-size: .86rem;
  padding: 1rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); line-height: 1.55;
}
.text-toolbar { display: flex; gap: .6rem; margin-bottom: .8rem; flex-wrap: wrap; }

/* Ad placeholders */
.ad-slot {
  display: flex; align-items: center; justify-content: center; margin-inline: auto;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-soft);
  color: var(--text-faint); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  position: relative;
}
.ad-slot::before { content: attr(data-label); }
.ad-header { width: 100%; max-width: 970px; height: 90px; margin-block: 0 0; display: none; }
.ad-below-tool { width: 100%; max-width: 728px; height: 90px; margin-block: 2rem auto; }
.ad-content { width: 100%; max-width: 468px; height: 120px; margin-block: 2.5rem auto; }
.ad-sidebar { width: 300px; height: 250px; display: none; }
.ad-corner {
  position: fixed; bottom: 1rem; right: 1rem; width: 240px; height: 90px; z-index: 60; box-shadow: var(--shadow-lg);
  background: var(--surface);
}
.ad-corner-close {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; background: var(--text);
  color: var(--bg); display: flex; align-items: center; justify-content: center; font-size: .85rem;
}
@media (min-width: 960px) { .ad-header { display: flex; } }

/* Download interstitial modal */
.dl-modal { border: none; border-radius: var(--radius-lg); padding: 0; max-width: 420px; width: calc(100% - 2rem); box-shadow: var(--shadow-lg); }
.dl-modal::backdrop { background: rgba(15, 17, 23, .55); backdrop-filter: blur(2px); }
.dl-modal-inner { padding: 1.6rem; text-align: center; }
.dl-modal-close { position: absolute; top: .8rem; right: .8rem; width: 32px; height: 32px; border-radius: 8px; }
.dl-modal-close:hover { background: var(--surface-2); }
.dl-modal .ad-slot { height: 250px; margin-block: 1rem 1.3rem; }

/* Catalog */
.catalog-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 2rem; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.tool-tile {
  display: flex; flex-direction: column; gap: .8rem; padding: 1.3rem; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), border-color .18s;
}
.tool-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.tool-tile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.tool-tile-icon {
  width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.tool-tile-icon svg { width: 22px; height: 22px; }
.tool-tile h3 { font-size: 1rem; }
.tool-tile p { font-size: .85rem; color: var(--text-muted); }
.tool-tile-cat { font-size: .72rem; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

/* Steps */
.steps-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; counter-reset: step; }
.step-card { text-align: center; }
.step-num {
  width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; margin-inline: auto; margin-bottom: 1rem; font-size: 1.1rem;
}
.step-card h3 { margin-bottom: .4rem; font-size: 1.02rem; }
.step-card p { color: var(--text-muted); font-size: .92rem; }

/* Use cases */
.usecase-grid { display: grid; gap: 1.1rem; grid-template-columns: 1fr; }
.usecase-card { padding: 1.4rem; }
.usecase-card .icon { width: 42px; height: 42px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; margin-bottom: .9rem; }
.usecase-card .icon svg { width: 22px; height: 22px; }
.usecase-card h3 { font-size: 1.02rem; margin-bottom: .35rem; }
.usecase-card p { color: var(--text-muted); font-size: .9rem; }

/* FAQ */
.faq-list { max-width: 760px; margin-inline: auto; display: flex; flex-direction: column; gap: .7rem; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.faq-item summary {
  cursor: pointer; padding: 1.05rem 1.2rem; font-weight: 600; font-size: .95rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary .chev { flex: none; width: 18px; height: 18px; color: var(--text-faint); transition: transform .2s var(--ease-out); }
.faq-item[open] summary .chev { transform: rotate(180deg); }
.faq-item .faq-body { padding: 0 1.2rem 1.2rem; color: var(--text-muted); font-size: .9rem; line-height: 1.65; }

/* Related tools */
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; }
.related-tile { display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem; border-radius: var(--radius-sm); }
.related-tile .tool-tile-icon { width: 36px; height: 36px; }
.related-tile .tool-tile-icon svg { width: 18px; height: 18px; }
.related-tile span { font-size: .87rem; font-weight: 600; }
.related-tile:hover { border-color: var(--accent); }

/* SEO content blocks */
.prose { max-width: 720px; margin-inline: auto; color: var(--text-muted); font-size: .98rem; line-height: 1.75; }
.prose h2, .prose h3 { color: var(--text); margin-top: 1.6rem; margin-bottom: .6rem; }
.prose ul { list-style: disc; padding-left: 1.3rem; }
.prose li { margin-bottom: .4rem; }

/* Toast (Recent tools / history removal notice etc.) */
.toast {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: .7rem 1.2rem; border-radius: 100px; font-size: .85rem; font-weight: 600;
  z-index: 200; pointer-events: none; transition: opacity .25s var(--ease-out), transform .25s var(--ease-out);
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Recent tools */
.recent-tools { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .3rem; }
.recent-tool-chip {
  flex: none; display: flex; align-items: center; gap: .5rem; padding: .5rem .9rem; border-radius: 100px;
  border: 1px solid var(--border); font-size: .82rem; font-weight: 600; background: var(--surface);
}

/* Legal pages */
.legal-page .prose { max-width: 780px; }

/* =============================================================
   6. Reduced-motion (intrusive only)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .drop-overlay-icon { animation: none; }
  .spinner { animation-duration: 1.4s; }
}

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 720px) {
  .hero-ctas { gap: 1rem; }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .usecase-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
  .main-nav { display: flex; }
  .nav-toggle { display: none; }
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
  .usecase-grid { grid-template-columns: repeat(3, 1fr); }
  .ad-sidebar { display: flex; }
}
@media (min-width: 1280px) {
  .container { padding-inline: 2rem; }
}
