:root {
  color-scheme: light;
  --bg: oklch(0.965 0.006 188);
  --ink: oklch(0.19 0.028 230);
  --muted: oklch(0.43 0.022 230);
  --panel: oklch(0.995 0.003 188);
  --line: oklch(0.86 0.018 210);
  --accent: oklch(0.66 0.13 180);
  --accent-strong: oklch(0.53 0.12 180);
  --danger: oklch(0.57 0.18 28);
  --shadow: 0 8px 24px oklch(0.32 0.03 230 / 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.camera-stage {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - 40px);
  background: oklch(0.1 0.016 230);
  border: 1px solid var(--line);
  border-radius: 16px;
}

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

#camera {
  object-fit: cover;
  transform: scaleX(-1);
}

#trailCanvas {
  pointer-events: none;
}

.status-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(280px, calc(100% - 32px));
  padding: 18px;
  color: white;
  text-align: center;
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease, transform 180ms ease;
}

.status-panel.is-hidden {
  opacity: 0;
  transform: translate(-50%, -46%);
  pointer-events: none;
}

.status-panel p {
  margin: 0;
  color: oklch(0.92 0.012 210);
}

.pulse {
  width: 44px;
  height: 44px;
  border: 3px solid oklch(0.82 0.09 180);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.control-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  min-height: calc(100vh - 40px);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.section-label {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  max-width: 10ch;
  font-size: 2.2rem;
  line-height: 1.08;
  letter-spacing: 0;
  text-wrap: balance;
}

.intro {
  margin: 16px 0 0;
  max-width: 34ch;
  color: var(--muted);
  line-height: 1.65;
  text-wrap: pretty;
}

.actions,
.settings {
  display: grid;
  gap: 12px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid oklch(0.74 0.12 180 / 0.7);
  outline-offset: 3px;
}

.primary-button {
  background: var(--accent);
  color: oklch(0.12 0.022 220);
}

.primary-button:hover {
  background: oklch(0.7 0.13 180);
}

.secondary-button {
  background: oklch(0.93 0.01 210);
  color: var(--ink);
}

.secondary-button:hover {
  background: oklch(0.9 0.015 210);
}

.settings {
  padding-top: 4px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 650;
}

input[type="color"] {
  width: 100%;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

input[type="range"] {
  accent-color: var(--accent-strong);
}

.readout {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  color: var(--muted);
  background: oklch(0.95 0.008 210);
  border-radius: 10px;
}

.state-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  background: var(--danger);
  border-radius: 50%;
}

.state-dot.is-active {
  background: var(--accent-strong);
}

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

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .camera-stage,
  .control-panel {
    min-height: auto;
  }

  .camera-stage {
    aspect-ratio: 3 / 4;
  }

  .control-panel {
    padding: 22px;
  }

  h1 {
    max-width: 14ch;
    font-size: 1.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
