:root {
  --bg: #f7f5f1;
  --card: #ffffff;
  --line: #e5e1d9;
  --line-soft: #ece8df;
  --text: #1d1d1d;
  --muted: #6b6b6b;
  --accent: #1d1d1d;
  --good: #2f8f4d;
  --bad:  #c53030;
  --hint-bg: #faf8f4;
  --avatar-col: 140px;
  --figure-col: 210px;
  --row-h: 160px;
  --head-h: 95px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  overflow: hidden;            /* no vertical page scroll */
  display: flex;
  flex-direction: column;
}

/* View system ------------------------------------------------ */
.view { flex: 1; min-height: 0; }
.view.hidden { display: none; }
#view_explore { overflow-y: auto; overflow-x: hidden; }
.viewnav { margin-right: auto; }   /* push advisor controls to the right */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
  flex-wrap: wrap;
}

header h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.2px;
}

.header-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}
.seg button {
  padding: 5px 12px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.seg button.active { background: var(--accent); color: #fff; }

button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}
button.ghost:hover { color: var(--text); border-color: #c0bcb1; }

/* Layout grid ----------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--figure-col) var(--avatar-col) 1fr;
  grid-template-rows: var(--head-h) var(--row-h) var(--row-h) var(--row-h);
  gap: 10px;
  padding: 12px 22px;
  height: 100%;
  align-items: start;
}

/* Dressed avatar (far-left column) --------------------------- */

.figure {
  grid-column: 1;
  grid-row: 1 / span 4;
  position: relative;
  height: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  --skin: #c69169;
}
.mannequin {
  position: absolute;
  inset: 10px 0;
  width: 100%;
  height: calc(100% - 20px);
  fill: var(--skin);
  opacity: 0.9;
}
/* garment layers are placed on the same 200x600 canvas as the SVG */
.fig-layer {
  position: absolute;
  cursor: pointer;
  --pos: top center;
  display: none;
}
.figure.has-top  .fig-top,
.figure.has-bot  .fig-bot,
.figure.has-full .fig-full,
.figure.has-feet .fig-feet { display: block; }
.fig-top  { left: 15%; top: calc(10px + 15%); width: 70%; height: 32%; }
.fig-bot  { left: 19%; top: calc(10px + 41%); width: 62%; height: 52%; }
.fig-full { left: 13%; top: calc(10px + 15%); width: 74%; height: 78%; }
.fig-feet { left: 25%; top: calc(10px + 88%); width: 50%; height: 10%; }
.fig-layer > img, .fig-layer > .tint { width: 100%; height: 100%; --pos: top center; }
.fig-layer > img { object-fit: contain; object-position: var(--pos); }
.fig-hit-head {
  position: absolute;
  left: 30%; top: 10px; width: 40%; height: 14%;
  cursor: pointer;
}
.fig-empty {
  position: absolute;
  left: 0; right: 0; bottom: 14px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 0 16px;
}
.figure.dressed .fig-empty { display: none; }

/* fitted layers are positioned in px by placeLayer(); the image fills
   the box exactly because the box has the image's aspect ratio */
.fig-layer.fitted > img, .fig-layer.fitted > .tint { --pos: center; }
.fig-layer.fitted .tint > img { object-fit: fill; }
/* height may be stretched independently of width, so the mask must stretch too */
.fig-layer.fitted .tint::before { -webkit-mask-size: 100% 100%; mask-size: 100% 100%; }
.fig-layer .fit-lines { display: none; }
.figure.show-lines .fig-layer .fit-lines { display: block; }
.mannequin .navel { fill: rgba(0,0,0,0.25); }
.mannequin .body-lines { display: none; stroke: rgba(0,0,0,0.35); stroke-dasharray: 3 3; stroke-width: 1; }
.mannequin .body-lines text { fill: rgba(0,0,0,0.5); stroke: none; font-size: 9px; }
.figure.show-lines .mannequin .body-lines { display: inline; }
.fig-tools {
  position: absolute;
  top: 8px; left: 8px; right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  z-index: 2;
}
.fig-tools { flex-wrap: wrap; }
.fig-tools button { padding: 3px 9px; font-size: 11px; }
.fig-model-row { display: flex; gap: 4px; width: 100%; align-items: center; }
.fig-model-row select {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}
.fig-upload {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
}
body.ai-on .fig-upload.ai-only { display: inline-block; }

/* model photo body */
.fig-photo, .fig-body-lines { position: absolute; display: none; }
.figure.photo .fig-photo { display: block; object-fit: fill; cursor: pointer; }
.figure.photo .mannequin, .figure.photo .fig-hit-head, .figure.photo .fig-empty { display: none; }
.figure.photo.show-lines .fig-body-lines { display: block; pointer-events: none; z-index: 1; }
.fig-body-lines svg { width: 100%; height: 100%; overflow: visible; }
.fig-body-lines line { stroke: #f59e0b; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; }
.fig-body-lines line.sole { stroke: #64748b; }
.fig-body-lines circle { fill: #f59e0b; }
.fig-body-lines text { fill: #b45309; font-weight: 600; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.fig-status {
  position: absolute;
  left: 8px; right: 8px; top: 64px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  z-index: 2;
}
.fig-status:empty { display: none; }
.fig-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

/* analysis controls exist only when the dev server has an API key */
.ai-only { display: none; }
body.ai-on .ai-only { display: inline-block; }

/* landmark overlay ------------------------------------------- */
.fit-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
}
.fit-wrap > img { display: block; width: 100%; height: 100%; }
.fit-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.fit-lines line { stroke-width: 2px; vector-effect: non-scaling-stroke; }
.fit-lines text { font-size: 0.045px; font-weight: 600; dominant-baseline: middle; paint-order: stroke; stroke: #fff; stroke-width: 0.012px; }
.fit-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #2563eb;
  opacity: 0.7;
}
.analyze-status { font-size: 12px; color: var(--muted); }
.detail-fit {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.detail-fit:has(.detail-fit-text:empty) { margin-top: 0; }
.fit-legend { display: inline-flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.fit-legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: -6px; }

/* Tinted white cutout: solid colour masked by the PNG, with the PNG's
   shading multiplied on top. --tint is the colour, --img the url(). */
.tint {
  position: relative;
  display: inline-block;
  isolation: isolate;
  --pos: center;
}
.tint::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--tint, #fff);
  -webkit-mask: var(--img) var(--pos) / contain no-repeat;
  mask: var(--img) var(--pos) / contain no-repeat;
}
.tint > img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: var(--pos);
  mix-blend-mode: multiply;
}

/* Avatar zones (left column) -------------------------------- */

.zone {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  transition: border-color 0.15s, background 0.15s;
  height: 100%;
  user-select: none;
  position: relative;
}
.zone:hover { border-color: #b9b3a3; }

.zone-head  { grid-row: 1; }
.zone-torso { grid-row: 2; }
.zone-legs  { grid-row: 3; }
.zone-feet  { grid-row: 4; }

.zone-label {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

.zone-head .head {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #d7b89a;
  border: 2px solid rgba(0,0,0,0.08);
  transition: background 0.2s;
}

.garment {
  width: 110px;
  height: 110px;
  display: none;
}
.garment > img, .garment > .tint { width: 100%; height: 100%; object-fit: contain; }
.zone.has-item .garment { display: block; }
.zone.has-item .placeholder { display: none; }

.placeholder {
  font-size: 13px;
  color: var(--muted);
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 18px 12px;
  text-align: center;
  width: 110px;
}

/* Alternative rows (right column) --------------------------- */

.alt-row-wrap {
  grid-column: 3;
  position: relative;
  height: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

#row_wrap_top    { grid-row: 2; }
#row_wrap_bottom { grid-row: 3; }
#row_wrap_shoes  { grid-row: 4; }
#row_wrap_full   { grid-row: 2 / span 2; }

.zone.disabled,
.alt-row-wrap.disabled {
  opacity: 0.45;
  pointer-events: none;
}
.zone.disabled .placeholder { border-style: dotted; }

.alt-row {
  flex: 1;
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.alt-row::-webkit-scrollbar { height: 4px; }
.alt-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.alt-row-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
  padding: 0 16px;
  text-align: center;
}

/* Alt cards -------------------------------------------------- */

.alt-card {
  flex: 0 0 auto;
  width: 130px;
  border: 1px solid var(--line);
  background: var(--hint-bg);
  border-radius: 12px;
  padding: 6px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: border-color 0.15s, transform 0.05s;
  cursor: pointer;
}
.alt-card:hover { border-color: #b9b3a3; }
.alt-card:active { transform: scale(0.98); }
.alt-card.active {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}

.alt-card .icon {
  width: 60px;
  height: 60px;
  object-fit: contain;
}
.alt-card .name {
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
}
.alt-card .formality {
  font-size: 10px;
  color: var(--muted);
}

.alt-palette {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
  justify-content: center;
  margin-top: 4px;
}

.alt-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.1s;
  position: relative;
  flex-shrink: 0;
}
.alt-swatch:hover { transform: scale(1.2); }
.alt-swatch.harmonizes::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 6px;
  border: 1.5px solid var(--good);
  pointer-events: none;
}

/* Sheet (picker) -------------------------------------------- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.sheet.hidden { display: none; }

.sheet-card {
  width: 100%;
  max-width: 720px;
  background: #fff;
  border-radius: 18px 18px 0 0;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.18s ease-out;
}
@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0.6; }
  to   { transform: translateY(0); opacity: 1; }
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.sheet-title { flex: 1; font-weight: 600; text-align: center; }
.sheet-body { padding: 14px; overflow-y: auto; }

/* type grid -------------------------------------------------- */

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.type-cell {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--hint-bg);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}
.type-cell:hover { border-color: #b9b3a3; }
.type-cell > img, .type-cell > .tint { width: 64px; height: 64px; }
.type-cell .name { font-size: 12px; line-height: 1.2; }
.type-cell.recommended {
  border-color: var(--good);
  box-shadow: 0 0 0 2px rgba(47,143,77,0.12);
}
.type-cell .badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--good);
  color: #fff;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* color grid ------------------------------------------------- */

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px;
}
.color-cell {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  background: var(--hint-bg);
}
.color-cell:hover { background: #f0ece2; }
.color-cell .chip {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.12);
  margin-bottom: 4px;
}
.color-cell .name { font-size: 11px; color: var(--muted); }
.color-cell.good   { border-color: var(--good); }
.color-cell.avoid  { opacity: 0.45; border-color: var(--bad); }
.color-cell.harmonizes { box-shadow: 0 0 0 3px rgba(47,143,77,0.18); }
.color-cell .flag {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--good);
  margin-top: 2px;
}
.color-cell.avoid .flag { color: var(--bad); }

/* skin tone picker ------------------------------------------- */

.skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.skin-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  cursor: pointer;
  background: var(--hint-bg);
}
.skin-cell:hover { border-color: #b9b3a3; }
.skin-cell .chip {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1);
}
.skin-cell .text { flex: 1; }
.skin-cell .text .label { font-size: 13px; font-weight: 500; }
.skin-cell .text .desc  { font-size: 11px; color: var(--muted); }
.skin-cell.selected { border-color: var(--accent); background: #fff; }

/* ===========================================================
   EXPLORE VIEW
   =========================================================== */
#view_explore { padding: 0 0 60px; }

.explore-intro {
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 22px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
}
.explore-intro-text { flex: 1 1 420px; }

/* library (image list) picker */
.list-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.list-pick select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23777' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  border-radius: 999px;
  padding: 6px 30px 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #222);
  cursor: pointer;
}
.list-pick select:hover { border-color: var(--accent); }
.list-pick select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* catalogs with background-removed cutouts: show the whole garment */
.cutout .card-img,
.cutout .detail-img { padding: 9%; }

/* Images sit in a .fit-wrap sized to the image's own aspect (--a, set
   once fit data exists) so landmark overlays line up with the pixels.
   The containers are size containers so the wrap can fit inside them. */
.card-img, .detail-img { container-type: size; }
.detail-img { min-height: 380px; }
.card-img .fit-wrap, .detail-img .fit-wrap {
  --a: 1;
  width: min(100cqw, 100cqh * var(--a));
  height: auto;
  aspect-ratio: var(--a);
}
.card-img .fit-wrap > img, .detail-img .fit-wrap > img { object-fit: cover; }
.cutout .fit-wrap > img { object-fit: contain !important; }
.fit-wrap.known > img { object-fit: fill !important; }
.explore-intro h2 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: -0.4px;
}
.explore-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 680px;
}

