:root {
  --bg: #111318;
  --panel: #191d24;
  --panel-2: #212630;
  --panel-3: #11151c;
  --line: #303846;
  --ink: #f4f7fb;
  --muted: #9ea9ba;
  --face: #38bdf8;
  --pose: #34d399;
  --hand: #f59e0b;
  --segmentation: #fb7185;
  --accent: #d9f99d;
  --danger: #fecdd3;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(135deg, #0f1115 0%, #171b22 52%, #101319 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

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

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

.control-panel,
.stage {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 29, 36, 0.92);
  box-shadow: var(--shadow);
}

.control-panel {
  overflow: auto;
  padding: 20px;
}

.app-head,
.setting-title,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.app-head {
  justify-content: flex-start;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  color: #111318;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), #67e8f9);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.8rem, 4vw, 2.45rem);
}

h2 {
  font-size: clamp(1.2rem, 2vw, 1.55rem);
}

.camera-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.version-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
}

.version-tabs a {
  display: grid;
  min-height: 38px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
  text-decoration: none;
}

.version-tabs a.active {
  color: #101319;
  background: var(--accent);
}

.primary-action,
.secondary-action {
  min-height: 46px;
  border-radius: 8px;
  font-weight: 850;
}

.primary-action {
  color: #101319;
  background: var(--accent);
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.setting-card,
.model-list,
.meta-grid,
.experiment-output,
.stats-grid {
  margin-top: 14px;
}

.setting-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
}

.setting-title span,
.select-field span,
.range-field span {
  color: var(--ink);
  font-weight: 800;
}

.setting-title strong,
.model-toggle small,
.status,
.meta-grid span,
.stat-card small {
  color: var(--muted);
}

.select-field,
.range-field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.range-field {
  grid-template-columns: 1fr auto;
}

.range-field input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-2);
  outline: none;
}

.model-list {
  display: grid;
  gap: 10px;
}

.model-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
}

.model-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.model-toggle .switch {
  position: relative;
  width: 46px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0f1319;
}

.model-toggle .switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.model-toggle input:checked + .switch::after {
  transform: translateX(20px);
  background: currentColor;
}

.model-toggle.face {
  color: var(--face);
}

.model-toggle.pose {
  color: var(--pose);
}

.model-toggle.hand {
  color: var(--hand);
}

.model-toggle.segmentation {
  color: var(--segmentation);
}

.model-toggle strong {
  display: block;
  color: var(--ink);
}

.model-toggle small {
  display: block;
  margin-top: 3px;
  line-height: 1.35;
}

.meta-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.meta-grid {
  grid-template-columns: repeat(2, 1fr);
}

.meta-grid div,
.stat-card {
  display: grid;
  gap: 5px;
  padding: 13px;
  background: var(--panel-3);
}

.meta-grid strong,
.stat-card strong {
  font-size: 0.95rem;
}

.experiment-output {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
}

.experiment-output strong {
  font-size: 0.9rem;
}

.experiment-output pre {
  max-height: 190px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font: 0.78rem/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  min-width: 0;
  padding: 14px;
}

.topbar {
  min-height: 58px;
}

.status {
  max-width: 430px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-3);
  font-size: 0.88rem;
  text-align: right;
}

.vision-frame {
  position: relative;
  overflow: hidden;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #080b10;
  background-size: 32px 32px;
}

#video,
#outputCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#video {
  opacity: 0;
  pointer-events: none;
}

#outputCanvas {
  display: block;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: rgba(8, 11, 16, 0.9);
}

.empty-state.is-hidden {
  display: none;
}

.empty-state > * {
  max-width: 460px;
}

.lens-mark {
  display: block;
  width: 128px;
  height: 128px;
  margin: 0 auto 18px;
  border: 14px solid #2e3745;
  border-radius: 50%;
  box-shadow: inset 0 0 0 16px #10151d, inset 0 0 0 30px #273142;
}

.empty-state p {
  margin: 10px auto 0;
  color: var(--muted);
  line-height: 1.5;
}

.stat-card.face {
  border-top: 3px solid var(--face);
}

.stat-card.pose {
  border-top: 3px solid var(--pose);
}

.stat-card.hand {
  border-top: 3px solid var(--hand);
}

.stat-card.segmentation {
  border-top: 3px solid var(--segmentation);
}

.stat-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

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

  .vision-frame {
    min-height: 62vh;
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 8px;
  }

  .control-panel,
  .stage {
    border-radius: 8px;
  }

  .app-head,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .camera-actions,
  .meta-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .status {
    max-width: none;
    text-align: left;
  }
}
