:root {
  --bg: #0b0e13;
  --panel: #141922;
  --line: #232b38;
  --text: #e6e9ef;
  --muted: #7d8696;
  --yellow: #ffc400;
  --crimson: #8f1d2c;
  --alert: #ff3b3b;
  --pass: #2ecc8f;
  --human: #ff9f1c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 44px 44px;
  min-height: 100vh;
}

/* ---------- top ---------- */
.hazard-strip {
  height: 6px;
  background: repeating-linear-gradient(45deg, var(--yellow) 0 12px, #3a0f16 12px 24px);
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,14,19,.8);
  backdrop-filter: blur(6px);
}
.brand { letter-spacing: .18em; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.brand b { color: var(--yellow); font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 10px var(--yellow); animation: blink 2s infinite; }
.sys { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--pass); letter-spacing: .12em; }

/* ---------- hero ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 0 24px 64px; }
.hero { position: relative; padding: 64px 0 40px; }
.hero::before {
  content: ""; position: absolute; left: -80px; top: -20px; width: 560px; height: 360px;
  background: radial-gradient(closest-side, rgba(143,29,44,.55), transparent);
  z-index: -1; filter: blur(10px);
}
.eyebrow { font-family: "JetBrains Mono", monospace; color: var(--yellow); letter-spacing: .25em; font-size: 12px; margin-bottom: 14px; }
.hero h1 { font-size: clamp(32px, 5vw, 56px); line-height: 1.05; font-weight: 700; max-width: 14em; }
.hero h1 span { color: var(--yellow); }
.sub { margin-top: 16px; max-width: 38em; color: var(--muted); font-size: 17px; line-height: 1.5; }

/* ---------- layout ---------- */
.console {
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-areas:
    "upload viewer"
    "cloud viewer"
    "detections trace";
  gap: 18px;
}
.upload-panel { grid-area: upload; }
.cloud-panel { grid-area: cloud; }
.viewer-panel { grid-area: viewer; }
.detections-panel { grid-area: detections; }
.trace-panel { grid-area: trace; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  position: relative;
}
.panel::after {
  content: ""; position: absolute; left: 20px; right: 20px; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--crimson), var(--yellow), transparent);
  opacity: .8;
}
.panel h2 {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px; font-weight: 600;
}

/* ---------- upload ---------- */
.dropzone {
  display: block; text-align: center; cursor: pointer;
  padding: 34px 16px;
  border: 2px dashed rgba(255,196,0,.45);
  border-radius: 12px;
  transition: .2s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--yellow); background: rgba(255,196,0,.06); }
.dz-title { font-weight: 700; font-size: 18px; }
.dz-hint { color: var(--muted); margin-top: 6px; font-size: 14px; }
.dz-file { font-family: "JetBrains Mono", monospace; color: var(--yellow); font-size: 12px; margin-top: 10px; word-break: break-all; }

.btn {
  width: 100%; margin-top: 16px; padding: 14px;
  background: var(--yellow); color: #14110a;
  font-family: "JetBrains Mono", monospace; font-weight: 600; letter-spacing: .15em;
  border: 0; border-radius: 10px; cursor: pointer; transition: .2s;
}
.btn:hover:not(:disabled) { box-shadow: 0 0 22px rgba(255,196,0,.45); transform: translateY(-1px); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- viewer ---------- */
.frame {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  background: #07090d; border-radius: 10px;
  display: grid; place-items: center;
}
.frame::before {
  content: ""; position: absolute; inset: 10px; z-index: 3; pointer-events: none;
  background:
    linear-gradient(var(--yellow), var(--yellow)) top left / 24px 2px no-repeat,
    linear-gradient(var(--yellow), var(--yellow)) top left / 2px 24px no-repeat,
    linear-gradient(var(--yellow), var(--yellow)) top right / 24px 2px no-repeat,
    linear-gradient(var(--yellow), var(--yellow)) top right / 2px 24px no-repeat,
    linear-gradient(var(--yellow), var(--yellow)) bottom left / 24px 2px no-repeat,
    linear-gradient(var(--yellow), var(--yellow)) bottom left / 2px 24px no-repeat,
    linear-gradient(var(--yellow), var(--yellow)) bottom right / 24px 2px no-repeat,
    linear-gradient(var(--yellow), var(--yellow)) bottom right / 2px 24px no-repeat;
}
.frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.placeholder { font-family: "JetBrains Mono", monospace; color: #3a4252; letter-spacing: .3em; font-size: 13px; }
.scanline {
  position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 2;
  background: var(--yellow);
  box-shadow: 0 0 18px 6px rgba(255,196,0,.55);
  animation: scan 1.5s linear infinite;
}

.badge {
  margin-top: 16px; text-align: center; padding: 16px;
  font-family: "JetBrains Mono", monospace; font-weight: 600; letter-spacing: .25em; font-size: 18px;
  border-radius: 10px; border: 1px solid;
}
.badge.idle   { color: var(--muted); border-color: var(--line); background: transparent; }
.badge.working{ color: var(--yellow); border-color: rgba(255,196,0,.5); background: rgba(255,196,0,.07); animation: blink 1s infinite; }
.badge.alert  { color: #fff; border-color: var(--alert); background: rgba(255,59,59,.18); animation: pulse 1.4s infinite; }
.badge.pass   { color: var(--pass); border-color: var(--pass); background: rgba(46,204,143,.12); }
.badge.human  { color: var(--human); border-color: var(--human); background: rgba(255,159,28,.12); }

/* ---------- lists ---------- */
ul, ol { list-style: none; }
.empty { color: #3f485a; font-size: 14px; }

#detections li:not(.empty) {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 8px; border-radius: 8px;
  background: #0f131a; border-left: 3px solid var(--pass);
  font-family: "JetBrains Mono", monospace; font-size: 13px;
}
#detections li.violation { border-left-color: var(--alert); }
#detections .conf { color: var(--muted); }
#detections .flag { font-size: 11px; letter-spacing: .12em; color: var(--pass); }
#detections li.violation .flag { color: var(--alert); }

#trace li:not(.empty) {
  position: relative; padding: 0 0 18px 30px;
  font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--text);
}
#trace li:not(.empty)::before {
  content: ""; position: absolute; left: 5px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--yellow); box-shadow: 0 0 10px rgba(255,196,0,.7);
}
#trace li:not(.empty)::after {
  content: ""; position: absolute; left: 9px; top: 18px; bottom: -2px; width: 2px; background: var(--line);
}
#trace li:last-child::after { display: none; }
#trace .step-no { color: var(--yellow); margin-right: 8px; }
#trace .step-detail { color: var(--muted); display: block; margin-top: 3px; }

