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

body {
  background: #f5f5f0;
  color: #1a1a1a;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px;
}

.app {
  max-width: 720px;
  width: 100%;
}

header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: -0.3px;
}

.session-badge {
  font-size: 11px;
  color: #888;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: #eee;
  padding: 2px 8px;
  border-radius: 4px;
}

.video-container {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #e8e8e4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

video {
  display: block;
  width: 100%;
  aspect-ratio: 4/3;
  transform: scaleX(-1);
}

canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
}

.loading {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: #888;
  z-index: 10;
}

.status-badge {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: rgba(0,0,0,0.7);
  color: #ef4444;
  border: 1px solid #ef4444;
  white-space: nowrap;
  z-index: 5;
}

.status-badge.detected {
  color: #16a34a;
  border-color: #16a34a;
}

.stats-gauge-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #e0e0d8;
  gap: 12px;
}

.stats-row {
  display: flex;
  gap: 16px;
  font-size: 13px;
  flex-wrap: wrap;
  flex: 1;
}

.stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-label {
  color: #888;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat-value {
  color: #1a1a1a;
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
}

.stat-unit {
  color: #888;
  font-size: 11px;
  margin-left: 1px;
}

.gauge-section {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.gauge {
  width: 52px;
  height: 52px;
}

.gauge-bg {
  fill: none;
  stroke: #e0e0d8;
  stroke-width: 7;
}

.gauge-fill {
  fill: none;
  stroke: #16a34a;
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.gauge-text {
  font-size: 22px;
  font-weight: 700;
  fill: #1a1a1a;
  text-anchor: middle;
  dominant-baseline: central;
}

.gauge-label {
  font-size: 7px;
  fill: #888;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 1px;
}

.gauge-detail {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 10px;
  color: #888;
  white-space: nowrap;
}

.gauge-detail strong {
  color: #1a1a1a;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.split-row {
  display: flex;
  gap: 16px;
  border-bottom: 1px solid #e0e0d8;
}

.timeline-section {
  flex: 1;
  padding: 12px 0;
}

.event-section {
  width: 220px;
  flex-shrink: 0;
  padding: 12px 0;
  border-left: 1px solid #e0e0d8;
  padding-left: 12px;
}

.section-label {
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.capture-count {
  color: #2563eb;
  font-weight: 600;
}

.timeline {
  display: flex;
  gap: 2px;
  height: 14px;
}

.timeline-block {
  flex: 1;
  border-radius: 2px;
  min-width: 3px;
}

.timeline-block.detected { background: #16a34a; }
.timeline-block.empty { background: #ef4444; }
.timeline-block.pending { background: #e0e0d8; }

.events {
  max-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.events::-webkit-scrollbar { width: 4px; }
.events::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.event-empty {
  font-size: 11px;
  color: #aaa;
  padding: 20px 0;
  text-align: center;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  padding: 3px 5px;
  border-radius: 3px;
  background: #fafaf8;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.event-icon { font-size: 8px; width: 12px; text-align: center; }
.event-enter .event-icon { color: #16a34a; }
.event-exit .event-icon { color: #ef4444; }
.event-capture .event-icon { color: #2563eb; }

.event-label {
  color: #555;
  flex-shrink: 0;
}

.event-detail {
  color: #888;
  flex: 1;
  text-align: right;
  margin-left: auto;
}

.event-ts {
  color: #bbb;
  font-size: 9px;
}

.gallery-section {
  padding-top: 12px;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

.gallery-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint {
  font-size: 11px;
  color: #aaa;
}

.btn {
  background: #fff;
  border: 1px solid #d0d0c8;
  color: #444;
  padding: 4px 14px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: 0.15s;
}

.btn:hover {
  border-color: #888;
  color: #1a1a1a;
}

.btn-report:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.btn-pause {
  border-color: #2563eb;
  color: #2563eb;
}

.btn-pause:hover {
  background: #2563eb;
  color: #fff;
}

.btn-clear:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.gallery::-webkit-scrollbar { height: 4px; }
.gallery::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.gallery-empty {
  width: 100%;
  text-align: center;
  font-size: 13px;
  color: #aaa;
  padding: 24px 0;
}

.capture-card {
  flex-shrink: 0;
  width: 140px;
  border: 1px solid #e0e0d8;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.15s;
}

.capture-card:hover {
  border-color: #2563eb;
}

.capture-card img {
  width: 100%;
  aspect-ratio: 4/3;
  display: block;
  background: #f0f0eb;
  object-fit: cover;
}

.capture-meta {
  padding: 5px 7px;
  font-size: 10px;
  color: #888;
  line-height: 1.3;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.capture-meta .hl { color: #2563eb; }

.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #1a1a1a;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 100;
}

.toast.show { opacity: 1; }

@media (max-width: 500px) {
  body { padding: 12px; }
  .stats-row { gap: 12px; font-size: 12px; }
  .capture-card { width: 110px; }
}
