/* ---------- Reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --zone-color: #3EA6FF;
  --zone-color-dim: rgba(62, 166, 255, 0.18);
  --mode-color: #22E07A;
  --panel-bg: rgba(30, 32, 36, 0.72);
  --panel-blur: blur(14px);
  --text-primary: #F5F6F7;
  --text-secondary: rgba(245, 246, 247, 0.68);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

body[data-mode="balance"] { --mode-color: #22E07A; }
body[data-mode="stealth"] { --mode-color: #F5D000; }
body[data-mode="panic"]   { --mode-color: #E11D2E; }

html, body {
  height: 100%;
  background: #0B0C0E;
  color: var(--text-primary);
  font-family: var(--font);
  overflow-x: hidden;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  background: none;
  color: inherit;
}

ul { list-style: none; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.topbar__brand { display: flex; align-items: center; gap: 12px; }
.topbar__mark { font-size: 22px; color: var(--zone-color); transition: color .4s ease; }
.topbar__title { font-weight: 700; font-size: 16px; letter-spacing: 0.01em; }
.topbar__tag { font-size: 12.5px; color: var(--text-secondary); margin-top: 1px; }

.topbar__stat { text-align: right; }
.topbar__stat span:first-child { font-size: 18px; font-weight: 700; margin-right: 6px; }
.topbar__stat-label { font-size: 11.5px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Viewport / scene ---------- */
.viewport {
  position: relative;
  width: 100%;
  height: calc(100svh - 66px - 78px);
  min-height: 460px;
  overflow: hidden;
}

.scene { position: absolute; inset: 0; background: #111; }
.scene__video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.scene__video.is-active { opacity: 1; }

.scene__vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 160px 40px rgba(0,0,0,0.55);
  background: linear-gradient(to bottom, rgba(0,0,0,0.35), transparent 30%, transparent 70%, rgba(0,0,0,0.45));
  transition: box-shadow .5s ease;
}
body[data-mode="panic"] .scene__vignette {
  box-shadow: inset 0 0 160px 40px rgba(220,38,38,0.35);
  animation: pulseVignette 1.6s ease-in-out infinite;
}
@keyframes pulseVignette {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ---------- Zone card ---------- */
.zone-card {
  position: absolute;
  top: 24px; left: 24px;
  width: min(280px, 42vw);
  background: var(--panel-bg);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 22px 20px;
  z-index: 5;
}

.zone-card__ring-wrap { width: 76px; height: 76px; position: relative; margin-bottom: 14px; }
.zone-card__ring {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.zone-card__ring circle {
  fill: none;
  stroke: var(--zone-color);
  stroke-linecap: round;
  transition: stroke .4s ease;
  animation: ringBreathe 2.8s ease-in-out infinite;
}
@keyframes ringBreathe {
  0%, 100% { stroke-width: 7px;   filter: drop-shadow(0 0 2px var(--zone-color)); }
  50%      { stroke-width: 9.5px; filter: drop-shadow(0 0 6px var(--zone-color)); }
}
.zone-card__pill {
  position: absolute;
  left: 50%; bottom: -4px;
  transform: translateX(-50%);
  background: var(--zone-color);
  color: #0B0C0E;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background .4s ease;
}

.zone-card__name { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.zone-card__desc { font-size: 13px; color: var(--text-secondary); line-height: 1.45; margin-bottom: 16px; }

.zone-card__toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--zone-color);
  color: #0B0C0E;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 999px;
  transition: background .4s ease;
}
.zone-card__toggle svg { transition: transform .3s ease; }
.zone-card.is-expanded .zone-card__toggle svg { transform: rotate(180deg); }

.zone-card__expand {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease, margin-top .35s ease;
}
.zone-card.is-expanded .zone-card__expand {
  max-height: 260px;
  margin-top: 16px;
}

.risk-meter__label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 6px;
}
.risk-meter__track {
  height: 6px; border-radius: 999px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
}
.risk-meter__fill {
  height: 100%;
  width: 10%;
  background: var(--zone-color);
  border-radius: 999px;
  transition: width .5s ease, background .4s ease;
}

.data-sources { margin-top: 16px; }
.data-sources__label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-secondary); margin-bottom: 8px;
}
.data-sources ul { display: flex; flex-direction: column; gap: 6px; }
.data-sources li {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
}
.data-sources li .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--dot-color, var(--zone-color));
  flex-shrink: 0;
}
.data-sources__empty { color: var(--text-secondary); font-style: italic; }

/* ---------- Trigger icons ---------- */
.triggers { position: absolute; inset: 0; z-index: 4; }
.trigger {
  position: absolute;
  width: 40px; height: 40px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--t-color);
  box-shadow: 0 0 0 0 var(--t-color);
  transform: translate(-50%, -50%);
  animation: triggerIn .35s ease both, triggerPulse 2.4s ease-in-out infinite;
  transition: opacity .3s ease, filter .3s ease;
}
.trigger svg { width: 20px; height: 20px; color: #0B0C0E; }
.trigger.is-dim { opacity: 0.35; filter: grayscale(40%); }
.trigger.is-urgent { animation: triggerIn .35s ease both, triggerPulseUrgent 1s ease-in-out infinite; }

@keyframes triggerIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes triggerPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--t-color) 55%, transparent); }
  50% { box-shadow: 0 0 0 8px transparent; }
}
@keyframes triggerPulseUrgent {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.6); }
  50% { box-shadow: 0 0 0 10px rgba(220,38,38,0); }
}

