:root {
  color-scheme: dark;
  --bg: #0e1117;
  --surface: #161b22;
  --surface-soft: #1c2331;
  --text: #e6edf3;
  --text-muted: #8b98a5;
  --primary: #7f5af0;
  --primary-hover: #9578ff;
  --accent: #2cb67d;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 20% 20%, rgba(127, 90, 240, 0.12), transparent 55%),
    radial-gradient(circle at 80% 0%, rgba(44, 182, 125, 0.12), transparent 55%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

a {
  color: var(--accent);
}

.app {
  width: min(1200px, 96vw);
  padding: 2.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.topbar {
  text-align: center;
}

.topbar h1 {
  font-size: clamp(2rem, 2.8vw, 2.7rem);
  margin: 0;
}

.tagline {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 1rem;
}

.content {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 320px 1fr;
}

.card {
  background: rgba(22, 27, 34, 0.85);
  border-radius: 18px;
  border: 1px solid rgba(148, 161, 178, 0.12);
  padding: 1.75rem;
  box-shadow: 0 24px 48px rgba(6, 11, 19, 0.35);
  backdrop-filter: blur(12px);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.control-group {
  display: grid;
  gap: 0.75rem;
}

.fitness-card {
  display: grid;
  gap: 0.8rem;
  background: rgba(127, 90, 240, 0.12);
  border: 1px solid rgba(127, 90, 240, 0.24);
  border-radius: 14px;
  padding: 1rem 1.25rem;
}

.fitness-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.fitness-card__title {
  font-weight: 600;
  font-size: 1rem;
}

.fitness-card__value {
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1;
}

.fitness-card__depth {
  display: grid;
  gap: 0.55rem;
}

.fitness-card__depth-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.fitness-card__status {
  color: var(--text);
}

.fitness-card__depth-bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(127, 90, 240, 0.2);
  overflow: hidden;
}

.fitness-card__depth-bar > div {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  width: 0%;
  transition: width 0.18s ease;
}

button {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.2rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 16px 32px rgba(127, 90, 240, 0.3);
}

.primary:hover:not(:disabled),
.primary:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 22px 40px rgba(127, 90, 240, 0.35);
}

.ghost {
  background: rgba(148, 161, 178, 0.08);
  color: var(--text);
  border: 1px solid rgba(148, 161, 178, 0.22);
}

.ghost:hover:not(:disabled),
.ghost:focus-visible {
  background: rgba(148, 161, 178, 0.15);
}

.compact {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: rgba(148, 161, 178, 0.12);
  color: var(--text);
  border-radius: 10px;
  border: 1px solid rgba(148, 161, 178, 0.2);
  font-size: 0.95rem;
}

.status {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.viewer {
  display: grid;
  gap: 1.25rem;
}

.stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #0b0e13;
  min-height: 420px;
  border: 1px solid rgba(148, 161, 178, 0.14);
}

video,
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

video.mirrored,
canvas.mirrored {
  transform: scaleX(-1);
}

.coordinates {
  background: rgba(14, 17, 23, 0.65);
  border-radius: 12px;
  border: 1px solid rgba(148, 161, 178, 0.18);
  padding: 1rem;
  max-height: 220px;
  overflow: auto;
  font-family: "JetBrains Mono", "SFMono-Regular", ui-monospace, monospace;
  font-size: 0.85rem;
  line-height: 1.4;
}

.coordinates.hidden {
  display: none;
}

.debug-panel {
  background: rgba(14, 17, 23, 0.7);
  border-radius: 12px;
  border: 1px solid rgba(148, 161, 178, 0.18);
  padding: 1rem;
  font-family: "JetBrains Mono", "SFMono-Regular", ui-monospace, monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

.debug-panel.hidden {
  display: none;
}

.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (max-width: 960px) {
  .content {
    grid-template-columns: 1fr;
  }
  .stage {
    min-height: 360px;
  }
}

@media (max-width: 600px) {
  .app {
    padding: 1.5rem 0;
  }
  .card {
    padding: 1.25rem;
  }
  video,
  canvas {
    border-radius: 0;
  }
}
