* {
  box-sizing: border-box;
}

:root {
  --leman-bleu: #0aa8ea;
  --leman-bleu-soft: color-mix(in srgb, var(--leman-bleu) 8%, transparent);
}

body {
  margin: 0;
  font-family: "ProximaNova","Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
  background: #f3f4f6;
  color: var(--leman-bleu);
  overflow: hidden;
}

.layout {
  height: 100vh;
  height: 100dvh;
  display: flex;
}

.radio-panel {
  width: 100%;
  background: #f7f7f8;
  border-right: 1px solid #e5e7eb;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.cover-wrap {
  grid-row: 1;
  position: relative;
  width: 100%;
  background: #ffffff;
  display: flex;
  justify-content: center;
  --now-cover-max-side: 30vh;
  --now-cover-size: min(100%, var(--now-cover-max-side));
}

#nowCover {
  display: block;
  box-sizing: border-box;
  width: var(--now-cover-size);
  max-width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  height: auto;
  object-fit: cover;
  object-position: center;
  border-radius: clamp(6px, calc(var(--now-cover-size) * 0.14), 14px);
  background: #ffffff;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.34s ease, transform 0.34s ease;
}

#nowCover.is-fading {
  opacity: 0.22;
  transform: scale(0.985);
}

.player-bar {
  grid-row: 2;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
  padding: 0.95rem 1.2rem;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}

.station-meta {
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.current-title-top {
  margin: 0;
  min-width: 0;
  font-size: 1rem;
  font-weight: bold;
  color: var(--leman-bleu);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.current-title-bottom {
  margin: 0.18rem 0 0;
  min-width: 0;
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.2;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.current-title-marquee {
  text-overflow: clip;
}

.current-title-text {
  display: inline-block;
  white-space: nowrap;
}

.current-title-marquee .current-title-text {
  animation: currentTitleMarquee 12s linear infinite;
}

.actions {
  display: flex;
  flex: 0 0 auto;
  flex-shrink: 0;
  align-items: center;
  gap: 0.75rem;
}

button {
  border: 0;
  background: transparent;
  color: #1e40af;
  font-size: 0.95rem;
  padding: 0.2rem 0.35rem;
  cursor: pointer;
}

button:hover {
  color: #1d4ed8;
}

button svg {
  display: block;
  width: 22px;
  height: 22px;
  transform: scale(1);
  transform-origin: center;
  transition: transform 0.16s ease;
}

button:hover svg,
button:focus-visible svg {
  transform: scale(1.3);
}

.volume-control {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  overflow: visible;
}

.volume-control::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 75px;
  height: 175px;
  pointer-events: none;
}

.volume-control:hover::before,
.volume-control #volumeSlider:hover,
.volume-control #volumeSlider:focus,
.volume-control #volumeSlider:active {
  pointer-events: auto;
}

.volume-btn {
  font-size: 0.95rem;
  padding: 0.2rem 0.35rem;
}

#volumeSlider {
  position: absolute;
  left: 50%;
  bottom: 130%;
  transform: translateX(-50%) translateY(6px) rotate(-90deg);
  transform-origin: center;
  margin-bottom: 34px;
  width: 104px;
  accent-color: var(--leman-bleu);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 2;
}

.volume-control:hover #volumeSlider,
#volumeSlider:hover,
#volumeSlider:focus,
#volumeSlider:active {
  opacity: 1;
  transform: translateX(-50%) translateY(0) rotate(-90deg);
  pointer-events: auto;
}

.time-shift-controls {
  grid-row: 5;
  flex-shrink: 0;
  z-index: 5;
  padding: 0.7rem 1.2rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid rgba(229, 231, 235, 0.85);
  box-shadow: 0 -8px 18px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.time-shift-controls[hidden] {
  display: none;
}

.time-shift-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.45rem;
  font-size: 0.84rem;
}

.time-shift-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

#rewind10Btn,
#goLiveBtn {
  color: var(--leman-bleu);
  font-size: 0.78rem;
  font-weight: bold;
  padding: 0;
}

#rewind10Btn svg {
  display: block;
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.2;
}

#rewind10Btn text {
  fill: currentColor;
  stroke: none;
  font-size: 12px;
  font-weight: bold;
  text-anchor: middle;
}

#goLiveBtn[hidden] {
  display: none;
}

.time-shift-slider-wrap {
  position: relative;
}

.time-shift-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.time-shift-marker {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--leman-bleu);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.22);
  transform: translate(-50%, -50%);
}

#timeShiftSlider {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  margin: 0;
  accent-color: var(--leman-bleu);
  cursor: pointer;
}

.status {
  grid-row: 3;
  margin: 0;
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
  color: #64748b;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}

.history-list {
  --history-item-scale: 0.75;
  --history-visible-items: 5;
  --history-item-height: calc(84px * var(--history-item-scale));
  --history-cover-size: clamp(
    calc(41px * var(--history-item-scale)),
    calc(var(--history-item-height) * 0.74),
    calc(106px * var(--history-item-scale))
  );
  --history-time-col: clamp(
    calc(48px * var(--history-item-scale)),
    calc(var(--history-item-height) * 0.72),
    calc(74px * var(--history-item-scale))
  );
  --history-time-size: clamp(
    calc(1rem * var(--history-item-scale)),
    calc(var(--history-item-height) * 0.26),
    calc(1.1rem * var(--history-item-scale))
  );
  --history-title-top-size: clamp(
    calc(0.92rem * var(--history-item-scale)),
    calc(var(--history-item-height) * 0.2),
    calc(1.2rem * var(--history-item-scale))
  );
  --history-title-bottom-size: clamp(
    calc(0.82rem * var(--history-item-scale)),
    calc(var(--history-item-height) * 0.168),
    calc(1.05rem * var(--history-item-scale))
  );
  --history-title-gap: clamp(
    calc(0.08rem * var(--history-item-scale)),
    calc(var(--history-item-height) * 0.0032),
    calc(0.24rem * var(--history-item-scale))
  );
  --history-fade-size: calc(var(--history-item-height) * 0.8);
  grid-row: 4;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  min-height: 0;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000 0,
    #000 calc(100% - var(--history-fade-size)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    #000 0,
    #000 calc(100% - var(--history-fade-size)),
    transparent 100%
  );
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--leman-bleu) 55%, #cbd5e1) #f1f5f9;
}

