:root {
  color-scheme: dark;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --bg: #08090b;
  --surface: #111317;
  --text: #f2f5f3;
  --muted: #8b9290;
  --line: rgba(255, 255, 255, .11);
  --accent: #74f2b8;
  --accent-strong: #36d998;
  --danger: #ff776f;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: .19em;
  text-decoration: none;
}

.wordmark-logo {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .24em;
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #c9cecc;
  font-size: 12px;
  white-space: nowrap;
}

.connection-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #69706d;
  transition: background .25s ease, box-shadow .25s ease;
}

.connection-badge.is-live i {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(116, 242, 184, .09), 0 0 18px rgba(116, 242, 184, .5);
  animation: livePulse 2s ease-in-out infinite;
}

.connection-badge.is-error i { background: var(--danger); }

.viewer-workspace {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, rgba(30, 42, 38, .52), transparent 37%),
    #08090b;
}

.remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050506;
  opacity: 0;
  transform: scale(1.012);
  transition: opacity .45s ease, transform .7s cubic-bezier(.2, .8, .2, 1);
}

.viewer-workspace.has-video .remote-video { opacity: 1; transform: scale(1); }

.screen-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.viewer-workspace.has-video .screen-grain { opacity: .035; }

.viewer-header {
  position: absolute;
  z-index: 3;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 28px;
  background: linear-gradient(to bottom, rgba(4, 5, 6, .78), transparent);
}

.header-actions { display: flex; align-items: center; gap: 18px; }

