@font-face{font-family:Instrument Serif;src:url("./fonts/instrument-serif.woff2") format("woff2");font-display:swap}
@font-face{font-family:Inter;src:url("./fonts/inter.woff2") format("woff2");font-weight:100 900;font-display:swap}

:root {
  color-scheme: light;
  --paper: #f6f3ee;
  --panel: #fbf9f6;
  --ink: #262124;
  --muted: #655e60;
  --line: #ded6d0;
  --plum: #49283e;
  --light-plum: #f1e8ed;
  --display: "Instrument Serif", Georgia, serif;
  font: 400 14px/1.55 Inter, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a, button, summary { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #84547a; outline-offset: 3px; }
[hidden] { display: none !important; }

.masthead {
  min-height: 74px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 3vw;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
  color: var(--plum);
  font: 32px/.95 var(--display);
  letter-spacing: -.045em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 16px;
  height: 20px;
  border: 1px solid currentColor;
  transform: skewY(-18deg);
  box-shadow: inset 6px 0 currentColor;
}

.model-selector { display: flex; justify-content: center; gap: 5px; }
.model-button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 3px 10px 3px 5px;
  border: 1px solid transparent;
  border-radius: 40px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 690;
  white-space: nowrap;
}
.model-button:hover { background: var(--light-plum); }
.model-button[aria-pressed="true"] { border-color: var(--plum); background: var(--light-plum); color: var(--plum); }
.model-avatar { position: relative; display: block; flex: none; width: 30px; height: 30px; overflow: hidden; border-radius: 50%; background: #e3d7c9; }
.model-avatar img { position: absolute; left: 50%; top: -1px; width: 146px; height: auto; max-width: none; transform: translateX(-50%); }
.model-button[data-model="rose"] .model-avatar { background: #eedce0; }
.model-button[data-model="lune"] .model-avatar { background: #e0e5ec; }
.library-trigger, .save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  border-radius: 100px;
  font-weight: 650;
}

.library-trigger {
  justify-self: end;
  padding: 0 13px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px;
}

.library-trigger:hover, .icon-button:hover:enabled, .light-buttons button:hover { background: var(--light-plum); }
.count { min-width: 20px; padding: 1px 4px; border-radius: 20px; background: var(--light-plum); color: var(--plum); text-align: center; }
.bookmark { width: 12px; height: 16px; background: currentColor; clip-path: polygon(0 0,100% 0,100% 100%,50% 72%,0 100%); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(390px, 33vw, 474px);
  gap: clamp(16px, 2vw, 30px);
  max-width: 1850px;
  margin: 0 auto;
  padding: clamp(18px, 2.3vw, 34px) 3vw 30px;
}

.stage {
  position: relative;
  height: clamp(585px, calc(100svh - 136px), 920px);
  overflow: hidden;
  isolation: isolate;
  background: #c9b8a7;
  border-radius: 18px;
}

.scene, .backdrop, .backdrop img, .stage-light, .figure-images, .figure-images img, .pins { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene { overflow: hidden; transition: filter .3s; }
.backdrop img { object-fit: cover; object-position: 62% 55%; }
.stage-light { background: linear-gradient(90deg, #43301e19, transparent 54%); pointer-events: none; }
:is(.stage, .compare-dialog)[data-light="dusk"] .scene { filter: sepia(.27) saturate(1.17) brightness(.87); }
:is(.stage, .compare-dialog)[data-light="mono"] .scene { filter: grayscale(1) contrast(1.06); }

.figure {
  position: absolute;
  left: 57%;
  bottom: 7%;
  height: 88%;
  aspect-ratio: 2 / 3;
  transform: translateX(-50%);
  transform-origin: 50% 2%;
  transition: transform .5s cubic-bezier(.22,.8,.28,1);
}
:is(.stage, .compare-dialog)[data-frame="mid"] .figure { transform: translateX(-50%) scale(1.58); }
:is(.stage, .compare-dialog)[data-frame="portrait"] .figure { transform: translateX(-50%) scale(2.58); }
.figure-images img { object-fit: contain; }
.floor-shadow {
  position: absolute;
  left: 57%;
  bottom: 6.7%;
  width: min(24%, 210px);
  height: 23px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, #33201667, transparent 69%);
}

.pins { pointer-events: none; }
.pin {
  display: grid;
  place-items: center;
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%,-50%);
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  pointer-events: auto;
}
.pin::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  font-size: 17px;
  line-height: 1;
  border: 1px solid #fffaf1;
  border-radius: 50%;
  background: #2f2233ca;
  color: white;
  box-shadow: 0 0 0 4px #fffaf145;
}
.pin:hover::before, .pin:focus-visible::before { background: var(--plum); box-shadow: 0 0 0 5px #fdf3f690; }
.scan {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  pointer-events: none;
  background: linear-gradient(transparent 12%, #f5d8ff 36%, #ffeff9 63%, transparent 92%);
  box-shadow: 0 0 12px #efd2ff;
}

.look-caption {
  position: absolute;
  left: clamp(18px, 3vw, 44px);
  bottom: 9.7%;
  z-index: 1;
  max-width: 34%;
  border-left: 1px solid #6e4f5f80;
  padding-left: clamp(12px, 1.5vw, 20px);
  color: #3b2231;
  pointer-events: none;
}
.look-caption p { margin: 0; }
.look-number, .eyebrow { font-size: 10px; font-weight: 700; letter-spacing: .17em; color: #614553; }
.look-caption h1 {
  margin: 8px 0;
  font: 400 clamp(38px, 5.6vw, 94px)/.81 var(--display);
  letter-spacing: -.032em;
  text-wrap: balance;
}
#look-subtitle { font-size: 12px; }
.frames {
  display: flex;
  gap: 2px;
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 3px;
  border: 1px solid #fff9;
  border-radius: 30px;
  background: #faf4ebee;
}
.frames button, .light-buttons button {
  border: 1px solid transparent;
  border-radius: 28px;
  min-height: 44px;
  padding: 0 12px;
  background: transparent;
  font-size: 12px;
  white-space: nowrap;
}
.frames button[aria-pressed="true"] { background: var(--plum); color: white; }
.frames button[aria-pressed="false"]:hover { background: var(--light-plum); }

.editor {
  min-width: 0;
  align-self: stretch;
  padding: clamp(16px, 1.9vw, 28px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
.editor-heading, .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.editor-heading h2, .dialog h2 { margin: 0; font-size: 26px; font-weight: 750; letter-spacing: -.06em; }
.editor-help { margin: 2px 0 18px; color: var(--muted); font-size: 12px; }
.history { display: flex; gap: 6px; }
.icon-button { width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); font-size: 20px; line-height: 1; }
.icon-button:disabled { opacity: .36; }

.looks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.look-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f1ece5;
  padding: 0;
  text-align: start;
}
.look-card:hover { border-color: #9e7d94; }
.look-card[aria-pressed="true"] { border-color: var(--plum); box-shadow: 0 0 0 1px var(--plum); }
.look-card img {
  display: block;
  width: 100%;
  height: clamp(76px, 11.2vh, 136px);
  padding-top: 3px;
  object-fit: contain;
  object-position: bottom;
}
.card-number { position: absolute; top: 5px; left: 6px; color: var(--plum); font-size: 9px; font-variant-numeric: tabular-nums; }
.card-label { display: block; min-height: 34px; padding: 8px 3px; border-radius: 0 0 8px 8px; text-align: center; font-size: 10px; font-weight: 650; }
.look-card[aria-pressed="true"] .card-label { background: var(--plum); color: white; }
.compare-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.plain-button {
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--plum);
  font-size: 12px;
  font-weight: 650;
}
.plain-button:hover:enabled:not([aria-disabled="true"]), .plain-button[data-saved="true"] { background: var(--light-plum); }
.plain-button:disabled { opacity: .6; }
.plain-button[aria-disabled="true"] { background: var(--light-plum); cursor: default; }
.compare-selection:not(:empty) { margin-top: 6px; }
.editor-options { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
.control-label { margin: 0 0 8px; font-size: 12px; font-weight: 700; }
.light-buttons { display: flex; gap: 5px; flex-wrap: wrap; }
.light-buttons button { display: flex; align-items: center; gap: 6px; padding: 0 9px; border-color: var(--line); }
.light-buttons button[aria-pressed="true"] { border-color: var(--plum); color: var(--plum); background: var(--light-plum); }
.swatch { width: 11px; height: 11px; border-radius: 50%; background: #b7a287; }
.swatch.dusk { background: #ab7474; }
.swatch.mono { background: #4d4a4a; }
.material-list { margin: 13px 0; border-block: 1px solid var(--line); }
.material-list summary { min-height: 44px; padding: 11px 0; cursor: pointer; font-size: 12px; font-weight: 680; }
.material-list ul { list-style: none; margin: 0 0 7px; padding: 0; }
.material-list li button { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 5px 9px; border: 0; border-radius: 5px; background: transparent; text-align: start; }
.material-list li button:hover { background: var(--light-plum); }

.editor-footer { margin-top: auto; }
.save-button { min-height: 48px; width: 100%; border: 0; background: var(--plum); color: white; }
.save-button:hover { background: #62405a; }
.save-button[data-saved="true"] { background: var(--light-plum); color: var(--plum); box-shadow: inset 0 0 0 1px var(--plum); }
.status { margin: 0; color: var(--plum); font-size: 12px; }
.status:not(:empty) { margin-top: 8px; }
.mobile-actions { display: none; }

.dialog {
  width: min(450px, calc(100% - 28px));
  max-height: calc(100dvh - 32px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 12px 52px #1d15234d;
}
.dialog::backdrop { background: #2c202393; backdrop-filter: blur(3px); }
.dialog-head form { margin: 0; }
.eyebrow { margin: 0 0 4px; }
.material-preview { margin: 18px 0 12px; }
.material-photo {
  position: relative;
  overflow: hidden;
  min-height: 215px;
  background-color: #ebdfd7;
  border-radius: 12px;
}
.material-photo img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 330%;
  height: auto;
  transform: translate(var(--crop-x), var(--crop-y));
}
.material-preview figcaption { margin-top: 6px; font-size: 11px; color: var(--muted); }
.dialog p:last-child { margin-bottom: 0; }
.compare-dialog { width: min(820px, calc(100% - 28px)); }
.compare-context { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.compare-fields, .compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.compare-fields { margin: 13px 0 12px; }
.compare-fields label { display: grid; gap: 4px; min-width: 0; font-size: 12px; font-weight: 700; }
.compare-fields select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}
.compare-switch { display: none; }
.compare-stage {
  position: relative;
  height: clamp(220px, 52dvh, 510px);
  overflow: hidden;
  border-radius: 12px;
  background: #c9b8a7;
}
.compare-stage .scene { background: #c9b8a7 url("./media/atelier-desktop.webp") center / cover; }
.compare-stage .figure { left: 50%; bottom: 6%; height: 88%; transition: none; }
.compare-stage .floor-shadow { left: 50%; bottom: 5.2%; width: min(32%, 140px); height: 16px; }
.compare-panel > button { width: 100%; margin-top: 8px; }
.library-empty { margin: 16px 0; color: var(--muted); }
.library-list { display: grid; gap: 8px; list-style: none; margin: 12px 0 0; padding: 0; }
.library-list li { display: flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 9px; background: #f3eee8; }
.library-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: transparent; padding: 5px 8px; }
.library-item img { width: 42px; height: 61px; object-fit: contain; }
.library-item small { color: var(--muted); }
.library-remove { margin-right: 5px; }

@media (max-width: 1020px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(330px, 41%); gap: 14px; }
  .stage { min-height: 555px; }
  .figure, .floor-shadow { left: 58%; }
  .look-caption { max-width: 40%; }
}
@media (max-width: 820px) {
  .masthead { padding: 0 4vw; min-height: 64px; }
  .workspace { grid-template-columns: minmax(0, 1fr); padding: 14px 4vw 28px; }
  .stage { min-height: 0; height: clamp(450px, 68svh, 650px); }
  .editor { padding: 18px; }
  .look-card img { height: clamp(100px, 17vw, 160px); }
}
@media (max-width: 600px) {
  :root { --mobile-controls-clearance: calc(96px + env(safe-area-inset-bottom, 0px)); }
  html { scroll-padding-bottom: var(--mobile-controls-clearance); }
  .masthead { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 7px; padding-block: 6px; }
  .brand { font-size: 29px; gap: 9px; }
  .brand-mark { width: 13px; height: 16px; }
  .model-selector { grid-column: 1 / -1; grid-row: 2; }
  .model-button { padding-inline: 4px 8px; }
  .library-trigger { padding-inline: 9px; gap: 6px; }
  .workspace { padding: 10px 10px var(--mobile-controls-clearance); gap: 10px; }
  .stage { height: clamp(365px, 49svh, 470px); border-radius: 12px; }
  .backdrop img { object-position: 50% 93%; }
  .frames { top: 8px; right: 8px; }
  .frames button { padding: 0 9px; }
  .figure, .floor-shadow { left: 57%; }
  .figure { height: 82%; bottom: 6%; }
  .stage[data-frame="portrait"] .figure { transform: translate(-50%, 12px) scale(2.58); }
  .floor-shadow { bottom: 5.6%; }
  .look-caption { left: 11px; bottom: 5%; max-width: 42%; padding-left: 7px; }
  .look-caption h1 { font-size: clamp(28px, 9vw, 51px); }
  .look-number, #look-subtitle { font-size: 10px; }
  .editor { padding: 13px; border-radius: 12px; }
  .editor-heading h2 { font-size: 23px; }
  .editor-help { margin-bottom: 12px; }
  .looks { gap: 6px; }
  .look-card img { height: clamp(77px, 21.8vw, 102px); }
  .card-label { min-height: 34px; padding-inline: 2px; }
  .editor-footer { display: none; }
  .mobile-actions {
    position: fixed;
    z-index: 3;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: var(--paper);
    box-shadow: 0 -6px 22px #30232a10;
  }
  .mobile-actions .save-button { min-height: 44px; border-radius: 10px; }
  .mobile-actions .status { grid-column: 1 / -1; margin: 0; text-align: center; }
  .mobile-actions .status:empty { display: none; }
  .compare-dialog { padding: 13px; }
  .compare-fields, .compare-switch { gap: 7px; }
  .compare-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 8px; }
  .compare-switch button[aria-pressed="true"] { border-color: var(--plum); background: var(--plum); color: white; }
  .compare-grid { grid-template-columns: minmax(0, 1fr); }
  .compare-dialog[data-side="a"] #compare-b-panel, .compare-dialog[data-side="b"] #compare-a-panel { display: none; }
  .compare-stage { height: clamp(190px, 47dvh, 390px); }
  .compare-stage .scene { background-image: url("./media/atelier-mobile.webp"); background-position: 50% 90%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; scroll-behavior: auto !important; }
}
