/**
 * RundAwn - 2026+ Modern Broadcast Skin
 * Glass morphism, micro-animations, keyboard-first design
 * High-contrast dark theme for broadcast environments
 */

/* ============================================================================
   Design Tokens
   ============================================================================ */

:root {
  /* Colour Palette */
  --bg-void: #050508;
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a24;
  --bg-elevated: #22222e;
  --bg-hover: #2a2a38;

  /* Glass Effects */
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-bg-hover: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(255, 255, 255, 0.15);
  --glass-blur: 20px;

  /* Text */
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --text-dim: #404050;

  /* Accent Colours */
  --accent-cyan: #00d4ff;
  --accent-green: #00ff88;
  --accent-orange: #ff9500;
  --accent-red: #ff3366;
  --accent-purple: #a855f7;
  --accent-pink: #ff6b9d;
  --accent-edit: #02b4a3;        /* Edit mode accent — teal */

  /* Gradients */
  --gradient-accent: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-green) 100%);
  --gradient-warm: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-red) 100%);
  --gradient-glow: radial-gradient(ellipse at center, var(--accent-cyan) 0%, transparent 70%);

  /* Status Colours */
  --status-live: #ff3b30;
  --status-standby: var(--accent-green);
  --status-paused: var(--accent-orange);
  --status-ending: #ff6600;
  --status-frozen: var(--accent-red);

  /* Segment Type Colours — see docs/SEGMENT-TYPES.md
     Broadcast-safe palette: avoids pure red/green (tally/PGM/PST reserved) */
  --type-act: #C4A0E2;               /* Soft Purple — performance/act */
  --type-cam: #7EB0E8;               /* Steel Blue — presenter/camera */
  --type-live: #E89090;              /* Muted Coral — live (distinct from CAM) */
  --type-iv: #E8B878;                /* Warm Amber — interview */
  --type-vt: #5EAD6E;                /* Forest Green — pre-recorded (muted, not tally-green) */
  --type-gfx: #C4D468;               /* Lime — graphics */
  --type-sting: #6CBCB4;             /* Teal — stinger transition */
  --type-bump: #6CBCB4;              /* Teal — bumper */
  --type-break: #E8E8EE;             /* Ice — break (near-white, neutral) */
  --type-game: #E290C0;              /* Orchid — esports/gaming */
  --type-misc: #A0A0B4;              /* Slate — uncategorised */

  /* Typography */
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Spacing Scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-cyan: 0 0 30px rgba(0, 212, 255, 0.3);
  --shadow-glow-green: 0 0 30px rgba(0, 255, 136, 0.3);
  --shadow-glow-red: 0 0 30px rgba(255, 51, 102, 0.4);

  /* Transitions */
  --transition-fast: 100ms ease-out;
  --transition-base: 200ms ease-out;
  --transition-slow: 300ms ease-out;
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-Index Scale */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 500;
  --z-toast: 600;
  --z-overlay: 700;
  --z-command: 800;
}

/* ============================================================================
   Reset & Base
   ============================================================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-void);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Skip Links - visible only on focus for keyboard navigation */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-3) var(--space-5);
  background: var(--accent-edit);
  color: var(--bg-void);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-md);
  z-index: calc(var(--z-command) + 10);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-4);
  outline: none;
}

/* Visually Hidden - accessible to screen readers but not visible */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Subtle background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(0, 255, 136, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* ============================================================================
   Layout — 2026 Modern Responsive
   Using container queries, fluid sizing, no rigid minimums
   ============================================================================ */

.app-container {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(8px, 2vw, 24px);
  gap: clamp(8px, 2vw, 24px);
}

.main-content {
  display: grid;
  /* Golden ratio split: 70.7% / 29.3% (≈ φ inverse)
     This specific ratio is critical for visual balance */
  grid-template-columns: 70.7fr 29.3fr;
  gap: var(--space-4);
  min-width: 0;
  width: 100%;
  overflow: hidden; /* Prevent content overflow from breaking layout */
}

.left-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
  contain: layout; /* CSS containment prevents child overflow propagation */
}

/* Stack layout on narrow viewports */
@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    order: -1;
    max-height: 40vh; /* Don't let panel dominate on mobile */
    overflow-y: auto;
  }
}

/* ============================================================================
   Glass Panel Base
   ============================================================================ */

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
}

.glass:hover {
  border-color: var(--glass-border-hover);
}

/* ============================================================================
   Header
   ============================================================================ */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  /* Ensure header dropdowns appear above main content (countdown, rundown) */
  position: relative;
  z-index: var(--z-sticky);
}

.header-left,
.header-center,
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0; /* Allow flex items to shrink below content size */
}

.header-left {
  flex: 0 1 auto; /* Don't grow, but allow shrinking */
  overflow: visible; /* Allow dropdown to overflow */
}

.header-center {
  flex: 1 1 auto; /* Grow to fill space, shrink when needed */
  justify-content: center;
  /* Note: overflow must be visible for rundown dropdown to show */
}

.header-right {
  flex-shrink: 0; /* Never shrink - always show ARM/STANDBY controls */
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.logo-img {
  height: 24px;
  width: auto;
}

/* Sync Status - matches .mode-btn style */
.btn-sync {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  cursor: default;
  transition: var(--transition-base);
  white-space: nowrap;
}

.btn-sync.online {
  color: var(--accent-green);
}

.btn-sync.offline {
  color: var(--text-muted);
}

.btn-sync .sync-text {
  white-space: nowrap;
}

/* Sync status - matches .mode-btn style */
.sync-status {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  background: transparent;
  transition: var(--transition-base);
  white-space: nowrap;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
  transition: var(--transition-base);
}

.sync-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.sync-dot.offline {
  background: var(--accent-red);
}

.sync-dot.connecting {
  background: var(--accent-orange);
  animation: sync-pulse 1s ease-in-out infinite;
}

.sync-status.saving .sync-dot {
  animation: sync-pulse 1s ease-in-out infinite;
}

.sync-status.error-flash {
  animation: sync-error-flash 0.5s ease-out;
}

.sync-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes sync-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

@keyframes sync-error-flash {
  0%, 100% { background: transparent; }
  25%, 75% { background: rgba(255, 59, 59, 0.2); }
}

/* Undo Indicator */
.undo-indicator {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0;
  transition: var(--transition-base);
}

.undo-indicator.visible {
  opacity: 1;
}

/* Module Navigation */
.module-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.module-nav-divider {
  width: 1px;
  height: 24px;
  background: var(--glass-border);
  margin: 0 var(--space-2);
}

/* Module links — icon-only with hover tooltip */
.module-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-base);
}

.module-link:hover {
  color: var(--text-primary);
  background: var(--glass-bg);
}

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

.module-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.module-icon svg {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  transition: var(--transition-base);
}

.module-link:hover .module-icon svg {
  opacity: 1;
}

/* Hide text labels — tooltip via title attribute */
.module-label {
  display: none;
}

/* Status Indicator */
.status-indicator {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  transition: var(--transition-base);
}

.status-indicator.standby {
  background: var(--bg-tertiary);
  color: var(--status-standby);
  border: 1px solid var(--status-standby);
  cursor: pointer;
}

.status-indicator.standby:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-edit);
}

.status-indicator.preroll {
  background: var(--accent-edit);
  color: var(--bg-primary);
  border: 1px solid var(--accent-edit);
  animation: pulse-status 1s ease-in-out infinite;
  cursor: pointer;
}

.status-indicator.live {
  background: var(--status-live);
  color: white;
  box-shadow: var(--shadow-glow-red);
  animation: pulse-status 1s ease-in-out infinite;
  cursor: pointer;
}

.status-indicator.paused {
  background: var(--status-paused);
  color: var(--bg-primary);
  cursor: pointer;
}

.status-indicator.paused:hover {
  filter: brightness(1.1);
}

.status-indicator.ending {
  background: var(--status-ending);
  color: white;
  animation: pulse-status 0.5s ease-in-out infinite;
  cursor: pointer;
}

.status-indicator.frozen {
  background: var(--status-frozen);
  color: white;
  animation: pulse-status 0.25s ease-in-out infinite;
}

@keyframes pulse-status {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
}

.btn:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}

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

.btn:active {
  transform: scale(0.98);
}

.btn-sm {
  font-size: 0.75rem;
  padding: var(--space-1) var(--space-2);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--glass-bg);
  border-color: var(--glass-border);
}

.btn-primary {
  background: var(--gradient-accent);
  border-color: transparent;
  color: var(--bg-primary);
  font-weight: 600;
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow-cyan);
  transform: translateY(-1px);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
  line-height: 1;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-label {
  display: none;
}

@media (min-width: 640px) {
  .btn-label {
    display: inline;
  }
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

/* Tap Tempo Button */
.btn-tap {
  position: relative;
  overflow: hidden;
}

.tap-pulse {
  position: absolute;
  inset: 0;
  background: var(--gradient-accent);
  opacity: 0;
  border-radius: inherit;
  transition: opacity 0.1s;
}

.btn-tap.active .tap-pulse {
  animation: tap-flash 0.15s ease-out;
}

@keyframes tap-flash {
  0% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.2); }
}

/* Tap Tempo and Audio Import Buttons */
#btn-tap-tempo,
#btn-import-audio {
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-colour, var(--glass-border));
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

#btn-tap-tempo {
  font-size: 0.7rem;
}

#btn-import-audio:hover:not(:disabled) {
  background: var(--bg-hover);
}

#btn-import-audio:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ARM Button - Hard-start toggle */
.btn-arm {
  background: var(--bg-tertiary);
  border-color: var(--glass-border);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: var(--transition-base);
}

.btn-arm:hover {
  background: var(--bg-hover);
  border-color: var(--accent-red);
  color: var(--text-secondary);
}

.btn-arm[aria-pressed="true"] {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: white;
  box-shadow: var(--shadow-glow-red);
  animation: arm-pulse 1.5s ease-in-out infinite;
}

.btn-arm[aria-pressed="true"]:hover {
  background: #ff1a1a;
}

@keyframes arm-pulse {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 0, 64, 0.4); }
  50% { box-shadow: 0 0 25px rgba(255, 0, 64, 0.6); }
}

/* RE-TIME Button - Programme re-timing */
.btn-retime {
  position: relative;
  background: var(--bg-tertiary);
  border-color: var(--glass-border);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: var(--transition-base);
}

.btn-retime:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent-edit);
  color: var(--text-secondary);
}

.btn-retime:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-retime.active {
  background: var(--accent-edit);
  border-color: var(--accent-edit);
  color: var(--bg-primary);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent-edit) 40%, transparent);
}

.btn-retime.late {
  border-color: var(--accent-orange);
}

.btn-retime.late:hover:not(:disabled) {
  border-color: var(--accent-orange);
}

/* Deviation badge on RE-TIME button */
.deviation-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: var(--radius-full);
  background: var(--accent-green);
  color: var(--bg-primary);
  white-space: nowrap;
}

.deviation-badge.late {
  background: var(--accent-orange);
}

.deviation-badge.critical {
  background: var(--accent-red);
  animation: badge-pulse 1s ease-in-out infinite;
}

.deviation-badge.hidden {
  display: none;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ============================================================================
   Countdown Banner
   ============================================================================ */

.countdown-banner {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  overflow: hidden;
}

.countdown-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: var(--space-4);
}

