/* Zyvi — Dark Theme.
   Palette mirrors the canonical KMP design-system tokens
   (core/common ZyviColorTokens, CTTV-802): #2196F3 primary on a #0B0B0B
   canvas so it matches Android + Desktop exactly. Keep in sync — any brand
   change starts in ZyviColorTokens. */
:root {
  --bg: #0b0b0b;
  --surface: #141414;
  --surface-hover: #2a2a2a;
  --surface-elevated: #1f1f1f;
  --border: #2a2a2a;
  --text: #e5e5e5;
  --text-secondary: #b3b3b3;
  --accent: #2196f3;
  --accent-hover: #1976d2;
  --accent-light: rgba(33, 150, 243, 0.14);
  --danger: #cf6679;
  --success: #2e7d32;
  --warning: #ffb300;
  --warning-bg: rgba(255, 179, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --content-max: 960px;
  --account-max: 720px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 500;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  left: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }

/* Header */
header {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  background: rgba(15, 17, 20, 0.92);
  backdrop-filter: blur(10px);
  z-index: 1000;
  overflow: visible;
  isolation: isolate;
}
header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  overflow: visible;
}
.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  text-decoration: none;
}
.logo:hover { text-decoration: none; opacity: 0.9; }
nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  overflow: visible;
}
nav .nav-link {
  margin-left: 4px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
nav .nav-link:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}
nav .nav-link.nav-active {
  color: var(--accent);
  background: var(--accent-light);
}
nav .nav-link-cta {
  color: var(--text);
  border: 1px solid var(--border);
}
nav .admin-link { opacity: 0.65; font-size: 13px; }

/* CTTV-839 (R-6/T-17): dead `.nav-dropdown*` rules removed — superseded by the
   flat top nav (CTTV-812). Their only JS consumer (`setupNavDropdown`) was
   never wired and has been deleted too. */

#app {
  position: relative;
  z-index: 0;
}

/* Hero */
.hero {
  text-align: center;
  padding: 72px 0 48px;
}
.hero-v2 { padding-bottom: 32px; }
.hero-eyebrow {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 12px;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -1px;
  line-height: 1.1;
}
.hero h1 span { color: var(--accent); }
.hero-lead,
.hero p {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 28px;
  line-height: 1.55;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.section-heading {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}
.setup-flow { padding: 24px 0 56px; }
.setup-steps {
  list-style: none;
  display: grid;
  gap: 16px;
  max-width: 640px;
  margin: 0 auto;
}
.setup-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.setup-step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.setup-step strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
}
.setup-step p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}
.feature-icon {
  font-size: 24px;
  margin-bottom: 10px;
  line-height: 1;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; padding: 14px 28px; font-size: 16px; }
.btn + .btn { margin-left: 12px; }
.hero-actions .btn + .btn { margin-left: 0; }

/* Features grid */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  padding: 40px 0 80px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.feature-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}
.feature-card p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Portal & Forms */
.page { padding: 40px 0 56px; }
.page-header { margin-bottom: 28px; }
.page-kicker {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 6px;
}
.page-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.page-subtitle {
  color: var(--text-secondary);
  margin-bottom: 0;
  max-width: 640px;
  line-height: 1.5;
}
.page-header + #guide-controls,
.page-header + #channels-controls,
.page-header + #library-controls,
.page-header + #categories-controls,
.page-header + #mystuff-controls {
  margin-top: 24px;
}
.loading-inline {
  padding: 20px 0;
  justify-content: flex-start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 480px;
  margin: 0 auto;
}
.card h2 {
  font-size: 20px;
  margin-bottom: 20px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}
.form-group input::placeholder { color: var(--text-secondary); }

.divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: var(--text-secondary);
  font-size: 13px;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.divider::before { margin-right: 12px; }
.divider::after { margin-left: 12px; }

