/* =====================================================================
   VOICEMOD web client - dark premium theme
   ===================================================================== */
:root {
  --bg: #07070b;
  --bg-2: #0d0d14;
  --panel: rgba(20, 20, 30, 0.72);
  --panel-solid: #14141e;
  --panel-2: rgba(30, 30, 44, 0.7);
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #ececf4;
  --muted: #8e8ea6;
  --dim: #5d5d74;
  --violet: #8b5cf6;
  --violet-2: #a78bfa;
  --blue: #3b82f6;
  --cyan: #22d3ee;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --grad: linear-gradient(135deg, #a78bfa 0%, #7c3aed 45%, #3b82f6 100%);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
kbd {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.error { color: #fca5a5; margin: 14px 0 0; }

/* ------------------------------------------------------------ background */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(1200px 600px at 50% -10%, #15122a 0%, var(--bg) 60%); }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35; animation: float 18s var(--ease) infinite alternate; }
.orb-a { width: 520px; height: 520px; background: #6d28d9; top: -180px; left: -120px; }
.orb-b { width: 460px; height: 460px; background: #1d4ed8; bottom: -200px; right: -120px; animation-delay: -6s; }
.grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 0%, transparent 70%);
  opacity: .35;
}
@keyframes float { to { transform: translate(60px, 40px) scale(1.08); } }

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--panel-2);
  padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer;
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s, opacity .2s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: rgba(167, 139, 250, .45); }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .seg:focus-visible, .mode:focus-visible, .mic-btn:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--violet-2); outline-offset: 2px;
}
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 8px 30px rgba(124, 58, 237, .35); }
.btn-primary:hover { box-shadow: 0 10px 36px rgba(124, 58, 237, .55); }
.btn-primary:disabled { opacity: .55; cursor: progress; }
.btn-xl { width: 100%; padding: 15px 18px; font-size: 16px; border-radius: 14px; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); border-color: var(--line); }
.btn-soft { background: rgba(139, 92, 246, .12); border-color: rgba(139, 92, 246, .3); }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 10px; }
.btn-icon.on { color: var(--red); background: rgba(239, 68, 68, .12); }

