:root {
  --bg: #070706;
  --bg-2: #11100e;
  --bg-3: #1a1814;
  --ink: #f4efe6;
  --muted: #b5aa9a;
  --dim: #6f675c;
  --line: rgba(244, 239, 230, 0.12);
  --gold: #e8c39a;
  --danger: #e35d5d;
  --sans: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  --rail: 268px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  min-height: 100vh;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  height: 100vh;
  display: grid;
  grid-template-rows: 56px auto 1fr;
}
.inspect-banner {
  background: #19160f;
  border-bottom: 1px solid var(--gold);
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 0.45rem 1rem;
}
.inspect-banner button {
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  margin-left: 0.4rem;
}
.inspect-banner.hidden { display: none; }
.inspect-banner a { color: var(--gold); }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 7, 6, 0.9);
  backdrop-filter: blur(12px);
  gap: 1rem;
}
.mark {
  font-family: var(--sans);
  letter-spacing: 0.2em;
  font-size: 0.72rem;
  text-transform: uppercase;
  text-decoration: none;
  color: inherit;
}
.mark span { color: var(--gold); }
.bar-mid {
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.bar-mid strong { color: var(--ink); font-weight: 600; }
.bar-actions { display: flex; gap: 0.45rem; flex-wrap: nowrap; justify-content: flex-end; align-items: center; }
.who {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin-left: 0.45rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--line);
}
.who-in, .who-up {
  text-decoration: none;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.68rem;
}
.who-in { color: var(--muted); }
.who-in:hover { color: var(--ink); }
.who-up { color: var(--gold); }
.who-up:hover { color: var(--ink); }
.who-more {
  text-decoration: none;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--gold);
}
.who-more:hover { color: var(--ink); }
@media (max-width: 980px) {
  .who-name { display: none; }
}
.who-acct {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
  color: var(--ink);
  max-width: 12rem;
}
.who-face {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  background: #1a1814;
  box-shadow: 0 0 0 1px var(--line);
}
.who-face b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  color: var(--gold);
}
.who-face img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.who-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.76rem;
}
.who-own {
  text-decoration: none;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.6rem;
}

.btn {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.btn:hover { border-color: var(--gold); }
.btn.solid { background: var(--ink); color: #111; border-color: var(--ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.shell {
  display: grid;
  grid-template-columns: var(--rail) 1fr var(--rail);
  min-height: 0;
}

.rail {
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 1rem 0.9rem 2rem;
  background: #0b0a09;
}
.rail.right { border-right: 0; border-left: 1px solid var(--line); }

.kicker {
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0.3rem 0 0.7rem;
}
.rail h2 {
  font-family: var(--sans);
  font-size: 1.15rem;
  font-weight: 500;
  margin: 0 0 0.35rem;
}
.hint { color: var(--muted); font-size: 0.82rem; margin: 0 0 1rem; }

.garment {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.8rem;
  margin-bottom: 0.5rem;
}
.garment.active { border-color: var(--gold); background: #19160f; }
.garment b { display: block; }
.garment span { color: var(--dim); font-size: 0.78rem; }

.swatches, .sizes, .sides { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--line);
  padding: 0;
}
.swatch.active { border-color: var(--gold); }
.chip {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.75rem;
}
.chip.active { border-color: var(--gold); color: var(--gold); }

.stage-wrap {
  min-width: 0;
  min-height: 0;
  position: relative;
  background:
    radial-gradient(800px 400px at 50% 10%, rgba(232, 195, 154, 0.06), transparent 55%),
    #090908;
}
.stage {
  position: absolute;
  inset: 0.75rem;
}
.stage img.mockup {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.print-holder {
  position: absolute;
  pointer-events: auto;
  outline: 1px dashed rgba(232, 195, 154, 0.55);
  outline-offset: 0;
}
.print-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.print-clip .canvas-container {
  transform-origin: 0 0;
}
.print-holder .safe {
  position: absolute;
  inset: 6%;
  border: 1px dashed rgba(244, 239, 230, 0.18);
  pointer-events: none;
}
.print-holder canvas { display: block; }
.design-name {
  width: 100%;
  margin: 0 0 0.9rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--ink);
}
.print-clip.blend-light,
.print-holder.blend-light .print-clip,
.print-clip.blend-dark,
.print-holder.blend-dark .print-clip { mix-blend-mode: normal; }
.inch-label {
  position: absolute;
  left: 0;
  bottom: -1.15rem;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  pointer-events: none;
  white-space: nowrap;
}
.ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(232, 195, 154, 0.0) 0,
      rgba(232, 195, 154, 0.0) calc(8.333% - 1px),
      rgba(232, 195, 154, 0.35) calc(8.333% - 1px),
      rgba(232, 195, 154, 0.35) 8.333%
    );
  opacity: 0.35;
  mask-image: linear-gradient(180deg, #000 0, #000 10px, transparent 11px);
}

.tool-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 36px;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
}
.tool-tabs .tab {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 10px;
  padding: 0.45rem 0.2rem;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.tool-tabs .tab.on { border-color: var(--gold); color: var(--gold); background: #19160f; }
.tool-tabs .tab.icon { font-size: 0.95rem; letter-spacing: 0; padding: 0; }
.tool-tabs .tab.danger { color: var(--danger); }
.tool-panel { margin-bottom: 0.8rem; }
.tool-panel .btn { width: 100%; border-radius: 10px; letter-spacing: 0.08em; }
.clipart-box {
  margin: 0 0 1rem;
  max-height: 52vh;
  overflow: auto;
}
.clip-tabs { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.45rem; }
.clip-tabs button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.clip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.clipart-box .clip {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 10px;
  padding: 0.35rem;
  display: grid;
  gap: 0.25rem;
}
.clipart-box .clip img { width: 100%; height: 72px; object-fit: contain; background: #141210; }
.clipart-box .clip span { font-size: 0.66rem; color: var(--muted); text-align: left; }

.field { margin-bottom: 0.75rem; }
.field label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.3rem;
}
.field input[type="text"], .field input[type="number"], .field select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
}
.field input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 10px;
  padding: 0.15rem;
}

.layers { display: flex; flex-direction: column; gap: 0.35rem; }
.layer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  font-size: 0.82rem;
}
.layer.active { border-color: var(--gold); }
.layer button { background: none; border: 0; color: var(--muted); padding: 0 0.2rem; }
.layer .x { color: var(--danger); }
.layer .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.library { display: flex; flex-direction: column; gap: 0.4rem; }
.lib-item {
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
}
.lib-item.active { border-color: var(--gold); }
.lib-item b { display: block; font-size: 0.82rem; }
.lib-item span { color: var(--dim); font-size: 0.72rem; }

.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 40;
}
.toast.show { opacity: 1; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(7, 7, 6, 0.82);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.gate-card {
  width: min(520px, 100%);
  background: #11100e;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.3rem 1.25rem 1.2rem;
}
.gate-card h2 {
  font-family: var(--sans);
  font-weight: 500;
  margin: 0 0 0.5rem;
}
.gate-card p { color: var(--muted); font-size: 0.92rem; margin: 0 0 0.8rem; }
.gate-card label {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-size: 0.88rem;
  color: var(--ink);
  margin: 0.8rem 0 1rem;
}
.gate-card input { margin-top: 0.2rem; }
.gate-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.hidden { display: none !important; }

@media (max-width: 980px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .shell { grid-template-columns: 1fr; }
  .stage-wrap { height: 70vh; }
  .rail { border: 0; border-top: 1px solid var(--line); }
}
