/* hum2synth: the hum2drum look (dark, one narrow column, a lime accent, slowly
   drifting colour), drawn again for this page. Dark only. The CSP allows no
   inline style: the script sets only custom properties and sizes through
   element.style. The font is ours if space-grotesk.woff2 is in static/;
   without it the system font takes over. */
@font-face {
  font-family: "Space Grotesk";
  src: url("/static/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --bg: #09090b;
  --panel: #141418;
  --panel-up: #1c1c22;
  --hair: rgba(255, 255, 255, .08);
  --hair-strong: rgba(255, 255, 255, .16);
  --ink: #f4f4f5;
  --soft: #a1a1aa;
  --faint: #6b6b75;
  --lime: #c8ff3d;
  --lime-ink: #0b1000;
  --red: #ff4d4f;
  --display: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --round: 26px;
  --gutter: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
}
/* Colour that drifts behind everything. */
body::before {
  content: "";
  position: fixed;
  inset: -14%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40vmax 32vmax at 12% 6%, rgba(200, 255, 61, .24), transparent 62%),
    radial-gradient(36vmax 30vmax at 94% 14%, rgba(255, 77, 150, .2), transparent 60%),
    radial-gradient(44vmax 36vmax at 2% 60%, rgba(56, 189, 248, .17), transparent 60%),
    radial-gradient(50vmax 40vmax at 102% 94%, rgba(124, 92, 255, .28), transparent 60%),
    radial-gradient(32vmax 26vmax at 48% 50%, rgba(200, 255, 61, .07), transparent 70%),
    radial-gradient(30vmax 24vmax at 28% 100%, rgba(255, 160, 60, .13), transparent 65%);
  animation: drift 38s ease-in-out infinite alternate;
}
button, input, a { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
/* a screen's heading or message takes focus when the screen changes (for screen readers): no ring */
[tabindex="-1"]:focus { outline: none; }
[hidden] { display: none !important; }

.shell {
  max-width: 460px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(env(safe-area-inset-top), 12px) calc(var(--gutter) + env(safe-area-inset-right))
           max(env(safe-area-inset-bottom), 16px) calc(var(--gutter) + env(safe-area-inset-left));
}
main { flex: 1; }

/* ---------- header ---------- */
.top { height: 48px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font: 600 19px/1 var(--display); letter-spacing: -.02em; }
.brand svg { width: 30px; height: 16px; fill: none; stroke: var(--lime); stroke-width: 2.6; stroke-linecap: round; }
.brand b { color: var(--lime); font-weight: 700; }
.badge {
  padding: 5px 9px;
  border: 1px solid var(--hair-strong);
  border-radius: 99px;
  color: var(--soft);
  font: 500 11px/1 var(--display);
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2 { margin: 0; font-family: var(--display); letter-spacing: -.035em; }
h1 { margin-top: 18px; font-size: clamp(38px, 11.5vw, 54px); line-height: .98; font-weight: 700; }
h1 span { color: var(--lime); }
h2 { font-size: 24px; line-height: 1.1; font-weight: 600; }
.lede { margin: 12px 0 0; color: var(--soft); font-size: 15.5px; }
.dim { color: var(--faint); }

.btn { border: 0; border-radius: 99px; padding: 13px 22px; font-size: 15.5px; font-weight: 600; transition: transform .15s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--lime); color: var(--lime-ink); }
.btn.secondary { background: transparent; border: 1px solid var(--hair-strong); }
.btn.wide { width: 100%; margin-top: 18px; }
.btn.wide + .btn.wide { margin-top: 10px; }

/* ---------- record ---------- */
.stage {
  position: relative;
  height: clamp(260px, 47dvh, 560px);
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--hair);
  border-radius: var(--round);
  background: rgba(20, 20, 24, .7) linear-gradient(var(--hair) 1px, transparent 1px) 0 0 / 100% 32px;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
/* the preview is a mirror, as a selfie camera is expected to be */
#preview { display: block; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
[data-camera="off"] #preview { visibility: hidden; }
/* the card sits above the synth drawing, so its words stay clear of the keys */
.stage-off {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  justify-content: center;
  justify-items: center;
  gap: 14px;
  padding: clamp(24px, 9%, 56px) 24px 24px;
  text-align: center;
}
.stage-off > :not(.synth-art) { position: relative; }
.stage-off p { max-width: 250px; margin: 0; color: var(--soft); font-size: 13.5px; }
[data-camera="on"] .stage-off, [data-camera="recording"] .stage-off { display: none; }
.stage-icon { width: 44px; height: 44px; fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-linejoin: round; }

/* A faint keyboard synth behind the camera-off card; it plays a little tune to itself. */
.synth-art {
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: min(86%, 340px);
  height: auto;
  transform: translateX(-50%);
  pointer-events: none;
  fill: none;
  stroke: rgba(244, 244, 245, .13);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.synth-art .black-keys rect { fill: rgba(9, 9, 11, .55); }
.synth-art .lit { stroke: none; fill: rgba(200, 255, 61, .3); opacity: 0; animation: keypress 3s ease-in-out infinite; }
.synth-art .lit-2 { animation-delay: .6s; }
.synth-art .lit-3 { animation-delay: 1.2s; }
.synth-art .lit-4 { animation-delay: 1.8s; }
.synth-art .lit-5 { animation-delay: 2.4s; }
.synth-art .art-wave, .synth-art .art-accent { stroke: rgba(200, 255, 61, .5); }
.synth-art .art-wave { animation: scroll 1.5s linear infinite; }
.synth-art .art-led { stroke: none; fill: rgba(200, 255, 61, .6); animation: blink 1.5s ease-in-out infinite; }
.synth-art .knob { transform-box: fill-box; transform-origin: center; animation: turn 4.2s ease-in-out infinite alternate; }
.synth-art .knob-2 { animation-delay: -1.4s; }
.synth-art .knob-3 { animation-delay: -2.8s; }
.synth-art .art-wheel { animation: wheel 3s ease-in-out infinite alternate; }

.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 99px;
  background: rgba(9, 9, 11, .55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font: 500 14px/1 var(--display);
  font-variant-numeric: tabular-nums;
}
[data-camera="off"] .hud { display: none; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
[data-camera="recording"] .rec-dot { background: var(--red); animation: pulse 1s infinite; }

.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 22px; }
.side-btn {
  justify-self: start;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 0;
  background: none;
  color: var(--soft);
  font-size: 12px;
}
.side-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-btn.ghost { visibility: hidden; }
.rec-wrap { position: relative; display: grid; place-items: center; }
.cue {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  z-index: 3;
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--lime);
  color: var(--lime-ink);
  font: 600 14px/1 var(--display);
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  animation: bob 1.6s ease-in-out infinite;
}
.cue::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--lime); }
[data-camera="on"] .cue { opacity: 1; }
.rec { position: relative; width: 84px; height: 84px; padding: 0; border: 0; background: none; display: grid; place-items: center; }
.rec:disabled { opacity: .35; cursor: default; }
.rec svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.rec circle { fill: none; stroke-width: 5; }
.ring-track { stroke: rgba(255, 255, 255, .22); }
[data-camera="on"] .ring-track { animation: glow 1.6s ease-in-out infinite; }
/* the dash is the circle's length (2π·46); the script empties it as the 30 s run out */
.ring { stroke: var(--lime); stroke-linecap: round; stroke-dasharray: 289.03; stroke-dashoffset: 289.03; }
.core { width: 62px; height: 62px; border-radius: 50%; background: var(--red); transition: width .2s, height .2s, border-radius .2s; }
[data-camera="recording"] .core { width: 30px; height: 30px; border-radius: 8px; }
.hint { margin: 16px 0 0; color: var(--faint); font-size: 13px; text-align: center; }

