:root {
  color-scheme: dark;
  --bg: #060b12;
  --panel: rgba(10, 16, 28, 0.76);
  --panel-strong: rgba(12, 20, 36, 0.92);
  --stroke: rgba(148, 176, 214, 0.18);
  --text: #eaf2ff;
  --muted: #8ea1bf;
  --accent: #5fd7ff;
  --accent-2: #f4c24d;
  --good: #75f0b1;
  --bad: #ff6d87;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(46, 92, 134, 0.22), transparent 34%),
    radial-gradient(circle at 88% 18%, rgba(244, 194, 77, 0.12), transparent 18%),
    linear-gradient(180deg, #05090f 0%, #08111c 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body {
  min-height: 100dvh;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100dvh;
  padding: 16px;
}

.stage {
  position: relative;
  min-height: calc(100dvh - 32px);
  overflow: hidden;
  border: 1px solid rgba(150, 186, 236, 0.14);
  border-radius: calc(var(--radius) + 4px);
  background: rgba(4, 8, 15, 0.88);
  box-shadow: var(--shadow);
}

#camera,
#overlay,
#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#camera {
  object-fit: cover;
  opacity: 0.92;
  transform: scaleX(1);
  filter: saturate(1.08) contrast(1.05) brightness(0.96);
}

#overlay,
#fx {
  pointer-events: none;
}

.stage-vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 7, 15, 0.14), rgba(4, 7, 15, 0.52)),
    radial-gradient(circle at center, transparent 28%, rgba(2, 5, 11, 0.34) 100%);
  pointer-events: none;
}

.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  display: grid;
  grid-template-columns: 1.2fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 12px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 24px rgba(95, 215, 255, 0.35);
}

.brand-name {
  font-size: 1.02rem;
  font-weight: 760;
  letter-spacing: 0.02em;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}

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

.status-chip {
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(95, 215, 255, 0.13);
  border: 1px solid rgba(95, 215, 255, 0.22);
  color: #dff8ff;
  font-size: 0.82rem;
  font-weight: 650;
}

.status-chip.ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: #c8d5eb;
}

.metrics {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.82rem;
}

.center-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(28vw, 220px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  opacity: 0.72;
  z-index: 2;
}

.center-reticle span {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(151, 222, 255, 0.24);
  border-radius: 50%;
}

.center-reticle span:last-child {
  inset: 20%;
  border-color: rgba(244, 194, 77, 0.28);
}

.control-strip {
  position: absolute;
  inset: auto 18px 18px 18px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-end;
  z-index: 5;
}

.control-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.control-group.compact {
  justify-content: flex-end;
}

.primary-btn,
.secondary-btn,
.swatch,
.ghost-link {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.primary-btn {
  background: linear-gradient(135deg, rgba(95, 215, 255, 0.92), rgba(116, 240, 177, 0.78));
  color: #03111c;
  font-weight: 760;
  box-shadow: 0 14px 34px rgba(95, 215, 255, 0.18);
}

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

.primary-btn:active,
.secondary-btn:active,
.swatch:active,
.ghost-link:active {
  transform: translateY(0) scale(0.98);
}

.secondary-btn,
.ghost-link {
  border-color: rgba(164, 193, 231, 0.16);
  color: #d5e2f7;
}

.ghost-link {
  padding: 8px 11px;
  font-size: 0.82rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(164, 193, 231, 0.12);
  color: #d8e3f5;
  font-size: 0.84rem;
  user-select: none;
}

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

.side-rail {
  position: absolute;
  right: 18px;
  top: 92px;
  bottom: 92px;
  width: min(360px, calc(100vw - 32px));
  display: grid;
  grid-template-rows: auto auto;
  gap: 14px;
  z-index: 4;
  pointer-events: none;
}

.panel {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel h2 {
  margin: 0;
  font-size: 0.96rem;
  letter-spacing: 0.02em;
}

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

.swatch {
  padding: 11px 0;
  font-weight: 700;
  min-width: 0;
}

.swatch.blue {
  background: rgba(88, 197, 255, 0.22);
}

.swatch.green {
  background: rgba(112, 241, 177, 0.18);
}

.swatch.violet {
  background: rgba(174, 132, 255, 0.2);
}

.swatch.warm {
  background: rgba(244, 194, 77, 0.18);
}

.swatch.bright {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.field label {
  font-size: 0.82rem;
  color: var(--muted);
}

.field input[type="range"] {
  width: 100%;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.debug-grid div {
  padding: 10px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(164, 193, 231, 0.09);
}

.debug-grid span {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 3px;
}

.debug-grid strong {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: #f3f7ff;
  word-break: break-word;
}

.mini-views {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.mini-views figure {
  margin: 0;
}

.mini-views canvas {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(164, 193, 231, 0.12);
  background: rgba(2, 7, 13, 0.88);
}

.mini-views figcaption {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.log {
  min-height: 94px;
  max-height: 142px;
  overflow: auto;
  padding: 10px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(164, 193, 231, 0.08);
  color: #cdd8e8;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-line;
}

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

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .metrics {
    justify-content: flex-start;
  }

  .side-rail {
    top: auto;
    bottom: 96px;
    right: 16px;
    left: 16px;
    width: auto;
    height: auto;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    padding: 0;
  }

  .stage {
    min-height: 100dvh;
    border-radius: 0;
  }

  .control-strip {
    left: 12px;
    right: 12px;
    bottom: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .control-group {
    justify-content: flex-start;
  }

  .side-rail {
    position: relative;
    inset: auto;
    padding: 0 12px 16px;
    margin-top: 84vh;
    width: auto;
  }
}
