/* ==========================================================================
   DocEpic — global stylesheet
   1. Tokens & themes   2. Base   3. Layout & grid   4. Buttons & chips
   5. Header & nav      6. Footer 7. Ad slots        8. Home
   9. Tool page         10. Dialogs & toasts         11. Consent & utilities
   ========================================================================== */

/* 1. Tokens & themes ------------------------------------------------------ */
:root {
  /* #cf3a2e: white on it, and it on white or the page background, stay above 4.5:1 (WCAG AA). */
  --brand: #cf3a2e;
  --brand-strong: #b02f25;
  --brand-soft: #fdecea;
  --on-brand: #ffffff;

  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --border: #e1e4ec;
  --text: #1b1f2e;
  --text-muted: #5b6276;
  --success: #15803d;
  --danger: #c62828;

  --cat-organize: #ea6a12;
  --cat-optimize: #17914a;
  --cat-convert-to: #2563eb;
  --cat-convert-from: #0b8aa8;
  --cat-edit: #8b3fd6;
  --cat-security: #4b5568;
  --cat-ai: #d0287a;

  --group-0: var(--cat-convert-to);
  --group-1: var(--cat-organize);
  --group-2: var(--cat-optimize);
  --group-3: var(--cat-edit);
  --group-4: var(--cat-ai);
  --group-5: var(--cat-convert-from);

  --ad-bg: repeating-linear-gradient(45deg, #f7f8fb 0 10px, #f0f2f7 10px 20px);
  --ad-border: #c9cedb;

  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
  --shadow-md: 0 6px 16px rgb(16 24 40 / 0.08);
  --shadow-lg: 0 18px 48px rgb(16 24 40 / 0.18);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --header-h: 64px;
  --container: 1240px;
  --gutter: 16px;
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--brand) 40%, transparent);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #f0625a;
    --on-brand: #1b0a09; /* white on this lighter red is only 3.2:1 */
    --brand-strong: #ff7a72;
    --brand-soft: #3a1d1c;
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1f2330;
    --border: #2b3040;
    --text: #e9ebf2;
    --text-muted: #9aa1b5;
    --success: #4ade80;
    --danger: #f87171;
    --cat-organize: #fb923c;
    --cat-optimize: #4ade80;
    --cat-convert-to: #60a5fa;
    --cat-convert-from: #22d3ee;
    --cat-edit: #c084fc;
    --cat-security: #a3adc2;
    --cat-ai: #f472b6;
    --ad-bg: repeating-linear-gradient(45deg, #191c26 0 10px, #1d2130 10px 20px);
    --ad-border: #3a4054;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 6px 16px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 18px 48px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --brand: #f0625a;
  --on-brand: #1b0a09;
  --brand-strong: #ff7a72;
  --brand-soft: #3a1d1c;
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1f2330;
  --border: #2b3040;
  --text: #e9ebf2;
  --text-muted: #9aa1b5;
  --success: #4ade80;
  --danger: #f87171;
  --cat-organize: #fb923c;
  --cat-optimize: #4ade80;
  --cat-convert-to: #60a5fa;
  --cat-convert-from: #22d3ee;
  --cat-edit: #c084fc;
  --cat-security: #a3adc2;
  --cat-ai: #f472b6;
  --ad-bg: repeating-linear-gradient(45deg, #191c26 0 10px, #1d2130 10px 20px);
  --ad-border: #3a4054;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 6px 16px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 18px 48px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

@media (min-width: 768px) {
  :root { --gutter: 24px; --header-h: 68px; }
}

/* 2. Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

main { flex: 1; outline: none; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.85rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Links inside running text are underlined, so they don't rely on colour alone (WCAG 1.4.1). */
p a:not(.btn), li > a:not([class]):is(.prose *), .prose a:not(.btn) { text-decoration: underline; text-underline-offset: 2px; }

img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

[hidden] { display: none !important; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 1000;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--brand); color: var(--on-brand);
}
.skip-link:focus { top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* 3. Layout & grid -------------------------------------------------------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 760px; }
.center { text-align: center; }
.muted { color: var(--text-muted); }

.section { padding-block: 40px; }
.section--alt { background: var(--surface); border-block: 1px solid var(--border); }
.section__title { margin-bottom: 20px; }

.grid { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }

.prose { line-height: 1.7; }

/* 4. Buttons & chips ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 10px;
  font-weight: 600; font-size: 0.95rem; line-height: 1;
  cursor: pointer; text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--primary { background: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-strong); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--danger); color: #fff; }
.btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 0.85rem; border-radius: 8px; }
.btn--lg { min-height: 50px; padding: 0 26px; font-size: 1.05rem; }
.btn--xl { min-height: 58px; padding: 0 40px; font-size: 1.15rem; border-radius: 12px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; border: 0; border-radius: 10px;
  background: transparent; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.link-btn { padding: 0; border: 0; background: none; color: inherit; cursor: pointer; font-size: inherit; }
.link-btn:hover { color: var(--brand); }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font-weight: 500; font-size: 0.92rem;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cat, var(--brand)); }
.chip:hover { border-color: var(--cat, var(--brand)); text-decoration: none; }

/* 5. Header & nav --------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { position: relative; display: flex; align-items: center; gap: 16px; height: var(--header-h); }

.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 1.2rem; }
.logo:hover { text-decoration: none; }
.logo__mark { width: 32px; height: 32px; flex: none; }

.header-actions { margin-left: auto; display: flex; gap: 4px; }

.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

.nav-list { display: flex; align-items: center; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 12px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font-weight: 600; font-size: 0.93rem; cursor: pointer; white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.chevron { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform 0.2s; }
.has-mega.is-open .chevron { transform: rotate(180deg); }

.mega { display: none; }
.mega__heading {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted);
}
.mega__heading::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--cat); }
.mega ul { margin: 0; padding: 0; list-style: none; }
.mega a { display: block; padding: 6px 8px; margin-inline: -8px; border-radius: 6px; color: var(--text); font-size: 0.93rem; }
.mega a:hover { background: var(--surface-2); text-decoration: none; }

.nav-burger { display: none; }

/* Desktop: inline nav with dropdown mega menus */
@media (min-width: 1024px) {
  .main-nav, .nav-list { height: 100%; }
  .main-nav { margin-left: 24px; }
  /* The <li> spans the full header height so the pointer never leaves it on the way to the panel. */
  .has-mega { display: flex; align-items: center; height: 100%; }
  .has-mega.is-open > .mega {
    display: grid; gap: 24px;
    position: absolute; top: calc(100% - 1px); left: var(--gutter); right: var(--gutter);
    padding: 24px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); box-shadow: var(--shadow-lg);
  }
  @media (hover: hover) {
    .has-mega:hover > .mega {
      display: grid; gap: 24px;
      position: absolute; top: calc(100% - 1px); left: var(--gutter); right: var(--gutter);
      padding: 24px; border: 1px solid var(--border); border-radius: var(--radius);
      background: var(--surface); box-shadow: var(--shadow-lg);
    }
  }
  .mega--convert { grid-template-columns: repeat(2, minmax(0, 220px)); justify-content: center; }
  .mega--all { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* Mobile & tablet: off-canvas drawer with accordion menus */
@media (max-width: 1023.98px) {
  .nav-burger { display: inline-grid; }
  .main-nav {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 120;
    width: min(340px, 86vw); padding: 72px 16px 24px; overflow-y: auto;
    background: var(--surface); box-shadow: var(--shadow-lg);
    transform: translateX(100%); transition: transform 0.25s ease; visibility: hidden;
  }
  .main-nav.is-open { transform: none; visibility: visible; }
  .nav-list { flex-direction: column; align-items: stretch; }
  .nav-link { width: 100%; justify-content: space-between; padding: 12px; font-size: 1rem; }
  .has-mega.is-open > .mega { display: grid; gap: 16px; padding: 8px 12px 16px; }
  .nav-scrim { position: fixed; inset: 0; z-index: 110; background: rgb(0 0 0 / 0.45); }
  /* backdrop-filter would make the header the containing block of the fixed drawer and scrim, clipping them to 64px. */
  .site-header { backdrop-filter: none; background: var(--surface); }
  body.nav-open { overflow: hidden; }
  body.nav-open .nav-burger { position: relative; z-index: 130; }
}

/* 6. Footer --------------------------------------------------------------- */
.site-footer { margin-top: 24px; padding-top: 40px; background: var(--surface); border-top: 1px solid var(--border); font-size: 0.92rem; }
.footer-top { display: grid; gap: 32px; }
@media (min-width: 1024px) { .footer-top { grid-template-columns: 260px 1fr; } }
.footer-brand p { color: var(--text-muted); }
.privacy-badge { display: flex; gap: 8px; align-items: flex-start; }
.privacy-badge svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--success); stroke-width: 1.8; stroke-linejoin: round; }
.footer-links { display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.footer-col__title { margin: 0 0 10px; font-weight: 700; color: var(--text); }
.footer-col ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.footer-col a, .footer-col .link-btn { color: var(--text-muted); }
.footer-col a:hover { color: var(--brand); }
.footer-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  margin-top: 32px; padding-block: 20px; border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.85rem;
}
.footer-bottom p { margin: 0; }