/* Device view */
.device-page { max-width: var(--account-max); }
.device-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.device-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.device-code-block { text-align: right; }
.device-code-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.device-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  letter-spacing: 4px;
}
.device-back-link {
  margin-top: 8px;
  font-size: 14px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-pill-live {
  background: rgba(102, 187, 106, 0.15);
  color: var(--success);
  border: 1px solid rgba(102, 187, 106, 0.35);
}
.status-pill-linked {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(66, 165, 245, 0.35);
}
.section-card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.playlist-list { list-style: none; }
.playlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.playlist-list-v2 { margin-top: 4px; }
.playlist-item-v2 {
  background: var(--bg);
  gap: 12px;
  flex-wrap: wrap;
}
.playlist-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.playlist-type-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.playlist-item .name { font-weight: 500; }
.playlist-item .type {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
}
.playlist-actions { display: flex; gap: 8px; flex-shrink: 0; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-state p { margin-bottom: 16px; }

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-error {
  background: rgba(244, 67, 54, 0.15);
  color: #f44336;
  border: 1px solid rgba(244, 67, 54, 0.3);
}
.alert-success {
  background: rgba(76, 175, 80, 0.15);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

/* Loading */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  gap: 12px;
  color: var(--text-secondary);
}

/* Page transition */
#page-app.page-enter,
main#page-app.page-enter,
#app.page-enter {
  animation: pageEnter 0.22s ease;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 20px;
  color: var(--text-secondary);
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { opacity: 0.45; user-select: none; }
.breadcrumb-current { color: var(--text); font-weight: 500; }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 64px;
}
footer a { color: var(--text-secondary); }
footer a:hover { color: var(--accent); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay-enter { animation: modalOverlayIn 0.2s ease; }
.modal-overlay-exit { animation: modalOverlayOut 0.18s ease forwards; }
@keyframes modalOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalOverlayOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
.modal {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-md);
  animation: modalIn 0.22s ease;
}
.modal-wide { max-width: 480px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.02em;
}
.modal-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.45;
}
.modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* Admin link in nav — subtle */
nav a.admin-link {
  font-size: 11px;
  color: var(--border);
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
}
nav a.admin-link:hover {
  opacity: 1;
  color: var(--text-secondary);
}

/* Admin layout — full width */
.admin-layout {
  padding: 32px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Admin header + breadcrumbs */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}
.admin-header h2 {
  font-size: 24px;
  font-weight: 700;
}
.admin-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.admin-breadcrumbs a { color: var(--accent); }
.admin-breadcrumbs span { color: var(--text-secondary); }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  text-align: center;
  border-top: 3px solid var(--border);
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { transform: translateY(-1px); }
.stat-card-devices { border-top-color: var(--accent); }
.stat-card-users { border-top-color: #ab47bc; }
.stat-card-firetv { border-top-color: #ff9800; }
.stat-card-recent { border-top-color: var(--success); }
.stat-card .stat-number {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Admin search */
.admin-search {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}
.admin-search:focus { border-color: var(--accent); }
.admin-search::placeholder { color: var(--text-secondary); }

/* Admin table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr { cursor: pointer; transition: background 0.15s; }
.admin-table tbody tr:hover { background: var(--surface-hover); }

/* Admin badge */
.admin-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent);
  white-space: nowrap;
}
.admin-badge.fire-tv { background: rgba(255, 152, 0, 0.15); color: #ff9800; }
.admin-badge.android-tv { background: rgba(76, 175, 80, 0.15); color: #4caf50; }

/* Pagination */
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}
.admin-pagination button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.admin-pagination button:hover { background: var(--surface-hover); }
.admin-pagination button:disabled { opacity: 0.4; cursor: default; }
.admin-pagination .page-info { font-size: 13px; color: var(--text-secondary); }

/* Admin device detail sections */
.admin-device-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.admin-device-info .info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.admin-device-info .info-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.admin-device-info .info-value {
  font-size: 15px;
  color: var(--text);
}

/* Admin & user playlist rows */
.playlist-admin,
.playlist-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.playlist-admin .pl-details { flex: 1; }
.playlist-admin .pl-name { font-weight: 600; }
.playlist-admin .pl-url {
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
  margin-top: 2px;
}
.playlist-admin .pl-type {
  font-size: 11px;
  background: var(--bg);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  display: inline-block;
}

.playlist-user .pl-name {
  font-weight: 500;
  color: var(--text-secondary);
}
.playlist-user .pl-privacy {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.6;
  font-style: italic;
  margin-left: 8px;
}

.playlist-actions-admin { display: flex; gap: 8px; flex-shrink: 0; }

.admin-section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  margin-bottom: 24px;
}
.admin-section-card .admin-section-title { margin-top: 0; }
.admin-section-card .section-card-desc { margin-bottom: 16px; }
.admin-devices-section .admin-search { margin-bottom: 12px; }
.admin-devices-section .admin-table { margin-top: 0; }

/* Admin login card */
.admin-login-card {
  max-width: 100%;
  margin: 0;
  text-align: left;
}
.admin-login-card h2 {
  font-size: 20px;
  margin-bottom: 8px;
}
.admin-login-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Code input group — 6 individual character boxes */
.code-input-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 24px 0 28px;
}
.code-input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 0;
  text-transform: uppercase;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  caret-color: var(--accent);
}
.code-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.code-input.filled {
  border-color: var(--accent);
}

