/* ==========================================================================
   Streamd Modern Dashboard Stylesheet
   Style: Clean, Bright, Elegant, Sophisticated Micro-interactions
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Color Palette - Crisp Light Slate with Warm Accents */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-surface-hover: #f8fafc;

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #6366f1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverted: #ffffff;

  /* Brand Accents */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-border: #c7d2fe;

  /* Status Colors */
  --status-live: #059669;
  --status-live-bg: #ecfdf5;
  --status-live-border: #a7f3d0;

  --status-rec: #e11d48;
  --status-rec-bg: #fff1f2;
  --status-rec-border: #fecdd3;

  --status-offline: #64748b;
  --status-offline-bg: #f8fafc;
  --status-offline-border: #e2e8f0;

  --status-warn: #d97706;
  --status-warn-bg: #fffbeb;
  --status-warn-border: #fde68a;

  /* Shadows - Multi-layered & Soft */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.04);

  /* Easing curves for high-end feel */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.2, 0.8, 0.2, 1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

input, button, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

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

/* App Container */
.app-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 60px;
  width: 100%;
}

/* ==========================================================================
   Top Header Navigation
   ========================================================================== */
.header {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 22px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s var(--ease-smooth);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  user-select: none;
  flex-shrink: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.28);
}

.brand-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.system-pill-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.stat-pill strong {
  color: var(--text-primary);
  font-weight: 600;
}

.stat-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-live);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 500;
  transition: all 0.18s var(--ease-spring);
  white-space: nowrap;
  user-select: none;
}

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

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 5px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.btn-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-danger {
  background: #ffffff;
  border: 1px solid #fecdd3;
  color: var(--status-rec);
}
.btn-danger:hover {
  background: var(--status-rec-bg);
  border-color: #fda4af;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon-only {
  padding: 8px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}
.btn-icon-only:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
}

/* ==========================================================================
   Hero: Active Capture Spotlight
   ========================================================================== */
.active-captures-wrap {
  margin-bottom: 24px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-badge {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ==========================================================================
   Active Captures Hero Spotlight (Broadcast-Grade Live Monitor)
   Clean Studio Slate Design - Zero Cheap Red Frames
   ========================================================================== */
.active-captures-wrap {
  margin-bottom: 24px;
}

.hero-capture-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03), 0 6px 18px -2px rgba(15, 23, 42, 0.04);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth);
}

.hero-capture-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 10px 24px -3px rgba(15, 23, 42, 0.06);
}

.hero-card-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: center;
}

.hero-preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #090d16;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.hero-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  opacity: 0.5;
}

.hero-preview-rec-tag {
  position: absolute;
  top: 9px;
  left: 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  letter-spacing: 0.06em;
  z-index: 2;
}

.hero-preview-rec-tag .rec-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f43f5e;
  box-shadow: 0 0 6px #f43f5e;
  animation: rec-blink 1.5s ease-in-out infinite;
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.85); }
}

.hero-preview-time-tag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  backdrop-filter: blur(4px);
}

.hero-preview-meta-tag {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  backdrop-filter: blur(4px);
}

.hero-details-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-streamer-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-avatar-img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  background: #e2e8f0;
}

.hero-avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-subtle);
  flex-shrink: 0;
}

.hero-titles {
  display: flex;
  flex-direction: column;
}

.hero-anchor-name {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-meta-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.platform-name-tag {
  font-weight: 600;
  color: var(--text-secondary);
}

.hero-room-title {
  color: var(--text-secondary);
  font-style: italic;
}

.pulse-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--status-rec);
  background: var(--status-rec-bg);
  border: 1px solid var(--status-rec-border);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-rec);
  position: relative;
}

.pulse-dot::after {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  background: var(--status-rec);
  opacity: 0.5;
  animation: pulse-ring 1.8s infinite var(--ease-smooth);
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(0.8); opacity: 0; }
}

.hero-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  background: var(--bg-surface-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.metric-item {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

/* ==========================================================================
   Filter & Search Toolbar
   ========================================================================== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.filter-pill {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.16s var(--ease-spring);
}

.filter-pill:hover {
  color: var(--text-primary);
  background: var(--bg-surface-subtle);
}

.filter-pill.active {
  background: var(--text-primary);
  color: #ffffff;
  font-weight: 600;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 220px;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.16s, box-shadow 0.16s;
}

.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ==========================================================================
   Target Stream Cards Grid with 16:9 Screenshot Covers
   ========================================================================== */
.streams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.stream-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.22s var(--ease-spring), box-shadow 0.22s var(--ease-spring), border-color 0.2s;
  position: relative;
}

.stream-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.stream-card.is-recording {
  border-color: var(--border-subtle);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 6px 18px -2px rgba(15, 23, 42, 0.05);
}

.stream-card.is-recording:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 12px 24px -3px rgba(15, 23, 42, 0.08);
}

