:root {
  --bg0: #07090f;
  --bg1: #0d1220;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.09);
  --text: #eef1f8;
  --muted: #8b93a7;
  --pink: #ff2d95;
  --violet: #7b5cff;
  --cyan: #00d4ff;
  --green: #2ee6a8;
  --red: #ff5470;
  --accent: linear-gradient(135deg, #ff2d95 0%, #7b5cff 55%, #00d4ff 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(123, 92, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(0, 212, 255, 0.12), transparent 55%),
    var(--bg0);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--cyan); }

.wrap { max-width: 1180px; margin: 0 auto;
  padding: 20px 16px 8px;
  scroll-padding-bottom: calc(118px + env(safe-area-inset-bottom)); }

.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: 0.4px; font-size: 20px;
}
.logo .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(255, 45, 149, 0.8);
}
.grad-text { background: var(--accent); -webkit-background-clip: text; background-clip: text; color: transparent; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 12px; font-size: 16px; letter-spacing: 0.3px; }
.muted { color: var(--muted); font-size: 13px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

button, .btn {
  appearance: none; border: 1px solid var(--border);
  background: var(--card2); color: var(--text);
  border-radius: 12px; padding: 10px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, opacity 0.15s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
  justify-content: center;
}
button:hover, .btn:hover { background: rgba(255, 255, 255, 0.13); }
button:active { transform: scale(0.98); }
button.primary { background: var(--accent); border: none; color: #fff; }
button.primary:hover { filter: brightness(1.1); }
button.danger { color: var(--red); border-color: rgba(255, 84, 112, 0.35); }
button.ghost { background: transparent; }
button[disabled] { opacity: 0.45; cursor: not-allowed; }

input, select, textarea {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--violet); }
input[type="checkbox"] { width: auto; }
input[type="range"] { padding: 0; }

label.field, div.field { display: block; margin-bottom: 12px; }
label.field span, div.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.toggle { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 14px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--violet); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--border); background: var(--card2);
}
.pill.live { color: var(--green); border-color: rgba(46, 230, 168, 0.4); }
.pill.off { color: var(--red); border-color: rgba(255, 84, 112, 0.4); }
.pill .blink { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.live .blink { animation: none; }
@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: 0.25 } }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 8px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: middle; }
tr:hover td { background: rgba(255, 255, 255, 0.025); }

.eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 22px; }
.eq i { width: 4px; border-radius: 2px; background: var(--accent); animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(1) { height: 40%; animation-delay: 0s; }
.eq i:nth-child(2) { height: 90%; animation-delay: 0.15s; }
.eq i:nth-child(3) { height: 60%; animation-delay: 0.3s; }
.eq i:nth-child(4) { height: 80%; animation-delay: 0.45s; }
.eq i:nth-child(5) { height: 35%; animation-delay: 0.6s; }
.eq.paused i { animation-play-state: paused; }
@keyframes eq { 0%,100% { transform: scaleY(0.4) } 50% { transform: scaleY(1) } }

.progress { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 4px; transition: width 1s linear; }

.toast {
  position: fixed; bottom: calc(124px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: #161c2c; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 18px; font-size: 14px; z-index: 100;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
  max-width: 90vw;
}
.toast.show { opacity: 1; }
.toast.err { border-color: rgba(255, 84, 112, 0.5); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff;
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }

.scroll { max-height: 420px; overflow: auto; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.18);
  border-radius: 14px; padding: 26px; text-align: center;
  color: var(--muted); cursor: pointer; transition: 0.15s;
}
.dropzone.hover, .dropzone:hover { border-color: var(--violet); color: var(--text); background: rgba(123, 92, 255, 0.06); }

.hidden { display: none !important; }

.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* список загруженных подложек */
.bed-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.bed-row { display: flex; align-items: stretch; gap: 8px; }
.bed-row button { margin: 0; }
.bed-row button.pick { flex: 0 0 auto; min-width: 108px; text-align: center; }
.bed-row button.pick[aria-pressed="true"] { background: var(--accent); border: none; color: #fff; }
.bed-row button.danger { flex: 0 0 auto; }
.bed-row { padding: 2px 0; }
.bed-row.chosen { background: rgba(124, 92, 255, .12); border-radius: 12px; }
.bed-name { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px 2px; }
.bed-tag { flex: 0 0 auto; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; }
.bed-row button.listen { flex: 0 0 auto; }


/* ================= Раскладка панели: сайдбар + мобильные вкладки ================= */
#app { max-width: 1380px; }
body.panel .wrap { max-width: none; margin: 0; padding: 20px 24px 20px 264px; }

#mainNav {
  display: flex; flex-direction: column; gap: 4px;
  position: fixed; left: 0; top: 0; bottom: 0; width: 236px;
  padding: 16px 12px; overflow-y: auto;
  background: linear-gradient(180deg, rgba(22, 28, 48, 0.96), rgba(9, 12, 21, 0.98));
  border-right: 1px solid var(--border);
  z-index: 45;
}
#mainNav::-webkit-scrollbar { width: 6px; }
#mainNav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 17px; letter-spacing: 0.3px;
  padding: 6px 8px 16px;
}
.nav-brand .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 16px rgba(255,45,149,.8); }

