:root {
  color-scheme: dark;
  --bg: #090b0f;
  --surface: #11161d;
  --surface-2: #171d25;
  --surface-3: #202834;
  --text: #f4f7fb;
  --muted: #9aa8b7;
  --line: #2b3441;
  --green: #31d39b;
  --blue: #4d8dff;
  --red: #ff5c70;
  --amber: #f1b84b;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.36);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

::selection {
  background: rgba(49, 211, 155, 0.28);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  min-height: 72px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(9, 11, 15, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--green);
  color: #06100d;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-nav a,
.lang-button {
  min-height: 36px;
  border-radius: 7px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
}

.site-nav a:hover,
.lang-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

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

.status {
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
}

.status.ok {
  color: var(--green);
  border-color: rgba(49, 211, 155, 0.42);
}

.status.bad {
  color: var(--red);
  border-color: rgba(255, 92, 112, 0.48);
}

.lang-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  background: rgba(255, 255, 255, 0.04);
}

.lang-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.lang-button.active {
  color: #06100d;
  background: var(--green);
}

.demo-notice {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 28px;
  background: rgba(13, 17, 23, 0.96);
  color: #7f8c9b;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

.lang-button:focus-visible,
.preset-button:focus-visible,
.ghost-button:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(49, 211, 155, 0.72);
  outline-offset: 2px;
}

.home-screen,
.app-shell,
.ops-screen {
  display: none;
}

body.home-page .home-screen,
body.streamer-page .app-shell,
body.viewer-page .app-shell,
body.debug-page .app-shell,
body.ops-page .ops-screen {
  display: block;
}

body.streamer-page .home-screen,
body.viewer-page .home-screen,
body.debug-page .home-screen,
body.ops-page .home-screen,
body.ops-page .app-shell,
body.home-page .app-shell {
  display: none;
}

.hero-section {
  position: relative;
  min-height: calc(100vh - 72px);
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(90deg, rgba(9, 11, 15, 0.98) 0%, rgba(9, 11, 15, 0.82) 58%, rgba(9, 11, 15, 0.38) 100%),
    #0a0d12;
}

.hero-content {
  position: relative;
  z-index: 2;
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 110px 0 96px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

.hero-content h1 {
  font-size: 78px;
  line-height: 0.95;
}

.hero-copy {
  max-width: 590px;
  margin: 24px 0 0;
  color: #d7dee8;
  font-size: 21px;
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 7px;
  padding: 0 18px;
  font-weight: 800;
  transition:
    transform 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease;
}

.primary-link {
  background: var(--green);
  color: #06100d;
}

.secondary-link {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.secondary-button {
  width: auto;
  min-height: 42px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0 14px;
}

.primary-link:hover,
.secondary-link:hover,
button:hover {
  transform: translateY(-1px);
}

.secondary-link:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.hero-meta span {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 7px 12px;
  color: #c8d1dc;
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  font-weight: 700;
}

.hero-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.scene-frame {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(17, 22, 29, 0.92);
  box-shadow: var(--shadow);
}

.frame-main {
  right: min(7vw, 90px);
  top: 13vh;
  width: min(45vw, 680px);
  min-width: 460px;
  aspect-ratio: 16 / 10;
  padding: 14px;
}

.scene-topline {
  width: 42%;
  height: 10px;
  border-radius: 999px;
  background: #2c3542;
}

.scene-video {
  position: relative;
  height: calc(100% - 72px);
  margin-top: 14px;
  overflow: hidden;
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(49, 211, 155, 0.2), rgba(77, 141, 255, 0.16)),
    #05070a;
}

.scene-video span {
  position: absolute;
  display: block;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.16);
}

.scene-video span:nth-child(1) {
  left: 8%;
  bottom: 15%;
  width: 38%;
  height: 42%;
}

.scene-video span:nth-child(2) {
  right: 9%;
  top: 14%;
  width: 32%;
  height: 24%;
  background: rgba(49, 211, 155, 0.28);
}

.scene-video span:nth-child(3) {
  right: 13%;
  bottom: 16%;
  width: 22%;
  height: 10%;
  background: rgba(255, 255, 255, 0.22);
}

.scene-controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.scene-controls i {
  width: 64px;
  height: 12px;
  border-radius: 999px;
  background: #2c3542;
}

.scene-controls i:first-child {
  background: var(--green);
}

.frame-chat {
  right: 42px;
  bottom: 12vh;
  width: 230px;
  padding: 14px;
}

.frame-chat b,
.frame-chat i {
  display: block;
  border-radius: 999px;
}

.frame-chat b {
  width: 52%;
  height: 12px;
  margin-bottom: 18px;
  background: var(--blue);
}

.frame-chat i {
  height: 10px;
  margin-top: 11px;
  background: #303a47;
}

.frame-chat i:nth-child(3),
.frame-chat i:nth-child(5) {
  width: 68%;
}

.frame-phone {
  right: min(31vw, 470px);
  bottom: 9vh;
  width: 170px;
  aspect-ratio: 9 / 16;
  padding: 10px;
}

.frame-phone span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 7px;
  background:
    linear-gradient(160deg, rgba(241, 184, 75, 0.22), rgba(77, 141, 255, 0.18)),
    #05070a;
}