/* Playlist type selector — two big button options */
.playlist-type-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.playlist-type-btn {
  flex: 1;
  padding: 16px 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.playlist-type-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}
.playlist-type-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* App toasts */
.app-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  z-index: 300;
  box-shadow: var(--shadow-md);
  animation: toastSlideIn 0.28s ease;
}
.app-toast-exit { animation: toastSlideOut 0.28s ease forwards; }
.app-toast-success {
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid rgba(102, 187, 106, 0.4);
  border-left: 4px solid var(--success);
}
.app-toast-warning {
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid rgba(255, 183, 77, 0.45);
  border-left: 4px solid var(--warning);
}
.app-toast-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.app-toast-success .app-toast-icon {
  background: rgba(102, 187, 106, 0.2);
  color: var(--success);
}
.app-toast-warning .app-toast-icon {
  background: var(--warning-bg);
  color: var(--warning);
}
.app-toast-text { flex: 1; min-width: 0; }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}
/* Legacy class alias */
.success-toast { display: none; }

/* Portal hero card */
.portal-page { padding-top: 32px; }
.portal-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  align-items: start;
  max-width: 880px;
}
.portal-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px 28px;
  box-shadow: var(--shadow-sm);
}
.portal-card-primary {
  border-color: rgba(66, 165, 245, 0.35);
  background: linear-gradient(180deg, rgba(66, 165, 245, 0.08) 0%, var(--surface) 40%);
}
.portal-card-secondary { text-align: left; }
.portal-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 8px;
}
.portal-hero-card h2,
.portal-hero-card h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.portal-hero-card .subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 20px;
  line-height: 1.45;
}
.portal-hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}
.portal-auth-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
  font-size: 14px;
}
.portal-card-primary { text-align: center; }
.portal-card-primary .form-group { text-align: left; }
.portal-secondary {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}
.portal-secondary a {
  color: var(--accent);
  font-weight: 500;
}

