:root {
  color-scheme: dark;
  --canvas: #000000;
  --ink: #fcfdff;
  --body: rgba(252, 253, 255, 0.86);
  --charcoal: rgba(252, 253, 255, 0.7);
  --mute: #a1a4a5;
  --ash: #888e90;
  --stone: #464a4d;
  --surface-card: #0a0a0c;
  --surface-elevated: #101012;
  --surface-deep: #06060a;
  --surface-light: #f1f7fe;
  --hairline: rgba(255, 255, 255, 0.06);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --divider-soft: rgba(255, 255, 255, 0.04);
  --accent-blue: #3b9eff;
  --accent-blue-glow: rgba(0, 117, 255, 0.34);
  --accent-green: #11ff99;
  --accent-green-glow: rgba(34, 255, 153, 0.18);
  --accent-red: #ff2047;
  --accent-yellow: #ffc53d;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(circle at 50% 0, var(--accent-blue-glow), transparent 520px),
    var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
select,
input {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
}

.app {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 32px 64px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 32px 0 48px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--charcoal);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  font-family: "Domaine Display", "Tiempos Headline", Georgia, serif;
  font-size: 5.75rem;
  font-weight: 400;
  line-height: 1;
  font-feature-settings: "ss01", "ss04", "ss11";
}

h2 {
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.4;
}

.intro,
.panel-head p,
.meta,
.message {
  margin: 0;
  color: var(--charcoal);
}

.intro {
  max-width: 620px;
  margin-top: 18px;
  color: var(--body);
  font-size: 1.125rem;
}

.panel {
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  background: var(--surface-card);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--hairline);
}

.panel-head.compact {
  padding: 16px 20px;
}

.server-status,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 9999px;
  background: var(--surface-elevated);
  color: var(--body);
  font-size: 0.75rem;
}

.server-status::before,
.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: var(--stone);
}

.server-status.is-ok::before,
.pill.is-ok::before {
  background: var(--accent-green);
}

.server-status.is-warn::before,
.pill.is-warn::before {
  background: var(--accent-yellow);
}

.server-status.is-error::before,
.pill.is-error::before {
  background: var(--accent-red);
}

.camera-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 20px 32px 32px;
}

.camera-link-item {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
}

.camera-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  background: var(--surface-deep);
  color: var(--body);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  word-break: break-word;
}

.camera-links .share-link {
  height: 100%;
  color: var(--ink);
}

.camera-links .share-link.is-copied {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.share-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  pointer-events: none;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.preview-stage {
  position: relative;
  display: grid;
  height: 360px;
  place-items: center;
  overflow: hidden;
  background: var(--surface-deep);
}

.preview-stage img,
.preview-stage video {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-stage.has-image img,
.preview-stage.has-image video {
  display: block;
}

.placeholder {
  margin: 0;
  padding: 24px;
  color: var(--mute);
  text-align: center;
}

.preview-stage.has-image .placeholder {
  display: none;
}

.preview-card .meta {
  padding: 12px 20px 20px;
  font-size: 0.875rem;
}

.anaglyph-panel {
  position: relative;
  overflow: hidden;
  margin-top: 16px;
}

.anaglyph-panel::before {
  content: "";
  position: absolute;
  top: -220px;
  right: 8%;
  width: 520px;
  height: 520px;
  border-radius: 9999px;
  background: radial-gradient(circle, var(--accent-green-glow), transparent 68%);
  pointer-events: none;
}

.anaglyph-layout {
  position: relative;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  padding: 24px 32px 32px;
}

.anaglyph-controls {
  display: grid;
  gap: 12px;
  align-content: start;
}

.control {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface-deep);
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.control-row label {
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
}

.control output {
  color: var(--charcoal);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--ink);
}

.toggle-row,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  background: var(--surface-deep);
  color: var(--body);
  cursor: pointer;
}

.toggle input {
  accent-color: var(--ink);
}

