:root {
  --ink: #111114;
  --muted: #8a8a90;
  --faint: rgba(17, 17, 20, 0.08);
  --bg: #ffffff;
  --dock-bg: rgba(255, 255, 255, 0.86);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  filter: drop-shadow(0 28px 34px rgba(30, 24, 12, 0.16)) drop-shadow(0 4px 6px rgba(30, 24, 12, 0.10));
}

.stage[data-ready] .stage-canvas { opacity: 1; }

.stage-fallback {
  position: absolute;
  top: 46%;
  left: 50%;
  height: min(78vh, 900px);
  max-width: 88vw;
  object-fit: contain;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 24px 30px rgba(30, 24, 12, 0.18));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}


.dock {
  position: absolute;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 18px;
  background: var(--dock-bg);
  border: 1px solid var(--faint);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.dock-thumb {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
}
.dock-thumb img {
  height: 40px;
  transform: rotate(-3deg);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
}

.dock-divider {
  width: 1px;
  height: 28px;
  background: var(--faint);
}

.dock-tool {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.dock-tool:hover { background: var(--faint); }
.dock-tool:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

#pause-btn .icon-play { display: none; }
#pause-btn[aria-pressed="true"] .icon-play { display: block; }
#pause-btn[aria-pressed="true"] .icon-pause { display: none; }

#look-btn[aria-expanded="true"] { background: var(--ink); color: #fff; }

.dock-pill {
  height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--faint);
  border-radius: 22px;
  background: transparent;
  color: var(--ink);
  font: 500 13px/1 inherit;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.dock-pill:hover { background: var(--faint); }
.dock-pill:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.dock-pill-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f6e3a1 0%, #c9952f 45%, #fff2c4 60%, #a8741f 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.dock-pill[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.dock-pill-swatch--foil {
  --foil: #d6a854;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--foil) 45%, #fff) 0%, var(--foil) 45%,
    color-mix(in srgb, var(--foil) 35%, #fff) 60%, color-mix(in srgb, var(--foil) 70%, #000) 100%);
}
#foil-btn { --foil: #d6a854; }
#foil-btn .dock-pill-swatch--foil { --foil: inherit; }

#lock-btn .icon-locked { display: none; }
#lock-btn[aria-pressed="true"] .icon-locked { display: block; }
#lock-btn[aria-pressed="true"] .icon-unlocked { display: none; }
#lock-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }

.dock-pill-swatch--emboss {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f1ede4 45%, #cfc8ba 100%);
}
.dock-pill[aria-disabled="true"] { cursor: default; }
.dock-finish { display: flex; gap: 6px; }
@media (max-width: 420px) {
  .dock { gap: 4px; padding: 6px; }
  .dock-tool { width: 40px; height: 40px; }
  .dock-pill { padding: 0 10px 0 8px; gap: 6px; }
  .dock-thumb { display: none; }
  .dock-thumb + .dock-divider { display: none; }
}

.look-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 300px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  margin: 0;
  padding: 14px 16px 12px;
  border-radius: 16px;
  background: var(--dock-bg);
  border: 1px solid var(--faint);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  user-select: none;
}
.look-panel[hidden] { display: none; }

/* phones / narrow windows: compact sheet above the dock, menu stays visible above it */
@media (max-width: 760px) {
  .look-panel {
    top: auto;
    right: auto;
    left: 50%;
    bottom: calc(max(24px, env(safe-area-inset-bottom)) + 76px);
    transform: translateX(-50%);
    width: calc(100vw - 32px);
    max-height: 42vh;
  }
}

.look-panel fieldset {
  margin: 0 0 10px;
  padding: 0;
  border: 0;
}
.look-panel fieldset.is-frozen { opacity: 0.38; }
.look-panel fieldset.is-frozen input { cursor: not-allowed; }
.look-panel legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.look-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
  margin-bottom: 6px;
}
.look-row label { font-size: 13px; }
.look-row output {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
}
.look-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}
.look-row--toggle input {
  width: 18px;
  height: 18px;
  margin: 3px 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.look-row--color { grid-template-columns: 1fr; row-gap: 6px; }
.look-label { font-size: 13px; }
.look-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.look-swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--swatch) 45%, #fff), var(--swatch) 50%, color-mix(in srgb, var(--swatch) 70%, #000));
  box-shadow: 0 0 0 1px var(--faint);
  cursor: pointer;
}
.look-swatch[aria-pressed="true"],
.look-swatch--custom.is-active { box-shadow: 0 0 0 2px var(--ink); }
.look-swatch--custom {
  -webkit-appearance: none;
  appearance: none;
  background: conic-gradient(#e66, #ec6, #6c6, #6ce, #66e, #c6e, #e66);
}
.look-swatch--custom::-webkit-color-swatch-wrapper { padding: 0; }
.look-swatch--custom::-webkit-color-swatch { border: 0; border-radius: 50%; opacity: 0; }
.look-swatch--custom::-moz-color-swatch { border: 0; border-radius: 50%; opacity: 0; }
.look-swatch:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.look-reset {
  width: 100%;
  height: 36px;
  border: 1px solid var(--faint);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.look-reset:hover { background: var(--faint); }
.look-reset:focus-visible,
.look-row input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .stage-canvas { transition: none; }
}
