* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0a0a0f;
  color: #e8e8f0;
  min-height: 100vh;
  padding: 24px;
}
h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
}
.subtitle {
  color: #8888a0;
  font-size: 13px;
  margin-bottom: 20px;
}
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
}
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
}
.panel {
  background: #14141c;
  border: 1px solid #26263a;
  border-radius: 12px;
  padding: 16px;
}
.video-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
}
video { display: none; }
canvas#view {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  cursor: crosshair;
}
.flash {
  position: absolute;
  inset: 0;
  background: rgba(240, 153, 149, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s ease-out;
}
.flash.on { opacity: 1; transition: none; }

.controls { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
button {
  background: #BA7517;
  color: #14141c;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
button.secondary {
  background: transparent;
  color: #e8e8f0;
  border: 1px solid #33334a;
}
button:disabled { opacity: 0.4; cursor: default; }

.row { display: flex; align-items: center; gap: 10px; font-size: 13px; margin: 10px 0; color: #b0b0c8; }
input[type=range] { flex: 1; accent-color: #BA7517; }
.val { width: 34px; text-align: right; color: #e8e8f0; font-variant-numeric: tabular-nums; }
.val-input {
  width: 48px;
  text-align: right;
  background: #1c1c28;
  color: #e8e8f0;
  border: 1px solid #33334a;
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.val-input::-webkit-inner-spin-button { opacity: 0.6; }
select {
  flex: 1;
  background: #1c1c28;
  color: #e8e8f0;
  border: 1px solid #33334a;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stat {
  background: #1c1c28;
  border-radius: 8px;
  padding: 10px 12px;
}
.stat .label { font-size: 11px; color: #8888a0; text-transform: uppercase; letter-spacing: 0.03em; }
.stat .value { font-size: 20px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

.warn {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(240,153,149,0.15);
  border: 1px solid #F09995;
  color: #F09995;
  border-radius: 8px;
  font-size: 12px;
}
.warn.show { display: block; }

h2 { font-size: 14px; margin: 0 0 10px; color: #b0b0c8; font-weight: 600; }

.log {
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.log-item {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1c1c28;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
}
.log-item .t { color: #8888a0; font-variant-numeric: tabular-nums; }
.log-item .a { color: #F09995; font-weight: 600; }
.log-item.marginal { opacity: 0.55; }
.log-item.marginal .a { color: #8888a0; }
.log-item.marginal .a-text { color: #6a6a80; }
.log-item.repeat { opacity: 0.5; }
.log-item.repeat .a { color: #d9a441; }
.log-item.repeat .a-text { color: #a8813a; }
.log-item.line-candidate { border: 1px solid #4ea8ff; background: #16202c; }
.log-item.line-candidate .a { color: #4ea8ff; }
.log-item.line-candidate .a-text { color: #cfe6ff; }
.log-item.faint-track { border: 1px solid #b17ee6; background: #1e1626; }
.log-item.faint-track .a { color: #b17ee6; }
.log-item.faint-track .a-text { color: #e2cdfa; }
.log-item img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  border-radius: 4px;
  border: 1px solid #33334a;
  background: #000;
  flex-shrink: 0;
}
.log-item .info { display: flex; flex-direction: column; gap: 2px; flex: 1; margin: 0 8px; }
.log-item .a-text { color: #8888a0; font-size: 11px; }
.log-item.selected { outline: 2px solid #3AD6FF; outline-offset: -1px; background: #16222b; }
.log-empty { color: #55556a; font-size: 12px; padding: 20px 0; text-align: center; }

.hotspot-list { max-height: 220px; overflow-y: auto; }
.hotspot-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid #20202e;
  font-size: 12px;
}
.hotspot-item:last-child { border-bottom: none; }
.hotspot-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid #d9a441;
}
.hotspot-dot.excluded { background: #ffd100; box-shadow: 0 0 6px rgba(255,209,0,0.7); }
.hotspot-item .coords { color: #c8c8dc; font-variant-numeric: tabular-nums; flex: 1; }
.hotspot-item .count { color: #8888a0; font-variant-numeric: tabular-nums; }
.hotspot-item .status { font-size: 10px; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.02em; }
.hotspot-item .status.excluded { background: rgba(255,209,0,0.15); color: #ffd100; }
.hotspot-item .status.learning { background: rgba(136,136,160,0.15); color: #8888a0; }
.hotspot-item button {
  padding: 4px 8px;
  font-size: 11px;
  background: #1c1c28;
  color: #c8c8dc;
  border: 1px solid #33334a;
}
.hotspot-item button:hover { background: #26263a; color: #ffffff; }

.log-item img { cursor: pointer; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 10, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.lightbox.show { display: flex; }
.lightbox-card {
  background: #14141c;
  border: 1px solid #26263a;
  border-radius: 12px;
  padding: 20px;
  max-width: 90vw;
  text-align: center;
}
.lightbox-card img {
  width: min(360px, 80vw);
  height: min(360px, 80vw);
  image-rendering: pixelated;
  border-radius: 8px;
  border: 1px solid #33334a;
  background: #000;
}
.lightbox-meta {
  margin-top: 14px;
  font-size: 13px;
  color: #b0b0c8;
  text-align: left;
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 16px;
}
.lightbox-meta .k { color: #8888a0; }
.lightbox-close {
  margin-top: 16px;
  background: #1c1c28;
  color: #c8c8dc;
  border: 1px solid #33334a;
}
.lightbox-close:hover { background: #26263a; color: #ffffff; }