.anaglyph-stage {
  position: relative;
  display: grid;
  height: 560px;
  place-items: center;
  overflow: auto;
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  background: var(--surface-deep);
}

.anaglyph-stage canvas {
  display: block;
  width: 100%;
  height: auto;
}

.anaglyph-stage.has-image .placeholder {
  display: none;
}

.preview-actions,
.fullscreen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.fullscreen-actions {
  flex-wrap: nowrap;
}

.fullscreen-actions .btn {
  width: auto;
}

.fullscreen-actions .btn-icon {
  width: 36px;
}

.fullscreen-preview {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #000000;
}

.fullscreen-preview[hidden] {
  display: none;
}

.preview-open {
  overflow: hidden;
}

.fullscreen-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--hairline-strong);
  background: rgba(0, 0, 0, 0.86);
}

.fullscreen-toolbar h2 {
  font-size: 1.125rem;
}

.fullscreen-toolbar p:last-child {
  margin: 4px 0 0;
  color: var(--charcoal);
  font-size: 0.875rem;
}

.btn-icon {
  width: 36px;
  padding: 0;
}

.fullscreen-canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 16px;
}

.fullscreen-canvas-wrap canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.fullscreen-canvas-wrap .placeholder[hidden] {
  display: none;
}

.capture-panel {
  margin-top: 16px;
}

.capture-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 24px 32px 12px;
}

.message {
  padding: 0 32px 24px;
  font-size: 0.875rem;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--charcoal);
  font-size: 0.75rem;
  font-weight: 400;
}

.field select {
  width: 100%;
  height: 40px;
  padding: 10px 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  background: var(--surface-card);
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  background: var(--surface-elevated);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-card);
  border-color: rgba(255, 255, 255, 0.28);
}

.btn:disabled {
  cursor: not-allowed;
  color: var(--stone);
  opacity: 0.5;
}

.btn-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #000000;
}

.btn-primary:hover:not(:disabled) {
  background: var(--surface-light);
  border-color: var(--surface-light);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 24px 32px 32px;
}

.result-card {
  overflow: hidden;
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  background: var(--surface-deep);
}

.result-image {
  display: grid;
  height: 300px;
  place-items: center;
  color: var(--mute);
  background: var(--surface-deep);
}

.result-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.result-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
  color: var(--charcoal);
}

.result-links a {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}

.camera-page {
  overflow: hidden;
}

.camera-page body,
body.camera-page {
  background: #000000;
}

.camera-shell {
  position: relative;
  height: 100vh;
  background: #000000;
}

#cameraVideo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000000;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  pointer-events: none;
}

.camera-header,
.camera-controls,
.camera-note {
  pointer-events: auto;
}

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

.camera-header h1 {
  font-size: 1.6rem;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-weight: 500;
}

.camera-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  background: rgba(10, 10, 12, 0.78);
  backdrop-filter: blur(16px);
}

.camera-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--charcoal);
}

@media (max-width: 1024px) {
  h1 {
    font-size: 4.75rem;
  }

  .anaglyph-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .topbar,
  .panel-head,
  .camera-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-grid,
  .result-grid,
  .camera-links {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 3.5rem;
  }

  .preview-stage {
    height: 300px;
  }

  .anaglyph-stage {
    height: 360px;
  }

  .capture-actions,
  .camera-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .btn,
  .field {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 28px 16px 40px;
  }

  .topbar {
    padding: 20px 0 32px;
  }

  h1 {
    font-size: 2.75rem;
  }

  .panel-head,
  .camera-links,
  .anaglyph-layout,
  .capture-actions,
  .result-grid {
    padding-right: 16px;
    padding-left: 16px;
  }

  .message {
    padding-right: 16px;
    padding-left: 16px;
  }

  .preview-stage {
    height: 235px;
  }

  .result-image {
    height: 235px;
  }

  .anaglyph-stage {
    height: 300px;
  }

  .camera-overlay {
    padding: 12px;
  }
}
