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

:root {
  --bg:          #eee9df;
  --card-bg:     #e0dbcf;
  --card-border: #dbd5c7;
  --badge-bg:    #cbc6bb;
  --green:       #1c432c;
  --black:       #000;
  --text-muted:  rgba(0,0,0,0.55);
  --font:        'IBM Plex Mono', monospace;
  --radius-card: 20px;
  --radius-img:  12px;
  --radius-pill: 200px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--black);
  font-family: var(--font);
  overflow-x: hidden;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  position: relative;
}

.header-wordmark {
  height: 28px;
  display: block;
  padding-top: 8px;
}


/* ── Main layout ───────────────────────────────────────────────────────────── */
#main {
  padding: 0 24px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Landing page ──────────────────────────────────────────────────────────── */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding-bottom: 80px;
}

.landing-hero {
  width: 100%;
  max-width: 960px;
  display: block;
  margin-top: 80px;
}

.landing-wordmark {
  width: 360px;
  max-width: 80vw;
  display: block;
  margin-top: 80px;
}

.landing-subtitle {
  font-size: 12px;
  color: #5b574e;
  text-align: center;
  margin-top: 20px;
  margin-bottom: 40px;
}

.landing-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 420px;
  padding: 0 24px;
}

.landing-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.landing-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.landing-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--black);
}

.surprise-btn {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: #296642;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.15s;
}
.surprise-btn:hover    { opacity: 0.65; }
.surprise-btn:disabled { opacity: 0.4; cursor: wait; }

.landing-input {
  width: 100%;
  height: 50px;
  background: #e1dbce;
  border: 1.5px solid transparent;
  border-radius: 12px;
  padding: 0 20px;
  font-family: var(--font);
  font-size: 12px;
  color: var(--black);
  outline: none;
  transition: border-color 0.15s;
}

.landing-input::placeholder { color: rgba(0,0,0,0.33); }
.landing-input:focus        { border-color: var(--green); border-width: 2px; }
.landing-input.input-error  { border-color: #c0392b; border-width: 2px; animation: shake 0.4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  60%       { transform: translateX(6px); }
}

.landing-btn {
  height: 50px;
  width: 208px;
  background: var(--green);
  color: #fff;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 40px;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.landing-btn:hover { opacity: 0.85; }

/* ── Feed ──────────────────────────────────────────────────────────────────── */
.feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: calc(100vh - 80px);
}

/* ── Video ─────────────────────────────────────────────────────────────────── */
.video-wrap {
  display: flex;
  justify-content: center;
  padding-top: 20px;
}

.video-frame {
  width: 100%;
  /* max-width is the smaller of 840px or the width that keeps 16:9 within the available vertical space.
     360px reserved = header (~70px) + birds zone (~200px) + status bar + padding (~90px) */
  max-width: min(840px, calc((100vh - 360px) * 16 / 9));
  min-width: 280px; /* never disappear on tiny viewports — 280×157px at 16:9 */
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  transform: rotate(0.18deg);
  background: #1a1a1a;
  position: relative;
}

#yt-player {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.rtsp-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255,255,255,0.7);
  font-family: var(--font);
  text-align: center;
  padding: 24px;
}
.rtsp-placeholder span { font-size: 40px; }
.rtsp-placeholder p { font-size: 15px; font-weight: 500; }
.rtsp-placeholder small { font-size: 12px; opacity: 0.7; }

/* ── Scroll wrapper — anchors chevrons, fills feed column ───────────────────── */
.scroll-wrap {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ── Chevron nav buttons ────────────────────────────────────────────────────── */
.scroll-chevron {
  position: absolute;
  top: calc(50% - 40px); /* offset for 80px bottom padding so chevrons centre on content */
  transform: translateY(-50%);
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  border: 0.5px solid rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--green);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.15s;
}
.scroll-chevron:hover  { opacity: 0.75; }
.scroll-chevron-left  { left: 12px; }
.scroll-chevron-right { right: 12px; }

/* ── Birds unified horizontal scroll ───────────────────────────────────────── */
.birds-scroll {
  display: flex;
  justify-content: safe center;
  align-items: center;
  overflow-x: auto;
  flex: 1;          /* fill scroll-wrap horizontally; scroll-wrap carries the feed flex: 1 */
  padding-bottom: 80px; /* clears fixed status bar (44px) + 16px bottom gap + breathing room */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.birds-scroll-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 40px;
  flex-shrink: 0;
  padding: 0 24px;
}

