/* ===================================================================
   Old Photo Studio - the eight tool pages (_PhotoStudioTool) and the hub
   (PhotoStudio/_PhotoStudioHub on /old-photo-restoration-tools).

   Same visual language as the redesigned colorizer (colorize-image.css):
   Inter, the blue-to-green gradient, soft grey-blue hero, cards on the
   site-wide --az-* tokens. Scoped under .ps.

   Motion is decoration: every state is also carried by text, and
   prefers-reduced-motion switches animation off at the bottom.
   =================================================================== */

.ps {
    --ps-blue: #3498db;
    --ps-blue-strong: #1f6fae;
    --ps-green: #2ecc71;
    --ps-green-strong: #17864f;
    --ps-grad: linear-gradient(110deg, #3498db 0%, #2ecc71 100%);
    --ps-soft: #eaf4fc;
    --ps-ring: rgba(52, 152, 219, .38);
    --ps-mask: rgba(231, 76, 60, .55);

    --ps-ink: var(--az-ink, #10162b);
    --ps-ink-2: var(--az-ink-2, #454d63);
    --ps-ink-3: var(--az-ink-3, #5f677d);
    --ps-bg: var(--az-bg, #fbf9f7);
    --ps-surface: var(--az-surface, #ffffff);
    --ps-line: var(--az-line, #e8e6e3);
    --ps-line-2: var(--az-line-2, #f0eeeb);
    --ps-warn: #8f5600;
    --ps-warn-soft: #fff2dc;
    --ps-fail: #c62f2f;
    --ps-fail-soft: #fdeeee;

    --ps-r-sm: 10px;
    --ps-r: var(--az-r, 14px);
    --ps-r-lg: 20px;
    --ps-shadow: 0 4px 16px rgba(16, 22, 43, .06);
    --ps-shadow-lg: 0 22px 48px -22px rgba(16, 22, 43, .28);
    --ps-ease: cubic-bezier(.2, .8, .2, 1);

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--ps-bg);
    color: var(--ps-ink-2);
    padding-bottom: 28px;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}

.ps *, .ps *::before, .ps *::after { box-sizing: border-box; }
.ps [hidden] { display: none !important; }
.ps-shell { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.ps h1, .ps h2, .ps h3, .ps h4 { color: var(--ps-ink); letter-spacing: -.01em; }
.ps :is(a, button, input, select, summary, [tabindex]):focus-visible { outline: 3px solid var(--ps-ring); outline-offset: 2px; }
.ps .visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.ps-small { margin: 8px 0 0; font-size: .82rem; line-height: 1.45; color: var(--ps-ink-3); }

/* ---- Buttons ---- */
.ps-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px; border-radius: 12px;
    font: inherit; font-weight: 700; font-size: .94rem; line-height: 1.1; text-decoration: none !important; text-align: center;
    border: 1px solid transparent; cursor: pointer;
    transition: transform .16s var(--ps-ease), box-shadow .16s var(--ps-ease), background-color .16s, border-color .16s, color .16s;
}
.ps-btn:disabled, .ps-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none !important; }
.ps-btn-primary { color: #fff !important; background: var(--ps-grad); box-shadow: 0 12px 24px -12px rgba(52, 152, 219, .75); }
.ps-btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 28px -12px rgba(46, 204, 113, .7); }
.ps-btn-lg { min-height: 52px; padding: 0 24px; font-size: 1rem; }
.ps-btn-soft { color: var(--ps-blue-strong) !important; background: var(--ps-soft); border-color: #d3e7f7; }
.ps-btn-soft:hover:not(:disabled) { background: #dcecfa; border-color: var(--ps-blue); }
.ps-btn-ghost { color: var(--ps-ink-2) !important; background: var(--ps-surface); border-color: var(--ps-line); }
.ps-btn-ghost:hover:not(:disabled) { border-color: var(--ps-blue); color: var(--ps-blue-strong) !important; }
.ps-btn-block { width: 100%; }
.ps-link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 0; font: inherit; font-size: .88rem; font-weight: 700; color: var(--ps-blue-strong); cursor: pointer; text-decoration: none; }
.ps-link-btn:hover { text-decoration: underline; }
.ps-link { color: var(--ps-blue-strong); font-weight: 700; text-decoration: underline; }

/* ---- Hero ---- */
.ps .ps-hero { position: relative; padding: 26px 0 30px; background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%); overflow: hidden; }
.ps-hero::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--ps-grad); }
.ps-hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 36px; align-items: center; }
.ps-crumbs ol { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0 0 12px; padding: 0; font-size: .82rem; color: var(--ps-ink-3); }
.ps-crumbs li + li::before { content: "/"; margin-right: 4px; color: #aab1c0; }
.ps-crumbs a { color: var(--ps-blue-strong); text-decoration: none; }
.ps-crumbs a:hover { text-decoration: underline; }
.ps-eyebrow {
    display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; margin: 0 0 12px; border-radius: 999px;
    font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
    color: var(--ps-blue-strong); background: rgba(255, 255, 255, .8); border: 1px solid #d3e7f7;
}
.ps-hero h1 { margin: 0 0 12px; font-weight: 800; line-height: 1.12; font-size: clamp(1.8rem, 4vw, 2.8rem); overflow-wrap: anywhere; }
.ps-lead { max-width: 600px; margin: 0 0 16px; font-size: 1.06rem; line-height: 1.6; color: var(--ps-ink-3); }
.ps-chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0 0 16px; padding: 0; }
.ps-chips li { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; font-size: .84rem; font-weight: 600; color: var(--ps-ink-2); background: var(--ps-surface); border: 1px solid var(--ps-line); }
.ps-chips i { color: var(--ps-green-strong); }
.ps-method { display: flex; flex-direction: column; gap: 6px; max-width: 600px; margin: 0 0 18px; padding: 10px 14px; border-radius: var(--ps-r-sm); background: rgba(255, 255, 255, .75); border: 1px solid #d3e7f7; }
.ps-method-badge { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ps-blue-strong); }
.ps-method[data-method="learned"] .ps-method-badge, .ps-method[data-method="ai"] .ps-method-badge { color: #6b3fb0; }
.ps-method-note { font-size: .88rem; line-height: 1.5; color: var(--ps-ink-2); }
.ps-hero-cta { min-height: 50px; }

/* Demo: an illustration built from the two licence-cleared sample images.
   The "after" copy is revealed over the "before" copy on a loop; the
   defect (scratches, grain, tear, blur, fade) lives only on the before side. */
.ps-demo { position: relative; margin: 0; justify-self: center; width: min(100%, 340px); }
.ps-demo-frame {
    position: relative; aspect-ratio: 410 / 614; border-radius: 22px; overflow: hidden; background: #d8dbe0;
    box-shadow: 0 30px 60px -28px rgba(16, 22, 43, .45), 0 0 0 8px #fff; transform: rotate(1.5deg);
}
.ps-demo-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ps-demo-img.is-after { clip-path: inset(0 100% 0 0); animation: ps-reveal 7s var(--ps-ease) infinite; }
.ps-demo-fx { position: absolute; inset: 0; pointer-events: none; }
.ps-demo-wipe { position: absolute; top: -4%; bottom: -4%; left: 0; width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 18px 6px rgba(255, 255, 255, .7), 0 0 40px 10px rgba(46, 204, 113, .45); animation: ps-wipe 7s var(--ps-ease) infinite; }
.ps-demo-tag { position: absolute; bottom: 14px; padding: 6px 12px; border-radius: 999px; font-size: .78rem; font-weight: 700; color: #fff; background: rgba(16, 22, 43, .72); }
.ps-demo-tag.is-before { left: 14px; }
.ps-demo-tag.is-after { right: 14px; background: linear-gradient(110deg, rgba(31, 111, 174, .95), rgba(23, 134, 79, .95)); }
.ps-demo-cap { margin: 16px 0 0; font-size: .76rem; text-align: center; color: var(--ps-ink-3); }
.ps-demo-glow { position: absolute; inset: 12% -8% 6% -8%; z-index: -1; border-radius: 40px; background: var(--ps-grad); filter: blur(40px); opacity: .28; }

/* scratches: thin light lines at a few angles */
.ps-demo.is-restore .ps-demo-fx, .ps-demo.is-scratches .ps-demo-fx {
    background:
        linear-gradient(97deg, transparent 31.6%, rgba(255, 255, 255, .85) 31.8%, transparent 32.1%),
        linear-gradient(83deg, transparent 58.2%, rgba(255, 255, 255, .7) 58.4%, transparent 58.7%),
        linear-gradient(12deg, transparent 44.3%, rgba(255, 255, 255, .65) 44.5%, transparent 44.8%),
        radial-gradient(circle at 22% 30%, rgba(255, 255, 255, .9) 0 1.5px, transparent 2.5px),
        radial-gradient(circle at 70% 62%, rgba(255, 255, 255, .85) 0 2px, transparent 3px),
        radial-gradient(circle at 40% 80%, rgba(255, 255, 255, .8) 0 1.5px, transparent 2.5px);
}
/* grain */
.ps-demo.is-restore .ps-demo-fx::after, .ps-demo.is-denoise .ps-demo-fx::after {
    content: ""; position: absolute; inset: 0; opacity: .5; mix-blend-mode: overlay;
    background:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .9) .6px, transparent 1px) 0 0 / 3px 3px,
        radial-gradient(circle at 2px 2px, rgba(0, 0, 0, .9) .6px, transparent 1.1px) 1px 2px / 4px 4px;
}
.ps-demo.is-denoise .ps-demo-fx::after { opacity: .75; }
/* tear and stain */
.ps-demo.is-repair .ps-demo-fx {
    background:
        radial-gradient(ellipse 18% 12% at 70% 26%, rgba(120, 84, 38, .55), transparent 70%),
        radial-gradient(ellipse 12% 9% at 28% 72%, rgba(120, 84, 38, .45), transparent 70%);
}
.ps-demo.is-repair .ps-demo-fx::before {
    content: ""; position: absolute; left: 0; top: 46%; width: 62%; height: 9%; background: #f4f1ea;
    clip-path: polygon(0 30%, 18% 10%, 34% 42%, 52% 5%, 70% 48%, 88% 20%, 100% 55%, 84% 90%, 60% 62%, 42% 100%, 22% 66%, 0 88%);
}
.ps-demo.is-restore .ps-demo-img.is-before { filter: sepia(.55) contrast(.72) brightness(1.08); }
.ps-demo.is-restore .ps-demo-img.is-after { filter: contrast(1.04); }
.ps-demo.is-unblur .ps-demo-img.is-before { filter: blur(2.4px); }
.ps-demo.is-upscale .ps-demo-img.is-before { filter: blur(1.6px) contrast(.95); }
.ps-demo.is-face .ps-demo-img { object-position: 50% 18%; transform: scale(1.5); transform-origin: 50% 22%; }
.ps-demo.is-face .ps-demo-img.is-before { filter: blur(1.3px) contrast(.84); }
.ps-demo.is-faded .ps-demo-img.is-before { filter: saturate(.3) sepia(.45) contrast(.7) brightness(1.14); }

/* ---- Notice (disabled, maintenance, unavailable) ---- */
.ps-notice { display: flex; gap: 12px; margin: 18px 0 0; padding: 14px 16px; border-radius: var(--ps-r); background: var(--ps-soft); border: 1px solid #cfe3f5; color: var(--ps-blue-strong); }
.ps-notice[data-kind="maintenance"], .ps-notice[data-kind="unavailable"] { background: var(--ps-warn-soft); border-color: rgba(143, 86, 0, .25); color: var(--ps-warn); }
.ps-notice[data-kind="disabled"] { background: var(--ps-fail-soft); border-color: rgba(198, 47, 47, .22); color: var(--ps-fail); }
.ps-notice-icon { margin-top: 2px; }
.ps-notice-title { margin: 0 0 2px; font-weight: 800; }
.ps-notice-text { margin: 0; color: var(--ps-ink-2); }
.ps-notice .ps-btn { margin-top: 10px; min-height: 38px; }

/* ---- Workbench ---- */
.ps-main { padding-top: 4px; }
.ps-bench {
    position: relative; margin-top: 18px; padding: 24px;
    background: var(--ps-surface); border: 1px solid var(--ps-line); border-radius: var(--ps-r-lg);
    box-shadow: var(--ps-shadow-lg); scroll-margin-top: 80px; min-height: 280px;
}
.ps-bench::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; border-radius: var(--ps-r-lg) var(--ps-r-lg) 0 0; background: var(--ps-grad); }
.ps-bench[data-state="disabled"] .ps-drop { cursor: not-allowed; opacity: .6; transform: none; }
.ps-panel { animation: ps-rise .35s var(--ps-ease) both; }
.ps-kicker { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 4px; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ps-blue-strong); }
.ps-kicker.is-success { color: var(--ps-green-strong); }

.ps-drop {
    position: relative; display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 36px 20px 28px; border-radius: 16px; cursor: pointer;
    border: 2px dashed #cfdcea; background: linear-gradient(180deg, #f9fbfd 0%, #f3f7fb 100%);
    transition: border-color .2s, background-color .2s, transform .2s var(--ps-ease), box-shadow .2s;
}
.ps-drop:hover { border-color: var(--ps-blue); box-shadow: var(--ps-shadow); }
.ps-drop.is-over { border-color: var(--ps-green); background: #eefaf3; }
.ps-drop-art { position: relative; width: 108px; height: 88px; margin-bottom: 14px; }
.ps-drop-card { position: absolute; width: 72px; height: 62px; border-radius: 12px; }
.ps-drop-card.is-back { left: 6px; top: 12px; background: linear-gradient(135deg, #c8ccd3, #9aa1ab); transform: rotate(-10deg); }
.ps-drop-card.is-front { right: 6px; top: 2px; display: grid; place-items: center; font-size: 1.6rem; color: #fff; background: var(--ps-grad); transform: rotate(8deg); box-shadow: 0 12px 22px -10px rgba(52, 152, 219, .8); animation: ps-float 3.2s ease-in-out infinite; }
.ps-drop-badge { position: absolute; right: -2px; bottom: 0; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: #e67e22; border: 3px solid #fff; font-size: .85rem; }
.ps-drop-title { margin: 0 0 6px; font-size: 1.3rem; font-weight: 800; color: var(--ps-ink); }
.ps-drop-hint { margin: 0 0 6px; color: var(--ps-ink-2); }
.ps-drop-meta { margin: 0; font-size: .86rem; color: var(--ps-ink-3); }
.ps-idle-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }

/* Ready */
.ps-ready-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 24px; align-items: start; }
.ps-ready-grid.has-mask { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.ps-thumb { border-radius: 16px; overflow: hidden; background: repeating-conic-gradient(#eef1f5 0% 25%, #fff 0% 50%) 50% / 20px 20px; border: 1px solid var(--ps-line); }
.ps-thumb img { display: block; width: 100%; max-height: 360px; object-fit: contain; }
.ps-file-name { margin: 0 0 2px; font-size: 1.15rem; font-weight: 800; color: var(--ps-ink); overflow-wrap: anywhere; }
.ps-file-meta { margin: 0 0 12px; font-size: .9rem; color: var(--ps-ink-3); }
.ps-note { display: flex; gap: 10px; margin: 0 0 12px; padding: 10px 12px; border-radius: var(--ps-r-sm); font-size: .88rem; line-height: 1.5; }
.ps-note > i { margin-top: 3px; }
.ps-note p { margin: 0; }
.ps-note.is-info { color: var(--ps-blue-strong); background: var(--ps-soft); border: 1px solid #d3e7f7; }
.ps-note.is-warn { color: var(--ps-warn); background: var(--ps-warn-soft); border: 1px solid rgba(143, 86, 0, .2); }
.ps-go-error { margin: 0 0 10px; padding: 10px 12px; border-radius: var(--ps-r-sm); font-weight: 700; color: var(--ps-fail); background: var(--ps-fail-soft); }
.ps-ready-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* Options */
.ps-options { display: grid; gap: 12px; padding: 14px; border-radius: var(--ps-r); background: #f8fafc; border: 1px solid var(--ps-line); }
.ps-options-title { margin: 0; font-size: .92rem; font-weight: 800; color: var(--ps-ink); }
.ps-options-title i { color: var(--ps-blue); }
.ps-opt { margin: 0; min-width: 0; }
.ps-opt.is-off { opacity: .5; }
.ps-opt-help { margin: 4px 0 0; font-size: .8rem; line-height: 1.45; color: var(--ps-ink-3); }
fieldset.ps-opt { border: 0; padding: 0; }
fieldset.ps-opt legend { float: none; width: auto; margin: 0 0 6px; padding: 0; font-size: .86rem; font-weight: 700; color: var(--ps-ink-2); }
.ps-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.ps-seg label { position: relative; margin: 0; flex: 1 1 auto; }
.ps-seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ps-seg span { display: block; min-height: 40px; padding: 9px 12px; border-radius: 10px; text-align: center; font-weight: 700; font-size: .86rem; color: var(--ps-ink-3); background: #fff; border: 1.5px solid var(--ps-line); cursor: pointer; transition: all .16s; }
.ps-seg input:checked + span { color: var(--ps-blue-strong); border-color: var(--ps-blue); background: var(--ps-soft); }
.ps-seg input:focus-visible + span { outline: 3px solid var(--ps-ring); outline-offset: 2px; }
.ps-seg input:disabled + span { cursor: not-allowed; }
.ps-switch { position: relative; display: flex; align-items: center; gap: 10px; margin: 0; cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--ps-ink-2); }
.ps-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ps-switch-track { flex: none; position: relative; width: 42px; height: 24px; border-radius: 999px; background: #cfd6e0; transition: background-color .2s; }
.ps-switch-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ps-ease); }
.ps-switch input:checked + .ps-switch-track { background: var(--ps-green-strong); }
.ps-switch input:checked + .ps-switch-track::after { transform: translateX(18px); }
.ps-switch input:focus-visible + .ps-switch-track { outline: 3px solid var(--ps-ring); outline-offset: 2px; }
.ps-range { display: block; margin: 0; }
.ps-range-top { display: flex; justify-content: space-between; gap: 8px; font-size: .86rem; font-weight: 700; color: var(--ps-ink-2); }
.ps-range output { font-variant-numeric: tabular-nums; color: var(--ps-ink-3); }
.ps-range input[type="range"] { width: 100%; margin: 6px 0 0; accent-color: var(--ps-blue); }
.ps-check { display: inline-flex; align-items: center; gap: 8px; margin: 4px 0 0; font-weight: 600; font-size: .86rem; color: var(--ps-ink-2); cursor: pointer; }
.ps-check input { width: 18px; height: 18px; accent-color: var(--ps-blue); }
.ps-advanced { border-top: 1px dashed var(--ps-line); padding-top: 8px; }
.ps-advanced summary { cursor: pointer; font-weight: 800; font-size: .88rem; color: var(--ps-blue-strong); padding: 4px 0; }
.ps-advanced[open] summary { margin-bottom: 8px; }
.ps-advanced .ps-opt + .ps-opt { margin-top: 12px; }
.ps-reset-opts { justify-self: start; }

/* Mask editor */
.psm { display: grid; gap: 10px; min-width: 0; }
.psm-title { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 800; color: var(--ps-ink); }
.psm-title i { color: var(--ps-blue); }
.psm-sub { margin: 2px 0 0; font-size: .86rem; line-height: 1.5; color: var(--ps-ink-3); }
.psm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; border-radius: 12px; background: #f4f7fb; border: 1px solid var(--ps-line); }
.psm-group { display: inline-flex; align-items: center; gap: 4px; }
.psm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; min-width: 40px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--ps-line); background: #fff; font: inherit; font-size: .84rem; font-weight: 700; color: var(--ps-ink-2); cursor: pointer; }
.psm-btn:hover:not(:disabled) { border-color: var(--ps-blue); color: var(--ps-blue-strong); }
.psm-btn[aria-pressed="true"] { color: #fff; background: var(--ps-blue-strong); border-color: var(--ps-blue-strong); }
.psm-btn:disabled { opacity: .45; cursor: not-allowed; }
.psm-btn.is-icon { padding: 0; }
.psm-btn.is-accent { color: var(--ps-green-strong); border-color: #bfe6cf; background: #eefaf3; }
.psm-size { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: .84rem; font-weight: 700; }
.psm-size input { width: 110px; accent-color: var(--ps-blue); }
.psm-size output, .psm-zoom { min-width: 48px; font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--ps-ink-3); text-align: center; }
.psm-overlay { margin: 0; }
.psm-viewport { position: relative; width: 100%; height: clamp(260px, 56vh, 560px); border-radius: 14px; overflow: hidden; touch-action: none; cursor: none; background: repeating-conic-gradient(#e9edf2 0% 25%, #f7f9fb 0% 50%) 50% / 24px 24px; border: 1px solid var(--ps-line); }
.psm-viewport.is-pan { cursor: grab; }
.psm-viewport.is-panning { cursor: grabbing; }
.psm-viewport canvas { display: block; width: 100%; height: 100%; }
.psm-cursor { position: absolute; left: 0; top: 0; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px rgba(16, 22, 43, .75); pointer-events: none; transform: translate(-50%, -50%); }
.psm-cursor.is-eraser { border-style: dashed; }
.psm-status { margin: 0; font-size: .86rem; font-weight: 600; color: var(--ps-ink-2); }
.psm-warn { margin: 0; }

/* Working */
.ps-working-grid { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 26px; align-items: center; }
.ps-scan { position: relative; border-radius: 16px; overflow: hidden; background: #d8dbe0; min-height: 160px; box-shadow: var(--ps-shadow-lg); }
.ps-scan img { display: block; width: 100%; max-height: 340px; object-fit: cover; }
.ps-scan-beam { position: absolute; left: -10%; right: -10%; height: 70px; top: -70px; background: linear-gradient(180deg, transparent, rgba(255, 255, 255, .55), transparent); animation: ps-beam 2s ease-in-out infinite; }
.ps-working-title { margin: 0 0 12px; font-size: 1.3rem; font-weight: 800; color: var(--ps-ink); }
.ps-steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.ps-steps li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--ps-line); background: var(--ps-surface); color: var(--ps-ink-3); font-weight: 600; }
.ps-step-dot { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ps-line); color: transparent; font-size: .7rem; }
.ps-step-name { flex: 1; }
.ps-step-info { font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ps-ink-3); }
.ps-steps li.is-active { color: var(--ps-ink); border-color: #bfdcf3; background: var(--ps-soft); }
.ps-steps li.is-active .ps-step-dot { border-color: var(--ps-blue); border-top-color: transparent; animation: ps-spin .8s linear infinite; }
.ps-steps li.is-done .ps-step-dot { border-color: var(--ps-green-strong); background: var(--ps-green-strong); color: #fff; }
.ps-bar { position: relative; height: 8px; margin-bottom: 8px; border-radius: 999px; overflow: hidden; background: #e7ecf2; }
.ps-bar-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--ps-grad); transition: width .4s var(--ps-ease); }
.ps-working-hint { margin: 0 0 14px; font-size: .88rem; color: var(--ps-ink-3); }

/* Done */
.ps-done-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ps-done-title { margin: 0; font-size: 1.35rem; font-weight: 800; }
.ps-done-title:focus { outline: none; }
.ps-zoom { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--ps-bg); border: 1px solid var(--ps-line-2); }
.ps-zoom button { min-height: 36px; min-width: 52px; padding: 0 12px; border: 0; border-radius: 9px; font: inherit; font-size: .86rem; font-weight: 700; color: var(--ps-ink-3); background: transparent; cursor: pointer; }
.ps-zoom button[aria-pressed="true"] { color: var(--ps-ink); background: var(--ps-surface); box-shadow: 0 1px 3px rgba(16, 22, 43, .12); }
.ps-done-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.ps-stage { position: relative; min-width: 0; }
.ps-stage-hint { margin: 8px 0 0; font-size: .84rem; color: var(--ps-ink-3); text-align: center; }

.ps-compare {
    --p: 50%;
    position: relative; width: 100%; max-height: 72vh; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden;
    background: #1b1f27; box-shadow: var(--ps-shadow-lg); touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.ps-compare:not([data-zoom="1"]) { touch-action: none; cursor: grab; }
.ps-compare.is-panning { cursor: grabbing; }
.ps-layer { position: absolute; inset: 0; overflow: hidden; }
.ps-layer.is-before { clip-path: inset(0 calc(100% - var(--p)) 0 0); }
.ps-compare.is-after-only .ps-layer.is-before, .ps-compare.is-after-only .ps-handle, .ps-compare.is-after-only .ps-layer-tag.is-before { display: none; }
.ps-pan { position: absolute; left: 0; top: 0; width: 100%; height: 100%; transform-origin: 0 0; will-change: transform; }
.ps-pan img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.ps-compare:not([data-zoom="1"]) .ps-pan img { image-rendering: auto; }
.ps-layer-tag { position: absolute; top: 12px; z-index: 3; padding: 5px 11px; border-radius: 999px; font-size: .76rem; font-weight: 700; color: #fff; background: rgba(16, 22, 43, .72); pointer-events: none; }
.ps-layer-tag.is-before { left: 12px; }
.ps-layer-tag.is-after { right: 12px; background: linear-gradient(110deg, rgba(31, 111, 174, .95), rgba(23, 134, 79, .95)); }
.ps-handle { position: absolute; top: 0; bottom: 0; left: var(--p); z-index: 2; width: 44px; margin-left: -22px; cursor: ew-resize; touch-action: none; }
.ps-handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 14px rgba(0, 0, 0, .35); }
.ps-handle-knob { position: absolute; top: 50%; left: 50%; display: flex; align-items: center; justify-content: center; gap: 2px; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; color: var(--ps-blue-strong); background: #fff; font-size: .72rem; box-shadow: 0 6px 16px rgba(0, 0, 0, .3); }
.ps-handle:focus-visible .ps-handle-knob, .ps-handle:hover .ps-handle-knob { color: #fff; background: var(--ps-blue-strong); }

.ps-side { display: grid; gap: 12px; min-width: 0; }
.ps-card { padding: 14px; border-radius: var(--ps-r); background: var(--ps-surface); border: 1px solid var(--ps-line); }
.ps-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ps-card-head h3 { margin: 0; font-size: .98rem; font-weight: 800; }
.ps-card-head h3 i { color: var(--ps-blue); margin-right: 4px; }
.ps-card .ps-btn + .ps-btn { margin-top: 8px; }
.ps-result-meta { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; font-size: .88rem; }
.ps-result-meta li { display: flex; gap: 8px; }
.ps-result-meta i { margin-top: 3px; color: var(--ps-blue); }
.ps-estimate { margin: 0; }
.ps-format { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.ps-format label { position: relative; margin: 0; }
.ps-format input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ps-format span { display: block; padding: 8px; border-radius: 10px; text-align: center; font-weight: 800; font-size: .86rem; color: var(--ps-ink-3); border: 1.5px solid var(--ps-line); cursor: pointer; }
.ps-format input:checked + span { color: var(--ps-blue-strong); border-color: var(--ps-blue); background: var(--ps-soft); }
.ps-format input:focus-visible + span { outline: 3px solid var(--ps-ring); outline-offset: 2px; }
.ps-card .ps-range { margin-bottom: 10px; }
.ps-next-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.ps-next-list .ps-btn { width: 100%; justify-content: flex-start; }
.ps-next-list .ps-btn span { white-space: normal; text-align: left; }

/* Error */
.ps-error { text-align: center; padding: 18px 10px; }
.ps-error-icon { display: inline-grid; place-items: center; width: 60px; height: 60px; margin-bottom: 10px; border-radius: 50%; font-size: 1.5rem; color: var(--ps-fail); background: var(--ps-fail-soft); }
.ps-error-title { margin: 0 0 6px; font-size: 1.3rem; font-weight: 800; }
.ps-error-text { max-width: 540px; margin: 0 auto 16px; color: var(--ps-ink-2); }
.ps-error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* What to expect + privacy */
.ps-before { margin-top: 16px; padding: 16px 18px; border-radius: var(--ps-r); background: #f4f8fc; border: 1px solid #e1ecf6; }
.ps-before-title { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 1rem; font-weight: 800; }
.ps-before-title i { color: var(--ps-blue); }
.ps-before ul { margin: 0 0 12px; padding-left: 20px; font-size: .9rem; line-height: 1.55; }
.ps-privacy { display: flex; gap: 10px; margin: 0; font-size: .88rem; line-height: 1.5; color: var(--ps-ink-2); }
.ps-privacy i { margin-top: 3px; color: var(--ps-green-strong); }

/* Ad: _AdUnit reserves min-height for non-subscribers; nothing is emitted for subscribers. */
.ps-ad { margin-top: 18px; }

/* Related */
.ps-related { margin-top: 26px; }
.ps-related-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.ps-related-head h2 { margin: 0; font-size: 1.2rem; font-weight: 800; }
.ps-related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; list-style: none; margin: 0; padding: 0; }
.ps-related-card { display: flex; align-items: center; gap: 12px; height: 100%; padding: 12px; border-radius: var(--ps-r); background: var(--ps-surface); border: 1px solid var(--ps-line); text-decoration: none; color: inherit; transition: border-color .16s, transform .16s var(--ps-ease); }
.ps-related-card:hover { border-color: var(--ps-blue); transform: translateY(-2px); }
.ps-related-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; color: #fff; background: var(--ps-grad); }
.ps-related-text { display: grid; min-width: 0; }
.ps-related-text strong { color: var(--ps-ink); font-size: .92rem; }
.ps-related-text span { font-size: .8rem; color: var(--ps-ink-3); }
.ps-credits { margin: 12px 0 0; font-size: .8rem; color: var(--ps-ink-3); }

/* Toast */
.ps-toast { position: fixed; left: 50%; bottom: 22px; z-index: 1080; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 12px; color: #fff; background: var(--ps-ink); box-shadow: 0 16px 34px -12px rgba(16, 22, 43, .5); font-weight: 600; font-size: .92rem; transform: translate(-50%, 0); }
.ps-toast i { color: #7fe0ab; }
.ps-toast.is-error i { color: #ff9b9b; }

/* =================================================================== Hub */
.psh { background: transparent; padding: 0; }
.psh > section, .psh > div { margin-top: 22px; }
.psh h2 { font-size: 1.35rem; font-weight: 800; margin: 0 0 8px; }
.psh-intro { padding: 22px; border-radius: var(--ps-r-lg); background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%); border: 1px solid var(--ps-line); position: relative; overflow: hidden; }
.psh-intro::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--ps-grad); }
.psh-intro h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); }
.psh-cando { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.psh-cando-col { padding: 14px; border-radius: var(--ps-r); background: #fff; border: 1px solid var(--ps-line); }
.psh-cando-col h3 { display: flex; gap: 8px; align-items: center; margin: 0 0 6px; font-size: .98rem; }
.psh-cando-col.is-can h3 i { color: var(--ps-green-strong); }
.psh-cando-col.is-cannot h3 i { color: var(--ps-fail); }
.psh-cando-col ul { margin: 0; padding-left: 18px; font-size: .9rem; line-height: 1.55; }
.psh-resume { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--ps-r); background: #eefaf3; border: 1px solid #bfe6cf; color: var(--ps-green-strong); }
.psh-resume p { margin: 0; flex: 1 1 260px; color: var(--ps-ink-2); }
.psh-picker { padding: 20px; border-radius: var(--ps-r-lg); background: #fff; border: 1px solid var(--ps-line); box-shadow: var(--ps-shadow); }
.psh-picker-sub, .psh-flow-sub { margin: 0 0 12px; color: var(--ps-ink-3); }
.psh-problems { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; }
.psh-problem { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--ps-line); background: #fafbfc; font: inherit; font-weight: 700; font-size: .9rem; text-align: left; color: var(--ps-ink-2); cursor: pointer; }
.psh-problem i { flex: none; width: 22px; text-align: center; color: var(--ps-blue); }
.psh-problem:hover { border-color: var(--ps-blue); }
.psh-problem[aria-pressed="true"] { border-color: var(--ps-blue-strong); background: var(--ps-soft); color: var(--ps-ink); }
.psh-answer { margin-top: 14px; padding: 16px; border-radius: var(--ps-r); background: var(--ps-soft); border: 1px solid #cfe3f5; }
.psh-answer-kicker { margin: 0; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ps-blue-strong); }
.psh-answer-name { margin: 2px 0 4px; font-size: 1.15rem; font-weight: 800; color: var(--ps-ink); }
.psh-answer-why { margin: 0 0 12px; color: var(--ps-ink-2); }
.psh-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; counter-reset: none; }
.psh-step { display: flex; gap: 12px; padding: 14px; border-radius: var(--ps-r); background: #fff; border: 1px solid var(--ps-line); }
.psh-step-num { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 800; background: var(--ps-grad); }
.psh-step h3 { margin: 0 0 4px; font-size: .98rem; font-weight: 800; }
.psh-step p { margin: 0; font-size: .88rem; line-height: 1.5; color: var(--ps-ink-3); }
.psh-step-links { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px !important; }
.psh-step-links a { font-weight: 700; color: var(--ps-blue-strong); }
.psh-flow-note { margin: 10px 0 0; font-size: .9rem; }
.psh-flow-note i { color: var(--ps-blue); }
.psh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; list-style: none; margin: 0; padding: 0; }
.psh-card a { display: flex; gap: 12px; height: 100%; padding: 16px; border-radius: var(--ps-r); background: #fff; border: 1px solid var(--ps-line); text-decoration: none; color: inherit; transition: border-color .16s, transform .16s var(--ps-ease), box-shadow .16s; }
.psh-card a:hover { border-color: var(--ps-blue); transform: translateY(-2px); box-shadow: var(--ps-shadow); }
.psh-card.is-separate a { background: #fbfaf7; border-style: dashed; }
.psh-card.is-suggested a { border-color: var(--ps-blue-strong); box-shadow: 0 0 0 3px var(--ps-ring); }
.psh-card-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: #fff; background: var(--ps-grad); }
.psh-card.is-separate .psh-card-icon { background: linear-gradient(110deg, #9b59b6, #e67e22); }
.psh-card-body { display: grid; gap: 6px; min-width: 0; }
.psh-card-body strong { color: var(--ps-ink); }
.psh-card-lead { font-size: .88rem; line-height: 1.5; color: var(--ps-ink-3); }
.psh-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.psh-card-go { color: var(--ps-blue-strong); }
.ps-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 800; color: var(--ps-blue-strong); background: var(--ps-soft); }
.ps-badge.is-learned { color: #6b3fb0; background: #f2ecfb; }
.psh-privacy-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.psh-privacy-grid > div { padding: 16px; border-radius: var(--ps-r); background: #f4f8fc; border: 1px solid #e1ecf6; }
.psh-privacy-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 8px; border-radius: 11px; color: #fff; background: var(--ps-grad); }
.psh-privacy-grid h3 { margin: 0 0 4px; font-size: .98rem; font-weight: 800; }
.psh-privacy-grid p { margin: 0; font-size: .88rem; line-height: 1.5; color: var(--ps-ink-3); }

/* ---- Responsive ---- */
@media (max-width: 1000px) {
    .ps-done-grid { grid-template-columns: 1fr; }
    .ps-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ps-side > .ps-btn { grid-column: 1 / -1; }
    .ps-ready-grid.has-mask { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .ps-hero-grid { grid-template-columns: 1fr; }
    .ps-demo { width: min(72%, 280px); }
    .psh-privacy-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .ps-bench { padding: 16px 12px; }
    .ps-ready-grid, .ps-working-grid { grid-template-columns: 1fr; }
    .ps-scan { max-width: 260px; margin: 0 auto; }
    .ps-ready-actions .ps-btn, .ps-idle-actions .ps-btn { flex: 1 1 100%; }
    .ps-side { grid-template-columns: 1fr; }
    .ps-zoom { width: 100%; }
    .ps-zoom button { flex: 1; }
    .ps-drop { padding: 26px 12px 20px; }
    .ps-drop-title { font-size: 1.12rem; }
    .psh-cando { grid-template-columns: 1fr; }
    .psh-intro, .psh-picker { padding: 16px 12px; }
    .psm-size input { width: 90px; }
    .psm-btn span:not(.visually-hidden) { font-size: .8rem; }
    .psm-viewport { height: clamp(240px, 52vh, 420px); }
}

/* ---- Motion ---- */
@keyframes ps-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ps-spin { to { transform: rotate(360deg); } }
@keyframes ps-float { 0%, 100% { transform: rotate(8deg) translateY(0); } 50% { transform: rotate(4deg) translateY(-6px); } }
@keyframes ps-beam { 0% { top: -70px; } 100% { top: 100%; } }
@keyframes ps-reveal {
    0%, 12% { clip-path: inset(0 100% 0 0); }
    52%, 84% { clip-path: inset(0 0 0 0); }
    96%, 100% { clip-path: inset(0 100% 0 0); }
}
@keyframes ps-wipe {
    0%, 12% { left: 0%; opacity: 0; }
    16% { opacity: 1; }
    52% { left: 100%; opacity: 1; }
    58%, 100% { left: 100%; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ps *, .ps *::before, .ps *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-duration: .01ms !important;
    }
    .ps-demo-img.is-after { clip-path: inset(0 0 0 50%) !important; }
    .ps-demo-wipe, .ps-scan-beam { display: none; }
}
