/* ==========================================================================
   Design system — light by default, dark when the device asks for it
   System fonts only: zero font downloads, no third-party requests.
   Built for low-end Android: no animated blur layers, blur only on nav/modal.
   Every colour lives in a token below; rules further down never hard-code one.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #f6f7fb;
  --bg-raised: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-sunken: #eef1f7;
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.20);
  --nav-bg: rgba(246, 247, 251, 0.88);
  --footer-bg: #eef1f7;
  --overlay-bg: rgba(15, 23, 42, 0.45);
  --glow-1: rgba(15, 118, 110, 0.10);
  --glow-2: rgba(13, 148, 136, 0.08);

  /* Translucent fills (hover, chips, panels) */
  --hover-bg: rgba(15, 23, 42, 0.05);
  --hover-bg-strong: rgba(15, 23, 42, 0.08);
  --chip-bg: rgba(15, 23, 42, 0.06);
  --code-bg: rgba(15, 23, 42, 0.07);
  --panel-bg: rgba(15, 23, 42, 0.03);
  --callout-bg: rgba(15, 23, 42, 0.04);
  --dropzone-bg: rgba(15, 23, 42, 0.02);
  --range-track: rgba(15, 23, 42, 0.16);

  /* Brand */
  --primary: #0f766e;
  --primary-2: #115e59;
  --primary-light: #115e59;
  --primary-glow: rgba(15, 118, 110, 0.25);
  --primary-glow-hover: rgba(15, 118, 110, 0.38);
  --accent-bg: rgba(15, 118, 110, 0.10);
  --accent-bg-2: rgba(15, 118, 110, 0.14);
  --accent-bg-3: rgba(15, 118, 110, 0.14);
  --accent-bg-soft: rgba(15, 118, 110, 0.10);
  --accent-hover: rgba(15, 118, 110, 0.10);
  --dragover-bg: rgba(15, 118, 110, 0.06);
  --accent-border: rgba(15, 118, 110, 0.30);
  --accent-border-strong: rgba(15, 118, 110, 0.48);
  --focus-glow: rgba(15, 118, 110, 0.25);

  /* Status */
  --success: #059669;
  --success-light: #047857;
  --success-bg: rgba(16, 185, 129, 0.12);
  /* Status messages sit inside the sunken preview pane, where --success-light drops under 4.5:1 */
  --status-ok-text: #065f46;
  --success-border: rgba(4, 120, 87, 0.30);
  --pill-border: rgba(4, 120, 87, 0.28);
  --status-ok-border: rgba(4, 120, 87, 0.25);
  --success-glow: rgba(16, 185, 129, 0.28);
  --success-glow-hover: rgba(16, 185, 129, 0.42);
  --on-success: #04201d;
  --warning: #d97706;
  --warning-bg: rgba(245, 158, 11, 0.14);
  --warn-text: #92400e;
  --warn-border: rgba(146, 64, 14, 0.30);
  --tag-edited-border: rgba(146, 64, 14, 0.35);
  --danger: #e11d48;
  --danger-bg: rgba(244, 63, 94, 0.10);
  --danger-text: #be123c;
  --danger-border: rgba(190, 18, 60, 0.30);
  --info-text: #115e59;
  --info-bg: rgba(15, 118, 110, 0.08);
  --info-border: rgba(15, 118, 110, 0.26);
  --toast-bg: #ecfdf5;
  --toast-border: rgba(4, 120, 87, 0.35);

  /* Text — all pairs ≥ 4.5:1 on --bg and --surface */
  --text: #0f172a;
  --text-2: #334155;
  --text-muted: #475569;
  --text-dim: #5b6b80;

  --grad-primary: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
  --grad-text: linear-gradient(135deg, #0f766e 0%, #0e7490 50%, #155e75 100%);
  --grad-success: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);

  /* Image preview backdrop and the EMI donut */
  --checker-a: #e2e8f0;
  --checker-b: #f8fafc;
  --donut-track: rgba(15, 23, 42, 0.10);
  --donut-principal: #059669;
  --donut-interest: #0284c7;
  --donut-interest-2: #0369a1;
  /* Face guide drawn over the photo itself, so it reads on any picture in either theme */
  --face-guide: rgba(255, 255, 255, 0.92);
  --face-guide-halo: rgba(15, 23, 42, 0.55);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-lg: 0 20px 40px -16px rgba(15, 23, 42, 0.18);
  --shadow-canvas: 0 6px 20px rgba(15, 23, 42, 0.25);
  --shadow-modal: 0 25px 60px -15px rgba(15, 23, 42, 0.35);
  --focus-ring: 0 0 0 3px #ffffff, 0 0 0 5px #0f766e;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur: 200ms;

  --z-nav: 100;
  --z-menu: 200;
  --z-dock: 1000;
  --z-modal: 1000;
  --z-toast: 1100;

  --font-head: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', Consolas, monospace;
}

