:root {
  color-scheme: dark;
  --ink: #f5f7ef;
  --muted: #aeb9b3;
  --ground: #071410;
  --panel: #10211a;
  --panel-2: #162b22;
  --line: rgba(221, 235, 225, 0.18);
  --acid: #f4cc4d;
  --mint: #62e6bc;
  --cyan: #4dd6f4;
  --photo: #ff6d4a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--ground); }
body { margin: 0; background: var(--ground); color: var(--ink); min-width: 320px; }
button, summary { font: inherit; }
button { color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: 88px; padding: 16px clamp(18px, 3vw, 48px);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  background: rgba(7, 20, 16, 0.94); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand-lockup, .top-actions, .legend { display: flex; align-items: center; }
.brand-lockup { gap: 14px; }
.brand-mark {
  width: 52px; height: 52px; display: grid; place-items: center;
  border: 2px solid var(--acid); color: var(--acid); font-weight: 900; font-size: 0.75rem;
  line-height: 0.9; letter-spacing: -0.04em; transform: rotate(-2deg);
}
.eyebrow, .section-number { margin: 0 0 4px; color: var(--acid); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.7rem); letter-spacing: -0.03em; }
.top-actions { gap: 22px; }
.legend { gap: 14px; color: var(--muted); font-size: 0.78rem; }
.legend span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.swatch { width: 11px; height: 11px; display: inline-block; border-radius: 50%; }
.swatch.boundary { background: rgba(244, 204, 77, 0.65); border: 2px solid var(--acid); border-radius: 2px; }
.swatch.photo { background: var(--photo); }

main { padding: 30px clamp(18px, 3vw, 48px) 72px; }
.intro { max-width: 1480px; margin: 0 auto 24px; display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 36px; align-items: end; }
.intro h2 { margin: 0; max-width: 800px; font-size: clamp(1.7rem, 3.1vw, 3.6rem); line-height: 0.99; letter-spacing: -0.055em; }
.instruction { margin: 0; padding-left: 18px; border-left: 2px solid var(--acid); color: var(--muted); font-size: 0.94rem; line-height: 1.55; }
.instruction strong { color: var(--ink); }

.layer-command-center {
  max-width: 1480px; margin: 0 auto 18px; display: grid; grid-template-columns: minmax(310px, 0.82fr) minmax(440px, 1.18fr);
  background: linear-gradient(120deg, #11241c, #0c1a15); border: 1px solid rgba(244,204,77,0.35); box-shadow: 0 12px 40px rgba(0,0,0,0.24);
}
.command-summary { padding: 20px 22px; border-right: 1px solid var(--line); }
.command-total-row { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.command-metrics { display: flex; gap: 17px; }
.command-metrics > div { display: grid; min-width: 66px; }
.command-metrics strong { color: var(--acid); font: 900 clamp(2.35rem, 4vw, 4.3rem)/0.88 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -0.08em; }
.command-metrics span { margin-top: 6px; color: var(--muted); font: 800 0.62rem/1 ui-monospace, monospace; letter-spacing: 0.09em; text-transform: uppercase; }
.command-metrics > div:last-child strong { color: #b983ff; }
.command-total-row h2 { margin: 0 0 5px; font-size: 1.2rem; letter-spacing: -0.025em; }
.command-total-row p { margin: 0; max-width: 520px; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.boundary-rule { margin-top: 16px; padding-top: 13px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.72rem; }
.boundary-rule strong { color: var(--ink); }
.verified-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(98,230,188,0.12); }
.layer-console { padding: 18px 20px; }
.layer-console-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: var(--muted); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.layer-console-header button { border: 0; padding: 5px 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 0.7rem; text-transform: none; letter-spacing: 0; }
.layer-console-header button:hover { color: var(--ink); }
.layer-toggles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.layer-toggle { min-height: 55px; padding: 9px 10px; display: grid; grid-template-columns: 13px 1fr auto; gap: 9px; align-items: center; border: 1px solid var(--line); background: rgba(255,255,255,0.025); color: var(--ink); cursor: pointer; text-align: left; }
.layer-toggle:hover { border-color: rgba(255,255,255,0.38); }
.layer-toggle[aria-pressed="false"] { opacity: 0.48; }
.layer-toggle[data-kind="events"] { border-color: rgba(185,131,255,0.35); background: rgba(185,131,255,0.07); }
.layer-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.85); box-shadow: 0 0 0 2px rgba(0,0,0,0.38); }
.layer-name { font-size: 0.76rem; font-weight: 800; line-height: 1.1; }
.layer-count { min-width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,0.08); color: var(--muted); font: 800 0.68rem/1 ui-monospace, monospace; }

.site-grid { max-width: 1480px; margin: 0 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.site-card { overflow: hidden; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0,0,0,0.2); }
.site-card.is-expanded { position: fixed; inset: 12px; z-index: 50; display: flex; flex-direction: column; box-shadow: 0 30px 120px #000; }
.site-card.is-expanded .map-wrap { flex: 1; min-height: 0; }
.site-card.is-expanded .map { height: 100%; }
body.has-expanded { overflow: hidden; }
.site-header { min-height: 95px; display: grid; grid-template-columns: 54px minmax(0, 1fr) 42px; gap: 12px; align-items: start; padding: 16px; }
.site-index { color: var(--acid); font: 800 1.5rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.site-title h3 { margin: 6px 0 3px; font-size: 1.22rem; letter-spacing: -0.03em; }
.site-location { margin: 0; color: var(--muted); font-size: 0.82rem; }
.site-tags { display: flex; gap: 6px; }
.tag { padding: 3px 7px; border: 1px solid var(--line); color: var(--muted); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.tag.type { color: var(--mint); border-color: rgba(98,230,188,0.35); }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 1.2rem; }
.icon-button:hover { border-color: var(--acid); color: var(--acid); }

.map-wrap { position: relative; overflow: hidden; background: #16211d; border-block: 1px solid var(--line); }
.map { height: 390px; width: 100%; }
.map-corner-label, .map-scale-note {
  position: absolute; z-index: 4; background: rgba(7,20,16,0.84); color: var(--ink);
  border: 1px solid rgba(255,255,255,0.16); backdrop-filter: blur(8px);
}
.map-corner-label { left: 12px; top: 12px; padding: 7px 9px; font: 750 0.66rem/1 ui-monospace, monospace; letter-spacing: 0.08em; }
.map-scale-note { left: 12px; bottom: 12px; padding: 5px 8px; color: var(--muted); font-size: 0.7rem; }
.map-message { position: absolute; z-index: 8; inset: 50% auto auto 50%; translate: -50% -50%; padding: 10px 14px; background: #071410; border: 1px solid var(--acid); color: var(--acid); text-align: center; }
.maplibregl-ctrl-bottom-right { right: 6px; bottom: 6px; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-popup-content { background: #0a1b15; color: var(--ink); border: 1px solid var(--line); padding: 12px 14px; border-radius: 0; }
.maplibregl-popup-tip { border-top-color: #0a1b15 !important; }
.popup-title { margin: 0 0 3px; font-weight: 800; }
.popup-meta { margin: 0; color: var(--muted); font-size: 0.75rem; }
.event-popup { min-width: 270px; max-width: 340px; }
.event-popup-header { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.event-status { padding: 3px 6px; background: #b983ff; color: #12091d; font: 900 0.62rem/1 ui-monospace, monospace; letter-spacing: 0.06em; text-transform: uppercase; }
.event-status.is-past { background: #9aa5a0; }
.event-status.is-active { background: var(--mint); }
.event-source { color: #d8baff; font-size: 0.69rem; font-weight: 800; }
.event-entry + .event-entry { margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--line); }
.event-entry h4 { margin: 0 0 5px; font-size: 0.86rem; }
.event-time { margin: 0 0 6px; color: var(--ink); font-size: 0.76rem; font-weight: 800; }
.event-meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px 9px; margin: 0; font-size: 0.68rem; line-height: 1.35; }
.event-meta-grid dt { color: #7f9188; }
.event-meta-grid dd { margin: 0; color: var(--muted); }
.event-meta-grid a { color: #d8baff; }

.site-controls { min-height: 67px; padding: 12px 16px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.button { border: 1px solid transparent; background: var(--acid); color: #0b160f; min-height: 40px; padding: 0 14px; font-size: 0.82rem; font-weight: 800; cursor: pointer; }
.button:hover { filter: brightness(1.08); }
.button.is-active { background: var(--photo); color: #fff; }
.button-secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.button-quiet { background: transparent; color: var(--muted); border-color: var(--line); }
.crosshair { font-size: 1.1rem; }
.placement-status { margin: 0 0 0 auto; color: var(--muted); font-size: 0.74rem; text-align: right; }
.placement-status strong { color: var(--photo); }

.site-footer { display: grid; grid-template-columns: 1.1fr 0.9fr; min-height: 96px; }
.site-meta { padding: 14px 16px; border-right: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.meta-item span { display: block; color: var(--muted); font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; }
.meta-item strong { display: block; margin-top: 3px; font-size: 0.76rem; line-height: 1.25; }
details { padding: 14px 16px; }
summary { color: var(--ink); cursor: pointer; font-size: 0.78rem; font-weight: 800; }
.asset-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 4px; border-radius: 99px; background: var(--cyan); color: #06120f; font-size: 0.7rem; }
.asset-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.asset-chip { padding: 4px 6px; border: 1px solid var(--line); color: var(--muted); font-size: 0.65rem; }
.source-note { margin: 9px 0 0; color: #7f9188; font-size: 0.66rem; line-height: 1.4; }

.camera-pin { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50% 50% 50% 8%; background: var(--photo); border: 3px solid white; color: white; font: 900 0.8rem/1 ui-monospace, monospace; box-shadow: 0 3px 12px rgba(0,0,0,0.45); transform: rotate(-45deg); cursor: grab; }
.camera-pin span { transform: rotate(45deg); }
.arrow-head { width: 19px; height: 24px; background: white; clip-path: polygon(50% 0, 100% 100%, 50% 72%, 0 100%); filter: drop-shadow(0 2px 3px #000); transform-origin: center; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 11px 15px; background: var(--ink); color: #071410; font-weight: 800; font-size: 0.8rem; transition: 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .topbar { align-items: flex-start; }
  .legend { display: none; }
  .intro { grid-template-columns: 1fr; gap: 18px; }
  .layer-command-center { grid-template-columns: 1fr; }
  .command-summary { border-right: 0; border-bottom: 1px solid var(--line); }
  .site-grid { grid-template-columns: 1fr; }
  .map { height: 420px; }
}

@media (max-width: 620px) {
  .topbar { position: static; padding: 14px; }
  .top-actions .button { padding: 0 10px; font-size: 0.72rem; }
  main { padding: 22px 12px 48px; }
  .layer-toggles { grid-template-columns: 1fr; }
  .command-total-row { grid-template-columns: 1fr; }
  .boundary-rule { align-items: flex-start; flex-wrap: wrap; }
  .site-header { grid-template-columns: 42px minmax(0, 1fr) 38px; }
  .map { height: 360px; }
  .site-controls { flex-wrap: wrap; }
  .placement-status { width: 100%; margin-left: 0; text-align: left; }
  .site-footer { grid-template-columns: 1fr; }
  .site-meta { border-right: 0; border-bottom: 1px solid var(--line); }
}
