:root {
  --bg: #1e1b2e;
  --fg: #ece9f7;
  --muted: #9d97b8;
  --accent: #7c6cf0;
  --ok: #4ade80;
  --warn: #fbbf24;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, "Segoe UI", sans-serif;
  display: grid;
  place-items: center;
}
main { text-align: center; padding: 16px; width: min(360px, 100%); }
[hidden] { display: none !important; }
h1 { font-weight: 600; font-size: 1.5rem; margin: 0.5rem 0; }
p { color: var(--muted); margin: 0.25rem 0 1rem; min-height: 1.4em; }
form { display: grid; gap: 12px; }
input, button {
  font: inherit;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid #3a3556;
  background: #2a2640;
  color: var(--fg);
}
button { cursor: pointer; background: var(--accent); border-color: var(--accent); }
button:hover { filter: brightness(1.1); }
button.off { background: #b4455a; border-color: #b4455a; }
.controls { display: flex; gap: 12px; justify-content: center; }
.error { color: #f87171; }
.orb {
  width: 120px; height: 120px; margin: 0 auto 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c4b5fd, var(--accent));
  opacity: 0.4; transition: opacity .3s, box-shadow .3s;
}
.orb.waiting { opacity: 0.4; }
.orb.connecting { opacity: 0.7; animation: pulse 1.2s ease-in-out infinite; }
.orb.live { opacity: 1; box-shadow: 0 0 40px 8px rgba(124, 108, 240, .55); }
@keyframes pulse { 50% { transform: scale(1.08); } }

.hint { font-size: 0.9rem; }
.gear {
  position: fixed; top: 12px; right: 12px; width: 44px; height: 44px; padding: 0;
  font-size: 1.4rem; background: #2a2640; border-color: #3a3556; color: var(--muted);
}
button.secondary { background: #2a2640; border-color: #3a3556; padding: 8px 12px; }
select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid #3a3556; background: #2a2640; color: var(--fg); width: 100%; }

dialog {
  background: var(--bg); color: var(--fg); border: 1px solid #3a3556; border-radius: 14px;
  width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; padding: 12px 16px;
  scrollbar-width: none;   /* still scrolls with the wheel or touch, just without a visible bar */
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 4px; font-size: 1.1rem; }
dialog form { display: grid; gap: 8px; text-align: left; }
dialog label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); }
dialog label.inline { display: flex; align-items: center; gap: 8px; color: var(--fg); }
dialog output { float: right; color: var(--fg); }
dialog input[type=range] { padding: 0; width: 100%; accent-color: var(--accent); }
dialog fieldset { border: 1px solid #3a3556; border-radius: 10px; display: grid; gap: 6px; margin: 0; }
dialog legend { color: var(--muted); font-size: 0.85rem; padding: 0 6px; }
dialog .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; }
.meter { position: relative; height: 10px; border-radius: 5px; background: #2a2640; overflow: hidden; }
#meter-fill { height: 100%; width: 0; background: var(--ok); transition: width .05s linear; }
#meter-fill.closed { background: #6b6788; }
#meter-thresh { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--warn); }
dialog::-webkit-scrollbar { display: none; }
dialog .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog fieldset { padding: 6px 10px; gap: 2px; }

.talk { width: 100%; padding: 28px 16px; font-size: 1.2rem; margin: 12px 0 4px; touch-action: none; user-select: none; -webkit-user-select: none; }
.talk.held { background: var(--ok); border-color: var(--ok); color: #0b2e18; }