/* Dark palette = the original look, used when the device asks for it */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070913;
    --bg-raised: #0d1226;
    --surface: #111733;
    --surface-2: #161d3d;
    --surface-sunken: rgba(0, 0, 0, 0.35);
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --nav-bg: rgba(7, 9, 19, 0.88);
    --footer-bg: #05070f;
    --overlay-bg: rgba(4, 6, 14, 0.78);
    --glow-1: rgba(20, 184, 166, 0.16);
    --glow-2: rgba(15, 118, 110, 0.18);

    --hover-bg: rgba(255, 255, 255, 0.05);
    --hover-bg-strong: rgba(255, 255, 255, 0.08);
    --chip-bg: rgba(255, 255, 255, 0.06);
    --code-bg: rgba(255, 255, 255, 0.08);
    --panel-bg: rgba(255, 255, 255, 0.025);
    --callout-bg: rgba(255, 255, 255, 0.03);
    --dropzone-bg: rgba(255, 255, 255, 0.02);
    --range-track: rgba(255, 255, 255, 0.14);

    --primary-light: #5eead4;
    --primary-glow: rgba(45, 212, 191, 0.30);
    --primary-glow-hover: rgba(45, 212, 191, 0.45);
    --accent-bg: rgba(45, 212, 191, 0.14);
    --accent-bg-2: rgba(45, 212, 191, 0.18);
    --accent-bg-3: rgba(45, 212, 191, 0.20);
    --accent-bg-soft: rgba(45, 212, 191, 0.12);
    --accent-hover: rgba(45, 212, 191, 0.16);
    --dragover-bg: rgba(45, 212, 191, 0.07);
    --accent-border: rgba(94, 234, 212, 0.30);
    --accent-border-strong: rgba(94, 234, 212, 0.45);
    --focus-glow: rgba(94, 234, 212, 0.25);

    --success: #10b981;
    --success-light: #6ee7b7;
    --success-bg: rgba(16, 185, 129, 0.12);
    --status-ok-text: #6ee7b7;
    --success-border: rgba(110, 231, 183, 0.3);
    --pill-border: rgba(110, 231, 183, 0.28);
    --status-ok-border: rgba(110, 231, 183, 0.25);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.12);
    --warn-text: #fde68a;
    --warn-border: rgba(251, 191, 36, 0.3);
    --tag-edited-border: rgba(251, 191, 36, 0.35);
    --danger: #fb7185;
    --danger-bg: rgba(244, 63, 94, 0.12);
    --danger-text: #fecdd3;
    --danger-border: rgba(251, 113, 133, 0.35);
    --info-text: #99f6e4;
    --info-bg: rgba(45, 212, 191, 0.10);
    --info-border: rgba(94, 234, 212, 0.25);
    --toast-bg: #0f2a24;
    --toast-border: rgba(110, 231, 183, 0.4);

    --text: #f8fafc;
    --text-2: #d5dde8;
    --text-muted: #a3b1c6;
    --text-dim: #8b9ab0;

    --grad-text: linear-gradient(135deg, #5eead4 0%, #2dd4bf 50%, #67e8f9 100%);

    --checker-a: #1e293b;
    --checker-b: #0f172a;
    --donut-track: rgba(255, 255, 255, 0.08);
    --donut-principal: #10b981;
    --donut-interest: #38bdf8;
    --donut-interest-2: #0ea5e9;

    --shadow-lg: 0 20px 40px -16px rgba(0, 0, 0, 0.6);
    --shadow-canvas: 0 6px 20px rgba(0, 0, 0, 0.5);
    --shadow-modal: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
    --focus-ring: 0 0 0 3px #070913, 0 0 0 5px #5eead4;
  }
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  color-scheme: light dark;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  /* Cheap static glow instead of animated blurred orbs */
  background-image:
    radial-gradient(600px 400px at 10% -5%, var(--glow-1), transparent 70%),
    radial-gradient(700px 500px at 100% 20%, var(--glow-2), transparent 70%);
  background-repeat: no-repeat;
}

img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
/* Component display rules (.btn, .share-nudge) must not defeat the hidden attribute */
[hidden] { display: none !important; }
button { cursor: pointer; }
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 2000;
  background: var(--text); color: var(--bg); padding: 0.6rem 1rem; border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-head);
  color: var(--text);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
h1 { font-size: clamp(1.9rem, 5vw, 3.1rem); }
h2 { font-size: clamp(1.45rem, 3vw, 2rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
p { color: var(--text-2); }
code {
  font-family: var(--font-mono); font-size: 0.88em;
  background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px;
}

.text-gradient {
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

.icon { width: 1.25em; height: 1.25em; flex-shrink: 0; }

/* --- Layout --- */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 1rem; }
@media (min-width: 640px) { .container { padding: 0 1.5rem; } }
.narrow { max-width: 820px; }
main { display: block; padding-bottom: 2rem; }

/* --- Navigation --- */
.site-nav {
  position: sticky; top: 0; z-index: var(--z-nav);
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 64px; }

/* Slim offline notice inside the sticky header, so it stays in view and never covers a control */
.net-notice {
  padding: 0.4rem 1rem; text-align: center; font-size: 0.85rem; font-weight: 600;
  background: var(--warning-bg); color: var(--warn-text); border-bottom: 1px solid var(--warn-border);
}
.calc-offline { margin: 0 0 1rem; align-items: center; flex-wrap: wrap; }

.brand-logo {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-head); font-size: 1.3rem; font-weight: 800; color: var(--text);
}
.brand-logo:hover { text-decoration: none; }
.logo-mark { display: block; width: 32px; height: 32px; flex-shrink: 0; }

.nav-links { display: none; list-style: none; gap: 0.25rem; }
.nav-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.8rem;
  font-size: 0.93rem; font-weight: 500; color: var(--text-muted); border-radius: var(--radius-sm);
}
.nav-link:hover { color: var(--text); background: var(--hover-bg); text-decoration: none; }
.nav-link[aria-current="page"] { color: var(--text); background: var(--accent-bg); }

