/* App chrome for the Fashion hub (P57: promoted verbatim from nails/styles.css -
   same rules, same order, zero visual change; outfit links this + its own
   slot board; hair converges later). Plum dark theme. */
:root {
  color-scheme: dark; /* native widgets (select, scrollbars) follow the plum theme */
  --bg: #17131f;
  --panel: #221c2e;
  --panel-edge: #3a2f4d;
  --text: #f2eef8;
  --muted: #b7a8cf;
  --accent: #e05c97;
  --accent-soft: #8f6bb0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation; /* no double-tap zoom */
}
main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  max-width: 900px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 1rem 1.2rem;
}

h2 { margin: 0 0 0.8rem; font-size: 1.05rem; }

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.8rem; }

/* P69b: .btn belongs to the photo panel - styled by /platform/photo-panel.css */

.preview-outline {
  border: 2px dashed var(--accent-soft);
  border-radius: 10px;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#source-preview[hidden] { display: none; } /* companion rule — id beats [hidden] (hair CSS trap) */
#source-preview {
  display: block;
  max-width: 100%;
  height: auto;
}

.result-outline { margin-top: 0.8rem; }


.zoom-frame {
  width: 100%;
  max-height: 75vh;
  overflow: auto;
  /* vertical drag = native scroll (frame then page); pinch + horizontal
     pan handled by Viewer; browser pinch-zoom stays disabled */
  touch-action: pan-y;
  scrollbar-width: none;
}

.zoom-frame::-webkit-scrollbar { display: none; }

/* Gallery modal viewer */
.picker.modal {
  width: min(720px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.modal-bar { margin: 0; }
.modal-bar .modal-close { margin-left: auto; }
.modal-frame { flex: none; } /* height locked by Viewer.fitFrame() */

/* Result-only view: the generated image is the layout element. */
.compare:not(.comparing) .compare-before,
.compare:not(.comparing) .compare-divider,
.compare:not(.comparing) .tag { display: none; }

.compare:not(.comparing) .compare-after {
  position: relative;
  clip-path: none;
}

.compare:not(.comparing) .compare-after img {
  position: static;
  height: auto;
  object-fit: contain;
}

.btn.selected { box-shadow: 0 0 0 2px #fff; }
.compare {
  position: relative;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.compare img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.compare-before { position: relative; }

.compare-after {
  position: absolute;
  inset: 0;
  overflow: hidden;
  clip-path: inset(0 0 0 var(--split, 50%));
}


.compare-after img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  margin-left: -1.5px;
  background: #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
  cursor: ew-resize;
}

.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.tag {
  position: absolute;
  top: 0.6rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.tag-before { left: 0.6rem; }
.tag-after { right: 0.6rem; }

.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.6rem; }

.count { color: var(--muted); font-size: 0.85rem; margin: 0.6rem 0 0; }

.swatches { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-bottom: 0.9rem; }

.swatch {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  padding: 0;
}

.swatch.selected { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); }

.swatch-custom {
  background: conic-gradient(
    #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00
  );
  position: relative;
  display: inline-block;
}

.swatch-custom::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
}

/* P68: the old nails picker modal CSS is gone - one shared ColorModal
   lives in /platform/color-picker.css (hair's card, tall rainbow bar) */

.preset-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.9rem; }

.pill {
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.pill.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.shape-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.3rem;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  background: #131019;
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
}

.shape-card img {
  height: 64px;
  width: auto;
  border-radius: 6px;
}

.shape-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  color: var(--text);
}

.spinner {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.4em;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -0.1em;
}

@keyframes spin { to { transform: rotate(360deg); } }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.7rem;
  margin-top: 0.4rem;
}

.gallery-item {
  position: relative;
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--panel-edge);
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
  cursor: pointer;
}

