/* ======================================================================
   GTC Kiosk Telemetry — styles.css
   Mobile-first. Desktop overrides via @media (min-width: 901px).
   ====================================================================== */

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

/* ── Design Tokens ── */
:root {
  --bg: #000;
  --surface: #0a0a0a;
  --surface-2: #141414;
  --border: rgba(255,255,255,0.06);
  --border-hi: rgba(255,255,255,0.12);
  --text: #fff;
  --text-dim: rgba(255,255,255,0.35);
  --text-mid: rgba(255,255,255,0.6);
  --green: #76B900;
  --green-dim: rgba(118,185,0,0.15);
  --red: #E42022;
  --red-dim: rgba(228,32,34,0.15);
  --amber: #F59E0B;
  --amber-dim: rgba(245,158,11,0.15);
  --cyan: #06B6D4;
  --cyan-dim: rgba(6,182,212,0.12);
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  line-height: normal;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

/* ======================================================================
   CHROME (page wrapper)
   ====================================================================== */

.chrome {
  max-width: 1600px;
  margin: 0 auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100vh;
}

/* ======================================================================
   HEADER
   ====================================================================== */

header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.25em;
  background: var(--green);
  color: #000;
  padding: 4px 10px;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}

h1 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-mid);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* Broker badge */
.broker-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 12px;
}
.broker-badge.connected { color: var(--green); border-color: rgba(118,185,0,0.2); }
.broker-badge.disconnected { color: var(--red); border-color: rgba(228,32,34,0.2); }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
}
.broker-badge.connected .dot { background: var(--green); animation: pulse 2s ease-in-out infinite; }
.broker-badge.disconnected .dot { background: var(--red); }