.countdown-time {
  font-size: clamp(3rem, 10vw, 8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; /* Fixed-width digits prevent layout shift */
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 60px rgba(0, 212, 255, 0.3);
  white-space: nowrap;
}

.countdown-tenths {
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 500;
  color: var(--text-muted);
  margin-left: var(--space-1);
}

/* Countdown states */
.countdown-banner.ending .countdown-time {
  background: var(--gradient-warm);
  -webkit-background-clip: text;
  background-clip: text;
  animation: glow-pulse 0.5s ease-in-out infinite;
}

.countdown-banner.overtime .countdown-time {
  background: var(--accent-red);
  -webkit-background-clip: text;
  background-clip: text;
}

/* Over-run states (countdown past zero) */
.countdown-banner.over-run .countdown-time {
  background: var(--accent-orange);
  -webkit-background-clip: text;
  background-clip: text;
}

.countdown-banner.over-run-warning .countdown-time {
  background: var(--accent-orange);
  -webkit-background-clip: text;
  background-clip: text;
  animation: glow-pulse 1s ease-in-out infinite;
}

.countdown-banner.over-run-critical .countdown-time {
  background: var(--accent-red);
  -webkit-background-clip: text;
  background-clip: text;
  animation: glow-pulse 0.5s ease-in-out infinite;
}

/* Over-run progress bar */
.countdown-banner.over-run .countdown-progress-bar,
.countdown-banner.over-run-warning .countdown-progress-bar {
  background: var(--accent-orange);
  box-shadow: 0 0 12px var(--accent-orange);
}

.countdown-banner.over-run-critical .countdown-progress-bar {
  background: var(--accent-red);
  box-shadow: 0 0 12px var(--accent-red);
}

@keyframes glow-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

/* Segment Info */
.segment-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.segment-slug {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.segment-type {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--type-misc);
  color: var(--text-secondary);
}

/* Segment type colours — see docs/SEGMENT-TYPES.md */
.segment-type.act { background: var(--type-act); color: var(--bg-primary); }
.segment-type.cam { background: var(--type-cam); color: var(--bg-primary); }
.segment-type.live { background: var(--type-live); color: var(--bg-primary); }
.segment-type.iv { background: var(--type-iv); color: var(--bg-primary); }
.segment-type.vt { background: var(--type-vt); color: var(--bg-primary); }
.segment-type.gfx { background: var(--type-gfx); color: var(--bg-primary); }
.segment-type.sting { background: var(--type-sting); color: var(--bg-primary); }
.segment-type.bump { background: var(--type-bump); color: var(--bg-primary); }
.segment-type.break { background: var(--type-break); color: var(--bg-primary); }
.segment-type.game { background: var(--type-game); color: var(--bg-primary); }
.segment-type.misc { background: var(--type-misc); color: var(--bg-primary); }

.badge {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* Segment type badges — all use dark text for contrast on pastel backgrounds */
.badge.act { background: var(--type-act); color: var(--bg-primary); }
.badge.cam { background: var(--type-cam); color: var(--bg-primary); }
.badge.live { background: var(--type-live); color: var(--bg-primary); }
.badge.iv { background: var(--type-iv); color: var(--bg-primary); }
.badge.vt { background: var(--type-vt); color: var(--bg-primary); }
.badge.gfx { background: var(--type-gfx); color: var(--bg-primary); }
.badge.sting { background: var(--type-sting); color: var(--bg-primary); }
.badge.bump { background: var(--type-bump); color: var(--bg-primary); }
.badge.game { background: var(--type-game); color: var(--bg-primary); }
.badge.break { background: var(--type-break); color: var(--bg-primary); }
.badge.misc { background: var(--type-misc); color: var(--bg-primary); }

/* Next Segment */
.next-segment {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.next-segment::before {
  content: 'NEXT → ';
  font-weight: 600;
  color: var(--text-dim);
}

.next-segment:empty::before {
  content: '';
}

/* Rate Indicator */
.rate-indicator {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-orange);
  min-height: 1.5em;
  opacity: 0;
  transition: var(--transition-base);
}

.rate-indicator:not(:empty) {
  opacity: 1;
}

/* Progress Bar */
.countdown-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--bg-tertiary);
  overflow: hidden;  /* Contain box-shadow glow within progress area */
}

.countdown-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--gradient-accent);
  transition: width 0.1s linear;
  box-shadow: 0 0 12px var(--accent-cyan);
}

.countdown-banner.ending .countdown-progress-bar {
  background: var(--gradient-warm);
  box-shadow: 0 0 12px var(--accent-orange);
}

/* ============================================================================
   Controls Panel
   ============================================================================ */

.controls-panel {
  /* Container queries: panel adapts content based on its own width */
  container-type: inline-size;
  container-name: controls;

  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: clamp(8px, 3cqi, 24px); /* Fluid padding based on container */
  min-width: 0;
  overflow: hidden; /* Prevent content overflow */
}

/* ============================================================================
   Controls Panel — Container Query Adaptations
   Panel content adapts to available width, not viewport
   ============================================================================ */

/* Compact mode: panel is narrow (< 280px) */
@container controls (width < 280px) {
  .control-section {
    padding: var(--space-2);
  }

  .control-section-header {
    font-size: 0.7rem;
  }

  .btn {
    padding: var(--space-1) var(--space-2);
    font-size: 0.75rem;
  }

  /* Hide less important sections when cramped */
  .control-section.collapsible:not([open]) {
    display: none;
  }
}

/* Very compact: panel is very narrow (< 220px) */
@container controls (width < 220px) {
  .control-section-header span:not(.section-icon) {
    display: none; /* Show only icons */
  }

  .btn-text {
    display: none; /* Icon-only buttons */
  }

  .timing-icons {
    gap: 2px;
  }
}

/* Comfortable mode: panel has good width (> 320px) */
@container controls (width > 320px) {
  .control-section {
    padding: var(--space-4);
  }
}

.control-section {
  /* No margin needed, gap handles spacing */
}

.control-section h3 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--glass-border);
}

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

/* Collapsible Sections */
.control-section.collapsible h3 {
  cursor: pointer;
  user-select: none;
  transition: var(--transition-base);
}

.control-section.collapsible h3:hover {
  color: var(--text-secondary);
}

.section-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.toggle-icon {
  margin-left: auto;
  font-size: 0.6rem;
  transition: var(--transition-base);
}

.control-section.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.control-section.collapsed > *:not(h3) {
  display: none;
}

/* Settings Buttons Grid */
.settings-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.btn-settings {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition-base);
}

.btn-settings:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}

.btn-settings:active {
  transform: scale(0.98);
}

.btn-settings .btn-icon {
  font-size: 1rem;
}

.btn-settings .btn-label {
  font-family: var(--font-mono);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Control Rows */
.control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

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

.control-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 50px;
}

.control-hint {
  flex-basis: 100%;
  font-size: 0.7rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: calc(-1 * var(--space-2));
  padding-left: calc(50px + var(--space-3));
}

/* ============================================================================
   Form Elements
   ============================================================================ */

.input-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

.ts-group {
  gap: var(--space-1);
  flex: 0 0 auto;
}

/* BPM row: input left, buttons right-aligned */
.control-row:has(#bpm-input) .input-group {
  justify-content: flex-end;
}

#bpm-input {
  width: 84px;
  margin-right: auto;
}

.ts-divider {
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.input,
.select {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  outline: none;
  transition: var(--transition-base);
}

.input:hover,
.select:hover {
  border-color: var(--glass-border-hover);
}

.input:focus,
.select:focus {
  border-color: var(--accent-edit);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-edit) 15%, transparent);
}

.input {
  width: 100%;
}

.input-sm {
  width: 72px;
  text-align: center;
  padding: var(--space-2);
}

.input-suffix {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.select {
  cursor: pointer;
  flex: 1;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

/* Position Display */
.position-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  padding: var(--space-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-top: var(--space-3);
}

.position-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.position-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.position-display.active .position-value {
  color: var(--accent-green);
}

/* ============================================================================
   Rundown Table
   ============================================================================ */

.rundown-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.rundown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--glass-border);
}

.rundown-header h2 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* Programme info in rundown header - matches h2 style */
.programme-info {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-left: var(--space-4);
}

.programme-stat {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.programme-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.programme-value,
.programme-time-input {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.programme-time-input {
  padding: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  width: 5.5em;
  transition: border-color var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
}

.programme-time-input::placeholder {
  color: var(--text-dim);
}

.programme-time-input:hover {
  border-bottom-color: var(--text-muted);
}

.programme-time-input:focus {
  outline: none;
  border-bottom-color: var(--accent-edit);
  color: var(--accent-edit);
  cursor: text;
}

/* Hide programme stats that have no value */
.programme-stat.hidden {
  display: none;
}

/* Column visibility menu */
.column-menu-container {
  position: relative;
}

.column-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.column-menu-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-edit);
}

.column-menu-btn:focus-visible {
  outline: 2px solid var(--accent-edit);
  outline-offset: 2px;
}

.column-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-1);
  min-width: 160px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: var(--z-dropdown, 100);
  padding: var(--space-1) 0;
}

.column-menu-dropdown.hidden {
  display: none;
}

.column-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.column-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.column-menu-item .column-check {
  width: 16px;
  color: var(--accent-edit);
  font-weight: 600;
}

.column-menu-item.hidden-col .column-check {
  visibility: hidden;
}

.column-menu-item.hidden-col {
  color: var(--text-dim);
}

.rundown-scroll {
  flex: 1;
  overflow: auto;
  min-width: 0;
  min-height: 0;
  container: rundown / inline-size;
}

.rundown-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto; /* Columns size based on content, flex columns expand */
}

.rundown-table th {
  position: sticky;
  top: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: left;
  padding: var(--space-2) var(--space-4);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--glass-border);
  z-index: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rundown-table td {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--glass-border);
  vertical-align: middle;
}

.rundown-table tbody tr {
  cursor: pointer;
  transition: var(--transition-fast);
  contain: layout style;
}

.rundown-table tbody tr:hover {
  background: var(--bg-hover);
}

/* Focus styles for keyboard navigation in Editor mode */
.rundown-table tbody tr:focus {
  outline: none;
  background: color-mix(in srgb, var(--accent-edit) 15%, transparent);
  box-shadow: inset 0 0 0 2px var(--accent-edit);
}

.rundown-table tbody tr:focus-visible {
  outline: 2px solid var(--accent-edit);
  outline-offset: -2px;
}

/* Currently playing segment - RED background + outline */
.rundown-table tbody tr.current {
  background: rgba(255, 0, 64, 0.15);
  outline: 2px solid var(--status-live);
  outline-offset: -2px;
}

/* Live AND selected - cyan background, keep red outline */
.rundown-table tbody tr.current.selected {
  background: color-mix(in srgb, var(--accent-edit) 15%, transparent);
  outline: 2px solid var(--status-live);
  outline-offset: -2px;
}

/* Next segment - GREEN outline */
.rundown-table tbody tr.next {
  background: rgba(0, 255, 136, 0.1);
  outline: 2px solid var(--accent-green);
  outline-offset: -2px;
}

.rundown-table tbody tr.past {
  opacity: 0.4;
}

/* Column widths
   LEFT SIDE (flex, expandable): Drag, ID, TOD, Slug, Description, Contributor
   RIGHT SIDE (fixed): Type, Timing/Go, Duration, Actions
*/

/* Left columns - compact or expanding */
.col-drag { width: 16px; max-width: 16px; }
.col-id { width: 36px; white-space: nowrap; color: var(--text-muted); }
.col-tod {
  width: 60px;
  white-space: nowrap;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Flex columns: share remaining space equally (1/3 each) */
.col-slug,
.col-description,
.col-contributor {
  width: 33.33%;
  min-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-slug { font-weight: 600; }
.col-description,
.col-contributor {
  color: var(--text-secondary);
  font-size: 0.85em;
}

/* Right columns - FIXED widths, never shrink */
.col-type {
  width: 80px;
  min-width: 80px;
  white-space: nowrap;
}
.col-timing {
  width: 50px;
  min-width: 50px;
  text-align: center;
}
.col-duration {
  width: 80px;
  min-width: 80px;
  white-space: nowrap;
  text-align: right;
  color: var(--text-secondary);
}
.col-actions {
  width: 50px;
  min-width: 50px;
  white-space: nowrap;
  text-align: right;
}
.col-actions .action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-1);
}

/* Column toggle - clickable headers */
.rundown-table th[data-column] {
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s ease;
}
.rundown-table th[data-column]:hover {
  opacity: 0.7;
}

/* Hidden columns */
.rundown-table.hide-id .col-id,
.rundown-table.hide-tod .col-tod,
.rundown-table.hide-slug .col-slug,
.rundown-table.hide-description .col-description,
.rundown-table.hide-contributor .col-contributor,
.rundown-table.hide-type .col-type,
.rundown-table.hide-timing .col-timing,
.rundown-table.hide-duration .col-duration {
  display: none;
}

/* TOD variance indicators */
.tod-calculated {
  display: block;
  line-height: 1.2;
}

.tod-variance {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.2;
}

.tod-variance.late {
  color: var(--accent-orange);
}

.tod-variance.early {
  color: var(--accent-green);
}

/* Timing indicators (start mode, flex, auto-advance)
   Order: start-mode, flex-mode, auto-advance
   Start/flex always bright (showing current mode)
   Auto-advance dim when off, bright when on */
.timing-icons {
  display: flex;
  gap: var(--space-1);
  justify-content: center;
  align-items: center;
}