/* ---------- cloud chips ---------- */
.chip {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  padding: 10px 12px; border-radius: 8px; background: #0f131a;
  font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--muted);
}
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #3a4252; }
.chip.on { color: var(--text); }
.chip.on::before { background: var(--pass); box-shadow: 0 0 10px var(--pass); }
.chip.off::before { background: var(--human); }

/* ---------- animation ---------- */
@keyframes scan  { from { top: 0; } to { top: 100%; } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,59,59,.5); } 50% { box-shadow: 0 0 0 10px rgba(255,59,59,0); } }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  .console { grid-template-columns: 1fr; grid-template-areas: "upload" "viewer" "cloud" "detections" "trace"; }
  .topbar { padding: 14px 18px; }
}
/* ===== live background icons ===== */
.bg-icons { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.ico {
  position: absolute; left: var(--x); top: var(--y);
  width: var(--s); height: var(--s);
  color: rgba(255,196,0,.10);
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
  transform: rotate(var(--r));
  animation: drift var(--d) ease-in-out infinite alternate;
}
.ico.red { color: rgba(190,40,55,.22); }
@keyframes drift {
  from { transform: translate(0, 0) rotate(var(--r)); }
  to   { transform: translate(28px, -44px) rotate(calc(var(--r) + 14deg)); }
}

/* optional: glass panels so icons faintly show through (delete to keep solid) */
.panel { background: rgba(20,25,34,.88); backdrop-filter: blur(4px); }

/* ===== orbiting light around the photo box ===== */
@property --a { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
.frame { --orbit-speed: 3.2s; --orbit-color: var(--yellow); }
.frame::after {
  content: ""; position: absolute; inset: 0; padding: 3px;
  border-radius: 10px; z-index: 4; pointer-events: none;
  background: conic-gradient(from var(--a),
    transparent 0 60%, #fff 62%, var(--orbit-color) 70%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  filter: drop-shadow(0 0 6px var(--orbit-color));
  animation: orbit var(--orbit-speed) linear infinite;
}
@keyframes orbit { to { --a: -360deg; } }
.frame.loaded { --orbit-speed: 9s; }

@media (prefers-reduced-motion: reduce) {
  .ico, .frame::after { animation: none; }
}

/* ===== mouse parallax (JS sets --mx and --my between -1 and 1) ===== */
.ico {
  translate: calc(var(--mx, 0) * var(--s) * -0.3) calc(var(--my, 0) * var(--s) * -0.3);
  transition: translate .35s ease-out;
}

/* ===== result effects ===== */
.log {
  font-family: "JetBrains Mono", monospace; font-size: 13px;
  color: var(--yellow); min-height: 20px; margin-top: 12px; letter-spacing: .05em;
}
.log:not(:empty)::after { content: "▋"; margin-left: 4px; animation: blink 1s infinite; }

.boxes { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.box {
  position: absolute; border: 2px solid var(--alert);
  box-shadow: 0 0 16px rgba(255,59,59,.6), inset 0 0 16px rgba(255,59,59,.15);
  animation: pop .5s ease-out both;
}
.box.ok { border-color: var(--pass); box-shadow: 0 0 16px rgba(46,204,143,.5); }
.box span {
  position: absolute; left: 0; top: 0; padding: 2px 7px;
  background: var(--alert); color: #fff; white-space: nowrap;
  font: 600 11px "JetBrains Mono", monospace; letter-spacing: .05em;
}
.box.ok span { background: var(--pass); color: #04110c; }
@keyframes pop { from { opacity: 0; transform: scale(1.2); } to { opacity: 1; transform: scale(1); } }

#detections li:not(.empty) { flex-wrap: wrap; }
.bar { flex-basis: 100%; height: 4px; background: #1b2230; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--alert); transition: width .8s ease-out; }
#detections li.ok .bar i { background: var(--pass); }

#trace li:not(.empty) { opacity: 0; transform: translateX(-10px); transition: .4s; }
#trace li.show { opacity: 1; transform: none; }



#detections { max-height: 420px; overflow-y: auto; padding-right: 4px; }
#detections li.uncertain { border-left-color: var(--human); }
#detections li.uncertain .flag { color: var(--human); }
#detections li.uncertain .bar i { background: var(--human); }
.box.ok span { display: none; }


.box.ok { border-width: 1px; opacity: .45; box-shadow: none; }
#detections { scrollbar-width: thin; scrollbar-color: #3a4252 transparent; }