.clock {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* Show hidden / Clear buttons */
.show-hidden-btn,
.auto-capture-btn {
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 3px 10px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.auto-capture-btn:hover { color: var(--cyan); border-color: rgba(6,182,212,0.3); background: var(--cyan-dim); }
.auto-capture-btn.active { color: var(--green); border-color: rgba(118,185,0,0.3); background: var(--green-dim); }

.clear-btn {
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 3px 8px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.show-hidden-btn:hover,
.show-hidden-btn.active {
  color: var(--amber);
  border-color: rgba(245,158,11,0.3);
  background: var(--amber-dim);
}
.clear-btn:hover {
  color: var(--red);
  border-color: rgba(228,32,34,0.3);
  background: var(--red-dim);
}

/* Latest event bar */
.header-latest {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 3px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-height: 22px;
}
.header-latest:empty { display: none; }
.header-log-ts { color: var(--text-dim); flex-shrink: 0; }
.header-log-kiosk { color: var(--green); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; flex-shrink: 0; }
.header-log-msg { color: var(--text-mid); overflow: hidden; text-overflow: ellipsis; }

/* ======================================================================
   STATS BAR
   ====================================================================== */

.stats-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 6px;
}
.stats-bar:empty { display: none; }

.stat-block {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  border-right: 1px solid var(--border);
}
.stat-block:last-child { border-right: none; }

.stat-label {
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
}

.stat-dim {
  font-size: 8px;
  font-weight: 500;
  color: var(--text-dim);
}

.stat-rate {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 0 3px;
}
.stat-rate.stat-ok { color: var(--green); background: var(--green-dim); }
.stat-rate.stat-warn { color: var(--amber); background: var(--amber-dim); }
.stat-rate.stat-bad { color: var(--red); background: var(--red-dim); }

/* ======================================================================
   KIOSK ROWS CONTAINER
   ====================================================================== */

.kiosk-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ======================================================================
   INSTANCE CARD
   Base (mobile): vertical stack
   ====================================================================== */

.instance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid rgba(118,185,0,0.2);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.instance-card.instance-offline {
  border-left-color: var(--red);
  opacity: 0.4;
}
.instance-card.instance-stale {
  border-left-color: var(--amber);
  opacity: 0.7;
}

/* ── Row 1 (mobile: vertical stack) ── */
.inst-row1 {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Row 2: health + actions ── */
.inst-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

/* ── Instance Identity ── */
.instance-identity {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.activation-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 1px 5px;
  border: 1px solid var(--border);
}

.instance-nickname {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-mid);
  letter-spacing: 0.05em;
  padding: 1px 6px;
  background: var(--cyan-dim);
  border: 1px solid rgba(6,182,212,0.15);
}

.nickname-btn {
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s;
  opacity: 0;
}
.instance-identity:hover .nickname-btn { opacity: 1; }
.nickname-btn:hover { color: var(--cyan); }

.instance-id {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: 0.05em;
}

.health-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-dot.ok {
  background: var(--green);
  box-shadow: 0 0 6px rgba(118,185,0,0.4);
  animation: pulse 2s ease-in-out infinite;
}
.health-dot.stale {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(245,158,11,0.3);
}
.health-dot.offline {
  background: var(--red);
  box-shadow: 0 0 6px rgba(228,32,34,0.3);
}

.last-completed {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.hide-btn {
  font-size: 10px;
  line-height: 1;
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.hide-btn:hover { color: var(--red); border-color: rgba(228,32,34,0.3); }
.hide-btn.unhide { color: var(--amber); }
.hide-btn.unhide:hover { color: var(--green); border-color: rgba(118,185,0,0.3); }

/* ── Pipeline ── */
.row-pipeline {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow-x: auto;
}

.pipeline-track {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.pipe-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  cursor: pointer;
}
.pipe-node:hover .pipe-dot { border-color: rgba(255,255,255,0.25); }
.pipe-node:hover .pipe-label { color: var(--text-mid); }

.pipe-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid rgba(255,255,255,0.08);
  transition: all 0.3s;
  position: relative;
}

.pipe-node.past .pipe-dot {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 6px rgba(118,185,0,0.3);
}
.pipe-node.current .pipe-dot {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 12px rgba(118,185,0,0.5), 0 0 24px rgba(118,185,0,0.2);
  animation: pipelinePulse 2s ease-in-out infinite;
}
.pipe-node.current .pipe-dot::after {
  content: '';
  position: absolute;
  top: -4px; left: -4px; right: -4px; bottom: -4px;
  border-radius: 50%;
  border: 1px solid rgba(118,185,0,0.3);
  animation: ringPulse 2s ease-in-out infinite;
}
.pipe-node.error .pipe-dot {
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 0 12px rgba(228,32,34,0.5);
}

.pipe-label {
  font-size: 6px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  transition: color 0.3s;
}
.pipe-node.past .pipe-label { color: rgba(118,185,0,0.6); }
.pipe-node.current .pipe-label { color: var(--green); font-size: 7px; animation: blinkLabel 1.5s ease-in-out infinite; }
.pipe-node.error .pipe-label { color: var(--red); animation: blinkLabel 1.5s ease-in-out infinite; }

.pipe-connector {
  flex: 1;
  height: 2px;
  min-width: 4px;
  background: rgba(255,255,255,0.06);
  margin-top: -16px;
  transition: background 0.3s;
}
.pipe-connector.filled { background: linear-gradient(90deg, var(--green), rgba(118,185,0,0.4)); }
.pipe-connector.active {
  background: linear-gradient(90deg, var(--green), rgba(118,185,0,0.15));
  animation: connectorFlow 1.5s ease-in-out infinite;
}

.gen-timer {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-dim);
  padding: 2px 8px;
  margin-left: 8px;
  animation: blinkLabel 1.5s ease-in-out infinite;
  white-space: nowrap;
}

/* ── Meta Pills ── */
.row-meta {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.meta-pill {
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 5px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  color: var(--text-mid);
  white-space: nowrap;
}
.meta-pill.danger { color: var(--red); border-color: rgba(228,32,34,0.2); }
.meta-pill.gen-ok { color: var(--green); border-color: rgba(118,185,0,0.2); background: var(--green-dim); }
.meta-pill.gen-fail { color: var(--red); border-color: rgba(228,32,34,0.2); background: var(--red-dim); }

/* ── Capture Thumbnail ── */
.inst-capture {
  position: relative;
  cursor: pointer;
  border: 1px solid var(--cyan);
  box-shadow: 0 0 8px rgba(6,182,212,0.3);
  flex-shrink: 0;
  width: 64px;
  height: 44px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.inst-capture:hover { box-shadow: 0 0 12px rgba(6,182,212,0.4); }
.inst-capture img,
.inst-capture video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.capture-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #000;
  background: var(--cyan);
  padding: 0 3px;
  line-height: 1.4;
}

/* Legacy capture thumbnail — dimmer, smaller */
.inst-capture-legacy {
  border-color: var(--border-hi);
  box-shadow: none;
  width: 48px;
  height: 34px;
  opacity: 0.5;
}
.inst-capture-legacy:hover { opacity: 0.8; box-shadow: none; }

/* Session badge — green */
.session-badge { background: var(--green); color: #000; }

/* Legacy badge — dim */
.legacy-badge { background: var(--border-hi); color: var(--text-dim); font-size: 8px; }

/* ── Action Buttons ── */
.inst-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 0;
  width: 100%;
}
.inst-actions .meta-pill {
  flex: 1;
  text-align: center;
}

.capture-action {
  cursor: pointer;
  color: var(--cyan);
  border-color: rgba(6,182,212,0.2);
  background: var(--cyan-dim);
  transition: background 0.2s, border-color 0.2s;
}
.capture-action:hover {
  background: rgba(6,182,212,0.2);
  border-color: rgba(6,182,212,0.4);
}

/* ======================================================================
   HEALTH INLINE (compact badges in row 2)
   ====================================================================== */

.health-inline {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.health-badge.health-ok {
  color: var(--green);
  border-color: rgba(118,185,0,0.2);
  background: var(--green-dim);
}
.health-badge.health-warn {
  color: var(--amber);
  border-color: rgba(245,158,11,0.2);
  background: var(--amber-dim);
}
.health-badge.health-bad {
  color: var(--red);
  border-color: rgba(228,32,34,0.2);
  background: var(--red-dim);
}
.health-badge.health-neutral {
  color: var(--text-dim);
  border-color: var(--border);
  background: rgba(255,255,255,0.02);
}

/* ======================================================================
   FILM STRIP
   ====================================================================== */

.film-section {
  background: var(--surface);
  border: 1px solid var(--border);
}

.film-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.film-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-mid);
}

.film-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.film-track {
  position: relative;
  padding: 6px 0;
}

/* Sprocket holes */
.sprocket-edge {
  position: absolute;
  left: 0; right: 0;
  height: 8px;
  z-index: 1;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px, transparent 14px,
    rgba(255,255,255,0.04) 14px, rgba(255,255,255,0.04) 20px,
    transparent 20px, transparent 34px
  );
}
.sprocket-edge.top { top: 0; border-bottom: 1px solid var(--border); }
.sprocket-edge.bottom { bottom: 0; border-top: 1px solid var(--border); }

.film-strip {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  padding: 8px 8px;
  scroll-behavior: smooth;
}

.film-frame {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  width: 100px;
  background: #080808;
  border: 1px solid var(--border);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.film-frame:hover {
  border-color: var(--border-hi);
  transform: translateY(-2px);
}

.film-brand-bar {
  height: 3px;
  width: 100%;
}

.film-frame img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.film-info {
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.film-scene {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.film-time {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-dim);
}

.film-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ======================================================================
   EVENT LOG
   ====================================================================== */

.event-log {
  background: var(--surface);
  border: 1px solid var(--border);
  max-height: 150px;
  display: flex;
  flex-direction: column;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.log-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-mid);
}

.log-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.log-body {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

.log-entry {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 8px;
  font-size: 10px;
  animation: fadeIn 0.2s ease;
}

.log-ts {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 55px;
}

.log-kiosk {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  flex-shrink: 0;
  width: 80px;
}

.log-msg {
  color: var(--text-mid);
  font-family: var(--font-mono);
  font-size: 8px;
}

.log-cmd .log-kiosk { color: var(--cyan); }

/* ======================================================================
   LIGHTBOX
   ====================================================================== */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
}
.lightbox.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(8px);
}

/* Mobile: stacked vertically */
.lb-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  max-height: 95vh;
  width: 100vw;
  overflow-y: auto;
}