.timing-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  transition: var(--transition-fast);
}

.timing-icon svg {
  display: block;
  width: 12px;
  height: 12px;
}

/* Start mode & flex mode — always bright (shows current state) */
.timing-icon.start-mode,
.timing-icon.flex-mode {
  color: var(--text-secondary);
  opacity: 1;
}

/* Default marker (using type default) — slightly dimmer */
.timing-icon.default {
  opacity: 0.6;
}

/* Auto-advance — only icon with active/inactive states */
.timing-icon.auto-advance.inactive {
  color: var(--text-dim);
  opacity: 0.4;
}

.timing-icon.auto-advance.active {
  color: var(--text-primary);
  opacity: 1;
}

/* Hover — all icons brighten on hover */
.timing-icon:hover {
  color: var(--text-primary);
  opacity: 1;
}

/* Clickable icons in Editor mode */
[data-gui-mode="editor"] .timing-icon {
  cursor: pointer;
}

[data-gui-mode="editor"] .timing-icon:hover {
  transform: scale(1.15);
}

.type-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 0;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 65px;
  text-align: center;
  /* Default: grey placeholder */
  background: var(--type-misc);
  color: var(--text-secondary);
}

/* Type badge colours — see docs/SEGMENT-TYPES.md
   Broadcast-safe: dark text on pastel backgrounds for contrast */
.type-badge.act { background: var(--type-act); color: var(--bg-primary); }
.type-badge.cam { background: var(--type-cam); color: var(--bg-primary); }
.type-badge.live { background: var(--type-live); color: var(--bg-primary); }
.type-badge.iv { background: var(--type-iv); color: var(--bg-primary); }
.type-badge.vt { background: var(--type-vt); color: var(--bg-primary); }
.type-badge.gfx { background: var(--type-gfx); color: var(--bg-primary); }
.type-badge.sting { background: var(--type-sting); color: var(--bg-primary); }
.type-badge.bump { background: var(--type-bump); color: var(--bg-primary); }
.type-badge.game { background: var(--type-game); color: var(--bg-primary); }
.type-badge.break { background: var(--type-break); color: var(--bg-primary); }
.type-badge.misc { background: var(--type-misc); color: var(--bg-primary); }

.btn-take {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  cursor: pointer;
  transition: var(--transition-base);
}

.btn-take:hover {
  background: var(--accent-edit);
  color: var(--bg-primary);
  border-color: var(--accent-edit);
}

/* ============================================================================
   Cue List
   ============================================================================ */

.cue-list {
  max-height: 180px;
  overflow-y: auto;
}

.cue-item {
  display: grid;
  grid-template-columns: 55px 75px 1fr;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border-bottom: 1px solid var(--glass-border);
  transition: var(--transition-fast);
  contain: layout style;
}

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

.cue-item:hover {
  background: var(--bg-hover);
  margin: 0 calc(-1 * var(--space-2));
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}

.cue-item.imminent {
  background: color-mix(in srgb, var(--accent-edit) 10%, transparent);
}

.cue-time {
  color: var(--accent-cyan);
  font-weight: 500;
}

.cue-action {
  color: var(--text-primary);
  font-weight: 600;
}

.cue-note {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================================
   Intent Log
   ============================================================================ */

.intent-log {
  max-height: 140px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.log-entry {
  display: grid;
  grid-template-columns: 70px 55px 1fr;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--glass-border);
  contain: layout style;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--text-dim);
}

.log-intent {
  color: var(--accent-cyan);
  font-weight: 600;
}

.log-payload {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================================
   Footer / Keyboard Hints
   ============================================================================ */

.footer {
  padding: var(--space-3) var(--space-4);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
}

.key-hints {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.key-hint {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.key-hint kbd {
  font-weight: 600;
  min-width: 28px;
  text-align: center;
}

/* ============================================================================
   Command Palette
   ============================================================================ */

.command-palette {
  position: fixed;
  inset: 0;
  z-index: var(--z-command);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.command-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  animation: fade-in 0.15s ease-out;
}

.command-modal {
  position: relative;
  width: 90%;
  max-width: 560px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--shadow-glow-cyan);
  overflow: hidden;
  animation: slide-up 0.2s ease-out;
}

.command-search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--glass-border);
}

.command-icon {
  font-size: 1.25rem;
  color: var(--text-muted);
}

.command-input {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  background: transparent;
  border: none;
  color: var(--text-primary);
  outline: none;
}

.command-input::placeholder {
  color: var(--text-dim);
}

.command-hint {
  opacity: 0.5;
}

.command-results {
  max-height: 360px;
  overflow-y: auto;
}

.command-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: var(--transition-fast);
  contain: layout style;
}

.command-item:hover,
.command-item.selected {
  background: var(--bg-hover);
}

.command-item.selected {
  border-left: 2px solid var(--accent-cyan);
  padding-left: calc(var(--space-4) - 2px);
}

.command-item-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.command-item-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.command-item-text {
  flex: 1;
}

.command-item-label {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.command-item-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.command-item-shortcut {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

.command-footer {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-3);
  background: var(--bg-tertiary);
  border-top: 1px solid var(--glass-border);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Empty state */
.command-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted);
}

/* ============================================================================
   Toast Notifications
   ============================================================================ */

.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-primary);
  pointer-events: auto;
  animation: toast-in 0.3s var(--transition-spring);
  contain: layout style;
}

.toast.exiting {
  animation: toast-out 0.2s ease-in forwards;
}

/* TRANSIENT replacement: smooth fade-left when new toast replaces old */
.toast.replacing {
  animation: toast-replace 0.2s ease-out forwards;
}

/* IMPORTANT push-out: slide down when evicted by same/higher priority */
.toast.pushed-out {
  animation: toast-push-out 0.25s ease-in forwards;
}

/* Duplicate refresh: brief pulse to show timer was reset */
.toast.refreshed {
  animation: toast-refresh 0.3s ease-out;
}

@keyframes toast-replace {
  0% {
    opacity: 1;
    transform: translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-30px);
  }
}

@keyframes toast-push-out {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(20px);
  }
}

@keyframes toast-refresh {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

/* CRITICAL toast styling — demands attention for playout/data failures */
.toast.critical {
  border-left-width: 4px;
  border-color: var(--accent-red);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(248, 113, 113, 0.3);
}

.toast.critical .toast-icon {
  color: var(--accent-red);
  animation: critical-pulse 1.5s ease-in-out infinite;
}

.toast.critical .toast-dismiss {
  color: var(--accent-red);
}

.toast.critical .toast-dismiss:hover {
  background: var(--accent-red);
  color: var(--bg-primary);
}

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

/* Focus visibility for keyboard users */
.toast-dismiss:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

.toast-icon {
  font-size: 1rem;
}

.toast-message {
  flex: 1;
}

.toast-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  font-size: 1rem;
  line-height: 1;
}

.toast-dismiss:hover {
  color: var(--text-primary);
}

/* Toast variants */
.toast.success {
  border-color: var(--accent-green);
}

.toast.success .toast-icon {
  color: var(--accent-green);
}

.toast.error {
  border-color: var(--accent-red);
}

.toast.error .toast-icon {
  color: var(--accent-red);
}

.toast.warning {
  border-color: var(--accent-orange);
}

.toast.warning .toast-icon {
  color: var(--accent-orange);
}

.toast.info {
  border-color: var(--accent-edit);
}

.toast.info .toast-icon {
  color: var(--accent-edit);
}

