:root {
  --bg: #07090c;
  --panel: #0e1319;
  --line: #1c2631;
  --text: #e8eef4;
  --muted: #7d8b99;
  --accent: #3dff9a;
  --accent-dim: rgba(61, 255, 154, 0.18);
  --warn: #ff3d5e;
  --amber: #ffc23d;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, rgba(61, 255, 154, 0.07), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 3px),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
}

[hidden] { display: none !important; }

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 20px 32px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.masthead { text-align: center; margin-bottom: 36px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font: 12px/1 var(--mono);
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--panel);
}
.badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 5rem);
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 800;
}
.accent { color: var(--accent); text-shadow: 0 0 24px rgba(61, 255, 154, 0.35); }
.poo { display: inline-block; font-size: .85em; transform-origin: 50% 90%; animation: wobble 2.8s ease-in-out infinite; }
@keyframes wobble { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-12deg); } 86% { transform: rotate(10deg); } 94% { transform: rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { .poo { animation: none; } }

.tagline { margin: 14px 0 0; color: var(--muted); font-size: 1.05rem; }

.view { flex: 1; }

/* ---------- Upload ---------- */
#upload-view { max-width: 560px; width: 100%; margin: 0 auto; text-align: center; }

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 24px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: #101a17;
}
.dropzone.drag { transform: scale(1.01); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }

#file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.dz-icon { width: 56px; height: 56px; color: var(--accent); margin-bottom: 8px; }
.dz-title { margin: 0; font-size: 1.2rem; font-weight: 600; }
.dz-sub { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.dz-name { margin: 12px 0 0; font: 13px var(--mono); word-break: break-all; }

#preview {
  display: block;
  max-width: 100%;
  max-height: 260px;
  margin: 0 auto;
  border-radius: 8px;
}

.error { min-height: 1.5em; margin: 12px 0 0; color: var(--warn); font-size: .95rem; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 15px 30px;
  font: 700 1.05rem var(--sans);
  letter-spacing: .01em;
  color: #04120b;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-dim), 0 8px 24px rgba(61, 255, 154, .2);
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, opacity .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 0 6px var(--accent-dim), 0 10px 30px rgba(61, 255, 154, .3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover:not(:disabled) { border-color: var(--muted); box-shadow: none; }

#check-btn {
  margin-top: 8px;
  min-width: 280px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.spinner { display: none; }
#check-btn.loading {
  opacity: 1;
  color: var(--accent);
  background: var(--panel);
  border: 1px solid var(--line);
  font: 600 .95rem var(--mono);
  cursor: progress;
}
#check-btn.loading .spinner {
  display: block;
  width: 16px; height: 16px;
  border: 2px solid var(--accent-dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.engine-status { margin: 10px 0 0; font-size: .85rem; color: var(--muted); }

.privacy { margin: 18px 0 0; color: var(--muted); font-size: .85rem; }

/* ---------- Photo frame + overlay ---------- */
.frame-wrap { display: flex; justify-content: center; align-items: flex-start; }

.photo-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  border-radius: 6px;
  background: #000;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 1px var(--line);
}
.photo-frame img {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  width: auto;
  height: auto;
  transition: filter .35s, transform .9s cubic-bezier(.2,.8,.2,1);
}

/* image "analysis" effects */
.fx-edge    { filter: grayscale(1) contrast(4) brightness(1.15); }
.fx-thermal { filter: invert(1) hue-rotate(180deg) saturate(3.5) contrast(1.4); }
.fx-mono    { filter: grayscale(1) sepia(1) hue-rotate(80deg) saturate(3) brightness(.8); }
.fx-noise   { filter: contrast(2.2) saturate(0) brightness(.9); }
.fx-zoom    { transform: scale(1.6); }
.fx-zoom2   { transform: scale(2.4) translate(8%, -6%); }

.overlay { position: absolute; inset: 0; pointer-events: none; }

.grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--accent-dim) 1px, transparent 1px),
    linear-gradient(90deg, var(--accent-dim) 1px, transparent 1px);
  background-size: 10% 10%;
  opacity: .55;
  animation: gridFlicker 3s steps(2) infinite;
}

