
/* IMPORTANT: вернуть корректную работу атрибута hidden
   (иначе display:flex / display:inline-flex перебьёт UA-стиль) */
[hidden] { display: none !important; }

/* ====== THEME TOKENS ====== */
:root{
  /* Системный color-scheme по умолчанию — тёмный */
  color-scheme: dark;

  /* Dark theme */
  --bg: #05070D;                 /* почти чёрный */
  --fg: #E7ECF3;                 /* мягкий светлый текст */
  --muted:#9AA4B2;
  --acc: #67D2FF;

  /* стекло (тёмное) */
  --glass: rgba(12,16,28,.52);
  --glass-strong: rgba(18,22,34,.72);
  --stroke: rgba(255,255,255,.10);
  --shadow: 0 26px 70px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06);
  --radius: 18px;

  /* статусы */
  --chip-ok: rgba(16,185,129,.18);
  --chip-ok-stroke: rgba(16,185,129,.38);
  --chip-warn: rgba(245,158,11,.18);
  --chip-warn-stroke: rgba(245,158,11,.38);
  --chip-danger: rgba(239,68,68,.20);
  --chip-danger-stroke: rgba(239,68,68,.45);

  /* кнопки / фокус */
  --btn-grad-a:#1BB8EA;
  --btn-grad-b:#0C6CB4;
  --focus: 0 0 0 2px rgba(103,210,255,.75);

  /* meter / ranges */
  --track-bg: rgba(255,255,255,.06);
  --track-stroke: rgba(255,255,255,.10);
  --fill-grad-a:#1BB8EA;
  --fill-grad-b:#14B8A6;
}

/* Light theme overrides */
:root[data-theme="light"]{
  color-scheme: light;

  --bg: #F5F7FB;
  --fg: #0B1220;
  --muted:#5A6B7C;
  --acc: #0C6CB4;

  --glass: rgba(255,255,255,.72);
  --glass-strong: rgba(255,255,255,.90);
  --stroke: rgba(0,0,0,.08);
  --shadow: 0 24px 60px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.90);
  --radius: 18px;

  --chip-ok: rgba(16,185,129,.18);
  --chip-ok-stroke: rgba(16,185,129,.38);
  --chip-warn: rgba(245,158,11,.18);
  --chip-warn-stroke: rgba(245,158,11,.38);
  --chip-danger: rgba(239,68,68,.18);
  --chip-danger-stroke: rgba(239,68,68,.38);

  --btn-grad-a:#2AA7FF;
  --btn-grad-b:#0A6AC2;
  --focus: 0 0 0 2px rgba(12,108,180,.45);

  --track-bg: rgba(0,0,0,.05);
  --track-stroke: rgba(0,0,0,.10);
  --fill-grad-a:#1892F0;
  --fill-grad-b:#14B8A6;
}