.entry-section {
  background: #0d1117;
  padding: 38px 0;
}

.entry-inner,
.feature-section {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
}

.entry-inner {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 16px;
}

.entry-panel,
.feature,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.entry-panel {
  display: grid;
  align-content: start;
  gap: 18px;
  min-height: 300px;
  padding: 22px;
  transition:
    border-color 150ms ease,
    transform 150ms ease,
    background-color 150ms ease;
}

.entry-panel:hover,
.feature:hover {
  border-color: rgba(49, 211, 155, 0.28);
  background: #131922;
}

.entry-panel h2 {
  font-size: 25px;
}

.entry-panel p,
.feature span {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.form-grid,
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
}

input::placeholder {
  color: #6f7e8f;
}

input:focus,
select:focus {
  outline: 2px solid rgba(77, 141, 255, 0.5);
  outline-offset: 1px;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: white;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background-color 150ms ease,
    opacity 150ms ease;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.entry-panel button,
.control-panel > button {
  width: 100%;
}

.feature-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 20px 0 54px;
}

.feature {
  padding: 18px;
}

.feature strong {
  display: block;
  font-size: 16px;
}

.ops-screen {
  min-height: calc(100vh - 72px);
  background: #0d1117;
}

.ops-inner {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.ops-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.ops-hero h1 {
  font-size: 34px;
  line-height: 1.1;
}

.ops-hero p:last-child {
  max-width: 620px;
  margin: 10px 0 0;
  color: var(--muted);
}

.ops-login {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
}

.ops-login[hidden],
.ops-dashboard[hidden] {
  display: none;
}

.ops-login h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.ops-login p {
  margin: 0;
  color: var(--muted);
}

.ops-login-form {
  display: grid;
  gap: 10px;
}

.ops-login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.ops-login-form button {
  width: 100%;
}

.ops-login-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
}

.ops-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.ops-kpi,
.ops-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.ops-kpi {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.ops-kpi span,
.ops-panel-title span,
.ops-list dt {
  color: var(--muted);
  font-size: 13px;
}

.ops-kpi strong {
  font-size: 30px;
  line-height: 1;
}

.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 16px;
  margin-bottom: 16px;
}

.ops-panel {
  padding: 18px;
}

.ops-panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.ops-panel-title h2 {
  font-size: 16px;
}

.ops-table-wrap {
  overflow-x: auto;
}

.ops-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.ops-quality-panel {
  margin-bottom: 16px;
}

.ops-quality-panel .ops-table {
  min-width: 1120px;
}

.ops-table th,
.ops-table td {
  border-top: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

.ops-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ops-table td {
  font-size: 14px;
}

.ops-empty {
  color: var(--muted);
}

.ops-health {
  font-weight: 800;
}

.ops-health.good {
  color: var(--green);
}

.ops-health.warn {
  color: var(--amber);
}

.ops-health.bad {
  color: var(--red);
}

.ops-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.ops-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.ops-list dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1.15;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(260px, 0.9fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

.control-panel {
  grid-row: span 2;
}

.video-panel {
  grid-column: 1 / -1;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-title h2 {
  font-size: 16px;
}

.panel-title span {
  color: var(--muted);
  font-size: 13px;
}

.copy-row {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 8px;
}

.copy-row button {
  min-height: 44px;
}

.metric-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.metric-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.metric-list dt {
  color: var(--muted);
  font-size: 13px;
}

.metric-list dd {
  margin: 0;
  text-align: right;
  font-weight: 800;
}

.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.video-grid div {
  display: grid;
  gap: 8px;
}

.video-grid span {
  color: var(--muted);
  font-size: 13px;
}

video,
#remoteCanvas {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #05070a;
  object-fit: contain;
}

#remoteVideoStage {
  position: relative;
  display: block;
}

#remoteVideoStage .viewer-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(5, 7, 10, 0.86);
  border-radius: 7px;
  color: #e8edf4;
  font-size: 14px;
  text-align: center;
  padding: 16px;
}

#remoteVideoStage .viewer-overlay[hidden] {
  display: none;
}

.viewer-overlay-sub {
  color: var(--muted);
  font-size: 12px;
}