/* 7. Ad slots ------------------------------------------------------------- */
/* Each variant reserves its height up front so ads never push content around (Core Web Vitals / CLS). */
.ad-slot {
  --ad-h: 90px;
  --ad-w: 100%;
  position: relative;
  width: 100%; max-width: var(--ad-w);
  margin: 20px auto;
  text-align: center;
}
.ad-slot__label {
  display: block; margin-bottom: 4px;
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted);
}
.ad-slot ins.adsbygoogle { min-height: var(--ad-h); }

.ad-slot--leaderboard { --ad-h: 100px; --ad-w: 970px; }
@media (min-width: 768px) { .ad-slot--leaderboard { --ad-h: 90px; } }
.ad-slot--banner     { --ad-h: 100px; --ad-w: 970px; }
.ad-slot--infeed     { --ad-h: 180px; --ad-w: 100%; }
.ad-slot--rectangle  { --ad-h: 280px; --ad-w: 336px; }
.ad-slot--skyscraper { --ad-h: 600px; --ad-w: 300px; margin: 0; }
.ad-slot--anchor     { --ad-h: 50px;  --ad-w: 320px; margin: 0 auto; }

/* Placeholder mode (no publisher ID yet): dashed preview box showing unit name and size. */
.ad-slot.is-placeholder ins.adsbygoogle { display: none !important; }
.ad-slot.is-placeholder::after {
  content: attr(data-ad-name) " · " attr(data-ad-size);
  display: flex; align-items: center; justify-content: center;
  min-height: var(--ad-h); padding: 8px;
  border: 1.5px dashed var(--ad-border); border-radius: var(--radius-sm);
  background: var(--ad-bg); color: var(--text-muted); font-size: 0.8rem; font-weight: 600;
}

/* Mobile sticky anchor. Only one anchor per page: if you enable Auto Ads anchors in AdSense, remove this unit. */
.anchor-ad {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgb(0 0 0 / 0.08);
}
.anchor-ad .ad-slot__label { display: none; }
.anchor-ad__close {
  position: absolute; top: -28px; right: 8px;
  width: 28px; height: 28px; border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0;
  background: var(--surface); cursor: pointer; font-size: 1.1rem; line-height: 1;
}
body.has-anchor { padding-bottom: 70px; }
@media (min-width: 768px) { .anchor-ad { display: none !important; } body.has-anchor { padding-bottom: 0; } }

/* 8. Home ----------------------------------------------------------------- */
.hero { padding: 40px 0 8px; text-align: center; }
.hero__inner { max-width: 900px; }
.hero__lead { max-width: 680px; margin-inline: auto; color: var(--text-muted); font-size: 1.08rem; }
.hero__chips { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin-top: 16px; }
.hero__chips-label { color: var(--text-muted); font-size: 0.9rem; margin-right: 2px; }
.hero__chips .chip { padding: 6px 12px; font-size: 0.85rem; }