@keyframes toast-in {
  0% {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toast-out {
  0% {
    opacity: 1;
    transform: translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ============================================================================
   File Drop Overlay
   ============================================================================ */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  animation: fade-in 0.2s ease-out;
}

.drop-content {
  text-align: center;
  animation: drop-bounce 0.3s var(--transition-spring);
}

.drop-icon {
  font-size: 4rem;
  margin-bottom: var(--space-4);
  animation: float 2s ease-in-out infinite;
}

.drop-text {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.drop-hint {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent-cyan);
}

@keyframes drop-bounce {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ============================================================================
   Modal Dialog (Recovery, etc.)
   ============================================================================ */

.modal-dialog {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  animation: fade-in 0.2s ease-out;
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 440px;
  padding: var(--space-8);
  text-align: center;
  animation: slide-up 0.3s ease-out;
}

.modal-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: var(--space-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.modal-icon {
  font-size: 1.5rem;
}

.modal-message {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-3);
}

.modal-message strong {
  color: var(--accent-green);
  font-family: var(--font-mono);
}

.modal-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-6);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

/* ============================================================================
   Rundown Settings Dialog
   ============================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease-out;
}

.modal-overlay.hidden {
  display: none;
}

.rundown-settings-dialog {
  display: flex;
  flex-direction: column;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: slide-up 0.3s ease-out;
  overflow: hidden;
}

.rundown-settings-dialog .modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--glass-border);
}

.rundown-settings-dialog .modal-header h2 {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-edit);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.rundown-settings-dialog .btn-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.rundown-settings-dialog .btn-close:hover {
  background: var(--bg-hover);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}

.rundown-settings-dialog .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.rundown-settings-dialog .settings-section {
  margin-bottom: var(--space-6);
}

.rundown-settings-dialog .settings-section:last-child {
  margin-bottom: 0;
}

.rundown-settings-dialog .settings-section h3 {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 var(--space-4) 0;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--glass-border);
}

.rundown-settings-dialog .form-group {
  margin-bottom: var(--space-4);
}

.rundown-settings-dialog .form-group:last-child {
  margin-bottom: 0;
}

.rundown-settings-dialog .form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.rundown-settings-dialog .form-input,
.rundown-settings-dialog .form-select {
  width: 100%;
  padding: var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.rundown-settings-dialog .form-input:focus,
.rundown-settings-dialog .form-select:focus {
  outline: none;
  border-color: var(--accent-edit);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-edit) 15%, transparent);
}

.rundown-settings-dialog .form-input::placeholder {
  color: var(--text-muted);
}

.rundown-settings-dialog textarea.form-input {
  resize: vertical;
  min-height: 60px;
}

.rundown-settings-dialog .form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.rundown-settings-dialog .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.rundown-settings-dialog .checkbox-group {
  margin-bottom: var(--space-3);
}

.rundown-settings-dialog .checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.rundown-settings-dialog .checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-edit);
}

.rundown-settings-dialog .modal-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
}

.rundown-settings-dialog .btn {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.rundown-settings-dialog .btn-secondary {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.rundown-settings-dialog .btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}

.rundown-settings-dialog .btn-primary {
  background: var(--accent-edit);
  border: 1px solid var(--accent-edit);
  color: var(--bg-primary);
}

.rundown-settings-dialog .btn-primary:hover {
  background: color-mix(in srgb, var(--accent-edit) 85%, black);
  border-color: color-mix(in srgb, var(--accent-edit) 85%, black);
}

/* ============================================================================
   Error Banner
   ============================================================================ */

.error-banner {
  background: var(--accent-red);
  color: white;
  border-radius: var(--radius-md);
  overflow: hidden;
  animation: error-slide-in 0.3s ease-out;
}

.error-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}

.error-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.error-message {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
}

.error-dismiss {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 var(--space-1);
  opacity: 0.7;
  transition: var(--transition-fast);
}

.error-dismiss:hover {
  opacity: 1;
}

.error-details {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: var(--space-3) var(--space-4);
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 140px;
  overflow-y: auto;
}

@keyframes error-slide-in {
  0% { opacity: 0; transform: translateY(-10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   Animations
   ============================================================================ */

@keyframes fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes slide-up {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   Scrollbar
   ============================================================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ============================================================================
   Reduced Motion
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 768px) {
  .app-container {
    padding: var(--space-3);
    gap: var(--space-3);
  }

  .countdown-time {
    font-size: 4rem;
  }

  .countdown-tenths {
    font-size: 1.5rem;
  }

  .segment-slug {
    font-size: 1.25rem;
  }

  .segment-info {
    flex-direction: column;
    gap: var(--space-2);
  }


  .key-hints {
    gap: var(--space-3);
  }

  .key-hint span {
    display: none;
  }

  .toast-container {
    bottom: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
  }

  .toast {
    width: 100%;
  }
}

/* ============================================================================
   GUI Mode Toggle
   ============================================================================ */

.mode-toggle {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
}

.mode-btn:hover {
  color: var(--text-secondary);
  background: var(--glass-bg);
}

.mode-btn.active {
  background: var(--gradient-accent);
  color: var(--bg-primary);
  font-weight: 600;
}

.mode-btn:focus-visible {
  outline: 2px solid var(--accent-edit);
  outline-offset: 1px;
}

.mode-icon {
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .mode-label {
    display: none;
  }
}

/* ============================================================================
   GUI Mode Visibility Rules
   ============================================================================ */

/* Viewer mode: hide table controls and countdown banner (shown in right panel instead) */
[data-gui-mode="viewer"] .btn-take,
[data-gui-mode="viewer"] .btn-delete,
[data-gui-mode="viewer"] .col-drag,
[data-gui-mode="viewer"] .col-actions,
[data-gui-mode="viewer"] .rundown-add-row,
[data-gui-mode="viewer"] .countdown-banner {
  display: none !important;
}

/* Player mode: hide editor controls */
[data-gui-mode="player"] .btn-delete,
[data-gui-mode="player"] .col-drag,
[data-gui-mode="player"] .rundown-add-row {
  display: none !important;
}

/* Editor mode: show everything, editable cells */
[data-gui-mode="editor"] td[data-editable]:hover {
  cursor: text;
  background: var(--glass-bg-hover);
}

[data-gui-mode="editor"] td[data-editable]::after {
  content: '✎';
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

[data-gui-mode="editor"] td[data-editable]:hover::after {
  opacity: 1;
}

/* ============================================================================
   Drag Handle Column
   ============================================================================ */

.col-drag {
  width: 32px;
  text-align: center;
  cursor: grab;
}

.col-drag:active {
  cursor: grabbing;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-dim);
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.drag-handle:hover {
  color: var(--text-secondary);
  background: var(--glass-bg);
}

/* Drag-in-progress state */
.rundown-table tbody tr.dragging {
  opacity: 0.5;
  background: var(--bg-hover);
}

.rundown-table tbody tr.drag-over {
  border-top: 2px solid var(--accent-edit);
}

/* ============================================================================
   Inline Editing
   ============================================================================ */

td[data-editable] {
  position: relative;
}

td.editing {
  padding: 0 !important;
}

.inline-edit-input {
  width: 100%;
  height: 100%;
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-tertiary);
  border: 2px solid var(--accent-edit);
  border-radius: 0;
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
}

.inline-edit-input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-edit) 20%, transparent);
}

.inline-edit-input::placeholder {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-style: italic;
}

/* Type dropdown in edit mode */
.inline-edit-select {
  width: 100%;
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-tertiary);
  border: 2px solid var(--accent-edit);
  border-radius: 0;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

/* Type dropdown option colours — see docs/SEGMENT-TYPES.md */
.inline-edit-select option[value="ACT"] { background: var(--type-act); color: #fff; }
.inline-edit-select option[value="CAM"] { background: var(--type-cam); color: #fff; }
.inline-edit-select option[value="LIVE"] { background: var(--type-live); color: #fff; }
.inline-edit-select option[value="IV"] { background: var(--type-iv); color: #fff; }
.inline-edit-select option[value="VT"] { background: var(--type-vt); color: #000; }
.inline-edit-select option[value="GFX"] { background: var(--type-gfx); color: #fff; }
.inline-edit-select option[value="STING"] { background: var(--type-sting); color: #000; }
.inline-edit-select option[value="BUMP"] { background: var(--type-bump); color: #000; }
.inline-edit-select option[value="BREAK"] { background: var(--type-break); color: #fff; }
.inline-edit-select option[value="GAME"] { background: var(--type-game); color: #000; }
.inline-edit-select option[value="MISC"] { background: var(--type-misc); color: #fff; }

/* Inline Type Dropdown - custom dropdown with coloured badges for segment types */
.inline-type-dropdown {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;
}

.inline-type-menu {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: var(--space-1);
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  min-width: 180px;
}

.inline-type-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1);
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.inline-type-option:hover {
  background: var(--glass-bg-hover);
}

.inline-type-option:focus {
  outline: none;
  border-color: var(--accent-edit);
}

.inline-type-option.selected {
  border-color: var(--accent-edit);
  background: var(--glass-bg-hover);
}

.inline-type-option .type-badge {
  font-size: 0.625rem;
  padding: 2px 6px;
  min-width: auto;
}

/* ============================================================================
   Delete Button
   ============================================================================ */

.btn-delete {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  cursor: pointer;
  transition: var(--transition-base);
  margin-right: var(--space-2);
}

.btn-delete:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
  background: rgba(255, 59, 59, 0.1);
}

.btn-delete.confirm {
  background: var(--accent-red);
  color: white;
  border-color: var(--accent-red);
  animation: pulse-delete 0.5s ease-in-out infinite;
}

@keyframes pulse-delete {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ============================================================================
   Add Segment Row
   ============================================================================ */

.rundown-add-row {
  background: var(--bg-secondary);
  border-top: 1px dashed var(--glass-border);
}

.rundown-add-row td {
  padding: var(--space-2) var(--space-4);
  text-align: center;
}

.btn-add-segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  cursor: pointer;
  transition: var(--transition-base);
}

.btn-add-segment:hover {
  color: var(--accent-edit);
  border-color: var(--accent-edit);
  background: color-mix(in srgb, var(--accent-edit) 10%, transparent);
}

.btn-add-segment:focus-visible {
  outline: 2px solid var(--accent-edit);
  outline-offset: 2px;
}

.btn-add-segment .plus-icon {
  font-size: 1rem;
  margin-right: 0.25em;
}

/* ============================================================================
   Print
   ============================================================================ */

@media print {
  body {
    background: white;
    color: black;
  }

  .header,
  .footer,
  .controls-panel,
  .command-palette,
  .toast-container,
  .drop-overlay,
  .modal-dialog,
  .error-banner {
    display: none !important;
  }

  .countdown-banner {
    border: 2px solid black;
    page-break-inside: avoid;
  }

  .countdown-time {
    color: black !important;
    -webkit-text-fill-color: black !important;
    background: none !important;
  }
}


/* ============================================================================
   Playout Integration
   ============================================================================ */

/* --- Backdrop --- */
.media-picker-backdrop,
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn var(--transition-fast) ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Media Picker --- */
.media-picker {
  width: min(700px, 90vw);
  max-height: 80vh;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp var(--transition-base) ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.media-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
}

.media-picker-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.media-picker-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.media-picker-close:hover {
  color: var(--text-primary);
  background: var(--glass-bg-hover);
}

.media-picker-search {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--glass-border);
}

.media-search-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.media-search-input:focus {
  border-color: var(--accent-edit);
}

.media-search-input::placeholder {
  color: var(--text-muted);
}

.media-source-filter {
  width: 140px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-2);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.media-source-filter:focus {
  border-color: var(--accent-edit);
}

.media-refresh-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.media-refresh-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.media-picker-content {
  display: flex;
  flex: 1;
  min-height: 0;
}

.media-picker-list {
  flex: 1;
  overflow-y: auto;
  border-right: 1px solid var(--glass-border);
  outline: none;
}

.media-picker-list:focus {
  outline: none;
}

.media-item {
  display: grid;
  grid-template-columns: 28px 1fr 60px 90px;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background var(--transition-fast);
}

.media-item:hover {
  background: var(--glass-bg-hover);
}

.media-item.selected {
  background: color-mix(in srgb, var(--accent-edit) 15%, transparent);
  border-left: 3px solid var(--accent-cyan);
  padding-left: calc(var(--space-3) - 3px);
}

.media-icon {
  font-size: 1rem;
  text-align: center;
}

.media-name {
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-duration {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-cyan);
  text-align: right;
}

.media-source {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-item-more {
  padding: var(--space-3);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

.media-picker-loading,
.media-picker-empty,
.media-picker-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--text-muted);
  text-align: center;
  gap: var(--space-3);
}

.media-picker-error {
  color: var(--accent-red);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.media-picker-preview {
  width: 200px;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.preview-thumbnail {
  aspect-ratio: 16 / 9;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
}

.preview-icon {
  font-size: 2rem;
  opacity: 0.5;
}

.preview-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.preview-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

.preview-duration {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.preview-source {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.preview-path {
  font-size: 0.7rem;
  color: var(--text-muted);
  word-break: break-all;
  max-height: 40px;
  overflow: hidden;
}

.media-picker-options {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--glass-border);
}

.media-picker-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.media-picker-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-edit);
}

.media-picker-footer {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--glass-border);
  justify-content: flex-end;
}

.media-picker-cancel,
.media-picker-confirm {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.media-picker-cancel {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.media-picker-cancel:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.media-picker-confirm {
  background: var(--accent-edit);
  border: none;
  color: var(--bg-primary);
}

.media-picker-confirm:hover:not(:disabled) {
  background: var(--accent-green);
}

.media-picker-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Audio Library Picker --- */
.audio-library-picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn var(--transition-fast) ease-out;
}

.audio-library-picker {
  width: min(800px, 90vw);
  max-height: 80vh;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp var(--transition-base) ease-out;
}

.audio-library-picker .dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
}

.audio-library-picker .dialog-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.audio-library-picker .dialog-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.audio-library-picker .dialog-close:hover {
  color: var(--text-primary);
  background: var(--glass-bg-hover);
}

.audio-library-search {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--glass-border);
  align-items: center;
}

.audio-library-search .search-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.audio-library-search .search-input:focus {
  border-color: var(--accent-edit);
}

.audio-library-search .search-input::placeholder {
  color: var(--text-muted);
}

.audio-library-search .song-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.audio-library-content {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.audio-library-list {
  width: 50%;
  overflow-y: auto;
  border-right: 1px solid var(--glass-border);
  outline: none;
}

.audio-library-list .list-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: var(--space-4);
  text-align: center;
}

.song-item {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--glass-border);
  transition: background var(--transition-fast);
}

.song-item .song-cache-status {
  flex-shrink: 0;
  width: 1.2em;
  text-align: center;
  font-size: 0.9em;
}

.song-item .song-cache-status.cached {
  color: var(--accent-green, #4ade80);
}

.song-item .song-cache-status.cloud {
  color: var(--text-muted);
}

.song-item .song-cache-status.missing {
  color: var(--accent-red, #f87171);
}

.song-item .song-cache-status.offline {
  color: var(--accent-orange, #fb923c);
}

.song-item .song-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.song-item:hover {
  background: var(--bg-tertiary);
}

.song-item.selected {
  background: color-mix(in srgb, var(--accent-edit) 10%, transparent);
  border-left: 3px solid var(--accent-edit);
  padding-left: calc(var(--space-4) - 3px);
}

.song-item .song-title {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-item .song-meta {
  font-size: 0.8em;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.audio-library-preview {
  width: 50%;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow-y: auto;
}

.audio-library-preview .preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.audio-library-preview .preview-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.audio-library-preview .preview-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.audio-library-preview .preview-artist {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: calc(var(--space-2) * -1);
}

.audio-library-preview .preview-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.audio-library-preview .meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.audio-library-preview .meta-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.audio-library-preview .meta-value {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.audio-library-preview .preview-audio {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.audio-library-preview .play-pause {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-edit);
  border: none;
  color: var(--bg-primary);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.audio-library-preview .play-pause:hover {
  background: var(--accent-edit-bright, #00e5ff);
  transform: scale(1.05);
}

.audio-library-preview .audio-progress {
  flex: 1;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
}

.audio-library-preview .progress-bar {
  height: 100%;
  background: var(--accent-cyan);
  width: 0%;
  transition: width 0.1s linear;
}

.audio-library-preview .current-time {
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 40px;
}

.audio-library-preview .preview-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.audio-library-picker .dialog-footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--glass-border);
}

.audio-library-picker .btn-import {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.audio-library-picker .btn-import:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.audio-library-picker .footer-spacer {
  flex: 1;
}

.audio-library-picker .dialog-cancel,
.audio-library-picker .dialog-confirm {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.audio-library-picker .dialog-cancel {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.audio-library-picker .dialog-cancel:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.audio-library-picker .dialog-confirm {
  background: color-mix(in srgb, var(--accent-edit) 20%, transparent);
  border: 1px solid var(--accent-edit);
  color: var(--accent-edit);
}

.audio-library-picker .dialog-confirm:hover:not(:disabled) {
  background: var(--accent-edit);
  color: var(--bg-primary);
}

.audio-library-picker .dialog-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Timeline Copy Picker --- */
.timeline-copy-modal .modal-dialog,
.timeline-copy-dialog {
  width: min(480px, 90vw);
  max-height: 70vh;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp var(--transition-base) ease-out;
}

.timeline-copy-dialog .modal-body {
  padding: var(--space-4);
  overflow-y: auto;
  flex: 1;
}

.timeline-copy-hint {
  margin: 0 0 var(--space-4);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.timeline-copy-hint strong {
  color: var(--text-primary);
}

.timeline-copy-empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
}

.timeline-copy-empty p {
  margin: 0;
}

.timeline-copy-empty .hint {
  font-size: 0.85rem;
  margin-top: var(--space-2);
  opacity: 0.7;
}

.timeline-copy-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.timeline-copy-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.timeline-copy-item:hover {
  border-color: var(--accent-edit);
  background: var(--glass-bg-hover);
}

.timeline-copy-item:focus {
  outline: none;
  border-color: var(--accent-edit);
  box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.2);
}

.timeline-copy-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.timeline-copy-slug {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.timeline-copy-type {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.timeline-copy-item-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.timeline-copy-song {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-copy-counts {
  flex-shrink: 0;
  color: var(--text-secondary);
}

.timeline-copy-warning,
.timeline-copy-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  margin-top: var(--space-1);
}

.timeline-copy-warning {
  background: rgba(255, 193, 7, 0.1);
  color: var(--text-warning);
}

.timeline-copy-info {
  background: rgba(0, 212, 170, 0.1);
  color: var(--text-secondary);
}

.warning-icon,
.info-icon {
  font-size: 0.9rem;
}

/* Copy Timeline Button in Properties Panel */
.btn-copy-timeline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: var(--space-2);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.btn-copy-timeline:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent-edit);
  color: var(--text-primary);
}

.btn-copy-timeline.hidden {
  display: none;
}

/* --- Playout Source Dialog --- */

/* Anchor dialog to top to prevent jumping when field count changes */
.dialog-backdrop:has(.playout-source-dialog) {
  align-items: flex-start;
  padding-top: 10vh;
}

.playout-source-dialog {
  width: min(500px, 90vw);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideUp var(--transition-base) ease-out;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
}

.dialog-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dialog-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.dialog-close:hover {
  color: var(--text-primary);
  background: var(--glass-bg-hover);
}

.dialog-form {
  padding: var(--space-4) var(--space-5);
}

.source-type-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.source-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-2);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.source-type-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.source-type-btn.active {
  background: rgba(var(--source-colour-rgb, 0, 212, 255), 0.15);
  border-color: var(--source-colour, var(--accent-edit));
  color: var(--source-colour, var(--accent-edit));
}

.source-type-selector .source-type-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--source-colour, var(--accent-cyan));
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.source-type-selector .source-type-icon svg {
  width: 100%;
  height: 100%;
  fill: var(--bg-primary);
}

.source-type-name {
  font-size: 0.75rem;
  font-weight: 500;
}

.form-fields {
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-group-checkbox {
  flex-direction: row;
  align-items: center;
}

.form-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-label .required {
  color: var(--accent-red);
  margin-left: 2px;
}

.form-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent-edit);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.form-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-edit);
}

.form-error {
  background: rgba(255, 59, 59, 0.1);
  border: 1px solid var(--accent-red);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--accent-red);
  font-size: 0.85rem;
  margin-bottom: var(--space-2);
}

.test-connection {
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--glass-border);
}

.test-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.test-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.test-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.test-icon {
  font-size: 1rem;
}

.test-status {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.test-status.testing {
  color: var(--accent-cyan);
}

.test-status.success {
  color: var(--accent-green);
}

.test-status.error {
  color: var(--accent-red);
}

.dialog-footer {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--glass-border);
}

.dialog-footer-spacer {
  flex: 1;
}

.dialog-delete {
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px solid var(--accent-red);
  border-radius: var(--radius-sm);
  color: var(--accent-red);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dialog-delete:hover {
  background: rgba(255, 59, 59, 0.15);
}

.dialog-cancel,
.dialog-save,
.dialog-close-btn,
.dialog-add {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dialog-cancel,
.dialog-close-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.dialog-cancel:hover,
.dialog-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dialog-save {
  background: var(--accent-edit);
  border: none;
  color: var(--bg-primary);
}

.dialog-save:hover {
  background: var(--accent-green);
}

.dialog-add {
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-edit);
  color: var(--accent-edit);
}

.dialog-add:hover {
  background: color-mix(in srgb, var(--accent-edit) 15%, transparent);
}

/* --- Source List Dialog --- */
.playout-source-list-dialog {
  width: min(500px, 90vw);
  max-height: 80vh;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideUp var(--transition-base) ease-out;
}

.source-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.source-list-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted);
}

.source-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--glass-border);
  transition: background var(--transition-fast);
}

.source-list-item:hover {
  background: var(--glass-bg-hover);
}

.source-list-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.source-list-icon svg {
  width: 100%;
  height: 100%;
  fill: var(--text-secondary);
}

.source-list-info {
  flex: 1;
  min-width: 0;
}

.source-list-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
}

.source-list-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.source-list-status {
  font-size: 0.75rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-weight: 500;
}

.source-list-status.connected {
  background: rgba(0, 255, 136, 0.15);
  color: var(--accent-green);
}

.source-list-status.disconnected {
  background: rgba(255, 149, 0, 0.15);
  color: var(--accent-orange);
}

.source-list-status.disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.source-list-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.source-list-edit:hover {
  color: var(--text-primary);
  background: var(--glass-bg-hover);
}

/* --- Playout Status Indicators --- */
.playout-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 0.8rem;
  margin-left: var(--space-2);
  border-radius: var(--radius-sm);
  opacity: 0.8;
}

.playout-status.state-playing {
  color: var(--accent-green);
  animation: pulse 1s ease-in-out infinite;
}

.playout-status.state-paused {
  color: var(--accent-orange);
}

.playout-status.state-stopped {
  color: var(--text-muted);
}

.playout-status.state-loading {
  color: var(--accent-cyan);
  animation: spin 1s linear infinite;
}

.playout-status.state-error {
  color: var(--accent-red);
}

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

/* --- Segment Playout Badge --- */
.segment-playout-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  background: rgba(255, 107, 157, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  color: var(--type-vt);
  margin-left: var(--space-2);
}

.segment-playout-badge .playout-source-name {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================================
   Script Analyzer Settings Modal
   ============================================================================ */

.script-settings-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.script-settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  animation: fadeIn var(--transition-fast) ease-out;
}

.script-settings-dialog {
  position: relative;
  width: min(450px, 90vw);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideUp var(--transition-base) ease-out;
}

.script-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
}

.script-settings-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.script-settings-header .btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.script-settings-header .btn-close:hover {
  color: var(--text-primary);
  background: var(--glass-bg-hover);
}

.script-settings-content {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.settings-group label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.settings-select,
.settings-input {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  outline: none;
  transition: var(--transition-base);
}

.settings-select:hover,
.settings-input:hover {
  border-color: var(--glass-border-hover);
}

.settings-select:focus,
.settings-input:focus {
  border-color: var(--accent-edit);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-edit) 15%, transparent);
}

.settings-input[type="number"] {
  width: 120px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.settings-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.script-settings-footer {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--glass-border);
  justify-content: flex-end;
}

.script-settings-footer .btn-cancel,
.script-settings-footer .btn-save {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.script-settings-footer .btn-cancel {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.script-settings-footer .btn-cancel:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.script-settings-footer .btn-save {
  background: var(--accent-edit);
  border: none;
  color: white;
}

.script-settings-footer .btn-save:hover {
  background: var(--accent-pink);
}

/* ============================================================================
   Version History Panel
   ============================================================================ */

.version-history-panel {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  justify-content: flex-end;
}

.version-history-panel.hidden {
  display: none;
}

.version-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  animation: fadeIn var(--transition-fast) ease-out;
}

.version-panel-content {
  position: relative;
  width: min(400px, 90vw);
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  animation: slideInRight var(--transition-base) ease-out;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.version-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.version-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.version-panel-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.branch-selector {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  outline: none;
}

.branch-selector:focus {
  border-color: var(--accent-edit);
}

.version-panel-controls button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.version-panel-controls button:hover {
  color: var(--text-primary);
  background: var(--glass-bg-hover);
}

.version-panel-loading,
.version-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8);
  color: var(--text-muted);
  text-align: center;
}

.version-panel-loading.hidden,
.version-panel-empty.hidden {
  display: none;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-icon {
  font-size: 2rem;
  opacity: 0.5;
}

.empty-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.empty-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.version-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.version-list.hidden {
  display: none;
}

.version-item {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.version-item:hover {
  background: var(--glass-bg);
}

.version-item.selected {
  background: var(--glass-bg-hover);
  border-left: 3px solid var(--accent-edit);
}

.version-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.version-number {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

.version-time {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.version-actions {
  margin-left: auto;
  display: flex;
  gap: var(--space-1);
}

.version-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.version-actions button:hover {
  color: var(--text-primary);
  background: var(--glass-bg-hover);
}

.version-message {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.version-meta {
  display: flex;
  gap: var(--space-3);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.version-changes {
  font-family: var(--font-mono);
}

.version-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

.version-tag {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent-edit) 20%, transparent);
  color: var(--accent-edit);
}

.version-panel-actions {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.btn-create-version {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-create-version:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

/* ============================================================================
   Version Diff View
   ============================================================================ */

.version-diff-view {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 10);
  display: flex;
  align-items: center;
  justify-content: center;
}

.version-diff-view.hidden {
  display: none;
}

.diff-view-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  animation: fadeIn var(--transition-fast) ease-out;
}

.diff-view-modal {
  position: relative;
  width: min(900px, 95vw);
  max-height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideUp var(--transition-base) ease-out;
}

.diff-view-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.diff-view-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.diff-view-version-labels {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.version-label {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.version-label.version-old {
  background: rgba(255, 59, 59, 0.15);
  color: var(--accent-red);
}

.version-label.version-new {
  background: rgba(0, 255, 136, 0.15);
  color: var(--accent-green);
}

.version-arrow {
  color: var(--text-dim);
}

.diff-view-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.view-mode-toggle {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.btn-mode {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: var(--space-1) var(--space-2);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-mode:hover {
  color: var(--text-secondary);
}

.btn-mode.active {
  background: var(--accent-edit);
  color: white;
}

.diff-view-controls .btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  border-radius: var(--radius-sm);
}

.diff-view-controls .btn-close:hover {
  color: var(--text-primary);
  background: var(--glass-bg-hover);
}

.diff-view-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8);
  color: var(--text-muted);
}

.diff-view-loading.hidden {
  display: none;
}

.diff-view-summary {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.summary-added {
  color: var(--accent-green);
}

.summary-removed {
  color: var(--accent-red);
}

.summary-modified {
  color: var(--accent-orange);
}

.diff-view-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) 0;
}

/* Inline diff */
.diff-inline .diff-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--glass-border);
}

.diff-indicator {
  width: 20px;
  text-align: center;
  font-weight: 600;
}

.diff-added {
  background: rgba(0, 255, 136, 0.1);
}

.diff-added .diff-indicator {
  color: var(--accent-green);
}

.diff-removed {
  background: rgba(255, 59, 59, 0.1);
}

.diff-removed .diff-indicator {
  color: var(--accent-red);
}

.diff-modified {
  background: rgba(255, 149, 0, 0.1);
}

.diff-modified .diff-indicator {
  color: var(--accent-orange);
}

.diff-unchanged {
  opacity: 0.6;
}

.diff-segment-id {
  width: 60px;
  color: var(--text-dim);
}

.diff-segment-slug {
  flex: 1;
  color: var(--text-primary);
}

.diff-segment-type {
  width: 80px;
  color: var(--text-secondary);
}

.diff-segment-duration {
  width: 60px;
  text-align: right;
  color: var(--text-secondary);
}

.diff-changes {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.diff-change {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.75rem;
}

.change-field {
  color: var(--text-dim);
}

.change-old {
  color: var(--accent-red);
  text-decoration: line-through;
}

.change-arrow {
  color: var(--text-dim);
}

.change-new {
  color: var(--accent-green);
}

/* Side-by-side diff */
.diff-side-by-side {
  display: flex;
  gap: var(--space-2);
  padding: 0 var(--space-4);
}

.diff-column {
  flex: 1;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.diff-column-header {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--glass-border);
}

.diff-column .diff-row {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border-bottom: 1px solid var(--glass-border);
}

.diff-error {
  padding: var(--space-8);
  text-align: center;
  color: var(--accent-red);
}

.diff-view-footer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.btn-restore-older {
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px solid var(--accent-orange);
  border-radius: var(--radius-sm);
  color: var(--accent-orange);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-restore-older:hover {
  background: rgba(255, 149, 0, 0.15);
}

.footer-spacer {
  flex: 1;
}

.btn-close-diff {
  padding: var(--space-2) var(--space-4);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-close-diff:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================================================
   Segment Properties Panel (Editor Mode)
   ============================================================================ */

/* Hide segment properties by default, show only in editor mode */
#segment-properties-section {
  display: none;
}

[data-gui-mode="editor"] #segment-properties-section {
  display: block;
}

/* Selected row styling */
.segment-row.selected {
  background: var(--glass-bg-hover);
  outline: 2px solid var(--accent-edit);
  outline-offset: -2px;
}

.rundown-table tbody tr.selected:not(.current) {
  background: color-mix(in srgb, var(--accent-edit) 15%, transparent);
}

/* Segment Properties Panel */
.segment-properties-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.properties-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
  text-align: center;
}

.properties-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}

.properties-empty-icon svg {
  width: 48px;
  height: 48px;
}

.properties-empty-text {
  font-size: 0.85rem;
}

.properties-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.property-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.property-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.property-input,
.property-select {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  outline: none;
  transition: var(--transition-base);
  width: 100%;
}

.property-input:hover,
.property-select:hover {
  border-color: var(--glass-border-hover);
}

.property-input:focus,
.property-select:focus {
  border-color: var(--accent-edit);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-edit) 15%, transparent);
}

/* Custom Type Dropdown - shows coloured badges */
.type-dropdown {
  position: relative;
  width: 100%;
}

.type-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-base);
}