/* 16:9 Live Room Screenshot / Cover Header */
.stream-card-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  overflow: hidden;
}

.stream-card-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s var(--ease-smooth), opacity 0.25s;
}

.stream-card:hover .stream-card-cover-img {
  transform: scale(1.04);
}

.stream-card.is-offline .stream-card-cover-img {
  filter: grayscale(35%) contrast(90%);
  opacity: 0.85;
}

.stream-card-cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  opacity: 0.3;
}

/* Overlays on top of the screenshot */
.cover-overlay-top-left {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
}

.cover-overlay-top-right {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}

.cover-overlay-bottom-right {
  position: absolute;
  bottom: 8px;
  right: 10px;
  z-index: 2;
}

.cover-quality-pill {
  font-size: 0.7rem;
  font-weight: 600;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.platform-glass-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 5px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.platform-glass-pill svg {
  display: block;
}

/* Card Body */
.stream-card-body {
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-grow: 1;
}

.stream-card-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stream-anchor-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  border: 1.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  background: #e2e8f0;
}

.stream-anchor-avatar-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-subtle);
  flex-shrink: 0;
}

.stream-card-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.stream-card-name {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-card-room-title {
  font-size: 0.76rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.stream-card-url {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.73rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
  transition: color 0.15s;
}

.stream-card-url:hover {
  color: var(--color-primary);
}

/* Status Badges Overlay on Cards */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  line-height: 1.2;
}

/* 1. 录制中 (Recording): 演播室深邃毛玻璃底 + 纯正电影机呼吸红点 + 柔光扩散 (告别红配绿) */
.status-badge-recording {
  background: rgba(15, 23, 42, 0.82);
  color: #ffffff;
  border-color: rgba(244, 63, 94, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}

.status-badge-recording .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f43f5e;
  box-shadow: 0 0 6px #f43f5e;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.status-badge-recording .pulse-dot::after {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  background: #f43f5e;
  opacity: 0.6;
  animation: pulse-ring 1.8s infinite var(--ease-smooth);
}

/* 2. 直播中 (Live - not recording): 暗色毛玻璃 + 纯正翡翠绿点 (绝无红绿冲突) */
.status-badge-live {
  background: rgba(15, 23, 42, 0.82);
  color: #ffffff;
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}

.status-badge-live .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 5px rgba(16, 185, 129, 0.8);
  display: inline-block;
  flex-shrink: 0;
}

/* 3. 未开播 (Offline): 浅灰色柔和半透 + 细致空心环 */
.status-badge-offline {
  background: rgba(15, 23, 42, 0.65);
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.1);
}

.status-badge-offline .offline-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1.5px solid #94a3b8;
  display: inline-block;
  flex-shrink: 0;
}

/* 4. 已暂停 (Paused) */
.status-badge-paused {
  background: rgba(30, 41, 59, 0.72);
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.1);
}

/* 5. 异常 / 探测中 */
.status-badge-warn {
  background: rgba(15, 23, 42, 0.82);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
}

.stream-card-configs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.config-tag {
  font-size: 0.73rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.stream-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-subtle);
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: auto;
}

.stream-next-probe {
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.stream-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Switch Toggle (iOS style) */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.2s var(--ease-spring);
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.2s var(--ease-spring);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(16px);
}

/* ==========================================================================
   Slide-over Drawer & Modals
   ========================================================================== */
.drawer-backdrop, .modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(6px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s var(--ease-smooth), visibility 0.25s;
}

.drawer-backdrop.active, .modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  justify-content: center;
  padding: 20px;
}

.drawer-panel {
  background: var(--bg-surface);
  width: 100%;
  max-width: 520px;
  height: 100%;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s var(--ease-spring);
}

.drawer-backdrop.active .drawer-panel {
  transform: translateX(0);
}

.modal-panel {
  background: var(--bg-surface);
  width: 100%;
  max-width: 440px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-subtle);
  transform: scale(0.95) translateY(8px);
  transition: transform 0.25s var(--ease-spring);
  overflow: hidden;
}

.modal-backdrop.active .modal-panel {
  transform: scale(1) translateY(0);
}

