:root {
  --bg: #0e0f13;
  --surface: #171922;
  --surface-2: #20232e;
  --line: #2a2e3b;
  --text: #eceef3;
  --muted: #9aa0ae;
  --accent: #f6b24b;
  --accent-ink: #1d1503;
  --ok: #3ddc84;
  --warn: #f6b24b;
  --bad: #ff6b6b;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.logo {
  width: 56px;
  height: 56px;
  fill: var(--accent);
}

.logo.small {
  width: 22px;
  height: 22px;
}

/* Sign-in ------------------------------------------------------------------------------------ */

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
  padding: 32px 26px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.card h1 {
  margin: 4px 0 0;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.card p {
  margin: 0;
}

.field {
  width: 100%;
  margin-top: 6px;
}

input[type='password'] {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming in on focus */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}

input[type='password']:focus-visible {
  border-color: var(--accent);
}

.primary {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  font-weight: 650;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.error {
  color: var(--bad);
  font-size: 14px;
}

/* Viewer ------------------------------------------------------------------------------------- */

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.pill[data-state='live'] .dot {
  background: var(--ok);
  animation: pulse 2s ease-in-out infinite;
}

.pill[data-state='waking'] .dot,
.pill[data-state='connecting'] .dot {
  background: var(--warn);
}

.pill[data-state='trouble'] .dot {
  background: var(--bad);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #000;
}

.stage:fullscreen {
  width: 100vw;
  height: 100vh;
}

/* Sized and rotated from script, so a sideways phone can be turned upright. */
#video {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: translate(-50%, -50%);
  background: #000;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: rgba(8, 9, 12, 0.82);
}

.overlay h2 {
  margin: 6px 0 0;
  font-size: 19px;
  font-weight: 650;
}

.overlay p {
  margin: 0;
  max-width: 34ch;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.panel {
  display: grid;
  gap: 10px;
  padding: 10px max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
}

.stats {
  min-height: 1.45em;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 13px;
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.tool svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool:disabled {
  opacity: 0.45;
  cursor: default;
}

.tool[aria-pressed='true'] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.tool.select {
  padding: 0;
}

.tool select {
  min-height: 40px;
  padding: 0 12px;
  font: inherit;
  font-weight: 550;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 12px;
  outline: none;
  cursor: pointer;
}

.tool select option {
  color: var(--text);
  background: var(--surface);
}

button:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.links {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 13px;
}

.links a,
.link {
  padding: 0;
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

@media (hover: hover) {
  .tool:not(:disabled):not([aria-pressed='true']):hover {
    background: var(--surface-2);
  }

  .links a:hover,
  .link:hover {
    color: var(--text);
  }
}

/* Phones held sideways: give the picture the room. */
@media (max-height: 480px) {
  .bar {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .panel {
    gap: 6px;
    padding-top: 6px;
  }

  .tool span:not(.sr-only),
  .links {
    display: none;
  }

  .tool {
    min-height: 36px;
  }
}

@media (max-width: 420px) {
  .tool span:not(.sr-only) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pill .dot {
    animation: none;
  }

  .spinner {
    animation-duration: 2.4s;
  }
}