.lb-close {
  position: absolute;
  top: 12px; right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  z-index: 2;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
.lb-close:hover { color: var(--text); }

/* Nav arrows: hidden on mobile */
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--border);
  color: var(--text-mid);
  font-size: 24px;
  cursor: pointer;
  z-index: 2;
  width: 36px;
  height: 60px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.lb-nav:hover { color: var(--text); background: rgba(0,0,0,0.8); }
.lb-prev { left: 0; }
.lb-next { right: 0; }

.lb-image {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  padding: 12px;
}
.lb-image img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

/* Meta panel: full-width on mobile */
.lb-meta {
  width: 100%;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lb-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.lb-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lb-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.lb-value {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.lb-style-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.lb-style-tag {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  background: var(--cyan-dim);
  color: var(--cyan);
  border: 1px solid rgba(6,182,212,0.15);
}

.lb-prompt {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.lb-prompt p {
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-mid);
  margin-top: 4px;
  max-height: 150px;
  overflow-y: auto;
}

.lb-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 9px;
  color: var(--text-dim);
}

.lb-full-link {
  color: var(--cyan);
  text-decoration: none;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.lb-full-link:hover { text-decoration: underline; }

/* ── Capture Gallery inside Lightbox ── */
.cap-gallery-section {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.cap-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  overflow-y: auto;
  max-height: 200px;
  padding: 2px 0;
}

.cap-grid-item {
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.cap-grid-item:hover { border-color: var(--border-hi); }
.cap-grid-item.cap-grid-active {
  border-color: var(--cyan);
  box-shadow: 0 0 6px rgba(6,182,212,0.3);
}

.cap-grid-item img,
.cap-grid-item video {
  width: 100%;
  height: 60px;
  object-fit: cover;
  display: block;
}

.cap-grid-type {
  position: absolute;
  top: 2px; left: 2px;
  font-family: var(--font-mono);
  font-size: 6px;
  font-weight: 700;
  padding: 0 3px;
  line-height: 1.5;
  letter-spacing: 0.05em;
}
.cap-type-video { background: var(--red); color: #fff; }
.cap-type-photo { background: var(--green); color: #000; }

.cap-grid-ts {
  position: absolute;
  bottom: 0; right: 0;
  font-family: var(--font-mono);
  font-size: 7px;
  color: var(--text-dim);
  background: rgba(0,0,0,0.8);
  padding: 1px 3px;
}

/* Type indicator in lightbox meta */
.cap-type-indicator { color: var(--text); }

/* ======================================================================
   KEYFRAME ANIMATIONS
   ====================================================================== */

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

@keyframes pipelinePulse {
  0%, 100% { box-shadow: 0 0 12px rgba(118,185,0,0.5), 0 0 24px rgba(118,185,0,0.2); }
  50% { box-shadow: 0 0 6px rgba(118,185,0,0.3), 0 0 12px rgba(118,185,0,0.1); }
}

@keyframes ringPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.2); }
}

@keyframes blinkLabel {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes connectorFlow {
  0% { background: linear-gradient(90deg, var(--green), rgba(118,185,0,0.15)); }
  50% { background: linear-gradient(90deg, rgba(118,185,0,0.6), rgba(118,185,0,0.3)); }
  100% { background: linear-gradient(90deg, var(--green), rgba(118,185,0,0.15)); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ======================================================================
   FOCUS STATES
   ====================================================================== */

button:focus-visible,
.film-frame:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
}

/* ======================================================================
   REDUCED MOTION
   ====================================================================== */

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

/* ======================================================================
   EXTRA SMALL SCREENS (iPhone SE etc.)
   ====================================================================== */

@media (max-width: 400px) {
  .header-left { gap: 4px; }
  h1 { font-size: 9px; }
  .broker-badge { font-size: 8px; padding: 3px 8px; }
  .clock { font-size: 8px; }
  .instance-id { font-size: 9px; }
  .pipe-label { font-size: 5px; }
  .pipe-dot { width: 6px; height: 6px; }
}

/* ======================================================================
   DESKTOP — min-width: 901px
   All desktop overrides go here, after all base (mobile) styles.
   ====================================================================== */

@media (min-width: 901px) {

  /* Chrome */
  .chrome {
    padding: 20px 24px;
    gap: 16px;
  }

  /* Header */
  .header-top { gap: 8px; }
  .header-left { gap: 12px; }
  h1 { font-size: 13px; letter-spacing: 0.15em; }
  .header-right { gap: 8px; }
  .clock { font-size: 11px; }
  .show-hidden-btn,
  .clear-btn { padding: 4px 12px; font-size: 9px; }

  /* Stats bar: roomier on desktop */
  .stats-bar { padding: 6px 10px; gap: 4px; }
  .stat-block { gap: 6px; padding: 0 12px; }
  .stat-label { font-size: 8px; }
  .stat-value { font-size: 14px; }
  .stat-dim { font-size: 10px; }
  .stat-rate { font-size: 11px; padding: 1px 6px; }

  /* Instance card */
  .instance-card { padding: 8px 20px; }

  /* Row 1: 4-column grid */
  .inst-row1 {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 16px;
  }

  /* Row 2: flex, actions right-aligned */
  .inst-row2 {
    flex-wrap: nowrap;
  }
  .inst-actions {
    margin-left: auto;
    width: auto;
    gap: 3px;
  }
  .inst-actions .meta-pill {
    flex: none;
  }

  /* Pipeline: centered, wider */
  .row-pipeline {
    justify-content: center;
  }
  .pipeline-track {
    max-width: 600px;
  }
  .pipe-dot { width: 10px; height: 10px; }
  .pipe-label { font-size: 7px; }
  .pipe-connector { min-width: 8px; }

  /* Meta pills: right-aligned, larger */
  .row-meta {
    justify-content: flex-end;
    gap: 6px;
  }
  .meta-pill {
    font-size: 9px;
    padding: 3px 8px;
    letter-spacing: 0.1em;
  }

  /* Capture thumbnail: larger */
  .inst-capture {
    width: 80px;
    height: 54px;
  }

  /* Health badges: larger */
  .health-inline { gap: 4px; }
  .health-badge {
    font-size: 8px;
    padding: 2px 7px;
  }

  /* Film strip */
  .film-strip { padding: 12px 12px; }
  .film-frame { width: 120px; }

  /* Event log */
  .event-log { max-height: 200px; }
  .log-entry { padding: 3px 16px; font-size: 11px; gap: 10px; }
  .log-ts { width: 65px; font-size: 9px; }
  .log-kiosk { width: 110px; font-size: 9px; }
  .log-msg { font-size: 10px; }

  /* Lightbox: side-by-side */
  .lb-container {
    flex-direction: row;
    max-width: 1100px;
    max-height: 90vh;
    width: 95vw;
    overflow-y: hidden;
    overflow-x: hidden;
  }
  .lb-image {
    flex: 1;
    min-width: 0;
    padding: 40px;
  }
  .lb-meta {
    width: 320px;
    border-left: 1px solid var(--border);
    border-top: none;
    max-height: none;
    overflow-y: auto;
  }
  .lb-nav {
    display: flex;
  }
  .lb-meta-grid { gap: 8px; }

  /* Capture gallery in lightbox */
  .cap-gallery {
    grid-template-columns: repeat(2, 1fr);
    max-height: 400px;
  }
  .cap-grid-item img,
  .cap-grid-item video {
    height: 80px;
  }
}

/* ======================================================================
   SESSION LIGHTBOX — rich session detail overlay
   ====================================================================== */

.lb-session-container {
  max-width: 900px;
  width: 95vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-hi);
}

.session-lb-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.session-lb-id {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.05em;
}
.session-lb-exp {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.session-lb-scene {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.session-lb-time {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  margin-left: auto;
}

.session-lb-body {
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.session-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.session-section-label {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Media grid inside session lightbox */
.session-media-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.session-media-item {
  background: #080808;
  border: 1px solid var(--border);
  overflow: hidden;
}
.session-media-item video,
.session-media-item img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: #000;
}
.session-media-label {
  padding: 4px 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.session-media-size {
  color: var(--text-dim);
}

/* Original vs AI comparison */
.session-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.session-compare-card {
  background: #080808;
  border: 1px solid var(--border);
  overflow: hidden;
}
.session-compare-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: #000;
}
.session-compare-card:hover img { opacity: 0.9; }
.session-compare-label {
  display: block;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.session-compare-empty {
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Generation metadata grid */
.session-gen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px;
}
.session-gen-field {
  padding: 6px 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
}
.sg-label {
  display: block;
  font-family: var(--font-display);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1px;
}
.sg-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  word-break: break-all;
}

/* Responsive */
@media (max-width: 700px) {
  .session-media-grid { grid-template-columns: 1fr 1fr; }
  .session-comparison { grid-template-columns: 1fr; }
  .session-gen-grid { grid-template-columns: 1fr 1fr; }
  .lb-session-container { width: 100vw; max-height: 100vh; border: none; }
}
