:root {
  color-scheme: dark;
  --ink: #f6f3ec;
  --muted: rgba(232, 226, 214, 0.58);
  --line: rgba(255, 255, 255, 0.08);
  --card: rgba(14, 16, 14, 0.9);
  --card-solid: #121412;
  --paper: #e7efe0;
  --sage: #c5d7b4;
  --red: #e24b42;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.48), 0 0 42px rgba(150, 184, 116, 0.07);
  font-family: "Outfit", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #050605;
  color: var(--ink);
}

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 0;
  background: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
}

#stage {
  position: fixed;
  inset: 0;
  touch-action: none;
}

#stage canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#stage.framed canvas {
  inset: auto;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28), 0 30px 90px rgba(0, 0, 0, 0.38);
}

#stage.transparent {
  background-color: #161616;
  background-image:
    linear-gradient(45deg, #2a2a2a 25%, transparent 25%),
    linear-gradient(-45deg, #2a2a2a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2a2a 75%),
    linear-gradient(-45deg, transparent 75%, #2a2a2a 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}

body.clear-bg #backdrops {
  opacity: 0.45;
}

#source {
  position: fixed;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
  left: 0;
  bottom: 0;
}

.hud {
  transition: opacity 0.2s ease;
}

body.clean .hud {
  opacity: 0;
  pointer-events: none;
}

.card, .top-right, .dock, #hint {
  position: fixed;
  z-index: 2;
}

.card {
  top: 16px;
  left: 16px;
  width: min(320px, calc(100vw - 32px));
  max-height: calc(100vh - 148px);
  overflow: auto;
  padding: 16px 16px 14px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.2);
}

.card::-webkit-scrollbar { width: 8px; }
.card::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 99px; }

.brand h1 {
  margin: 2px 0 4px;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 28px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.eyebrow, .label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.blurb, .meta {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.steps {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.steps li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
}

.steps span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sage);
  color: #161814;
  font-size: 12px;
  font-weight: 650;
}

.steps p {
  margin: 0;
  color: rgba(246, 243, 236, 0.78);
  font-size: 13px;
  line-height: 1.35;
}

.steps strong {
  color: var(--ink);
  font-weight: 650;
}

.step-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.step-play {
  min-width: 72px;
}

.step-play:disabled {
  opacity: 0.4;
  cursor: default;
}

.block { margin-top: 14px; }

.label-row, .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.row { justify-content: flex-start; }

.segment {
  display: flex;
  margin-top: 8px;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
}

.segment button {
  flex: 1;
  min-height: 32px;
  border-radius: 9px;
  color: var(--muted);
}

.segment button.on {
  background: var(--sage);
  color: #161814;
  font-weight: 600;
}

.primary, .ghost, .record, .play {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
}

.primary {
  background: var(--paper);
  color: #161814;
  font-weight: 600;
}

.ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--ink);
}

.ghost.on {
  background: rgba(255, 255, 255, 0.16);
}

.text {
  margin-top: 6px;
  padding: 0;
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.swatches {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background:
    radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.7), transparent 42%),
    var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.swatch.on {
  box-shadow: 0 0 0 2px #121412, 0 0 0 4px var(--sage);
}

.top-right {
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.top-right .segment { margin-top: 0; }

.top-right .segment button { padding: 0 12px; }

.dock {
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(760px, calc(100vw - 32px));
  padding: 8px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.2);
}

.play {
  width: 72px;
  background: var(--paper);
  color: #161814;
  font-weight: 600;
}

.play:disabled { opacity: 0.4; cursor: default; }

.scrub-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 6px;
}

#scrub {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: rgba(246, 243, 236, 0.22);
  margin: 0;
}

#scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

#time {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.record {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 69, 58, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 69, 58, 0.5);
  font-weight: 650;
}

.record .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.record.live {
  background: var(--red);
  border-color: var(--red);
}

.record.live .dot {
  background: #fff;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.35; }
}

#hint {
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  font-size: 12px;
  color: rgba(246, 243, 236, 0.7);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

#drop {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(6, 7, 10, 0.55);
  border: 2px dashed rgba(255, 255, 255, 0.45);
  margin: 12px;
  border-radius: 24px;
  text-align: center;
  backdrop-filter: blur(8px);
}

#drop[hidden] { display: none; }

#drop strong {
  display: block;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 34px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.02em;
}
#drop span { color: var(--muted); }

#toast {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translate(-50%, -12px);
  z-index: 6;
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--card-solid);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#boot {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  margin: 0;
  background: #050605;
  color: var(--muted);
}

body.ready #boot { display: none; }

@media (max-width: 820px) {
  .card { max-height: 42vh; }
  .dock { border-radius: 18px; flex-wrap: wrap; bottom: 40px; }
  #hint { display: none; }
  .top-right { top: auto; bottom: 118px; }
}