.scanline {
  position: absolute; left: 0; right: 0; top: 0;
  height: 26%;
  background: linear-gradient(to bottom, transparent, rgba(61,255,154,.06) 70%, rgba(61,255,154,.35) 98%, var(--accent) 100%);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 6px 18px rgba(61,255,154,.6);
  animation: scan 2.2s ease-in-out infinite alternate;
}

.xh { position: absolute; background: rgba(255,255,255,.55); transition: top .6s cubic-bezier(.3,.9,.3,1), left .6s cubic-bezier(.3,.9,.3,1); }
.xh-h { left: 0; right: 0; height: 1px; top: 50%; }
.xh-v { top: 0; bottom: 0; width: 1px; left: 50%; }

.corner { position: absolute; width: 22px; height: 22px; border: 3px solid var(--accent); }
.corner.tl { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.corner.tr { top: 8px; right: 8px; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: 8px; left: 8px; border-right: 0; border-top: 0; }
.corner.br { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }

.box {
  position: absolute;
  border: 1.5px solid var(--accent);
  background: rgba(61,255,154,.07);
  animation: boxIn .35s cubic-bezier(.2,.9,.3,1.3) both;
}
.box.warn { border-color: var(--warn); background: rgba(255,61,94,.1); }
.box.amber { border-color: var(--amber); background: rgba(255,194,61,.08); }
.box.out { animation: boxOut .3s ease-in both; }
.box-label {
  position: absolute;
  left: -1.5px; bottom: 100%;
  padding: 2px 5px;
  font: 700 10px/1.2 var(--mono);
  letter-spacing: .03em;
  white-space: nowrap;
  color: #04120b;
  background: var(--accent);
}
.box.warn .box-label { background: var(--warn); color: #fff; }
.box.amber .box-label { background: var(--amber); }
.box.label-below .box-label { bottom: auto; top: 100%; }

/* Real detector boxes */
.box.pet {
  z-index: 2;
  border: 3px solid #ff8ad8;
  background: rgba(255, 138, 216, .1);
  box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 0 22px rgba(255, 138, 216, .7);
  animation: boxIn .5s cubic-bezier(.2,.9,.3,1.3) both, catGlow 1.2s ease-in-out .5s infinite alternate;
}
.box.pet .box-label { left: -3px; padding: 3px 7px; font-size: 12px; background: #ff8ad8; color: #2a0620; }
.box.pet.label-inside .box-label { bottom: auto; top: -3px; }
.box.pet.dog {
  border-color: #ffb347;
  background: rgba(255, 179, 71, .1);
  box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 0 22px rgba(255, 179, 71, .7);
  animation-name: boxIn, dogGlow;
}
.box.pet.dog .box-label { background: #ffb347; color: #2a1600; }
@keyframes dogGlow { to { box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 0 40px rgba(255, 179, 71, 1); } }
@keyframes catGlow { to { box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 0 40px rgba(255, 138, 216, 1); } }

/* Cat found mid-scan: the fake scanning gear switches off */
.scanline, .xh { transition: opacity .3s; }
.pet-found .scanline, .pet-found .xh { opacity: 0; }
.pet-found .grid { animation: none; opacity: 0; transition: opacity .3s; }
.bar.done { transition: width .4s ease-out; }

/* "Not shit" verdict */
.is-pet .result-frame img { filter: none; }
.is-pet .stamp {
  border-color: var(--accent);
  color: var(--accent);
  white-space: nowrap;
  font-size: clamp(1.8rem, 6vw, 3.8rem);
  top: auto; bottom: 8%;
  transform: translate(-50%, 0) rotate(-8deg);
  animation-name: stampCat;
}
@keyframes stampCat {
  from { opacity: 0; transform: translate(-50%, 0) rotate(-8deg) scale(3); }
  to   { opacity: 1; transform: translate(-50%, 0) rotate(-8deg) scale(1); }
}
.is-pet .score { border-color: rgba(61,255,154,.45); background: rgba(61,255,154,.07); }
.is-pet .score strong,
.is-pet .metrics .m-val { color: var(--accent); }
.is-pet .metrics .m-bar i { background: var(--accent); }

/* ---------- Scanning layout ---------- */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.console {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font: 12px/1.5 var(--mono);
  overflow: hidden;
}
.console-head {
  display: flex; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  letter-spacing: .08em;
}
.blink { color: var(--warn); animation: pulse 1s steps(2) infinite; }

.log {
  list-style: none;
  margin: 0;
  padding: 10px 14px;
  height: 300px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.log li { display: flex; gap: 8px; justify-content: space-between; padding: 2px 0; color: var(--muted); animation: fadeUp .25s ease-out both; }
.log li.active { color: var(--text); }
.log li.active .txt::after { content: "▋"; margin-left: 3px; color: var(--accent); animation: pulse .8s steps(2) infinite; }
.log .tag { flex: none; font-weight: 700; }
.tag.ok { color: var(--accent); }
.tag.fail { color: var(--warn); }
.tag.warn { color: var(--amber); }

.readouts { margin: 0; padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.readouts div { display: flex; justify-content: space-between; padding: 3px 0; }
.readouts dt { color: var(--muted); }
.readouts dd { margin: 0; color: var(--accent); font-variant-numeric: tabular-nums; }
#ro-shit { color: var(--warn); }

.progress {
  height: 6px;
  margin-top: 24px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #b6ffda);
  box-shadow: 0 0 12px var(--accent);
}
.status { margin: 12px 0 0; text-align: center; font: 15px var(--mono); color: var(--accent); min-height: 1.5em; }

/* ---------- Result ---------- */
.result {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 40px;
  align-items: center;
}

.result-frame img { filter: saturate(.6) brightness(.85); }

.stamp {
  position: absolute;
  top: 50%; left: 50%;
  padding: 6px 22px;
  border: 7px solid var(--warn);
  border-radius: 10px;
  color: var(--warn);
  font: 900 clamp(2.5rem, 9vw, 5.5rem)/1 var(--sans);
  letter-spacing: .08em;
  background: rgba(10, 0, 3, .3);
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  transform: translate(-50%, -50%) rotate(-14deg);
  animation: stamp .45s cubic-bezier(.2,1.6,.4,1) .35s both;
}

.kicker { margin: 0 0 8px; font: 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.verdict h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.1; letter-spacing: -0.02em; }
.verdict-body { margin: 12px 0 0; color: var(--muted); font-size: 1.1rem; }

.score {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 26px;
  padding: 14px 18px;
  border: 1px solid rgba(255,61,94,.4);
  border-radius: 10px;
  background: rgba(255,61,94,.07);
}
.score span { font: 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.score strong { font: 800 2.2rem/1 var(--mono); color: var(--warn); }
.score-note { margin: 6px 0 0; min-height: 1.2em; font-size: .85rem; color: var(--muted); text-align: right; }

.metrics { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
.metrics li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: .92rem; }
.metrics .m-val { font: 12px var(--mono); color: var(--warn); text-align: right; }
.metrics .m-bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.metrics .m-bar i { display: block; height: 100%; width: 0; background: var(--warn); transition: width 1s cubic-bezier(.2,.8,.2,1); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

/* ---------- Footer ---------- */
.foot {
  margin-top: 56px;
  text-align: center;
  font-size: .8rem;
  color: #4b5764;
}

/* ---------- Animations ---------- */
@keyframes pulse { 50% { opacity: .3; } }
@keyframes scan { from { transform: translateY(-100%); } to { transform: translateY(385%); } }
@keyframes gridFlicker { 50% { opacity: .35; } }
@keyframes boxIn { from { opacity: 0; transform: scale(1.4); } to { opacity: 1; transform: scale(1); } }
@keyframes boxOut { to { opacity: 0; transform: scale(.9); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
@keyframes stamp {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(-14deg) scale(3); }
  to   { opacity: 1; transform: translate(-50%, -50%) rotate(-14deg) scale(1); }
}
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(4px); }
  50% { transform: translateX(-4px); }
}
.shake { animation: shake .45s; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .app { padding-top: 32px; }
  .stage, .result { grid-template-columns: 1fr; }
  .log { height: 170px; }
  .photo-frame img { max-height: 50vh; }
  .result { gap: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .scanline { animation-duration: 6s; }
  .grid, .badge .dot, .blink { animation: none; }
}
