:root {
  --bg: #14161a;
  --surface: #1e2126;
  --border: #2c2f36;
  --text: #e8e9ec;
  --text-dim: #9a9fa8;
  --accent: #4f8cff;
  --error: #ff6b6b;
  --success: #5fd196;
  --favorite: #f5c542;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

select,
input,
button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
}

#search-input {
  flex: 1;
  min-width: 10rem;
}

button {
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

/* Overflow menu ("...") for lower-frequency actions: check streams,
   capture snapshots, edit playlists, import. Native <details>/<summary>
   handles open/close with no custom JS. */
.menu {
  position: relative;
}

.menu summary {
  list-style: none;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
}

.menu summary:hover {
  border-color: var(--accent);
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu[open] summary {
  border-color: var(--accent);
}

.menu-content {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  min-width: 11rem;
  z-index: 2;
}

.menu-content button {
  text-align: left;
}

/* Quick-filter chips: favorites (independent toggle) + resolution tier
   (single-select, click again to clear). */
.filter-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.filter-pill {
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.filter-pill--active {
  border-color: var(--accent);
  color: var(--text);
}

#filter-favorites.filter-pill--active {
  border-color: var(--favorite);
  color: var(--favorite);
}

/* Shared chrome for every <dialog> in the app. */
dialog.app-dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  width: min(32rem, calc(100vw - 2rem));
}

dialog.app-dialog--narrow {
  width: min(22rem, calc(100vw - 2rem));
}

dialog.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

dialog.app-dialog h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

#import-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#import-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

#import-form textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  min-height: 10rem;
  resize: vertical;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.dialog-status {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0;
}

.playlists-manage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.playlists-manage-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.playlists-manage-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

main {
  padding: 1.5rem;
}

.status-banner {
  color: var(--text-dim);
  margin: 0 0 1rem;
}

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

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.channel-card-wrapper {
  position: relative;
}

.channel-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  text-align: center;
  width: 100%;
}

.channel-card img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #0c0d10;
  border-radius: 8px;
}

.channel-name {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.2;
}

.channel-badge {
  font-size: 0.7rem;
  min-height: 1em;
  color: var(--text-dim);
}

.channel-badge--ok {
  color: var(--success);
}

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

.channel-badge--checking {
  color: var(--text-dim);
  font-style: italic;
}

.channel-card--action {
  opacity: 0.6;
  border-color: var(--accent);
}

/* The only per-card *control* besides the card itself — the badge above
   is informational (resolution/live status), not interactive. Snapshot
   capture lives in the bulk "Capture snapshots" menu action instead of a
   per-card button. */
.channel-favorite {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(12, 13, 16, 0.65);
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
}

.channel-favorite:hover {
  color: var(--text);
}

.channel-favorite--active {
  color: var(--favorite);
}

/* In-browser player popup (web build): video only + download/close actions. */
dialog.app-dialog--wide {
  width: min(48rem, calc(100vw - 2rem));
}

#player-video {
  width: 100%;
  max-height: 60vh;
  background: #000;
  border-radius: 8px;
}

#player-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-url-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0 0 0.75rem;
}

.player-url-inputrow {
  display: flex;
  gap: 0.5rem;
}

.player-url-inputrow input {
  flex: 1;
  min-width: 0;
}
