:root {
  --bg: #ecebe8;
  --panel: #fbfaf8;
  --ink: #1d1c1a;
  --muted: #6f6c66;
  --line: #dedbd4;
  --accent: #1d1c1a;
  --radius: 10px;
  font-family: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  background: var(--bg);
  overflow: hidden;
}

#stage { position: relative; min-height: 0; }
#view { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }

#hint {
  position: absolute; left: 20px; bottom: 14px; margin: 0;
  font-size: 12px; color: var(--muted); pointer-events: none;
}

#loading {
  position: absolute; inset: 0; display: flex; gap: 12px;
  align-items: center; justify-content: center;
  background: rgba(236, 235, 232, .7); font-size: 14px; color: var(--muted);
}
#loading[hidden] { display: none; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--ink);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#panel {
  display: flex; flex-direction: column; gap: 26px;
  padding: 28px 24px; background: var(--panel);
  border-left: 1px solid var(--line); overflow-y: auto;
}

.eyebrow {
  margin: 0 0 6px; font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.01em; }

h2 {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0 0 12px; font-size: 12px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
}
.current { font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--muted); font-size: 13px; }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 3px; gap: 3px; background: #efede8; border-radius: var(--radius);
}
.segmented button {
  padding: 9px 6px; border: 0; border-radius: 8px; background: transparent;
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer;
}
.segmented button[aria-checked="true"] {
  background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.segmented.small button { padding: 6px 12px; }

.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.swatch {
  display: flex; flex-direction: column; gap: 6px; padding: 0;
  border: 0; background: none; font: inherit; text-align: left; cursor: pointer;
}
.swatch .chip {
  aspect-ratio: 1; width: 100%; border-radius: var(--radius);
  background-size: cover; background-position: center;
  outline: 1px solid var(--line); outline-offset: -1px;
  transition: transform .15s ease;
}
.swatch:hover .chip { transform: scale(1.03); }
.swatch[aria-checked="true"] .chip { outline: 2px solid var(--accent); outline-offset: 3px; }
.swatch .label { font-size: 12px; line-height: 1.25; color: var(--muted); }
.swatch[aria-checked="true"] .label { color: var(--ink); }
.swatch.original .chip {
  display: grid; place-items: center; font-size: 11px; color: var(--muted);
}

.upload {
  display: block; margin-top: 14px; padding: 10px; text-align: center;
  border: 1px dashed #c9c5bc; border-radius: var(--radius);
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.upload:hover { border-color: var(--ink); color: var(--ink); }

.note {
  margin: 14px 0 0; padding: 10px 12px; border-radius: var(--radius);
  background: #f3ecdc; font-size: 13px; line-height: 1.4; color: #6a5521;
}

.row {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 8px 12px; margin-bottom: 14px; font-size: 13px;
}
.row input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--ink); }
.row output { grid-row: 1; grid-column: 2; color: var(--muted); font-variant-numeric: tabular-nums; }

.ghost {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer;
}
.ghost:hover { border-color: var(--ink); }

#tuning.disabled { opacity: .4; pointer-events: none; }

footer { display: flex; gap: 8px; margin-top: auto; }

@media (max-width: 820px) {
  body { grid-template-columns: 1fr; grid-template-rows: 52vh 1fr; }
  #panel { border-left: 0; border-top: 1px solid var(--line); padding: 20px 16px; gap: 20px; }
  .swatches { grid-template-columns: repeat(4, 1fr); }
  #hint { display: none; }
}