.nav-actions { display: flex; align-items: center; gap: 0.5rem; }
/* Phones: icon-only install button (the label stays for screen readers) */
@media (max-width: 639px) {
  .btn.install-btn { min-width: 44px; min-height: 44px; padding: 0; }
  .install-label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
}
/* 320px phones: logo + install + search + menu must fit on one row */
@media (max-width: 379px) {
  .nav-container { gap: 0.5rem; }
  .nav-actions { gap: 0.3rem; }
  .brand-logo { gap: 0.45rem; font-size: 1.12rem; }
}

.search-trigger-btn {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; min-width: 44px;
  padding: 0 0.75rem; background: var(--hover-bg); border: 1px solid var(--border);
  border-radius: var(--radius-full); color: var(--text-muted); font-size: 0.88rem;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.search-trigger-btn:hover { color: var(--text); border-color: var(--border-strong); }
.search-trigger-btn .search-label, .search-trigger-btn .key-badge { display: none; }

.menu-toggle {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
}

.key-badge {
  font-family: var(--font-mono); font-size: 0.72rem; padding: 0.1rem 0.4rem;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; color: var(--text-2);
}

.mobile-menu {
  display: none; position: fixed; inset: var(--nav-h, 64px) 0 0 0; z-index: var(--z-menu);
  background: var(--bg); overflow-y: auto; padding: 1rem 1rem 3rem;
  border-top: 1px solid var(--border);
}
.mobile-menu.open { display: block; transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
@starting-style { .mobile-menu.open { opacity: 0; transform: translateY(-8px); } }
.mobile-menu h2 {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); margin: 1.25rem 0 0.5rem; font-family: var(--font-body);
}
.mobile-menu ul { list-style: none; }
.mobile-menu a {
  display: flex; align-items: center; min-height: 48px; padding: 0 0.75rem;
  color: var(--text); border-radius: var(--radius-sm); font-weight: 500;
}
.mobile-menu a:hover, .mobile-menu a[aria-current="page"] { background: var(--surface); text-decoration: none; }
body.menu-open { overflow: hidden; }

@media (min-width: 960px) {
  .nav-links { display: flex; }
  .menu-toggle, .mobile-menu, .mobile-menu.open { display: none; }
  .search-trigger-btn .search-label, .search-trigger-btn .key-badge { display: inline; }
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px; padding: 0.6rem 1.25rem;
  font-size: 0.95rem; font-weight: 600; line-height: 1.2;
  border-radius: var(--radius-md); border: 1px solid transparent;
  text-align: center; user-select: none; touch-action: manipulation;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur) var(--ease-out),
              background-color var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast);
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--grad-primary); color: #fff; box-shadow: 0 4px 18px var(--primary-glow); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 26px var(--primary-glow-hover); }

.btn-success { background: var(--grad-success); color: var(--on-success); font-weight: 700; box-shadow: 0 4px 18px var(--success-glow); }
.btn-success:hover:not(:disabled) { box-shadow: 0 6px 26px var(--success-glow-hover); }

.btn-ghost { background: var(--hover-bg); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--border-strong); background: var(--hover-bg-strong); }

.btn-sm { min-height: 44px; padding: 0.4rem 0.9rem; font-size: 0.88rem; border-radius: var(--radius-sm); }
.btn-lg { min-height: 52px; padding: 0.8rem 1.6rem; font-size: 1.02rem; }
.btn-block { width: 100%; }

/* --- Badges & pills --- */
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.2rem 0.55rem; border-radius: var(--radius-full);
  background: var(--accent-bg); border: 1px solid var(--accent-border); color: var(--primary-light);
}
.badge-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-light); }

.pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.9rem; border-radius: var(--radius-full);
  background: var(--success-bg); border: 1px solid var(--pill-border);
  color: var(--success-light); font-size: 0.85rem; font-weight: 600;
}

/* --- Breadcrumb --- */
.breadcrumb { padding-top: 1.25rem; font-size: 0.85rem; color: var(--text-dim); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.breadcrumb li + li::before { content: '/'; margin-right: 0.4rem; color: var(--text-dim); }
.breadcrumb a { color: var(--text-muted); padding: 0.85rem 0; } /* inline padding: a 44 px tap area, same line height */

/* --- Hero --- */
.hero { padding-block: 3rem 2rem; text-align: center; }
.hero h1 { max-width: 880px; margin: 1rem auto 1rem; }
.hero .lead { max-width: 660px; margin: 0 auto 1.75rem; font-size: 1.08rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.trust-bar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem 1.75rem;
  margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  list-style: none;
}
.trust-bar li { display: flex; align-items: center; gap: 0.45rem; font-size: 0.88rem; color: var(--text-muted); }
.trust-bar .icon { color: var(--success); }

.page-head { padding-block: 1rem 1.5rem; }
.page-head h1 { margin: 0.5rem 0 0.75rem; }
.page-head .lead { font-size: 1.05rem; max-width: 720px; }
.share-row { display:flex; flex-wrap:wrap; align-items:center; gap:0.5rem 0.75rem; margin:-1rem 0 2rem; color:var(--text-muted); font-size:0.9rem; }

@media (min-width: 768px) { .hero { padding-block: 4.5rem 2.5rem; } }

/* --- Cards --- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
}
@media (min-width: 640px) { .card { padding: 1.75rem; } }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.tool-card {
  display: flex; flex-direction: column; gap: 0.5rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; color: var(--text);
  transition: border-color var(--dur), transform var(--dur) var(--ease-out), background-color var(--dur);
}
.tool-card:hover { text-decoration: none; border-color: var(--accent-border-strong); background: var(--surface-2); }
@media (hover: hover) and (pointer: fine) {
  .tool-card:hover { transform: translateY(-2px); }
}
.tool-card h3 { font-size: 1.05rem; }
.tool-card p { font-size: 0.88rem; color: var(--text-muted); }
.tool-card .tool-icon {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-bg); color: var(--primary-light);
}
.tool-card .spec { margin-top: auto; font-size: 0.78rem; color: var(--success-light); font-weight: 600; }

.section { margin: 3rem 0; }
.section-head { margin-bottom: 1.25rem; }
.section-head p { color: var(--text-muted); margin-top: 0.35rem; }

/* Hub home (two or more sections): one large tile per section, then a short block per section */
.section-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; margin-top: 0.5rem; }
.section-tile { padding: 1.5rem; }
.section-tile .tool-icon { width: 48px; height: 48px; border-radius: 12px; }
.section-tile-name { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; }
.section-tile p { font-size: 0.95rem; }
.section-more { margin-top: 1.25rem; }