.gallery-del {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  border: none;
  background: #d21f3c;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.gallery-del:active { transform: scale(0.92); }

/* top bar - identical structure to hair's .navbar (user consistency ruling) */
.navbar { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 14px 28px; background: var(--panel); border-bottom: 1px solid var(--panel-edge); }
.navbar h1 { margin: 0; font-size: 22px; }
.homeLink { color: var(--muted); text-decoration: none; }
.homeLink:hover { color: var(--accent); }
.hsep { color: rgba(242, 238, 248, .45); font-weight: 400; } /* P47: parity with hair - was var(--panel-edge), near-invisible on the plum navbar */
.navRight { display: flex; align-items: center; gap: 10px; }


/* legal row - identical to hair's (user request) */
.legalRow { text-align: center; margin-top: 14px; }
.legalRow a { color: var(--muted); text-decoration: none; }
.legalRow a:hover { text-decoration: underline; }

/* mobile top bar - mirrors hair's compact rules EXACTLY (user consistency
   ruling; S21 lesson: keep FULL texts, go compact instead of abbreviating) */
/* P60 (human: "hair fits more content"): hair's compact rhythm at phone
   widths - main padding + grid gap + panel padding step down together. */
@media (max-width: 860px) {
  main { padding: 12px 10px 24px; gap: 12px; }
  .panel { padding: 12px; }
}
@media (max-width: 480px) {
  main { padding: 10px 8px 20px; gap: 10px; }
  .panel { padding: 10px; }
}
@media (max-width: 480px) {
  .navbar { padding: 10px 10px; gap: 6px; flex-wrap: nowrap; }
  .navbar h1 { font-size: 14px; white-space: nowrap; }
  .navRight { gap: 4px; }
  .creditChip { font-size: 11px; white-space: nowrap; }
  .authBox .signInBtn { padding: 5px 7px; font-size: 10px; white-space: nowrap; }
}
@media (max-width: 379px) {
  .navbar { flex-wrap: wrap; }
}

/* ==== hair-anatomy styles ported verbatim (fashion unification) ==== */

button {
  font: inherit; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--ink); cursor: pointer;
}
.num {
  display: inline-flex; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px;
  align-items: center; justify-content: center;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.status { color: var(--muted); font-size: 13px; }
.status.error { color: #dc2626; font-weight: 700; }
.resultBox {
  position: relative;
  min-height: 320px; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: 8px; overflow: hidden; background: #1d1828;
}
.resultBtns { margin-top: 12px; }
.galleryBar { margin-bottom: 12px; }
.galleryGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.shot {
  position: relative; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; background: var(--panel);
}
.shot img { width: 100%; height: 110px; object-fit: cover; display: block; }
.shotMeta {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted); padding: 6px;
}
.shotDel {
  position: absolute; top: 4px; right: 4px; z-index: 2;
  width: 26px; height: 26px; padding: 0; border-radius: 6px;
  background: rgba(255, 255, 255, 0.92); color: #dc2626;
  font-weight: 700; line-height: 1;
}
@property --run { syntax: '<angle>'; initial-value: 0turn; inherits: false; }
.viewZoomBtn:not(:disabled)::before {
  content: "";
  position: absolute; inset: -1.5px; border-radius: 9px; padding: 1.5px;
  /* (1) the white comet - identical to the approved DARK look; (2) a base ring
     colour, TRANSPARENT by default so dark is unchanged. background-color paints
     the padding box, which the mask below clips to the ring band -> the comet
     travels along a faint track. (filter would NOT work here: it applies before
     the mask, so a halo would be cut off.) Light media sets --ringBase. */
  background-image: conic-gradient(from var(--run),
    transparent 0deg 250deg, rgba(255,255,255,.85) 320deg, transparent 360deg);
  background-color: var(--ringBase, transparent);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: runBorder 3.4s linear infinite;
  pointer-events: none;
}

/* ==== CompareSlider mechanics + overlay uncap - ported verbatim from hair ==== */
/* touch-action: pan-y disables BROWSER pinch/double-tap zoom on Blink
   (Chrome/Samsung ignore the meta's user-scalable=no from ~v120). Set on the
   ROOT so it intersects every descendant; vertical scroll (the page must scroll)
   stays allowed. Does NOT harm the in-app zoom: the modal's CompareSlider drives
   its zoom via Pointer Events, which fire regardless of touch-action (its own
   .cmp is touch-action:none, intersected here = still none). iOS is covered by
   the separate gesture* cancel in app.js. Human 2026-10-13: "a proper app does
   not let you zoom the UI" - this is the lock that works on the S23. */
html { touch-action: pan-y; }
.spinner { position: absolute; top: 50%; left: 50%; width: 52px; height: 52px; margin: -26px;
  border: 5px solid rgba(0, 0, 0, .12); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite; }
.resultBox .placeholder { color: var(--muted); }
/* P132: honesty line under the generating spinner. Inside the result box, so it
   disappears with the ghost when the result replaces the content. */
/* live capacity line (top-right, beside the title) */
/* before/after compare slider (element 4) */
/* NO min-height here: with aspect-ratio it forces width = min-height * ratio,
   which for landscape photos exceeds a phone viewport and stretches the whole
   page (the S21 bug). Height comes purely from width x photo aspect. */
.cmp { position: relative; width: 100%; max-height: 70vh; touch-action: none; overflow: hidden; }
/* overflow:hidden: the zoomed stage must not spill past the box - the after
   stage is trimmed by its divider clip-path but the before stage has none,
   so the source photo used to overflow its borders when zoomed (2026-10-08) */
/* zoom stages: outer keeps the divider clip in container space,
   inner carries the pinch/wheel zoom transform (both photos together);
   inner is JS-sized to the BEFORE photo's rendered rect so both photos
   always occupy the exact same area (no peek-through when zoomed) */
.cmpStage { position: absolute; inset: 0; }
.cmpStageInner { position: absolute; transform-origin: 0 0; will-change: transform; }
.cmp img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; }
.cmpAfter { object-fit: fill; }
/* stretches the model's ~0.2% ratio rounding onto the BEFORE frame -> pixel-aligned compare */
.cmpDivider { position: absolute; top: 0; bottom: 0; width: 1.5px; background: #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4); transform: translateX(-50%); cursor: ew-resize; }
.cmpHandle { position: absolute; top: auto; bottom: var(--cmp-bottom, 12px); left: 50%;
  transform: translateX(-50%);
  width: 44px; height: 44px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--border); color: #333;
  cursor: ew-resize;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
.cmpHandle svg { width: 26px; height: 26px; display: block; }
/* The blob IS a <button>, so the global `button:hover:not(:disabled)` (0-2-1)
   OUT-SPECIFIES `.cmpHandle` (0-1-0) and repainted it: gray in light mode, and
   in dark mode #2f2740 while its icon color stayed dark -> a stuck BLACK blob
   after a tap (on touch :hover sticks after release - the ghost-hover trap
   already noted at the top of this file for Download). Same class of bug the
   accent-button note above warns about: carry your own hover rule.
   -webkit-tap-highlight-color removes the mobile tap flash; the press feedback
   is an :active scale instead, which ALWAYS reverts on release (unlike hover). */
.cmpHandle:hover:not(:disabled) { background: #fff; }
.cmpHandle:active { transform: translateX(-50%) scale(0.94); }
.cmpHandle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.cmpBadge { position: absolute; top: 10px; padding: 3px 9px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 11px; font-weight: 600;
  pointer-events: none; }
.cmpBadgeBefore { left: 10px; }
.cmpBadgeAfter { right: 10px; }
/* horizontal split (static in-page result view): line across, after BELOW */
.cmpH .cmpDivider { top: 50%; left: 0; right: 0; bottom: auto; width: auto; height: 1.5px;
  transform: translateY(-50%); cursor: default; }
.cmpH .cmpBadgeAfter { top: auto; bottom: 10px; }
/* static mode: no drag, but the page scrolls through it AND a tap opens the
   interactive compare (human calls 2026-10-08 keep scrolls, 2026-10-10 the tap;
   touch-action pan-y still lets vertical swipes scroll, never fire the tap) */
.cmpStatic { touch-action: pan-y; cursor: zoom-in; }
.cmpStatic .cmpDivider { cursor: zoom-in; }
.cmpStatic:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
/* the compare slider inside the overlay is JS-fitted to the photo
   (CompareSlider fit option) - no 70vh cap here. Selector-scoped (NOT a
   class added after construction): a data-URL slider measures itself
   SYNCHRONOUSLY in the constructor, before any post-add class could land
   -> it sized to the 70vh cap and the photos stuck top-left (2026-10-08) */
#ovTrack .cmp { max-height: none; }

/* accent buttons - hair parity (#id-scoped rules ported; nails' generate) */
#generate { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (hover: hover) { #generate:hover:not(:disabled) { background: #f06fa8; } }
/* #generate:disabled removed — /platform/base.css now carries the global
   button:disabled rule. This page used to style the disabled state ONLY as
   .btn:disabled, and #downloadBtn / .viewZoomBtn / #delSelBtn carry no .btn
   class, so they never greyed out (human report 2026-10-20). */

/* explicit select styling - identical on hair & nails (was: native per-scheme) */
select { font: inherit; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--ink); }

/* ==== ported round 2 (gap audit): preview container + zoom-ring ==== */
/* P69: photo-panel styles moved to /platform/photo-panel.css */
@property --run { syntax: '<angle>'; initial-value: 0turn; inherits: false; }
#downloadBtn, .viewZoomBtn {
  font-weight: 600;
  background: var(--accent); border-color: var(--accent); color: #fff;
  position: relative;
}
@media (hover: hover) { #downloadBtn:hover:not(:disabled), .viewZoomBtn:hover:not(:disabled) { background: #f06fa8; } }
.resultBox img { max-width: 100%; max-height: 70vh; display: block; }
.viewZoomBtn:not(:disabled)::before {
  content: "";
  position: absolute; inset: -1.5px; border-radius: 9px; padding: 1.5px;
  background-image: conic-gradient(from var(--run),
    transparent 0deg 250deg, rgba(255,255,255,.85) 320deg, transparent 360deg);
  background-color: var(--ringBase, transparent);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: runBorder 3.4s linear infinite;
  pointer-events: none;
}
@keyframes runBorder { to { --run: 1turn; } }
@media (prefers-reduced-motion: reduce) { .viewZoomBtn:not(:disabled)::before { animation: none; } }

/* ==== overlay viewer + confirm modal family - ported from hair (gap audit round 3) ==== */
/* display:flex above would override the hidden attribute (same trap as .overlay) */
.pickerOverlay[hidden] { display: none; }
/* overlay viewer */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 12, 16, 0.92);
  display: flex; flex-direction: column; padding: 10px 12px 14px; }
