:root {
  --bg: #080d1a;
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.16);
  --text: #f3f6fc;
  --muted: #9aa7c2;
  --primary: rgba(56, 189, 248, 0.28);
  --primary-border: rgba(56, 189, 248, 0.55);
  --accent: rgba(52, 211, 153, 0.26);
  --accent-border: rgba(52, 211, 153, 0.52);
  --danger: #fb7185;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 20px);
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 0;
  pointer-events: none;
}
.orb-1 { width: 320px; height: 320px; background: #1d4ed8; top: -80px; left: -60px; opacity: 0.35; }
.orb-2 { width: 300px; height: 300px; background: #0d9488; bottom: -80px; right: -60px; opacity: 0.3; }

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-radius: 22px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
}

.top-bar {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.08rem; font-weight: 600; letter-spacing: -0.01em; }
.sub { font-size: 0.78rem; color: var(--muted); }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 10px #34d399;
}

.pill {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
}

.ring-banner {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-color: rgba(251, 113, 133, 0.65);
  background: rgba(251, 113, 133, 0.18);
  animation: pulseRing 1.4s infinite;
}
.ring-banner > div { min-width: 0; }
.ring-banner .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ring-banner .glass-btn { flex-shrink: 0; padding: 14px 24px; font-size: 1rem; min-width: 112px; }
.ring-pill { background: rgba(251, 113, 133, 0.35); border-color: rgba(251, 113, 133, 0.7); }
@keyframes pulseRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.35); }
  50% { box-shadow: 0 0 24px 4px rgba(251, 113, 133, 0.45); }
}

.video-card { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.video-stage {
  aspect-ratio: 16 / 10;
  border-radius: 16px;
  background: rgba(4, 8, 18, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
}

.gate-cam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cam-badge {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.muted { color: var(--muted); font-size: 0.8rem; }

.media-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.glass-btn {
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  border-radius: 18px;
  padding: 12px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.18s ease;
}
.glass-btn:active { transform: scale(0.97); }
.glass-btn.primary { background: var(--primary); border-color: var(--primary-border); }
.glass-btn.accent { background: var(--accent); border-color: var(--accent-border); }

.action-btn {
  min-height: 82px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 16px;
}
.btn-title { font-size: 1.05rem; font-weight: 700; }
.btn-sub { font-size: 0.75rem; color: var(--muted); font-weight: 500; }

.log-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.log-header { display: flex; align-items: center; justify-content: space-between; }
.log-header h2 { font-size: 0.95rem; font-weight: 600; }
.text-btn { background: none; border: none; color: #7dd3fc; font-size: 0.82rem; cursor: pointer; }

.event-list { list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.event-item {
  display: flex; flex-direction: column;
  padding: 10px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.05); font-size: 0.82rem;
}
.event-row {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
}
.empty { color: var(--muted); font-size: 0.82rem; text-align: center; padding: 12px 0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 7, 15, 0.72);
  display: grid; place-items: center; padding: 20px; z-index: 20;
}
.modal-card { width: 100%; max-width: 340px; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.modal-card input {
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--glass-border);
  border-radius: 12px; padding: 11px 12px; color: var(--text); font-size: 0.92rem;
}
.error-msg { color: var(--danger); font-size: 0.82rem; }
.hidden { display: none !important; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92); border: 1px solid var(--glass-border);
  padding: 10px 16px; border-radius: 999px; font-size: 0.84rem; z-index: 30;
}