.type-dropdown-trigger:hover {
  border-color: var(--glass-border-hover);
}

.type-dropdown.open .type-dropdown-trigger {
  border-color: var(--accent-edit);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-edit) 15%, transparent);
}

.type-dropdown-chevron {
  font-size: 0.625rem;
  color: var(--text-muted);
  transition: transform var(--transition-base);
}

.type-dropdown.open .type-dropdown-chevron {
  transform: rotate(180deg);
}

.type-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: var(--space-1);
  max-height: 280px;
  overflow-y: auto;
}

.type-dropdown-option {
  display: block;
  width: 100%;
  padding: var(--space-2);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.type-dropdown-option:hover {
  background: var(--glass-bg-hover);
}

.type-dropdown-option .type-badge {
  display: inline-block;
  min-width: 70px;
  padding: var(--space-1) var(--space-2);
  text-align: center;
}

.property-duration {
  width: 80px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Toggle buttons (Start Mode, Flex Type) */
.property-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.toggle-btn {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  padding: var(--space-1) var(--space-2);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-base);
}

.toggle-btn:hover {
  color: var(--text-secondary);
  background: var(--glass-bg);
}

.toggle-btn.active {
  background: var(--accent-edit);
  color: white;
}

/* Timeline toggle button (only visible for MUSIC segments) */
.toggle-btn-timeline {
  /* Same as other toggle buttons by default */
}

.toggle-btn-timeline.active {
  background: var(--accent-edit);
  color: var(--bg-primary);
}

.toggle-btn-timeline.hidden {
  display: none;
}

/* Readonly input state (e.g., duration in TIMELINE mode) */
.property-input.readonly {
  background: var(--bg-tertiary);
  color: var(--text-dim);
  cursor: not-allowed;
  border-color: transparent;
}

.readonly-group .property-label {
  color: var(--text-dim);
}

/* Timeline mode hint styling */
.property-hint.hint-timeline {
  color: var(--accent-cyan);
  font-weight: 500;
}

/* Checkbox property */
.property-checkbox {
  flex-direction: row;
  align-items: center;
}

.property-checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.property-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-edit);
}