.overlay[hidden] { display: none; }
.ovTop { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ovInfo { color: #fff; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.ovInfo .dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid #666; flex: none; }
.ovTop button, .ovNav { /* was 0.12/0.25 alpha - too faded on the dark overlay (S21, 2026-10-08) */
  background: rgba(255, 255, 255, 0.22); color: #fff; border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; }
.ovTop button { width: 36px; height: 36px; font-size: 16px; line-height: 1; }
.ovMain { position: relative; flex: 1; min-height: 0; display: flex; margin: 8px 0; }
.ovTrack { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
/* the compare slider inside the overlay is JS-fitted to the photo
   (CompareSlider fit option) - no 70vh cap here. Selector-scoped (NOT a
   class added after construction): a data-URL slider measures itself
   SYNCHRONOUSLY in the constructor, before any post-add class could land
   -> it sized to the 70vh cap and the photos stuck top-left (2026-10-08) */
#ovTrack .cmp { max-height: none; }
.ovPlain { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.ovBtns { display: flex; gap: 10px; justify-content: center; margin: 2px 0 10px; }
/* Close = secondary action, same look as the crop modal's Cancel */
.ovCloseBtn { background: #2b2438; border: 1px solid #8f6bb0; color: #fff;
  font-weight: 600; padding: 10px 26px; }
.ovDownload { background: var(--accent); color: #fff;
  border: none; font-weight: 600; padding: 10px 26px; }
@media (hover: hover) {
/* :not(:disabled) REQUIRED - plain .ovCloseBtn:hover (0-2-0) loses to the
     global button:hover:not(:disabled) (0-2-1) -> gray veil on hover (human
     report 2026-10-09) */
  .ovCloseBtn:hover:not(:disabled) { background: #2c313a; border-color: #2c313a; }
}

/* ==== gallery button sizing - ported clean, top level EXACTLY as hair
   (the "on phones" comment in hair's source is stale - both rules sit at
   depth 0 there; computed parity is what matters) ==== */
.galleryBar { flex-wrap: nowrap; gap: 6px; }
.galleryBar button { padding: 8px 8px; font-size: 12px; white-space: nowrap; }

/* ==== ratio-crop parity (p22): guide + adjust button, hair values ==== */


/* P48: 'My own' thumbnail = the user's photo, cropped into the same slot */
.shape-card-own img { width: 48px; height: 64px; object-fit: cover; }
.shape-card-own img[hidden] { display: none; }
