:root {
  color-scheme: dark;
  --bg: #080b12;
  --panel: rgba(18, 24, 38, 0.88);
  --panel-strong: #121827;
  --card: #151d30;
  --line: rgba(148, 163, 184, 0.18);
  --text: #eef4ff;
  --muted: #9aa8bd;
  --accent: #5eead4;
  --accent-strong: #2dd4bf;
  --blue: #60a5fa;
  --danger: #fb7185;
  --warning: #fbbf24;
  --ok: #34d399;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(45, 212, 191, 0.2), transparent 32rem),
    radial-gradient(circle at 80% 10%, rgba(96, 165, 250, 0.16), transparent 30rem),
    linear-gradient(135deg, #070a11 0%, #101827 48%, #080b12 100%);
  color: var(--text);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}
.app-shell.viewer-only {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
.compact-hero {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 30;
  display: block;
  align-items: start;
  margin: 0;
  pointer-events: none;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2 { margin: 0; }
h1 { font-size: clamp(2.4rem, 5vw, 4.8rem); line-height: 0.95; letter-spacing: -0.06em; }
h2 { font-size: 1.7rem; letter-spacing: -0.03em; }
.viewer-only h1 { font-size: 1.45rem; letter-spacing: 0; }
.subtitle, .muted { color: var(--muted); line-height: 1.65; }
.subtitle { max-width: 720px; margin: 16px 0 0; font-size: 1.02rem; }
.compact-hero .eyebrow, .compact-hero .subtitle { display: none; }

.socket-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(8, 11, 18, 0.62);
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.socket-card small { display: block; color: var(--muted); margin-top: 3px; }
.embedded-socket {
  width: 100%;
  min-width: 0;
  margin: 12px 0 14px;
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: none;
  background: rgba(2, 6, 23, 0.34);
}
.pulse {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--warning);
  box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.13);
}
.pulse.online { background: var(--ok); box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.13); }
.pulse.offline { background: var(--danger); box-shadow: 0 0 0 6px rgba(251, 113, 133, 0.13); }

.tabs {
  display: inline-flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(8, 11, 18, 0.58);
  margin-bottom: 16px;
}
.tab {
  border: 0;
  border-radius: 13px;
  padding: 12px 18px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}
.tab.active {
  color: #04111b;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  box-shadow: 0 10px 26px rgba(45, 212, 191, 0.24);
}

.notice {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 14px;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.08);
  font-size: 0.9rem;
}
.notice strong { margin-right: 8px; color: #fef3c7; }

.panel { display: none; }
.panel.active { display: block; }
.panel-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}
.viewer-layout {
  display: block;
}

.control-card, .screen-card, .log-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.control-card { padding: 24px; }
.viewer-only .control-card {
  position: fixed;
  left: 12px;
  top: 58px;
  z-index: 40;
  width: 300px;
  padding: 18px;
  overflow: auto;
  max-height: calc(100vh - 70px);
  background: rgba(18, 24, 38, 0.82);
}
.viewer-only.tools-connected .control-card {
  left: auto;
  top: auto;
  right: 16px;
  bottom: 16px;
  width: 320px;
  max-height: calc(100vh - 32px);
}
.viewer-only.tools-collapsed .control-card {
  display: none;
}
.tools-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.viewer-tools-collapse {
  flex: 0 0 auto;
}
.viewer-tools-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 45;
  display: grid;
  gap: 3px;
  min-width: 156px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: rgba(18, 24, 38, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.viewer-tools-fab[hidden] { display: none !important; }
.viewer-tools-fab span {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
}
.viewer-tools-fab strong {
  font-size: 0.98rem;
}
.screen-card { overflow: hidden; min-height: 430px; }
.viewer-only .screen-card { min-height: 100vh; }
.log-card { margin-top: 18px; padding: 18px; }

.primary-button, .ghost-button {
  width: 100%;
  border-radius: 16px;
  border: 0;
  padding: 15px 18px;
  margin-top: 14px;
  font-weight: 900;
}
.primary-button {
  color: #04111b;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  box-shadow: 0 14px 34px rgba(45, 212, 191, 0.26);
}
.native-button {
  background: linear-gradient(135deg, #fbbf24, #fb7185);
}
.ghost-button {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, 0.08);
}
.download-button {
  display: block;
  text-align: center;
  text-decoration: none;
}
.tiny-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
}

.code-box {
  margin: 20px 0;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(94, 234, 212, 0.25);
  background: rgba(94, 234, 212, 0.08);
}
.code-box span { display: block; color: var(--muted); font-size: 0.84rem; margin-bottom: 6px; }
.code-box strong {
  display: block;
  font-size: 2.5rem;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
}

.input-label { display: block; margin: 20px 0 8px; color: var(--muted); font-weight: 800; }
.viewer-only .input-label { margin-top: 14px; }
.code-input {
  width: 100%;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  outline: none;
  color: var(--text);
  background: rgba(2, 6, 23, 0.55);
  font-size: 1.5rem;
  letter-spacing: 0.2em;
  text-align: center;
}
.viewer-only .code-input { padding: 12px 14px; }
.code-input:focus, .remote-stage:focus { border-color: rgba(94, 234, 212, 0.7); box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.1); }