/* Property hint */
.property-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: var(--space-1);
}

/* Playout info */
.playout-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.playout-source-name {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-pink);
  font-weight: 500;
}

.playout-file-name {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: break-all;
}

/* Music config (MUSIC segments) */
.music-config {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.btn-select-song {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-base);
}

.btn-select-song:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-edit);
}

.music-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-cyan);
}

.music-song-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.music-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Delete segment button */
.btn-delete-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: var(--transition-base);
  margin-top: var(--space-2);
}

.btn-delete-segment:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
  background: rgba(255, 59, 59, 0.1);
}

.btn-delete-segment.confirm {
  background: var(--accent-red);
  color: white;
  border-color: var(--accent-red);
  animation: pulse-delete 0.5s ease-in-out infinite;
}

/* Script textarea and duration estimation */
.property-textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  outline: none;
  transition: var(--transition-base);
  width: 100%;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.property-textarea:hover {
  border-color: var(--glass-border-hover);
}

.property-textarea:focus {
  border-color: var(--accent-edit);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-edit) 15%, transparent);
}

.property-textarea::placeholder,
.property-input::placeholder {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-style: italic;
}

/* Duration estimate row */
.duration-estimate-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}

.estimate-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.estimate-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 50px;
}

/* Confidence badge */
.confidence-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confidence-badge[data-level="high"] {
  background: rgba(34, 197, 94, 0.2);
  color: var(--accent-green);
}

.confidence-badge[data-level="medium"] {
  background: rgba(234, 179, 8, 0.2);
  color: var(--accent-yellow);
}

.confidence-badge[data-level="low"] {
  background: rgba(255, 59, 59, 0.2);
  color: var(--accent-red);
}

.confidence-badge[data-level="none"] {
  display: none;
}

/* Apply estimate button */
.btn-apply-estimate {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--accent-edit);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  transition: var(--transition-base);
}

.btn-apply-estimate:hover:not(:disabled) {
  background: var(--accent-pink);
}

.btn-apply-estimate:disabled {
  background: var(--bg-tertiary);
  color: var(--text-dim);
  cursor: not-allowed;
}

/* Estimate details */
.estimate-details {
  display: flex;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

.estimate-details.hidden {
  display: none;
}

/* ============================================================================
   Viewer Mode Layout
   ============================================================================ */

/* Hide viewer countdown by default */
#viewer-countdown-section {
  display: none;
}

/* Viewer mode: show large countdown, hide other controls */
[data-gui-mode="viewer"] #viewer-countdown-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 300px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  position: relative; /* Required for absolutely positioned progress bar */
}

[data-gui-mode="viewer"] .control-section:not(#viewer-countdown-section) {
  display: none !important;
}

/* Viewer countdown styling */
.viewer-current-segment {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: var(--space-4);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-countdown-time {
  font-family: var(--font-mono);
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 60px rgba(0, 212, 255, 0.3);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  max-width: 100%;
}

.viewer-next-segment {
  font-family: var(--font-mono);
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 500;
  color: var(--text-muted);
  margin-top: var(--space-6);
  text-align: center;
}

/* Viewer mode: same golden ratio, countdown-focused */
[data-gui-mode="viewer"] .main-content {
  grid-template-columns: 70.7fr 29.3fr;
}

[data-gui-mode="viewer"] .controls-panel {
  padding: clamp(12px, 3cqi, 24px); /* Reduced max to prevent overflow */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* Viewer mode countdown states */
[data-gui-mode="viewer"] .viewer-countdown.ending .viewer-countdown-time {
  background: var(--gradient-warm);
  -webkit-background-clip: text;
  background-clip: text;
  animation: glow-pulse 0.5s ease-in-out infinite;
}

[data-gui-mode="viewer"] .viewer-countdown.over-run .viewer-countdown-time {
  background: var(--accent-orange);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-gui-mode="viewer"] .viewer-countdown.over-run-critical .viewer-countdown-time {
  background: var(--accent-red);
  -webkit-background-clip: text;
  background-clip: text;
  animation: glow-pulse 0.5s ease-in-out infinite;
}

/* Viewer countdown progress bar */
.viewer-countdown-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}

.viewer-countdown-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--gradient-accent);
  transition: width 0.1s linear;
  box-shadow: 0 0 12px var(--accent-cyan);
}

.viewer-countdown.ending .viewer-countdown-progress-bar {
  background: var(--gradient-warm);
  box-shadow: 0 0 12px var(--accent-orange);
}

.viewer-countdown.over-run-warning .viewer-countdown-progress-bar {
  background: var(--accent-orange);
  box-shadow: 0 0 12px var(--accent-orange);
}

.viewer-countdown.over-run-critical .viewer-countdown-progress-bar {
  background: var(--accent-red);
  box-shadow: 0 0 12px var(--accent-red);
}

/* ============================================================================
   Sub-countdown for Hierarchical Groups
   ============================================================================ */

.sub-countdown {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  margin-top: var(--space-2);
}

.sub-countdown-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#sub-countdown-time {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

/* ============================================================================
   Hierarchical Groups
   ============================================================================ */

/* Group row styling */
.segment-row.group {
  font-weight: 600;
  background: var(--bg-elevated);
}

.segment-row.group td:first-child {
  padding-left: var(--space-2);
}

/* Indentation for child rows */
.segment-row[data-depth="1"] td.col-slug {
  padding-left: calc(var(--space-4) + 1.5rem);
}

.segment-row[data-depth="2"] td.col-slug {
  padding-left: calc(var(--space-4) + 3rem);
}

/* Group toggle icon */
.group-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: transform var(--transition-fast), color var(--transition-fast);
  margin-right: var(--space-1);
}

.group-toggle:hover {
  color: var(--text-primary);
}

.group-toggle.collapsed {
  transform: rotate(-90deg);
}

/* Group summary in slug cell */
.group-summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.group-count {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

/* ============================================================================
   Export/Import Dialog
   ============================================================================ */

.export-import-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.export-import-dialog-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.export-import-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s ease;
}

.export-import-dialog-overlay.visible .export-import-dialog {
  transform: scale(1) translateY(0);
}

.export-import-dialog .dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--glass-border);
}

.export-import-dialog .dialog-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.export-import-dialog .dialog-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
}

.export-import-dialog .dialog-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.export-import-dialog .dialog-content {
  padding: var(--space-4);
  flex: 1;
  overflow-y: auto;
}

.export-import-dialog .dialog-footer {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  padding: var(--space-4);
  border-top: 1px solid var(--glass-border);
}