.birds-scroll::-webkit-scrollbar { height: 4px; }
.birds-scroll::-webkit-scrollbar-track { background: transparent; }
.birds-scroll::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 2px; }

/* ── Live group — card box ──────────────────────────────────────────────────── */
.live-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  padding: 44px 28px 28px;   /* tall top so the LIVE badge has room */
  position: relative;
}

.live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--badge-bg);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.05em;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* Divider between live card and history — hidden, card box is separator enough */
.birds-divider { display: none; }

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2.5vh, 24px);
  padding: 40px 24px;
  white-space: nowrap;
}

.looking-img {
  width: clamp(80px, 16vh, 160px);
  height: auto;
  display: block;
}

.looking-text {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.loading-dots span {
  animation: dotFade 1.4s ease-in-out infinite;
  opacity: 0;
}
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotFade {
  0%, 60%, 100% { opacity: 0; }
  30%            { opacity: 1; }
}

/* ── Bird cards row ────────────────────────────────────────────────────────── */
.bird-cards {
  display: flex;
  flex-direction: row;
  gap: 20px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* ── Bird card ─────────────────────────────────────────────────────────────── */
.bird-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: clamp(100px, 14vh, 140px);
  flex-shrink: 0;
  animation: fadeInUp 0.3s ease forwards;
}

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

.bird-img-wrap {
  width: clamp(100px, 14vh, 140px);
  height: clamp(100px, 14vh, 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.bird-img {
  width: clamp(70px, 10vh, 100px);
  height: clamp(70px, 10vh, 100px);
  border-radius: var(--radius-img);
  object-fit: cover;
  display: block;
}

.bird-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  text-align: center;
}

.bird-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--black);
  line-height: 1.3;
  word-break: break-word;
}

.bird-time {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.8; }

.btn-primary { background: var(--green); color: #fff; }
.btn-ghost   { background: transparent; color: var(--text-muted); }

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

/* ── Status bar ────────────────────────────────────────────────────────────── */
.status-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #cdc7b7;
  color: #1c432c;
  border-radius: var(--radius-pill);
  padding: 0 4px 0 24px;
  height: 44px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 50;
  white-space: nowrap;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(12px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

.status-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Status text colours by state */
#status-text { transition: color 0.2s; }

.status-bar.state-connecting #status-text,
.status-bar.state-ended     #status-text,
.status-bar.state-error     #status-text { color: #7a8074; }

.status-bar.state-live #status-text { color: #1c432c; }

/* Pulsing opacity for connecting/resolving */
.status-bar.state-connecting #status-text {
  animation: statusPulse 1.6s ease-in-out infinite;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* Pause button — hidden by default, only shown when live */
.status-refresh-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  border: none;
  background: rgba(255,255,255,0.47);
  color: #1c432c;
  cursor: pointer;
  transition: background 0.15s;
}
.status-bar.state-live .status-refresh-btn { display: flex; }
.status-refresh-btn:hover { background: rgba(255,255,255,0.65); }
.status-refresh-btn.is-spinning svg {
  animation: spin-ccw 0.7s linear infinite;
  transform-origin: center;
  transform-box: fill-box;
}
@keyframes spin-ccw {
  to { transform: rotate(-360deg); }
}

.stop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  border: none;
  background: #1c432c;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
}
.stop-btn:hover { opacity: 0.85; }

/* ── Loading ───────────────────────────────────────────────────────────────── */
.loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
}

.loading-hero {
  width: 78%;
  max-width: 960px;
  height: auto;
  margin-top: 120px;
  flex-shrink: 0;
}

.loading-wordmark {
  height: auto;
  max-width: 321.6px;
  width: 78%;
  margin-top: 80px;
  flex-shrink: 0;
}

.loading-subtitle {
  font-size: 12px;
  color: #5b574e;
  font-weight: 400;
  margin: 20px 0 0;
  text-align: center;
}

.loading-status-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.loading-status {
  font-size: 14px;
  color: #5b574e;
  font-weight: 400;
  text-align: center;
  margin: 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--card-border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Debug button ──────────────────────────────────────────────────────────── */
.debug-btn {
  position: absolute;
  left: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  border: 0.5px solid rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.debug-btn:hover { background: rgba(255,255,255,0.95); color: var(--black); }
.debug-btn.active { background: var(--green); border-color: var(--green); color: #fff; }

/* ── Debug panel ───────────────────────────────────────────────────────────── */
.debug-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: #0d1117;
  color: #e6edf3;
  font-family: var(--font);
  font-size: 12px;
  border-top: 1px solid #30363d;
  display: flex;
  flex-direction: column;
  max-height: 320px;
  animation: slideUp 0.2s ease;
}

.debug-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}

.debug-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #58a6ff;
}

