:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --accent: #0ea5e9;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --radius: 12px;
  --session-bar-h: 44px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1e293b, #020617);
  color: var(--text);
  line-height: 1.5;
}

.header {
  padding: 0.5rem 1rem 0.3rem;
  text-align: center;
  border-bottom: 0px solid #1f2937;
}

.header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
}

.header p {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

#logoHeader {
  text-align: center;
  padding: 0.2rem 0;
}

/* ===== DESKTOP DEFAULT ===== */
.main {
  display: flex;
  flex-direction: row;
  gap: 1.5rem;
  padding: 0.5rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Player section */
.player-section {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  flex: 2;
}

#player-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  margin-bottom: 1rem;
}

#player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin-top: -4px;
}

/* Controls */
.controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.btn {
  flex: 1;
  padding: 0.8rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: #111827;
  color: var(--text);
  transition: all 0.2s ease;
}

.btn:hover {
  background: #1f2937;
  transform: translateY(-2px);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #0b1120;
}

.btn-primary:hover {
  background: #06b6d4;
}

/* Autoplay & mute toggles */
.autoplay-controls {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.autoplay-controls label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.autoplay-controls input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Current info */
.current-info {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

/* ===== LIST SECTION ===== */
.list-section {
  background: #020617;
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid #1f2937;
  flex: 1;
  display: flex;
  flex-direction: column;
  max-height: 700px;
  overflow: hidden;
  padding-bottom: 0.75rem;
}

.list-section h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

/* Przypięty licznik */
#statsLabel {
  position: sticky;
  top: 0;
  background: #020617;
  padding: 0.4rem 0;
  z-index: 10;
  font-size: 0.9rem;
}

/* Lista filmów — JEDYNY scroll */
#playlistList {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex-grow: 1;
  padding-right: 6px;
  padding-bottom: var(--session-bar-h);
}

#playlistList::-webkit-scrollbar {
  width: 6px;
}

#playlistList::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 3px;
}

.playlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  background: #111827;
  transition: all 0.15s ease;
  font-size: 0.88rem;
}

.playlist-item:hover {
  background: #1f2937;
  transform: translateX(4px);
}

.playlist-item.active {
  background: var(--accent);
  color: #0b1120;
  font-weight: 600;
  border-left: 3px solid #06b6d4;
}

.item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 0.6rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.playlist-item.active .item-meta {
  color: #0b1120;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1rem 1rem 1.2rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid #1f2937;
}

.footer-inner {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

.footer a:hover {
  color: #06b6d4;
  text-shadow: 0 0 6px rgba(6, 182, 212, 0.6);
}

.footer-inner .dot {
  padding: 0 6px;
  color: var(--muted);
}

.coffee-link {
  color: #facc15;
}

.coffee-link:hover {
  color: #fde047;
  text-shadow: 0 0 6px rgba(253, 224, 71, 0.6);
}

/* Session time with index */
#sessionTime {
  margin-top: auto;
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  gap: 0.5rem;
}

.session-left {
  flex: 1;
}

.session-right {
  font-weight: 600;
  opacity: 0.9;
  white-space: nowrap;
  flex-shrink: 0;
}

.video-description {
  margin-top: 0.8rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
  background: #0b1120;
  padding: 1rem;
  border-radius: var(--radius);
  display: none;
}

.spaz-tuba-counter {
  color: #22c55e;
  font-weight: 600;
  display: inline-block;
}

/* Autoplay row layout */
.autoplay-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.autoplay-controls-left {
  flex-basis: 100%;
}

.autoplay-controls-right {
  display: flex;
  align-items: center;
  gap: 31px;
}

.autoplay-controls-right label {
  white-space: nowrap;
}

.current-info {
  font-size: 14px;
  opacity: 0.8;
  text-align: right;
  min-width: 120px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

#volumeSlider {
  width: 180px;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
  vertical-align: middle;
}

#volumeIcon {
  font-size: 18px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  margin: 0;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

/* Playlist select */
.playlist-select {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
}

.playlist-select label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  white-space: nowrap;
}

.playlist-select input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Mobile */
@media (max-width: 768px) {
  .video-description {
    display: none !important;
  }

  .main {
    flex-direction: column;
  }

  #player-container {
    padding-top: 60%;
  }

  .list-section {
    max-height: 65vh;
  }

  #playlistList {
    max-height: calc(65vh - 3rem - var(--session-bar-h));
    padding-bottom: var(--session-bar-h);
  }

  .controls {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .playlist-select {
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .playlist-select label {
    flex: 0 1 auto;
    font-size: 0.85rem;
  }

  #sessionTime {
    flex-direction: row;
    align-items: center;
    gap: 0.3rem;
  }

  .session-left {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
  }

  .session-right {
    margin-left: auto;
    white-space: nowrap;
  }

  .playlist-item {
    font-size: 0.8rem;
  }

  .autoplay-row {
    gap: 0.6rem;
  }

  .autoplay-controls-right {
    gap: 0.8rem;
    flex-wrap: wrap;
  }

  .current-info {
    min-width: auto;
    font-size: 0.85rem;
  }

  #volumeSlider {
    width: 100px;
  }
}

/* Ultra small */
@media (max-width: 480px) {
  #player-container {
    padding-top: 65%;
  }

  .playlist-select label {
    width: auto;
    font-size: 0.8rem;
  }

  .playlist-item {
    font-size: 0.75rem;
    padding: 0.5rem;
  }

  .current-info {
    font-size: 0.8rem;
    min-width: auto;
  }

  #volumeSlider {
    width: 80px;
  }

  #sessionTime {
    font-size: 0.75rem;
  }

  .session-left {
    font-size: 0.75rem;
  }

  .session-right {
    font-size: 0.75rem;
  }
}

@media (max-width: 600px) {
  #logoHeader img {
    max-width: 140px;
  }

  .footer-inner {
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.9rem;
  }

  .footer-inner span:not(.dot) {
    display: none;
  }
}