/* --- Tool workspace --- */
.tool-workspace {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem; box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
}
@media (min-width: 640px) { .tool-workspace { padding: 1.75rem; } }

.tool-header-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.tool-header-row h2 { font-size: 1.3rem; display: flex; align-items: center; gap: 0.5rem; }
.tool-header-row p { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.2rem; }

.tool-split { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 900px) { .tool-split { grid-template-columns: 1fr 1fr; gap: 2rem; } }

/* Photo & image tools: input → result → settings on phones; result column beside them on desktop */
.tool-split.ws-grid { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "input" "output" "controls"; gap: 1.25rem; }
.ws-input { grid-area: input; min-width: 0; }
.ws-output { grid-area: output; min-width: 0; }
.ws-controls { grid-area: controls; min-width: 0; }
@media (min-width: 900px) {
  .tool-split.ws-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "input output" "controls output"; align-items: start; gap: 1.25rem 2rem; }
  .ws-output { position: sticky; top: 80px; }
}
@media (max-width: 899px) {
  /* Nothing to show until a file is added; once it is, "Change photo" in the result replaces the dropzone */
  [data-state="empty"] .ws-output { display: none; }
  [data-state="ready"] .ws-input .dropzone, [data-state="ready"] .ws-input .step-title { display: none; }
}

.step {
  display: inline-grid; place-items: center; flex-shrink: 0; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--accent-bg-2); color: var(--primary-light); font-size: 0.85rem; font-weight: 700; line-height: 1;
}
.step-title { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.6rem; font-size: 0.95rem; font-weight: 600; color: var(--text); }
.control-label.step-label { justify-content: flex-start; gap: 0.55rem; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-strong); background: var(--dropzone-bg);
  border-radius: var(--radius-md); padding: 1.75rem 1rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 200px; transition: border-color var(--dur), background-color var(--dur);
}
.dropzone.dragover { border-color: var(--primary-light); background: var(--dragover-bg); }
.dropzone-icon {
  width: 56px; height: 56px; border-radius: var(--radius-md); display: grid; place-items: center;
  background: var(--accent-bg-soft); color: var(--primary-light); margin-bottom: 0.25rem;
}
.dropzone-title { font-size: 1.05rem; font-weight: 600; }
.dropzone-hint { font-size: 0.85rem; color: var(--text-dim); }
.ws-input .dropzone { cursor: pointer; }
/* "drag it here" means nothing on a touch screen */
.hint-pointer { display: none; }
@media (hover: hover) { .hint-pointer { display: inline; } .hint-touch { display: none; } }
/* Phones can't press Ctrl+V, so the paste hint is for a mouse and keyboard only */
.paste-hint { display: none; }
@media (hover: hover) and (pointer: fine) { .paste-hint { display: inline; } .paste-hint::before { content: ' · '; } }
.privacy-note {
  display: inline-flex; align-items: center; gap: 0.4rem; margin-top: 0.4rem;
  font-size: 0.8rem; color: var(--success-light); background: var(--success-bg);
  padding: 0.25rem 0.7rem; border-radius: var(--radius-full);
}
/* Joiner (11c): two small pickers side by side, each showing its picture once chosen */
.join-picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.dropzone-compact { min-height: 170px; padding: 1rem 0.6rem; }
.join-thumb { max-width: 100%; max-height: 110px; object-fit: contain; border-radius: var(--radius-sm); background: #fff; }
.dropzone.compact { min-height: 0; padding: 1rem; flex-direction: row; flex-wrap: wrap; justify-content: space-between; text-align: left; }

/* Form controls */
.control-group { margin-bottom: 1.15rem; }
.control-label {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  font-size: 0.9rem; font-weight: 600; color: var(--text-2); margin-bottom: 0.45rem;
}
.control-hint { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.35rem; font-weight: 400; }
.control-hint-warn { color: var(--warn-text); font-weight: 600; }
.control-input, .control-select {
  width: 100%; min-height: 44px; padding: 0.6rem 0.85rem;
  background: var(--surface-sunken); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text); font-size: 1rem; transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.control-input:focus, .control-select:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px var(--focus-glow); }
