:root {
  --bg: #0a0a12;
  --bg2: #12121e;
  --card: #161625;
  --line: #262640;
  --text: #f2f2fa;
  --dim: #9a9ab8;
  --accent: #8b5cf6;
  --accent2: #22d3ee;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --green: #34d399;
  --red: #f43f5e;
  --purple: #c084fc;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #1d1340 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
#app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .3px; font-size: 18px; }
.logo {
  width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(from 200deg, var(--accent), var(--accent2), var(--accent));
  box-shadow: 0 0 18px rgba(139, 92, 246, .55);
  position: relative;
}
.logo::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--bg); }
.room {
  font: 700 13px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 2px; padding: 8px 10px; border-radius: 999px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--dim);
}

/* cards */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.01)), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.join h1 { font-size: 28px; line-height: 1.15; margin: 4px 0 10px; letter-spacing: -.3px; }
.sub { color: var(--dim); margin: 0 0 18px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--dim); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%; font-size: 18px; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 92, 246, .25); }
.phones {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px;
  background: rgba(34, 211, 238, .08); border: 1px solid rgba(34, 211, 238, .25); margin-bottom: 16px; font-size: 15px;
}
.phones svg { width: 30px; height: 30px; flex: none; fill: var(--accent2); }
.big {
  width: 100%; font-size: 19px; font-weight: 800; padding: 17px; border: 0; border-radius: 16px; cursor: pointer;
  color: #fff; background: linear-gradient(135deg, var(--accent), #6d28d9 60%, #4c1d95);
  box-shadow: 0 10px 30px rgba(109, 40, 217, .45); transition: transform .08s ease;
}
.big:active { transform: scale(.98); }
.big:disabled { opacity: .6; cursor: default; }
.err { color: var(--red); font-weight: 600; margin: 12px 0 0; }
.fine { color: var(--dim); font-size: 13px; margin: 12px 0 0; }
.center { text-align: center; }

/* hero status */
.hero {
  --c: var(--amber);
  position: relative; display: flex; align-items: center; gap: 18px;
  padding: 22px 20px; border-radius: 24px; margin-bottom: 12px; min-height: 120px; overflow: hidden;
  background: radial-gradient(400px 200px at 0% 50%, color-mix(in srgb, var(--c) 22%, transparent), transparent 70%), var(--card);
  border: 1px solid color-mix(in srgb, var(--c) 45%, var(--line));
  transition: border-color .3s, background .3s;
}
.hero[data-state="connecting"], .hero[data-state="waiting"] { --c: var(--amber); }
.hero[data-state="linked"] { --c: var(--blue); }
.hero[data-state="beat"] { --c: var(--accent2); }
.hero[data-state="hearing"] { --c: var(--green); }
.hero[data-state="recording"] { --c: var(--red); }
.hero[data-state="uploading"] { --c: var(--purple); }
.hero[data-state="landed"] { --c: var(--green); }
.hero[data-state="error"] { --c: var(--red); }
.light {
  width: 54px; height: 54px; border-radius: 50%; flex: none; background: var(--c);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 18%, transparent), 0 0 34px var(--c);
}
.hero[data-state="connecting"] .light, .hero[data-state="waiting"] .light { animation: pulse 1.4s ease-in-out infinite; }
.hero[data-state="recording"] .light { animation: pulse .9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.88); } }
.hero-title { font-size: 26px; font-weight: 900; letter-spacing: -.2px; line-height: 1.1; }
.hero[data-state="recording"] .hero-title { letter-spacing: 2px; }
.hero-sub { color: var(--dim); margin-top: 4px; font-size: 15px; }
.countin {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: rgba(10, 10, 18, .82); backdrop-filter: blur(4px);
}
.countin span { font-size: 88px; font-weight: 900; line-height: 1; color: var(--red); text-shadow: 0 0 40px rgba(244, 63, 94, .6); }
.countin small { color: var(--dim); font-size: 16px; align-self: flex-end; margin-bottom: 18px; }
.countin.tick span { animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(1.35); } to { transform: scale(1); } }