.viewer-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: #5b8cff;
  border-radius: 50%;
  animation: viewer-spin 0.9s linear infinite;
}

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

#remoteVideoStage .viewer-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(transparent, rgba(5, 7, 10, 0.78));
  border-radius: 0 0 7px 7px;
  opacity: 0;
  transition: opacity 0.18s ease;
}

#remoteVideoStage .viewer-controls[hidden] {
  display: none;
}

#remoteVideoStage:hover .viewer-controls,
#remoteVideoStage:focus-within .viewer-controls {
  opacity: 1;
}

.viewer-controls button {
  background: rgba(20, 24, 32, 0.92);
  color: #e8edf4;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
}

.viewer-controls button:hover {
  border-color: #5b8cff;
}

.picture-toolbar {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 14px;
  margin-bottom: 18px;
}

.picture-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.picture-heading strong {
  display: block;
  font-size: 15px;
}

.picture-heading span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.ghost-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0 12px;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.preset-button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  padding: 0 10px;
  white-space: nowrap;
}

.preset-button.active {
  border-color: rgba(49, 211, 155, 0.55);
  background: rgba(49, 211, 155, 0.14);
  color: var(--text);
}

.picture-sliders {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.picture-sliders label {
  margin-bottom: 0;
}

.picture-sliders input[type="range"] {
  min-height: 28px;
  padding: 0;
  accent-color: var(--green);
}

.video-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#peerState.running {
  color: var(--green);
}

#peerState.error {
  color: var(--red);
}

.creator-auth {
  display: none;
}

body.streamer-page .creator-auth {
  display: grid;
}

body.viewer-page .metrics-panel,
body.viewer-page .peer-panel,
body.viewer-page .advanced-field,
body.viewer-page .video-metrics,
body.viewer-page .viewer-link-field,
body.viewer-page .streamer-only,
body.streamer-page .metrics-panel,
body.streamer-page .peer-panel,
body.streamer-page .advanced-field,
body.streamer-page .video-metrics {
  display: none;
}

body.viewer-page .control-panel,
body.streamer-page .control-panel {
  grid-row: auto;
}

body.viewer-page .layout,
body.streamer-page .layout {
  grid-template-columns: minmax(280px, 0.72fr) minmax(360px, 1.28fr);
}

body.viewer-page .video-panel,
body.streamer-page .video-panel {
  grid-column: auto;
}

body.viewer-page #localVideoWrap {
  display: none;
}

body.viewer-page .video-grid {
  grid-template-columns: 1fr;
}

body.streamer-page #remoteVideoWrap {
  display: none;
}

body.streamer-page .video-grid {
  grid-template-columns: 1fr;
}

@media (max-width: 900px) {
  .site-header {
    grid-template-columns: 1fr auto;
    padding: 0 16px;
  }

  .demo-notice {
    padding: 8px 16px;
  }

  .site-nav {
    display: none;
  }

  .hero-content {
    padding: 76px 0 64px;
  }

  .hero-content h1 {
    font-size: 56px;
  }

  .hero-copy {
    font-size: 18px;
  }

  .frame-main {
    right: -180px;
    top: 18vh;
    min-width: 420px;
    opacity: 0.42;
  }

  .frame-chat,
  .frame-phone {
    display: none;
  }

  .entry-inner,
  .feature-section,
  .layout,
  .ops-login,
  .ops-kpis,
  .ops-grid,
  body.viewer-page .layout,
  body.streamer-page .layout {
    grid-template-columns: 1fr;
  }

  body.viewer-page .video-panel,
  body.streamer-page .video-panel {
    grid-column: 1;
  }
}

@media (max-width: 640px) {
  .header-actions {
    gap: 6px;
  }

  .status {
    display: none;
  }

  .hero-section {
    min-height: auto;
  }

  .hero-content {
    width: min(100vw - 22px, 560px);
    padding: 58px 0 48px;
  }

  .hero-content h1 {
    font-size: 44px;
  }

  .hero-copy {
    font-size: 16px;
  }

  .hero-actions,
  .form-grid,
  .field-grid,
  .copy-row,
  .video-grid,
  .picture-sliders,
  .preset-row,
  .video-metrics {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    display: grid;
  }

  .entry-inner,
  .feature-section,
  .shell {
    width: min(100vw - 20px, 560px);
  }

  .entry-panel {
    min-height: auto;
    padding: 18px;
  }

  .feature-section {
    padding-bottom: 32px;
  }

  .topbar,
  .panel-title,
  .ops-hero,
  .ops-panel-title,
  .metric-list div {
    display: grid;
    align-items: start;
  }

  .metric-list dd {
    text-align: start;
  }
}