.icon-button, .text-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: .76;
  transition: opacity .2s ease, transform .2s ease;
}
.icon-button:hover, .text-button:hover { opacity: 1; transform: translateY(-1px); }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.text-button { color: #aeb4b1; font-size: 12px; }
.token-copy-button {
  color: var(--accent);
  padding: 7px 11px;
  border: 1px solid rgba(116, 242, 184, .28);
  border-radius: 999px;
  background: rgba(116, 242, 184, .06);
}
.token-copy-button:hover { border-color: rgba(116, 242, 184, .56); }

.empty-state {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: min(560px, calc(100% - 48px));
  text-align: center;
  transform: translate(-50%, -46%);
  animation: stageIn .75s cubic-bezier(.2, .8, .2, 1) both;
  transition: opacity .35s ease, transform .35s ease;
}
.viewer-workspace.has-video .empty-state { opacity: 0; transform: translate(-50%, -43%); pointer-events: none; }
.empty-state h1 { margin: 0 0 14px; font-size: clamp(30px, 4vw, 54px); font-weight: 620; letter-spacing: -.045em; }
.empty-state > p:last-child { margin: 0; color: var(--muted); font-size: 14px; }

.signal-field { position: relative; width: 124px; height: 70px; margin: 0 auto 26px; }
.signal-field span {
  position: absolute;
  top: 50%; left: 50%;
  border: 1px solid rgba(116, 242, 184, .3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: signalWave 2.8s ease-out infinite;
}
.signal-field span:nth-child(2) { animation-delay: .7s; }
.signal-field span:nth-child(3) { animation-delay: 1.4s; }

.metrics-band {
  position: absolute;
  z-index: 4;
  right: 20px;
  bottom: 20px;
  left: 20px;
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
  background: rgba(7, 8, 9, .72);
  border-top: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(20px);
  animation: metricsIn .35s ease both;
}
.metrics-band dl, .agent-metrics dl { min-width: 0; margin: 0; padding: 13px 18px; border-right: 1px solid var(--line); }
.metrics-band dl:last-child, .agent-metrics dl:last-child { border-right: 0; }
.metrics-band dt, .agent-metrics dt { margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.metrics-band dd, .agent-metrics dd { overflow: hidden; margin: 0; font-size: 12px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }

.login-layer {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr);
  background: #090a0c;
  transition: opacity .45s ease, visibility .45s;
}
.login-layer.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.login-copy {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(48px, 7vw, 112px);
  background:
    linear-gradient(110deg, rgba(9,10,12,.18), rgba(9,10,12,.92)),
    radial-gradient(circle at 25% 35%, rgba(116,242,184,.18), transparent 33%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 1px, transparent 1px 72px),
    #101417;
}
.login-wordmark { position: absolute; top: 34px; }
.login-copy h1 { max-width: 720px; margin: 0 0 22px; font-size: clamp(48px, 7vw, 92px); font-weight: 580; line-height: .98; letter-spacing: -.065em; }
.login-copy > p:last-child { max-width: 480px; margin: 0; color: #9ea6a2; font-size: 15px; line-height: 1.65; }
.login-form { align-self: center; padding: 56px; animation: formIn .7s .1s ease both; }
.login-form label { display: block; margin-bottom: 12px; color: #aab0ad; font-size: 12px; }
.password-row { display: flex; border-bottom: 1px solid #4a504e; }
.password-row:focus-within { border-color: var(--accent); }
.password-row input { min-width: 0; flex: 1; padding: 16px 2px; color: var(--text); border: 0; outline: 0; background: transparent; }
.password-row button {
  padding: 0 4px 0 24px;
  color: var(--accent);
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.password-row button:disabled { opacity: .45; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 12px; }


.agent-page { overflow: hidden; }
.agent-shell { min-height: 100vh; display: grid; grid-template-rows: 72px 1fr auto; padding: 0 38px 28px; background: radial-gradient(circle at 70% 30%, rgba(116,242,184,.075), transparent 30%), #0a0b0d; }
.agent-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.capture-stage { display: grid; align-content: center; grid-template-columns: minmax(0, 1fr) auto; gap: 40px; min-height: 360px; padding: 44px 4vw; }
.capture-intro h1 { max-width: 680px; margin: 0 0 14px; font-size: clamp(42px, 6vw, 78px); font-weight: 580; line-height: 1.02; letter-spacing: -.06em; }
.capture-intro > p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.capture-control { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 10px; min-width: 180px; }
.primary-action, .secondary-action { border: 0; cursor: pointer; transition: transform .2s ease, background .2s ease, opacity .2s ease; }
.primary-action { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 24px; color: #07110d; background: var(--accent); font-size: 13px; font-weight: 730; }
.primary-action:hover:not(:disabled) { transform: translateY(-2px); background: #90f7c8; }
.primary-action:disabled { cursor: not-allowed; opacity: .35; }
.action-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.secondary-action { min-height: 42px; color: #b8bfbc; background: transparent; font-size: 12px; }
.secondary-action:hover { color: white; }
.capture-line { grid-column: 1 / -1; height: 1px; margin-top: 34px; overflow: hidden; background: var(--line); }
.capture-line span { display: block; width: 0; height: 100%; background: var(--accent); box-shadow: 0 0 18px rgba(116,242,184,.55); transition: width .7s cubic-bezier(.2,.8,.2,1); }
.agent-status { display: grid; grid-template-columns: 220px 1fr; align-items: stretch; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.status-primary { display: flex; flex-direction: column; justify-content: center; padding: 18px 20px 18px 0; border-right: 1px solid var(--line); }
.status-label { margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.status-primary strong { font-size: 13px; font-weight: 600; }
.agent-metrics { display: grid; grid-template-columns: repeat(6, minmax(90px, 1fr)); }
.agent-error { position: fixed; right: 24px; bottom: 24px; max-width: 420px; padding: 13px 16px; color: #ffd9d6; background: #3b1716; border-left: 2px solid var(--danger); font-size: 12px; }

@keyframes livePulse { 50% { opacity: .5; } }
@keyframes signalWave { 0% { width: 10px; height: 10px; opacity: .9; } 100% { width: 120px; height: 70px; opacity: 0; } }
@keyframes stageIn { from { opacity: 0; transform: translate(-50%, -42%); } }
@keyframes formIn { from { opacity: 0; transform: translateY(18px); } }
@keyframes metricsIn { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 920px) {
  .login-layer { grid-template-columns: 1fr; }
  .login-copy { min-height: 46vh; padding: 64px 30px 36px; }
  .login-copy h1 { font-size: 52px; }
  .login-form { width: 100%; padding: 38px 30px; }
  .metrics-band { grid-template-columns: repeat(4, 1fr); overflow: hidden; }
  .metrics-band dl:nth-child(n+5) { display: none; }
  .capture-stage { grid-template-columns: 1fr; }
  .capture-control { align-items: flex-start; }
  .agent-status { grid-template-columns: 1fr; }
  .status-primary { border-right: 0; border-bottom: 1px solid var(--line); }
  .agent-metrics { grid-template-columns: repeat(3, 1fr); }
  .viewer-header { padding: 0 16px; }
  .header-actions { gap: 10px; }
  .connection-badge { display: none; }
}

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