/* Account layout */
.account-layout {
  max-width: var(--account-max);
  margin: 0 auto;
}
.account-layout-wide { max-width: var(--content-max); }
.account-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
}
.account-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.account-tab {
  flex: 1;
  min-width: 0;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.account-tab:hover { color: var(--text); background: var(--surface-hover); }
.account-tab.active {
  color: var(--text);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-sm);
}
.account-tab-panel { display: none; }
.account-tab-panel.active {
  display: block;
  animation: tabFadeIn 0.2s ease;
}
@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.section-card-highlight {
  border-color: rgba(66, 165, 245, 0.3);
  background: linear-gradient(180deg, rgba(66, 165, 245, 0.06) 0%, var(--surface) 120px);
}
.section-card-muted { background: var(--bg); }
.section-card-header { margin-bottom: 16px; }
.section-card-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}
.section-card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}
.section-card-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.section-card-actions .btn { margin-left: 0; }
.settings-form { margin-top: 4px; }
.settings-form .form-group:last-of-type { margin-bottom: 8px; }
.empty-state-card {
  text-align: center;
  padding: 32px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.empty-state-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.empty-state-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 0;
  line-height: 1.5;
}
.empty-state-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.empty-state-card-warn {
  border-color: rgba(255, 183, 77, 0.4);
  background: linear-gradient(180deg, var(--warning-bg) 0%, var(--bg) 80px);
}
.admin-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Device cards in account dashboard */
.device-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: border-color 0.2s;
}
.device-card:hover {
  border-color: var(--accent);
}
.device-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.device-card-name {
  font-size: 16px;
  font-weight: 600;
}
.device-card-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 10px;
  border-radius: 4px;
  letter-spacing: 2px;
}
.device-card-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Link device modal */
.link-device-modal {
  text-align: center;
}
.link-device-modal .code-input-group {
  margin: 16px 0 24px;
}
.link-device-modal .modal-actions {
  justify-content: center;
}

.shared-playlists-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 12px 0 16px;
  line-height: 1.5;
}

/* CTTV-478 — warning variant of the success toast. Same shape; amber
   accent + glyph so the user notices an anomaly without it reading
   as an error. */