/* progress */
.progress {
  position: relative; height: 34px; border-radius: 12px; overflow: hidden; margin-bottom: 12px;
  background: var(--bg2); border: 1px solid var(--line);
}
.progress-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--accent), var(--purple)); transition: width .2s; }
.progress-text { position: relative; display: flex; height: 100%; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

/* status lights */
.lights { list-style: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 460px) { .lights { grid-template-columns: repeat(3, 1fr); } }
.lights li { white-space: nowrap; }
.lights li {
  display: flex; align-items: center; gap: 7px; padding: 9px 10px; border-radius: 12px; font-size: 13px; font-weight: 600;
  background: var(--bg2); border: 1px solid var(--line); color: var(--dim); transition: all .25s;
}
.lights li b { font-weight: 800; }
.lights li i { width: 9px; height: 9px; border-radius: 50%; background: #3a3a55; flex: none; transition: all .25s; }
.lights li.on { color: var(--text); border-color: color-mix(in srgb, var(--lc, var(--green)) 50%, var(--line)); }
.lights li.on i { background: var(--lc, var(--green)); box-shadow: 0 0 10px var(--lc, var(--green)); }
.lights li[data-k="link"] { --lc: var(--blue); }
.lights li[data-k="beat"] { --lc: var(--accent2); }
.lights li[data-k="rec"] { --lc: var(--red); }
.lights li[data-k="up"] { --lc: var(--purple); }

/* mic */
.mic .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.label { font-weight: 800; font-size: 15px; }
.hint { font-weight: 700; font-size: 14px; color: var(--dim); }
.hint[data-level="good"] { color: var(--green); }
.hint[data-level="quiet"] { color: var(--amber); }
.hint[data-level="loud"] { color: var(--red); }
.meter { position: relative; height: 22px; border-radius: 11px; overflow: hidden; background: var(--bg2); border: 1px solid var(--line); }
.meter-zones { position: absolute; inset: 0; display: flex; opacity: .22; }
.meter-zones span:nth-child(1) { flex: 0 0 50%; background: var(--amber); }
.meter-zones span:nth-child(2) { flex: 0 0 45%; background: var(--green); }
.meter-zones span:nth-child(3) { flex: 1; background: var(--red); }
.meter-fill { position: absolute; inset: 0; clip-path: inset(0 100% 0 0); background: linear-gradient(90deg, var(--amber) 0%, var(--amber) 42%, var(--green) 52%, var(--green) 93%, var(--red) 96%); }
.meter-peak { position: absolute; top: 0; bottom: 0; width: 3px; left: 0; background: #fff; opacity: .8; }
.toggles { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.tog { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 10px 12px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); flex: 1 1 140px; font-weight: 600; font-size: 15px; }
.tog input { position: absolute; opacity: 0; pointer-events: none; }
.sw { width: 40px; height: 24px; border-radius: 12px; background: #34344d; position: relative; flex: none; transition: background .2s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tog input:checked + .sw { background: var(--accent); }
.tog input:checked + .sw::after { transform: translateX(16px); }
.tog input:focus-visible + .sw { box-shadow: 0 0 0 3px rgba(139, 92, 246, .4); }
#muteMic:checked + .sw { background: var(--red); }

/* studio sound (mirror chain, monitor only) */
.studio { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.studio .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.studio-tag {
  font-size: 13px; font-weight: 800; padding: 6px 10px; border-radius: 999px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); background: rgba(139, 92, 246, .16); border: 1px solid rgba(139, 92, 246, .45);
}
.studio .fine { margin-top: 8px; }
.mix { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: var(--dim); }
.mix input { flex: 1; min-width: 0; height: 32px; accent-color: var(--accent); margin: 0; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { font-size: 13px; font-weight: 700; padding: 7px 11px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); color: var(--dim); }

/* takes */
.takes { list-style: none; padding: 0; margin: 10px 0 0; }
.takes li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.takes li:first-child { border-top: 0; }
.takes li span:last-child { color: var(--green); font-weight: 700; white-space: nowrap; }

/* notice */
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; background: rgba(251, 191, 36, .1); border: 1px solid rgba(251, 191, 36, .35); font-weight: 600; }
.notice button { border: 0; border-radius: 10px; padding: 9px 12px; font-weight: 800; background: var(--amber); color: #1a1405; cursor: pointer; }

@media (max-width: 380px) {
  .hero-title { font-size: 22px; }
  .lights li { font-size: 12px; padding: 9px 8px; }
}