/* ====== RESET & LAYOUT ====== */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; min-height:100svh; display:grid; place-items:center;
  font: 16px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  color: var(--fg); -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(1200px 800px at 15% -10%, #10243A 0%, transparent 60%),
    radial-gradient(1200px 800px at 120% 120%, #1C0E31 0%, transparent 60%),
    var(--bg);
}
:root[data-theme="light"] body{
  background:
    radial-gradient(1000px 700px at -10% -20%, #DBEAFE 0%, transparent 60%),
    radial-gradient(1000px 700px at 120% 120%, #FDE68A 0%, transparent 60%),
    var(--bg);
}

.card{
  width:min(1120px, 96vw);
  position:relative;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(115%);
  -webkit-backdrop-filter: blur(16px) saturate(115%);
  border:1px solid var(--stroke);
  border-radius: calc(var(--radius) + 2px);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card::before{
  content:""; position:absolute; inset:0; border-radius: inherit; pointer-events:none;
  background: linear-gradient(180deg, rgba(255,255,255,.07), transparent 38%);
}
:root[data-theme="light"] .card::before{ background: linear-gradient(180deg, rgba(255,255,255,.65), transparent 42%); }

.card__header{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px;}
.title{font-size: clamp(22px, 2.2vw, 28px); margin:0; letter-spacing:.2px}

.badges{display:flex; gap:8px; flex-wrap:wrap}
.chip{
  padding:6px 10px; border-radius:999px; font-size:13px;
  background: var(--glass-strong); border:1px solid var(--stroke);
}
.chip.ok{ background:var(--chip-ok); border-color:var(--chip-ok-stroke); }
.chip.warn{ background:var(--chip-warn); border-color:var(--chip-warn-stroke); }
.chip.danger{ background: var(--chip-danger); border-color: var(--chip-danger-stroke); }

.row{display:grid; grid-template-columns: 1fr 1fr; gap:16px}
@media (max-width: 980px){ .row{ grid-template-columns:1fr } }

.panel{
  display:flex; flex-direction:column; min-height: 520px;
  background: linear-gradient(180deg, rgba(20,24,36,.78), rgba(12,16,28,.58));
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  padding:16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
:root[data-theme="light"] .panel{
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.82));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
}

.footer{ margin-top:16px; display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap }

.label{display:block; font-size:13px; color:var(--muted); margin-bottom:6px}
.mono{font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size:13px}
.dim{opacity:.85}
.grow{flex:1 1 auto}
.sp{height:12px}

a{ color:var(--acc); text-decoration:none; border-bottom:1px dashed transparent }
a:hover{ border-bottom-color: currentColor }

/* ====== FIELDS / BUTTONS ====== */
.field, .range, .btn, .seg button{
  width:100%; border-radius:14px; outline:none;
}

/* поля ввода */
.field{
  padding:14px 16px; color:var(--fg);
  background: rgba(255,255,255,.06);
  border:1px solid var(--stroke);
  transition: box-shadow .15s ease, background .2s ease;
}
:root[data-theme="light"] .field{
  background: rgba(0,0,0,.04);
}
.field:focus-visible{ box-shadow: var(--focus) }

/* ====== RANGE (fix fill bleed & unify look) ====== */
.range{
  --p: 0%;
  -webkit-appearance:none; appearance:none;
  height:34px; background:transparent; padding:0; border:none;
}
.range:focus-visible{ outline:none; box-shadow: var(--focus) }

.range::-webkit-slider-runnable-track{
  height:6px; border-radius:999px;
  border:1px solid var(--track-stroke);
  background:
    linear-gradient(90deg, var(--fill-grad-a), var(--fill-grad-b)) 0 0/var(--p) 100% no-repeat,
    linear-gradient(90deg, rgba(103,210,255,.35), rgba(20,184,166,.30));
}
:root[data-theme="light"] .range::-webkit-slider-runnable-track{
  background:
    linear-gradient(90deg, var(--fill-grad-a), var(--fill-grad-b)) 0 0/var(--p) 100% no-repeat,
    var(--track-bg);
}

.range::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none;
  width:18px; height:18px; border-radius:50%;
  margin-top:-6px;
  background: linear-gradient(180deg, var(--btn-grad-a), var(--btn-grad-b));
  border:0; box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

.range::-moz-range-track{
  height:6px; border-radius:999px;
  border:1px solid var(--track-stroke);
  background:
    linear-gradient(90deg, var(--fill-grad-a), var(--fill-grad-b)) 0 0/var(--p) 100% no-repeat,
    linear-gradient(90deg, rgba(103,210,255,.35), rgba(20,184,166,.30));
}
:root[data-theme="light"] .range::-moz-range-track{ background:
  linear-gradient(90deg, var(--fill-grad-a), var(--fill-grad-b)) 0 0/var(--p) 100% no-repeat,
  var(--track-bg);
}
.range::-moz-range-thumb{
  width:18px; height:18px; border-radius:50%;
  background: linear-gradient(180deg, var(--btn-grad-a), var(--btn-grad-b));
  border:0; box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

/* ====== LEVEL METER ====== */
.meter{
  height:14px; border-radius:999px; overflow:hidden;
  background: var(--track-bg);
  border:1px solid var(--stroke);
}
.bar{
  height:100%; width:0%;
  background: linear-gradient(90deg, var(--fill-grad-a), var(--fill-grad-b));
  transition: width .08s linear;
}

/* ====== BUTTONS ====== */
.buttons{display:flex; gap:10px; margin-top:auto}

.btn{
  display:flex; align-items:center; justify-content:center; gap:10px;
  padding:14px 16px; font-weight:600; letter-spacing:.2px; color:var(--fg);
  cursor:pointer; user-select:none;
  transition: transform .06s ease, box-shadow .2s ease, opacity .15s ease, background .2s ease, border-color .2s ease;
}
.btn:active{ transform: translateY(1px) }
.btn[aria-pressed="true"]{ opacity:.95 }

.btn--primary{
  color:white;
  background: linear-gradient(180deg,var(--btn-grad-a),var(--btn-grad-b));
  border:none;
  text-shadow:0 1px 0 rgba(0,0,0,.35);
  box-shadow: 0 6px 18px rgba(12,108,180,.35);
}
.btn--primary:hover{ box-shadow: 0 10px 28px rgba(12,108,180,.45) }
.btn--primary:focus-visible{ box-shadow: var(--focus), 0 6px 18px rgba(12,108,180,.35) }

.btn--ghost{
  background: rgba(255,255,255,.05);
  border:1px solid var(--stroke);
}
:root[data-theme="light"] .btn--ghost{
  background: rgba(0,0,0,.04);
}
.btn--ghost:hover{ background: rgba(255,255,255,.08) }
:root[data-theme="light"] .btn--ghost:hover{ background: rgba(0,0,0,.06) }
.btn--ghost:focus-visible{ box-shadow: var(--focus) }

/* явное «нельзя нажать» */
.btn.is-disabled,
.btn:disabled{
  opacity:.45 !important;
  cursor:not-allowed !important;
  filter:saturate(.6);
  box-shadow:none !important;
}

/* ====== SEGMENT (PTT/LIVE) ====== */
.seg{
  display:inline-flex; border:1px solid var(--stroke); border-radius:12px; overflow:hidden;
  background: rgba(255,255,255,.06);
}
:root[data-theme="light"] .seg{ background: rgba(0,0,0,.05) }
.seg button{
  padding:10px 14px; border:0; background:transparent; color:var(--fg); cursor:pointer;
  font-weight:600; letter-spacing:.2px;
}
.seg button.active{ background: linear-gradient(180deg,var(--btn-grad-a),var(--btn-grad-b)); color:#fff }
.seg button:disabled{opacity:.55; cursor:default}

/* ====== PTT TOUCHPAD (mobile coarse pointer) ====== */
.ptt-wrap[hidden]{ display:none !important; }

.ptt-pad{
  display:block;
  width:100%;
  aspect-ratio:1/1;
  min-height:160px;
  max-height:360px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.04));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  color:var(--fg);
  font-weight:700;
  letter-spacing:.2px;
  cursor:pointer;
  user-select:none;
  -webkit-user-select:none;
  touch-action:none;             /* блокируем скролл/жесты */
  outline:none;
  position:relative;
}
:root[data-theme="light"] .ptt-pad{
  background: linear-gradient(180deg, rgba(0,0,0,.04), rgba(0,0,0,.02));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
}
.ptt-pad[disabled]{
  opacity:.5;
  cursor:not-allowed;
}
.ptt-pad:focus-visible{ box-shadow: var(--focus) }

.ptt-pad__text{
  position:absolute; inset:0;
  display:grid; place-items:center;
  font-size: clamp(14px, 3.6vw, 18px);
  opacity:.9;
}

/* pressed */
.ptt-pad[aria-pressed="true"]{
  background: linear-gradient(180deg, var(--btn-grad-a), var(--btn-grad-b));
  color:#fff;
  text-shadow: 0 1px 0 rgba(0,0,0,.35);
  box-shadow: 0 6px 18px rgba(12,108,180,.35);
}
.ptt-pad[aria-pressed="true"] .ptt-pad__text{
  opacity:1;
}

/* ====== RX SPEAKER (who talks) ====== */
.rx-speaker{
  margin-top: 10px;
  display:flex;
  align-items:center;
  gap:12px;

  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--stroke);

  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.04));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
:root[data-theme="light"] .rx-speaker{
  background: linear-gradient(180deg, rgba(0,0,0,.03), rgba(0,0,0,.02));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
}

.rx-speaker.is-active{
  border-color: rgba(103,210,255,.28);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.08),
    0 10px 30px rgba(12,108,180,.18);
}

