/* ============================================================
   ScanKoro — free PDF studio
   ============================================================ */

:root {
  --bg: #f7f8fc;
  --bg-soft: #f1f2f9;
  --surface: #ffffff;
  --surface-2: #f5f5ff;
  --surface-3: #eef0f8;
  --ink: #20223a;
  --ink-soft: #34364f;
  --muted: #797d95;
  --muted-2: #9a9db2;
  --line: #e7e9f2;
  --line-strong: #d8dbe8;
  --primary: #5145e5;
  --primary-600: #4438d6;
  --primary-700: #3930be;
  --primary-soft: #eeecfe;
  --primary-soft-2: #e4e1fd;
  --green: #39b98a;
  --green-soft: #e6f7f0;
  --amber: #e59b32;
  --amber-soft: #fdf2e0;
  --red: #e05b5b;
  --red-soft: #fdecec;
  --blue: #3f8cff;
  --blue-soft: #e9f2ff;
  --pink: #d957a8;
  --pink-soft: #fbeaf4;
  --teal: #22a5a5;
  --teal-soft: #e4f6f6;

  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --shadow-lg: 0 30px 70px rgba(32, 34, 58, .12);
  --shadow: 0 16px 40px rgba(32, 34, 58, .08);
  --shadow-sm: 0 6px 18px rgba(32, 34, 58, .06);
  --shadow-btn: 0 8px 20px rgba(81, 69, 229, .22);

  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Manrope", "DM Sans", system-ui, sans-serif;

  --header-h: 72px;
  --wrap: 1160px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

[data-theme="dark"] {
  --bg: #101119;
  --bg-soft: #151622;
  --surface: #191b27;
  --surface-2: #1e2030;
  --surface-3: #242637;
  --ink: #f1f2fa;
  --ink-soft: #dcdef0;
  --muted: #9da0b8;
  --muted-2: #7d8098;
  --line: #2a2d3e;
  --line-strong: #383b4f;
  --primary: #7d72ff;
  --primary-600: #6a5dfa;
  --primary-700: #5a4de0;
  --primary-soft: #242141;
  --primary-soft-2: #2c2852;
  --green: #4fd3a0;
  --green-soft: #17352b;
  --amber: #f0b45a;
  --amber-soft: #3a2c17;
  --red: #ff7f7f;
  --red-soft: #3a2020;
  --blue: #6aa6ff;
  --blue-soft: #1b2c47;
  --pink: #f07cc4;
  --pink-soft: #3a2031;
  --teal: #4cc9c9;
  --teal-soft: #173434;
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, .45);
  --shadow: 0 16px 40px rgba(0, 0, 0, .35);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, .28);
  --shadow-btn: 0 8px 20px rgba(81, 69, 229, .3);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, canvas, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); color: var(--ink); letter-spacing: -.02em; line-height: 1.15; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }

::selection { background: var(--primary); color: #fff; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

.skip {
  position: fixed; top: -60px; left: 16px; z-index: 200;
  background: var(--primary); color: #fff; padding: 10px 16px;
  border-radius: 10px; transition: top .2s;
}
.skip:focus { top: 12px; }

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: var(--wrap); margin: 0 auto; padding: 0 24px;
  height: var(--header-h);
  display: flex; align-items: center; gap: 24px;
}

.brand { display: inline-flex; align-items: center; gap: 11px; flex-shrink: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, #6c5ffb 0%, #5145e5 55%, #4235cd 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(81, 69, 229, .32), inset 0 1px 0 rgba(255,255,255,.35);
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--font-display); font-size: 20px; font-weight: 800; letter-spacing: -.035em; }
.brand-name span { color: var(--primary); }
.brand-sub { font-size: 8.5px; font-weight: 700; letter-spacing: .22em; color: var(--muted); margin-top: 5px; }

.main-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.main-nav a {
  padding: 8px 13px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
  transition: background .18s, color .18s;
}
.main-nav a:hover { background: var(--surface-3); color: var(--ink); }
.main-nav a.active { background: var(--primary-soft); color: var(--primary); }
.main-nav .nav-cta {
  margin-left: 6px; background: var(--primary); color: #fff;
  padding: 9px 16px; box-shadow: var(--shadow-btn);
}
.main-nav .nav-cta:hover { background: var(--primary-600); color: #fff; }

.header-actions { display: flex; align-items: center; gap: 8px; margin-left: 4px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--ink-soft);
  transition: background .18s, transform .18s;
}
.icon-btn:hover { background: var(--surface-3); transform: translateY(-1px); }
.icon-btn svg { width: 19px; height: 19px; }
.ic-moon { display: none; }
[data-theme="dark"] .ic-sun { display: none; }
[data-theme="dark"] .ic-moon { display: block; }
.menu-btn { display: none; }

/* ---------- Hero ---------- */

.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 48px; align-items: center;
  padding-top: 72px; padding-bottom: 64px;
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 800; letter-spacing: .14em;
  color: var(--muted); text-transform: uppercase;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 4px rgba(57, 185, 138, .14);
  flex-shrink: 0;
}

.hero h1 {
  font-size: clamp(38px, 5.1vw, 62px);
  font-weight: 800; letter-spacing: -.045em; line-height: 1.03;
  margin: 18px 0 20px;
}
.grad {
  background: linear-gradient(100deg, #5145e5 0%, #7a5cff 45%, #a15cff 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
[data-theme="dark"] .grad {
  background: linear-gradient(100deg, #8d83ff 0%, #ab8dff 50%, #d29bff 100%);
  -webkit-background-clip: text; background-clip: text;
}
.lede { font-size: 17.5px; color: var(--muted); max-width: 535px; line-height: 1.65; }

.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.trust-row {
  display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 24px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.trust-row li { display: inline-flex; align-items: center; gap: 6px; }
.trust-row svg { width: 14px; height: 14px; color: var(--green); }

/* Hero art */
.hero-art { position: relative; display: flex; justify-content: center; }
.art-glow {
  position: absolute; inset: 4% 2% 6%;
  background: radial-gradient(closest-side, rgba(111, 93, 255, .24), rgba(111, 93, 255, 0) 72%);
  filter: blur(6px); z-index: 0;
}
.doc-stack { position: relative; width: 340px; height: 400px; z-index: 1; }
.doc-sheet {
  position: absolute; border-radius: 20px; background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.sheet-back {
  inset: 34px 18px 26px 46px; transform: rotate(7deg);
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
}
.sheet-mid {
  inset: 24px 30px 34px 30px; transform: rotate(3deg);
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
}
.sheet-front { inset: 12px 24px 44px 22px; padding: 22px 22px 18px; transform: rotate(-1.5deg); }
.doc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.doc-brand { font-size: 9px; font-weight: 800; letter-spacing: .2em; color: var(--muted); }
.doc-tag {
  font-size: 9px; font-weight: 800; letter-spacing: .08em;
  color: var(--primary); background: var(--primary-soft);
  padding: 4px 8px; border-radius: 6px;
}
.doc-line { height: 9px; border-radius: 9px; background: var(--primary-soft-2); margin-bottom: 10px; }
.doc-line.w70 { width: 72%; }
.doc-line.w45 { width: 46%; background: var(--surface-3); }
.doc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 20px; }
.doc-grid i { height: 42px; border-radius: 8px; background: var(--surface-3); }
.doc-grid i:nth-child(2) { background: color-mix(in srgb, var(--primary) 16%, var(--surface)); }
.doc-sign {
  position: absolute; right: 26px; bottom: 34px;
  font-family: "Brush Script MT", cursive; font-size: 22px;
  color: var(--primary); transform: rotate(-6deg);
}
.art-badge {
  position: absolute; display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; padding: 9px 13px;
  font-size: 11.5px; font-weight: 700; color: var(--ink-soft);
  box-shadow: var(--shadow-sm); white-space: nowrap;
}
.badge-top { top: 34px; left: -6px; animation: float 6s ease-in-out infinite; }
.badge-bottom { bottom: 44px; right: -4px; animation: float 7s ease-in-out infinite reverse; }
.art-badge-dot { width: 8px; height: 8px; border-radius: 50%; }
.art-badge-dot.green { background: var(--green); }
.art-badge-dot.violet { background: var(--primary); }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

/* ---------- Free strip ---------- */

.free-strip { background: var(--surface); border-block: 1px solid var(--line); }
.free-strip-inner {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding-top: 20px; padding-bottom: 20px;
}
.free-strip strong { font-family: var(--font-display); font-size: 16px; letter-spacing: -.02em; }
.free-strip span { color: var(--muted); font-size: 14.5px; flex: 1; min-width: 260px; }
.link-arrow { font-size: 14px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.link-arrow:hover { color: var(--primary-600); }

/* ---------- Sections ---------- */

.tools-section { padding-top: 84px; padding-bottom: 20px; }
.section-head { max-width: 660px; margin-bottom: 32px; }
.section-head.center { margin: 0 auto 42px; text-align: center; }
.section-head h2 {
  font-size: clamp(28px, 3.5vw, 40px); font-weight: 800;
  letter-spacing: -.035em; margin: 14px 0 12px;
}
.section-head p { color: var(--muted); font-size: 16px; }
.br-desk { display: inline; }

.filters {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px;
}
.chip {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 8px 15px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  display: inline-flex; align-items: center; gap: 7px;
  transition: all .18s;
}
.chip span {
  font-size: 10.5px; background: var(--surface-3); border-radius: 99px;
  padding: 1px 6px; color: var(--muted);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 6px 16px rgba(81, 69, 229, .22);
}
.chip.active span { background: rgba(255,255,255,.22); color: #fff; }

.tool-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 14px;
}
.tool-card {
  position: relative; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px 20px 20px; min-height: 168px;
  display: flex; flex-direction: column; gap: 7px;
  transition: transform .22s var(--ease), box-shadow .22s, border-color .22s;
  overflow: hidden;
}
.tool-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow .22s;
}
.tool-card:hover {
  transform: translateY(-3px); border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
  box-shadow: var(--shadow);
}
.tool-card:hover::after { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 20%, transparent); }
.tool-ico {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; margin-bottom: 10px;
}
.tool-ico svg { width: 22px; height: 22px; }
.c-violet { background: var(--primary-soft); color: var(--primary); }
.c-green { background: var(--green-soft); color: var(--green); }
.c-blue { background: var(--blue-soft); color: var(--blue); }
.c-amber { background: var(--amber-soft); color: var(--amber); }
.c-red { background: var(--red-soft); color: var(--red); }
.c-pink { background: var(--pink-soft); color: var(--pink); }
.c-teal { background: var(--teal-soft); color: var(--teal); }
.tool-card h3 { font-size: 16px; font-weight: 700; letter-spacing: -.015em; }
.tool-card p { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.tag-free {
  position: absolute; top: 16px; right: 16px;
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--green); background: var(--green-soft);
  border-radius: 99px; padding: 3px 8px;
}

/* ---------- Why ---------- */

.why-section { padding-top: 88px; }
.why-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.why-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 24px 22px;
  transition: transform .22s, box-shadow .22s;
}
.why-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.why-ico {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
  margin-bottom: 16px;
}
.why-ico svg { width: 21px; height: 21px; }
.why-card h3 { font-size: 16px; margin-bottom: 6px; }
.why-card p { font-size: 13.5px; color: var(--muted); }

/* ---------- Steps ---------- */

.steps-section { padding-top: 92px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; counter-reset: step; }
.steps li {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 24px 22px;
}
.step-num {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary); color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: 15px;
  box-shadow: 0 6px 14px rgba(81, 69, 229, .25);
}
.steps h3 { font-size: 16px; margin-bottom: 4px; }
.steps p { font-size: 13.5px; color: var(--muted); }

/* ---------- FAQ ---------- */

.faq-section { padding-top: 92px; }
.faq { max-width: 760px; margin: 0 auto; display: grid; gap: 10px; }
.faq details {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color .2s;
}
.faq details[open] { border-color: color-mix(in srgb, var(--primary) 32%, var(--line)); }
.faq summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 20px; font-weight: 700; font-size: 15px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq .plus {
  position: relative; width: 18px; height: 18px; flex-shrink: 0;
  border-radius: 6px; background: var(--surface-3);
}
.faq .plus::before, .faq .plus::after {
  content: ""; position: absolute; inset: 50% auto auto 50%;
  width: 9px; height: 1.8px; border-radius: 2px; background: var(--muted);
  transform: translate(-50%, -50%);
}
.faq .plus::after { transform: translate(-50%, -50%) rotate(90deg); transition: transform .2s; }
.faq details[open] .plus::after { transform: translate(-50%, -50%) rotate(0); }
.faq details p { padding: 0 20px 20px; color: var(--muted); font-size: 14.5px; max-width: 650px; }

/* ---------- CTA ---------- */

.cta-band { padding-top: 88px; padding-bottom: 88px; }
.cta-card {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 28px; flex-wrap: wrap;
  padding: 44px 48px; border-radius: var(--radius-xl);
  background:
    radial-gradient(120% 160% at 100% 0%, rgba(255,255,255,.18), transparent 45%),
    linear-gradient(120deg, #4b3fe0 0%, #6152f5 55%, #7b5cff 100%);
  color: #fff; box-shadow: 0 26px 60px rgba(81, 69, 229, .32);
}
.cta-card h2 { color: #fff; font-size: clamp(24px, 3vw, 34px); font-weight: 800; letter-spacing: -.03em; }
.cta-card p { color: rgba(255,255,255,.82); margin-top: 8px; font-size: 15px; }
.cta-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Footer ---------- */

.site-footer { background: var(--surface); border-top: 1px solid var(--line); }
.footer-grid {
  display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 40px; padding-top: 56px; padding-bottom: 40px;
}
.footer-brand p { font-size: 13.5px; color: var(--muted); margin-top: 16px; max-width: 290px; }
.footer-free {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 16px; font-size: 12px; font-weight: 700; color: var(--ink-soft);
}
.footer-col h4 { font-family: var(--font); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.footer-col a { display: block; font-size: 13.5px; color: var(--ink-soft); padding: 4px 0; transition: color .15s; }
.footer-col a:hover { color: var(--primary); }
.footer-bottom {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding-top: 20px; padding-bottom: 26px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: 1px solid transparent; border-radius: 12px;
  padding: 13px 22px; font-size: 14.5px; font-weight: 700;
  transition: transform .18s, background .18s, box-shadow .18s, border-color .18s;
  white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-btn); }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
.btn-soft { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-soft:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: transparent; }
.btn-white { background: #fff; color: #4338d6; box-shadow: 0 10px 24px rgba(20, 16, 70, .22); }
.btn-white:hover { background: #f4f2ff; }
.btn-outline-light { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.4); }
.btn-outline-light:hover { background: rgba(255,255,255,.16); }
.btn-sm { padding: 9px 14px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 15px 26px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---------- Generic UI ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  border-radius: 99px; padding: 5px 10px;
}
.pill.free { background: var(--green-soft); color: var(--green); }
.pill.soft { background: var(--primary-soft); color: var(--primary); }

/* ---------- Tools page ---------- */

.tools-page, .tool-page { padding-bottom: 40px; }
.page-head { padding-top: 48px; margin-bottom: 30px; }
.page-head h1 { font-size: clamp(32px, 4.4vw, 48px); font-weight: 800; letter-spacing: -.04em; margin: 14px 0 10px; }
.page-head p { color: var(--muted); max-width: 620px; }

.back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  padding: 8px 0; transition: color .15s;
}
.back svg { width: 14px; height: 14px; }
.back:hover { color: var(--primary); }

.tool-head {
  display: flex; align-items: flex-start; gap: 18px;
  padding: 26px 0 24px;
}
.tool-head .tool-ico { width: 56px; height: 56px; border-radius: 16px; margin: 0; flex-shrink: 0; }
.tool-head .tool-ico svg { width: 27px; height: 27px; }
.tool-head h1, .tool-head h2 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; letter-spacing: -.04em; }
.tool-head p { color: var(--muted); margin-top: 6px; max-width: 640px; }
.tool-head .pill { margin-left: auto; flex-shrink: 0; margin-top: 6px; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
  padding: 26px;
}
.panel + .panel { margin-top: 16px; }

/* ---------- Honest-limit pages ---------- */

.pill.limited { background: var(--amber-soft); color: var(--amber); }
.tag-limited {
  position: absolute; top: 16px; right: 16px;
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--amber); background: var(--amber-soft);
  border-radius: 99px; padding: 3px 8px;
}
/* A limited card links to an explanation, not to a converter. It sits among the
   working tools without pretending to be one, so it keeps the recessed surface
   and drops the lift-and-glow hover the real tools get. */
.tool-card.is-limited { background: var(--bg-soft); border-style: dashed; }
.tool-card.is-limited:hover {
  transform: none; box-shadow: none;
  border-color: var(--line-strong); border-style: solid;
}
.tool-card.is-limited:hover::after { box-shadow: none; }

.status-panel { display: flex; flex-direction: column; gap: 16px; }
.status-flag {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--amber); background: var(--amber-soft);
  border-radius: 99px; padding: 7px 12px;
}
.status-flag svg { width: 15px; height: 15px; flex-shrink: 0; }
.status-why { font-size: 15px; line-height: 1.65; color: var(--ink); max-width: 62ch; }
.status-next {
  font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.status-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.status-link {
  display: flex; align-items: center; gap: 11px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 13px; padding: 13px 14px;
  transition: border-color .15s, transform .15s;
}
.status-link:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); transform: translateY(-1px); }
.status-link > span:nth-child(2) { flex: 1; min-width: 0; }
.status-link .tool-ico { width: 34px; height: 34px; border-radius: 10px; margin: 0; flex-shrink: 0; }
.status-link .tool-ico svg { width: 17px; height: 17px; }
.status-link strong { display: block; font-size: 13px; }
.status-link span span { font-size: 11px; color: var(--muted); }
.status-link > svg { width: 15px; height: 15px; color: var(--muted-2); flex-shrink: 0; }
.status-note { font-size: 13px; line-height: 1.6; color: var(--muted); max-width: 66ch; }