.control-input[aria-invalid="true"] { border-color: var(--danger); }
.control-select option, .control-select optgroup { background: var(--surface); color: var(--text); }
/* PDF size limit: one wrapping row above the Create PDF button */
.pdf-limit { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.pdf-limit .control-label { margin-bottom: 0; }
.pdf-limit .control-select { width: auto; min-width: 140px; }
.pdf-limit .control-input { width: 170px; }
.pdf-limit .field-error { flex: 1 1 100%; margin-top: 0; }
.input-inline { display: inline-flex; align-items: center; gap: 0.35rem; }
.input-inline .control-input { width: 110px; text-align: right; min-height: 44px; padding: 0.35rem 0.6rem; }
.input-inline .unit { font-size: 0.85rem; color: var(--text-muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
textarea.control-input { min-height: 120px; resize: vertical; }

fieldset { border: 0; }
.fieldset-box { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.85rem 1rem; }
legend { font-size: 0.9rem; font-weight: 600; color: var(--text-2); margin-bottom: 0.45rem; padding: 0; }

.check-row { display: flex; align-items: flex-start; gap: 0.7rem; cursor: pointer; min-height: 44px; padding: 0.35rem 0; }
.check-row input[type="checkbox"], .check-row input[type="radio"] {
  width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; cursor: pointer;
}
.check-row strong { display: block; font-size: 0.93rem; color: var(--text); font-weight: 600; }
.check-row span { font-size: 0.82rem; color: var(--text-dim); }

.segmented { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.95rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-full);
  font-size: 0.9rem; font-weight: 600; color: var(--text-muted); background: var(--surface-sunken);
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.segmented input:checked + span { background: var(--accent-bg-3); border-color: var(--primary-light); color: var(--text); }
.segmented input:focus-visible + span { box-shadow: var(--focus-ring); }

/* Range slider */
.range-slider {
  width: 100%; height: 28px; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer;
}
.range-slider::-webkit-slider-runnable-track { height: 6px; background: var(--range-track); border-radius: var(--radius-full); }
.range-slider::-moz-range-track { height: 6px; background: var(--range-track); border-radius: var(--radius-full); }
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%;
  background: var(--primary-light); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--primary-light);
}
.range-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--primary-light);
  border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--primary-light);
}
.range-slider:focus-visible { box-shadow: none; }
.range-slider:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus-ring); }
.range-slider:focus-visible::-moz-range-thumb { box-shadow: var(--focus-ring); }

/* Preview */
.preview-pane {
  background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 1.25rem; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.preview-empty { text-align: center; color: var(--text-dim); max-width: 320px; }
.preview-empty .icon { width: 44px; height: 44px; margin: 0 auto 0.75rem; opacity: 0.6; }
.preview-result { width: 100%; text-align: center; transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
@starting-style { .preview-result { opacity: 0; transform: translateY(6px); } }
.preview-canvas-wrapper {
  display: inline-flex; align-items: center; justify-content: center; max-width: 100%;
  padding: 10px; border-radius: var(--radius-sm); margin-bottom: 1rem;
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 16px 16px;
}
.preview-canvas-wrapper canvas, .preview-canvas-wrapper img {
  max-width: 100%; max-height: 300px; width: auto; height: auto; box-shadow: var(--shadow-canvas);
}
/* The frame is exactly the canvas box, so the face guide can be placed in percentages of it */
.canvas-frame { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.canvas-frame canvas { display: block; }
.canvas-frame canvas.is-pannable { touch-action: none; cursor: grab; }
.canvas-frame canvas.is-dragging { cursor: grabbing; }
.canvas-frame canvas:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* Oval: 60% wide, 70% of the picture area tall, centred at 45% of it; --guide-area = area / canvas height */
.face-guide {
  position: absolute; left: 20%; width: 60%;
  top: calc(var(--guide-area, 1) * 10%); height: calc(var(--guide-area, 1) * 70%);
  border: 2px dashed var(--face-guide); border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 1px var(--face-guide-halo), inset 0 0 0 1px var(--face-guide-halo);
}
.crop-box { margin: -0.25rem 0 0.75rem; text-align: left; }
.crop-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.75rem; }
.crop-label { font-size: 0.9rem; font-weight: 600; color: var(--text-2); }
.crop-row .range-slider { flex: 1 1 8rem; width: auto; min-width: 0; }
.crop-val { min-width: 3.2em; font-size: 0.85rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.crop-box .control-hint { margin-top: 0.15rem; }
.guide-row { justify-content: center; margin: -0.35rem 0 0.5rem; }
.guide-row span { font-size: 0.88rem; color: var(--text-2); }
.status-msg .btn { margin-left: auto; flex-shrink: 0; }
#photoSideways { align-items: center; flex-wrap: wrap; }
.btn-icon { padding-left: 0; padding-right: 0; width: 52px; flex: 0 0 auto; }
/* IBPS declaration wording, shown in the empty preview so nobody has to search for it */
.decl-text { margin-top: 1rem; text-align: left; }
.decl-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.decl-quote {
  margin: 0.5rem 0; padding: 0.6rem 0.8rem; font-size: 0.9rem; line-height: 1.5; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary-light); border-radius: var(--radius-sm);
}
.decl-note { font-size: 0.82rem; color: var(--text-muted); }
/* Original-file panel */
.facts-box {
  margin-top: 1rem; background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 1rem; text-align: left;
}
.facts-title { font-size: 0.95rem; margin-bottom: 0.6rem; }
.facts-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.facts-table th, .facts-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; }
.facts-table th[scope="row"] { color: var(--text-muted); font-weight: 500; }
.fact-ok { color: var(--success-light); }
.fact-bad { color: var(--danger-text); }
.facts-list { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; font-size: 0.85rem; margin-top: 0.75rem; }
.facts-list > div { display: contents; }
.facts-list dt { color: var(--text-muted); }
.facts-list dd { color: var(--text); margin: 0; }
.facts-notes { list-style: none; margin-top: 0.75rem; padding: 0; }
.facts-notes li { font-size: 0.85rem; border-left: 3px solid var(--warning); padding-left: 0.85rem; margin-top: 0.5rem; }
.facts-notes:empty { display: none; }
.facts-fixnote { margin-top: 0.5rem; font-size: 0.82rem; color: var(--text-muted); }

/* "Also needed for IBPS:" quick switch after a download */
.next-docs { margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--border); }
.next-docs-title { margin-bottom: 0.5rem; font-size: 0.9rem; font-weight: 600; color: var(--text-2); }
.next-docs-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }

/* Phones: Download stays reachable while the main button is scrolled away */
.dl-dock {
  position: fixed; left: 0.75rem; right: 0.75rem; bottom: 0.75rem; z-index: var(--z-dock); /* above anchor ads */
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 0.6rem 0.75rem; box-shadow: var(--shadow-lg);
}
.dl-dock span { min-width: 0; font-size: 0.88rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.dl-dock .btn { flex-shrink: 0; }
@media (min-width: 900px) { .dl-dock { display: none !important; } }
@media (max-width: 899px) { body.has-dock { padding-bottom: 88px; } }
body.menu-open .dl-dock { display: none; } /* the dock now sits above the menu's layer */
.ws-input .status-msg { margin: 0.75rem 0 0; }

.stat-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-bottom: 0.85rem; }
.stat-chip {
  font-size: 0.85rem; color: var(--text-muted); background: var(--chip-bg);
  padding: 0.3rem 0.75rem; border-radius: var(--radius-full); border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.stat-chip strong { color: var(--text); }

/* "Check the actual file" (24c): the encoded file itself at 2x, scrollable, in the search modal's shell */
.check-btn { margin-bottom: 0.85rem; }
.modal-overlay.check-overlay { align-items: center; padding: 1rem; } /* two classes: outweighs the later .modal-overlay rules */
.modal-window.check-window {
  display: flex; flex-direction: column; max-width: 760px; padding: 0.85rem;
  max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem);
}
.check-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.check-title { margin: 0; font-size: 1.05rem; }
.check-note { margin: 0.5rem 0 0.75rem; font-size: 0.88rem; color: var(--text-muted); }
.check-scroll {
  flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 8px;
  border-radius: var(--radius-sm); background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 16px 16px;
}
.check-scroll img { max-width: none; margin: 0 auto; }

.status-msg {
  display: flex; align-items: flex-start; gap: 0.5rem; text-align: left;
  padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); font-size: 0.88rem; margin-bottom: 0.85rem;
  border: 1px solid transparent;
}
.status-msg:empty { display: none; }
.status-msg .icon { margin-top: 2px; }
.status-ok { background: var(--success-bg); color: var(--status-ok-text); border-color: var(--status-ok-border); }
.status-warn { background: var(--warning-bg); color: var(--warn-text); border-color: var(--warn-border); }
.status-error { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.status-info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); }

.meta-line { margin-top: 0.75rem; font-size: 0.8rem; color: var(--text-dim); }
.ext-group { margin: 0 0 0.6rem; padding: 0; min-width: 0; }
.result-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.result-actions .btn-success { flex: 1 1 220px; }
/* Phones: the two actions that matter are big, full-width targets */
@media (max-width: 639px) {
  .ws-input .btn-primary, #photoDownload { width: 100%; flex-basis: 100%; min-height: 56px; font-size: 1.05rem; }
}