.success-toast.toast-warning {
  background: var(--bg-warning, #fef3c7);
  color: var(--text-warning, #92400e);
  border-color: var(--border-warning, #f59e0b);
}

/* CTTV-487 — Playlist Health rows (server-side worker status). */
.health-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}
.health-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.health-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.health-row-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  min-width: 0;
  flex: 1;
}
.health-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-dot.health-badge-ok { background: var(--success, #4caf50); }
.health-dot.health-badge-failing { background: var(--danger, #f44336); }
.health-dot.health-badge-unknown { background: var(--text-secondary, #999); }
.health-row-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-secondary);
}
.health-row-badge.health-badge-ok { color: var(--success, #4caf50); }
.health-row-badge.health-badge-failing { color: var(--danger, #f44336); }
.health-row-meta {
  display: flex;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.health-row-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* CTTV-501 — catalogue sub-section under each Playlist Health row.
   Shows VOD/Series counts, last ingest time, Firestore path prefix,
   and a "Refresh server" button. */
.catalogue-section {
  display: flex;
  align-items: center;
  /* CTTV-501 ux-review — `flex-start` + `margin-left: auto` on
     the button keeps it right-anchored on wide rows but wraps
     more predictably on narrow ones (Firefox mobile, narrow
     browser windows) than `space-between` did. */
  justify-content: flex-start;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border, rgba(0, 0, 0, 0.1));
  flex-wrap: wrap;
}
.playlist-refresh-actions {
  width: 100%;
}
.playlist-refresh-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  align-items: center;
}
.playlist-refresh-buttons .btn-sm {
  white-space: nowrap;
  flex-shrink: 0;
}
.catalogue-meta {
  display: flex;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  align-items: center;
}
.catalogue-meta strong {
  color: var(--text);
  font-weight: 600;
}
.catalogue-storage {
  font-family: var(--font-mono, ui-monospace, "SF Mono", monospace);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  /* CTTV-501 ux-review — was `cursor: help` which implies a
     rich tooltip / click affordance. The tooltip exists but
     there's no click action yet (copy-to-clipboard is a
     follow-up); `cursor: default` matches reality. */
  cursor: default;
}
.m3u-refresh-btn,
.catalogue-refresh-btn,
.epg-refresh-btn {
  flex-shrink: 0;
}
/* CTTV-501 ux-review + M3U follow-up — pin the leftmost of the
   button group with `margin-left: auto`. The three buttons
   (M3U / Catalogue / EPG) sit together right-anchored on wide
   layouts, wrap together on narrow ones. */
.m3u-refresh-btn {
  margin-left: auto;
}
.catalogue-refresh-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

/* CTTV-482 — per-worker status chips (M3U / EPG / Catalogue). */
.health-row-chips {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.health-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 500;
  cursor: help;
}
.health-chip-ok {
  background: rgba(76, 175, 80, 0.12);
  color: var(--success, #4caf50);
  border-color: rgba(76, 175, 80, 0.3);
}
.health-chip-failing {
  background: rgba(244, 67, 54, 0.12);
  color: var(--danger, #f44336);
  border-color: rgba(244, 67, 54, 0.3);
}
.health-chip-unknown {
  background: var(--bg);
  color: var(--text-secondary);
  border-color: var(--border, rgba(0, 0, 0, 0.1));
}
.health-chip-building {
  background: rgba(255, 183, 77, 0.15);
  color: #ffb74d;
  border-color: rgba(255, 183, 77, 0.45);
  animation: browse-chip-pulse 1.4s ease-in-out infinite;
}
.health-chip-skipped {
  background: rgba(158, 158, 158, 0.2);
  color: #bdbdbd;
  border-color: rgba(158, 158, 158, 0.35);
}
@keyframes browse-chip-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* Portal content section — expectations + rebuild progress (CTTV-694) */
.portal-content-intro {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(33, 150, 243, 0.08);
  border: 1px solid rgba(33, 150, 243, 0.25);
  font-size: 13px;
  color: var(--text-secondary);
}
.portal-content-intro strong {
  color: var(--text);
  font-size: 14px;
}
.portal-content-steps {
  margin: 10px 0 0 1.1rem;
  padding: 0;
  line-height: 1.5;
}
.portal-content-steps li {
  margin-bottom: 6px;
}
.portal-content-note {
  margin: 10px 0 0;
  font-size: 12px;
  font-style: italic;
}
.health-meta-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 6px;
}
.browse-progress-panel {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.browse-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.browse-elapsed {
  font-size: 12px;
  color: var(--text-secondary);
}
.browse-stage-line {
  margin: 8px 0 10px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}
.browse-progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border, rgba(255, 255, 255, 0.1));
  overflow: hidden;
  margin-bottom: 12px;
}
.browse-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #42a5f5, #4caf50);
  transition: width 0.6s ease;
}
.browse-step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.browse-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.browse-step-icon {
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
}
.browse-step-done {
  color: var(--success, #4caf50);
}
.browse-step-active {
  color: #ffb74d;
  font-weight: 500;
}
.browse-hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Responsive */
@media (max-width: 600px) {
  .hero h1 { font-size: 32px; }
  .hero p, .hero-lead { font-size: 16px; }
  .device-hero { flex-direction: column; }
  .device-code-block { text-align: left; }
  .device-code { font-size: 22px; }
  .section-card-header-row { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-layout { padding: 16px; }
  .admin-device-info { grid-template-columns: 1fr; }
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 8px 6px; }
  .code-input-group { gap: 6px; }
  .code-input { width: 40px; height: 48px; font-size: 20px; }
  .portal-hero-card { padding: 24px 18px 20px; }
  .portal-hero-card h2, .portal-hero-card h3 { font-size: 22px; }
  .portal-split { grid-template-columns: 1fr; }
  .playlist-type-selector { flex-direction: column; }
  .account-header { flex-direction: column; gap: 12px; }
  .account-tab { padding: 10px 12px; font-size: 13px; }
  .section-card { padding: 18px; }
  .device-card { padding: 16px; }
  .device-card-meta { flex-direction: column; gap: 4px; }
  nav .nav-link { padding: 6px 10px; font-size: 13px; }
}

/* ─── Portal content views (CTTV-618 C1 / CTTV-621 C4) ───────── */

/* Category filter bar (C1) + chips */
/* CTTV-848 — search input shared by catch-up search + library search. */
.search-input-row {
  margin: 12px 0;
}
.search-input {
  width: 100%;
  max-width: 520px;
  padding: 10px 14px;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.search-input::placeholder { color: var(--text-secondary); }
.search-input:focus { border-color: var(--accent); }
.cat-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}
.cat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cat-chip:hover { background: var(--surface-hover); color: var(--text); }
.cat-chip.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.cat-chip-count {
  opacity: 0.7;
  font-size: 11px;
  margin-left: 4px;
}

/* Channel grid (C1) */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.channel-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-width: 0;
}
.channel-logo {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: contain;
  background: var(--bg);
  flex-shrink: 0;
}
.channel-logo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-secondary);
}
.channel-card-text { min-width: 0; }
.channel-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-group {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-unavailable {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 6px;
}

/* Category overview tiles (C4) */
.cat-overview-section { margin-bottom: 28px; }
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.cat-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.cat-tile:hover:not(.cat-tile-static) {
  background: var(--surface-hover);
  border-color: var(--accent);
}
.cat-tile-static { cursor: default; }
.cat-tile-name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-tile-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

/* ─── Session 6 portal views (C2 Library / C3 catch-up / C5-C6) ── */

/* Segmented toggle (Live|Catch-up, Movies|Series, Favourites|Watching) */
.seg-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 12px;
}
.seg-btn {
  background: var(--surface);
  color: var(--text-secondary);
  border: none;
  padding: 7px 18px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn:hover { background: var(--surface-hover); color: var(--text); }
.seg-btn.active { background: var(--accent); color: #fff; }

/* Catch-up badge on a channel card (C3) */
.catchup-badge {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 6px;
}

/* Poster grid for VOD / series browse (C2) */
.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}
.poster-card { min-width: 0; }
.poster-frame {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}
.poster-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.poster-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  color: var(--text-secondary);
}
.poster-rating {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffd54f;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}
/* CTTV-848 — favourite toggle on series poster cards. */
.poster-fav {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.poster-fav:hover { background: rgba(0, 0, 0, 0.85); transform: scale(1.08); }
.poster-fav:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.poster-fav.on { color: #ffd54f; border-color: #ffd54f; }
.poster-fav:disabled { opacity: 0.6; cursor: default; }
.poster-name {
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Continue Watching rows (C6) */
.cw-list { display: flex; flex-direction: column; gap: 12px; }
.cw-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.cw-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.cw-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cw-kind {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.cw-time {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}
.progress-track {
  height: 5px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.progress-fill-live {
  width: 100%;
  opacity: 0.35;
}

/* C2 episodes (CTTV-633) — clickable series cards + episode browser */
.poster-card-clickable { cursor: pointer; }
.poster-card-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.poster-card-clickable .poster-frame { transition: border-color 0.15s ease, transform 0.15s ease; }
.poster-card-clickable:hover .poster-frame { border-color: var(--accent); transform: translateY(-2px); }

.series-episodes-modal {
  position: relative;
  max-width: 640px;
  max-height: 82vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.modal-close:hover { color: var(--text); }
.series-modal-title { margin-bottom: 8px; padding-right: 28px; }
.episode-count-line {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.season-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.season-accordion > summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 600;
  background: var(--surface);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.season-accordion > summary::-webkit-details-marker { display: none; }
.season-count { font-size: 12px; font-weight: 400; color: var(--text-secondary); }
.episode-list { list-style: none; margin: 0; padding: 0; }
.episode-row {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  align-items: baseline;
}
.episode-num {
  flex: 0 0 36px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  font-size: 13px;
}
.episode-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.episode-title { font-size: 14px; }
.episode-meta { font-size: 12px; color: var(--text-secondary); }

/* Admin inline action feedback (browse rebuild, etc.) */
.admin-inline-status { font-size: 13px; color: var(--text-secondary); }
.advanced-settings { margin-top: 24px; }

/* CTTV-679 — Guide EPG grid + Smart Browse catch-up */
.guide-day-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 16px;
  flex-wrap: wrap;
}
.guide-day-label { font-weight: 600; min-width: 140px; text-align: center; }
.epg-grid { display: flex; flex-direction: column; gap: 8px; }
.epg-row {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.epg-channel { font-weight: 600; font-size: 14px; }
.epg-progs { display: flex; flex-wrap: wrap; gap: 8px; }
.epg-prog {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  min-width: 120px;
  max-width: 200px;
}
.epg-prog-title { font-size: 13px; font-weight: 500; }
.epg-prog-time { font-size: 11px; color: var(--text-secondary); }
.catchup-browse-layout {
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: 16px;
  min-height: 320px;
}
.catchup-channel-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--surface);
}
.catchup-channel-item {
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.catchup-channel-item:hover { background: var(--bg); }
.catchup-channel-selected { background: var(--accent-dim, rgba(99,102,241,.15)); font-weight: 600; }
.catchup-programme-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface);
  overflow-y: auto;
  max-height: 480px;
}
.catchup-prog-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.catchup-prog-title { font-size: 14px; font-weight: 500; }
.admin-browse-readiness { margin-bottom: 24px; }
.admin-readiness-table { font-size: 13px; }
.admin-readiness-error { color: var(--error, #f44336); cursor: help; }
.browse-not-ready { text-align: center; }
.admin-health-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.admin-health-chip { padding: 6px 10px; border-radius: 6px; font-size: 13px; }
.admin-health-chip.health-green { background: rgba(76, 175, 80, 0.2); color: #a5d6a7; }
.admin-health-chip.health-amber { background: rgba(255, 152, 0, 0.2); color: #ffcc80; }
.admin-health-chip.health-red { background: rgba(244, 67, 54, 0.2); color: #ef9a9a; }

/* ── CTTV-812: full-bleed browse layout ──────────────────────────── */
/* Browse surfaces use the full viewport width (capped on ultrawide for
   readability); account / admin / portal / device keep the default
   constrained .container width. */
#app.app-fullbleed .container {
  max-width: 1600px;
  padding: 0 clamp(16px, 4vw, 64px);
}

/* ── CTTV-812: reusable poster carousel ──────────────────────────── */
.poster-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  padding-bottom: 8px;
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
}
.poster-carousel > * { scroll-snap-align: start; }

/* ── CTTV-811 / CTTV-812: signed-in streaming home ───────────────── */
.stream-home {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 64px) 48px;
}
.stream-hero {
  position: relative;
  min-height: 340px;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(120deg, var(--surface-elevated), var(--bg));
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}
.stream-hero-scrim {
  width: 100%;
  padding: 48px;
  background: linear-gradient(0deg, rgba(11, 11, 11, 0.9), transparent);
}
.stream-hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 8px;
}
.stream-hero-title { font-size: 40px; font-weight: 700; margin: 0 0 20px; }
.stream-hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.stream-row { margin-bottom: 32px; }
.stream-row-title { font-size: 20px; font-weight: 600; margin: 0 0 12px; }
.stream-row-empty { color: var(--text-secondary); font-size: 14px; margin: 0; }
.stream-card {
  flex: 0 0 auto;
  width: 160px;
  text-decoration: none;
  color: var(--text);
}
.stream-card:hover .stream-card-art,
.stream-card:focus-visible .stream-card-art {
  outline: 2px solid var(--accent);
  transform: scale(1.04);
}
.stream-card-art {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: transform 200ms ease, outline-color 200ms ease;
}
.stream-card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
}
.stream-card-progress {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}
.stream-card-progress span { display: block; height: 100%; background: var(--accent); }
.stream-card-title {
  font-size: 14px;
  font-weight: 500;
  margin: 8px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stream-card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 2px 0 0;
}
