:root {
  color-scheme: dark;
  --bg: #080a0d;
  --panel: #11151a;
  --panel-2: #171c22;
  --border: #27303a;
  --text: #f5f7f8;
  --muted: #98a2ad;
  --accent: #33d17a;
  --accent-dark: #1f9d59;
  --danger: #ff6b6b;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(51, 209, 122, 0.12), transparent 35rem),
    radial-gradient(circle at 100% 30%, rgba(51, 209, 122, 0.06), transparent 28rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
.button-link {
  border: 0;
  border-radius: 0.8rem;
  padding: 0.72rem 1rem;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.78rem 0.9rem;
  color: var(--text);
  background: #0c1014;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 209, 122, 0.12);
}

label span {
  display: block;
  margin-bottom: 0.42rem;
  color: var(--muted);
  font-size: 0.84rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.2rem;
  font-size: clamp(1.65rem, 4vw, 2.5rem);
}

h2 {
  margin-bottom: 0.3rem;
  font-size: 1.18rem;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 0.8rem;
  line-height: 1.5;
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.primary {
  color: #06110b;
  background: var(--accent);
  font-weight: 800;
}

.primary:hover {
  background: #46dc8b;
}

.secondary,
.ghost,
.chip,
.round {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.danger {
  color: #ffecec;
  background: rgba(255, 107, 107, 0.16);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.small {
  padding: 0.55rem 0.78rem;
}

.wide {
  width: 100%;
}

.button-link {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.badge,
.status-dot {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(17, 21, 26, 0.8);
  font-size: 0.8rem;
}

.status-dot.connected {
  color: #b8ffd4;
  border-color: rgba(51, 209, 122, 0.35);
  background: rgba(51, 209, 122, 0.12);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 0.75rem;
}

.header-actions,
.inline-actions,
.queue-actions,
.device-row,
.volume-row,
.mini-controls {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 1rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem clamp(1rem, 3vw, 2rem) 2rem;
}

.card {
  min-width: 0;
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: linear-gradient(180deg, rgba(23, 28, 34, 0.95), rgba(13, 17, 21, 0.96));
  box-shadow: var(--shadow);
}

.now-card {
  grid-column: 1 / -1;
}

.info-card {
  align-self: start;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.now-content {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: clamp(1rem, 4vw, 2rem);
  align-items: center;
}

.cover {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 1rem;
  object-fit: cover;
  background: #0a0c0f;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
}

.cover.fallback {
  display: grid;
  place-items: center;
  font-size: 5rem;
  color: var(--accent);
  background:
    linear-gradient(145deg, rgba(51, 209, 122, 0.24), rgba(51, 209, 122, 0.02)),
    #0b0f12;
}

.player-panel {
  min-width: 0;
}

.progress-wrap {
  display: grid;
  grid-template-columns: 3.5rem 1fr 3.5rem;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.progress {
  height: 0.42rem;
  overflow: hidden;
  border-radius: 999px;
  background: #2b333d;
}

.progress > div {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin: 1.3rem 0;
}

.round {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 50%;
}

.primary-round {
  width: 4rem;
  height: 4rem;
  color: #06110b;
  background: var(--accent);
  border-color: transparent;
  font-size: 1.25rem;
}

.grow {
  flex: 1;
}

.volume-row {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr) 3rem;
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.mini-controls {
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

.chip.active {
  color: #c8ffdc;
  border-color: rgba(51, 209, 122, 0.4);
  background: rgba(51, 209, 122, 0.13);
}

.owner-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
}

.search-info {
  min-height: 1.4rem;
  margin: 0.8rem 0;
  font-size: 0.85rem;
}

.track-list {
  display: grid;
  gap: 0.65rem;
}

.track-row {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: rgba(10, 13, 16, 0.55);
}

.track-image {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 0.65rem;
  object-fit: cover;
  background: #0a0c0f;
}

.track-main {
  min-width: 0;
}

.track-title,
.track-subtitle,
.track-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-title {
  margin: 0;
  font-weight: 750;
}

.track-subtitle,
.track-meta {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.track-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.icon-btn {
  min-width: 2.2rem;
  padding: 0.52rem 0.65rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.queue-actions {
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.empty-state {
  padding: 1.2rem;
  border: 1px dashed var(--border);
  border-radius: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 1rem;
  bottom: 1rem;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: #151a20;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.7rem);
  transition: 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(255, 107, 107, 0.45);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-shell {
  width: min(100%, 460px);
}

.login-card {
  padding: clamp(1.4rem, 5vw, 2.2rem);
  border: 1px solid var(--border);
  border-radius: 1.4rem;
  background: rgba(17, 21, 26, 0.96);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  margin-bottom: 1.25rem;
  border-radius: 1.2rem;
  color: #051009;
  background: var(--accent);
  font-size: 2rem;
  font-weight: 900;
}

.stack {
  display: grid;
  gap: 1rem;
  margin-top: 1.3rem;
}

.notice {
  margin: 1rem 0;
  padding: 0.8rem 0.9rem;
  border-radius: 0.75rem;
  background: rgba(51, 209, 122, 0.12);
  border: 1px solid rgba(51, 209, 122, 0.3);
}

.notice.error {
  color: #ffdede;
  background: rgba(255, 107, 107, 0.11);
  border-color: rgba(255, 107, 107, 0.3);
}

@media (max-width: 900px) {
  .page-grid {
    grid-template-columns: 1fr;
  }

  .now-card {
    grid-column: auto;
  }

  .now-content {
    grid-template-columns: 150px minmax(0, 1fr);
  }
}

@media (max-width: 620px) {
  .topbar,
  .owner-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .now-content {
    grid-template-columns: 1fr;
  }

  .cover {
    max-width: 240px;
    margin: 0 auto;
  }

  .device-row {
    align-items: stretch;
    flex-direction: column;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .track-row {
    grid-template-columns: 3.2rem minmax(0, 1fr);
  }

  .track-image {
    width: 3.2rem;
    height: 3.2rem;
  }

  .track-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

/* Transmisja audio WebRTC */
.audio-card {
  grid-column: 1 / -1;
}

.audio-header-badges,
.audio-pane-heading,
.audio-main-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.audio-header-badges {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.status-dot.audio-error {
  color: #ffdede;
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.12);
}

.audio-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.audio-layout.listener-only {
  grid-template-columns: 1fr;
}

.audio-pane {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(8, 12, 15, 0.54);
}

.audio-pane-heading {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.8rem;
}

.audio-pane h3 {
  margin: 0;
  font-size: 1.08rem;
}

.audio-pulse {
  display: grid;
  flex: 0 0 auto;
  width: 3.3rem;
  height: 3.3rem;
  place-items: center;
  border: 1px solid rgba(51, 209, 122, 0.28);
  border-radius: 50%;
  color: var(--accent);
  background: rgba(51, 209, 122, 0.08);
  font-size: 1.45rem;
  transition: box-shadow 180ms ease, transform 180ms ease;
}

.audio-pulse.streaming {
  box-shadow:
    0 0 0 8px rgba(51, 209, 122, 0.08),
    0 0 30px rgba(51, 209, 122, 0.2);
  animation: audio-pulse 1.5s ease-in-out infinite;
}

@keyframes audio-pulse {
  50% {
    transform: scale(1.05);
  }
}

.audio-main-actions {
  margin-top: 1rem;
  flex-wrap: wrap;
}

.audio-volume-row {
  margin-top: 1rem;
}

.audio-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 1rem;
}

.audio-stats > div {
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: rgba(17, 21, 26, 0.72);
}

.audio-stats span,
.audio-device-label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.audio-stats strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-device-label {
  margin-top: 1rem;
}

.audio-meter {
  height: 0.55rem;
  margin: 1rem 0;
  overflow: hidden;
  border-radius: 999px;
  background: #2b333d;
}

.audio-meter > div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #dce85b, #ff7a70);
  transition: width 70ms linear;
}

.audio-status-copy {
  min-height: 1.3rem;
  margin: 0.85rem 0 0;
}

@media (max-width: 900px) {
  .audio-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .audio-header-badges,
  .audio-pane-heading {
    width: 100%;
    justify-content: space-between;
  }

  .audio-stats {
    grid-template-columns: 1fr;
  }

  .audio-main-actions > button {
    width: 100%;
  }
}
