:root {
  --paper: #ebe4d6;
  --card: #fbf7f0;
  --ink: #1d1a16;
  --muted: #6d655b;
  --line: #ddd4c4;
  --brass: #8d5b32;
  --brass-soft: rgba(141, 91, 50, 0.14);
  --stage: #f4eee4;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--serif);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 440px);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 247, 240, 0.92);
}
.brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand h1 { margin: 0; font-size: 28px; font-weight: 560; letter-spacing: -0.03em; }
.brand p { margin: 0; color: var(--muted); font-family: var(--sans); font-size: 13px; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

.stage {
  position: relative;
  background: var(--stage);
  min-height: 0;
}
.photo-outfit {
  position: absolute;
  z-index: 1;
  inset: 0 0 36px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  container-type: size;
  pointer-events: none;
}
.photo-outfit[hidden] { display: none; }
.photo-stack {
  position: relative;
  width: min(100cqi, calc(100cqb * 390 / 1034));
  aspect-ratio: 390 / 1034;
  transform-origin: 50% 100%;
}
.photo-stack img {
  position: absolute;
  height: auto;
  pointer-events: auto;
  user-select: none;
}
#photo-pants { left: 14.1%; width: 71.8%; bottom: 0; z-index: 1; }
#photo-vest { left: 24.4%; width: 51.3%; bottom: 65.8%; z-index: 2; }
.photo-jacket-slot {
  position: absolute;
  left: 0;
  width: 100%;
  bottom: 51.2%;
  z-index: 3;
}
.photo-jacket-slot[hidden] { display: none; }
#photo-jacket {
  position: static;
  display: block;
  width: 100%;
  height: auto;
}
#photo-square-mask {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
#photo-square-mask[hidden] { display: none; }
#photo-square {
  position: absolute;
  height: auto;
  transform-origin: center center;
  pointer-events: auto;
}
.caption {
  position: absolute;
  z-index: 2;
  left: 18px;
  bottom: 16px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(251, 247, 240, 0.88);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
[data-part] { cursor: pointer; }
.is-editing { filter: drop-shadow(0 0 7px rgba(141, 91, 50, 0.55)); }

.panel {
  min-height: 0;
  overflow: auto;
  padding: 18px 18px 28px;
  background: var(--card);
  border-left: 1px solid var(--line);
}
.kicker {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.summary { margin: 0 0 8px; font-size: 20px; line-height: 1.35; }
.notes { margin: 0 0 14px; color: var(--brass); font-family: var(--sans); font-size: 13px; }
.notes:empty { display: none; }

.presets, .categories { display: flex; flex-wrap: wrap; gap: 8px; }
a.text-btn { display: inline-block; text-decoration: none; text-align: center; }
.chip, .text-btn, .measure-toggle {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: 13px;
}
.chip[aria-pressed="true"], .measure-toggle[aria-expanded="true"] {
  background: var(--ink);
  color: #fbf7f0;
  border-color: var(--ink);
}
.chip .swatch-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.measure-toggle { margin: 12px 0; }
.sliders { display: grid; gap: 10px; margin-bottom: 8px; }
.sliders[hidden] { display: none; }
.slider { display: grid; gap: 4px; }
.slider span { display: flex; justify-content: space-between; font-family: var(--sans); font-size: 13px; }
.slider output { color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--brass); }
.privacy { margin: 4px 0 16px; color: var(--muted); font-family: var(--sans); font-size: 12px; line-height: 1.45; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.empty-cards {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
}
.card {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  align-items: center;
  text-align: left;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
}
.card[aria-pressed="true"] {
  border-color: var(--brass);
  box-shadow: inset 0 0 0 1px var(--brass);
  background: #fffaf4;
}
.card b { display: block; font-size: 14px; font-weight: 560; }
.card small { color: var(--muted); font-family: var(--sans); font-size: 11px; }
.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.swatch.none {
  background:
    linear-gradient(135deg, transparent 46%, var(--line) 46%, var(--line) 54%, transparent 54%),
    #fff;
}
.footnote { margin: 16px 0 0; color: var(--muted); font-family: var(--sans); font-size: 12px; line-height: 1.45; }

@media (max-width: 900px) {
  .app { display: block; height: auto; }
  .stage { height: 68dvh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .topbar { align-items: flex-start; }
  .top-actions { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
