* {
  box-sizing: border-box;
}

:root {
  --bg: #eef3fa;
  --text: #0f172a;
  --muted: #475569;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #d8e0eb;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --accent: #0f172a;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --player-bg: #0b1220;
  --player-text: #e2e8f0;
  --player-muted: #9fb0c8;
  --player-song: #7dd3fc;
}

body.dark {
  --bg: #0b1220;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --surface: #121a2a;
  --surface-2: #0f1726;
  --border: #273449;
  --primary: #60a5fa;
  --primary-soft: #1e3a5f;
  --accent: #f8fafc;
  --shadow: 0 12px 30px rgba(2, 6, 23, 0.45);
  --player-bg: #020617;
  --player-text: #e2e8f0;
  --player-muted: #93a9c7;
  --player-song: #67e8f9;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: radial-gradient(circle at top, var(--surface-2), var(--bg));
  color: var(--text);
  padding-bottom: 110px;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.container {
  width: min(1200px, 94vw);
  margin: 2rem auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2rem;
  margin: 0;
  letter-spacing: 0.2px;
}

#themeToggle {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.import-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.import-box h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.import-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.2rem;
}

#importToggle {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

#importContent[hidden] {
  display: none;
}

.import-box p {
  margin: 0 0 0.6rem;
  color: var(--muted);
}

.import-box textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  resize: vertical;
}

.import-actions {
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.import-box hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0.9rem 0;
}

.api-import-grid {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 0.6rem;
  align-items: center;
}

.api-import-grid input {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
}

.api-import-grid button {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
}

.import-actions button {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
}

.import-actions .danger {
  border-color: #dc2626;
  color: #dc2626;
}

body.dark .import-actions .danger {
  border-color: #f87171;
  color: #fca5a5;
}

#importStatus {
  color: var(--muted);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filters input,
.filters select,
.actions button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
}

#summary {
  margin: 0.5rem 0 1rem;
  color: var(--muted);
}

.list {
  display: grid;
  gap: 0.8rem;
}

.card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border-radius: 14px;
  padding: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-main {
  flex: 1;
  min-width: 300px;
}

.title {
  margin: 0;
  font-size: 1.1rem;
}

.meta,
.tags {
  margin: 0.35rem 0;
  color: var(--muted);
}

.url {
  display: inline-block;
  margin-top: 0.25rem;
  word-break: break-all;
  color: var(--primary);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.actions button {
  cursor: pointer;
  background: var(--surface);
}

.actions .play {
  border-color: var(--accent);
  color: var(--accent);
}

.actions button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--player-bg);
  color: var(--player-text);
  border-top: 1px solid var(--border);
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.player-info {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

#nowPlayingTitle,
#nowPlayingMeta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#nowPlayingMeta {
  color: var(--player-muted);
  font-size: 0.9rem;
}

#nowPlayingSong {
  color: var(--player-song);
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

#stopPlayback {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  background: transparent;
  color: var(--player-text);
  cursor: pointer;
}

#radioPlayer {
  width: min(360px, 60vw);
  height: 38px;
}

@media (max-width: 700px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  #themeToggle {
    width: 100%;
  }

  .api-import-grid {
    grid-template-columns: 1fr;
  }

  body {
    padding-bottom: 150px;
  }

  .player-bar {
    flex-direction: column;
    align-items: stretch;
  }

  #radioPlayer {
    width: 100%;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }
}