/* Export preview */
.export-preview {
  background: var(--bg-tertiary);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.export-preview .preview-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.export-preview .preview-stats {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Format options */
.export-format-options,
.import-options {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.export-format-options legend,
.import-options legend,
.export-options legend {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 var(--space-2);
}

.radio-option,
.checkbox-option {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.radio-option:hover,
.checkbox-option:hover {
  background: var(--bg-hover);
}

.radio-option input,
.checkbox-option input {
  margin-top: 2px;
  accent-color: var(--accent-edit);
}

.radio-option .option-label {
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.radio-option .option-description {
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: calc(1rem + var(--space-2));
}

.checkbox-option span {
  color: var(--text-primary);
}

/* Export options */
.export-options {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

/* Asset summary */
.asset-summary {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  font-size: 0.9rem;
}

.asset-summary .asset-count {
  color: var(--text-primary);
}

.asset-summary .asset-size {
  color: var(--text-muted);
}

/* Progress bar */
.export-progress,
.import-progress {
  margin-top: var(--space-4);
}

.progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.progress-fill {
  height: 100%;
  background: var(--gradient-accent);
  width: 0;
  transition: width 0.3s ease;
}

.progress-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.progress-status.has-errors {
  color: var(--accent-red);
}

/* Hidden elements */
.export-import-dialog .hidden {
  display: none !important;
}

/* Import dialog specific styles */
.drop-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent-edit);
  background: color-mix(in srgb, var(--accent-edit) 5%, transparent);
}

.drop-zone-content {
  pointer-events: none;
}

.drop-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: var(--space-2);
}

.drop-text {
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.drop-formats {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Import preview */
.import-preview {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.import-preview .preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--glass-border);
}

.import-preview .preview-format {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  background: color-mix(in srgb, var(--accent-edit) 10%, transparent);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.import-preview .preview-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.import-preview .preview-row {
  display: flex;
  gap: var(--space-3);
}

.import-preview .preview-label {
  width: 80px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.import-preview .preview-value {
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* Import warnings */
.import-warnings {
  margin-top: var(--space-3);
}

.import-warnings details {
  background: rgba(255, 149, 0, 0.1);
  border: 1px solid rgba(255, 149, 0, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
}

.import-warnings summary {
  font-size: 0.85rem;
  color: var(--accent-orange);
  cursor: pointer;
}

.import-warnings .warning-list {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-4);
  font-size: 0.8rem;
  color: var(--text-secondary);
  max-height: 120px;
  overflow-y: auto;
}

.import-warnings .warning-list li {
  margin-bottom: var(--space-1);
}

/* Small button variant */
.btn-small {
  padding: 4px 8px;
  font-size: 0.75rem;
}

/* ============================================================================
   Hard-Start Warning Styles
   ============================================================================ */

/* Hard-start warning indicator in Next segment display */
.hard-start-warning {
  color: var(--accent-orange) !important;
  animation: hard-start-pulse 1.5s ease-in-out infinite;
}

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

/* Hard-start countdown in Next segment - urgent (< 30s) */
.hard-start-warning.urgent {
  color: var(--accent-red) !important;
  animation: hard-start-urgent 0.5s ease-in-out infinite;
}

@keyframes hard-start-urgent {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Hard-start armed state — subtle glow when armed */
.timing-icon.start-mode.armed {
  color: var(--accent-green);
  filter: drop-shadow(0 0 3px var(--accent-green));
}

/* ============================================================================
   Version Conflict Dialog Styles
   ============================================================================ */

.conflict-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.conflict-dialog-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.conflict-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.conflict-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border-bottom: 1px solid var(--glass-border);
}

.conflict-dialog-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--accent-orange);
}

.conflict-dialog-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.conflict-dialog-close:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.conflict-dialog-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.conflict-message {
  margin-bottom: var(--space-4);
  line-height: 1.6;
}

.conflict-message p {
  margin: 0 0 var(--space-2);
}

.conflict-message strong {
  color: var(--accent-orange);
}

/* Conflict details (diff summary) */
.conflict-details {
  margin-bottom: var(--space-4);
}

.conflict-details h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.conflict-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.conflict-local,
.conflict-remote {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.conflict-local h4 {
  color: var(--accent-cyan);
  font-size: 0.85rem;
  margin: 0 0 var(--space-2);
}

.conflict-remote h4 {
  color: var(--accent-magenta);
  font-size: 0.85rem;
  margin: 0 0 var(--space-2);
}

.change-list {
  margin: 0;
  padding-left: var(--space-3);
  font-size: 0.8rem;
  color: var(--text-secondary);
  max-height: 150px;
  overflow-y: auto;
}

.change-list li {
  margin-bottom: var(--space-1);
  word-break: break-word;
}

/* Concurrent editors warning */
.concurrent-editors {
  background: rgba(255, 170, 0, 0.1);
  border: 1px solid rgba(255, 170, 0, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}

.concurrent-editors h3 {
  font-size: 0.9rem;
  color: var(--accent-orange);
  margin: 0 0 var(--space-2);
}

.editor-list {
  margin: 0;
  padding-left: var(--space-3);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.editor-list li {
  margin-bottom: var(--space-1);
}

/* Conflict dialog actions */
.conflict-dialog-actions {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-4);
  border-top: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.conflict-dialog-actions .btn {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.conflict-dialog-actions .btn.hidden {
  display: none;
}

.conflict-dialog-actions .btn-merge {
  background: var(--accent-green);
  border: none;
  color: var(--bg-primary);
}

.conflict-dialog-actions .btn-merge:hover {
  filter: brightness(1.1);
}

.conflict-dialog-actions .btn-review {
  background: var(--accent-edit);
  border: none;
  color: var(--bg-primary);
}

.conflict-dialog-actions .btn-review:hover {
  filter: brightness(1.1);
}

.conflict-dialog-actions .btn-overwrite {
  background: var(--accent-orange);
  border: none;
  color: var(--bg-primary);
}

.conflict-dialog-actions .btn-overwrite:hover {
  filter: brightness(1.1);
}

.conflict-dialog-actions .btn-discard {
  background: var(--accent-red);
  border: none;
  color: white;
}

.conflict-dialog-actions .btn-discard:hover {
  filter: brightness(1.1);
}

.conflict-dialog-actions .btn-cancel {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.conflict-dialog-actions .btn-cancel:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ============================================================================
   Playout Config Editor Styles
   ============================================================================ */

.playout-config-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.playout-config-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.playout-config-editor {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.config-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border-bottom: 1px solid var(--glass-border);
}

.config-editor-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.use-rundown-config {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.use-rundown-config input {
  accent-color: var(--accent-edit);
}

.config-editor-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}

.config-editor-close:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.config-editor-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.config-disabled-notice {
  text-align: center;
  padding: var(--space-6);
  color: var(--text-muted);
}

.config-disabled-notice p {
  margin: 0 0 var(--space-2);
}

/* Sources section */
.config-sources,
.config-settings {
  margin-bottom: var(--space-4);
}

.sources-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.sources-header h3,
.config-settings h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-add-source {
  background: var(--accent-edit);
  border: none;
  color: var(--bg-primary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-add-source:hover {
  filter: brightness(1.1);
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.no-sources {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-4);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

/* Source card */
.source-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.source-card.disabled {
  opacity: 0.6;
}

.source-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.source-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--bg-primary);
  flex-shrink: 0;
  overflow: hidden;
}

.source-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.source-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.source-name {
  font-weight: 500;
  color: var(--text-primary);
}

.source-type {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.source-actions {
  display: flex;
  gap: var(--space-1);
}

.source-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.source-actions button:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.source-actions .btn-toggle {
  color: var(--accent-green);
}

.source-card.disabled .source-actions .btn-toggle {
  color: var(--text-muted);
}

.source-details {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--glass-border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.source-details .priority {
  margin-left: auto;
  color: var(--accent-cyan);
}

/* Settings grid */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.settings-grid label:last-child {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.settings-grid select {
  padding: var(--space-2);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

/* Config editor actions */
.config-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4);
  border-top: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.config-editor-actions .btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
}

.config-editor-actions .btn-cancel {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.config-editor-actions .btn-save {
  background: var(--accent-green);
  border: none;
  color: var(--bg-primary);
}

.config-editor-actions .btn-save:hover {
  filter: brightness(1.1);
}

/* Source dialog (add/edit) */
.source-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 10001;
}

.source-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  width: 90%;
  max-width: 400px;
}

.source-dialog h3 {
  margin: 0 0 var(--space-4);
}

.source-dialog .form-group {
  margin-bottom: var(--space-3);
}

.source-dialog label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.source-dialog input,
.source-dialog select {
  width: 100%;
  padding: var(--space-2);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.source-dialog .dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.source-dialog .btn {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.source-dialog .btn-cancel {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.source-dialog .btn-add,
.source-dialog .btn-save {
  background: var(--accent-edit);
  border: none;
  color: var(--bg-primary);
}

/* Source type selector grid */
.source-type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.source-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  min-height: 88px;
  background: var(--bg-tertiary);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.source-type-btn:hover {
  border-color: var(--source-colour, var(--accent-edit));
  background: rgba(255, 255, 255, 0.05);
}

.source-type-btn.selected {
  border-color: var(--source-colour, var(--accent-edit));
  background: rgba(255, 255, 255, 0.08);
}

.source-type-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--source-colour, var(--accent-cyan));
  border-radius: var(--radius-md);
  color: var(--bg-primary);
  overflow: hidden;
}

.source-type-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.source-type-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ============================================================================
   Asset Uploader
   ============================================================================ */

.asset-uploader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.asset-uploader-overlay.hidden {
  display: none;
}

.asset-uploader {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  width: min(700px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.asset-uploader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--glass-border);
}

.asset-uploader-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.asset-uploader-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: var(--space-1);
}

.asset-uploader-close:hover {
  color: var(--text-primary);
}

.asset-uploader-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

/* Drop Zone */
.asset-drop-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  margin-bottom: var(--space-4);
  cursor: pointer;
  transition: var(--transition-base);
}

.asset-drop-zone:hover,
.asset-drop-zone.drag-over {
  border-color: var(--accent-edit);
  background: color-mix(in srgb, var(--accent-edit) 5%, transparent);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.drop-zone-content.hidden {
  display: none;
}

.drop-zone-icon {
  font-size: 2.5rem;
  opacity: 0.5;
}

.drop-zone-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.drop-zone-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.drop-zone-input {
  display: none;
}

.drop-zone-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.drop-zone-progress.hidden {
  display: none;
}

.progress-bar {
  width: 100%;
  max-width: 300px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-cyan);
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Filter Tabs */
.asset-filter-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: var(--space-2);
}

.filter-tab {
  background: none;
  border: none;
  padding: var(--space-1) var(--space-2);
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.filter-tab:hover {
  color: var(--text-secondary);
  background: var(--glass-bg);
}

.filter-tab.active {
  color: var(--accent-edit);
  background: color-mix(in srgb, var(--accent-edit) 10%, transparent);
}

/* Asset List */
.asset-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 300px;
  overflow-y: auto;
}

.asset-list-empty {
  text-align: center;
  padding: var(--space-4);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.asset-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}

.asset-item:hover {
  border-color: var(--glass-border-hover);
}

.asset-icon {
  font-size: 1.2rem;
}

.asset-info {
  flex: 1;
  min-width: 0;
}

.asset-name {
  display: block;
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-path {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-actions {
  display: flex;
  gap: var(--space-1);
}

.asset-actions button {
  background: none;
  border: none;
  padding: var(--space-1);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.asset-actions button:hover {
  opacity: 1;
}

/* Footer */
.asset-uploader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--glass-border);
}

.asset-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   New Rundown Dialog
   ========================================================================== */

.new-rundown-dialog {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--transition-fast) ease-out;
}

.new-rundown-dialog.closing {
  animation: fadeOut var(--transition-fast) ease-out forwards;
}

.new-rundown-dialog .dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.new-rundown-dialog .dialog-content {
  position: relative;
  width: 90%;
  max-width: 600px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  animation: slideUp var(--transition-normal) ease-out;
}

.new-rundown-dialog.closing .dialog-content {
  animation: slideDown var(--transition-fast) ease-out forwards;
}

.new-rundown-dialog .dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
}

.new-rundown-dialog .dialog-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.new-rundown-dialog .dialog-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  transition: color var(--transition-fast);
}

.new-rundown-dialog .dialog-close:hover {
  color: var(--text-primary);
}

.new-rundown-dialog .dialog-body {
  padding: var(--space-4) var(--space-5);
}

.new-rundown-dialog .dialog-intro {
  margin: 0 0 var(--space-4);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.new-rundown-dialog .template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.new-rundown-dialog .template-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--glass-bg-subtle);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.new-rundown-dialog .template-option:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.new-rundown-dialog .template-option:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(0, 255, 200, 0.2);
}

.new-rundown-dialog .template-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.new-rundown-dialog .template-icon {
  font-size: 1.5rem;
}

.new-rundown-dialog .template-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.new-rundown-dialog .template-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.new-rundown-dialog .template-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.new-rundown-dialog .dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--glass-border);
  background: var(--glass-bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.new-rundown-dialog .switch-editor-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.new-rundown-dialog .switch-editor-label input {
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
}

.new-rundown-dialog .btn-cancel {
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.new-rundown-dialog .btn-cancel:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

/* Animations */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

/* Responsive: Stack templates on mobile */
@media (max-width: 500px) {
  .new-rundown-dialog .template-grid {
    grid-template-columns: 1fr;
  }
}

/* ================================================
   Confirmation Dialog
   ================================================ */

.confirmation-dialog {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 10);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--transition-fast) ease-out;
}

.confirmation-dialog.closing {
  animation: fadeOut var(--transition-fast) ease-out forwards;
}

.confirmation-dialog .dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.confirmation-dialog .dialog-content {
  position: relative;
  width: 90%;
  max-width: 400px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  animation: slideUp var(--transition-normal) ease-out;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.confirmation-dialog.closing .dialog-content {
  animation: slideDown var(--transition-fast) ease-out forwards;
}

.confirmation-dialog .dialog-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
}

.confirmation-dialog .dialog-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--warning);
}

.confirmation-dialog .dialog-body {
  padding: var(--space-4) var(--space-5);
}

.confirmation-dialog .dialog-body p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirmation-dialog .dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--glass-border);
}

.confirmation-dialog .btn-cancel {
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.confirmation-dialog .btn-cancel:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.confirmation-dialog .btn-confirm {
  padding: var(--space-2) var(--space-4);
  background: var(--warning);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--bg-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.confirmation-dialog .btn-confirm:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.confirmation-dialog .btn-confirm:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 200, 0, 0.3);
}

/* ============================================================================
   Rundown Selector (Patch 009)
   Project Management UX - Dropdown for switching between rundowns
   ============================================================================ */

.rundown-selector {
  position: relative;
}

.rundown-current {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-base);
  width: 180px; /* Fixed width prevents layout shift on content change */
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.rundown-current:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}

.rundown-current:focus {
  outline: none;
  border-color: var(--accent-edit);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-edit) 20%, transparent);
}

