:root {
  --bg: #141114;
  --panel: #1d191d;
  --chip: #2a242a;
  --chip-on: #f4d6d9;
  --text: #f5eef0;
  --muted: #a99ca3;
  --accent: #e8838f;
  --accent-ink: #2a1013;
  --line: #352d34;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
}
.brand { font-weight: 700; letter-spacing: .04em; font-size: 17px; }
.pill {
  border: 1px solid var(--line); background: var(--chip); border-radius: 999px;
  padding: 7px 16px; min-width: 72px;
}
.pill.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; }
.view { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.view canvas { display: block; transform-origin: 0 0; position: absolute; left: 0; top: 0; }
.view.heal canvas { cursor: crosshair; }

.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 24px 16px;
}
.empty h1 { margin: 18px 0 6px; font-size: 26px; }
.empty p { margin: 0 0 22px; color: var(--muted); max-width: 320px; }
.empty .muted { margin-top: 14px; font-size: 13px; }
.empty-mark {
  width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe3e6, #e8838f 55%, #7a3a45);
  box-shadow: 0 0 60px rgba(232,131,143,.45);
}
.big {
  border: 0; border-radius: 999px; padding: 14px 32px; font-size: 17px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink);
}

.compare {
  position: absolute; right: 16px; bottom: 12px; border: 0; border-radius: 999px;
  padding: 8px 14px; background: rgba(20,17,20,.7); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px); font-size: 13px; touch-action: none;
}
.compare.on { background: var(--chip-on); color: var(--accent-ink); }
.toast {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  background: rgba(20,17,20,.85); padding: 8px 14px; border-radius: 999px; font-size: 13px;
  opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; max-width: calc(100% - 32px);
  overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; }
.busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20,17,20,.35); }
.busy-box { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 0 24px; }
.busy-box p { margin: 0; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.busy-box p:empty { display: none; }
.busy .spin {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.2);
  border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.panel {
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 10px 0 calc(env(safe-area-inset-bottom) + 6px);
}
.slider-row { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 36px; }
.slider-row.hidden { visibility: hidden; }
.slider-label { width: 92px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slider-value { width: 34px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); height: 28px; }

.extra-row { display: flex; gap: 10px; padding: 6px 16px 2px; overflow-x: auto; scrollbar-width: none; min-height: 0; }
.extra-row:empty { display: none; }
.extra-row::-webkit-scrollbar, .tools::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.swatch {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); padding: 0;
}
.swatch.on { border-color: var(--text); }
.mini { flex: none; border: 1px solid var(--line); background: var(--chip); border-radius: 999px; padding: 5px 12px; font-size: 13px; white-space: nowrap; }
.mini.go { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.status { flex: none; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #776; }
.status.on::before { background: #6fd18b; }
.status.off::before { background: #e07070; }

.tools { display: flex; gap: 8px; padding: 10px 16px 6px; overflow-x: auto; scrollbar-width: none; }
.tool {
  flex: none; border: 0; background: var(--chip); border-radius: 12px; padding: 9px 13px;
  font-size: 14px; white-space: nowrap; position: relative;
}
.tool.on { background: var(--chip-on); color: var(--accent-ink); font-weight: 600; }
.tool.changed::after {
  content: ""; position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.tool.on.changed::after { background: var(--accent-ink); }

.tabs { display: flex; justify-content: space-around; padding: 4px 8px 0; overflow-x: auto; scrollbar-width: none; }
.tab {
  flex: none; border: 0; background: none; color: var(--muted); padding: 8px 10px; font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tab.on { color: var(--text); border-bottom-color: var(--accent); }

@media (min-width: 800px) {
  .panel { padding-left: calc(50% - 360px); padding-right: calc(50% - 360px); }
}