.rx-speaker__avatar{
  width:44px; height:44px;
  border-radius: 999px;
  overflow:hidden;
  position:relative;
  flex: 0 0 auto;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.12);
}
:root[data-theme="light"] .rx-speaker__avatar{
  background: rgba(0,0,0,.06);
}

.rx-speaker__img{
  width:100%; height:100%;
  object-fit: cover;
  display:block;
}
.rx-speaker__fallback{
  position:absolute; inset:0;
  display:grid; place-items:center;
  font-weight:800;
  letter-spacing:.2px;
  opacity:.85;
}

.rx-speaker__body{flex:1 1 auto; min-width:0;}
.rx-speaker__top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.rx-speaker__name{
  font-weight:800;
  letter-spacing:.2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  min-width:0;
}
.rx-speaker__sub{
  margin-top: 2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* Live pill */
.rx-live{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border:1px solid rgba(16,185,129,.35);
  background: rgba(16,185,129,.16);
}
.rx-live__dot{
  width:8px; height:8px;
  border-radius:999px;
  background: rgba(16,185,129, .95);
  box-shadow: 0 0 0 6px rgba(16,185,129,.12);
  animation: rxPulse 1.2s ease-in-out infinite;
}
@keyframes rxPulse{
  0%,100%{ transform: scale(.95); opacity:.9; }
  50%{ transform: scale(1.15); opacity:1; }
}

/* mini equalizer */
.rx-eq{
  margin-top: 6px;
  height: 14px;
  display:flex;
  align-items:flex-end;
  gap:4px;
  opacity:.85;
}
.rx-eq span{
  width: 4px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--fill-grad-a), var(--fill-grad-b));
  transform-origin: bottom;
  animation: rxEq 900ms ease-in-out infinite;
  animation-play-state: paused; /* включаем только когда активен */
}
.rx-speaker.is-active .rx-eq span{
  animation-play-state: running;
}

