@font-face {
  font-family: 'Bodoni Moda';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/bodoni-moda-latin.woff2) format('woff2');
}
@font-face {
  font-family: 'Bodoni Moda';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/bodoni-moda-latin-italic.woff2) format('woff2');
}

/* Layout: phone = one scrolling column above a bottom tab bar; 900px and up = sidebar + wide content.
   Clothes always sit on a lit grey "studio" surface, in dark mode too, so black pieces stay visible. */
:root {
  --bg: #edeff2;
  --surface: #ffffff;
  --raised: #f6f7f9;
  --ink: #16171b;
  --muted: #5d626c;
  --line: #d6dae0;
  --chip: #e2e5ea;
  --accent: #7a1f2e;
  --accent-ink: #ffffff;
  --accent-soft: #f4e5e8;
  --studio: #e2e4e8;
  --studio-glow: #f8f9fa;
  --studio-edge: #c9cdd4;
  --tag: #f7f4ee;
  --dot-ring: rgba(0, 0, 0, 0.2);
  --danger: #b3261e;
  --scrim: rgba(12, 12, 16, 0.42);
  --shadow: 0 1px 2px rgba(22, 23, 27, 0.06), 0 10px 28px rgba(22, 23, 27, 0.09);
  --piece-shadow: drop-shadow(0 6px 8px rgba(30, 32, 40, 0.18));

  --display: 'Bodoni Moda', 'New York', ui-serif, Georgia, serif;
  --body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  --gutter: 16px;
  --radius: 14px;
  --tabbar: 62px;
  --tile-w: 132px;
  --tile-h: 150px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111216;
    --surface: #1b1d22;
    --raised: #22252b;
    --ink: #f1f2f4;
    --muted: #a3a8b2;
    --line: #2e3138;
    --chip: #272a31;
    --accent: #e48896;
    --accent-ink: #26090f;
    --accent-soft: #3b2128;
    --studio: #aeb2ba;
    --studio-glow: #cbced4;
    --studio-edge: #8e939c;
    --tag: #2a2c32;
    --dot-ring: rgba(255, 255, 255, 0.35);
    --danger: #ff8a80;
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.35);
    --piece-shadow: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.28));
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.locked { overflow: hidden; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: 0.4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.tight { gap: 6px; flex-wrap: nowrap; }

/* ---------- Shell ---------- */

main {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 28px);
}
.view {
  display: none;
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-block: 14px 0;
}
.view.active { display: block; animation: rise 0.25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.tabs {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(18px);
  backdrop-filter: saturate(1.5) blur(18px);
  border-top: 1px solid var(--line);
}
.brand { display: none; }
.tabs a {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.tabs a[aria-current] { color: var(--accent); }
.tabs a[aria-current] .i { stroke-width: 2; }
.tab-add {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: -14px 6px 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
}
.tab-add .i { width: 26px; height: 26px; stroke-width: 2; }
.tab-add span { display: none; }

/* ---------- Type ---------- */

.vh {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.wordmark, .title {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.wordmark { font-size: clamp(2.6rem, 11vw, 3.6rem); }
.title { font-size: clamp(2.2rem, 9vw, 3rem); }
.meta {
  margin: 8px 0 0;
  font: 500 0.7rem/1.3 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
h2, h3 { text-wrap: balance; }

/* ---------- Buttons and controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
}
.btn .i { width: 19px; height: 19px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn.danger-text { color: var(--danger); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; }
.btn.fav[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn.fav[aria-pressed="true"] .i { fill: currentColor; }
.head-add { display: none; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}
.icon-btn:hover:not(:disabled) { background: var(--chip); }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--chip);
  max-width: 100%;
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg .count { font: 500 0.72rem var(--mono); opacity: 0.75; }
.seg.scroll { overflow-x: auto; scrollbar-width: none; }
.seg.scroll::-webkit-scrollbar { display: none; }
.seg .i { width: 18px; height: 18px; }

.field { display: grid; gap: 7px; margin-top: 16px; }
.field > span { font-weight: 600; font-size: 0.9rem; }
.field small, .slider small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raised);
  font-size: 1rem;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: center; margin-top: 12px; font-size: 0.93rem; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--dot-ring);
  flex: none;
}
.dot.pattern { background: repeating-linear-gradient(0deg, #1f2a46 0 3px, #f5f5f2 3px 6px); }

.colours {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
}
.colour-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px 6px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
  white-space: nowrap;
}
.colour-chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 600; }

/* ---------- Wardrobe ---------- */

.filters { display: grid; gap: 10px; margin-bottom: 6px; }
.dots { display: flex; gap: 4px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.dots::-webkit-scrollbar { display: none; }
.dot-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}
.dot-btn .dot { width: 20px; height: 20px; }
.dot-btn .i { width: 20px; height: 20px; }
.dot-btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--ink); color: var(--accent); }
.dot-btn.fav-filter[aria-pressed="true"] .i { fill: currentColor; }
.filter-note { margin: 4px 0 0; font-size: 0.9rem; color: var(--muted); }

.rack { margin-top: 26px; }
.rack-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.rack-head h2 { margin: 0; font: italic 600 1.75rem/1 var(--display); letter-spacing: -0.01em; }
.rack-head .count { font: 500 0.75rem var(--mono); color: var(--muted); letter-spacing: 0.06em; }
.rack-head .see { margin-left: auto; font-size: 0.9rem; }

/* The rail: a fixed rod the hangers hook over while the clothes slide along it. */
.rack-body { position: relative; margin-inline: calc(-1 * var(--gutter)); }
.rack-body::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 14px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(var(--studio-glow), var(--studio-edge));
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}
.shelf .rack-body::before {
  top: calc(12px + var(--tile-h));
  height: 6px;
  border-radius: 2px;
}
.rail {
  position: relative;
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--gutter);
  padding: 8px var(--gutter) 6px;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail .card { width: var(--tile-w); flex: none; scroll-snap-align: start; }

.card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  min-width: 0;
}
.hanger {
  display: block;
  width: 78%;
  height: auto;
  margin: 0 auto -2px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  position: relative;
  z-index: 1;
}
.tile {
  position: relative;
  display: grid;
  place-items: center;
  height: var(--tile-h);
  border-radius: 12px;
  background: radial-gradient(120% 90% at 50% 28%, var(--studio-glow), var(--studio));
  overflow: hidden;
}
.tile img {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
  max-width: none;
  object-fit: contain;
  filter: var(--piece-shadow);
}
.tile.hung { border-radius: 6px 6px 12px 12px; }
.tile.hung img { inset: 6px 7% 7%; width: 86%; height: calc(93% - 6px); object-position: 50% 0; }
.tile.photo img { inset: 0; width: 100%; height: 100%; object-fit: cover; filter: none; }
.tile img.missing { visibility: hidden; }
.tile.ghost {
  place-items: center;
  align-content: center;
  gap: 6px;
  background: transparent;
  border: 1.5px dashed var(--studio-edge);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  padding: 10px;
}
.card .cap { display: grid; gap: 1px; padding: 8px 2px 0; min-width: 0; }
.card .name { font-size: 0.92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .no { font: 500 0.68rem var(--mono); color: var(--muted); letter-spacing: 0.06em; }
.badge {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.badge .i { width: 13px; height: 13px; fill: currentColor; stroke-width: 1.5; }
.card .no .sample { margin-left: 6px; padding: 1px 5px; border-radius: 4px; background: var(--chip); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.6rem; }

.grid-section { margin-top: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
.grid .tile { height: auto; aspect-ratio: 4 / 5; max-width: 100%; }

.nudge {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.nudge p { margin: 0; font-size: 0.92rem; }

.empty { max-width: 560px; padding: 28px 0 8px; }
.empty h2 { margin: 0 0 8px; font: italic 600 1.9rem/1.1 var(--display); }
.empty p { margin: 0 0 18px; color: var(--muted); max-width: 60ch; }
.tips {
  margin-top: 26px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.tips h3 { margin: 0 0 6px; font: 600 0.72rem var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.tips ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 0.93rem; }

/* ---------- Style board ---------- */

.stage {
  position: relative;
  aspect-ratio: 3 / 4;
  max-width: 100%;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(70% 18% at 50% 98%, rgba(0, 0, 0, 0.08), transparent 70%),
    radial-gradient(90% 70% at 50% 32%, var(--studio-glow), var(--studio) 80%);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.stage img.piece {
  position: absolute;
  object-fit: fill;
  filter: var(--piece-shadow);
  transition: left 0.3s ease, top 0.3s ease, width 0.3s ease, height 0.3s ease;
  -webkit-user-drag: none;
  pointer-events: none;
}
.stage img.piece.photo { border-radius: 4%; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); filter: none; }
.stage.mini img.piece { filter: drop-shadow(0 2px 3px rgba(30, 32, 40, 0.18)); transition: none; }
.stage.big { cursor: grab; }

.style-grid { display: grid; gap: 18px; }
.stage-wrap { display: grid; gap: 8px; justify-items: center; }
.stage-wrap .stage { width: min(100%, 62dvh); }
.hint { margin: 0; font-size: 0.82rem; color: var(--muted); text-align: center; }
.style-side { display: grid; gap: 14px; align-content: start; }
.slots { display: grid; gap: 8px; }
.slot-row {
  display: grid;
  grid-template-columns: 76px 40px minmax(0, 1fr) 40px 40px;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 6px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.slot-row.empty-slot { grid-template-columns: 76px minmax(0, 1fr); }
.slot-label { font: 600 0.66rem var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.slot-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}
.slot-pick:hover { background: var(--raised); }
.slot-thumb {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 8px;
  object-fit: contain;
  background: radial-gradient(var(--studio-glow), var(--studio));
  padding: 3px;
}
.slot-thumb.none { display: block; background: transparent; border: 1.5px dashed var(--studio-edge); }
.slot-name { font-weight: 600; font-size: 0.93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lock[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.slot-add { display: inline-flex; align-items: center; gap: 8px; justify-self: start; padding: 8px 10px; border: 0; background: none; color: var(--accent); font-weight: 600; }
.slot-add .i { width: 18px; height: 18px; }
.style-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.style-actions .btn { min-height: 48px; }

/* ---------- Outfits ---------- */

.look-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
.look-card { display: grid; gap: 0; padding: 0; border: 0; background: none; text-align: left; min-width: 0; }
.look-card .stage { border-radius: 14px; }
.look-card .cap { display: grid; padding: 8px 2px 0; min-width: 0; }
.look-card .name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.look-card .no { font: 500 0.68rem var(--mono); color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.look-big .stage { width: min(100%, 52dvh); margin: 0 auto; }
.look-pieces { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.look-piece { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; min-width: 0; }
.look-piece .tile { width: 48px; height: 48px; flex: none; border-radius: 8px; }
.look-piece span:last-child { display: grid; min-width: 0; }
.look-piece strong { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.look-piece small { color: var(--muted); font-size: 0.78rem; }

/* ---------- More ---------- */

.panel {
  margin-top: 14px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  max-width: 720px;
}
.panel h2 { margin: 0 0 8px; font: italic 600 1.45rem/1.15 var(--display); }
.panel p { margin: 0 0 10px; max-width: 64ch; }
.panel .row { margin-top: 8px; }
.steps { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 4px; }
.facts { margin: 0; display: grid; gap: 8px; }
.facts div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.backup-area { margin: 6px 0 10px; }
.ready { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-weight: 600; }
.ready .i { color: var(--accent); }
.danger-zone h2 { color: var(--danger); }
.colophon { max-width: 720px; margin-top: 18px; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; }

/* ---------- Dialogs ---------- */

dialog {
  border: 0;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  overscroll-behavior: contain;
}
dialog::backdrop { background: var(--scrim); }
dialog.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 6px 18px calc(22px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  overflow-y: auto;
}
dialog.sheet[open] { animation: sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
dialog.small {
  width: min(92vw, 400px);
  margin: auto;
  padding: 20px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
dialog.full {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  background: var(--bg);
}
.sheet-head {
  position: sticky;
  top: -6px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 -18px 6px;
  padding: 10px 10px 8px 18px;
  background: var(--surface);
}
.sheet-head h2 { margin: 0; font: italic 600 1.5rem/1.1 var(--display); min-width: 0; overflow-wrap: anywhere; }
.small-title { margin: 0 0 8px; font: italic 600 1.4rem/1.15 var(--display); }
.small-body { margin: 0 0 4px; color: var(--muted); }
.small-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.add-options { display: grid; gap: 8px; }
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raised);
  text-align: left;
}
.option .i { width: 26px; height: 26px; color: var(--accent); }
.option span { display: grid; }
.option small { color: var(--muted); font-size: 0.84rem; }
#add .tips { background: var(--raised); }

.piece-hero {
  display: grid;
  place-items: center;
  height: min(46dvh, 380px);
  padding: 18px;
  border-radius: 18px;
  background: radial-gradient(90% 80% at 50% 35%, var(--studio-glow), var(--studio));
}
.piece-hero img { max-height: 100%; object-fit: contain; filter: var(--piece-shadow); }
.piece-hero.photo { padding: 0; overflow: hidden; }
.piece-hero.photo img { width: 100%; height: 100%; object-fit: cover; filter: none; }

/* The hang tag: a card with clipped corners and a punched hole, like the one on new clothes. */
.tag {
  position: relative;
  display: grid;
  gap: 10px;
  margin: 16px 0 6px;
  padding: 14px 18px 14px 44px;
  background: var(--tag);
  clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
  border-radius: 0 10px 10px 0;
}
.tag-hole {
  position: absolute;
  left: 15px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}
.tag-no { font: italic 600 1.6rem/1 var(--display); white-space: nowrap; }
.tag dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
@media (min-width: 520px) { .tag dl { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tag dt { font: 600 0.62rem var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.tag dd { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 0.92rem; font-weight: 600; }
.tag dd .dot { width: 14px; height: 14px; }
.actions { margin-top: 16px; }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; padding-bottom: 6px; }
.pick-card { display: grid; gap: 6px; padding: 0; border: 0; background: none; text-align: left; min-width: 0; }
.pick-card .tile { height: auto; aspect-ratio: 1; border-radius: 12px; }
.pick-card[aria-pressed="true"] .tile { box-shadow: inset 0 0 0 2.5px var(--accent); }
.pick-card .tile.none { background: var(--raised); border: 1.5px dashed var(--studio-edge); color: var(--muted); font-weight: 600; }
.pick-name { font-size: 0.86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Editor ---------- */

.ed { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.ed-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.ed-bar > :first-child { justify-self: start; }
.ed-bar > :last-child { justify-self: end; }
.ed-title { text-align: center; }
.ed-title h2 { margin: 0; font: italic 600 1.3rem/1.1 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-title .meta { margin: 2px 0 0; }
.ed-body {
  overflow-y: auto;
  display: grid;
  grid-auto-rows: max-content;
  gap: 16px;
  align-content: start;
  padding: 14px max(var(--gutter), env(safe-area-inset-left, 0px)) calc(28px + env(safe-area-inset-bottom, 0px));
}
.ed-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 12px;
  border-radius: 18px;
  background: var(--studio);
  overflow: hidden;
}
.ed-canvas {
  display: block;
  max-width: 100%;
  max-height: 48dvh;
  width: auto;
  height: auto;
  touch-action: none;
  border-radius: 6px;
  background: repeating-conic-gradient(var(--studio-glow) 0 25%, var(--studio) 0 50%) 0 0 / 22px 22px;
  cursor: crosshair;
}
.ed-stage.whole .ed-canvas { cursor: default; }
.ed-ring {
  position: absolute;
  pointer-events: none;
  border: 1.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.ed-busy, .ed-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 600;
}
.ed-busy {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--studio) 70%, transparent);
  color: #16171b;
}
.ed-loading { height: 100%; padding: 24px; text-align: center; color: var(--muted); }
.ed-loading p { max-width: 40ch; color: var(--ink); }
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ed-msg { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 0.9rem; }
.ed-msg:empty { display: none; }
.ed-panel { display: grid; gap: 14px; align-content: start; min-width: 0; }
.ed-group { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.ed-group h3 { margin: 0 0 10px; font: 600 0.7rem var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.ed-group.off { opacity: 0.5; }
.ed-group .check:first-child { margin-top: 0; }
.slider { display: grid; gap: 6px; margin-top: 14px; font-weight: 600; font-size: 0.9rem; }
.seg.tools button { padding: 8px 11px; }
.seg.cats { display: flex; flex-wrap: wrap; border-radius: 16px; }
.seg.cats button { flex: 1 1 auto; justify-content: center; }
.btn.icon-text { min-height: 40px; padding: 8px 14px; }

/* ---------- Toast, drop veil ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 100;
  max-width: min(92vw, 460px);
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#drop-veil {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border: 3px dashed var(--accent);
  pointer-events: none;
}
#drop-veil p { padding: 14px 22px; border-radius: 999px; background: var(--surface); font-weight: 700; box-shadow: var(--shadow); }
.noscript { padding: 24px; }

/* ---------- Wider screens ---------- */

@media (max-width: 430px) {
  .seg.scroll button { padding: 7px 9px; gap: 4px; font-size: 0.85rem; }
  .ed-bar .btn { padding-inline: 12px; }
}

@media (min-width: 700px) {
  :root { --gutter: 24px; --tile-w: 150px; --tile-h: 172px; }
  dialog.sheet { margin: auto; border-radius: 22px; max-height: 88dvh; padding-bottom: 22px; }
  .style-grid { grid-template-columns: minmax(0, 1.1fr) minmax(300px, 1fr); align-items: start; }
  .stage-wrap .stage { width: 100%; }
  .ed-body { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); align-items: start; }
  .ed-stage { position: sticky; top: 0; min-height: calc(100dvh - 120px); }
  .ed-canvas { max-height: calc(100dvh - 150px); }
}

@media (min-width: 900px) {
  :root { --gutter: 32px; }
  .app { display: grid; grid-template-columns: 228px minmax(0, 1fr); }
  main { padding-bottom: 48px; }
  .tabs {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 2px;
    padding: 28px 14px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: var(--surface);
  }
  .brand {
    display: block;
    order: 0;
    padding: 0 10px 22px;
    font: italic 600 1.9rem/1 var(--display);
    letter-spacing: -0.01em;
  }
  .tabs a {
    order: 2;
    flex: none;
    flex-direction: row;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
  }
  .tabs a:hover { background: var(--raised); }
  .tabs a[aria-current] { background: var(--accent-soft); color: var(--accent); }
  .tab-add {
    order: 1;
    display: flex;
    gap: 8px;
    width: auto;
    height: 44px;
    margin: 0 0 18px;
    border-radius: 999px;
    font-weight: 600;
    box-shadow: none;
  }
  .tab-add .i { width: 20px; height: 20px; }
  .tab-add span { display: inline; }
  .view { padding-block: 34px 0; }
  .vh { margin-bottom: 18px; }
  #toast { bottom: 28px; }
}

@media (min-width: 1200px) {
  :root { --tile-w: 164px; --tile-h: 188px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