/* ---------- invite ---------- */
.gate { padding-top: 48px; text-align: center; }
.gate-icon { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; background: rgba(200, 255, 61, .12); }
.gate-icon svg { width: 28px; height: 28px; fill: none; stroke: var(--lime); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.invite-form { margin-top: 22px; }
.invite-form input {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--hair-strong);
  border-radius: 16px;
  background: var(--panel);
  font-size: 16px; /* 16 px keeps iOS from zooming in */
}
.invite-form input:focus { border-color: var(--lime); outline: none; }
.gate-error { margin: 14px 0 0; color: #ff8a8c; font-size: 14px; }

/* ---------- working ---------- */
.draft {
  position: relative;
  width: 132px;
  aspect-ratio: 3 / 4;
  margin: 26px auto 22px;
  overflow: hidden;
  border: 1px solid var(--hair);
  border-radius: 20px;
  background: var(--panel);
}
.draft video { display: block; width: 100%; height: 100%; object-fit: cover; opacity: .8; }
/* a result opened from its link has no local video: the mark stands in */
.draft.empty video { display: none; }
.draft.empty::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 18'%3E%3Cpath d='M2 9.5c1.9-6 3.8-6 5.7 0s3.8 6 5.7 0M20 13.5v-9M25 16.5v-15M30 12v-6' fill='none' stroke='%236b6b75' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / 56px auto no-repeat;
}
.scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, rgba(200, 255, 61, .28) 50%, transparent 60%) 0 0 / 100% 250%;
  animation: scan 2.2s linear infinite;
}
#working h2 { text-align: center; }
.steps { display: grid; gap: 4px; margin: 22px 0 0; padding: 0; list-style: none; }
.steps li { display: grid; grid-template-columns: 28px 1fr; align-items: center; padding: 11px 14px; border-radius: 16px; color: var(--faint); transition: color .3s, background .3s; }
.steps li i { position: relative; width: 18px; height: 18px; border: 1.5px solid var(--hair-strong); border-radius: 50%; }
.steps li em { display: none; grid-column: 2; color: var(--faint); font-size: 12.5px; font-style: normal; }
.steps li.done { color: var(--soft); }
.steps li.done i { border-color: var(--lime); background: var(--lime); }
.steps li.done i::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid var(--lime-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.steps li.active { background: var(--panel); color: var(--ink); }
.steps li.active em:not(:empty) { display: block; }
/* the active step's dot is a little level meter */
.steps li.active i {
  border: 0;
  border-radius: 2px;
  background:
    linear-gradient(var(--lime), var(--lime)) 2px 100% / 3px 40% no-repeat,
    linear-gradient(var(--lime), var(--lime)) 7.5px 100% / 3px 80% no-repeat,
    linear-gradient(var(--lime), var(--lime)) 13px 100% / 3px 55% no-repeat;
  animation: meter .9s ease-in-out infinite alternate;
}

/* ---------- results ---------- */
.player {
  position: relative;
  max-height: 62dvh;
  margin: 14px auto 0;
  overflow: hidden;
  aspect-ratio: var(--aspect, 3 / 4);
  border: 1px solid var(--hair);
  border-radius: var(--round);
  background: #000 var(--poster, none) center / contain no-repeat;
}
/* One video per take, stacked: the one playing on top, the one before it just
   under, so a switch shows the old picture until the new one paints. */
.player video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; }
.player video.back { z-index: 0; opacity: 1; }
.player video.front { z-index: 1; opacity: 1; }
.play-overlay, .now, .scrub { z-index: 2; }
.play-overlay { position: absolute; inset: 0; border: 0; background: rgba(0, 0, 0, .18); display: grid; place-items: center; transition: opacity .2s; }
.play-overlay svg {
  width: 74px;
  height: 74px;
  padding: 20px 18px 20px 22px;
  border-radius: 50%;
  background: rgba(9, 9, 11, .6);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  fill: var(--ink);
}
.playing .play-overlay { opacity: 0; }
/* the player and the cards clip what is drawn outside them: these rings go inside */
.play-overlay:focus-visible, .take-play:focus-visible, .take-dl a:focus-visible { outline-offset: -2px; }
.play-overlay { border-radius: calc(var(--round) - 1px); }
/* playing, the overlay is see-through: keyboard focus still shows its ring, not the play sign */
.playing .play-overlay:focus-visible { opacity: 1; background: none; }
.playing .play-overlay:focus-visible svg { visibility: hidden; }
.now {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 99px;
  background: rgba(9, 9, 11, .55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  max-width: calc(100% - 24px);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}
.now b { color: var(--lime); font: 600 14px/1 var(--display); }
.now span { overflow: hidden; color: var(--soft); text-overflow: ellipsis; }
.scrub { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; display: flex; align-items: flex-end; cursor: pointer; touch-action: none; }
.scrub i { width: 0; height: 3px; background: var(--lime); }
.scrub:focus-visible { outline-offset: -2px; }

.original {
  width: 100%;
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--hair);
  border-radius: 18px;
  background: var(--panel);
  color: var(--soft);
  font-size: 14px;
  text-align: left;
}
.original svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.original b { margin-right: 2px; color: var(--ink); font-weight: 600; }
.original.current { border-color: var(--lime); color: var(--ink); }
.original.current svg { stroke: var(--lime); }

