:root {
  color-scheme: dark;
  --background: #09090a;
  --panel: #101012;
  --edge: #29292e;
  --muted: #a6a6af;
  --ink: #f5f5f7;
  --accent: #b3e978;
  font-family: "Helvetica Neue", Inter, "Hiragino Kaku Gothic ProN", "Hiragino Sans", sans-serif;
  color: var(--ink);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
.shell { width: min(100% - 96px, 1600px); margin-inline: auto; }

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 73px;
  border-bottom: 1px solid var(--edge);
}

.wordmark, .method {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .12em;
}

.mark {
  display: block;
  width: 15px;
  height: 13px;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 100%, 0 100%, 50% 0, 50% 32%, 19% 87%, 81% 87%, 50% 32%);
}

.method { color: var(--muted); }
.method span { color: var(--accent); }

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 29px 0 31px;
}

h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(45px, 5vw, 91px); font-weight: 780; line-height: 1.08; letter-spacing: -.065em; }
.intro p { margin: 14px 0 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
h2 { font-size: 13px; font-weight: 650; letter-spacing: .07em; }

.run-controls { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
button, summary {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--edge);
  border-radius: 0;
  color: var(--ink);
  background: #19191c;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease;
}
button:hover:not(:disabled), summary:hover { background: #26262a; border-color: #63636b; }
button:disabled { opacity: .43; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.run-controls button, summary { min-height: 42px; padding-inline: 17px; }
button.primary {
  min-width: 98px;
  color: #121808;
  background: var(--accent);
  border-color: var(--accent);
}
button.primary:hover:not(:disabled) { background: #caefa2; border-color: #caefa2; }
.settings { position: relative; z-index: 2; }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; margin-left: 9px; font-size: 15px; color: var(--muted); }
details[open] summary::after { content: "−"; }
.settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 238px;
  padding: 16px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--edge);
  background: #19191c;
  box-shadow: 0 12px 30px #0009;
}
.settings-panel label, .evolution-controls label { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; }
.settings-panel output, .evolution-controls output { color: var(--accent); font-variant-numeric: tabular-nums; }
input[type="range"] { margin: 0; min-width: 0; accent-color: var(--accent); }

.stage { display: grid; grid-template-columns: minmax(0, 2.55fr) minmax(270px, 1fr); gap: 14px; }
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--edge); }
.panel-heading {
  height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-inline: 16px;
  color: var(--muted);
}
.panel-heading h2, .chart h2 { color: var(--ink); }
.panel-heading > span, .chart-heading > span { font-size: 11px; }
#source-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.run-status { display: flex; align-items: center; gap: 8px; }
.run-status i, .brush-controls i {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #777780;
  border-radius: 50%;
}
.run-status[data-state="running"] i, .brush-controls i {
  background: var(--accent);
  box-shadow: 0 0 10px #b3e97866;
}

.result-panel { display: grid; grid-template-rows: auto 1fr auto auto; }
.result-surface, .source-surface {
  background: #080809;
  border-block: 1px solid var(--edge);
}
.result-surface {
  height: clamp(300px, 47vh, 545px);
  display: grid;
  place-items: center;
  min-width: 0;
  background-color: #09090a;
  background-image: linear-gradient(#b0b0c009 1px, transparent 1px),
    linear-gradient(90deg, #b0b0c009 1px, transparent 1px);
  background-size: 28px 28px;
}
#result { display: block; width: 0; height: 0; box-shadow: 0 0 0 1px #ffffff16; }
.evolution-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 3vw, 32px);
  padding: 12px 15px;
  border-bottom: 1px solid var(--edge);
}
.evolution-controls > div { display: grid; gap: 5px; }
.evolution-controls input { width: 100%; min-height: 24px; }
#layer-count, .range-endpoints { color: var(--muted); font-size: 11px; }
.range-endpoints { display: flex; justify-content: space-between; }
.result-actions { display: flex; gap: 14px; align-items: center; min-height: 56px; padding: 7px 15px; }
.result-actions input { flex: 1; }

