:root {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-alt: #111827;
  --fg: #f8fafc;
  --fg-muted: rgba(226, 232, 240, 0.88);
  --accent: #e4582d;
  --accent-hover: #cf3d15;
  --card: rgba(17, 24, 39, 0.92);
  --card-dark: rgba(15, 23, 42, 0.95);
  --muted: rgba(148, 163, 184, 0.78);
  --muted-strong: rgba(203, 213, 225, 0.9);
  --muted-dark: rgba(148, 163, 184, 0.65);
  --muted-dark-strong: rgba(226, 232, 240, 0.94);
  font-family: "Inter", "Segoe UI", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg), #1f2937);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.app {
  width: min(960px, 90vw);
  margin: 32px auto;
  padding: 32px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  color: var(--fg);
  box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
  .app {
    background: var(--card-dark);
    color: var(--fg);
  }
}

@media (max-width: 640px) and (prefers-color-scheme: dark) {
  .app {
    background: transparent;
    color: var(--fg);
  }
}

.app__header {
  text-align: center;
  margin-bottom: 24px;
}

.hint {
  margin-top: 8px;
  color: var(--muted);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 16px;
  cursor: pointer;
  background: rgba(228, 88, 45, 0.12);
  color: var(--fg);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(228, 88, 45, 0.3);
}

.btn.primary {
  background: var(--accent);
  color: #fff4ec;
  box-shadow: 0 12px 30px rgba(228, 88, 45, 0.35);
}

.btn.primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 16px 34px rgba(207, 61, 21, 0.45);
}

.btn.danger {
  background: rgba(248, 113, 113, 0.16);
  color: var(--fg);
}

.btn.danger:hover {
  background: rgba(248, 113, 113, 0.26);
  box-shadow: 0 10px 30px rgba(248, 113, 113, 0.28);
}

.player__summary {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
}

.player__texts {
  display: grid;
  gap: 8px;
}

.player__station {
  font-size: 24px;
  font-weight: 700;
}

.player__track {
  font-size: 18px;
  color: var(--muted-strong);
}

.player__dj {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-top: 4px;
}

.player__status {
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
  text-align: left;
}

.player__status.error {
  color: #f87171;
}

.player__art {
  width: 140px;
  height: 140px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.player__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player__buttons {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  body {
    display: block;
    min-height: 100svh;
    height: 100svh;
    padding: 0;
    overflow: hidden;
  }

  .app {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 16px 16px 16px;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    min-height: 100svh;
    height: 100svh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
  }

  .app__player {
    flex-shrink: 0;
    margin-bottom: 16px;
  }

  .player__status {
    text-align: center;
  }

  .player__buttons {
    flex-wrap: wrap;
  }

  .btn__text {
    display: none;
  }

  .btn {
    padding: 12px 16px;
    min-width: 48px;
  }

  .app__stations {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    margin-top: 24px;
  }

  .app__stations h2 {
    margin-top: 0;
    margin-bottom: 12px;
    flex-shrink: 0;
  }

  .app__stations ul {
    max-height: none !important;
    flex: 1;
    overflow-y: auto;
    margin: 0;
    border-radius: 0;
  }
}

@media (max-width: 720px) {
  .player__summary {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .player__texts {
    gap: 6px;
  }

  .player__art {
    margin: 0 auto;
  }
}

@media (prefers-color-scheme: dark) {
  .player__track {
    color: var(--muted-dark-strong);
  }
}

.stations__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.toggle__label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
  user-select: none;
  transition: color 0.3s ease;
}

.toggle__switch {
  position: relative;
  width: 60px;
  height: 28px;
  background: rgba(148, 163, 184, 0.2);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.3s ease;
  padding: 0;
  flex-shrink: 0;
}

.toggle__switch:hover {
  background: rgba(148, 163, 184, 0.3);
}

.toggle__slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: var(--fg);
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle__switch.active .toggle__slider {
  transform: translateX(32px);
}

.toggle__switch.active {
  background: rgba(228, 88, 45, 0.3);
}

.toggle__switch.active + .toggle__label {
  color: var(--accent);
}

.stations__toggle .toggle__label:first-child {
  color: var(--fg);
}

.toggle__switch.active ~ .toggle__label:first-child {
  color: var(--muted);
}

.toggle__switch.active + .toggle__label {
  color: var(--accent);
}

.app__stations {
  margin-top: 32px;
}

.app__stations ul {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 320px;
  overflow-y: auto;
  border-radius: 16px;
  background: rgba(17, 24, 39, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

@media (prefers-color-scheme: dark) {
  .app__stations ul {
    background: rgba(17, 24, 39, 0.82);
  }
}

.app__stations li {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  transition: background 0.2s ease;
}

.app__stations li.dragging {
  opacity: 0.5;
}

.app__stations li .drag-handle {
  cursor: grab;
  user-select: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.app__stations li .drag-handle:active {
  cursor: grabbing;
}

.app__stations li .name {
  flex: 1;
}

.app__stations li .favorite-toggle {
  cursor: pointer;
  user-select: none;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.app__stations li .favorite-toggle:hover {
  transform: scale(1.2);
}

.app__stations li:last-child {
  border-bottom: none;
}

.app__stations li:hover {
  background: rgba(228, 88, 45, 0.18);
}

.app__stations li.active {
  background: rgba(228, 88, 45, 0.28);
  color: var(--accent);
}

.app__stations li span.url {
  font-size: 12px;
  color: var(--muted-strong);
  word-break: break-all;
}

@media (prefers-color-scheme: dark) {
  .hint,
  .app__stations li span.url {
    color: var(--muted-dark);
  }

  .app__stations li {
    border-bottom: 1px solid rgba(226, 232, 240, 0.12);
  }

  .app__stations li:hover {
    background: rgba(228, 88, 45, 0.24);
  }

  .app__stations li.active {
    background: rgba(228, 88, 45, 0.36);
    color: var(--fg);
  }
}
