:root {
  color-scheme: dark;
  --bg: #0e1116;
  --bg-elev: #171b22;
  --bg-elev-2: #1f242d;
  --text: #eef2f7;
  --muted: #a7b0bd;
  --accent: #4f8cff;
  --accent-strong: #6ea2ff;
  --danger: #ff6b6b;
  --border: #2a313c;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

a {
  color: var(--accent-strong);
}

a:hover {
  color: #fff;
}

:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 100;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 17, 22, 0.9);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-nav a {
  text-decoration: none;
}

.who {
  color: var(--muted);
  font-size: 0.9rem;
}

.inline-form {
  margin: 0;
}

/* Main */
.site-main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Typography */
h1 {
  font-size: clamp(1.6rem, 2.4vw + 1rem, 2.4rem);
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.25rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

code {
  background: var(--bg-elev-2);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

/* Buttons */
.button,
.link-button {
  font: inherit;
  cursor: pointer;
}

.button {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease, transform 0.05s ease;
}

.button:hover {
  background: #2b323d;
  color: #fff;
}

.button:active {
  transform: translateY(1px);
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button-small {
  padding: 0.4rem 0.85rem;
  font-size: 0.9rem;
}

.link-button {
  background: none;
  border: none;
  color: var(--accent-strong);
  padding: 0;
  text-decoration: underline;
}

/* Hero */
.hero {
  padding: 2rem 0 1rem;
}

.lede {
  font-size: 1.1rem;
  max-width: 60ch;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 2.5rem;
}

.features article {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* Panels and forms */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.panel.narrow {
  max-width: 460px;
  margin: 1rem auto;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}

input[type="text"],
input[type="password"] {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

input:focus {
  border-color: var(--accent);
}

.alert {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
}

.alert-error {
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 107, 107, 0.12);
  color: #ffd7d7;
}

/* Channels */
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.channel-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.channel-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.channel-card:hover {
  border-color: var(--accent);
}

.channel-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.35);
}

.channel-link {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  color: inherit;
  text-decoration: none;
}

.channel-media {
  flex: 0 0 auto;
}

.channel-logo {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--bg-elev-2);
}

.channel-logo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--muted);
  font-size: 1.1rem;
}

.channel-body {
  min-width: 0;
  flex: 1;
}

.channel-name {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.channel-number {
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 0.35rem;
}

.now-name {
  margin: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-times {
  margin: 0.15rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

.next {
  margin: 0.5rem 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

/* Player */
.back {
  margin: 0 0 1rem;
}

.back a {
  text-decoration: none;
}

.player-frame {
  position: relative;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.player-frame video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  text-align: center;
  padding: 1rem;
}

.player-overlay[hidden] {
  display: none;
}

.player-overlay p {
  margin: 0;
  max-width: 40ch;
}

.player-meta {
  margin-top: 1.25rem;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media (max-width: 480px) {
  .site-main {
    padding: 1.25rem 1rem 2rem;
  }

  .who {
    display: none;
  }

  .channel-link {
    padding: 0.85rem;
  }
}