.limits-section { padding-top: 44px; }

/* ---------- Tools dashboard ---------- */

.dash-bar { padding-top: 26px; }
.dash-search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 0 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color .18s, box-shadow .18s;
}
.dash-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.dash-ico { width: 19px; height: 19px; color: var(--muted-2); flex-shrink: 0; }
.dash-search input {
  flex: 1; min-width: 0; border: 0; outline: none; background: none;
  font: inherit; font-size: 16px; color: var(--ink); padding: 14px 0;
}
.dash-search input::placeholder { color: var(--muted-2); }
.dash-hint { font-size: 13px; color: var(--muted); margin: 10px 4px 0; }

.dash-section { padding-top: 30px; }
.dash-section + .dash-section { padding-top: 26px; }
.dash-section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.dash-section-head h2 { font-size: 14px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.dash-section-head p { font-size: 12.5px; color: var(--muted); }

.tool-cell { position: relative; display: flex; }
.tool-cell > .tool-card { flex: 1; }
/* Only cards that carry a star reserve the corner for it; the honest-limit
   cards have no button and keep their normal padding. */
.tool-card.has-pin { padding-bottom: 40px; }
.fav-btn {
  position: absolute; right: 12px; bottom: 12px; z-index: 2;
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; padding: 0;
  background: transparent; border: 1px solid transparent; color: var(--muted-2);
  cursor: pointer;
  transition: color .15s, background .15s, transform .15s;
}
/* The visible mark stays small, but the hit area is pushed to 44px so a thumb
   on a phone does not miss it and follow the card link instead. */
.fav-btn::after { content: ""; position: absolute; inset: -7px; }
.fav-btn svg { width: 16px; height: 16px; }
.fav-btn:hover { color: var(--primary); background: var(--primary-soft); }
.fav-btn:active { transform: scale(.92); }
.fav-btn.on { color: var(--amber); background: var(--amber-soft); }
.fav-btn.on svg { fill: currentColor; }
.fav-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.dash-empty {
  background: var(--surface); border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg); padding: 32px 26px; text-align: center;
}
.dash-empty h2 { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.dash-empty p { font-size: 13.5px; color: var(--muted); margin: 8px auto 16px; max-width: 52ch; line-height: 1.6; }

/* Dropzone */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; cursor: pointer;
  border: 1.6px dashed var(--line-strong); border-radius: var(--radius-lg);
  background: var(--bg);
  padding: 46px 24px;
  transition: border-color .2s, background .2s, transform .2s;
}
.drop:hover, .drop.drag {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.drop.drag { transform: scale(1.005); }
.drop-ico {
  width: 54px; height: 54px; border-radius: 16px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; margin-bottom: 6px;
}
.drop-ico svg { width: 26px; height: 26px; }
.drop-title { font-weight: 800; font-size: 16px; }
.drop-sub { font-size: 13px; color: var(--muted); }
.drop-sub .browse { color: var(--primary); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.drop-meta { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }

/* File rows */
.file-list { display: grid; gap: 8px; margin-top: 16px; }
.file-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 12px;
}
.file-badge {
  width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
  background: var(--red-soft); color: var(--red);
  display: grid; place-items: center;
  font-size: 8px; font-weight: 800; letter-spacing: .02em;
}
.file-badge.img { background: var(--blue-soft); color: var(--blue); }
.file-meta { min-width: 0; flex: 1; }
.file-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11.5px; color: var(--muted); }
.file-actions { display: flex; gap: 4px; flex-shrink: 0; }
.file-actions button {
  width: 30px; height: 30px; border-radius: 8px; border: 0;
  background: transparent; color: var(--muted);
  display: grid; place-items: center;
}
.file-actions button:hover { background: var(--surface-3); color: var(--ink); }
.file-actions button svg { width: 15px; height: 15px; }

.add-more {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 12px; font-size: 13px; font-weight: 700; color: var(--primary);
  background: none; border: 0; padding: 6px 2px;
}
.add-more svg { width: 15px; height: 15px; }

/* Options */
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-top: 22px; }
.opt { display: flex; flex-direction: column; gap: 7px; }
.opt > label, .opt-label { font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.opt .hint { font-size: 11.5px; color: var(--muted-2); }

.input, .select {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px 12px; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.input::placeholder { color: var(--muted-2); }

.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 9px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--surface); transition: all .15s;
}
.radio input { position: absolute; opacity: 0; pointer-events: none; }
.radio:has(input:checked) {
  border-color: var(--primary); background: var(--primary-soft); color: var(--primary);
}
.radio .r-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.radio:has(input:checked) .r-dot { background: var(--primary); }

.switch-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; }
.switch { position: relative; width: 40px; height: 23px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong);
  transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: transform .2s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(17px); }

input[type="range"] { width: 100%; accent-color: var(--primary); }

.range-row { display: flex; align-items: center; gap: 12px; }
.range-value { font-size: 12.5px; font-weight: 700; min-width: 54px; text-align: right; color: var(--ink-soft); }

.actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line);
}
.actions .note { font-size: 12px; color: var(--muted-2); }
.actions .spacer { flex: 1; }

/* Progress */
.progress { margin-top: 18px; }
.progress-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.progress-track { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-bar {
  height: 100%; width: 0%; border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #8a74ff);
  transition: width .25s var(--ease);
}

/* Result */
.result {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 18px; padding: 16px 18px;
  border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line));
  background: color-mix(in srgb, var(--green) 7%, var(--surface));
  border-radius: var(--radius);
}
.result-ico {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--green-soft); color: var(--green);
  display: grid; place-items: center; flex-shrink: 0;
}
.result-ico svg { width: 20px; height: 20px; }
.result-meta { flex: 1; min-width: 180px; }
.result-title { font-size: 14px; font-weight: 800; }
.result-sub { font-size: 12px; color: var(--muted); }
.result .btn { flex-shrink: 0; }

.error-box {
  margin-top: 16px; padding: 12px 15px; border-radius: 11px;
  background: var(--red-soft); color: var(--red);
  font-size: 13px; font-weight: 600;
}