.hub-search { position: relative; max-width: 640px; margin: 24px auto 0; }
.hub-search__icon {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.hub-search__input {
  width: 100%; height: 56px; padding: 0 52px 0 52px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 1rem;
  box-shadow: var(--shadow-md); -webkit-appearance: none; appearance: none;
}
.hub-search__input::placeholder { color: var(--text-muted); opacity: 0.85; }
.hub-search__input:focus { outline: none; border-color: var(--brand); box-shadow: var(--shadow-md), var(--focus-ring); }
.hub-search__input::-webkit-search-cancel-button { cursor: pointer; }
.hub-search__kbd {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  min-width: 24px; padding: 2px 7px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-2); color: var(--text-muted); font: 600 0.8rem/1.4 var(--font); text-align: center;
}
.hub-search__input:focus ~ .hub-search__kbd, .hub-search__input:not(:placeholder-shown) ~ .hub-search__kbd { display: none; }
@media (hover: none) { .hub-search__kbd { display: none; } }

.section--hub { padding-top: 16px; }
.hub-bar {
  position: sticky; top: var(--header-h); z-index: 40;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin: 0 calc(var(--gutter) * -1) 20px; padding: 12px var(--gutter);
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
}
.filter-chips {
  display: flex; gap: 8px; min-width: 0; max-width: 100%;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip--filter { flex: none; padding: 8px 14px; }
.chip--plain::before { display: none; }
.chip__count { color: var(--text-muted); font-size: 0.78rem; font-weight: 600; }
.chip--filter[aria-current="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip--filter[aria-current="true"] .chip__count { color: inherit; opacity: 0.75; }
.chip--filter[aria-current="true"]::before { background: var(--surface); }
.hub-status { margin: 0; color: var(--text-muted); font-size: 0.88rem; }
.hub-status strong { color: var(--text); }

.hub-grid {
  display: grid; gap: 16px; margin: 0; padding: 0; list-style: none;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}
.hub-item { min-width: 0; }

.tool-card {
  display: flex; flex-direction: column; gap: 8px; height: 100%;
  padding: 20px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.tool-card:hover { border-color: var(--cat); box-shadow: var(--shadow-md); transform: translateY(-3px); text-decoration: none; }
.tool-card:focus-visible { border-radius: var(--radius); }
.tool-card__name { margin-top: 6px; font-weight: 700; font-size: 1.05rem; }
.tool-card__desc { color: var(--text-muted); font-size: 0.9rem; line-height: 1.45; }
.tool-card__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }

.tool-icon {
  display: grid; place-items: center; width: 48px; height: 48px; flex: none;
  border-radius: 12px; color: var(--cat);
  background: color-mix(in srgb, var(--cat) 14%, transparent);
}
.tool-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; }
/* Tag text is the colour mixed towards the body text: at this small size it needs 4.5:1, in both themes. */
.tag--client { background: color-mix(in srgb, var(--success) 14%, transparent); color: color-mix(in srgb, var(--success) 60%, var(--text)); }
.tag--server { background: color-mix(in srgb, var(--cat-convert-to) 14%, transparent); color: color-mix(in srgb, var(--cat-convert-to) 60%, var(--text)); }
.tag--popular { background: var(--brand-soft); color: color-mix(in srgb, var(--brand) 60%, var(--text)); }

/* Native in-feed ad card: same footprint as a tool card, clearly labelled. */
.hub-item--ad {
  display: flex; flex-direction: column; justify-content: center;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.hub-item--ad .ad-slot { --ad-h: 180px; margin: 0; }

.hub-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 48px 16px; text-align: center; }
.hub-empty svg { width: 56px; height: 56px; fill: none; stroke: var(--text-muted); stroke-width: 1.6; stroke-linecap: round; margin-bottom: 8px; }
.hub-empty__title { margin: 0; font-size: 1.15rem; font-weight: 700; overflow-wrap: anywhere; }

.feature { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.feature p { margin: 0; color: var(--text-muted); }

/* 9. Tool page ------------------------------------------------------------ */
.tool-page { padding-top: 8px; }

.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; padding: 0; list-style: none; font-size: 0.85rem; color: var(--text-muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; opacity: 0.6; }
.breadcrumbs a { color: var(--text-muted); }

.tool-hero { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 24px; }
.tool-hero .tool-icon { width: 56px; height: 56px; margin-bottom: 12px; }
.tool-hero .tool-icon svg { width: 30px; height: 30px; }
.tool-hero p { color: var(--text-muted); font-size: 1.05rem; max-width: 640px; margin-inline: auto; }
.engine-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
  background: var(--surface-2); color: color-mix(in srgb, var(--text-muted) 60%, var(--text));
}
.engine-badge::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.engine-badge--server::before { background: var(--cat-convert-to); }

.tool-layout { display: grid; gap: 24px; align-items: start; }
.tool-sidebar { display: none; }
@media (min-width: 1100px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .tool-layout--solo { grid-template-columns: minmax(0, 1fr); }
  .tool-sidebar { display: block; position: sticky; top: calc(var(--header-h) + 16px); }
}

.workspace { min-width: 0; }
.ws-panel {
  min-height: 380px; padding: 24px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
@media (min-width: 768px) { .ws-panel { padding: 32px; } }
.ws-panel--upload { display: grid; padding: 12px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 356px; padding: 24px;
  border: 2px dashed color-mix(in srgb, var(--cat, var(--brand)) 45%, var(--border));
  border-radius: var(--radius); text-align: center; cursor: pointer;
  background: color-mix(in srgb, var(--cat, var(--brand)) 4%, transparent);
  transition: background-color 0.15s, border-color 0.15s;
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--cat, var(--brand));
  background: color-mix(in srgb, var(--cat, var(--brand)) 10%, transparent);
}
.dropzone__icon { width: 64px; height: 64px; fill: none; stroke: var(--cat, var(--brand)); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dropzone__title { margin: 8px 0 0; font-size: 1.25rem; font-weight: 700; }
.dropzone__hint { margin: 0 0 8px; color: var(--text-muted); }

.processing, .done { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding-block: 16px; }
.processing__title { margin: 8px 0 0; font-size: 1.15rem; font-weight: 700; }
.processing__pct { margin: 0; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.spinner {
  width: 56px; height: 56px; border-radius: 50%;
  border: 5px solid var(--surface-2); border-top-color: var(--brand);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress { width: min(420px, 100%); height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress__bar { width: 0; height: 100%; border-radius: inherit; background: var(--brand); transition: width 0.25s ease; }

.done__icon { width: 72px; height: 72px; fill: none; stroke: var(--success); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.done__icon--error { stroke: var(--danger); }
.done__title { margin: 4px 0 0; }
.done__summary { margin: 0; color: var(--text-muted); }
.done__secondary { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.done__ad { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }

.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 10px; color: var(--text-muted); }
.steps strong { color: var(--text); }

.error-code { margin: 0; font-size: 5rem; font-weight: 800; line-height: 1; color: var(--brand); }

/* 9b. Workbench, file board & drag-and-drop (Step 3) --------------------- */
.workspace { container-type: inline-size; }
.ws-panel--options { padding: 16px; }
@media (min-width: 768px) { .ws-panel--options { padding: 24px; } }

.workbench { display: grid; gap: 20px; align-items: start; }
@container (min-width: 720px) {
  .workbench { grid-template-columns: minmax(0, 1fr) 260px; }
  .workbench__quick-run { display: none; }
  .workbench__panel { position: sticky; top: calc(var(--header-h) + 16px); }
}
.workbench__toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.workbench__count { margin: 0; font-weight: 700; }
.workbench__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.workbench__hint { margin: 14px 0 0; color: var(--text-muted); font-size: 0.85rem; }
.workbench__panel {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.workbench__title { margin: 0; font-size: 1.05rem; }
.workbench__options { display: grid; gap: 14px; font-size: 0.92rem; }
.workbench__options p { margin: 0; }
.workbench__requirement { margin: 0; color: var(--danger); font-size: 0.85rem; font-weight: 600; }
.workbench__run { width: 100%; padding-inline: 16px; white-space: nowrap; }

.file-board {
  display: grid; gap: 14px; margin: 0; padding: 0; list-style: none;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.file-card {
  position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0;
  padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  cursor: grab; user-select: none; -webkit-user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.file-card:hover, .file-card:focus-visible { border-color: var(--cat, var(--brand)); box-shadow: var(--shadow-md); }
.file-card:focus-visible { border-radius: 12px; }
.file-card.is-dragging { opacity: 0.35; border-style: dashed; box-shadow: none; }
.file-card.is-error { border-color: var(--danger); cursor: default; }
.file-card.is-error .file-card__meta { color: var(--danger); }

.file-card__thumb {
  display: grid; place-items: center; aspect-ratio: 3 / 4; overflow: hidden;
  border-radius: 8px; background: var(--surface-2);
}
.file-card__thumb > canvas, .file-card__thumb > img {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain; box-shadow: 0 1px 4px rgb(0 0 0 / 0.18); pointer-events: none;
}
.thumb-file {
  display: grid; place-items: center; width: 64%; aspect-ratio: 3 / 4; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--cat, var(--brand)); font-weight: 800; font-size: 0.85rem; letter-spacing: 0.04em;
}
.skeleton {
  width: 72%; aspect-ratio: 3 / 4; border-radius: 6px;
  background: linear-gradient(100deg, var(--surface) 30%, var(--border) 50%, var(--surface) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -150% 0; } }

.file-card__pages {
  position: absolute; top: 16px; left: 16px;
  min-width: 26px; padding: 1px 7px; border-radius: 999px;
  background: rgb(20 22 30 / 0.78); color: #fff; font-size: 0.75rem; font-weight: 700; text-align: center;
}
.file-card__info { display: grid; gap: 1px; min-width: 0; }
.file-card__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 0.85rem; }
.file-card__meta { color: var(--text-muted); font-size: 0.75rem; }

.file-card__order { display: flex; justify-content: center; gap: 4px; }
.file-card__btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text-muted); cursor: pointer;
}
.file-card__btn:hover { background: var(--surface-2); color: var(--text); }
.file-card__btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.file-card__grip { cursor: grab; touch-action: none; }
.file-card__grip svg { fill: currentColor; stroke: none; }

.file-card__remove {
  position: absolute; top: 4px; right: 4px;
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-muted);
  cursor: pointer; box-shadow: var(--shadow-sm); opacity: 0; transition: opacity 0.15s;
}
.file-card__remove svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.file-card__remove:hover { color: var(--danger); border-color: var(--danger); }
.file-card:hover .file-card__remove, .file-card:focus-within .file-card__remove, .file-card.is-error .file-card__remove { opacity: 1; }
@media (hover: none) { .file-card__remove { opacity: 1; } }

.file-add { display: flex; }
.file-add__btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 200px;
  border: 2px dashed var(--border); border-radius: 12px; background: none; color: var(--text-muted);
  font-weight: 600; font-size: 0.85rem; cursor: pointer;
}
.file-add__btn:hover { border-color: var(--cat, var(--brand)); color: var(--cat, var(--brand)); }
.file-add__btn svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.sortable-ghost {
  position: fixed; z-index: 500; margin: 0; list-style: none; pointer-events: none;
  border-color: var(--cat, var(--brand)); box-shadow: var(--shadow-lg); opacity: 0.95;
}
body.is-sorting, body.is-sorting * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }

.drop-overlay {
  position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--brand) 14%, rgb(10 12 20 / 0.45)); backdrop-filter: blur(3px);
  pointer-events: none;
}
.drop-overlay__box {
  display: grid; justify-items: center; gap: 8px; width: min(520px, 100%); padding: 48px 24px;
  border: 3px dashed #fff; border-radius: var(--radius-lg); color: #fff; text-align: center;
}
.drop-overlay__box svg { width: 64px; height: 64px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.drop-overlay__box p { margin: 0; font-size: 1.4rem; font-weight: 800; }

/* 9c. Form controls & page grid (Step 4) ---------------------------------- */
.field__hint { color: var(--text-muted); font-size: 0.8rem; line-height: 1.4; }
.workbench__panel .input { background: var(--surface); }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; line-height: 1.4; }
.check input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand); cursor: pointer; }
.check small { display: block; margin-top: 2px; color: var(--text-muted); font-size: 0.8rem; }