.file-transfer {
  margin-top: 10px;
}
.file-transfer input[type="file"] {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(2, 6, 23, 0.42);
}
.transfer-status {
  margin: 8px 0 0;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.status-list { margin: 18px 0 0; }
.viewer-only .status-list { margin-top: 12px; }
.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.viewer-only .status-list div { padding: 9px 0; }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; text-align: right; font-weight: 800; }

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.38);
}
.viewer-only .screen-header { display: none; }
.viewer-only .screen-header strong { display: none; }
.screen-header span {
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(94, 234, 212, 0.1);
  font-size: 0.82rem;
  font-weight: 800;
}

video {
  width: 100%;
  height: 100%;
  min-height: 378px;
  display: block;
  object-fit: contain;
  object-position: left top;
  background: #020617;
}
.remote-card { min-height: 560px; }
.viewer-only .remote-card {
  position: fixed;
  inset: 0;
  z-index: 1;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  background: #020617;
}
.remote-stage {
  position: relative;
  width: 100vw;
  min-height: 100vh;
  height: 100vh;
  display: grid;
  place-items: start;
  outline: none;
  border: 1px solid transparent;
  background: #020617;
  overflow: hidden;
  touch-action: none;
}
.remote-stage video, .native-canvas { min-height: 0; }
.native-canvas, .remote-stage video {
  width: 100%;
  height: 100%;
  display: block;
  background: #020617;
  object-fit: contain;
  object-position: left top;
  transform-origin: left top;
  will-change: transform;
}
.remote-stage.panning { cursor: grabbing; }
.remote-stage video[hidden], .native-canvas[hidden] {
  display: none !important;
}
.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}
.empty-state.hidden { display: none; }

.event-log {
  min-height: 110px;
  max-height: 220px;
  overflow: auto;
  padding: 0;
  margin: 0;
  list-style: none;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}
.event-log li { padding: 7px 0; border-bottom: 1px solid rgba(148, 163, 184, 0.1); }

.customer-page {
  min-height: 100vh;
}
.customer-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 18, 0.72);
  backdrop-filter: blur(16px);
}
.customer-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
}
.customer-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(94, 234, 212, 0.4);
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.2), rgba(96, 165, 250, 0.26));
  box-shadow: 0 10px 24px rgba(45, 212, 191, 0.18);
}
.customer-ready {
  margin-left: auto;
  padding: 6px 12px;
  border: 1px solid rgba(52, 211, 153, 0.32);
  border-radius: 999px;
  color: var(--ok);
  background: rgba(52, 211, 153, 0.1);
  font-size: 0.8rem;
  font-weight: 900;
}
.customer-shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 46px 0 42px;
}
.customer-hero {
  max-width: 780px;
  margin: 0 auto;
  padding: 26px 0 26px;
  text-align: center;
}
.customer-hero h1 {
  font-size: clamp(2.2rem, 7vw, 4.6rem);
  letter-spacing: 0;
}
.hero-badge {
  display: inline-block;
  margin: 0 0 18px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
  font-size: 0.82rem;
  font-weight: 900;
}
.customer-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
  margin: 10px 0 26px;
}
.customer-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 24, 38, 0.76);
  box-shadow: var(--shadow);
}
.customer-card-primary {
  background:
    linear-gradient(135deg, rgba(94, 234, 212, 0.14), rgba(96, 165, 250, 0.1)),
    rgba(18, 24, 38, 0.82);
}
.card-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
}
.customer-card h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}
.customer-card p:not(.card-kicker) {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.customer-download {
  display: inline-flex;
  width: 100%;
  justify-content: center;
  text-decoration: none;
}
.customer-viewer-link {
  display: inline-flex;
  width: 100%;
  justify-content: center;
  text-decoration: none;
}
.customer-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.customer-steps article {
  min-height: 168px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 24, 38, 0.72);
}
.customer-steps span {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 14px;
  border-radius: 999px;
  color: #04111b;
  background: var(--accent);
  font-weight: 900;
}
.customer-steps strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.05rem;
}
.customer-steps p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}
.customer-footer {
  margin-top: 24px;
  text-align: right;
}
.customer-footer a {
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 920px) {
  .hero, .panel-grid { grid-template-columns: 1fr; display: grid; }
  .hero { display: grid; }
  .socket-card { min-width: 0; }
  .customer-grid { grid-template-columns: 1fr; }
  .customer-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 20px; }
  .tabs { display: grid; width: 100%; }
  .panel-grid { gap: 12px; }
  .control-card { padding: 18px; }
  .code-box strong { font-size: 2rem; }
  .customer-bar { padding: 12px 16px; }
  .customer-ready { display: none; }
  .customer-shell { width: min(100% - 20px, 920px); padding-top: 28px; }
  .customer-steps { grid-template-columns: 1fr; }
  .customer-download { width: 100%; }
}