/* Thumbnails */
.thumb-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
  gap: 14px; margin-top: 20px;
}
.thumb {
  position: relative; background: var(--bg); border: 1px solid var(--line);
  border-radius: 11px; padding: 8px; cursor: grab;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.thumb:hover { border-color: var(--line-strong); }
.thumb.dragging { opacity: .45; }
.thumb.drop-target { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.thumb .thumb-canvas-wrap {
  background: #fff; border-radius: 6px; overflow: hidden;
  display: grid; place-items: center; min-height: 100px;
}
.thumb canvas { max-width: 100%; height: auto; }
.thumb .thumb-num {
  position: absolute; left: 12px; top: 12px;
  background: rgba(20, 22, 40, .72); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 6px; padding: 2px 6px;
}
.thumb .thumb-x {
  position: absolute; right: 11px; top: 11px;
  width: 24px; height: 24px; border-radius: 7px; border: 0;
  background: rgba(20, 22, 40, .72); color: #fff;
  display: grid; place-items: center; opacity: 0; transition: opacity .15s;
}
.thumb:hover .thumb-x { opacity: 1; }
.thumb .thumb-x svg { width: 13px; height: 13px; }
.thumb-label { font-size: 10.5px; color: var(--muted); text-align: center; padding-top: 7px; }
.thumb-tools { position: absolute; left: 11px; bottom: 34px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.thumb:hover .thumb-tools { opacity: 1; }
.thumb-tools button {
  width: 24px; height: 24px; border-radius: 7px; border: 0;
  background: rgba(20,22,40,.72); color: #fff; display: grid; place-items: center;
}
.thumb-tools button svg { width: 12px; height: 12px; }
@media (pointer: coarse), (max-width: 768px) {
  .thumb .thumb-x, .thumb .thumb-tools { opacity: 1; }
  .thumb .thumb-x { width: 30px; height: 30px; }
  .thumb .thumb-x svg { width: 15px; height: 15px; }
  .thumb-tools button { width: 30px; height: 30px; }
  .thumb-tools button svg { width: 14px; height: 14px; }
}
.thumb.removed { opacity: .35; }
.thumb.removed .thumb-canvas-wrap { filter: grayscale(1); }
.thumb.removed::after {
  content: "Removed"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: var(--red);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  border-radius: 11px; pointer-events: none;
}

.hint-box {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--blue-soft); color: color-mix(in srgb, var(--blue) 70%, var(--ink));
  border-radius: 11px; padding: 12px 14px; font-size: 12.5px; line-height: 1.5;
  margin-top: 16px;
}
.hint-box svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

.privacy-note {
  display: flex; align-items: center; gap: 10px;
  margin-top: 18px; font-size: 12.5px; color: var(--muted);
}
.privacy-note svg { width: 16px; height: 16px; color: var(--green); flex-shrink: 0; }

.related { margin-top: 34px; }
.related h2 { font-size: 18px; margin-bottom: 14px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.related-card {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: 13px 14px;
  transition: border-color .15s, transform .15s;
}
.related-card:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); transform: translateY(-1px); }
.related-card .tool-ico { width: 34px; height: 34px; border-radius: 10px; margin: 0; }
.related-card .tool-ico svg { width: 17px; height: 17px; }
.related-card strong { display: block; font-size: 13px; }
.related-card span span { font-size: 11px; color: var(--muted); }

/* ---------- Editor ---------- */

.editor-page { background: var(--bg-soft); min-height: calc(100vh - var(--header-h)); }
/* dvh, not vh: on a phone vh counts the URL bar that has already scrolled away,
   so the workspace bottom — and the page you are editing — hides under it.
   The extra 1px is the header's bottom border, which --header-h does not include.
   Without it the shell overshoots the viewport by a pixel and the document itself
   grows a scrollbar, which is exactly the page-level scroll being removed here. */
.editor-shell {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--header-h) - 1px);
  height: calc(100dvh - var(--header-h) - 1px);
  min-height: 460px;
}
/* The marketing footer is not part of an editing session. Left in place it puts
   the document's bottom edge below the fold, so a stray wheel notch scrolls the
   whole editor away. It returns the moment the file is closed (destroy()). */
body.editor-workspace .site-footer { display: none; }
/* The marketing header is 72px of logo and nav that an editing session does not
   read. Slim it, do not remove it — the brand link is still how you leave. */