.takes-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.legend { color: var(--faint); font-size: 12px; text-align: right; }
.takes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.take { overflow: hidden; border: 1px solid var(--hair); border-radius: 20px; background: var(--panel); transition: border-color .2s, background .2s; }
.take.current { border-color: var(--lime); background: var(--panel-up); }
.take-play {
  width: 100%;
  border-radius: 19px 19px 0 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 8px;
  padding: 14px 14px 12px;
  border: 0;
  background: none;
  text-align: left;
}
.take-n { color: var(--faint); font: 600 30px/1 var(--display); letter-spacing: -.04em; }
.take.current .take-n { color: var(--lime); }
.take-name { grid-column: 1; font-size: 15px; font-weight: 600; }
.take-state { grid-column: 2; grid-row: 2; justify-self: end; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; }
.take-state svg { width: 12px; height: 12px; margin-left: 2px; fill: var(--bg); }
.take.on-air .take-state { background: var(--lime); }
.take.on-air .take-state svg { display: none; }
/* playing: the round button shows two pause bars */
.take.on-air .take-state::before {
  content: "";
  width: 10px;
  height: 10px;
  background:
    linear-gradient(var(--lime-ink), var(--lime-ink)) 0 0 / 3.5px 100% no-repeat,
    linear-gradient(var(--lime-ink), var(--lime-ink)) 100% 0 / 3.5px 100% no-repeat;
}
.take-dl { display: flex; border-top: 1px solid var(--hair); }
.take-dl a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 0;
  color: var(--soft);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .02em;
  text-decoration: none;
}
.take-dl a + a { border-left: 1px solid var(--hair); }
.take-dl a:active { background: var(--panel-up); color: var(--ink); }
.take-dl svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- error ---------- */
#error { padding-top: 60px; text-align: center; }
.oops { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 77, 79, .12); color: var(--red); font: 700 30px/1 var(--display); }