/* category tabs */
.cat-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 22px;
  background: rgba(247,245,241,0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line-soft);
  scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.cat-tab:hover { border-color: #b9b3a3; color: var(--text); }
.cat-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.cat-count {
  font-size: 11px;
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 600;
}
.cat-tab.active .cat-count { background: rgba(255,255,255,0.22); color: #fff; }

/* toolbar */
.explore-toolbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 22px 6px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}
.search-ico {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
  pointer-events: none;
}
#explore_search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px 9px 34px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}
#explore_search:focus { border-color: #b9b3a3; }
#filter_toggle { display: none; }   /* shown on mobile */

/* body: filters + results */
.explore-body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 22px 0;
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 22px;
  align-items: start;
}

.filters {
  position: sticky;
  top: 64px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.filter-group { }
.filter-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.chip:hover { border-color: #b9b3a3; }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip-count { font-size: 10px; color: var(--muted); }
.chip.on .chip-count { color: rgba(255,255,255,0.7); }
.filter-empty { color: var(--muted); font-size: 13px; font-style: italic; }

/* results head */
.results-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
#results_count { font-size: 13px; color: var(--muted); font-weight: 500; }
.active-pills { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.active-pill {
  border: 1px solid var(--accent);
  background: #fff;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.active-pill span { color: var(--muted); font-size: 10px; }
.active-pill:hover { background: var(--bg); }
.clear-btn.hidden { display: none; }

/* card grid */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px;
}
.cards.hidden { display: none; }
.card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  transition: border-color .15s, box-shadow .15s;
  font: inherit;
  color: inherit;
}
.card:hover { border-color: #b9b3a3; box-shadow: 0 6px 20px rgba(0,0,0,0.06); }
.card-img {
  aspect-ratio: 1 / 1;
  background: var(--hint-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 10px 12px 12px; }
.card-name { font-size: 14px; font-weight: 600; line-height: 1.25; }
.card-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.card-chips span {
  font-size: 10px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 2px 6px;
  text-transform: capitalize;
}

/* empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state.hidden { display: none; }
.empty-state p { margin: 0 0 14px; font-size: 15px; }

/* ===========================================================
   DETAIL MODAL
   =========================================================== */
.detail {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.detail.hidden { display: none; }
.detail-card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  animation: slide-up .18s ease-out;
}
.detail-close {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 2;
  width: 32px; height: 32px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
}
.detail-img {
  background: var(--hint-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-img img { width: 100%; height: 100%; object-fit: cover; }
.detail-info {
  padding: 26px 26px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.detail-cat {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  font-weight: 600;
}
.detail-info h3 { margin: 4px 0 10px; font-size: 24px; letter-spacing: -0.3px; }
.detail-info p { margin: 0 0 18px; color: var(--text); font-size: 14px; line-height: 1.5; }
.detail-tags { display: flex; flex-direction: column; gap: 12px; }
.dtag-group { display: flex; gap: 10px; align-items: baseline; }
.dtag-label {
  flex: 0 0 74px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  padding-top: 3px;
}
.dtag-vals { display: flex; flex-wrap: wrap; gap: 6px; }
.dtag {
  border: 1px solid var(--line);
  background: var(--hint-bg);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.dtag:hover { border-color: var(--accent); background: #fff; }
.detail-nav { margin-top: auto; padding-top: 20px; display: flex; justify-content: space-between; gap: 10px; }

/* ===========================================================
   RESPONSIVE
   =========================================================== */
@media (max-width: 720px) {
  .explore-body { grid-template-columns: 1fr; }
  #filter_toggle { display: inline-block; }
  .filters {
    position: static;
    display: none;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    margin-bottom: 6px;
  }
  .filters.open { display: flex; }
  .detail-card {
    grid-template-columns: 1fr;
    grid-template-rows: 44vh auto;
    max-height: 90vh;
  }
  .detail-info { max-height: 46vh; }
  .explore-intro h2 { font-size: 22px; }
}

/* ---- signed-in user (Worker deploy) ---- */
.auth-box { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: #666; margin-left: auto; }
.auth-box:empty { display: none; }
.auth-box img { width: 22px; height: 22px; border-radius: 50%; }
.auth-box span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-box a.ghost { text-decoration: none; padding: 4px 8px; }

/* =============================================================
   App bar (brand, tabs, sign-in) + signed-out landing
   ============================================================= */
header { position: relative; z-index: 20; }
header .brand { display: flex; align-items: center; gap: 10px; }
header .brand .logo { width: 30px; height: 30px; border-radius: 8px; flex: none; }
header .brand em { font-style: normal; font-weight: 500; color: var(--muted); }
header .spacer { flex: 1; }
.viewnav { margin-right: 0; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: inherit; font-size: 13px; color: var(--text); text-decoration: none;
  background: #fff; border: 1px solid var(--line);
}
.btn:hover { border-color: #c0bcb1; background: var(--hint-bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #333; border-color: #333; }
.btn .gicon { width: 16px; height: 16px; flex: none; }
.btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

/* who is signed in (Worker only) */
.auth-box { position: relative; display: flex; align-items: center; gap: 8px; }
.auth-box:empty { display: none; }
.avatar {
  width: 34px; height: 34px; padding: 0; border-radius: 50%; cursor: pointer; overflow: hidden;
  border: 1px solid var(--line); background: var(--hint-bg); color: var(--text);
  font: 600 13px/1 inherit; display: inline-flex; align-items: center; justify-content: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar:hover { border-color: #c0bcb1; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.10); z-index: 30;
}
.menu[hidden] { display: none; }
.menu .who { padding: 8px 10px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; word-break: break-all; }
.menu .who b { display: block; color: var(--text); font-size: 13px; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 8px; font: inherit; font-size: 13px; color: var(--text); text-decoration: none; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--hint-bg); }

/* signed-in / signed-out switching (set by fit.js once /api/me answers) */
body:not(.auth-known) .view, body:not(.auth-known) .landing, body:not(.auth-known) .app-only { display: none !important; }
body.auth-known:not(.signed-in) .view, body.auth-known:not(.signed-in) .app-only { display: none !important; }
body.signed-in .landing { display: none !important; }

/* ---- landing ---- */
.landing { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.landing-inner { max-width: 1160px; margin: 0 auto; padding: 0 24px 28px; }
.hero-grid {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px; align-items: center;
  min-height: calc(100svh - 57px); padding: 2.5vh 0;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px; font-size: clamp(12px, 1.8vh, 14px);
  background: #fff; border: 1px solid var(--line); color: var(--muted);
}
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #c98a9a; box-shadow: 0 0 8px #c98a9a; }
.hero-title { font-size: clamp(34px, min(5.4vw, 9vh), 72px); line-height: 1.04; letter-spacing: -0.025em; margin: 2.2vh 0 1.8vh; font-weight: 700; }
.grad { background: linear-gradient(92deg, #c98a9a, #8a3b4a 50%, #4a5f8a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: clamp(16px, 2.6vh, 20px); line-height: 1.55; color: var(--muted); max-width: 32em; margin: 0 0 3.2vh; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.cta .btn { padding: 12px 24px; font-size: clamp(14px, 2.2vh, 16px); }
.fine { font-size: clamp(12px, 1.8vh, 14px); color: var(--muted); margin-top: 2.4vh; display: flex; gap: 8px; align-items: flex-start; }
.auth-error {
  margin-top: 16px; padding: 10px 14px; border-radius: 10px; font-size: 13px;
  color: #b42318; background: #fef3f2; border: 1px solid #fecdca;
}
.auth-error.hidden { display: none; }

/* the dressing-room card: mannequin + tinted cutouts, cycling through outfits */
.dressing-room {
  position: relative; margin: 0 auto;
  height: min(640px, calc(100svh - 57px - 5vh - 40px)); aspect-ratio: 3 / 4;
  border-radius: 28px; overflow: hidden;
  background: linear-gradient(180deg, #ffffff, #f1ede4);
  border: 1px solid var(--line);
  box-shadow: 0 30px 70px rgba(60, 40, 30, 0.14);
}
.dressing-room .mannequin { position: absolute; left: 50%; top: 4%; height: 92%; transform: translateX(-50%); }
.dressing-room .mannequin path, .dressing-room .mannequin rect, .dressing-room .mannequin circle, .dressing-room .mannequin ellipse { fill: #d9c5b2; }
.dressing-room .mannequin circle:first-child { fill: #d9c5b2; }
.outfit { position: absolute; inset: 0; opacity: 0; transition: opacity 0.7s ease; }
.outfit.on { opacity: 1; }
.outfit .piece { position: absolute; left: 50%; transform: translateX(-50%); }
.outfit .piece .tint, .outfit .piece .tint > img { width: 100%; height: 100%; --pos: top center; }
.outfit .top    { top: 15.5%; height: 26%; width: 62%; }
.outfit .bottom { top: 32%;   height: 56%; width: 48%; }
.outfit .full   { top: 15.5%; height: 70%; width: 58%; }
.outfit .outer  { top: 15%;   height: 30%; width: 70%; }
.room-chip {
  position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%);
  padding: 7px 14px; border-radius: 999px; font-size: 12px; white-space: nowrap;
  background: rgba(255,255,255,0.86); border: 1px solid var(--line); backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.room-chip b { color: var(--good); }
.room-line { position: absolute; border-top: 1px dashed rgba(37, 99, 235, 0.55); pointer-events: none; }
.room-line span { position: absolute; right: 0; top: -1.3em; font-size: 10px; color: #2563eb; opacity: 0.8; white-space: nowrap; }
.hero-dots { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.hero-dots button {
  width: 8px; height: 8px; padding: 0; border-radius: 999px; cursor: pointer;
  background: #d6d1c7; border: 0; transition: width 0.3s, background 0.3s;
}
.hero-dots button.on { width: 22px; background: var(--accent); }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 2vh; }
.step { padding: 20px; border-radius: 18px; background: #fff; border: 1px solid var(--line); }
.step .n {
  width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; background: var(--hint-bg); border: 1.5px solid var(--accent); margin-bottom: 10px;
}
.step h3 { margin: 0 0 6px; font-size: 16px; }
.step p { margin: 0; font-size: 14px; color: var(--muted); }
.landing-foot { margin-top: 28px; text-align: center; font-size: 13px; color: var(--muted); }
.landing-foot a { color: inherit; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 32px; min-height: 0; padding: 4vh 0 0; }
  .hero-title { font-size: clamp(32px, 8.5vw, 52px); }
  .dressing-room { height: auto; width: min(320px, 80vw); }
  .steps { grid-template-columns: repeat(2, 1fr); margin-top: 6vh; }
}
@media (max-width: 520px) {
  .steps { grid-template-columns: 1fr; }
  .cta .btn { width: 100%; justify-content: center; }
  header .brand span { display: none; }
  .landing-inner { padding: 0 16px 24px; }
}