.history-list::-webkit-scrollbar {
  width: 8px;
}

.history-list::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 999px;
}

.history-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--leman-bleu) 50%, #cbd5e1);
  border-radius: 999px;
  border: 2px solid #f1f5f9;
}

.history-list::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--leman-bleu) 78%, #fff);
}

.history-list::-webkit-scrollbar-thumb:active {
  background: var(--leman-bleu);
}

.history-item {
  display: grid;
  grid-template-columns: var(--history-time-col) var(--history-cover-size) minmax(0, 1fr) auto;
  align-items: center;
  gap: calc(0.8rem * var(--history-item-scale));
  padding: calc(0.85rem * var(--history-item-scale)) calc(1.3rem * var(--history-item-scale));
  min-height: var(--history-item-height);
  border-bottom: 1px solid #f1f5f9;
}

.history-time {
  margin: 0;
  font-size: var(--history-time-size);
  line-height: 1;
  font-weight: bold;
  color: var(--leman-bleu);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.history-time-seekable {
  cursor: pointer;
}

.history-time-seekable:hover {
  opacity: 0.72;
  transform: translateX(calc(2px * var(--history-item-scale)));
}

.history-cover {
  width: var(--history-cover-size);
  height: var(--history-cover-size);
  border-radius: clamp(
    calc(6px * var(--history-item-scale)),
    calc(var(--history-cover-size) * 0.14),
    calc(12px * var(--history-item-scale))
  );
  object-fit: cover;
  background: #e2e8f0;
  cursor: zoom-in;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.history-cover:hover {
  box-shadow: 0 calc(8px * var(--history-item-scale)) calc(18px * var(--history-item-scale))
    rgba(10, 168, 234, 0.38);
  transform: scale(1.04);
}

.history-title-wrap {
  min-width: 0;
}

.history-title-top,
.history-title-bottom {
  margin: 0;
  color: #64748b;
  line-height: 1.2;
}

.history-title-top {
  font-size: var(--history-title-top-size);
  color: var(--leman-bleu);
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-title-bottom {
  font-size: var(--history-title-bottom-size);
  margin-top: var(--history-title-gap);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-current {
  box-shadow: inset calc(4px * var(--history-item-scale)) 0 0 var(--leman-bleu);
  background: var(--leman-bleu-soft);
}

.history-item-entering {
  animation: historyItemEnter 1s ease both;
}

.history-item-current-exiting {
  animation: historyCurrentBorderFade 0.8s ease both;
}

.sound-wave {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 13px;
  justify-self: end;
  align-self: center;
}

.sound-wave-bar {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--leman-bleu);
  animation: wave 1s ease-in-out infinite;
}

.sound-wave-bar:nth-child(2) {
  animation-delay: 0.2s;
}

.sound-wave-bar:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes wave {
  0%,
  100% {
    transform: scaleY(0.25);
    opacity: 0.6;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

@keyframes historyItemEnter {
  0% {
    opacity: 0;
    transform: translateY(calc(-12px * var(--history-item-scale, 1))) scale(0.985);
  }
  65% {
    opacity: 1;
    transform: translateY(calc(2px * var(--history-item-scale, 1))) scale(1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes historyCurrentBorderFade {
  0% {
    box-shadow: inset calc(4px * var(--history-item-scale, 1)) 0 0 var(--leman-bleu);
  }
  100% {
    box-shadow: inset 0 0 0 transparent;
  }
}

@keyframes currentTitleMarquee {
  0%,
  15% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-100%);
  }
  50.01% {
    transform: translateX(100%);
  }
  85%,
  100% {
    transform: translateX(0);
  }
}

.history-empty {
  padding: 1.3rem;
  color: #64748b;
  font-size: 1.15rem;
}

.cover-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(10, 168, 234, 0.33);
  opacity: 0;
  perspective: 900px;
  transition: opacity 0.18s ease;
}

.cover-preview-modal[hidden] {
  display: none;
}

.cover-preview-modal.is-open {
  opacity: 1;
}

.cover-preview-img {
  width: min(82vw, 460px);
  max-height: 82vh;
  border-radius: 18px;
  object-fit: contain;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
  transform: rotateX(8deg) scale(0.94);
  transition: transform 0.22s ease;
}

.cover-preview-modal.is-open .cover-preview-img {
  transform: rotateX(0) rotateY(-4deg) scale(1);
}

.cover-preview-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  color: #ffffff;
  font-size: 2rem;
  line-height: 1;
}

@media (max-width: 640px) {
  .layout {
    display: block;
    height: 100dvh;
    max-height: 100dvh;
  }

  .radio-panel {
    width: 100%;
    border-right: 0;
    height: 100dvh;
    max-height: 100dvh;
  }
}
