:root {
  --ink: #0d1230;
  --soft: #3f4768;
  --muted: #5a6283;
  --line: #e2e6f2;
  --paper: #f6f7fc;
  --electric: #2b59ff;
  --violet: #7a4dff;
  --magenta: #d63c8f;
  --alert: #ff4d6d;
  --grad: linear-gradient(110deg, #2b59ff, #7a4dff 55%, #d63c8f);
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --sans: "Manrope", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh; font-family: var(--sans); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(40% 40% at 6% 0%, rgba(43, 89, 255, 0.12), transparent 70%),
    radial-gradient(35% 35% at 100% 8%, rgba(255, 111, 174, 0.12), transparent 70%),
    linear-gradient(180deg, #fbf9f4, #f3f5fd 45%, #eef2fd);
  background-attachment: fixed;
}

a { color: inherit; }
:focus-visible { outline: 2.5px solid var(--electric); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 12px; z-index: 10; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 99px; }

.top, main, .foot { width: min(1240px, 100% - 32px); margin-inline: auto; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: -0.02em; }
.brand-orb { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 30% 25%, #fff, transparent 38%), conic-gradient(from 210deg, #2b59ff, #7a4dff, #ff6fae, #13c8e6, #2b59ff); }
.pill-link { font-size: 14px; font-weight: 700; text-decoration: none; padding: 9px 16px; border-radius: 99px; background: var(--ink); color: #fff; transition: transform 0.2s, background 0.3s; white-space: nowrap; }
.pill-link:hover { transform: translateY(-1px); background: var(--violet); }

.hero { padding: 24px 0 26px; max-width: 820px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grad); }
h1 { margin-top: 14px; font-family: var(--display); font-weight: 700; font-size: clamp(2.3rem, 6vw, 4rem); line-height: 1.02; letter-spacing: -0.04em; }
h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { margin-top: 16px; font-size: clamp(16px, 2vw, 18px); color: var(--soft); max-width: 700px; }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.7));
  border: 1px solid rgba(255, 255, 255, 0.95); box-shadow: 0 24px 60px -32px rgba(28, 38, 92, 0.35);
  border-radius: 24px; padding: 18px; min-width: 0;
}
h2 { font-family: var(--display); font-size: 18px; letter-spacing: -0.02em; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1000px) { .workspace { grid-template-columns: minmax(0, 1fr) 340px; } }

/* Buttons */
.btn {
  position: relative; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer; border-radius: 99px;
  padding: 8px 14px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.2s; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--violet); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.active, .btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn.icon { width: 38px; padding: 8px 0; text-align: center; letter-spacing: -2px; }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload:focus-within { outline: 2.5px solid var(--electric); outline-offset: 3px; }

.toolbar, .zone-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* Video screen */
.screen { position: relative; margin: 14px 0; border-radius: 18px; overflow: hidden; background: #05081a; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
#view { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; touch-action: none; }
.screen.drawing #view { cursor: crosshair; }
.screen.flash { animation: flash 0.7s ease-out; }
@keyframes flash { 0% { box-shadow: inset 0 0 0 4px var(--alert), 0 0 0 4px rgba(255, 77, 109, 0.45); } 100% { box-shadow: inset 0 0 0 0 transparent, 0 0 0 0 transparent; } }
.overlay-msg {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center;
  color: #fff; font-weight: 600; background: rgba(5, 8, 26, 0.72); backdrop-filter: blur(4px);
}
.overlay-msg[hidden] { display: none; }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--soft); cursor: pointer; padding: 6px 4px; }
.check input { width: 16px; height: 16px; accent-color: var(--violet); }
.hint { margin-top: 10px; font-size: 12.5px; color: var(--muted); }

/* Side panel */
.side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.stat.wide { grid-column: span 2; }
.stat .k { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.stat strong { font-family: var(--display); font-size: 26px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat.wide strong { font-size: 16px; font-family: var(--mono); letter-spacing: 0; }

.rules { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
@media (min-width: 700px) { .rules { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; } }
.range-field { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--soft); }
.range-field output { font-weight: 800; color: var(--ink); }
.range-field input { accent-color: var(--violet); width: 100%; }

.log-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.events { list-style: none; display: grid; gap: 8px; margin-top: 12px; max-height: 360px; overflow-y: auto; padding-right: 2px; }
.events li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--violet); border-radius: 12px; padding: 6px; }
.events li.intrusion { border-left-color: var(--alert); }
.events li.loitering { border-left-color: #f5a524; }
.events li.crowd { border-left-color: var(--electric); }
.events img { width: 76px; height: 43px; object-fit: cover; border-radius: 8px; background: #05081a; display: block; }
.events .t { font-size: 13.5px; font-weight: 700; }
.events .d { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.empty { margin-top: 10px; font-size: 13px; color: var(--muted); }

/* How it works */
.how { margin-top: 52px; }
.how > h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); letter-spacing: -0.03em; }
.steps { list-style: none; display: grid; gap: 14px; margin-top: 18px; }
@media (min-width: 760px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.steps li { background: rgba(255, 255, 255, 0.75); border: 1px solid #fff; border-radius: 22px; padding: 20px; box-shadow: 0 18px 40px -30px rgba(28, 38, 92, 0.4); }
.steps .num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--grad); color: #fff; font-weight: 700; }
.steps h3 { margin-top: 12px; font-family: var(--display); font-size: 18px; letter-spacing: -0.02em; }
.steps p { margin-top: 6px; font-size: 14.5px; color: var(--soft); }

.foot { padding: 44px 0 32px; font-size: 14px; color: var(--soft); }
.foot a { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.foot .muted { margin-top: 6px; max-width: 820px; }

@media (max-width: 520px) {
  .card { padding: 14px; }
  .btn { font-size: 13px; padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Desktop: the side panel is exactly as tall as the monitor; the event log scrolls inside it */
@media (min-width: 1000px) {
  .side { display: flex; flex-direction: column; min-height: 0; contain: size; }
  .log { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .events { flex: 1; min-height: 120px; max-height: none; }
}