.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* ------------------------------------------------------------ join screen */
.screen.join { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.join-card { width: 100%; max-width: 440px; border-radius: 24px; padding: 32px 28px; animation: rise .6s var(--ease); }
.join-card.center { text-align: center; display: grid; justify-items: center; gap: 12px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-lg { margin-bottom: 24px; }
.brand-lg h1 {
  font-size: 30px; font-weight: 800; letter-spacing: .04em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-lg p { margin: 2px 0 0; font-size: 13px; }
.lead { display: block; color: #cfcfe0; margin: 0 0 14px; }
.code-form input {
  width: 100%; text-align: center; font-family: var(--mono); font-size: 26px; letter-spacing: .18em;
  padding: 14px 12px; margin-bottom: 14px; text-transform: uppercase;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line-2); border-radius: 14px; color: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.code-form input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px rgba(139, 92, 246, .2); }
.how { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; color: var(--muted); font-size: 13.5px; }
.how summary { cursor: pointer; color: #cfcfe0; }
.how ol { padding-left: 18px; margin: 10px 0; }
.how li { margin: 6px 0; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--violet-2); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { border-radius: 12px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 16px; border: 1px solid; }
.banner.warn { background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .35); color: #fcd34d; }
.banner.danger { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .35); color: #fca5a5; }
.banner.info { background: rgba(59, 130, 246, .1); border-color: rgba(59, 130, 246, .35); color: #93c5fd; }

/* ------------------------------------------------------------ app layout */
.screen.app { max-width: 1240px; margin: 0 auto; padding: 16px 16px 120px; }
.topbar {
  position: sticky; top: 12px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px 10px 16px; border-radius: 16px;
}
.brand-name { font-weight: 800; letter-spacing: .06em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-pills { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line-2); background: var(--panel-2); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.pill-ok { color: #86efac; }
.pill-warn { color: #fcd34d; }
.pill-bad { color: #fca5a5; }
.pill-accent { color: #c4b5fd; border-color: rgba(139, 92, 246, .35); }
.pill .ico { width: 14px; height: 14px; }

.banners { display: grid; gap: 8px; margin: 12px 0 0; }
.banners .banner { margin: 0; animation: rise .4s var(--ease); }

.layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.col-me { display: grid; gap: 16px; }
.card { border-radius: var(--radius); padding: 18px; }
.card-title { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; margin-bottom: 12px; }

/* ------------------------------------------------------------ me card */
.me-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.me-name { font-size: 19px; font-weight: 700; word-break: break-all; }
.badges { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; border-radius: 6px; background: rgba(59, 130, 246, .15); color: #93c5fd; border: 1px solid rgba(59, 130, 246, .3); }
.badge.bedrock { background: rgba(34, 197, 94, .12); color: #86efac; border-color: rgba(34, 197, 94, .3); }
.badge-dim { background: var(--panel-2); color: var(--muted); border-color: var(--line); }

.avatar-wrap { position: relative; width: 52px; height: 52px; flex: none; }
.me-avatar { width: 64px; height: 64px; }
.avatar { width: 100%; height: 100%; border-radius: 14px; object-fit: cover; image-rendering: pixelated; position: relative; z-index: 1; background: var(--panel-solid); }
.avatar.initials { display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff; background: var(--grad); }
.level-ring, .speak-ring {
  position: absolute; inset: -4px; border-radius: 18px; z-index: 0;
  background: var(--grad); opacity: 0; transform: scale(.92);
  transition: opacity .12s, transform .12s;
}
.speak-ring { box-shadow: 0 0 24px rgba(139, 92, 246, .8); }
.peer.speaking .speak-ring { opacity: 1; transform: scale(1); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 34px rgba(59, 130, 246, .9); } }

.mic-btn {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 14px 16px; border-radius: 16px; cursor: pointer;
  background: rgba(34, 197, 94, .1); border: 1px solid rgba(34, 197, 94, .35); color: #bbf7d0;
  transition: background .2s, border-color .2s, color .2s, transform .15s var(--ease);
}
.mic-btn:active { transform: scale(.985); }
.mic-btn .mic-ico { width: 28px; height: 28px; }
.mic-text { display: grid; flex: 1; }
.mic-text strong { font-size: 16px; }
.mic-text small { color: var(--muted); }
.mic-btn.muted { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .4); color: #fecaca; }
.mic-btn.locked { background: rgba(245, 158, 11, .08); border-color: rgba(245, 158, 11, .35); color: #fde68a; cursor: not-allowed; }
.kbd-hint { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 6px; }

.meter { position: relative; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .06); margin-top: 14px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, #a3e635 60%, #f59e0b 85%, #ef4444); border-radius: 99px; transition: width 60ms linear; }
.meter-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #fff; opacity: .7; left: 50%; }
.tx-indicator { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.tx-indicator .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); transition: background .1s, box-shadow .1s; }
.tx-indicator.on { color: #86efac; }
.tx-indicator.on .dot { background: var(--green); box-shadow: 0 0 12px var(--green); }

/* ------------------------------------------------------------ controls */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: rgba(0, 0, 0, .3); border-radius: 12px; border: 1px solid var(--line); }
.seg { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; transition: background .2s, color .2s; }
.seg .ico { width: 16px; height: 16px; }
.seg.active { background: var(--grad); color: #fff; box-shadow: 0 4px 18px rgba(124, 58, 237, .4); }
.seg:disabled { opacity: .4; cursor: not-allowed; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .2); cursor: pointer; text-align: left; font-size: 13px; font-weight: 600; color: #cfcfe0; transition: border-color .2s, background .2s; }
.mode .ico { color: var(--violet-2); }
.mode.active { border-color: rgba(139, 92, 246, .6); background: rgba(139, 92, 246, .14); }
.mode:disabled { opacity: .4; cursor: not-allowed; }

.field { margin-top: 14px; display: grid; gap: 6px; }
.field label { font-size: 13px; color: #cfcfe0; display: flex; justify-content: space-between; }
.key-btn { justify-self: start; min-width: 90px; font-family: var(--mono); }
.key-btn.listening { border-color: var(--violet); animation: blink 1s infinite; }
@keyframes blink { 50% { box-shadow: 0 0 0 4px rgba(139, 92, 246, .25); } }
select { width: 100%; background: rgba(0, 0, 0, .35); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 10px; }
select option { background: var(--panel-solid); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .1); outline-offset: 4px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--violet); box-shadow: 0 0 0 4px rgba(139, 92, 246, .2); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 4px solid var(--violet); cursor: pointer; }
.toggle { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13.5px; color: #cfcfe0; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--violet); }

/* ------------------------------------------------------------ people */
.people-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 4px 12px; gap: 12px; }
.people-head h2 { font-size: 20px; display: flex; align-items: center; gap: 10px; }
.count { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: rgba(139, 92, 246, .18); color: #c4b5fd; }
.speaking-now { font-size: 13px; color: #86efac; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peers { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.peer { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: var(--radius); animation: rise .35s var(--ease); transition: border-color .2s, opacity .3s; }
.peer.speaking { border-color: rgba(139, 92, 246, .55); }
.peer.far { opacity: .55; }
.peer-main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.peer-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.peer-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-flags { display: inline-flex; gap: 4px; color: var(--muted); }
.peer-flags .ico { width: 15px; height: 15px; }
.peer-flags .red { color: var(--red); }
.peer-dist { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.bars i { width: 3px; border-radius: 1px; background: var(--line-2); }
.bars i:nth-child(1) { height: 25%; } .bars i:nth-child(2) { height: 50%; } .bars i:nth-child(3) { height: 75%; } .bars i:nth-child(4) { height: 100%; }
.bars i.on { background: var(--violet-2); }
.peer-vol { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.peer-vol .ico { width: 15px; height: 15px; }
.vol-val { font-size: 11.5px; width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.peer-actions { display: grid; gap: 4px; }
.peer.local-muted .peer-vol { opacity: .4; }

.empty { border-radius: var(--radius); padding: 40px 24px; text-align: center; display: grid; justify-items: center; gap: 4px; }
.empty-ico { width: 44px; height: 44px; color: var(--violet-2); margin-bottom: 8px; opacity: .8; }
.empty p { margin: 0; }
.nearby { margin-top: 18px; }
.nearby h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 4px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 10px; border-radius: 99px; font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line); }

/* ------------------------------------------------------------ PTT FAB */
.ptt-fab {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 18px 34px; border-radius: 999px; z-index: 10;
  border: 0; background: var(--grad); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 14px 40px rgba(124, 58, 237, .5); touch-action: none; user-select: none; -webkit-user-select: none;
  transition: transform .12s var(--ease), box-shadow .2s;
}
.ptt-fab .ico { width: 22px; height: 22px; }
.ptt-fab.held { transform: translateX(-50%) scale(1.06); box-shadow: 0 0 0 10px rgba(139, 92, 246, .25), 0 14px 50px rgba(59, 130, 246, .7); }

/* ------------------------------------------------------------ toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 20; max-width: min(360px, calc(100vw - 32px)); }
.toast { padding: 11px 14px; border-radius: 12px; background: var(--panel-solid); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 13.5px; animation: rise .3s var(--ease); }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .3s; }
.toast.error { border-color: rgba(239, 68, 68, .45); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .col-people { order: -1; }
}
@media (max-width: 520px) {
  .screen.app { padding: 10px 10px 120px; }
  .topbar { top: 8px; padding: 8px 8px 8px 12px; }
  .brand-name { display: none; }
  .peers { grid-template-columns: 1fr; }
  .join-card { padding: 26px 20px; }
  .toasts { left: 16px; right: 16px; bottom: 90px; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
