:root {
  --bg: #0B0C10;
  --surface: #14161C;
  --surface-2: #1B1E26;
  --line: #262A35;
  --text: #ECEEF3;
  --muted: #8A90A0;
  --accent: #7C6CFF;
  --accent-2: #FF5C8A;
  --ok: #3DD68C;
  --danger: #FF4D4F;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
.mono { font-family: ui-monospace, "SF Mono", "Roboto Mono", monospace; }
.upper { text-transform: uppercase; letter-spacing: .12em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
small { display: block; font-size: 12px; }

/* screens */
.screen {
  position: absolute; inset: 0; display: none; flex-direction: column;
  padding: calc(20px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  overflow-y: auto;
}
.screen.active { display: flex; }

/* brand */
.brand { text-align: center; margin: 28px 0 24px; }
.brand h1 { margin: 14px 0 6px; font-size: 28px; letter-spacing: -.02em; }
.brand p { margin: 0 auto; max-width: 300px; }
.logo { width: 56px; height: 56px; margin: 0 auto; position: relative; }
.logo span {
  position: absolute; width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--accent); top: 10px;
}
.logo span:first-child { left: 0; }
.logo span:last-child { right: 0; border-color: var(--accent-2); }

/* card & forms */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
form.card { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 12px; padding: 13px 14px; font-size: 16px;
  outline: none; user-select: text; -webkit-user-select: text;
}
input:focus { border-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; }
.row > input { flex: 1; }
details summary { color: var(--muted); font-size: 13px; cursor: pointer; margin-bottom: 8px; }

button {
  font: inherit; font-weight: 600; border: 0; border-radius: 12px;
  padding: 13px 16px; cursor: pointer; color: var(--text); background: var(--surface-2);
  transition: transform .08s, opacity .15s;
}
button:active { transform: scale(.97); }
button.primary { background: linear-gradient(135deg, var(--accent), #9B6CFF); }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.danger { background: var(--danger); }
button.link { background: none; color: var(--muted); font-weight: 500; }
button.icon { background: none; font-size: 22px; padding: 6px 12px; }
.row button { flex: 1; }
.row > input + button { flex: 0 0 auto; }

.perms { display: flex; align-items: center; gap: 12px; }
.perms > div { flex: 1; }

/* lobby */
.lobby { margin: auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lobby h2 { margin: 18px 0 0; }
.pulse {
  width: 84px; height: 84px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(124,108,255,.6); animation: pulse 1.8s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 28px rgba(124,108,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(124,108,255,0); }
}
.consent { margin-top: 22px; text-align: left; width: 100%; }
.consent p { margin: 0 0 10px; }

/* pad */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.peer { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.warn { background: #FFB020; }

.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.meter {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center;
}
.meter small { grid-column: 1 / -1; color: var(--muted); }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .06s linear; }
.bar.in i { background: var(--accent-2); }
.meter span { font-size: 13px; min-width: 38px; text-align: right; }

.pad-wrap {
  flex: 1; position: relative; min-height: 240px;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(120% 80% at 50% 0%, #191B27 0%, var(--surface) 70%);
}
#pad { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.axis {
  position: absolute; top: 10px; bottom: 10px; left: 12px; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 10px; letter-spacing: .15em; color: var(--muted);
}

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.toggle { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); }
.sw { width: 34px; height: 20px; border-radius: 10px; background: var(--line); position: relative; transition: background .15s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on .sw { background: var(--ok); }
.toggle.on .sw::after { left: 17px; }

.sheet {
  position: absolute; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 -10px 40px rgba(0,0,0,.5);
}

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translate(-50%, 20px);
  background: var(--surface-2); border: 1px solid var(--line); padding: 10px 16px;
  border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- v2 additions ---- */
.center { margin: auto; }
.error { color: var(--danger); font-size: 13px; margin: -4px 0 0; }
.wide { width: 100%; }
.row.tight { gap: 0; }
.row.tight button { flex: 0 0 auto; }
.icon { display: inline-flex; align-items: center; justify-content: center; color: var(--text); }
.nudge { margin-top: 18px; }
.pulse.off { background: var(--surface-2); animation: none; box-shadow: none; }
.lobby { flex: 1; justify-content: center; }
.note {
  margin: 0 0 12px; padding: 10px 12px; font-size: 12px; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line); border-radius: 12px;
}
.danger-text { color: var(--danger); }
.setup-card { display: flex; align-items: center; gap: 12px; }
.setup-card > div { flex: 1; }
#menu { z-index: 10; }
button:disabled { opacity: .5; }

.axis-x {
  position: absolute; left: 12px; right: 12px; bottom: 8px; pointer-events: none;
  display: flex; justify-content: space-between; padding-left: 34px;
  font-size: 10px; letter-spacing: .15em; color: var(--muted);
}