.source-surface {
  position: relative;
  height: clamp(200px, 27vh, 335px);
  display: grid;
  place-items: center;
}
.source-surface.is-dragging { outline: 2px solid var(--accent); outline-offset: -2px; }
.source-frame { position: relative; width: 0; height: 0; }
.source-frame canvas { display: block; width: 100%; height: 100%; }
.source-frame video { display: block; width: 100%; height: 100%; object-fit: fill; }
#weights { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.camera-view, .camera-view video { position: absolute; inset: 0; width: 100%; height: 100%; }
.camera-view video { object-fit: contain; background: #080809; }
#countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(54px, 8vw, 125px);
  font-weight: 760;
  text-shadow: 0 2px 16px #000;
}
.brush-controls, .photo-controls { display: flex; align-items: center; gap: 8px; margin: 0 15px; }
.brush-controls { justify-content: space-between; min-height: 59px; color: var(--muted); font-size: 12px; }
.brush-controls i { margin-right: 5px; vertical-align: 2px; }
.brush-controls button, .text-button { background: transparent; }
.photo-controls { flex-wrap: wrap; border-top: 1px solid var(--edge); padding-top: 13px; }
.text-button { border-color: transparent; color: var(--muted); }
.privacy, .notice { margin: 10px 15px 14px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.notice { color: var(--accent); }

.telemetry { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); margin-top: 14px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; }
.metrics > div { padding: 18px 15px 16px; border-right: 1px solid var(--edge); }
.metrics dt { color: var(--muted); font-size: 12px; }
.metrics dd {
  margin-top: 8px;
  font-size: clamp(19px, 2.6vw, 40px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 580;
  letter-spacing: -.045em;
}
.metrics small { padding-left: 4px; font-size: .53em; color: var(--muted); }
.chart { padding: 12px 16px 8px; }
.chart-heading { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; color: var(--muted); }
#graph { display: block; margin-top: 3px; width: 100%; height: 53px; }
.live-meter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.live-meter meter { width: 70px; }
.live-meter output { color: var(--accent); font-variant-numeric: tabular-nums; }

footer {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 16px 0 19px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

@media (max-width: 1050px) {
  .shell { width: calc(100% - 48px); }
  .stage { grid-template-columns: minmax(0, 1.8fr) minmax(255px, 1fr); }
  .metrics > div { padding-left: 10px; padding-right: 10px; }
}

@media (max-width: 700px) {
  .shell { width: calc(100% - 32px); }
  .masthead { min-height: 52px; }
  .wordmark, .method { gap: 8px; font-size: 10px; }
  .intro { display: grid; gap: 17px; padding: 24px 0 18px; }
  .intro p { font-size: 13px; margin-top: 9px; }
  .settings-panel { left: 0; right: auto; width: min(215px, calc(100vw - 32px)); }
  .stage, .telemetry { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .result-surface { height: clamp(240px, 67vw, 340px); }
  .evolution-controls { padding-inline: 10px; }
  .result-actions { gap: 8px; padding-inline: 10px; }
  .source-surface { height: clamp(230px, 65vw, 340px); }
  .telemetry { gap: 0; margin-top: 10px; }
  .metrics > div { padding: 12px 8px; }
  .metrics > div:last-child { border-right: 0; }
  .metrics dd { font-size: clamp(18px, 6vw, 32px); }
  .chart { border-top: 1px solid var(--edge); }
  footer { flex-direction: column; gap: 4px; }
}

@media (max-width: 540px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics > div:nth-child(2n) { border-right: 0; }
  .metrics > div:nth-child(-n + 2) { border-bottom: 1px solid var(--edge); }
}

@media (max-width: 430px) {
  .settings-panel { right: 0; left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

@media (min-width: 1051px) and (max-height: 1199px) {
  .masthead { min-height: 52px; }
  .intro { padding: 14px 0 16px; }
  h1 { font-size: clamp(40px, 6vh, 72px); }
  .intro p { margin-top: 6px; }
  .metrics > div { padding-block: 12px 11px; }
  .metrics dd { margin-top: 4px; font-size: clamp(19px, 3.4vh, 36px); }
  footer { padding-block: 10px 12px; }
}