.rx-eq span:nth-child(1){ animation-duration: 760ms; }
.rx-eq span:nth-child(2){ animation-duration: 920ms; }
.rx-eq span:nth-child(3){ animation-duration: 680ms; }
.rx-eq span:nth-child(4){ animation-duration: 980ms; }
.rx-eq span:nth-child(5){ animation-duration: 820ms; }

@keyframes rxEq{
  0%,100%{ transform: scaleY(.55); opacity:.75; }
  50%{ transform: scaleY(1.35); opacity:1; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce){
  .rx-live__dot, .rx-eq span{ animation: none !important; }
}

/* ====== MINI BUTTON (header) ====== */
.btn--mini{
  width:auto !important;
  padding:6px 10px !important;
  border-radius:999px !important;
  font-weight:800;
}

/* ====== AUTH MODAL ====== */
.modal[hidden]{ display:none !important; }
.modal{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal__backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal__card{
  position:relative;
  width: min(560px, 96vw);
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: var(--glass);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(18px) saturate(115%);
  -webkit-backdrop-filter: blur(18px) saturate(115%);
}
.modal__card::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  pointer-events:none;
  background: linear-gradient(180deg, rgba(255,255,255,.09), transparent 45%);
}
:root[data-theme="light"] .modal__card::before{
  background: linear-gradient(180deg, rgba(255,255,255,.72), transparent 48%);
}

.modal__top{
  display:flex;
  gap:12px;
  align-items:flex-start;
}
.modal__icon{
  width:42px;
  height:42px;
  border-radius: 14px;
  display:grid;
  place-items:center;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--stroke);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
:root[data-theme="light"] .modal__icon{
  background: rgba(0,0,0,.04);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
}

.modal__title{
  font-weight: 900;
  letter-spacing: .2px;
  font-size: 18px;
}
.modal__sub{
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.modal__actions{
  margin-top: 14px;
  display:flex;
  gap:10px;
}
@media (max-width: 520px){
  .modal__actions{ flex-direction: column; }
}
.modal__hint{
  margin-top: 10px;
}