.debug-meta {
  font-size: 11px;
  color: #8b949e;
  flex: 1;
}

.debug-close {
  background: none;
  border: none;
  color: #8b949e;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
}
.debug-close:hover { background: #21262d; color: #e6edf3; }

/* ── Debug tabs ────────────────────────────────────────────────────────────── */
.debug-tabs {
  display: flex;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
  padding: 0 8px;
}

.debug-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #8b949e;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 7px 12px;
  margin-bottom: -1px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s;
  white-space: nowrap;
}
.debug-tab:hover  { color: #e6edf3; }
.debug-tab.active { color: #58a6ff; border-bottom-color: #58a6ff; }

/* ── Debug panes ───────────────────────────────────────────────────────────── */
.debug-pane {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  min-height: 0;
}

.debug-pane .debug-section {
  flex: 1;
  min-height: 0;
}

.debug-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #8b949e;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dbg-count {
  background: #21262d;
  color: #8b949e;
  border-radius: 8px;
  padding: 0 5px;
  font-size: 10px;
}

.debug-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.debug-section-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.debug-section-scroll::-webkit-scrollbar { width: 4px; }
.debug-section-scroll::-webkit-scrollbar-track { background: transparent; }
.debug-section-scroll::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }

.dbg-empty {
  color: #484f58;
  font-size: 11px;
  font-style: italic;
}

/* Bird row in debug panel */
.dbg-bird {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 5px;
  background: #161b22;
  border: 1px solid #21262d;
}

.dbg-bird-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #e6edf3;
  font-size: 11px;
}

.dbg-bird-conf {
  font-size: 11px;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}
