/* Universal box model reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* iOS-specific optimizations */
html {
  /* Prevent iOS text size adjustment on orientation change */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Enable smooth touch scrolling */
  -webkit-tap-highlight-color: transparent;
}

/* Screen reader only - visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Subtle page entrance animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body {
  animation: fadeIn 0.3s ease-out;
}

/* CSS Custom Properties - Design System */
:root {
  /* Layout dimensions */
  --channel-width: 7.5rem;
  --channel-height: 3.75rem;
  --time-height: 3.125rem;
  --hour-width: 15rem;

  /* Colors */
  --background: #001f3d;

  /* Borders and dividers */
  --border-color: #ddd;
  --border-width: 0.0625rem;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-base: 1rem;
  --spacing-lg: 1.25rem;
  --program-padding: var(--spacing-sm);

  /* Typography */
  --text-xs: 0.625rem;
  --text-sm: 0.75rem;
  --text-base: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.75rem;

  /* Border radius */
  --radius-sm: 0.25rem;
  --radius-base: 0.5rem;

  /* Current time indicator */
  --time-indicator-width: 0.125rem;
  --time-indicator-color: #e74c3c;

  /* Shadows */
  --shadow-sm: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.15);
  --shadow-base: 0 0.625rem 2.5rem rgba(0, 0, 0, 0.2);
  --shadow-corner: 0 0 0.625rem 0.0625rem rgba(0, 0, 0, 0.5);
  --shadow-sidebar: 0.125rem 0 0.625rem -0.125rem rgba(0, 0, 0, 0.5);

  /* Row stripes */
  --odd-stripe-color: #ffffff;
  --even-stripe-color: #f5f5f5;

  /* Program image width */
  --program-image-width: 40px;
}

/* Small screen CSS variables override */
@media only screen and (max-width: 768px) {
  :root {
    --hour-width: 12rem;
    --channel-width: 70px;
    --channel-height: 50px;
    --time-height: 40px;
    --program-padding: 4px;
    --spacing-sm: 0;
  }

  .channel-logo {
    width: 24px;
    height: 18px;
  }

  .channel-number {
    font-size: 0.6rem;
  }

  .channel-name {
    font-size: 0.65rem;
  }

  .program-duration {
    font-size: 0.55rem;
    padding: 2px 4px;
    gap: 2px;
  }

  .duration-icon {
    width: 12px;
    height: 12px;
  }

  .program-title {
    font-size: 0.7rem;
  }

  .program-time {
    font-size: 0.6rem;
  }

  .time-slot-date {
    font-size: 0.7rem;
  }

  .time-slot-time {
    font-size: 0.6rem;
  }
}

body {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    'SF Pro Display',
    'SF Pro Text',
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    sans-serif,
    Apple Color Emoji,
    Segoe UI Emoji,
    Segoe UI Symbol;
  background: #f0f0f0;
  color: #2c3e50;
  overflow: hidden;
  /* Use dvh for proper iOS Safari viewport handling */
  height: 100vh;
  height: 100dvh;
  /* Safe area padding for notch/Dynamic Island */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

#epg-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: white;
  position: relative;
}

/* Date slot in time axis */
.time-slot.date-slot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding-left: 0.5rem;
}

.time-slot-date {
  font-weight: 600;
  font-size: 0.8rem;
  color: #fff;
}

.time-slot-time {
  font-size: 0.7rem;
  opacity: 0.7;
}

/* Search Container - positioned in floating nav */
#search-container {
  position: relative;
}

/* Search panel (input + results) - hidden by default */
.search-panel {
  display: none;
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  width: 280px;
}

#search-container.expanded .search-panel {
  display: block;
}

#search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(0, 31, 61, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: #fff;
  font-size: 1rem;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  /* iOS-specific styling */
  -webkit-appearance: none;
  appearance: none;
  /* Prevent iOS zoom on focus */
  font-size: 16px;
}

#search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

#search-input:focus {
  outline: none;
  background: rgba(0, 31, 61, 0.95);
  border-color: rgba(255, 255, 255, 0.4);
}

.search-results {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 0.5rem;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  max-height: 400px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  z-index: 100;
}

.search-results.active {
  display: block;
}