#mainNav .tab {
  justify-content: flex-start; gap: 12px; width: 100%;
  background: transparent; border: 1px solid transparent;
  padding: 11px 12px; border-radius: 12px;
  font-size: 14px; font-weight: 600; color: var(--muted);
  text-align: left;
}
#mainNav .tab .ico { font-size: 17px; line-height: 1; width: 22px; text-align: center; }
#mainNav .tab:hover { background: rgba(255,255,255,.06); color: var(--text); }
#mainNav .tab.active {
  background: var(--accent); color: #fff; border-color: transparent;
  box-shadow: 0 8px 24px rgba(123, 92, 255, 0.28);
}

/* карточки чуть живее */
.card { transition: border-color .18s ease, background .18s ease; }
.card:hover { border-color: rgba(255,255,255,.16); }

@media (max-width: 860px) {
  body.panel .wrap { padding: 14px 12px calc(104px + env(safe-area-inset-bottom)); }
  #mainNav {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: auto;
    flex-direction: row; gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-top: 1px solid var(--border);
    background: rgba(10, 14, 24, 0.96);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  }
  #mainNav .nav-brand { display: none; }
  #mainNav .tab {
    flex: 0 0 auto; width: auto; flex-direction: column; gap: 3px;
    padding: 7px 12px; font-size: 11px; border-radius: 10px;
  }
  #mainNav .tab .ico { font-size: 19px; width: auto; }
  #mainNav .tab .lbl { white-space: nowrap; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* Компьютер: нижняя навигация плеера не нужна — есть сайдбар */
@media (min-width: 861px) {
  #bottomNav { display: none !important; }
  .player-bar { left: 236px; }
  body.panel .wrap { padding-bottom: 92px; }
}
/* Телефон: семь разделов прячем, снизу работает навигация плеера */
@media (max-width: 860px) {
  #mainNav { display: none !important; }
  body.panel .wrap { padding-left: 12px; }
}

/* Раскладка по типу устройства (класс ставит скрипт) */
body.is-desktop #bottomNav { display: none !important; }
body.is-desktop #mainNav { display: flex; }
body.is-desktop .player-bar { left: 236px; }
body.is-desktop .wrap { padding-left: 264px; padding-bottom: 92px; }

body.is-mobile #mainNav, body.is-tablet #mainNav { display: none !important; }
body.is-mobile .player-bar, body.is-tablet .player-bar { left: 0; }
body.is-mobile .wrap, body.is-tablet .wrap { padding: 14px 12px calc(112px + env(safe-area-inset-bottom)); }

.bed-row .bed-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) {
  .bed-row { flex-wrap: wrap; }
  .bed-row .bed-name { flex: 1 1 100%; white-space: normal; padding: 6px 2px 0; }
  .bed-row button { flex: 1 1 auto; min-width: 0; }
  .bed-row button.pick { min-width: 0; }
}

#liveHint { overflow-wrap: anywhere; line-height: 1.45; }
.toast { max-width: min(92vw, 420px); max-height: 46vh; overflow: auto;
  white-space: normal; overflow-wrap: anywhere; text-align: left; }