.spec-callout {
  display: flex; gap: 0.6rem; align-items: flex-start; margin-top: 0.25rem; margin-bottom: 1.15rem;
  font-size: 0.85rem; color: var(--text-muted); background: var(--callout-bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.65rem 0.8rem;
}
.spec-callout .icon { color: var(--primary-light); margin-top: 2px; }
/* Before an exam is picked (26b): no spec, no settings and no picture, only the file's facts and the way to step 1 */
[data-no-exam] .spec-callout, [data-no-exam] .ws-controls, [data-no-exam] .preview-canvas-wrapper,
[data-no-exam] .stat-row, [data-no-exam] .ext-group, [data-no-exam] .guide-row, [data-no-exam] #photoRotL, [data-no-exam] #photoRotR { display: none; }
/* "Other documents: Signature · Thumb · Declaration" under the exam picker */
.other-docs { margin-top: 0.4rem; font-size: 0.85rem; color: var(--text-muted); }
.other-docs a { display: inline-block; padding: 0.3rem 0.1rem; font-weight: 600; }
.spec-report { white-space: nowrap; font-weight: 600; }
/* Narrow phones: the link drops to its own line instead of squeezing the tip into a thin column */
.spec-callout { flex-wrap: wrap; }
.spec-callout > span { flex: 1 1 10rem; min-width: 0; }
.spec-callout > .spec-report { margin-left: calc(1.25em + 0.6rem); }
.share-nudge {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem;
  margin-top: 0.85rem; font-size: 0.88rem; color: var(--text-muted);
}

/* Size rules — collapsible override of the preset numbers */
.rules-box { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius-md); }
.rules-box summary, .more-options > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem 0.6rem;
  min-height: 48px; padding: 0.55rem 0.9rem; font-size: 0.9rem; font-weight: 600; color: var(--text-2);
}
.rules-box summary::-webkit-details-marker, .more-options > summary::-webkit-details-marker { display: none; }
.rules-box summary > .icon, .more-options > summary > .icon { margin-left: auto; color: var(--text-muted); transition: transform var(--dur) var(--ease-out); }
.rules-box[open] summary > .icon, .more-options[open] > summary > .icon { transform: rotate(180deg); }
/* Advanced photo controls, closed by default */
.more-options { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius-md); }
.more-hint { font-weight: 500; font-size: 0.85rem; color: var(--text-muted); }
.more-body { padding: 0.9rem; border-top: 1px solid var(--border); }
.more-body > :last-child { margin-bottom: 0; }
.rules-summary { font-weight: 500; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.rules-body { padding: 0.25rem 0.9rem 0.9rem; border-top: 1px solid var(--border); }
.rules-body .field-row { margin-top: 0.75rem; }
.tag {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.1rem 0.5rem; border-radius: var(--radius-full);
  background: var(--chip-bg); border: 1px solid var(--border); color: var(--text-muted);
}
.tag-edited { background: var(--warning-bg); border-color: var(--tag-edited-border); color: var(--warn-text); }
.field-error { font-size: 0.82rem; color: var(--danger-text); margin-top: 0.4rem; }
.field-error:empty { display: none; }

/* PDF thumbnails */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.75rem; margin-top: 1rem; list-style: none; }
.thumb-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.thumb-card img { width: 100%; height: 100px; object-fit: cover; border-radius: 4px; }
.thumb-card .thumb-label { font-size: 0.75rem; color: var(--text-dim); text-align: center; }
.thumb-actions { display: flex; justify-content: space-between; gap: 2px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text-muted);
}
.icon-btn:hover:not(:disabled) { background: var(--hover-bg-strong); color: var(--text); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.icon-btn .icon { width: 16px; height: 16px; }

/* Calculator results */
.result-panel {
  background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 1.1rem; margin-top: 1.25rem;
}
.result-big { font-family: var(--font-head); font-size: clamp(1.6rem, 4vw, 2rem); font-weight: 800; color: var(--success-light); font-variant-numeric: tabular-nums; }
.result-label { font-size: 0.82rem; color: var(--text-muted); }
.result-rows { display: grid; gap: 0.4rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); font-size: 0.9rem; }
.result-rows div { display: flex; justify-content: space-between; gap: 1rem; color: var(--text-muted); }
.result-rows strong { color: var(--text); font-variant-numeric: tabular-nums; }
.donut-track { stroke: var(--donut-track); }
.donut-principal { stroke: var(--donut-principal); }
.donut-interest { stroke: var(--donut-interest); }
.donut-wrap { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.legend { list-style: none; display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--text-muted); }
.legend li { display: flex; align-items: center; gap: 0.45rem; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch-principal { background: var(--donut-principal); }
.swatch-interest { background: repeating-linear-gradient(45deg, var(--donut-interest) 0 3px, var(--donut-interest-2) 3px 6px); }

.calc-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 900px) { .calc-grid { grid-template-columns: 1fr 1fr; } }

/* --- Article / SEO content --- */
.prose { max-width: 760px; }
.prose h2 { margin: 2.25rem 0 0.75rem; }
.prose h3 { margin: 1.5rem 0 0.5rem; }
.prose p, .prose li { font-size: 1rem; line-height: 1.75; }
.prose p + p { margin-top: 0.85rem; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0.6rem 0; color: var(--text-2); }
.prose li + li { margin-top: 0.35rem; }
.prose strong { color: var(--text); }
.prose .note { font-size: 0.9rem; color: var(--text-muted); border-left: 3px solid var(--primary-light); padding-left: 0.85rem; margin-top: 1rem; }

.spec-table { width: 100%; border-collapse: collapse; margin: 0.75rem 0 1rem; font-size: 0.93rem; }
.spec-table th, .spec-table td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.spec-table th { color: var(--text-muted); font-weight: 600; width: 40%; }
.spec-table td { color: var(--text); }
.table-scroll { overflow-x: auto; }
.table-scroll-hint { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 0.4rem; }
@media (min-width: 1200px) { .table-scroll-hint { display: none; } } /* wide screens show every column */
/* "Sizes by exam": several columns, so headers keep their natural width and short values stay on one line */
.sizes-table th { width: auto; }
.sizes-table th[scope="row"] { min-width: 9.5rem; }
.sizes-table thead th { color: var(--text-2); }
.sizes-table td:nth-child(2), .sizes-table td:nth-child(3) { white-space: nowrap; }
/* A board with no pixel size (27a): its wording wraps, with the board's own note on its own line */
.sizes-table td.px-free { white-space: normal; min-width: 11rem; }
.px-note { display: block; margin-top: 0.25rem; font-size: 0.85rem; color: var(--text-muted); }
/* The size chart (18b) has seven columns: it may use the full container width while its text keeps the reading width */
.prose-wide { max-width: none; }
.prose-wide > :not(.table-scroll) { max-width: 760px; }
.size-chart th[scope="row"] { min-width: 8.5rem; }
.size-chart td:nth-child(2) { white-space: normal; min-width: 9rem; }
.size-chart td:nth-child(3), .size-chart td:nth-child(4) { white-space: nowrap; }
.size-chart td.px-free { white-space: normal; }

/* FAQ — native <details>, keyboard accessible without JS */
.faq-list { display: grid; gap: 0.75rem; max-width: 820px; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.faq-item summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.15rem; font-weight: 600; color: var(--text); min-height: 52px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary .icon { transition: transform var(--dur) var(--ease-out); color: var(--text-muted); }
.faq-item[open] summary .icon { transform: rotate(180deg); }
.faq-item .faq-body { padding: 0 1.15rem 1.1rem; color: var(--text-2); font-size: 0.95rem; }
.faq-item .faq-body p + p { margin-top: 0.6rem; }

/* --- Ads (reserved space to avoid CLS) --- */
.ad-slot { margin: 2.5rem auto; max-width: 970px; min-height: 280px; text-align: center; }
@media (min-width: 900px) { .ad-slot { min-height: 120px; } }
.ad-slot .ad-label { display: block; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 0.3rem; }
.ad-slot ins.adsbygoogle { display: block; }
/* Shown once in place of the first ad when ads are blocked; never covers a tool */
.support-note {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin: 2.5rem auto; max-width: 970px; padding: 0.85rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-2); font-size: 0.92rem;
}
.support-note p { flex: 1 1 16rem; margin: 0; }