.trigger-label {
  position: absolute;
  transform: translate(-50%, 30px);
  background: var(--t-color);
  color: #0B0C0E;
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 6;
  pointer-events: none;
  animation: labelPop .25s ease both;
}
.trigger-label::before {
  content: "";
  position: absolute;
  top: -5px; left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid var(--t-color);
}
@keyframes labelPop {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 30px); }
}

/* ---------- Notification prompt ---------- */
.notify {
  position: absolute;
  right: 24px; bottom: 24px;
  width: min(300px, 46vw);
  background: var(--panel-bg);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 18px;
  z-index: 8;
  animation: slideUp .3s ease both;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.notify__icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--t-color, var(--zone-color));
  margin-bottom: 10px;
}
.notify__icon svg { width: 18px; height: 18px; color: #0B0C0E; }
.notify__text { font-size: 13px; line-height: 1.5; margin-bottom: 14px; }
.notify__actions { display: flex; gap: 8px; }
.notify.is-result .notify__actions { display: none; }
.notify.is-result .notify__text { margin-bottom: 0; }
.notify__btn {
  flex: 1;
  padding: 9px 0;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
}
.notify__btn--deny { background: var(--t-color, var(--zone-color)); color: #0B0C0E; }
.notify__btn--allow { background: rgba(255,255,255,0.1); color: var(--text-primary); }

/* ---------- Mode toast ---------- */
.toast {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, 70vw);
  background: var(--panel-bg);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  z-index: 9;
  animation: fadeScale .3s ease both;
}
@keyframes fadeScale {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.toast__icon { display: block; font-size: 26px; color: var(--zone-color); margin-bottom: 8px; }
.toast__title { font-weight: 700; margin-bottom: 4px; }
.toast__desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }

/* ---------- Mode badge ---------- */
.mode-badge {
  position: absolute;
  left: 24px; bottom: 24px;
  z-index: 7;
}
.mode-badge__main {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel-bg);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.mode-badge__shield {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--mode-color);
  color: #0B0C0E;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900;
  transition: background .4s ease;
}
.mode-badge__info {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--panel-bg);
  border: 1px solid rgba(255,255,255,0.1);
  margin-left: 8px;
  font-style: italic;
  font-size: 12px;
  vertical-align: middle;
}

.mode-menu[hidden], .mode-detail[hidden] { display: none; }

.mode-menu {
  position: absolute;
  bottom: 54px; left: 0;
  width: 250px;
  background: var(--panel-bg);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
  animation: slideUp .25s ease both;
}
.mode-menu__item {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.mode-menu__item:hover { background: rgba(255,255,255,0.08); }
.mode-menu__item strong { font-size: 13px; }
.mode-menu__item span { font-size: 11.5px; color: var(--text-secondary); line-height: 1.4; }
.mode-menu__item.is-active { background: rgba(255,255,255,0.1); box-shadow: inset 3px 0 0 var(--mode-color); }

.mode-detail {
  position: absolute;
  bottom: 54px; left: 0;
  width: min(300px, 80vw);
  background: var(--panel-bg);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  border: 1px solid rgba(255,255,255,0.1);
  border-left: 3px solid var(--mode-color);
  border-radius: 16px;
  padding: 16px 18px;
  animation: slideUp .25s ease both;
}
.mode-detail__body { font-size: 12.5px; line-height: 1.55; margin-bottom: 10px; }
.mode-detail__row { font-size: 11.5px; line-height: 1.5; color: var(--text-secondary); margin-top: 4px; }
.mode-detail__row strong { color: var(--text-primary); }
.toast__icon { color: var(--mode-color); }

/* ---------- Demo bar ---------- */
.demo-bar {
  padding: 16px 28px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.demo-bar__group {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.demo-bar__label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.demo-bar__chips { display: flex; gap: 8px; flex-wrap: wrap; }
.demo-chip {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-secondary);
  transition: all .2s ease;
}
.demo-chip:hover { color: var(--text-primary); }
.demo-chip.is-active {
  background: var(--zone-color);
  color: #0B0C0E;
  border-color: transparent;
}
.demo-bar__note { font-size: 11.5px; color: var(--text-secondary); max-width: 620px; }

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
  .topbar { padding: 14px 16px; }
  .zone-card { top: 16px; left: 16px; width: min(240px, 60vw); padding: 16px; }
  .notify { right: 16px; left: 16px; width: auto; bottom: 16px; }
  .mode-badge { left: 16px; bottom: 16px; }
  .mode-menu { width: min(240px, 80vw); }
  .demo-bar { padding: 14px 16px 18px; }
}