body.editor-workspace { --header-h: 46px; }
body.editor-workspace .header-inner { padding: 0 12px; gap: 10px; height: 46px; }
body.editor-workspace .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
body.editor-workspace .brand-mark svg { width: 16px; height: 16px; }
body.editor-workspace .brand-sub { display: none; }
body.editor-workspace .brand-name { font-size: 16px; }
.editor-shell:fullscreen, .editor-shell:-webkit-full-screen { height: 100vh; }
.editor-top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 4px 12px; min-height: 40px;
}
.editor-top .back { padding: 0; }
.editor-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13.5px; }
.editor-title svg { width: 17px; height: 17px; color: var(--primary); }
.editor-file-name { font-size: 12px; color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-top .spacer { flex: 1; }

.editor-toolbar {
  /* One compact row, scrolling sideways instead of stacking a second bar over the page */
  display: flex; align-items: center; gap: 4px;
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 4px 10px; min-height: 40px;
  position: sticky; top: var(--header-h); z-index: 30;
}
.editor-toolbar::-webkit-scrollbar { display: none; }
.editor-toolbar .tool-btn, .editor-status .tool-btn {
  gap: 5px; flex: 0 0 auto; white-space: nowrap;
  border-radius: 7px; padding: 4px 8px;
  font-size: 12px;
}
.editor-toolbar .tool-btn svg, .editor-status .tool-btn svg { width: 15px; height: 15px; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; background: transparent;
  border-radius: 8px; padding: 6px 10px;
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
  transition: background .15s, color .15s, border-color .15s;
}
.tool-btn svg { width: 15px; height: 15px; }
.tool-btn:hover:not(:disabled) { background: var(--surface-3); }
.tool-btn:disabled { opacity: .4; cursor: not-allowed; }
.tool-btn.active { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.tool-btn.icon-only { padding: 5px 6px; min-width: 28px; justify-content: center; }
.tool-sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; flex: 0 0 auto; }
.toolbar-group { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.toolbar-group .input { width: 56px; padding: 4px 6px; font-size: 12px; height: 28px; }
.toolbar-group input[type="color"] {
  width: 28px; height: 28px; padding: 2px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: var(--surface); cursor: pointer;
}
.toolbar-group .select { width: auto; max-width: 130px; padding: 3px 6px; font-size: 11.5px; height: 28px; border-radius: 6px; }
.toolbar-label { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

.editor-body {
  /* Dynamic grid: rail and side collapse cleanly so the document preview occupies 85-90%+ of the space */
  flex: 1; display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0; min-height: 0; overflow: hidden;
}
.editor-rail {
  width: 96px;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 8px 8px; overflow-y: auto;
  transition: width .2s ease, padding .2s ease;
}
.editor-rail.is-collapsed {
  width: 0 !important; padding: 0 !important; border-right: 0 !important; overflow: hidden !important; pointer-events: none;
}
.rail-title { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 2px 4px 8px; }
.editor-thumb {
  width: 100%; border: 1.5px solid transparent; border-radius: 8px;
  background: var(--bg); padding: 3px; margin-bottom: 6px; cursor: pointer;
  transition: border-color .15s;
}
.editor-thumb.active { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.editor-thumb canvas { width: 100%; height: auto; border-radius: 5px; background: #fff; }
.editor-thumb span { display: block; text-align: center; font-size: 10px; color: var(--muted); padding-top: 3px; }

.editor-stage {
  position: relative; overflow: auto;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 0) 0 0 / 18px 18px,
    var(--bg-soft);
  padding: 8px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  height: 100%;
}
.page-wrap { position: relative; flex-shrink: 0; }
.page-wrap canvas { display: block; border-radius: 2px; box-shadow: 0 14px 40px rgba(20, 22, 40, .22); background: #fff; }
/* Render spinner. Sits inside .page-wrap so it always lands on the page the user
   is waiting for, at any zoom level, and disappears the moment the canvas is ready.
   pointer-events:none is essential: it paints above .overlay-layer and .text-layer,
   so without it the spinner would eat clicks aimed at the page centre. */
.page-wrap.loading::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px;
  margin: -17px 0 0 -17px; border-radius: 50%; pointer-events: none;
  border: 3px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-top-color: var(--primary); animation: sk-spin .7s linear infinite;
}
@keyframes sk-spin { to { transform: rotate(360deg); } }
.overlay-layer { position: absolute; inset: 0; pointer-events: none; }
.overlay-item {
  position: absolute; border: 1.5px dashed transparent; cursor: move;
  user-select: none; touch-action: none; pointer-events: auto;
}
.overlay-item[data-type="textedit"] { cursor: text; }
.overlay-item[data-type="textedit"].selected { background: transparent; }

.text-layer { position: absolute; inset: 0; pointer-events: none; }
.page-wrap.text-mode .text-layer { pointer-events: auto; }
.text-line {
  position: absolute; border: 1.5px solid transparent; border-radius: 4px;
  background: transparent; cursor: text; pointer-events: auto;
  transition: background .12s, border-color .12s;
}
.text-line:hover, .text-line:focus-visible {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
  outline: none;
}
.text-line.busy { background: color-mix(in srgb, var(--primary) 22%, transparent); cursor: progress; }
.overlay-item:hover, .overlay-item.selected { border-color: var(--primary); }
.overlay-item.selected { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.overlay-item .ov-content { width: 100%; height: 100%; overflow: hidden; }
.overlay-item .ov-move {
  position: absolute; left: -11px; top: -11px; width: 22px; height: 22px;
  display: none; place-items: center; border-radius: 50%;
  background: var(--primary); color: #fff; border: 2px solid #fff;
  font-size: 13px; line-height: 1; cursor: grab; z-index: 3;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.overlay-item.selected .ov-move { display: grid; }
.overlay-item .ov-text {
  width: 100%; height: 100%; outline: none; white-space: pre-wrap;
  overflow: hidden; line-height: 1.25;
}
.overlay-item img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.overlay-item .ov-whiteout { width: 100%; height: 100%; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.overlay-item .resize {
  position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--primary); border: 2px solid #fff;
  cursor: nwse-resize; display: none;
}
.overlay-item.selected .resize { display: block; }
.overlay-item .del {
  position: absolute; right: -10px; top: -10px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--red); color: #fff; border: 2px solid #fff;
  display: none; place-items: center;
}
.overlay-item.selected .del { display: grid; }
.overlay-item .del svg { width: 10px; height: 10px; }
.overlay-stamp {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; border: 2px solid currentColor; border-radius: 4px;
  font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  font-size: 14px;
}

.editor-side {
  width: 224px;
  background: var(--surface); border-left: 1px solid var(--line);
  padding: 14px 12px; overflow-y: auto;
  transition: width .2s ease, padding .2s ease;
}
.editor-side:not(.is-open):not(.has-item) {
  width: 0 !important; padding: 0 !important; border-left: 0 !important; overflow: hidden !important; pointer-events: none;
}
.side-title { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.side-empty { font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.side-field { margin-bottom: 13px; }
.side-field label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.side-field .input, .side-field .select { padding: 8px 10px; font-size: 13px; }
.side-actions { display: grid; gap: 7px; margin-top: 14px; }
.side-note { font-size: 11px; color: var(--muted-2); margin-top: 12px; line-height: 1.5; }
.side-quote {
  font-size: 12px; color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  max-height: 70px; overflow: auto; word-break: break-word;
}
.stamp-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.stamp-chip {
  border: 1.5px solid color-mix(in srgb, var(--stamp) 55%, var(--line));
  color: var(--stamp); background: color-mix(in srgb, var(--stamp) 6%, transparent);
  border-radius: 6px; padding: 4px 7px; font-size: 9.5px; font-weight: 800;
  letter-spacing: .05em; text-transform: uppercase; cursor: pointer;
}
.stamp-chip:hover, .stamp-chip.active {
  background: color-mix(in srgb, var(--stamp) 15%, transparent);
  border-color: var(--stamp);
}

.editor-status {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px 12px; font-size: 11.5px; color: var(--muted);
}
.editor-status::-webkit-scrollbar { display: none; }
/* UI.icon() emits <svg> with no width/height attributes, so every icon needs an
   explicit CSS size. Without this the shield icon fell back to its 171x171
   intrinsic default, inflating the status bar to 206px and stealing the height
   the PDF needs to auto-fit into. */
.editor-status svg { width: 14px; height: 14px; flex-shrink: 0; }
.editor-status { flex-shrink: 0; }
.editor-status .spacer { flex: 1; }
.editor-status [data-zoom-label] {
  min-width: 40px; text-align: center; font-weight: 700; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.zoom-group, .fit-group {
  display: inline-flex; align-items: center; gap: 1px; flex: 0 0 auto;
  background: var(--surface-3); border-radius: 9px; padding: 2px;
}
.status-local { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
/* Only phones get the drawer buttons; tablet and desktop already show both panels. */
.editor-drawer-toggle { display: none; }
.editor-empty { padding: 52px 24px; text-align: center; }
.editor-empty .drop { max-width: 560px; margin: 0 auto; }
.editor-empty h1, .editor-empty h2 { font-size: 26px; margin: 18px 0 6px; }
.editor-empty p { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.sigpad-wrap { background: var(--surface); border-radius: 18px; padding: 20px; width: min(560px, 92vw); }
.sigpad-wrap h3 { font-size: 18px; margin-bottom: 4px; }
.sigpad-wrap p { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.sigpad {
  width: 100%; height: 200px; border: 1.5px dashed var(--line-strong);
  border-radius: 12px; background: var(--bg); touch-action: none; cursor: crosshair;
}
.sigpad-actions { display: flex; gap: 8px; margin-top: 14px; }
.sigpad-actions .spacer { flex: 1; }

.sig-tabs {
  display: inline-flex; gap: 3px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 14px;
}
.sig-tab {
  display: inline-flex; align-items: center; gap: 6px; border: 0;
  background: transparent; border-radius: 7px; padding: 7px 12px;
  font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.sig-tab svg { width: 15px; height: 15px; }
.sig-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(20,22,40,.14); }
.sig-upload {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: 12px;
  background: var(--bg); padding: 16px;
  transition: border-color .15s, background .15s;
}
.sig-upload:hover, .sig-upload.drag { border-color: var(--primary); background: var(--primary-soft); }
.sig-upload-ico {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  background: var(--surface); display: grid; place-items: center; color: var(--primary);
}
.sig-upload-ico svg { width: 18px; height: 18px; }
.sig-upload-text strong { display: block; font-size: 13.5px; }
.sig-upload-text span { font-size: 11.5px; color: var(--muted); }
.sig-preview {
  margin-top: 12px; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: grid; place-items: center; min-height: 130px;
  background: repeating-conic-gradient(color-mix(in srgb, var(--ink) 6%, transparent) 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
}
.sig-preview img { max-width: 100%; max-height: 180px; }
.sig-clean-row { margin-top: 12px; font-size: 12.5px; }

.stamp-wrap { background: var(--surface); border-radius: 18px; padding: 20px; width: min(540px, 92vw); }
.stamp-wrap h3 { font-size: 18px; margin-bottom: 4px; }
.stamp-wrap p { font-size: 12.5px; color: var(--muted); }
.stamp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; margin: 14px 0 16px; }
.stamp-preset {
  padding: 12px 8px; border-radius: 9px; cursor: pointer;
  border: 2px solid var(--stamp); color: var(--stamp);
  background: color-mix(in srgb, var(--stamp) 7%, transparent);
  font-weight: 800; letter-spacing: .08em; font-size: 12px; text-transform: uppercase;
  transition: background .15s, transform .15s;
}
.stamp-preset:hover { background: color-mix(in srgb, var(--stamp) 15%, transparent); transform: translateY(-1px); }
.stamp-custom { display: flex; gap: 8px; align-items: center; }
.stamp-custom .input { flex: 1; min-width: 0; padding: 8px 10px; font-size: 13px; }
.stamp-custom input[type="color"] {
  width: 40px; height: 38px; padding: 3px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface);
}
.stamp-hint { margin-top: 12px; font-size: 11.5px; color: var(--muted); }

/* ---------- Scanner ---------- */

.scan-page { padding-bottom: 50px; }
.scan-head { padding-top: 42px; }
.scan-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 18px; margin-top: 24px; align-items: start; }
.scan-stage {
  position: relative; background: #0d0e15; border-radius: var(--radius-xl);
  overflow: hidden; aspect-ratio: 4 / 3; display: grid; place-items: center;
  border: 1px solid var(--line);
}
.scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.scan-stage .scan-placeholder { text-align: center; color: #b9bdd4; padding: 30px; }
.scan-placeholder svg { width: 46px; height: 46px; margin: 0 auto 12px; opacity: .75; }
.scan-placeholder p { font-size: 13.5px; }
.scan-frame {
  position: absolute; inset: 6%; border: 2px solid rgba(255,255,255,.75);
  border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(0,0,0,.18);
}
.scan-frame::before, .scan-frame::after {
  content: ""; position: absolute; width: 26px; height: 26px;
  border: 3px solid #8b7dff; border-radius: 4px;
}
.scan-frame::before { left: -3px; top: -3px; border-right: 0; border-bottom: 0; }
.scan-frame::after { right: -3px; bottom: -3px; border-left: 0; border-top: 0; }
.scan-stage-btns {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}
.scan-stage-btns .btn { backdrop-filter: blur(8px); }
.scan-side { display: grid; gap: 14px; }
.scan-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
.scan-card h3 { font-size: 15px; margin-bottom: 12px; }
.scan-actions { display: grid; gap: 8px; }
.scan-pages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scan-page-thumb {
  position: relative; border: 1px solid var(--line); border-radius: 9px;
  overflow: hidden; background: var(--bg); aspect-ratio: 3 / 4;
}
.scan-page-thumb img { width: 100%; height: 100%; object-fit: cover; }
.scan-page-thumb button {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  border-radius: 6px; border: 0; background: rgba(15,17,26,.72); color: #fff;
  display: grid; place-items: center;
}
.scan-page-thumb button svg { width: 11px; height: 11px; }
.scan-empty { font-size: 12px; color: var(--muted-2); text-align: center; padding: 16px 0; }
.scan-card h3 .scan-count { display: block; margin: 4px 0 10px; font-family: var(--font); font-size: 11.5px; font-weight: 600; color: var(--muted); }
.scan-stage-btns { flex-wrap: wrap; justify-content: center; width: 90%; }

.text-preview {
  margin-top: 12px; max-height: 300px; overflow: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; font-size: 12.5px; line-height: 1.6; color: var(--ink-soft);
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.rot180 { transform: rotate(180deg); }
.rot90 { transform: rotate(90deg); }

/* ---------- Toasts / modal ---------- */

.toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 150; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(440px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 9px;
  background: #20223a; color: #fff; border-radius: 11px;
  padding: 11px 16px; font-size: 13px; font-weight: 600;
  box-shadow: 0 14px 34px rgba(15, 17, 30, .3);
  animation: toastIn .25s var(--ease);
  max-width: 100%;
}
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success svg { color: #5fe0b0; }
.toast.error { background: #5c2323; }
.toast.error svg { color: #ff9d9d; }
.toast.out { animation: toastOut .2s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.98); } }

.modal-root {
  position: fixed; inset: 0; z-index: 140;
  background: rgba(16, 17, 28, .55); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
  animation: fadeIn .18s;
}
.modal-root > * { animation: modalIn .22s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.985); } }

/* ---------- CV / Resume Maker ---------- */

.cv-page { background: var(--bg-soft); min-height: calc(100vh - var(--header-h)); padding-bottom: 60px; }
.cv-wrap { padding-top: 30px; }
.cv-head { margin-top: 14px; }

.cv-bar {
  position: sticky; top: var(--header-h); z-index: 25;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px; margin: 18px 0;
  box-shadow: var(--shadow-sm);
}
.cv-bar .btn { white-space: nowrap; }
.cv-bar-spacer { flex: 1; }
.cv-count { background: var(--surface-3); border-radius: 99px; padding: 1px 7px; font-size: 11px; font-weight: 800; }

.cv-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); gap: 20px; align-items: start; }
.cv-form { display: grid; gap: 16px; min-width: 0; }
.cv-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.cv-card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.cv-card-head h3 { font-size: 15px; font-weight: 800; }
.cv-hint { font-size: 11.5px; color: var(--muted-2); }

.cv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cv-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cv-field.full { grid-column: 1 / -1; }
.cv-field > span { font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.cv-textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.5;
  resize: vertical; min-height: 72px;
  transition: border-color .15s, box-shadow .15s;
}
.cv-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.cv-repeat { border: 1px dashed var(--line-strong); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: var(--surface-2); }
.cv-repeat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.cv-repeat-head span { font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.cv-add-row { display: flex; flex-wrap: wrap; gap: 8px; }

.cv-import-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cv-import-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 14px; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; text-align: left;
  transition: border-color .15s, background .15s;
}
.cv-import-btn:hover { border-color: var(--primary); background: var(--surface-2); }
.cv-import-btn svg { width: 18px; height: 18px; color: var(--primary); }
.cv-import-btn strong { font-size: 13.5px; margin-top: 4px; }
.cv-import-btn span { font-size: 11.5px; color: var(--muted); }
.cv-help { font-size: 12px; line-height: 1.55; color: var(--muted); margin-top: 10px; }

.cv-preview-btn { display: none; }
.cv-preview-wrap {
  position: sticky; top: calc(var(--header-h) + 18px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px;
}
.cv-preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cv-preview-head strong { font-size: 13px; font-weight: 800; }
.cv-preview-head span { font-size: 11px; color: var(--muted-2); }
.cv-preview-scroll {
  max-height: calc(100vh - var(--header-h) - 170px); overflow: auto;
  border-radius: 10px; background: var(--bg-soft); padding: 10px;
}
.cv-preview-help { margin-top: 10px; }

.cv-paper {
  background: #fff; color: #191b26; border-radius: 4px; padding: 28px 26px;
  box-shadow: 0 10px 26px rgba(20, 22, 40, .14);
  font-family: "Helvetica Neue", Arial, sans-serif; font-size: 12px; line-height: 1.45;
}
/* Not an <h1>: the CV sheet is a preview of the user's own document, and a second
   page-level h1 would compete with this page's real heading. Same box as before. */
.cv-paper-head .cv-name {
  display: block; font-family: var(--font-display); font-weight: 700; font-size: 21px;
  line-height: 1.15; letter-spacing: -.02em; color: #11131c; margin: 0;
}
.cv-role { font-size: 13px; color: #4a4d5c; margin-top: 2px; }
.cv-contact { font-size: 10.5px; color: #5a5d6c; margin-top: 6px; word-break: break-word; }
.cv-sec { margin-top: 16px; }
.cv-sec h2 {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #2a2d3a;
  padding-bottom: 4px; border-bottom: 1px solid #d8dae2; margin-bottom: 8px;
}
.cv-text { font-size: 11.5px; color: #33364a; }
.cv-entry { margin-bottom: 10px; }
.cv-entry-top { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; }
.cv-entry-top strong { font-weight: 700; color: #191b26; }
.cv-entry-top span { color: #5a5d6c; white-space: nowrap; font-size: 10.5px; }
.cv-entry-sub { font-size: 11px; color: #4a4d5c; margin-top: 1px; word-break: break-word; }
.cv-bullets { margin: 5px 0 0 16px; padding: 0; }
.cv-bullets li { font-size: 11px; color: #33364a; margin-bottom: 3px; }
.cv-placeholder { font-size: 12px; color: #8a8d9b; padding: 20px 4px; }

.cv-modal {
  background: var(--surface); border-radius: 18px; padding: 20px;
  width: min(560px, 94vw); max-height: calc(100vh - 40px); overflow: auto;
  box-shadow: var(--shadow);
}
.cv-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cv-modal-head h3 { font-size: 18px; font-weight: 800; }
.cv-x { border: 0; background: var(--surface-3); border-radius: 8px; width: 30px; height: 30px; display: grid; place-items: center; flex-shrink: 0; }
.cv-x svg { width: 14px; height: 14px; }
.cv-modal .cv-field { margin-top: 12px; }
.cv-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.cv-confirm p { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin-top: 8px; }

.cv-file {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding: 12px; border: 1.5px dashed var(--line-strong);
  border-radius: 12px; background: var(--bg-soft); cursor: pointer;
}
.cv-file:hover { border-color: var(--primary); }
.cv-file-btn { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--primary); }
.cv-file-btn svg { width: 16px; height: 16px; }
.cv-file-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cv-hint-list {
  background: var(--blue-soft); color: color-mix(in srgb, var(--blue) 70%, var(--ink));
  border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.5; margin-top: 12px;
}

.cv-lib-list { display: grid; gap: 8px; margin-top: 12px; }
.cv-lib-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; flex-wrap: wrap;
}
.cv-lib-meta strong { display: block; font-size: 13px; }
.cv-lib-meta span { font-size: 11.5px; color: var(--muted); }
.cv-lib-actions { display: flex; gap: 6px; }
.cv-empty { font-size: 12.5px; color: var(--muted); line-height: 1.55; }

@media (max-width: 1080px) {
  .cv-layout { grid-template-columns: 1fr; }
  .cv-preview-btn { display: inline-flex; }
  .cv-preview-wrap { display: none; position: static; }
  .cv-preview-scroll { max-height: none; }
  .cv-layout.show-preview .cv-form { display: none; }
  .cv-layout.show-preview .cv-preview-wrap { display: block; }
}

@media (max-width: 640px) {
  .cv-grid { grid-template-columns: 1fr; }
  .cv-import-grid { grid-template-columns: 1fr; }
  .cv-bar .btn { flex: 1 1 auto; justify-content: center; }
  .cv-bar-spacer { display: none; }
  .cv-card { padding: 14px; }
  .cv-paper { padding: 22px 18px; }
  .cv-wrap { padding-top: 20px; }
}

/* ---------- Document Scanner ---------- */

.ds-page { background: var(--bg-soft); min-height: calc(100vh - var(--header-h)); padding-bottom: 60px; }
.ds-head { padding-top: 8px; }

.ds-steps {
  position: sticky; top: var(--header-h); z-index: 25;
  display: flex; gap: 4px; overflow-x: auto;
  margin: 16px 0 16px; padding: 7px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-sm);
  scrollbar-width: none;
}
.ds-steps::-webkit-scrollbar { display: none; }
.ds-step {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  border: 1px solid transparent; background: transparent;
  border-radius: 10px; padding: 9px 13px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.ds-step:hover { background: var(--surface-3); color: var(--ink); }
.ds-step[aria-selected="true"] {
  background: var(--primary-soft); color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 26%, transparent);
}
.ds-step-num {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted);
  font-size: 11px; font-weight: 800;
}
.ds-step[aria-selected="true"] .ds-step-num { background: var(--primary); color: #fff; }
.ds-step-count { background: var(--surface-3); border-radius: 99px; padding: 1px 7px; font-size: 11px; font-weight: 800; }
.ds-step[aria-selected="true"] .ds-step-count { background: rgba(255, 255, 255, .55); color: inherit; }
[data-theme="dark"] .ds-step[aria-selected="true"] .ds-step-count { background: rgba(0, 0, 0, .28); }
.ds-step:focus-visible, .ds-strip-item:focus-visible, .ds-page-card:focus-visible,
.ds-handle:focus-visible, .ds-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Capture */
.ds-capture-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, .6fr); gap: 16px; align-items: start; }
.ds-stage {
  position: relative; display: grid; place-items: center;
  aspect-ratio: 4 / 3; min-height: 320px; overflow: hidden;
  background: #0c0d14; border-radius: var(--radius-xl);
  border: 1px solid var(--line);
}
.ds-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ds-stage-empty { position: relative; text-align: center; color: #c4c8dd; padding: 30px 24px; max-width: 420px; }
.ds-stage-ico {
  width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 18px;
  display: grid; place-items: center;
  background: rgba(139, 125, 255, .16); color: #a99eff;
  border: 1px solid rgba(139, 125, 255, .28);
}
.ds-stage-ico svg { width: 30px; height: 30px; }
.ds-stage-empty strong { display: block; font-size: 18px; color: #fff; }
.ds-stage-empty p { font-size: 13px; line-height: 1.55; margin-top: 6px; color: #a9aec6; }
.ds-cta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ds-stage-empty .ds-cta-row, .ds-help .ds-cta-row { justify-content: center; }
.ds-stage-empty .btn-soft { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .24); color: #fff; box-shadow: none; }
.ds-stage-empty .btn-soft:hover { background: rgba(255, 255, 255, .18); }

.ds-cam-frame {
  position: absolute; inset: 7%; pointer-events: none;
  border: 1.5px solid rgba(255, 255, 255, .38); border-radius: 16px;
}
.ds-cam-frame::before, .ds-cam-frame::after {
  content: ""; position: absolute; width: 28px; height: 28px;
  border: 3px solid #9b8dff; border-radius: 5px;
}
.ds-cam-frame::before { left: -3px; top: -3px; border-right: 0; border-bottom: 0; }
.ds-cam-frame::after { right: -3px; bottom: -3px; border-left: 0; border-top: 0; }

.ds-cam-bar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 22px;
  padding: 10px 16px; border-radius: 99px;
  background: rgba(14, 16, 26, .62); backdrop-filter: blur(10px);
}
.ds-cam-side {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .24);
  background: rgba(255, 255, 255, .08); color: #fff;
  display: grid; place-items: center;
}
.ds-cam-side:hover { background: rgba(255, 255, 255, .18); }
.ds-cam-side svg { width: 19px; height: 19px; }
.ds-shutter {
  width: 66px; height: 66px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .9); background: #fff;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, .16);
  transition: transform .15s;
}
.ds-shutter:hover { transform: scale(1.04); }
.ds-shutter:active { transform: scale(.95); }

.ds-snap {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  padding: 18px; background: #0c0d14;
}
.ds-snap img { max-width: 100%; max-height: calc(100% - 64px); object-fit: contain; border-radius: 8px; }
.ds-snap-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.ds-snap-btns .btn-soft { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .24); color: #fff; box-shadow: none; }

.ds-stage-busy {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(9, 10, 16, .78); color: #e6e8f5; text-align: center; padding: 20px;
}
.ds-stage-busy p { font-size: 13px; font-weight: 600; }
.ds-spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .22); border-top-color: #a99eff;
  animation: dsSpin .75s linear infinite;
}
@keyframes dsSpin { to { transform: rotate(360deg); } }

.ds-help {
  margin-top: 14px; padding: 16px 18px;
  background: var(--amber-soft); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  border-radius: var(--radius); font-size: 12.5px; line-height: 1.55;
  color: color-mix(in srgb, var(--amber) 60%, var(--ink));
}
.ds-help-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.ds-help-head svg { width: 17px; height: 17px; flex-shrink: 0; }
.ds-help-msg { margin-top: 6px; font-weight: 700; }
.ds-help ol { list-style: decimal; padding-left: 20px; margin: 8px 0; display: grid; gap: 4px; }
.ds-help p + p { margin-top: 6px; }

.ds-capture-note {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding: 12px 16px;
  background: var(--green-soft); color: color-mix(in srgb, var(--green) 62%, var(--ink));
  border-radius: 12px; font-size: 13px; font-weight: 600;
}

.ds-side { display: grid; gap: 14px; }
.ds-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
.ds-card h3 { font-size: 15px; font-weight: 800; margin-bottom: 12px; }
.ds-note { font-size: 11.5px; line-height: 1.55; color: var(--muted-2); margin-top: 10px; }

.ds-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  text-align: center; cursor: pointer; padding: 26px 16px;
  border: 1.6px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--bg); transition: border-color .2s, background .2s;
}
.ds-drop:hover, .ds-drop.drag { border-color: var(--primary); background: var(--primary-soft); }
.ds-drop-ico {
  width: 44px; height: 44px; border-radius: 13px; margin-bottom: 6px;
  display: grid; place-items: center; background: var(--primary-soft); color: var(--primary);
}
.ds-drop-ico svg { width: 21px; height: 21px; }
.ds-drop strong { font-size: 13.5px; }
.ds-drop-sub { font-size: 12px; color: var(--muted); }
.ds-drop-meta { font-size: 10.5px; color: var(--muted-2); margin-top: 6px; line-height: 1.45; }

.ds-errors { display: grid; gap: 8px; margin-top: 10px; }
.ds-error {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--red-soft); color: var(--red);
  border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.5; font-weight: 600;
}
.ds-error svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

.ds-tips ul { display: grid; gap: 7px; margin-top: 2px; }
.ds-tips li { position: relative; padding-left: 16px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.ds-tips li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* Edit */
.ds-edit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 348px); gap: 16px; align-items: start; }
.ds-preview-card {
  position: sticky; top: calc(var(--header-h) + 74px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 16px;
}
.ds-preview-card.loading::after {
  content: ""; position: absolute; top: 22px; right: 20px;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--primary);
  animation: dsSpin .7s linear infinite;
}
.ds-preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ds-preview-head strong { display: block; font-size: 14px; }
.ds-preview-head [data-edit-sub] { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.ds-view-toggle { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.ds-view-toggle button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 11.5px; font-weight: 700; border-radius: 7px; padding: 5px 9px;
  transition: background .15s, color .15s;
}
.ds-view-toggle button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

.ds-cmp { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.ds-cmp figure {
  margin: 0; display: flex; flex-direction: column; min-width: 0;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.ds-cmp canvas {
  width: auto; height: auto; max-width: 100%; max-height: min(62vh, 600px);
  margin: 0 auto; background: #fff;
}
.ds-cmp figcaption {
  font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); text-align: center; padding: 7px 6px;
  border-top: 1px solid var(--line); background: var(--surface);
}
.ds-cmp.view-split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ds-cmp.view-split canvas { max-height: min(48vh, 460px); }
.ds-cmp.view-after figure:first-child { display: none; }
.ds-cmp.view-before figure:last-child { display: none; }

.ds-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; font-size: 12px; color: var(--ink-soft); line-height: 1.5;
}
.ds-banner span { display: inline-flex; align-items: center; gap: 7px; }
.ds-banner svg { width: 15px; height: 15px; color: var(--green); flex-shrink: 0; }
.ds-banner .btn { padding: 5px 8px; }

.ds-strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 14px; padding-bottom: 4px; scrollbar-width: thin; }
.ds-strip-item {
  position: relative; flex: 0 0 64px; width: 64px; height: 84px;
  border: 2px solid transparent; border-radius: 9px; padding: 0;
  background: var(--surface-3); overflow: hidden;
}
.ds-strip-item img { width: 100%; height: 100%; object-fit: cover; }
.ds-strip-item span {
  position: absolute; left: 3px; bottom: 3px;
  background: rgba(16, 17, 28, .74); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 5px; padding: 0 5px;
}
.ds-strip-item.active { border-color: var(--primary); }
.ds-strip-add {
  flex: 0 0 44px; height: 84px; border-radius: 9px;
  border: 1.5px dashed var(--line-strong); background: transparent; color: var(--muted);
  display: grid; place-items: center;
}
.ds-strip-add:hover { border-color: var(--primary); color: var(--primary); }
.ds-strip-add svg { width: 18px; height: 18px; }

.ds-controls { position: sticky; top: calc(var(--header-h) + 74px); }
.ds-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ds-card-head h3 { margin: 0; }
.ds-link {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: transparent; color: var(--primary);
  font-size: 12px; font-weight: 700; padding: 4px 6px; border-radius: 7px;
}
.ds-link:disabled { color: var(--muted-2); cursor: not-allowed; }
.ds-link svg { width: 13px; height: 13px; }

.ds-field {
  display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px;
  font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.ds-field select, .ds-field .input {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 8px 10px; font-size: 13px; font-weight: 600;
  color: var(--ink); text-transform: none; letter-spacing: 0;
}
.ds-field select:focus, .ds-field .input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.ds-slider { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 8px; margin-bottom: 10px; }
.ds-slider label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.ds-slider output {
  font-size: 11px; font-weight: 800; color: var(--primary);
  background: var(--primary-soft); border-radius: 6px; padding: 1px 6px;
  min-width: 34px; text-align: center;
}
.ds-slider input[type="range"] { grid-column: 1 / -1; }
.ds-slider.is-disabled { opacity: .45; }
.ds-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ds-actions .btn { flex: 1 1 auto; }

.ds-empty {
  background: var(--surface); border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg); padding: 46px 24px; text-align: center;
}
.ds-empty-ico {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 17px;
  display: grid; place-items: center; background: var(--primary-soft); color: var(--primary);
}
.ds-empty-ico svg { width: 27px; height: 27px; }
.ds-empty h2 { font-size: 18px; margin-bottom: 6px; }
.ds-empty p { font-size: 13px; color: var(--muted); max-width: 360px; margin: 0 auto 16px; }

/* Pages */
.ds-pages-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.ds-pages-head strong { display: block; font-size: 15px; }
.ds-pages-head span { font-size: 12px; color: var(--muted); }
.ds-pages-head .ds-cta-row { margin-top: 0; }
.ds-page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.ds-page-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: 8px; cursor: grab;
  transition: border-color .15s, box-shadow .15s, opacity .15s;
}
.ds-page-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.ds-page-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
.ds-page-card.dragging { opacity: .45; }
.ds-page-card.drop-target { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.ds-page-thumbwrap { position: relative; aspect-ratio: 3 / 4; display: grid; place-items: center; background: #fff; border-radius: 8px; overflow: hidden; }
.ds-page-thumbwrap img { width: 100%; height: 100%; object-fit: contain; }
.ds-page-num {
  position: absolute; top: 6px; left: 6px;
  background: rgba(16, 17, 28, .74); color: #fff;
  font-size: 10px; font-weight: 800; border-radius: 5px; padding: 1px 6px;
}
.ds-page-tools { position: absolute; right: 6px; bottom: 6px; display: flex; gap: 3px; }
.ds-page-tools button {
  width: 26px; height: 26px; border-radius: 7px; border: 0;
  background: rgba(16, 17, 28, .72); color: #fff;
  display: grid; place-items: center;
}
.ds-page-tools button:hover { background: var(--primary); }
.ds-page-tools button svg { width: 13px; height: 13px; }
.ds-page-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 2px 1px; }
.ds-page-meta > span { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-page-move { display: flex; gap: 2px; flex-shrink: 0; }
.ds-page-move button {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); display: grid; place-items: center;
}
.ds-page-move button:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.ds-page-move button:disabled { opacity: .35; cursor: not-allowed; }
.ds-page-move svg { width: 12px; height: 12px; }

/* Export */
.ds-export-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 16px; align-items: start; }
.ds-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ds-export-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ds-export-actions .btn-primary { flex: 1 1 100%; }
.ds-export-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 8px; }
.ds-export-thumb { position: relative; aspect-ratio: 3 / 4; background: #fff; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.ds-export-thumb img { width: 100%; height: 100%; object-fit: contain; }
.ds-export-thumb span {
  position: absolute; left: 4px; bottom: 4px;
  background: rgba(16, 17, 28, .72); color: #fff;
  font-size: 9.5px; font-weight: 700; border-radius: 4px; padding: 1px 5px;
}
.ds-card-count { font-size: 11.5px; font-weight: 700; color: var(--muted); }

/* Crop modal */
.ds-modal {
  background: var(--surface); border-radius: 18px; padding: 20px;
  width: min(920px, 96vw); max-height: calc(100vh - 40px); overflow: auto;
  box-shadow: var(--shadow-lg);
}
.ds-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ds-modal-head h2 { font-size: 20px; font-weight: 800; }
.ds-modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.ds-crop-stage { background: #0c0d14; border-radius: 12px; padding: 14px; display: grid; place-items: center; }
.ds-crop-inner { position: relative; max-width: 100%; }
.ds-crop-inner canvas { display: block; width: 100%; height: 100%; border-radius: 6px; }
.ds-handle {
  position: absolute; width: 22px; height: 22px; margin: 0;
  border: 3px solid #fff; background: var(--primary);
  border-radius: 50%; transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .4);
  touch-action: none; padding: 0;
}
.ds-crop-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.ds-crop-actions .btn { flex: 0 0 auto; }

.ds-confirm { width: min(420px, 94vw); }
.ds-confirm h2 { font-size: 19px; margin-bottom: 8px; }
.ds-confirm p { font-size: 13px; color: var(--muted); line-height: 1.55; }
.ds-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.ds-flip { transform: scaleX(-1); }

.tool-card-cta {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: auto; padding-top: 6px;
  font-size: 12.5px; font-weight: 800; color: var(--primary);
}
.tool-card-cta span { transition: transform .18s var(--ease); }
.tool-card:hover .tool-card-cta span { transform: translateX(3px); }

@media (max-width: 1080px) {
  .ds-capture-grid, .ds-edit, .ds-export-grid { grid-template-columns: 1fr; }
  .ds-preview-card, .ds-controls { position: static; }
}

@media (max-width: 640px) {
  .ds-page { padding-bottom: 40px; }
  .ds-head { padding-top: 0; }
  .ds-steps { margin: 12px 0; }
  .ds-step { padding: 8px 10px; font-size: 12px; gap: 6px; }
  .ds-step-num { display: none; }
  .ds-stage { aspect-ratio: 3 / 4; min-height: 280px; }
  .ds-stage-empty { padding: 22px 18px; }
  .ds-card { padding: 14px; }
  .ds-grid2 { grid-template-columns: 1fr; gap: 0; }
  .ds-cmp.view-split { grid-template-columns: 1fr; }
  .ds-page-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .ds-page-tools { right: 6px; bottom: 6px; gap: 4px; }
  .ds-page-tools button { width: 30px; height: 30px; }
  .ds-page-tools button svg { width: 14px; height: 14px; }
  .ds-export-actions .btn { flex: 1 1 100%; }
  .ds-modal { padding: 14px; }
  .ds-crop-actions .btn { flex: 1 1 auto; }
  .ds-crop-actions .grow { display: none; }
  .ds-pages-head .ds-cta-row { width: 100%; }
}

/* ---------- Rubber Stamp Studio ---------- */

.page-wrap.stamp-place { cursor: crosshair; }
.page-wrap.stamp-place canvas { box-shadow: 0 0 0 3px var(--primary), 0 14px 40px rgba(20, 22, 40, .22); }
.overlay-item[data-type="rstamp"] { cursor: move; }
.overlay-item .rotate {
  position: absolute; left: 50%; top: -30px; transform: translateX(-50%);
  width: 22px; height: 22px; display: none; place-items: center;
  border-radius: 50%; background: var(--surface); color: var(--primary);
  border: 2px solid var(--primary); cursor: grab; z-index: 3;
  box-shadow: var(--shadow-sm);
}
.overlay-item .rotate svg { width: 12px; height: 12px; }
.overlay-item.selected .rotate { display: grid; }

.side-stamp-preview {
  display: grid; place-items: center; min-height: 84px; padding: 10px; margin-bottom: 12px;
  border: 1px dashed var(--line-strong); border-radius: 12px;
  background:
    linear-gradient(45deg, var(--surface-3) 25%, transparent 25%, transparent 75%, var(--surface-3) 75%) 0 0 / 12px 12px,
    linear-gradient(45deg, var(--surface-3) 25%, transparent 25%, transparent 75%, var(--surface-3) 75%) 6px 6px / 12px 12px,
    var(--surface);
}
.side-stamp-preview img { max-width: 100%; max-height: 96px; object-fit: contain; }
.side-hint { font-size: 11px; line-height: 1.45; color: var(--muted); margin: 6px 0 0; }
.side-field label output { float: right; font-weight: 700; color: var(--ink-soft); }

.ss {
  width: min(1000px, 100%); max-height: min(860px, calc(100vh - 40px));
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.ss-head, .ss-tabs, .ss-foot { flex: none; }
.ss-head { display: flex; align-items: flex-start; gap: 16px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.ss-head h2 { font-family: var(--font-display); font-size: 21px; margin: 0 0 4px; }
.ss-head p { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 0; max-width: 720px; }
.ss-close {
  margin-left: auto; flex-shrink: 0; width: 34px; height: 34px;
  display: grid; place-items: center; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--ink-soft);
}
.ss-close:hover { background: var(--surface-3); }
.ss-close svg { width: 16px; height: 16px; }
.ss-tabs { display: flex; gap: 4px; padding: 10px 22px 0; border-bottom: 1px solid var(--line); }
.ss-tab {
  border: 0; border-bottom: 2px solid transparent; background: transparent;
  padding: 9px 12px 11px; font-size: 13px; font-weight: 700; color: var(--muted);
}
.ss-tab:hover { color: var(--ink); }
.ss-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.ss-count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  padding: 0 5px; margin-left: 4px; border-radius: 9px;
  background: var(--surface-3); font-size: 10.5px; color: var(--muted);
}
.ss-tab.active .ss-count { background: var(--primary-soft); color: var(--primary); }
.ss-body { flex: 1; min-height: 0; overflow: hidden; display: flex; }
.ss-panel { flex: 1; min-width: 0; overflow-y: auto; padding: 16px 22px 22px; }
.ss-panel[hidden] { display: none; }
.ss-search-row {
  position: sticky; top: -16px; z-index: 2; padding: 0 0 10px;
  background: linear-gradient(var(--surface) 82%, transparent);
}
.ss-search-row .input { width: 100%; }
.ss-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ss-cat {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 11px; font-size: 11.5px; font-weight: 700; color: var(--ink-soft);
}
.ss-cat:hover { border-color: var(--line-strong); }
.ss-cat.active { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.ss-recent { margin-bottom: 14px; }
.ss-recent-label {
  display: block; font-size: 10px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.ss-recent-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.ss-recent-item {
  flex: 0 0 auto; width: 96px; height: 52px; display: grid; place-items: center;
  padding: 4px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.ss-recent-item:hover { border-color: var(--primary); }
.ss-recent-item img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ss-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ss-tile {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 10px 8px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.ss-tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.ss-tile.active { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.ss-tile-canvas { display: grid; place-items: center; height: 74px; margin-bottom: 2px; }
.ss-tile-canvas img { max-width: 100%; max-height: 74px; object-fit: contain; }
.ss-tile-label {
  font-size: 11.5px; font-weight: 800; letter-spacing: .02em; color: var(--ink);
  line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-tile-cat { font-size: 10px; color: var(--muted); }
.ss-empty { padding: 26px 8px; text-align: center; font-size: 13px; color: var(--muted); }

.ss-studio { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.ss-preview-col { position: sticky; top: 0; display: grid; gap: 8px; }
.ss-preview {
  display: grid; place-items: center; min-height: 190px; padding: 18px;
  border: 1px dashed var(--line-strong); border-radius: 14px;
  background:
    linear-gradient(45deg, var(--surface-3) 25%, transparent 25%, transparent 75%, var(--surface-3) 75%) 0 0 / 16px 16px,
    linear-gradient(45deg, var(--surface-3) 25%, transparent 25%, transparent 75%, var(--surface-3) 75%) 8px 8px / 16px 16px,
    var(--surface);
}
.ss-preview img { max-width: 100%; max-height: 260px; object-fit: contain; }
.ss-note { font-size: 11px; line-height: 1.5; color: var(--muted); margin: 0; }
.ss-controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; align-items: start; }
.ss-group {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
}
.ss-group h4 {
  grid-column: 1 / -1; margin: 0 0 2px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.ss-field { display: grid; gap: 4px; min-width: 0; }
.ss-field > span {
  font-size: 11px; font-weight: 700; color: var(--muted);
  display: flex; justify-content: space-between; gap: 6px;
}
.ss-field > span em { font-style: normal; font-weight: 500; color: var(--muted-2); }
.ss-field > span b { color: var(--ink-soft); font-weight: 700; }
.ss-field .input, .ss-field .select { width: 100%; padding: 8px 9px; font-size: 12.5px; }
.ss-field input[type="range"] { accent-color: var(--primary); width: 100%; }
.ss-wide { grid-column: 1 / -1; }
.ss-check { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-soft); }
.ss-check input { accent-color: var(--primary); }
.ss-color input[type="color"] {
  width: 100%; height: 32px; padding: 2px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--surface);
}
.ss-toggles { display: flex; gap: 6px; }
.ss-tg {
  width: 34px; height: 32px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); font-weight: 900; font-size: 13px; color: var(--ink-soft);
}
.ss-tg.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.ss-upload { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.ss-up {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); font-size: 11.5px; font-weight: 700;
  color: var(--ink-soft); cursor: pointer;
}
.ss-up:hover { background: var(--surface-3); }
.ss-up-state {
  flex: 1; font-size: 11px; color: var(--muted);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-clear { border: 0; background: transparent; font-size: 11px; font-weight: 700; color: var(--primary); padding: 4px; }
.ss-clear:hover { text-decoration: underline; }

.ss-foot {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 22px; border-top: 1px solid var(--line); background: var(--surface);
}
.ss-selected { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ss-selected img { width: 74px; height: 40px; object-fit: contain; }
.ss-selected > span { display: grid; gap: 1px; min-width: 0; }
.ss-selected strong {
  font-size: 12.5px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 190px;
}
.ss-selected span span { font-size: 10.5px; color: var(--muted); }
.ss-foot-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ss-name { width: 190px; padding: 8px 10px; font-size: 12.5px; }

.ss-saved { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ss-saved-card {
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.ss-saved-thumb { display: grid; place-items: center; height: 80px; border-radius: 8px; background: var(--surface-2); }
.ss-saved-thumb img { max-width: 100%; max-height: 76px; object-fit: contain; }
.ss-saved-meta { display: grid; gap: 2px; }
.ss-saved-meta strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-saved-meta span { font-size: 11px; color: var(--muted); }
.ss-saved-actions { display: flex; gap: 3px; flex-wrap: wrap; }
.ss-saved-actions button {
  display: inline-flex; align-items: center; border: 1px solid var(--line);
  background: var(--surface); border-radius: 8px; padding: 5px 8px;
  font-size: 11px; font-weight: 700; color: var(--ink-soft);
}
.ss-saved-actions button:hover { background: var(--surface-3); }
.ss-saved-actions button svg { width: 13px; height: 13px; }
.ss-rename { padding: 6px 8px; font-size: 12.5px; }

.ss-confirm {
  width: min(440px, 100%); padding: 22px; border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.ss-confirm h3 { margin: 0 0 8px; font-size: 17px; }
.ss-confirm p { margin: 0 0 16px; font-size: 13px; line-height: 1.55; color: var(--muted); }
.ss-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 880px) {
  /* Drawers, not stacked panels: one place that decides where an open Pages or
     Properties sheet sits, so the two can never fight over the bottom of a phone
     screen. The safe-area inset keeps the last row clear of the iOS gesture bar. */
  .editor-side.has-item, .editor-side.is-open, .editor-rail.is-open {
    position: fixed; left: 10px; right: 10px; bottom: 10px;
    max-height: 48vh; z-index: 70; border: 1px solid var(--line);
    border-radius: 16px; box-shadow: var(--shadow-lg); background: var(--surface);
    padding: 12px 14px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .ss-studio { grid-template-columns: 1fr; }
  .ss-preview-col { position: static; }
  .ss-preview { min-height: 150px; }
}

@media (max-width: 620px) {
  .ss { max-height: calc(100vh - 12px); border-radius: 14px; }
  .ss-head { padding: 14px 14px 10px; }
  .ss-head h2 { font-size: 18px; }
  .ss-head p { font-size: 11px; }
  .ss-tabs { padding: 8px 12px 0; overflow-x: auto; }
  .ss-tab { white-space: nowrap; padding: 8px 8px 10px; font-size: 12px; }
  .ss-panel { padding: 12px 14px 16px; }
  .ss-search-row { top: -12px; }
  .ss-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .ss-tile-canvas { height: 60px; }
  .ss-tile-canvas img { max-height: 60px; }
  .ss-group { grid-template-columns: 1fr; padding: 10px; }
  .ss-wide { grid-column: auto; }
  .ss-upload { grid-column: auto; flex-wrap: wrap; }
  .ss-foot { padding: 10px 14px; }
  .ss-selected { display: none; }
  .ss-foot-actions { margin: 0; width: 100%; }
  .ss-name { flex: 1; width: auto; min-width: 120px; }
  .ss-foot-actions .btn { flex: 1; }
  .ss-saved { grid-template-columns: 1fr; }
}

/* ============================================================
   Passport Photo Maker (.pp-*) — photo studio + A4 sheet maker
   ============================================================ */

.pp-page { background: var(--bg-soft); min-height: calc(100vh - var(--header-h)); padding-bottom: 60px; }
.pp-shell { max-width: 1520px; margin: 0 auto; padding: 16px 22px 0; }
.pp-grow { flex: 1; }
.pp-mt8 { margin-top: 8px; }
.pp-mt12 { margin-top: 12px; }

.pp-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0 16px; }
.pp-heading { display: flex; flex-direction: column; min-width: 0; }
.pp-heading h1, .pp-heading h2 { font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
.pp-heading p { font-size: 12.5px; color: var(--muted); }

.pp-body { display: grid; grid-template-columns: 286px minmax(0, 1fr) 316px; gap: 14px; align-items: start; }
.pp-rail, .pp-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.pp-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 15px; }
.pp-sec-h { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 800; color: var(--ink); margin-bottom: 11px; }
.pp-sec-h svg { width: 16px; height: 16px; color: var(--primary); flex-shrink: 0; }
.pp-sub { font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
.pp-muted { font-size: 12px; color: var(--muted-2); line-height: 1.5; }
.pp-ellipsis { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

.pp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pp-four { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pp-btn-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* Segmented tab strips (reuse .chip) */
.pp-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.pp-tabs .chip { flex: 1 1 auto; justify-content: center; padding: 7px 10px; font-size: 12px; }
.pp-tabs-sm .chip { padding: 5px 9px; font-size: 11.5px; gap: 5px; }
.pp-tabs .chip svg { width: 13px; height: 13px; }

/* Dropzone + thumbnails */
.pp-drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg);
  padding: 22px 14px; background: var(--surface); cursor: pointer; transition: all .18s;
}
.pp-drop:hover, .pp-drop.drag, .pp-drop:focus-visible { border-color: var(--primary); background: var(--primary-soft); outline: none; }

.pp-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; }
.pp-thumbs:empty { display: none; }
.pp-thumb {
  position: relative; border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 4px 4px 28px; cursor: pointer; transition: all .15s;
}
.pp-thumb img { display: block; width: 100%; height: 62px; object-fit: cover; border-radius: 6px; }
.pp-thumb.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.pp-thumb-name {
  position: absolute; left: 6px; right: 6px; bottom: 15px; font-size: 9.5px; font-weight: 700;
  color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pp-thumb-copies { position: absolute; left: 6px; bottom: 3px; font-size: 9.5px; font-weight: 800; color: var(--primary); }
.pp-thumb-x {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: 0; border-radius: 999px;
  background: rgba(16, 17, 25, .62); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.pp-thumb-x svg { width: 11px; height: 11px; }

/* Key/value readouts */
.pp-readout { margin-top: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.pp-readout-sm { padding: 7px 9px; }
.pp-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12px; padding: 2px 0; }
.pp-row + .pp-row { border-top: 1px dashed var(--line); }
.pp-row-k { color: var(--muted); font-weight: 600; }
.pp-row-v { color: var(--ink); font-weight: 700; text-align: right; }

/* Sliders */
.pp-slider { margin-top: 10px; }
.pp-slider-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.pp-slider-top label { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.pp-slider-top .range-value { min-width: 46px; }

/* Background editing */
.pp-swatches { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.pp-swatch {
  position: relative; width: 26px; height: 26px; padding: 0; border-radius: 8px;
  border: 2px solid var(--line-strong); background: var(--sw, #fff);
  cursor: pointer; transition: transform .12s, border-color .12s;
}
.pp-swatch:hover { transform: scale(1.08); }
.pp-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.pp-swatch-custom { overflow: hidden; background: conic-gradient(#f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.pp-swatch-custom input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.pp-colourinput { height: 38px; padding: 3px; cursor: pointer; }
.pp-brush { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }

.pp-select-sm { width: auto; min-width: 110px; padding: 6px 10px; font-size: 12px; }

/* Notes */
.pp-note {
  display: flex; align-items: flex-start; gap: 8px; font-size: 12px; line-height: 1.5;
  border-radius: var(--radius-sm); padding: 9px 11px; margin-top: 10px;
}
.pp-note svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.pp-note.ok { background: var(--green-soft); color: #1c7a58; }
.pp-note.warn { background: var(--amber-soft); color: #8a5a12; }
.pp-note.bad { background: var(--red-soft); color: #a83434; }
[data-theme="dark"] .pp-note.ok { color: var(--green); }
[data-theme="dark"] .pp-note.warn { color: var(--amber); }
[data-theme="dark"] .pp-note.bad { color: var(--red); }

/* Checklist modal */
.pp-modal { max-width: 560px; max-height: 86vh; overflow: auto; }
.pp-modal .modal-head h2 { font-size: 18px; font-weight: 800; }
.pp-check { display: grid; gap: 7px; list-style: none; margin: 12px 0; }
.pp-check label { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; line-height: 1.45; }
.pp-check input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; accent-color: var(--primary); }

/* Crop workspace */
.pp-stage {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px;
  height: clamp(440px, calc(100vh - var(--header-h) - 210px), 800px);
}
.pp-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pp-toolbar .tool-btn { display: inline-flex; align-items: center; gap: 6px; }
.pp-zoomlabel { min-width: 46px; text-align: center; font-size: 12px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.pp-sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
.pp-canvas-area {
  position: relative; flex: 1; min-height: 200px; overflow: hidden;
  border-radius: var(--radius); background: var(--surface-3); touch-action: none;
}
.pp-frame { position: absolute; z-index: 0; }
.pp-ghost { display: block; width: 100%; height: 100%; opacity: .32; filter: grayscale(.55); }
.pp-viewport {
  position: absolute; z-index: 1; overflow: hidden; touch-action: none; cursor: grab; border-radius: 3px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .92), 0 0 0 9999px rgba(16, 17, 25, .55);
}
.pp-viewport.dragging { cursor: grabbing; }
.pp-viewport.brushing { cursor: crosshair; }
.pp-shot { display: block; width: 100%; height: 100%; }
.pp-guides { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pp-guides line { stroke-width: 1; vector-effect: non-scaling-stroke; }
.pp-guides .g-eye { stroke: rgba(255, 205, 70, .95); stroke-dasharray: 5 4; }
.pp-guides .g-soft { stroke: rgba(255, 255, 255, .5); stroke-dasharray: 3 4; }
.pp-guides .g-centre { stroke: rgba(125, 114, 255, .85); stroke-dasharray: 5 5; }
.pp-guides .g-face { fill: none; stroke: rgba(79, 211, 160, .95); stroke-width: 1; vector-effect: non-scaling-stroke; }
.pp-brushdot {
  position: absolute; z-index: 3; border-radius: 50%; pointer-events: none;
  transform: translate(-50%, -50%); border: 1.5px solid #fff; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .5);
}
.pp-empty {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; text-align: center; color: var(--muted); padding: 24px;
}
.pp-empty strong { color: var(--ink-soft); font-size: 15px; }
.pp-empty > span:last-child { font-size: 12.5px; max-width: 320px; }
.pp-stage-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pp-tilt { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.pp-tilt label { white-space: nowrap; }
.pp-tilt .pp-range { flex: 1 1 120px; min-width: 90px; max-width: 190px; }
.pp-tilt .range-value { min-width: 40px; }
.pp-foot-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pp-foot-group .switch-row { font-size: 12px; }

/* A4 sheet maker */
.pp-sheetsec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; margin-top: 14px; }
.pp-sheet-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.pp-sheet-head .pp-sec-h { margin-bottom: 0; }
.pp-sheet-body { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
.pp-sheet-canvas-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pp-sheet-paper {
  display: flex; justify-content: center; align-items: flex-start;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
}
.pp-sheet-paper canvas { display: block; border-radius: 2px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.pp-sheet-controls { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pp-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.pp-counts .chip { flex: 1 1 auto; justify-content: center; padding: 6px 10px; font-size: 11.5px; }
.pp-celllist { display: grid; gap: 5px; max-height: 240px; overflow-y: auto; }
.pp-cell {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface-2); font-size: 11.5px;
}
.pp-cell-over { border-color: var(--primary); background: var(--primary-soft); }
.pp-cell-n {
  width: 18px; height: 18px; flex-shrink: 0; border-radius: 50%; background: var(--surface-3);
  display: grid; place-items: center; font-size: 10px; font-weight: 800; color: var(--muted);
}
.pp-cell-name { flex: 1; min-width: 0; font-weight: 700; color: var(--ink-soft); }
.pp-cell-mm { color: var(--muted-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-cell-btn {
  width: 22px; height: 22px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--muted); display: grid; place-items: center; cursor: pointer;
}
.pp-cell-btn:hover { color: var(--primary); border-color: var(--primary); }
.pp-cell-btn svg { width: 12px; height: 12px; }

/* Status strip — sized icons, or the SVG inflates the bar (see Phase A). */
.pp-status {
  display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 8px 12px;
  border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); flex-shrink: 0;
}
.pp-status > span:first-child { font-weight: 700; color: var(--ink-soft); }
.pp-status-note { display: inline-flex; align-items: center; gap: 6px; }
.pp-status-note svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--green); }

@media (max-width: 1280px) {
  .pp-body { grid-template-columns: 262px minmax(0, 1fr) 292px; }
}
@media (max-width: 1100px) {
  .pp-body { grid-template-columns: minmax(0, 1fr); }
  /* One column collapses the three panels into a stack. The crop workspace must
     come FIRST — otherwise the whole control rail (upload, size, source file)
     pushes the photo ~1400px down and the user cannot see what they are cropping. */
  .pp-stage { order: -1; height: 62vh; min-height: 420px; max-height: 720px; }
  .pp-sheet-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .pp-shell { padding: 12px 14px 0; }
  .pp-heading h1, .pp-heading h2 { font-size: 20px; }
  .pp-body { gap: 10px; }
  .pp-stage { height: 56vh; min-height: 380px; }
  .pp-four { grid-template-columns: 1fr 1fr; }
  .pp-status { flex-wrap: wrap; row-gap: 4px; }
  .pp-status-note { font-size: 11px; }
}

/* ---------- Utility ---------- */

.center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .why-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { gap: 28px; }
  .editor-body { grid-template-columns: auto minmax(0, 1fr) auto; }
  .editor-rail { width: 88px; }
  .editor-side { width: 190px; }
}

@media (max-width: 880px) {
  .main-nav {
    position: fixed; top: var(--header-h); left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    flex-direction: column; align-items: stretch; padding: 12px 18px 18px;
    gap: 2px; box-shadow: var(--shadow); display: none;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px; }
  .main-nav .nav-cta { margin: 8px 0 0; text-align: center; }
  .menu-btn { display: grid; }
  .header-actions { margin-left: 0; }
  .main-nav { margin-left: 0; }
  .header-inner { gap: 12px; }
  .brand { margin-right: auto; }

  .hero { grid-template-columns: 1fr; padding-top: 48px; text-align: left; }
  .hero-art { order: -1; transform: scale(.86); margin: -20px 0 -30px; }
  .doc-stack { height: 350px; }
  .lede { font-size: 16px; }
  .free-strip-inner span { min-width: 100%; }
  .steps { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
  .footer-brand { grid-column: 1 / -1; }
  .cta-card { padding: 32px 26px; }

  /* Phone workspace. The shell keeps the viewport-height layout it has on desktop
     and the stage becomes the only scrolling region, so the tool row and the zoom
     row stay under the thumb instead of the whole page drifting away. */
  .editor-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
  .editor-stage { height: auto; min-height: 0; padding: 10px; }
  .editor-toolbar { position: static; }
  .scan-layout { grid-template-columns: 1fr; }
  .editor-shell { min-height: 0; }
  .editor-empty { padding: 40px 18px; }
  /* Neither panel stacks under the page any more — that cost the document half a
     screen on a phone. Both open as drawers from the status row instead. */
  .editor-rail, .editor-side { display: none; }
  .editor-side.has-item, .editor-side.is-open { display: block; }
  .editor-rail.is-open {
    display: grid; grid-auto-flow: column; grid-auto-columns: 84px; gap: 8px;
    align-content: start; overflow: auto; border-right: 0;
  }
  .editor-rail .rail-title { display: none; }
  .editor-rail .editor-thumb { margin-bottom: 0; }
  .editor-drawer-toggle { display: inline-flex; }
}

@media (max-width: 620px) {
  .wrap { padding: 0 18px; }
  .header-inner { padding: 0 18px; }
  .brand-sub { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-name { font-size: 18px; }
  .hero h1 { font-size: 38px; }
  .hero-art { transform: scale(.78); margin: -40px 0 -50px; }
  .main-nav { top: var(--header-h); }
  .filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }
  .tool-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tool-card { padding: 16px 14px; min-height: 152px; }
  .tool-card h3 { font-size: 14.5px; }
  .tool-card p { font-size: 12px; }
  .tool-ico { width: 38px; height: 38px; border-radius: 11px; }
  .tool-ico svg { width: 19px; height: 19px; }
  .tag-free { top: 12px; right: 12px; }
  .tag-limited { top: 12px; right: 12px; }
  .status-links { grid-template-columns: 1fr; }
  .limits-section { padding-top: 32px; }
  .why-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px; border-radius: var(--radius-lg); }
  .tool-head { gap: 12px; padding-top: 16px; }
  .tool-head .pill { display: none; }
  .tool-head .tool-ico { width: 46px; height: 46px; border-radius: 13px; }
  .tool-head h1, .tool-head h2 { font-size: 28px; }
  .drop { padding: 32px 18px; }
  .thumb-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .cta-actions { width: 100%; }
  .cta-actions .btn { flex: 1; }
  .site-footer .footer-bottom { flex-direction: column; align-items: flex-start; }
  .editor-top { padding: 6px 10px; gap: 8px; flex-wrap: nowrap; }
  /* "PDF Editor" is already the page title and the h1 above; on a phone it costs
     a whole wrapped row of the top bar, which is height the document needs. */
  .editor-top .editor-title { display: none; }
  .editor-file-name { display: none; }
  /* Icons only, but the words stay in the accessibility tree. display:none here
     used to strip the accessible name from every icon-only button on a phone. */
  .tool-btn > span {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .tool-btn { padding: 8px; position: relative; }
  .toolbar-label { display: none; }
  .editor-status { flex-wrap: nowrap; font-size: 11px; padding: 3px 10px; }
  .editor-status .status-local > span { display: none; }
}

/* Touch targets. A pointer:coarse device gets 44px squares for every editor
   control, which is the WCAG 2.2 minimum and cannot be reached by widening the
   padding on a 12px label alone. */
@media (pointer: coarse) {
  .editor-toolbar .tool-btn, .editor-status .tool-btn, .pp-toolbar .tool-btn {
    min-height: 44px; min-width: 44px; align-items: center; justify-content: center;
  }
  .editor-status { padding: 6px 12px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .editor-toolbar { padding: 6px 12px; }
  .file-actions button { min-width: 38px; min-height: 38px; }
  .toolbar-group .input, .toolbar-group input[type="color"] { min-height: 40px; }
  .chip { min-height: 44px; }
  .main-nav a { min-height: 44px; display: inline-flex; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}


/* ---------- SEO landing blocks ---------- */

.breadcrumbs { margin: 22px auto 0; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs li + li::before { content: "/"; margin-right: 8px; opacity: .5; }

.seo-points { display: grid; gap: 9px; margin: 20px 0 0; padding: 0; list-style: none; max-width: 620px; }
.seo-points li { position: relative; padding-left: 26px; font-size: 14.5px; color: var(--muted); }
.seo-points li::before { content: ""; position: absolute; left: 0; top: 2px; width: 17px; height: 17px; border-radius: 50%; background: var(--primary-soft); }

.seo-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.seo-links li { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: var(--card, #fff); }
.seo-links a { display: block; font-weight: 700; font-size: 15px; color: var(--ink); text-decoration: none; }
.seo-links a:hover { color: var(--primary); }
.seo-links span { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); }

.seo-nav-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 26px; padding-bottom: 48px; }
.seo-nav-col h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 12px; }
.seo-nav-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.seo-nav-col a { font-weight: 700; font-size: 15px; color: var(--ink); text-decoration: none; }
.seo-nav-col a:hover { color: var(--primary); }
.seo-nav-col span { display: block; font-size: 12.5px; color: var(--muted); }


/* ---------- Legal pages and analytics consent ---------- */

.page-updated { font-size: 13px; color: var(--muted); margin-top: 14px; }
.footer-legal { display: flex; flex-wrap: wrap; gap: 8px 22px; padding-top: 22px; }
.footer-legal a { font-size: 13.5px; font-weight: 600; color: var(--muted); text-decoration: none; }
.footer-legal a:hover { color: var(--primary); }
.prose-section { padding-top: 40px; max-width: 780px; }
.prose-section h2 { font-size: 22px; margin-bottom: 12px; }
.prose-section p { font-size: 15.5px; line-height: 1.72; color: var(--muted); margin: 0 0 14px; }
.prose-section p strong { color: var(--ink); }
.prose-section code { font-size: 13.5px; padding: 2px 6px; border-radius: 6px; background: var(--primary-soft); color: var(--ink); }
.prose-section a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

.consent-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; padding: 14px 0 16px;
  background: var(--card, #fff); border-top: 1px solid var(--line); box-shadow: 0 -12px 32px rgba(16, 17, 25, .1); }
.consent-inner { display: grid; gap: 12px; }
.consent-inner p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--muted); max-width: 760px; }
.consent-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.consent-link { font-size: 14px; font-weight: 700; color: var(--primary); text-decoration: none; }
.consent-link:hover { text-decoration: underline; }
.consent-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.consent-buttons .btn { min-height: 44px; }
.consent-buttons .btn-ghost { border-color: var(--line); }
@media (max-width: 640px) {
  .consent-actions { flex-direction: column; align-items: stretch; }
  .consent-buttons .btn { flex: 1 1 0; justify-content: center; }
}

/* ============================================================
   Newer tool panels: crop, resize, header/footer, stamps,
   whiteout boxes, form fields, viewer
   ============================================================ */

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.opt.opt-switch { justify-content: flex-end; }
.opt.is-disabled { opacity: .45; }
.opt input:disabled, .opt select:disabled, .opt textarea:disabled {
  background: var(--surface-3); cursor: not-allowed;
}

.hint-box code, .report-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; background: rgba(255, 255, 255, .7);
  padding: 1px 5px; border-radius: 6px;
}
.hint-box a, .report-note a { color: inherit; font-weight: 700; }

.image-pick {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-top: 20px; padding: 14px 16px;
  border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2);
}
.image-pick .hint { flex: 1 1 220px; font-size: 12px; color: var(--muted); }
.image-pick .btn.is-set { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.hf-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px; margin-top: 22px;
}
.hf-col {
  display: grid; gap: 7px; align-content: start;
  padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
}
.hf-col .opt { gap: 5px; }
.hf-col > .opt-label { margin-bottom: 4px; }

.box-bar, .viewer-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 18px;
}
.box-bar .spacer, .viewer-bar .spacer { flex: 1; }
.box-bar .btn svg, .viewer-bar .btn svg { width: 15px; height: 15px; }
.box-page {
  font-size: 13px; font-weight: 800; color: var(--ink-soft);
  min-width: 104px; text-align: center;
}
.viewer-page { width: 66px; text-align: center; padding: 8px; }

.box-stage, .viewer-stage {
  position: relative; margin-top: 14px; padding: 16px;
  background: var(--surface-3); border-radius: 14px; overflow: auto;
}
.box-stage { cursor: crosshair; }
.box-stage canvas, .viewer-stage canvas {
  display: block; margin: 0 auto; max-width: 100%; background: #fff;
  border-radius: 3px; box-shadow: 0 14px 40px rgba(20, 22, 40, .18);
}
.box-layer { position: absolute; touch-action: none; }
.drawn-box {
  position: absolute; border: 1.5px dashed var(--primary);
  background: rgba(255, 255, 255, .78); border-radius: 2px;
}
.drawn-box.is-drawing { border-style: solid; }

.form-fields {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin-top: 22px; padding: 18px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2);
  max-height: 480px; overflow: auto;
}
.form-fields textarea.input { resize: vertical; font-family: inherit; line-height: 1.5; }
.form-fields select[multiple] { padding: 6px; }
.form-fields .hint { text-transform: none; letter-spacing: 0; font-weight: 600; }

.report-note {
  margin-top: 12px; padding: 12px 14px; border-radius: 11px;
  background: var(--amber-soft); color: color-mix(in srgb, var(--amber) 62%, var(--ink));
  font-size: 12.5px; line-height: 1.55;
}

@media (max-width: 640px) {
  .box-bar .btn, .viewer-bar .btn { min-height: 44px; flex: 1 1 auto; justify-content: center; }
  .box-page { min-width: 0; flex: 1 1 100%; order: -1; }
  .form-fields { max-height: none; }
}
