:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #ececea;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --border: #dcdcd8;
  --accent: #c4302b;
  --accent-text: #ffffff;
  --error: #b3261e;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --surface: #1c1c1b;
    --surface-2: #2a2a28;
    --text: #ececea;
    --muted: #9c9c96;
    --border: #33332f;
    --accent: #e0524c;
    --accent-text: #ffffff;
    --error: #f2938d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }

a { color: inherit; }

button, input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: var(--radius);
  padding: 8px 16px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button:disabled { opacity: 0.45; cursor: default; }

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.icon { padding: 6px 10px; font-size: 18px; line-height: 1; }

input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

/* --- logowanie --- */

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card {
  width: min(360px, 100%);
  display: grid;
  gap: 10px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.login-card h1 { margin: 0 0 8px; font-size: 22px; }
.login-card label { color: var(--muted); font-size: 13px; }
.login-card p { margin: 0; min-height: 1.4em; }

/* --- pasek górny --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; text-decoration: none; white-space: nowrap; }

.search { flex: 1; display: flex; gap: 8px; max-width: 720px; }

/* --- lista --- */

.content { padding: 16px 16px 120px; max-width: 1400px; margin: 0 auto; }

.list-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.list-title { margin: 4px 0 8px; font-size: 18px; }
.list-title:empty { display: none; }

.fav-btn { padding: 5px 12px; font-size: 14px; font-weight: 500; }
.fav-btn.active { border-color: var(--accent); color: var(--accent); }

/* --- ulubione --- */

.favorites { margin-bottom: 24px; }

.fav-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fav-item {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.fav-link {
  padding: 6px 4px 6px 14px;
  text-decoration: none;
  font-weight: 500;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-link:hover { color: var(--accent); }

.fav-remove {
  background: none;
  color: var(--muted);
  padding: 6px 12px 6px 8px;
  font-size: 16px;
  line-height: 1;
  border-radius: 0;
}

.fav-remove:hover { color: var(--error); }

.status { color: var(--muted); margin: 8px 0 16px; }
.status:empty { display: none; }
.status.error { color: var(--error); }

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px 14px;
}

.card { min-width: 0; }

.card-play {
  display: block;
  width: 100%;
  padding: 0;
  background: none;
  color: inherit;
  text-align: left;
  font-weight: 500;
  border-radius: var(--radius);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}

.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.badge.live { background: var(--accent); }

.card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 8px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.channel-link { text-decoration: none; }
.channel-link:hover { text-decoration: underline; }

.card.playing .thumb { outline: 3px solid var(--accent); outline-offset: -3px; }
.card.playing .card-title { color: var(--accent); }

.more { display: block; margin: 24px auto 0; }

/* --- odtwarzacz --- */

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.np-thumb {
  width: 80px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-2);
  flex: none;
}

.np-info { min-width: 0; flex: 1; }
.np-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-channel { color: var(--muted); font-size: 13px; }

.np-controls { display: flex; align-items: center; gap: 8px; flex: 1.4; }
.np-controls audio { flex: 1; min-width: 0; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; }
  .brand { flex: 1; }
  .player { flex-wrap: wrap; }
  .np-thumb { width: 64px; }
  .np-controls { flex-basis: 100%; }
  .content { padding-bottom: 170px; }
}
