:root { font: 500 16px/1.4 "Helvetica Neue", Helvetica, Arial, sans-serif; color: #f5f5f3; background: #08090b; color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; }
header { padding: 16px 28px; border-bottom: 1px solid #36373a; }
header > div { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 28px; }
.wordmark { font-size: 26px; font-weight: 700; letter-spacing: -1px; text-transform: lowercase; text-decoration: none; display: block }
.title-row { display: flex; flex-basis: 100%; align-items: center; gap: 16px; }
h1 { font-size: 18px; margin: 0; font-weight: 600; color: #b7b8bc; }
h2 { font-size: 18px; margin: 0; font-weight: 650; }
p { margin: 0; color: #c4c5c8; font-size: 15px; overflow-wrap: anywhere; }
a { color: inherit; }
p:empty, [hidden] { display: none !important; }
button, input, select { font: inherit; }
button, .download-button { cursor: pointer; }
.download-button, .dataset-input button { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border: 1px solid transparent; border-radius: 8px; background: #efefed; color: #101113; font-weight: 700; text-decoration: none; white-space: nowrap; }
.download-button { background: #26282c; color: #b7b8bc; font-size: 13px; font-weight: 600; padding: 7px 11px; }
.dataset-input button:hover:not(:disabled) { background: #fff; }
.download-button:hover { background: #4c4e54; }
button:disabled, select:disabled { opacity: .5; cursor: default; }
input, select { color: #f5f5f3; background: #18191c; border: 1px solid #62646b; border-radius: 7px; padding: 10px 12px; }
input::placeholder { color: #b9bbc1; }
.dataset-picker { max-width: 1800px; margin: auto; padding: 14px 28px; border-bottom: 1px solid #36373a; display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); gap: 8px 24px; }
.dataset-picker label { display: block; margin-bottom: 6px; font-weight: 650; }
.dataset-input { display: flex; gap: 8px; }
.dataset-input input, .dataset-input select { min-width: 0; flex: 1; width: 100%; }
#load-status { grid-column: 1/-1; }
main { display: grid; grid-template-columns: minmax(0,1.3fr) minmax(400px,1fr); max-width: 1800px; margin: auto; width: 100%; }
.preview, aside { min-width: 0; padding: 18px 24px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.badge, .reference-tag { color: #eee; background: #303238; border-radius: 5px; padding: 4px 8px; font-size: 14px; }
.stage { position: relative; background: #030405; border: 1px solid #36373a; border-radius: 8px; overflow: hidden; display: grid; place-items: center; min-height: 0; }
canvas { display: block; width: 100%; height: 100%; object-fit: contain; min-height: 0; }
#preview-error { position: absolute; background: #101113ee; padding: 8px; max-width: 90%; }
.overlay-controls { display: flex; align-items: center; gap: 12px; padding: 12px 0; color: #dedee0; }
.overlay-controls input { flex: 1; min-width: 30px; padding: 0; accent-color: #fa4839; }
.overlay-controls output { width: 44px; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.metrics > div { background: #191a1e; border: 1px solid #36373a; border-radius: 8px; padding: 10px; display: grid; gap: 4px; }
.metrics span { font-size: 14px; font-weight: 600; color: #d0d1d4; }
.metrics strong { font-size: clamp(19px,2vw,28px); font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#detail { color: #ffd095; margin-top: 8px; }
aside { border-left: 1px solid #36373a; }
aside select { max-width: 200px; font-size: 15px; }
#count { color: #c4c5c8; margin-left: 6px; }
#episodes { display: grid; gap: 10px; }
.episode { width: 100%; display: grid; grid-template-columns: 88px minmax(0,1fr); gap: 14px; text-align: left; background: #1c1e22; color: inherit; border: 1px solid #46484e; border-radius: 8px; padding: 12px; align-items: center; }
.episode:hover { background: #2c2e34; }
.episode[aria-pressed=true] { border: 2px solid #fa4839; padding: 11px; background: #35201f; }
.episode img { width: 88px; height: 72px; object-fit: contain; background: #08090b; border-radius: 4px; }
.episode .summary { display: grid; gap: 8px; min-width: 0; }
.episode b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 17px; font-weight: 700; }
.episode .values { display: flex; flex-wrap: wrap; gap: 6px; }
.episode small { color: #ffd095; font-size: 14px; }
.metric-tag { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 4px; background: #ffffff08; white-space: nowrap; font-size: 14px; font-variant-numeric: tabular-nums; }
.metric-tag svg { width: 15px; height: 15px; flex: none; }
.severity-orange { color: #ffc16c; }
.severity-red { color: #ff9690; }
#error { padding: 8px 28px; color: #ff9690; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #ff8277; outline-offset: 3px; }
::selection { background: #fa4839; color: #08090b; }
@media(min-width: 1000px) and (min-height: 650px) {
  body { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  header, .dataset-picker, #error { flex: none; }
  .dataset-picker { width: 100%; }
  main { flex: 1; min-height: 0; }
  .preview { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
  .preview > :not(.stage) { flex-shrink: 0; }
  .stage { flex: 1; }
  aside { overflow-y: auto; }
}
@media(max-width: 999px), (max-height: 649px) {
  .stage { height: min(40vh, 360px); }
  main { grid-template-columns: 1fr; }
  aside { border-left: 0; border-top: 1px solid #36373a; }
}
@media(max-width: 650px) {
  header, .dataset-picker, .preview, aside { padding: 16px; }
  .dataset-picker { grid-template-columns: 1fr; }
  .title-row { flex-wrap: wrap; gap: 12px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .dataset-input { flex-wrap: wrap; }
  .dataset-input input, .dataset-input select { flex-basis: 100%; }
}

/* ─── Superception house style: tokens, motion, loading states ───────────────
   Same palette as superception.io. Body copy is kept at #c4c5c8 or brighter
   and labels at #dedee0, so nothing here reads dimmer than before. */
:root {
  --black: #08090a; --panel: #0e0f11; --white: #efefed;
  --dim: #c4c5c8; --label: #dedee0; --line: rgb(185 190 200 / 12%);
  --line-hi: rgb(185 190 200 / 26%);
  --red: #fa4839; --red-hi: #ff6a5e;
  --ease: cubic-bezier(.25, 1, .5, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sheen { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(1turn); } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

body { color: var(--white); -webkit-font-smoothing: antialiased; isolation: isolate; }
/* Red grid and film grain, matching the marketing site's atmosphere. */
body::before, body::after { content: ''; position: fixed; inset: 0; pointer-events: none; }
body::before {
  z-index: -2;
  background-image: radial-gradient(ellipse at top right, #fa483910, transparent 55%),
                    linear-gradient(#fa483908 1px, transparent 1px),
                    linear-gradient(90deg, #fa483908 1px, transparent 1px);
  background-size: auto, 96px 96px, 96px 96px;
}
body::after {
  z-index: -1; opacity: .05; mix-blend-mode: screen; background-size: 180px 180px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

header, .dataset-picker, aside, .stage, .metrics > div { border-color: var(--line); }

/* Company name — red. */
.wordmark { color: var(--red); font-weight: 500; font-size: 26px; letter-spacing: -1px; transition: color .2s var(--ease), text-shadow .2s var(--ease); }
.wordmark:hover { color: var(--red-hi); text-shadow: 0 0 24px #fa483955; }
h1 { color: var(--label); font-weight: 500; letter-spacing: -.02em; }
h2 { font-weight: 550; letter-spacing: -.02em; }
p { color: var(--dim); }

.download-button, .dataset-input button, input, select, .episode, .metrics > div, .stage, .badge, .reference-tag, .metric-tag {
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease), transform .12s var(--ease);
}
.download-button, .dataset-input button { border-radius: 999px; }
.download-button { color: var(--label); background: #1e2024; border-color: var(--line); }
.download-button:hover { background: #2c2e34; border-color: var(--line-hi); }
#load-camera:not(:disabled) { background: var(--red); }
#load-camera:hover:not(:disabled) { background: var(--red-hi); box-shadow: 0 6px 20px #fa483933; }
.dataset-input button:active:not(:disabled), .download-button:active { transform: scale(.975); }
input, select { border-color: #4b4d54; border-radius: 8px; }
input:hover:not(:disabled), select:hover:not(:disabled) { border-color: #74767d; }
input:focus, select:focus { border-color: var(--red); }
.dataset-picker label { color: var(--label); }

.stage { background: #050607; }
.metrics > div { background: #121316; }
.metrics > div:hover { border-color: var(--line-hi); }
.metrics strong { color: #ffffff; font-size: clamp(24px, 2.2vw, 32px); font-weight: 750; line-height: 1.2; opacity: 1; }
.metrics strong.severity-orange { color: #ffc16c; }
.metrics strong.severity-red { color: #ff9690; }
.badge, .reference-tag { background: #ffffff10; color: var(--label); }

/* Episode list */
#episodes .episode { background: #131417; border-color: var(--line); animation: rise .35s var(--ease) both; }
#episodes .episode:nth-child(2) { animation-delay: .03s; }
#episodes .episode:nth-child(3) { animation-delay: .06s; }
#episodes .episode:nth-child(4) { animation-delay: .09s; }
#episodes .episode:nth-child(5) { animation-delay: .12s; }
#episodes .episode:nth-child(6) { animation-delay: .15s; }
#episodes .episode:nth-child(n+7) { animation-delay: .18s; }
.episode:hover { background: #1e2024; border-color: var(--line-hi); transform: translateX(2px); }
.episode:active { transform: translateX(2px) scale(.995); }
.episode[aria-pressed=true] { background: #2a1a19; box-shadow: 0 6px 22px #00000059; }
.episode img { opacity: 0; transition: opacity .35s var(--ease); }
.episode img.loaded { opacity: 1; }
/* Thumbnail skeleton until the frame decodes. */
.episode img:not(.loaded) {
  background-image: linear-gradient(100deg, #101114 35%, #1c1e22 50%, #101114 65%);
  background-size: 200% 100%;
  animation: sheen 2.2s linear infinite;
}
.metric-tag:hover { background: #ffffff14; }

/* ─── Loading states ─── */
/* A spinner ahead of the status line while a dataset or camera is loading. */
#load-status.loading::before, #preview-error.loading::before {
  content: ''; display: inline-block; vertical-align: -2px; margin-right: 8px;
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid #ffffff2e; border-top-color: var(--red);
  animation: spin .7s linear infinite;
}
#load-status.loading { color: var(--label); }
#preview-error.loading { color: var(--label); }
/* The stage sweeps while the overlay frames are being fetched. */
.stage.loading {
  background-image: linear-gradient(100deg, #050607 35%, #16181c 50%, #050607 65%);
  background-size: 200% 100%;
  animation: sheen 2.2s linear infinite;
}
.dataset-picker.busy label { animation: breathe 1.6s ease-in-out infinite; }
#load-camera:disabled, #find-cameras:disabled { opacity: .45; }

#detail:not(:empty), #error:not(:empty) { animation: rise .25s var(--ease) both; }
::selection { background: var(--red); color: var(--black); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .episode img { opacity: 1; }
}

.wordmark { display: inline-flex; align-items: center; gap: 9px; }
.brand-eye { display: block; width: 1em; height: 1em; flex: none; transform: translateY(.08em); }
