.project-overlay {
  --page-padding:clamp(36px,4.85vw,90px);
  --portfolio-card-radius:24px;
  --portfolio-media-bottom-radius:34px;
  --ink:#25313A;
  --muted:#50595F;
  --warm:#DFBCA0;
  --button-outline:#52616D;
  --tag-bracket:#50595F;
  --card-shadow:0 20px 48px rgba(37,49,58,.105),0 5px 14px rgba(37,49,58,.055),0 1px 3px rgba(223,188,160,.12);
}

/* Popup-only visual candidates; shared design system and cards unchanged. */
.project-overlay{position:fixed;inset:0;z-index:100;display:none;align-items:flex-start;justify-content:center;background:rgba(20,20,20,.78);padding:var(--space-32);overflow:auto;overscroll-behavior:contain}
.project-overlay.is-open{display:flex}.project-popup{width:min(100%,var(--content-max));background:#f7f4ef;border-radius:var(--portfolio-card-radius);position:relative;isolation:isolate;box-shadow:0 28px 100px #0005;margin:auto 0;overflow:clip}
.project-gallery{--gallery-base:#31363f;--gallery-mid:#424954;--gallery-tail:#5f595d;--gallery-warm:rgba(239,177,126,.24);--gallery-number-glow:rgba(244,186,137,.34);background:radial-gradient(circle at 78% 84%,var(--gallery-number-glow) 0%,rgba(244,186,137,.14) 13%,rgba(244,186,137,0) 28%),linear-gradient(118deg,var(--gallery-base) 0%,var(--gallery-mid) 56%,var(--gallery-tail) 100%);color:#f9f6f1;padding:var(--space-24) var(--space-32) var(--space-20);border-radius:var(--portfolio-card-radius) var(--portfolio-card-radius) var(--portfolio-media-bottom-radius) var(--portfolio-media-bottom-radius);position:relative;overflow:hidden}


.project-gallery[data-bg='hero-slate']{--gallery-base:#2c3945;--gallery-mid:#3b4550;--gallery-tail:#585158;--gallery-warm:rgba(236,182,136,.22);--gallery-number-glow:rgba(244,186,137,.38)}
.project-gallery[data-bg='hero-soft']{--gallery-base:#2d3943;--gallery-mid:#434a53;--gallery-tail:#64595b;--gallery-warm:rgba(228,165,119,.18);--gallery-number-glow:rgba(240,181,131,.28)}
.project-gallery[data-bg='graphite-flat']{--gallery-base:#25282e;--gallery-mid:#31363d;--gallery-tail:#3f444b;--gallery-warm:rgba(232,177,128,.12);--gallery-number-glow:rgba(240,181,131,.24)}
.gallery-top,.gallery-bottom{display:flex;align-items:center;justify-content:space-between;gap:var(--space-12)}.gallery-top{margin-bottom:var(--space-18)}.gallery-bottom{margin-top:var(--space-12);min-height:76px}.gallery-label{font-size:var(--type-label);color:#cdc5bd}.gallery-switch{display:none;gap:4px}.gallery-switch button,.gallery-control,.gallery-skin-switch button{border:0;background:transparent;color:#f7f3ed;cursor:pointer;min-height:44px;padding:0 12px}.gallery-top-main{display:flex;align-items:center;gap:var(--space-12);min-width:0}.gallery-top-side{display:flex;align-items:center;gap:10px;margin-left:auto}.gallery-skin-switch{display:flex;align-items:center;gap:6px;padding:4px;border-radius:999px;background:rgba(255,255,255,.05);box-shadow:inset 0 0 0 1px rgba(255,255,255,.08)}.gallery-skin-switch button{min-height:34px;padding:0 10px;border-radius:999px;font-size:11px;letter-spacing:.02em;color:#bfb8b1}.gallery-skin-switch button[aria-pressed='true']{color:#fff3df;box-shadow:inset 0 0 0 1px rgba(223,188,160,.78);text-shadow:0 0 14px #ffb83f55}.gallery-control{width:44px;padding:0;display:grid;place-items:center;flex-shrink:0;border-radius:50%;transition:color .2s,background .2s}.gallery-control:not(:disabled):hover{color:#ffcf99;background:#ffffff0b}.gallery-control:disabled{opacity:.28;cursor:default}.gallery-control svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.45;stroke-linecap:round;stroke-linejoin:round}.gallery-switch button{font-size:var(--type-label);color:#aaa49d;border-radius:999px}.gallery-switch button[aria-pressed=true]{color:#fff4df;box-shadow:inset 0 0 0 1px #dfbca0; text-shadow:0 0 12px #ffb83f66}.gallery-close{position:relative}.gallery-stage{display:flex;justify-content:center;align-items:center;gap:var(--space-18);width:100%;min-width:0;touch-action:pan-y;overflow:hidden;position:relative}.gallery-stage img{display:block;height:auto;max-width:100%;object-fit:contain;border-radius:4px;box-shadow:0 12px 36px #0005;flex-shrink:0}.gallery-stage img[hidden]{display:none}.gallery-caption{font-size:var(--type-label);color:#cfc7bf;letter-spacing:-.01em}.gallery-nav{display:flex;align-items:center;gap:var(--space-12);margin-left:auto}.gallery-counter{position:relative;display:flex;align-items:baseline;justify-content:center;gap:6px;min-width:132px;padding:12px 17px;isolation:isolate;font-variant-numeric:tabular-nums}.gallery-current{font-size:clamp(42px,3.5vw,56px);font-weight:650;line-height:1;letter-spacing:-.07em;color:#fff3df;display:block;text-shadow:0 0 10px #ffb83f4d,0 0 24px #ff9b5b42,0 0 46px #ff84511a}.gallery-total{font-size:var(--type-label);color:#c8bcb0}.gallery-number-window{display:inline-grid;position:relative;line-height:1;vertical-align:baseline;overflow:visible;min-width:1.15em;font-size:clamp(42px,3.5vw,56px)}.gallery-current{font-size:inherit;grid-area:1/1}.gallery-number-light::after{content:'';position:absolute;inset:-18% -22%;z-index:-1;pointer-events:none;background:radial-gradient(circle,var(--gallery-number-glow) 0%,rgba(244,186,137,.16) 28%,rgba(244,186,137,0) 66%)}
.project-info{color:var(--ink);padding:var(--space-40) var(--space-32);display:grid;grid-template-columns:minmax(280px,.92fr) minmax(0,1.18fr);grid-template-areas:'identity detail' 'link detail';column-gap:var(--space-32);row-gap:var(--space-24);align-items:start}.project-identity{grid-area:identity;display:grid;align-content:start;gap:var(--space-12)}.project-info h2{font-size:var(--type-h3);font-weight:500;line-height:1.15;letter-spacing:-.02em;margin:0 0 var(--space-12)}.project-info p{font-size:var(--type-body);line-height:1.5;color:var(--muted);margin:0}.project-info h3{font-size:var(--type-h4);font-weight:500;margin:0 0 var(--space-12)}.project-detail{grid-area:detail;padding:0}.project-link{grid-area:link;display:inline-flex;align-items:center;gap:12px;color:var(--ink);border:1px solid var(--button-outline);border-radius:999px;padding:16px 22px;white-space:nowrap;text-decoration:none;font-size:var(--type-label);align-self:start;justify-self:start}.project-link svg{width:18px;height:18px}.project-link:hover{background:#eae5dd}.project-link[hidden]{display:none}.project-overlay button:focus-visible,.project-link:focus-visible{outline:2px solid var(--warm);outline-offset:3px}.project-overlay .gallery-switch[hidden],.gallery-nav[hidden]{display:none!important}
@media(max-width:1050px){.project-info{grid-template-columns:1fr 1fr;grid-template-areas:'identity detail' 'link link'}.project-link{justify-self:start}}
@media(max-width:767px){.project-overlay{padding:0}.project-popup{width:100%;min-height:100dvh;margin:0;border-radius:0}.project-gallery{padding:var(--space-18) var(--space-12);border-radius:0 0 28px 28px}.gallery-switch{display:flex}.gallery-skin-switch{display:none}.project-info{padding:var(--space-32) var(--space-22);grid-template-columns:minmax(0,1fr);grid-template-areas:'identity' 'detail' 'link';gap:var(--space-24)}.gallery-label{display:none}.gallery-bottom{min-height:66px}.gallery-nav{gap:4px}.gallery-counter{min-width:100px;padding:10px 12px}.gallery-current{font-size:40px}.gallery-caption{font-size:12px}.gallery-control{width:44px}.project-link{grid-column:auto}}
body[data-mode=mobile] .project-overlay{padding:0}body[data-mode=mobile] .project-popup{width:390px;max-width:100%;min-height:100dvh;margin:0;border-radius:0;--layout-vw:3.9px}body[data-mode=mobile] .project-gallery{padding:var(--space-18) var(--space-12);border-radius:0 0 28px 28px}body[data-mode=mobile] .gallery-switch{display:flex}body[data-mode=mobile] .gallery-skin-switch{display:none}body[data-mode=mobile] .project-info{padding:var(--space-32) var(--space-22);grid-template-columns:minmax(0,1fr);grid-template-areas:'identity' 'detail' 'link';gap:var(--space-24)}body[data-mode=mobile] .gallery-label{display:none}body[data-mode=mobile] .gallery-nav{gap:4px}body[data-mode=mobile] .gallery-counter{min-width:100px;padding:10px 12px}body[data-mode=mobile] .gallery-current{font-size:40px}body[data-mode=mobile] .gallery-caption{font-size:12px}body[data-mode=mobile] .project-link{grid-column:auto}
@media(prefers-reduced-motion:reduce){.gallery-counter *{animation:none!important}.gallery-control{transition:none}}

/* Layout 03.3: sequential gallery motion and local background switch. */
.gallery-counter.is-changing .gallery-current{animation:none}
.gallery-counter{background:transparent}


@media(max-width:767px){.gallery-number-window{font-size:40px}}
body[data-mode=mobile] .gallery-number-window{font-size:40px}

/* 03.4: stage owns geometry; slide changes never resize the media area. */
.gallery-stage{height:73vh;height:73dvh;}
@media(max-width:767px){.gallery-stage{height:67vh;height:67dvh;}}
body[data-mode=mobile] .gallery-stage{height:67vh;height:67dvh;}

/* 03.5: native dialog, one scroll surface, static slide pair. */
.project-overlay{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;border:0;color:inherit;background:transparent;box-sizing:border-box;overflow:auto;overscroll-behavior:contain;display:none;}
.project-overlay[open]{display:flex;}
.project-overlay::backdrop{background:rgba(20,20,20,.78)}
.project-popup{isolation:auto;overflow:visible;flex-shrink:0;}
.project-gallery{overflow:visible;background:radial-gradient(ellipse at 18% 16%,rgba(84,111,136,.152) 0%,transparent 42%),radial-gradient(ellipse at 82% 80%,rgba(228,165,119,.171) 0%,transparent 34%),radial-gradient(circle at 78% 84%,var(--gallery-number-glow) 0%,rgba(244,186,137,.14) 13%,rgba(244,186,137,0) 28%),linear-gradient(118deg,var(--gallery-base),var(--gallery-mid) 56%,var(--gallery-tail));}
.gallery-stage{display:block;overflow:visible;position:static;}
.slide-pair{display:flex;align-items:center;justify-content:center;gap:var(--space-18);width:100%;height:100%;}
.gallery-stage img{box-shadow:none;transform:none;filter:none;animation:none;transition:none;}
.gallery-counter{isolation:auto;}
.gallery-number-light::after{z-index:auto;}
.gallery-current{position:relative;z-index:1;}

/* 03.6: motion scoped to the existing slide pair. */
.gallery-stage.is-moving{overflow:hidden;position:relative;}
.gallery-stage.is-moving .slide-pair img{transition:none;animation:none;}
.gallery-number-window.is-rolling{overflow:hidden;}

/* 03.7 — viewport-height budget, local preview control */
.project-overlay[open]{align-items:flex-start;}
.project-popup{margin:0;}
.project-gallery{display:flex;flex-direction:column;height:80vh;height:80dvh;max-height:80dvh;}
.gallery-top,.gallery-bottom{flex:0 0 auto;}
.gallery-stage{flex:1 1 0;min-height:0;height:auto!important;}
.gallery-bottom{position:relative;}
@media(max-height:420px){.project-gallery{height:340px;max-height:none;}}

/* 03.8 — local polish only. Stable glow outside rolling digit mask. */
.gallery-number-light{display:inline-grid;position:relative;isolation:isolate;vertical-align:baseline;line-height:1;}
.gallery-number-light::after{inset:-45% -55%;z-index:-1;background:radial-gradient(ellipse closest-side,var(--gallery-number-glow) 0%,rgba(244,186,137,.14) 35%,rgba(244,186,137,0) 100%);pointer-events:none;}
.gallery-number-window{z-index:0;}
.gallery-number-window.is-rolling{overflow:hidden;}
.gallery-close{transform:translate(12px,-6px);}
.gallery-close svg{width:30px;height:30px;}
.gallery-nav .gallery-control{transition:color .2s ease,background .2s ease,transform .2s ease;}
.gallery-nav .gallery-control svg{transition:scale .22s cubic-bezier(.2,.7,.25,1),filter .22s ease;}
@media(hover:hover) and (pointer:fine){.gallery-nav .gallery-control:not(:disabled):hover svg{scale:1.17;filter:drop-shadow(0 0 5px #ffb87988);}}
.gallery-nav .gallery-control:not(:disabled):active svg{scale:.91;}
.gallery-nav .gallery-control.is-pressed{opacity:1;color:#ffcf99;}
.gallery-nav .gallery-control.is-pressed svg{animation:gallery-arrow-press 360ms cubic-bezier(.2,.75,.25,1) both;}
@keyframes gallery-arrow-press{0%{scale:1.17}28%{scale:.9}100%{scale:1}}
@media(max-width:767px){.gallery-close{transform:translate(4px,-4px);}.gallery-close svg{width:28px;height:28px;}}
body[data-mode=mobile] .gallery-close{transform:translate(4px,-4px);}
body[data-mode=mobile] .gallery-close svg{width:28px;height:28px;}
@media(prefers-reduced-motion:reduce){.gallery-nav .gallery-control svg{transition:none;animation:none!important;}}


/* CK 2.2.1: identity and detail own the light-surface text color. */
.project-info :is(h2,h3,.tags,.tags li){color:var(--ink)}

/* Corner seam: let the gallery own the upper rounding; keep the outer light background out of its antialiased edge. */
.project-popup{background:transparent;}
.project-info{background:#f7f4ef;border-radius:0 0 var(--portfolio-card-radius) var(--portfolio-card-radius);position:relative;}
.project-gallery{isolation:isolate;}
.project-info::before{content:"";position:absolute;left:0;right:0;top:calc(-1 * var(--portfolio-media-bottom-radius));height:var(--portfolio-media-bottom-radius);background:#f7f4ef;z-index:-1;pointer-events:none;}
.project-gallery{z-index:1;}
.project-info{z-index:0;isolation:isolate;}
@media(max-width:767px){.project-info{border-radius:0;}}
body[data-mode="mobile"] .project-info{border-radius:0;}


.project-overlay .tags{display:flex;flex-wrap:wrap;gap:var(--space-12);padding:0;margin:0;list-style:none}.project-overlay .tags li::before{content:"[ "}.project-overlay .tags li::after{content:" ]"}.project-detail p{white-space:pre-line}.project-overlay .gallery-switch[hidden],.project-overlay .project-link[hidden]{display:none!important}.project-overlay .project-gallery{padding-inline:var(--space-dialog-inset)}.project-overlay .project-info{padding-inline:var(--space-dialog-inset)}@media(max-width:767px){.project-overlay .project-gallery{padding-inline:var(--space-12)}.project-overlay .project-info{padding-inline:var(--space-22)}}