.panel-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.panel-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Form Groups */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.form-input, .form-select {
  padding: 9px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: 0.88rem;
  color: var(--text-primary);
  transition: border-color 0.16s, box-shadow 0.16s;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input:disabled, .form-select:disabled {
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-help {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.locked-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.8rem;
  color: #92400e;
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 8px 18px 8px 12px;
  min-height: 38px;
  min-width: 140px;
  box-sizing: border-box;
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.1), 0 1px 3px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  animation: toast-float-up 0.28s var(--ease-spring);
  white-space: nowrap;
  transition: width 0.2s var(--ease-smooth), min-width 0.2s var(--ease-smooth);
}

.toast-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-icon-success {
  background: #ecfdf5;
  color: #059669;
}

.toast-icon-error {
  background: #fef2f2;
  color: #dc2626;
}

.toast-icon-warn {
  background: #fffbeb;
  color: #d97706;
}

.toast-icon-info {
  background: #f1f5f9;
  color: #475569;
}

.toast-icon-pause {
  background: #f1f5f9;
  color: #64748b;
}

.toast-msg {
  color: var(--text-primary);
  line-height: 1;
}

@keyframes toast-float-up {
  from { transform: translateY(16px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Archive List Table */
.archive-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.archive-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border-subtle);
  color: var(--text-muted);
  font-weight: 600;
}

.archive-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.archive-table tr:hover td {
  background: var(--bg-surface-subtle);
}

.bvid-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0284c7;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
}

.bvid-link:hover {
  background: #e0f2fe;
  text-decoration: none;
}

/* Helper Grid and Table Containers */
.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.archive-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer-archive-panel {
  max-width: 680px;
}

/* ==========================================================================
   Responsive Mobile & Tablet Optimization
   ========================================================================== */

/* Tablet & Smaller Laptops */
@media (max-width: 1024px) {
  .header {
    display: grid;
    grid-template-areas:
      "brand actions"
      "stats stats";
    grid-template-columns: 1fr auto;
    row-gap: 12px;
    column-gap: 12px;
    padding: 12px 18px;
    margin-bottom: 20px;
  }

  .brand {
    grid-area: brand;
    align-self: center;
  }

  .header-actions {
    grid-area: actions;
    gap: 8px;
  }

  .system-pill-group {
    grid-area: stats;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .system-pill-group::-webkit-scrollbar {
    display: none;
  }

  .hero-card-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Mobile Devices (iPhone, Android, Foldables) */
@media (max-width: 768px) {
  .app-layout {
    padding: 12px 12px 48px;
  }

  .header {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
  }

  /* Compact nav buttons on mobile */
  .btn-nav-btn .btn-label {
    display: none;
  }

  .btn-nav-btn {
    padding: 7px 9px;
    border-radius: var(--radius-md);
  }

  .btn-add-stream {
    padding: 7px 12px;
    font-size: 0.82rem;
  }

  /* Toolbar Filter Tabs & Search */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }

  .filter-pills {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 3px;
    gap: 4px;
  }

  .filter-pills::-webkit-scrollbar {
    display: none;
  }

  .filter-pill {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .search-box {
    width: 100%;
    min-width: 0;
  }

  .search-input {
    width: 100%;
    font-size: 16px; /* Prevents unwanted iOS auto-zoom */
    padding: 9px 12px 9px 36px;
  }

  /* Hero Live Capture Card */
  .hero-capture-card {
    padding: 14px 14px;
  }

  .hero-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .hero-streamer-info {
    width: 100%;
  }

  .hero-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .hero-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 8px;
  }

  .hero-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px 12px;
  }

  /* Stream Cards Grid (Single Column on Phone) */
  .streams-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .stream-card-body {
    padding: 12px 14px 10px;
  }

  .stream-card-bottom {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Full Screen Slide-over Drawer on Mobile */
  .drawer-panel {
    width: 100% !important;
    max-width: 100% !important;
    height: 100%;
    border-radius: 0;
  }

  .panel-header {
    padding: 14px 16px;
  }

  .panel-body {
    padding: 14px 16px;
  }

  .panel-footer {
    padding: 12px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
  }

  .form-row-2col {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .form-input, .form-select {
    font-size: 16px; /* iOS auto-zoom prevention */
  }

  .archive-table {
    min-width: 500px;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .modal-panel {
    width: 100%;
    max-width: 100%;
    padding: 20px 16px;
  }
}

/* Small Phones (< 480px, e.g. iPhone SE / Mini) */
@media (max-width: 480px) {
  .brand span:nth-of-type(1) {
    font-size: 1.05rem;
  }
  .brand-badge {
    display: none;
  }
  .btn-add-stream .btn-label {
    display: none;
  }
  .btn-add-stream {
    padding: 7px 9px;
    border-radius: var(--radius-md);
  }
  .stat-pill {
    font-size: 0.75rem;
    padding: 3px 9px;
  }
}