.search-result-item {
  padding: 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.2s ease;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.selected {
  background: rgba(255, 255, 255, 0.1);
}

.search-result-item.selected {
  outline: 2px solid rgba(255, 255, 255, 0.3);
  outline-offset: -2px;
}

.search-result-title {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.search-result-meta {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
}

.search-no-results {
  padding: 1rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.875rem;
}

.search-loading {
  padding: 1rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
}

#sticky-container {
  display: flex;
  width: fit-content;
  min-width: 100%;
}

#time-axis {
  display: flex;
  height: var(--time-height);
  width: fit-content;
  min-width: calc(24 * var(--hour-width));
  background: var(--background);
  box-shadow: var(--shadow-corner);
  position: sticky;
  top: 0;
  z-index: 12;
  margin-left: calc(-1 * var(--channel-width));
  padding-left: var(--channel-width);
}

.time-slot {
  width: var(--hour-width);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: start;
  padding-left: 0.5rem;
  font-size: var(--text-base);
  border-right: 1px solid hsla(0, 0%, 87%, 0.5);
  color: #fff;
  background: linear-gradient(90deg, #001f3d, #002e5c);
}

#main-scroll-wrapper {
  flex: 1;
  overflow: auto;
  position: relative;
  cursor: grab;
}

#channel-sidebar {
  position: sticky;
  left: 0;
  width: var(--channel-width);
  background: #ecf0f1;
  z-index: 1;
  flex-shrink: 0;
  padding-top: var(--time-height);
}

#channel-list {
  width: 100%;
  box-shadow: var(--shadow-sidebar);
}

.channel {
  min-height: var(--channel-height);
  height: var(--channel-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--text-base);
  padding: var(--spacing-sm);
  border-bottom: 1px solid hsla(0, 0%, 87%, 0.5);
  color: #fff;
  background: linear-gradient(180deg, #001f3d, #002e5c);
}

.channel-logo {
  width: 40px;
  height: 30px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

.channel-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
}

.channel-number {
  font-size: var(--text-xs);
  color: #fff;
}

.channel-name {
  font-size: var(--text-sm);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

#programs-container {
  flex: 1;
  position: relative;
  overflow: visible;
  width: calc(24 * var(--hour-width));
}

#programs-grid {
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
}

/* Rowgroup container for ARIA structure */
#programs-grid > [role='rowgroup'] {
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
}

.channel-row {
  display: flex;
  min-height: var(--channel-height);
  height: var(--channel-height);
  width: calc(24 * var(--hour-width));
  border-bottom: var(--border-width) solid var(--border-color);
  position: relative;
  border-bottom: 1px solid #bbb;
  background-color: var(--odd-stripe-color);
  background-image: linear-gradient(
    to left top,
    transparent,
    transparent 25%,
    hsla(240, 9%, 60%, 0.1) 0,
    hsla(240, 9%, 60%, 0.1) 50%,
    transparent 0,
    transparent 75%,
    hsla(240, 9%, 60%, 0.1) 0
  );
  background-size: 1rem 1rem;
}

.channel-row:nth-child(odd) {
  background-color: var(--odd-stripe-color);
}

.channel-row:nth-child(even) {
  background-color: var(--even-stripe-color);
}