footer { padding-top: 28px; color: var(--faint); font-size: 12px; text-align: center; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border: 1px solid var(--hair-strong);
  border-radius: 14px;
  background: var(--panel-up);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  font-size: 14px;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
}
.toast.on { opacity: 1; pointer-events: auto; animation: rise .25s ease; }

@keyframes drift { 50% { transform: translate3d(3%, -2%, 0) rotate(4deg); } 100% { transform: translate3d(-3%, 3%, 0) scale(1.08); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes bob { 50% { transform: translate(-50%, -4px); } }
@keyframes glow { 50% { stroke: rgba(200, 255, 61, .6); } }
@keyframes keypress { 0%, 22%, 100% { opacity: 0; } 4%, 15% { opacity: 1; } }
@keyframes scroll { to { transform: translateX(-20px); } }
@keyframes blink { 50% { opacity: .2; } }
@keyframes turn { from { transform: rotate(-35deg); } to { transform: rotate(40deg); } }
@keyframes wheel { from { transform: translateY(-14px); } to { transform: translateY(14px); } }
@keyframes scan { from { background-position: 0 100%; } to { background-position: 0 -150%; } }
@keyframes meter { from { background-size: 3px 30%, 3px 90%, 3px 45%; } to { background-size: 3px 85%, 3px 35%, 3px 100%; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 700px) { .shell { padding-top: 28px; } h1 { margin-top: 28px; } }