.rundown-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  text-align: left;
}

/* Note: Main .rundown-status-badge styles moved to "Rundown Mode Indicators" section below */
.rundown-status-badge.hidden {
  display: none;
}

.rundown-chevron {
  font-size: 0.7rem;
  opacity: 0.6;
  transition: transform var(--transition-base);
  flex-shrink: 0;
}

.rundown-selector.open .rundown-chevron {
  transform: rotate(180deg);
}

.rundown-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  width: 320px;
  max-height: 400px;
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
  animation: slideUp var(--transition-base) ease-out;
}

.rundown-dropdown.hidden {
  display: none;
}

/* Action buttons row (Load/Export) inside dropdown */
.rundown-dropdown-actions {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
}

.dropdown-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition-base);
}

.dropdown-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-edit);
  color: var(--text-primary);
}

.dropdown-action-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.rundown-dropdown-header {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
}

.rundown-search {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-sans);
}

.rundown-search::placeholder {
  color: var(--text-muted);
}

.rundown-search:focus {
  outline: none;
  border-color: var(--accent-edit);
}

.rundown-new {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-edit);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--bg-primary);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-base);
  flex-shrink: 0;
}

.rundown-new:hover {
  background: var(--accent-green);
  transform: scale(1.05);
}

.rundown-new:focus {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-edit) 30%, transparent);
}

.rundown-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
}

.rundown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  cursor: pointer;
  transition: var(--transition-fast);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  contain: layout style;
}

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

.rundown-item:hover,
.rundown-item.selected {
  background: var(--glass-bg-hover);
}

.rundown-item.selected {
  border-left: 2px solid var(--accent-edit);
  padding-left: calc(var(--space-3) - 2px);
}

.rundown-item.current {
  background: color-mix(in srgb, var(--accent-edit) 8%, transparent);
}

.rundown-item.current::after {
  content: '✓';
  margin-left: auto;
  color: var(--accent-edit);
  font-size: 0.8rem;
}

.rundown-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.rundown-item-status {
  font-size: 0.65rem;
  padding: 2px 6px;
  flex-shrink: 0;
}

.rundown-item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.rundown-empty,
.rundown-loading {
  padding: var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.rundown-empty.hidden,
.rundown-loading.hidden {
  display: none;
}

/* Status badge colours */
.status-draft { background: var(--text-muted); color: var(--bg-primary); }
.status-rehearsal { background: var(--accent-purple); color: white; }
.status-ready { background: var(--accent-edit); color: var(--bg-primary); }
.status-live { background: var(--status-live); color: white; }
.status-completed { background: var(--accent-green); color: var(--bg-primary); }
.status-archived { background: var(--bg-tertiary); color: var(--text-secondary); }

/* Save Status (deprecated - now part of .sync-status) */

/* ============================================================================
   New Rundown Dialog (Patch 009)
   Project Management UX - Modal for creating new rundowns
   ============================================================================ */

.new-rundown-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn var(--transition-fast) ease-out;
}

.new-rundown-modal.hidden {
  display: none;
}

.new-rundown-dialog {
  width: 90%;
  max-width: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideUp var(--transition-base) ease-out;
}

.new-rundown-dialog .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
}

.new-rundown-dialog .modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.new-rundown-dialog .modal-icon {
  font-size: 1.2rem;
}

.new-rundown-dialog .btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.new-rundown-dialog .btn-close:hover {
  color: var(--text-primary);
  background: var(--glass-bg-hover);
}

.new-rundown-dialog .modal-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.new-rundown-dialog .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.new-rundown-dialog .form-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.new-rundown-dialog .form-label .required {
  color: var(--accent-red);
}

.new-rundown-dialog .form-label .optional {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.8rem;
}

.new-rundown-dialog .form-input,
.new-rundown-dialog .form-select {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  transition: var(--transition-fast);
}

.new-rundown-dialog .form-input:focus,
.new-rundown-dialog .form-select:focus {
  outline: none;
  border-color: var(--accent-edit);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-edit) 15%, transparent);
}

.new-rundown-dialog .form-input::placeholder {
  color: var(--text-muted);
}

.new-rundown-dialog textarea.form-input {
  resize: vertical;
  min-height: 60px;
}

.new-rundown-dialog .form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.new-rundown-dialog .modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
}

.new-rundown-dialog .btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.new-rundown-dialog .btn-secondary {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.new-rundown-dialog .btn-secondary:hover:not(:disabled) {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.new-rundown-dialog .btn-primary {
  background: var(--accent-edit);
  border: none;
  color: var(--bg-primary);
}

.new-rundown-dialog .btn-primary:hover:not(:disabled) {
  background: var(--accent-green);
  transform: translateY(-1px);
}

.new-rundown-dialog .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.new-rundown-dialog .btn-text.hidden,
.new-rundown-dialog .btn-loading.hidden {
  display: none;
}

/* ============================================================================
   Rundown Mode Indicators (Planning / Rehearsal / Live)
   ============================================================================ */

/* Mode badge in header - extends .rundown-status-badge */
.rundown-status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  transition: all var(--transition-base);
}

.rundown-status-badge .mode-icon {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

/* Icon visibility based on mode */
.rundown-status-badge.planning .icon-unlocked { display: block; }
.rundown-status-badge.planning .icon-locked { display: none; }
.rundown-status-badge.rehearsal .icon-unlocked,
.rundown-status-badge.live .icon-unlocked { display: none; }
.rundown-status-badge.rehearsal .icon-locked,
.rundown-status-badge.live .icon-locked { display: block; }

/* Planning mode - green, unlocked */
.rundown-status-badge.planning {
  background: color-mix(in srgb, var(--accent-green) 20%, transparent);
  color: var(--accent-green);
  border: 1px solid color-mix(in srgb, var(--accent-green) 40%, transparent);
}

/* Rehearsal mode - amber, locked */
.rundown-status-badge.rehearsal {
  background: color-mix(in srgb, var(--accent-orange) 20%, transparent);
  color: var(--accent-orange);
  border: 1px solid color-mix(in srgb, var(--accent-orange) 40%, transparent);
}

/* Live mode - red, locked, pulsing */
.rundown-status-badge.live {
  background: color-mix(in srgb, var(--status-live) 25%, transparent);
  color: var(--status-live);
  border: 1px solid color-mix(in srgb, var(--status-live) 50%, transparent);
  animation: mode-live-pulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 12px color-mix(in srgb, var(--status-live) 30%, transparent);
}

@keyframes mode-live-pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 12px color-mix(in srgb, var(--status-live) 30%, transparent);
  }
  50% {
    opacity: 0.85;
    box-shadow: 0 0 20px color-mix(in srgb, var(--status-live) 50%, transparent);
  }
}

/* Mode transition animation */
.rundown-status-badge.mode-transitioning {
  animation: mode-transition 0.4s ease-out;
}

@keyframes mode-transition {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================================
   Renumber Button States
   ============================================================================ */

.btn-renumber {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition-base);
}

.btn-renumber:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent-edit);
  color: var(--text-primary);
}

/* Disabled state when rundown is frozen */
.btn-renumber:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--bg-tertiary);
  border-color: var(--glass-border);
  color: var(--text-muted);
}

.btn-renumber:disabled:hover {
  /* Override hover styles when disabled */
  background: var(--bg-tertiary);
  border-color: var(--glass-border);
}

/* Tooltip for disabled renumber button */
.btn-renumber[data-tooltip-frozen] {
  position: relative;
}

.btn-renumber[data-tooltip-frozen]:disabled::after {
  content: attr(data-tooltip-frozen);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.75rem;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
  z-index: var(--z-dropdown);
}

.btn-renumber[data-tooltip-frozen]:disabled:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ============================================================================
   OMITTED Segment Styling (Frozen Mode)
   Struck segments remain visible with their ID preserved for crew communication
   ============================================================================ */

/* Base omitted row styling */
.rundown-table tbody tr.omitted {
  opacity: 0.5;
  background: color-mix(in srgb, var(--bg-primary) 80%, var(--accent-red) 5%);
}

/* Strikethrough on text content */
.rundown-table tbody tr.omitted .col-slug,
.rundown-table tbody tr.omitted .col-description,
.rundown-table tbody tr.omitted .col-contributor {
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
}

/* OMITTED badge */
.omitted-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: color-mix(in srgb, var(--accent-red) 15%, transparent);
  color: var(--accent-red);
  border: 1px solid color-mix(in srgb, var(--accent-red) 30%, transparent);
  border-radius: var(--radius-sm);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-left: var(--space-2);
}

.omitted-badge .omitted-icon {
  width: 8px;
  height: 8px;
}

/* Omitted row still draggable - preserve drag handle */
.rundown-table tbody tr.omitted .drag-handle {
  opacity: 0.6;
  cursor: grab;
}

.rundown-table tbody tr.omitted .drag-handle:active {
  cursor: grabbing;
}

/* Hover state for omitted - slightly less dimmed */
.rundown-table tbody tr.omitted:hover {
  opacity: 0.65;
  background: color-mix(in srgb, var(--bg-hover) 80%, var(--accent-red) 8%);
}

/* Omitting segment animation (fade to omitted state) */
.rundown-table tbody tr.omitting {
  animation: omit-segment 0.4s ease-out forwards;
}

@keyframes omit-segment {
  0% {
    opacity: 1;
    background: var(--bg-primary);
    transform: translateX(0);
  }
  30% {
    transform: translateX(-4px);
    background: color-mix(in srgb, var(--bg-primary) 70%, var(--accent-red) 15%);
  }
  100% {
    opacity: 0.5;
    background: color-mix(in srgb, var(--bg-primary) 80%, var(--accent-red) 5%);
    transform: translateX(0);
  }
}

/* ============================================================================
   Suffix Segment Indication (Inserted During Live)
   ============================================================================ */

/* Subtle visual marker for suffix segments (e.g., A06B) */
.segment-id.has-suffix {
  position: relative;
}

.segment-id.has-suffix::after {
  content: '';
  position: absolute;
  top: 2px;
  right: -6px;
  width: 4px;
  height: 4px;
  background: var(--accent-purple);
  border-radius: 50%;
  opacity: 0.8;
}

/* Alternative: suffix badge indicator */
.suffix-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  background: color-mix(in srgb, var(--accent-purple) 20%, transparent);
  color: var(--accent-purple);
  border-radius: var(--radius-sm);
  font-size: 0.55rem;
  font-weight: 700;
  vertical-align: middle;
}

/* Tooltip for suffix segments */
.segment-id.has-suffix[data-suffix-tooltip] {
  cursor: help;
}

.segment-id.has-suffix[data-suffix-tooltip]::before {
  content: attr(data-suffix-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-2);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.7rem;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
  z-index: var(--z-dropdown);
}

.segment-id.has-suffix[data-suffix-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Suffix row background - very subtle purple tint */
.rundown-table tbody tr.has-suffix-id {
  background: color-mix(in srgb, var(--bg-primary) 97%, var(--accent-purple) 3%);
}

.rundown-table tbody tr.has-suffix-id:hover {
  background: color-mix(in srgb, var(--bg-hover) 95%, var(--accent-purple) 5%);
}

/* ============================================================================
   Responsive Rundown Table - Container Queries
   RIGHT SIDE (never hidden): Type, Timing/Go, Duration, Actions
   LEFT SIDE (hidden progressively): Contributor → Description → TOD → ID
   Slug always visible
   ============================================================================ */

/* Below 900px: Hide Contributor */
@container rundown (max-width: 900px) {
  .col-contributor { display: none; }
}

/* Below 700px: Also hide Description */
@container rundown (max-width: 700px) {
  .col-description { display: none; }
}

/* Below 500px: Also hide TOD */
@container rundown (max-width: 500px) {
  .col-tod { display: none; }
}

/* Below 400px: Also hide ID, keep Slug + right columns */
@container rundown (max-width: 400px) {
  .col-id { display: none; }
}