.program {
  position: absolute;
  height: calc(100%);
  padding: 0;
  border-left: 1px solid #ddd;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  cursor: default;
  /* Minimum touch target size for accessibility (WCAG 2.5.5) */
  min-width: 48px;
  /* CSS Containment for performance */
  contain: layout style paint;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.channel-row:nth-child(odd) .program {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.channel-row:nth-child(even) .program {
  background: #f5f5f5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Focus styles for keyboard navigation */
.program:focus {
  outline: 3px solid #3b82f6;
  outline-offset: 2px;
  box-shadow:
    0 0 0 4px rgba(59, 130, 246, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 2;
  transform: scale(1.02);
  transition: all 0.2s ease-out;
}

/* Highlight animation for navigated program */
@keyframes highlightPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
    transform: scale(1.02);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    transform: scale(1);
  }
}

.program.highlight-pulse {
  animation: highlightPulse 1s ease-out 2;
  border: 2px solid #3b82f6;
  z-index: 10;
}

.program-image {
  padding: 0.25rem; /* give the image a bit of space around it */
  flex-shrink: 0;
  width: var(--program-image-width);
  height: 100%;
  background: linear-gradient(135deg, #e8eef2 0%, #f5f7f9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.program-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.program-content {
  flex: 1;
  /*padding: var(--program-padding);*/
  display: flex;
  flex-direction: column;
  /*justify-content: space-between;*/
  min-width: 0;
  gap: 0.25rem;
}

.program-title-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.program-info-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #718096;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.15s ease;
}

.program-info-link:hover {
  color: #3498db;
  background: rgba(52, 152, 219, 0.1);
}

.program-info-link svg {
  display: block;
}

.program-title {
  width: 100%;
  font-size: 1rem;
  color: #1a202c;
  /*line-height: 1.3;*/
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /*margin-bottom: 2px;*/
  text-decoration: none;
  /* Ensure adequate touch target (WCAG 2.5.5) */
  padding: 8px 4px;
  /*min-height: 44px;*/
  display: block;
}

.program-title:hover {
  color: #3498db;
  text-decoration: underline;
}

.program-title:visited {
  color: #1a202c;
}

.program-title:visited:hover {
  color: #3498db;
}

.program-time {
  font-size: 0.688rem;
  color: #4a5568;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
}

.program-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  font-size: 0.625rem;
  color: #fff;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.duration-icon {
  flex-shrink: 0;
  opacity: 0.9;
}

.program.continues-from-yesterday {
  mask-image:
    linear-gradient(to top left, #fff, #fff 50%, transparent 0, transparent),
    linear-gradient(270deg, transparent 0.5rem, #000 0, #fff);
  mask-size:
    0.5rem 0.5rem,
    100% 100%;
  mask-repeat: repeat-y;
  mask-position: top left;
}

.program.continues-to-tomorrow {
  mask-image:
    linear-gradient(to top right, #fff, #fff 50%, transparent 0, transparent),
    linear-gradient(270deg, transparent 0.5rem, #000 0, #fff);
  -webkit-mask-size:
    0.5rem 0.5rem,
    100% 100%;
  mask-size:
    0.5rem 0.5rem,
    100% 100%;
  -webkit-mask-repeat: repeat-y;
  mask-repeat: repeat-y;
  -webkit-mask-position: top right;
  mask-position: top right;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.current-time-indicator {
  --now-border-size: 0.5rem;
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  background: rgba(231, 76, 60, 0.15);
  box-sizing: border-box;
  background-clip: padding-box;
  width: 1px;
  margin: 0 calc(-1 * var(--now-border-size));
  border-left: var(--now-border-size) solid rgba(231, 76, 60, 0.1);
  border-right: var(--now-border-size) solid rgba(231, 76, 60, 0.1);
  transition: left 0.5s ease-out;
}

.current-time-indicator::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e74c3c;
  transform: translateX(-50%);
  animation: pulse 2s ease-in-out infinite;
}

.current-time-indicator:before {
  --now-size: 0.5rem;
  content: '';
  display: block;
  margin-left: calc(-1 * var(--now-size));
  top: var(--time-height);
  width: 0;
  height: 0;
  pointer-events: none;
  position: sticky;
  border-width: var(--now-size);
  border-style: solid;
  border-color: #e74c3c transparent transparent transparent;
  border-image: initial;
  z-index: 1;
  filter: drop-shadow(0 2px 4px rgba(231, 76, 60, 0.3));
}

/* Dragging state optimizations */
#main-scroll-wrapper.dragging {
  cursor: grabbing !important;
  user-select: none;
}

#main-scroll-wrapper.dragging * {
  cursor: grabbing !important;
}

/* Program Modal - Netflix Style */
.program-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  /* Safe area padding for iPhone notch/Dynamic Island */
  padding-top: max(2rem, env(safe-area-inset-top, 0px));
  padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
  padding-left: max(2rem, env(safe-area-inset-left, 0px));
  padding-right: max(2rem, env(safe-area-inset-right, 0px));
  transition: all 0.3s ease;
}

.program-modal-overlay.active {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.program-modal {
  background: #181818;
  color: #fff;
  border-radius: 8px;
  max-width: 850px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  transform: scale(0.9);
  opacity: 0;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}

.program-modal-overlay.active .program-modal {
  transform: scale(1);
  opacity: 1;
}

/* Backdrop image */
.program-backdrop {
  position: relative;
  width: 100%;
  height: 400px;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
}

.program-backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Portrait image handling */
.program-backdrop.portrait {
  height: 300px;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.program-backdrop.portrait img {
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.backdrop-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: linear-gradient(to top, #181818, transparent);
}

/* Modal header (close button only) */
.program-modal-header {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 20;
}

.program-modal-close {
  background: rgba(0, 0, 0, 0.6);
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #fff;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.program-modal-close:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Modal body */
.program-modal-body {
  padding: 2rem;
  padding-top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}

/* Program header */
.program-header {
  margin-bottom: 1.5rem;
}

.modal-program-title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  line-height: 1.2;
  color: #fff;
}

.program-metadata {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
  color: #b3b3b3;
  margin-bottom: 0.75rem;
}

.metadata-separator {
  color: #666;
}

.inline-badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #666;
  border-radius: 3px;
  font-size: 0.8rem;
  color: #b3b3b3;
}

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

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-new {
  background: #e50914;
  color: white;
}

.badge-quality {
  background: #46d369;
  color: #000;
}

/* Episode title */
.episode-title {
  font-size: 1.1rem;
  color: #b3b3b3;
  margin-bottom: 1rem;
  font-weight: 500;
}

/* Description */
.program-description {
  font-size: 1rem;
  line-height: 1.6;
  color: #d4d4d4;
  margin-bottom: 1.5rem;
}

/* Airing info */
.airing-info {
  font-size: 0.9rem;
  color: #b3b3b3;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #333;
}

/* Current airing link */
.current-airing-link {
  cursor: pointer;
  padding: 0.75rem;
  margin: 0 -0.75rem 1.5rem;
  border-radius: 4px;
  border-left: 3px solid #e50914;
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.2s ease;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.current-airing-link:hover,
.current-airing-link:focus {
  background: rgba(255, 255, 255, 0.08);
  border-left-width: 5px;
  transform: translateX(2px);
}

.current-airing-link:active {
  transform: translateX(2px) scale(0.98);
}

.current-airing-link .airing-arrow {
  color: #e50914;
  font-size: 1.5rem;
  opacity: 0.5;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.current-airing-link:hover .airing-arrow,
.current-airing-link:focus .airing-arrow {
  opacity: 1;
  transform: translateX(4px);
}

/* Content grid - two columns */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.content-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.content-section {
  font-size: 0.9rem;
}

.section-label {
  color: #999;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.section-value {
  color: #d4d4d4;
  line-height: 1.5;
}

.more-link {
  color: #aaa;
  font-style: italic;
  font-size: 0.85rem;
}

.advisories {
  color: #ffc107;
  font-size: 0.9rem;
}

/* Awards section */
.awards-section {
  margin-bottom: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #333;
}

.awards-list {
  margin-top: 0.5rem;
}

.award-item {
  color: #d4d4d4;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

/* Event section */
.event-section {
  margin-bottom: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #333;
}

.event-teams {
  font-size: 1.1rem;
  color: #fff;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.event-info {
  color: #b3b3b3;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

/* Airings section */
.airings-section {
  margin-bottom: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #333;
}

.airings-list {
  margin-top: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
  overflow-x: hidden; /* Prevent horizontal scrollbar on hover */
}

.airing-item {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  border-left: 3px solid #e50914;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.airing-item:last-child {
  margin-bottom: 0;
}

.airing-item:hover,
.airing-item:focus {
  background: rgba(255, 255, 255, 0.1);
  border-left-width: 5px;
  transform: translateX(2px);
}

.airing-item:active {
  transform: translateX(2px) scale(0.98);
}

.airing-content {
  flex: 1;
}

.airing-date {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.airing-channel {
  color: #b3b3b3;
  font-size: 0.85rem;
}

.airing-arrow {
  color: #e50914;
  font-size: 1.5rem;
  opacity: 0.5;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.airing-item:hover .airing-arrow,
.airing-item:focus .airing-arrow {
  opacity: 1;
  transform: translateX(4px);
}

/* Loading and error states */
.loading {
  text-align: center;
  padding: 3rem;
  color: #b3b3b3;
}

.error-message {
  background: rgba(229, 9, 20, 0.1);
  border-left: 4px solid #e50914;
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
  color: #ff8a80;
}

/* Fallback info rows (for error state) */
.info-row {
  margin-bottom: 0.75rem;
  line-height: 1.6;
  color: #d4d4d4;
}

.info-row:last-child {
  margin-bottom: 0;
}

/* Legacy badge support */
.category-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #e50914;
  color: white;
}

/* Responsive */
@media (max-width: 768px) {
  .program-modal-overlay {
    padding: 0;
  }

  .program-modal {
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .program-backdrop {
    height: 250px;
  }

  .program-backdrop.portrait {
    height: 200px;
  }

  .program-modal-body {
    padding: 1.5rem 1rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }

  .modal-program-title {
    font-size: 1.5rem;
  }

  .content-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Loading state */
.epg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  font-size: var(--text-lg);
  color: #7f8c8d;
}

.epg-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  color: #e74c3c;
}

/* Empty state: day with no schedules (grid stays visible behind it) */
.epg-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 2rem);
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  background: rgba(0, 31, 61, 0.85);
  color: white;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 50;
}

.epg-empty-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
}

.epg-empty-help {
  margin: 0.25rem 0 0;
  font-size: var(--text-base);
  opacity: 0.8;
}

/* Floating navigation buttons (mobile-friendly) */
.floating-nav {
  position: fixed;
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  right: calc(1.5rem + env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  z-index: 100;
}

.fab-button {
  width: 3.5rem;
  height: 3.5rem;
  min-width: 44px; /* Touch target minimum */
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 31, 61, 0.5);
  color: white;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.fab-button:hover {
  background: rgba(0, 31, 61, 0.75);
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.fab-button:active {
  transform: scale(0.95);
}

.fab-button.fab-today {
  background: rgba(41, 128, 185, 0.5);
}

.fab-button.fab-today:hover {
  background: rgba(41, 128, 185, 0.75);
}

.fab-button svg {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
}

/* Responsive breakpoint for tablets and mobile devices */
@media (max-width: 48rem) {
  /* Disable hover effects on touch devices */
  .program {
    will-change: auto;
    backface-visibility: visible;
    /* Optimize touch scrolling */
    touch-action: pan-x pan-y;
  }

  .program:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .program:active {
    transform: scale(0.98) translateZ(0);
    transition: transform 0.1s;
    background: rgba(0, 0, 0, 0.05);
  }

  .channel-row {
    contain: layout style;
  }

  /* Smooth scrolling on mobile */
  #main-scroll-wrapper {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
    scroll-behavior: smooth;
    /* Improve touch scroll performance */
    touch-action: pan-x pan-y;
    overscroll-behavior: contain;
  }

  /* Adjust floating nav for mobile with safe areas */
  .floating-nav {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
    gap: 0.5rem;
  }

  .fab-button {
    width: 3rem;
    height: 3rem;
    font-size: 1.25rem;
  }

  #search-container.expanded .search-panel {
    bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
    left: calc(1rem + env(safe-area-inset-left, 0px));
    width: auto;
  }

  /* Larger touch targets */
  .program-title {
    font-size: var(--text-sm);
    padding: 2px 0;
  }

  .program-time {
    font-size: var(--text-xs);
  }

  /* Full-screen modal on mobile with safe areas */
  .program-modal-overlay {
    padding: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .program-modal {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .program-modal-header {
    padding: 0.75rem 1rem;
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
    padding-right: calc(1rem + env(safe-area-inset-right, 0px));
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .program-modal-body {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(1rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1rem + env(safe-area-inset-right, 0px));
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Better touch feedback */
  .program-modal-close {
    width: 44px;
    height: 44px;
  }

  .program-modal-close:active {
    transform: scale(0.9);
    transition: transform 0.1s;
  }

  /* Optimize time axis for mobile */
  .time-slot {
    font-size: 0.75rem;
    padding-left: 0.25rem;
  }

  /* Improve search results touch targets */
  .search-result-item {
    padding: 1rem 0.75rem;
    min-height: 44px;
  }
}