.segmented { display: flex; gap: 2px; margin: 0; padding: 3px; border: 0; border-radius: 10px; background: var(--surface-2); }
.segmented label { position: relative; flex: 1; }
.segmented input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.segmented span {
  display: block; padding: 8px 4px; border-radius: 8px; text-align: center;
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted); line-height: 1.2;
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { box-shadow: var(--focus-ring); }

.select-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.summary { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 600; font-size: 0.88rem; }

.page-grid {
  display: grid; gap: 12px; margin: 0; padding: 0; list-style: none;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
}
.page-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0;
  padding: 8px 8px 6px; border: 2px solid transparent; border-radius: 12px;
  background: var(--surface-2); user-select: none; -webkit-user-select: none;
  transition: border-color 0.12s, background-color 0.12s, opacity 0.12s;
}
.page-card:focus-visible { border-radius: 12px; }
.page-card__thumb { display: grid; place-items: center; width: 100%; aspect-ratio: 3 / 4; overflow: hidden; }
.page-card__thumb > canvas, .page-card__thumb > img {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.2); pointer-events: none; transition: opacity 0.12s;
}
.thumb-blank { width: 76%; aspect-ratio: 3 / 4; background: #fff; border: 1px dashed #b9bfcc; box-shadow: 0 1px 4px rgb(0 0 0 / 0.12); }
.thumb-blank.is-landscape { width: 96%; aspect-ratio: 4 / 3; }
.page-card__label { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; font-weight: 700; color: var(--text-muted); }
.page-card__file {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 5px;
  background: var(--file); color: #fff; font-size: 0.7rem;
}

/* select mode */
.page-grid--select .page-card { cursor: pointer; }
.page-grid--select .page-card:hover { border-color: color-mix(in srgb, var(--cat, var(--brand)) 45%, transparent); }
.page-card__check {
  position: absolute; top: 12px; right: 12px; display: grid; place-items: center;
  width: 24px; height: 24px; border: 2px solid var(--border); border-radius: 50%; background: var(--surface);
}
.page-card__check svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.page-grid--keep .page-card__check .cross, .page-grid--remove .page-card__check .tick { display: none; }
.page-card.is-selected .page-card__check svg { visibility: visible; }
.page-grid--keep .page-card.is-selected { border-color: var(--cat, var(--brand)); background: color-mix(in srgb, var(--cat, var(--brand)) 12%, var(--surface)); }
.page-grid--keep .page-card.is-selected .page-card__check { background: var(--cat, var(--brand)); border-color: var(--cat, var(--brand)); }
.page-grid--remove .page-card.is-selected { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.page-grid--remove .page-card.is-selected .page-card__thumb > * { opacity: 0.3; }
.page-grid--remove .page-card.is-selected .page-card__check { background: var(--danger); border-color: var(--danger); }

/* view mode groups (Split) */
.page-card__group {
  position: absolute; top: 12px; left: 12px; padding: 1px 7px; border-radius: 999px;
  background: var(--group); color: #fff; font-size: 0.7rem; font-weight: 700; box-shadow: var(--shadow-sm);
}
.page-grid--view .page-card:not(.is-out) { border-color: color-mix(in srgb, var(--group) 55%, transparent); }
.page-card.is-out { opacity: 0.4; }

/* organize mode */
.page-grid--organize .page-card { cursor: grab; }
.page-grid--organize .page-card:hover { border-color: var(--cat, var(--brand)); }
.page-card.is-dragging { opacity: 0.3; border-style: dashed; border-color: var(--cat, var(--brand)); }
.page-card__actions {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 1px; padding: 2px; border-radius: 9px;
  background: var(--surface); box-shadow: var(--shadow-md); opacity: 0; transition: opacity 0.12s;
}
.page-card:hover .page-card__actions, .page-card:focus-within .page-card__actions { opacity: 1; }
@media (hover: none) { .page-card__actions { opacity: 1; } }
.page-card__actions button {
  display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 7px; background: none; color: var(--text-muted); cursor: pointer;
}
.page-card__actions button:hover { background: var(--surface-2); color: var(--text); }
.page-card__actions button[data-act="delete"]:hover { color: var(--danger); }
.page-card__actions svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.page-card__grip { display: none; }
@media (hover: none) {
  .page-card__grip {
    display: block; width: 36px; height: 14px; touch-action: none; cursor: grab;
    background: radial-gradient(circle, var(--text-muted) 1.3px, transparent 1.6px) 0 0 / 6px 6px;
    opacity: 0.6;
  }
}

/* 9d. Stamping, crop & form tools (Step 5) -------------------------------- */
.field label output { margin-left: 4px; color: var(--text-muted); font-weight: 600; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.field-row--center { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.field--narrow .input { width: 84px; }
select.input { padding-right: 8px; cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--brand); cursor: pointer; }
.color-field { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.color-field input {
  width: 42px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer;
}

.position-picker { margin: 0; padding: 0; border: 0; }
.position-picker legend { margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 0.9rem; }
.position-picker {
  display: grid; grid-template-columns: repeat(var(--cols), 34px); gap: 4px;
}
.position-picker legend { grid-column: 1 / -1; }
.position-picker label { position: relative; display: block; width: 34px; height: 34px; }
.position-picker input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.position-picker label > span {
  display: grid; place-items: center; width: 100%; height: 100%;
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
}
.position-picker label > span::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.position-picker input:checked + span { border-color: var(--brand); background: var(--brand-soft); }
.position-picker input:checked + span::after { background: var(--brand); }
.position-picker input:focus-visible + span { box-shadow: var(--focus-ring); }
.position-picker.is-disabled { opacity: 0.4; pointer-events: none; }

.margin-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; border: 0; }
.margin-fields legend { grid-column: 1 / -1; margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 0.9rem; }
.margin-fields label { display: grid; gap: 3px; font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

.workbench__custom { min-width: 0; }
.preview { display: grid; gap: 10px; justify-items: center; }
.preview__stage {
  position: relative; display: grid; place-items: center; width: 100%; max-width: 720px; min-height: 320px;
  padding: 16px; border-radius: 12px; background: var(--surface-2);
}
.preview__stage > canvas { max-width: 100%; height: auto; box-shadow: 0 2px 10px rgb(0 0 0 / 0.18); }
.preview__stage > .skeleton { width: 60%; }
.preview__stage.is-busy::after {
  content: ""; position: absolute; top: 12px; right: 12px; width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--brand); animation: spin 0.8s linear infinite;
}
.preview__nav { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9rem; }
.preview__nav .icon-btn:disabled { opacity: 0.35; cursor: default; }
.preview__nav svg { fill: none; }
.preview__caption, .preview__error { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.preview__error { color: var(--danger); font-weight: 600; }

.page-card__rot {
  position: absolute; bottom: 30px; right: 12px; padding: 1px 6px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 0.7rem; font-weight: 700;
}
.page-grid--rotate .page-card { cursor: pointer; }
.page-grid--rotate .page-card:hover, .page-grid--rotate .page-card.is-rotated { border-color: var(--cat, var(--brand)); }

.crop-editor { display: grid; gap: 10px; justify-items: center; }
.crop-stage {
  position: relative; width: 100%; max-width: 640px; aspect-ratio: 3 / 4;
  background: var(--surface-2); box-shadow: 0 2px 10px rgb(0 0 0 / 0.18); overflow: hidden; touch-action: none;
}
.crop-stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.crop-stage > .skeleton { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; }
.crop-box {
  position: absolute; border: 2px solid var(--brand); cursor: move;
  box-shadow: 0 0 0 9999px rgb(10 12 20 / 0.5);
}
.crop-box:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 2px; border-radius: 0; }
.crop-handle {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border: 2px solid var(--brand); border-radius: 4px; background: #fff; touch-action: none;
}
@media (hover: none) { .crop-handle { width: 26px; height: 26px; margin: -13px 0 0 -13px; } }
.crop-handle--nw { left: 0; top: 0; cursor: nwse-resize; }
.crop-handle--n  { left: 50%; top: 0; cursor: ns-resize; }
.crop-handle--ne { left: 100%; top: 0; cursor: nesw-resize; }
.crop-handle--e  { left: 100%; top: 50%; cursor: ew-resize; }
.crop-handle--se { left: 100%; top: 100%; cursor: nwse-resize; }
.crop-handle--s  { left: 50%; top: 100%; cursor: ns-resize; }
.crop-handle--sw { left: 0; top: 100%; cursor: nesw-resize; }
.crop-handle--w  { left: 0; top: 50%; cursor: ew-resize; }
.crop-stage.is-dragging, .crop-stage.is-dragging * { user-select: none; }

.form-pages { display: grid; gap: 20px; justify-items: center; }
.form-page { width: 100%; max-width: 820px; }
.form-page__sheet { position: relative; width: 100%; background: #fff; box-shadow: 0 2px 10px rgb(0 0 0 / 0.18); container-type: inline-size; }
.form-page__canvas { position: absolute; inset: 0; display: grid; place-items: center; }
.form-page__canvas > canvas { width: 100%; height: 100%; }
.form-page__layer { position: absolute; inset: 0; }
.form-page__label { margin: 6px 0 0; text-align: center; color: var(--text-muted); font-size: 0.8rem; font-weight: 600; }
.form-field {
  position: absolute; margin: 0; padding: 0 0.4cqw; border: 1px solid rgb(37 99 235 / 0.55); border-radius: 2px;
  background: rgb(219 234 254 / 0.55); color: #111; font-family: Helvetica, Arial, sans-serif; line-height: 1.15;
}
.form-field:hover { background: rgb(219 234 254 / 0.8); }
.form-field:focus { outline: 2px solid #2563eb; outline-offset: 0; background: rgb(255 255 255 / 0.95); }
.form-field:disabled { background: rgb(0 0 0 / 0.04); border-color: transparent; }
textarea.form-field { resize: none; padding-top: 0.3cqw; }
.form-field--checkbox, .form-field--radio { appearance: auto; accent-color: #2563eb; cursor: pointer; }

/* 9e. Security & placement tools (Step 6) ---------------------------------- */
.password-field { position: relative; }
.password-field .input { padding-right: 44px; }
.password-field__toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 8px; background: none; color: var(--text-muted); cursor: pointer;
}
.password-field__toggle[aria-pressed="true"] { color: var(--brand); }
.password-field__toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.strength { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
.strength__bar { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.strength__bar > span { display: block; height: 100%; width: 33%; border-radius: inherit; background: var(--danger); transition: width 0.2s; }
.strength[data-level="2"] .strength__bar > span { width: 66%; background: var(--cat-organize); }
.strength[data-level="3"] .strength__bar > span { width: 100%; background: var(--success); }

.advanced { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.advanced summary { padding: 10px 12px; font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.advanced__body { display: grid; gap: 12px; padding: 0 12px 12px; }

.input-row { display: flex; gap: 6px; }
.input-row .input { flex: 1; min-width: 0; }
.input-row .btn { min-height: 44px; }

.toggle-group { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.toggle-group .btn { border-color: transparent; }
.toggle-group .btn[aria-pressed="true"] { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); color: var(--brand); }

.sig-slot {
  display: grid; place-items: center; min-height: 90px; padding: 10px;
  border: 1px dashed var(--border); border-radius: 10px; background: #fff;
}
.sig-slot img { max-width: 100%; max-height: 80px; }
.sig-slot .muted { margin: 0; color: #6b7280; }
.place-hint { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 0.85rem; }

/* placement editor */
.pe { display: grid; gap: 22px; justify-items: center; outline: none; }
.pe-page { width: 100%; max-width: 820px; }
.pe-sheet { position: relative; width: 100%; background: #fff; box-shadow: 0 2px 10px rgb(0 0 0 / 0.18); container-type: inline-size; }
.pe-canvas { position: absolute; inset: 0; display: grid; place-items: center; }
.pe-canvas > canvas { width: 100%; height: 100%; }
.pe-layer { position: absolute; inset: 0; overflow: hidden; touch-action: pan-y; }
.pe[data-mode="place"] .pe-layer { cursor: copy; touch-action: none; }
.pe[data-mode="rect"] .pe-layer { cursor: crosshair; touch-action: none; }
.pe[data-mode="ink"] .pe-layer { cursor: crosshair; touch-action: none; }
.pe[data-mode="rect"] .pe-item, .pe[data-mode="ink"] .pe-item, .pe[data-mode="place"] .pe-item { pointer-events: none; }
.pe.is-dragging, .pe.is-dragging * { user-select: none; -webkit-user-select: none; }
.pe-label { margin: 6px 0 0; text-align: center; color: var(--text-muted); font-size: 0.8rem; font-weight: 600; }

.pe-item { position: absolute; cursor: move; touch-action: none; outline: none; }
.pe-content { width: 100%; height: 100%; }
.pe-item--image img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.pe-item--ink svg { display: block; width: 100%; height: 100%; overflow: visible; }
.pe-item--text textarea {
  display: block; width: 100%; height: 100%; margin: 0; padding: 0.25cqw; border: 0; resize: none; overflow: hidden;
  background: transparent; line-height: 1.2; cursor: move;
}
.pe-item--text.is-selected textarea { cursor: text; }
.pe-item:hover { outline: 1px dashed rgb(37 99 235 / 0.7); }
.pe-item.is-selected { outline: 2px solid #2563eb; outline-offset: 1px; }
.pe-handle, .pe-delete { position: absolute; display: none; }
.pe-item.is-selected .pe-handle, .pe-item.is-selected .pe-delete { display: grid; }
.pe-handle {
  right: -7px; bottom: -7px; width: 14px; height: 14px; border: 2px solid #2563eb; border-radius: 4px;
  background: #fff; cursor: nwse-resize;
}
@media (hover: none) { .pe-handle { width: 24px; height: 24px; right: -12px; bottom: -12px; } }
.pe-delete {
  place-items: center; top: -12px; right: -12px; width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 50%; background: var(--danger); color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* signature dialog */
.sigpad { display: grid; gap: 14px; }
.sigpad__panel { display: grid; gap: 10px; }
.sigpad__canvas {
  width: 100%; height: 200px; border: 1px dashed var(--border); border-radius: 10px;
  background: #fff; touch-action: none; cursor: crosshair;
}
.sigpad__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.sigpad__fonts { display: grid; gap: 8px; }
.sigpad__fonts label { position: relative; display: block; }
.sigpad__fonts input { position: absolute; opacity: 0; }
.sigpad__fonts span {
  display: block; padding: 10px 14px; border: 2px solid var(--border); border-radius: 10px; background: #fff;
  font-size: 2rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.sigpad__fonts input:checked + span { border-color: var(--brand); }
.sigpad__fonts input:focus-visible + span { box-shadow: var(--focus-ring); }
.sigpad__preview { display: grid; place-items: center; min-height: 80px; border-radius: 10px; background: #fff; }
.sigpad__preview img { max-width: 100%; max-height: 140px; }
.sigpad__colors { display: flex; align-items: center; gap: 10px; margin: 0; padding: 0; border: 0; }
.sigpad__colors legend { float: left; margin-right: 6px; padding: 0; font-weight: 600; font-size: 0.9rem; }
.sigpad__colors label { position: relative; }
.sigpad__colors input { position: absolute; opacity: 0; }
.sigpad__colors label > span { display: block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.sigpad__colors input:checked + span { box-shadow: 0 0 0 2px var(--brand); }
.sigpad__colors input:focus-visible + span { box-shadow: var(--focus-ring); }

/* 9f. Conversions & OCR (Step 7) ------------------------------------------ */
.dropzone__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
.check-list { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.check-list legend { margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 0.9rem; }

.scan-preview { display: grid; place-items: center; min-height: 0; border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.scan-preview:empty { display: none; }
.scan-preview canvas { display: block; max-width: 100%; max-height: 260px; width: auto; height: auto; }

.md-preview { display: grid; gap: 8px; }
.md-preview__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.md-preview__title { font-weight: 700; }
.md-preview__text {
  margin: 0; min-height: 320px; max-height: 70vh; overflow: auto; padding: 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
  font: 0.85rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}
.md-preview__text .skeleton { display: block; width: 60%; aspect-ratio: auto; height: 1rem; }

.camera { display: grid; gap: 12px; }
.camera__view { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.camera__view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera__guide { position: absolute; inset: 8%; border: 2px dashed rgb(255 255 255 / 0.7); border-radius: 8px; pointer-events: none; }
.camera__controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.camera__controls > :last-child { justify-self: end; }
.camera__shutter {
  width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--surface); cursor: pointer;
  background: var(--brand); box-shadow: 0 0 0 3px var(--brand);
}
.camera__shutter:active { transform: scale(0.94); }
.camera__count { font-weight: 700; color: var(--text-muted); }
.camera__strip { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; overflow-x: auto; }
.camera__strip img { display: block; height: 64px; border-radius: 6px; }

/* 9g. Server tools (Step 8) ------------------------------------------------ */
.notice { margin: 12px auto 0; max-width: 640px; padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: 0.92rem; }
.notice--warning { background: color-mix(in srgb, var(--cat-organize) 14%, var(--surface)); color: var(--text); border: 1px solid color-mix(in srgb, var(--cat-organize) 40%, transparent); }

.choice-cards { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.choice-cards legend { margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 0.9rem; }
.choice-card { position: relative; display: block; cursor: pointer; }
.choice-card input { position: absolute; opacity: 0; }
.choice-card > span {
  display: grid; gap: 2px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--surface);
}
.choice-card small { color: var(--text-muted); font-size: 0.8rem; }
.choice-card input:checked + span { border-color: var(--brand); background: var(--brand-soft); }
.choice-card input:focus-visible + span { box-shadow: var(--focus-ring); }

.url-form { display: grid; gap: 6px; width: min(440px, 100%); margin-top: 14px; cursor: default; }
.url-form__label { color: var(--text-muted); font-size: 0.85rem; font-weight: 600; text-align: center; }

/* 9h. Compare & AI tools (Step 9) ------------------------------------------ */
.done__preview {
  width: min(640px, 100%); max-height: 320px; overflow: auto; margin: 4px 0 8px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
  text-align: start; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.92rem; line-height: 1.6;
}
.change-list { display: grid; gap: 4px; max-height: 220px; overflow: auto; margin: 0; padding-left: 1.2em; font-size: 0.85rem; }
.change-list:empty { display: none; }
.change-list span { color: var(--text-muted); }
.change-list .link-btn { color: var(--brand); font-weight: 600; }

.cmp-empty { display: grid; justify-items: center; gap: 10px; padding: 48px 16px; color: var(--text-muted); text-align: center; }
.cmp { display: grid; gap: 18px; }
.cmp__head { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; }
.cmp__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 10px; border-radius: 8px; }
.cmp__label--old { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.cmp__label--new { background: color-mix(in srgb, var(--success) 14%, transparent); text-align: end; }
.cmp-row { display: grid; gap: 8px; }
.cmp-row__title { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 700; }
.cmp-badge { padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; background: var(--surface-2); color: var(--text-muted); }
.cmp-badge--changed { background: color-mix(in srgb, var(--cat-organize) 18%, transparent); color: var(--text); }
.cmp-badge--added-page { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--text); }
.cmp-badge--removed-page { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--text); }
.cmp-row__pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cmp-page--missing { display: grid; place-items: center; min-height: 160px; border: 2px dashed var(--border); border-radius: 8px; color: var(--text-muted); font-size: 0.85rem; text-align: center; }
.cmp-sheet { position: relative; width: 100%; background: #fff; box-shadow: 0 1px 6px rgb(0 0 0 / 0.18); }
.cmp-sheet__canvas { position: absolute; inset: 0; display: grid; place-items: center; }
.cmp-sheet__canvas > canvas { width: 100%; height: 100%; }
.cmp-marks, .cmp-pixels { position: absolute; inset: 0; pointer-events: none; }
.cmp-pixels > canvas { width: 100%; height: 100%; }
.cmp-mark { position: absolute; border-radius: 2px; }
.cmp-mark--old { background: rgb(220 38 38 / 0.32); box-shadow: inset 0 -2px 0 rgb(220 38 38 / 0.8); }
.cmp-mark--new { background: rgb(22 163 74 / 0.30); box-shadow: inset 0 -2px 0 rgb(22 163 74 / 0.8); }
.cmp[data-mode="visual"] .cmp-marks { display: none; }
.cmp[data-mode="text"] .cmp-pixels { display: none; }

/* 9i. FAQ & legal pages (Step 10) ------------------------------------------ */
.faq { display: grid; gap: 8px; max-width: 820px; }
.faq__item { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.faq__item summary { padding: 14px 16px; font-weight: 600; cursor: pointer; list-style-position: inside; }
.faq__item p { margin: 0; padding: 0 16px 14px; color: var(--text-muted); }
.prose h2 { margin-top: 1.6em; font-size: 1.3rem; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: 0.4em; }
.prose .updated { color: var(--text-muted); font-size: 0.9rem; }

/* 10. Dialogs & toasts ---------------------------------------------------- */
.modal {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.modal--sm { width: min(400px, calc(100vw - 32px)); }
.modal--lg { width: min(820px, calc(100vw - 32px)); }
.modal::backdrop { background: rgb(10 12 20 / 0.55); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-in 0.18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal__header { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.modal__title { margin: 0; font-size: 1.15rem; }
.modal__close { margin-left: auto; width: 36px; height: 36px; }
.modal__body { padding: 16px 20px; overflow-y: auto; }
.modal__body p:last-child { margin-bottom: 0; }
.modal__footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; }

.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.9rem; }
.input {
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); }

.toast-stack {
  position: fixed; right: 16px; bottom: 16px; z-index: 300;
  display: grid; gap: 8px; width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
body.has-anchor .toast-stack { bottom: 86px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 12px; border-left: 4px solid var(--text-muted);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  pointer-events: auto; animation: toast-in 0.2s ease-out;
}
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--info { border-left-color: var(--cat-convert-to); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: 0.2s; }
.toast__msg { flex: 1; font-size: 0.93rem; }
.toast__close { border: 0; background: none; cursor: pointer; font-size: 1.1rem; line-height: 1; color: var(--text-muted); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* 11. Consent & utilities ------------------------------------------------- */
.consent {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 200;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  max-width: 920px; margin-inline: auto; padding: 18px 20px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-lg); font-size: 0.9rem;
}
.consent__body { flex: 1 1 320px; }
.consent__body p { margin: 0; color: var(--text-muted); }
.consent__title { margin-bottom: 4px !important; font-weight: 700; color: var(--text) !important; }
.consent__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