/* --- Command palette --- */
.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: var(--overlay-bg); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center; padding: 10vh 1rem 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal-window {
  width: 100%; max-width: 560px; background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-modal); padding: 1rem;
}
.palette-search { display: flex; align-items: center; gap: 0.6rem; padding: 0 0.25rem 0.75rem; border-bottom: 1px solid var(--border); }
.palette-search input { flex: 1; min-height: 44px; background: transparent; border: 0; outline: none; font-size: 1rem; color: var(--text); }
.palette-results { list-style: none; max-height: 55vh; overflow-y: auto; margin-top: 0.5rem; display: grid; gap: 2px; }
.palette-results a {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  min-height: 48px; padding: 0.5rem 0.85rem; border-radius: var(--radius-sm); color: var(--text);
}
.palette-results a:hover, .palette-results a[aria-selected="true"] { background: var(--accent-hover); text-decoration: none; }
.palette-empty { padding: 1.25rem; text-align: center; color: var(--text-dim); }

/* --- Toast --- */
.toast-region { position: fixed; z-index: var(--z-toast); left: 50%; bottom: 1rem; transform: translateX(-50%); width: calc(100% - 2rem); max-width: 420px; display: grid; gap: 0.5rem; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1rem; border-radius: var(--radius-md);
  background: var(--toast-bg); border: 1px solid var(--toast-border); color: var(--success-light);
  font-weight: 600; font-size: 0.92rem; box-shadow: var(--shadow-lg);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
@starting-style { .toast { opacity: 0; transform: translateY(10px); } }
.toast.leaving { opacity: 0; transform: translateY(6px); transition-duration: 150ms; }

/* --- Footer --- */
.site-footer { border-top: 1px solid var(--border); background: var(--footer-bg); padding: 3rem 0 1.5rem; margin-top: 4rem; font-size: 0.92rem; }
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; margin-bottom: 2rem; }
@media (min-width: 640px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .footer-grid { grid-template-columns: 1.6fr 1fr 1fr 1fr; } }
.footer-col h2 { font-size: 0.95rem; margin-bottom: 0.85rem; font-family: var(--font-body); font-weight: 700; }
.footer-col p { color: var(--text-muted); font-size: 0.88rem; max-width: 340px; margin-top: 0.75rem; }
.footer-links { list-style: none; }
.footer-links li { margin-bottom: 0.15rem; }
.footer-links a { display: inline-flex; align-items: center; min-height: 36px; color: var(--text-muted); }
.footer-links a:hover { color: var(--text); }
.footer-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem;
  padding-top: 1.25rem; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 0.82rem;
}
.footer-bottom p { color: var(--text-dim); font-size: 0.82rem; }

/* --- Legal / static pages --- */
.legal h2 { font-size: 1.2rem; margin: 2rem 0 0.5rem; }
.legal ul { padding-left: 1.3rem; color: var(--text-2); margin-top: 0.5rem; }
.legal li + li { margin-top: 0.3rem; }

/* --- Utilities (replace inline styles so CSP can forbid them) --- */
.footer-links-inline { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.items-center { align-items: center; }
/* Two-class selector so these beat .input-inline .control-input */
.input-inline .w-80 { width: 80px; }
.input-inline .w-90 { width: 90px; }
.input-inline .w-130 { width: 130px; }
.input-inline .w-140 { width: 140px; }
.gst-custom-rate { margin-top: 0.6rem; max-width: 160px; }
.not-found { text-align: center; padding-block: 4rem; }
.not-found .lead { margin: 0 auto 1.5rem; }

/* --- Motion preferences --- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn:active:not(:disabled), .tool-card:hover, .toast, .toast.leaving { transform: none; }
  @starting-style { .toast, .mobile-menu.open, .preview-result { transform: none; } }
}

/* My documents (Task 20): saved originals above the dropzone, and the opt-in after a download */
.btn-link { display: inline-flex; align-items: center; background: none; border: 0; padding: 0.25rem 0; min-height: 44px; min-width: 44px; color: var(--primary-light); font: inherit; font-size: 0.85rem; font-weight: 600; text-decoration: underline; cursor: pointer; }
.btn-link:focus-visible { box-shadow: var(--focus-ring); border-radius: 4px; }
.saved-docs { margin-bottom: 0.9rem; padding: 0.75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-sunken); }
.saved-docs-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; }
.saved-docs-title span { font-weight: 400; color: var(--text-dim); }
.saved-docs-list { list-style: none; margin: 0 0 0.25rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.saved-doc { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.saved-doc-use { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; padding: 0.35rem; min-width: 76px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface, #fff); color: var(--text); font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.saved-doc-use:focus-visible { box-shadow: var(--focus-ring); }
.saved-doc-use img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 4px; }
.keep-row { margin-top: 0.75rem; }
.keep-ask { padding: 0.75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-md); font-size: 0.88rem; }
.keep-ask p + p { margin-top: 0.4rem; }
.keep-warn { color: var(--warn-text); }
.keep-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
@media (max-width: 899px) { [data-state="ready"] .ws-input .saved-docs { display: none; } }