.dbg-bird-conf.high  { color: #3fb950; }
.dbg-bird-conf.mid   { color: #d29922; }
.dbg-bird-conf.low   { color: #f85149; }

.dbg-bird-age {
  font-size: 10px;
  color: #8b949e;
  min-width: 32px;
  text-align: right;
}

.dbg-bird-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 3px;
}
.dbg-bird-badge.live {
  background: rgba(63,185,80,0.15);
  color: #3fb950;
  border: 1px solid rgba(63,185,80,0.3);
}
.dbg-bird-badge.hist {
  background: rgba(88,166,255,0.12);
  color: #58a6ff;
  border: 1px solid rgba(88,166,255,0.25);
}

/* Frame summary */
.dbg-frame-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e6edf3;
  padding: 3px 6px;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 5px;
}
.dbg-frame-count {
  font-size: 22px;
  font-weight: 600;
  color: #58a6ff;
  line-height: 1;
}
.dbg-frame-label {
  font-size: 11px;
  color: #8b949e;
}

/* ── Pipeline tab ──────────────────────────────────────────────────────────── */
/* Summary funnel row at the top of the pipeline pane */
.dbg-pipe-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 5px;
  margin-bottom: 8px;
  font-size: 11px;
  color: #8b949e;
  flex-shrink: 0;
}
.dbg-pipe-summary-num {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}
.dbg-pipe-summary-num.c-yolo  { color: #58a6ff; }
.dbg-pipe-summary-num.c-nms   { color: #d29922; }
.dbg-pipe-summary-num.c-final { color: #3fb950; }
.dbg-pipe-summary-sep { color: #30363d; font-size: 12px; }

/* Per-detection rows */
.dbg-pipe-det {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 5px;
  background: #161b22;
  border: 1px solid #21262d;
  font-size: 11px;
}

/* Stage chip */
.dbg-pipe-stage {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.dbg-pipe-stage.s-pass { background: rgba(63,185,80,0.13);  color: #3fb950; border: 1px solid rgba(63,185,80,0.25); }
.dbg-pipe-stage.s-fail { background: rgba(248,81,73,0.13);  color: #f85149; border: 1px solid rgba(248,81,73,0.25); }
.dbg-pipe-stage.s-warn { background: rgba(210,153,34,0.13); color: #d29922; border: 1px solid rgba(210,153,34,0.25); }
.dbg-pipe-stage.s-info { background: rgba(88,166,255,0.10); color: #58a6ff; border: 1px solid rgba(88,166,255,0.20); }
.dbg-pipe-stage.s-err  { background: rgba(248,81,73,0.08);  color: #6e7681; border: 1px solid #30363d; }

.dbg-pipe-arrow { color: #30363d; font-size: 10px; flex-shrink: 0; }

.dbg-pipe-final {
  color: #e6edf3;
  font-weight: 500;
  margin-left: 2px;
}

.dbg-pipe-alts {
  color: #484f58;
  font-size: 10px;
  margin-left: 2px;
}

/* Event log */
.debug-log {
  gap: 2px;
}
.dbg-log-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: #8b949e;
  font-size: 11px;
  line-height: 1.5;
}
.dbg-log-row.detect { color: #3fb950; }
.dbg-log-row.status { color: #58a6ff; }
.dbg-log-row.error  { color: #f85149; }
.dbg-log-time { color: #484f58; font-size: 10px; flex-shrink: 0; }
.dbg-log-msg  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Header actions (+ button row) ────────────────────────────────────────── */
.header-actions {
  position: absolute;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-stream-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  border: 0.5px solid rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.add-stream-btn:hover { background: rgba(255,255,255,0.95); color: var(--black); }

/* ── Stream Modal ──────────────────────────────────────────────────────────── */
.stream-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stream-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.stream-modal-box {
  position: relative;
  background: #f5f0e8;
  border-radius: 16px;
  width: 460px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.stream-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stream-modal-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--black);
}

.stream-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 6px;
  transition: background 0.15s;
}
.stream-modal-close:hover { background: rgba(0,0,0,0.08); }

.stream-modal-tabs {
  display: flex;
  gap: 4px;
  background: rgba(0,0,0,0.07);
  border-radius: 10px;
  padding: 4px;
}

.stream-modal-tab {
  flex: 1;
  height: 32px;
  background: none;
  border: none;
  border-radius: 7px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.stream-modal-tab.active {
  background: #fff;
  color: var(--black);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stream-modal-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stream-modal-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stream-modal-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--black);
}

.stream-modal-input {
  width: 100%;
  height: 46px;
  background: #e1dbce;
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 0 16px;
  font-family: var(--font);
  font-size: 12px;
  color: var(--black);
  outline: none;
  transition: border-color 0.15s;
}
.stream-modal-input:focus { border-color: var(--green); border-width: 2px; }
.stream-modal-input::placeholder { color: rgba(0,0,0,0.3); }

.stream-modal-btn {
  height: 46px;
  background: var(--green);
  color: #fff;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.stream-modal-btn:hover { opacity: 0.85; }

/* Agent instructions */
.agent-instructions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-instructions-note,
.agent-connect-note {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.agent-step {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.agent-step-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.agent-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.06);
  border-radius: 8px;
  padding: 9px 12px;
}

.agent-code {
  flex: 1;
  font-family: var(--font);
  font-size: 11px;
  color: var(--black);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-copy-btn {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  color: var(--green);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.agent-copy-btn:hover { opacity: 0.65; }

.agent-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-muted);
  margin: 2px 0;
}
.agent-divider::before,
.agent-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(0,0,0,0.1);
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #main { padding: 0 8px 100px; }
  .feed { gap: 24px; }
  .scroll-chevron { display: none; }

  .video-frame { transform: none; border-radius: 16px; }

  /* Entire birds area becomes a vertical column */
  .birds-scroll {
    display: block;
    overflow-x: visible;
    padding-bottom: 0;
  }

  .birds-scroll-inner {
    flex-direction: column;
    gap: 20px;
    flex-shrink: unset;
    padding: 0;
    align-items: stretch;
  }

  /* Live group stays a card box on mobile, just goes full-width column */
  .live-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 44px 20px 24px;
    width: 100%;
  }

  /* LIVE badge stays pinned top-left of card — already absolute, no change needed */

  /* Bird cards: 2-column grid on mobile */
  .bird-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    flex: unset;
    flex-shrink: unset;
  }

  /* No vertical divider on mobile */
  .birds-divider { display: none; }

  /* History empty message */
  .history-empty { padding: 40px 0; white-space: normal; }

  /* Bird card fills its grid cell */
  .bird-card {
    width: 100%;
    flex-direction: column;
    align-items: center;
  }

  /* Square image wrap that fills card width */
  .bird-img-wrap {
    width: 88%;
    height: auto;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Image sized relative to its wrap */
  .bird-img {
    width: 72%;
    height: 72%;
  }

  .bird-name { font-size: 12px; }
  .bird-time { font-size: 11px; }
}
