/* Night-monitor theme: a dark map, amber camera beams, one blinking REC light. */
:root {
  --night: #0E1622;      /* page + map base */
  --panel: #142030;      /* bars, panels */
  --raised: #1B2A3D;     /* inputs, buttons */
  --line: #2A3C54;       /* borders */
  --text: #E6EDF5;
  --muted: #8C9DB3;
  --signal: #FFB020;     /* camera beams, primary actions */
  --signal-soft: rgba(255, 176, 32, .14);
  --rec: #FF4D4F;        /* recording light, destructive actions */
  --display: "Chakra Petch", "IBM Plex Sans", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--night);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--signal); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
::selection { background: var(--signal); color: var(--night); }

/* ---------- Top bar ---------- */
.bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 24px;
  min-height: 62px; padding: 8px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: relative; z-index: 1100;
}
.brand {
  margin: 0; font-family: var(--display); font-weight: 700;
  font-size: 1.375rem; letter-spacing: .02em; line-height: 1.1;
}
.status { display: flex; align-items: center; gap: 10px; }
.rec {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--rec); box-shadow: 0 0 8px rgba(255, 77, 79, .8);
}
@media (prefers-reduced-motion: no-preference) {
  .rec { animation: rec-blink 2s steps(1) infinite; }
  @keyframes rec-blink { 50% { opacity: .15; box-shadow: none; } }
}
.count { margin: 0; color: var(--muted); font-size: .9375rem; }
.count strong { color: var(--text); font-family: var(--display); font-weight: 600; font-size: 1.0625rem; }
.bar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.bar-public > .primary { align-self: center; }

/* ---------- Buttons ---------- */
.primary, .danger, .ghost {
  font-family: var(--display); font-weight: 600; letter-spacing: .02em;
  border-radius: 3px; padding: 10px 18px; cursor: pointer; line-height: 1.2;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.primary { background: var(--signal); color: var(--night); border: 1px solid var(--signal); }
.primary:hover { box-shadow: 0 0 0 3px var(--signal-soft), 0 0 18px rgba(255, 176, 32, .35); }
.danger { background: transparent; color: var(--rec); border: 1px solid var(--rec); }
.danger:hover { background: var(--rec); color: var(--night); }
.ghost { background: var(--raised); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: progress; box-shadow: none; }
.link {
  background: none; border: 0; padding: 10px 6px; cursor: pointer; color: var(--text);
  font-family: var(--display); font-weight: 600; letter-spacing: .02em;
}
.link:hover { color: var(--signal); }
.wide { width: 100%; margin-top: 26px; padding: 14px 16px; font-size: 1.0625rem; }

/* ---------- Map ---------- */
.stage { position: relative; flex: 1; min-height: 0; }
.map { position: absolute; inset: 0; background: var(--night); }
.leaflet-container { font-family: var(--body); background: var(--night); }
/* Turns the standard light map into a dark, blue-tinted night map. */
.leaflet-tile-pane {
  filter: grayscale(1) invert(1) sepia(.35) hue-rotate(180deg) saturate(1.5) brightness(.78) contrast(1.08);
}
.map.placing { cursor: crosshair; }
.cone { filter: drop-shadow(0 0 6px rgba(255, 176, 32, .55)); }

.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: none !important; }
.leaflet-bar a, .leaflet-bar a:hover {
  background: var(--panel); color: var(--text); border-bottom-color: var(--line);
}
.leaflet-bar a:hover { color: var(--signal); }
.leaflet-control-attribution {
  background: rgba(14, 22, 34, .8) !important; color: var(--muted);
}
.leaflet-control-attribution a { color: var(--muted); }

.cam-dot span {
  display: block; width: 16px; height: 16px; border-radius: 50%;
  background: var(--night); border: 3px solid var(--signal);
  box-shadow: 0 0 10px rgba(255, 176, 32, .7);
  transition: transform .15s;
}
.cam-dot.is-active span { transform: scale(1.45); background: var(--signal); border-color: var(--text); }
.draft-pin span {
  display: block; width: 28px; height: 28px; border-radius: 50%;
  background: var(--signal); border: 4px solid var(--night);
  box-shadow: 0 0 0 2px var(--text), 0 0 16px rgba(255, 176, 32, .8);
  cursor: grab;
}

/* ---------- Placement hint ---------- */
.hint {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 1000;
  display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; justify-content: center;
  width: max-content; max-width: calc(100% - 32px);
  padding: 10px 10px 10px 18px; border-radius: 4px;
  background: var(--panel); border: 1px solid var(--signal);
  box-shadow: 0 0 24px rgba(255, 176, 32, .2);
}
.hint p { margin: 0; font-weight: 500; }
.hint-actions { display: flex; gap: 6px; }

/* ---------- Side panel / bottom sheet ---------- */
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 1000;
  width: min(420px, 100%);
  display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line);
}
.panel-head { display: flex; justify-content: flex-end; padding: 6px 8px 0; flex: none; }
.close {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.close:hover { background: var(--raised); color: var(--text); }
.panel-body { flex: 1; overflow-y: auto; padding: 0 24px 32px; overscroll-behavior: contain; }

@media (prefers-reduced-motion: no-preference) {
  .panel { animation: panel-in .22s ease-out; }
  @keyframes panel-in { from { transform: translateX(28px); opacity: 0; } }
}

@media (max-width: 640px) {
  .bar { padding: 8px 14px; gap: 4px 16px; }
  .brand { font-size: 1.2rem; }
  /* Phones: name + report button on top, then the count, then the links row. */
  .bar-public {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
    grid-template-areas: "brand report" "status status" "links links"; gap: 4px 12px; padding: 10px 14px 6px;
  }
  .bar-public .brand { grid-area: brand; }
  .bar-public .status { grid-area: status; }
  .bar-public .bar-actions {
    grid-area: links; display: flex; align-items: center; justify-content: flex-start; gap: 20px;
    margin-left: 0; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px;
  }
  .bar-public .primary { grid-area: report; align-self: center; padding: 9px 13px; white-space: nowrap; font-size: .9375rem; }
  .bar-public .link { padding: 4px 2px; }
  .bar-public .brand { font-size: clamp(.95rem, 4.3vw, 1.2rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bar-public .count { white-space: nowrap; }
  .panel {
    top: auto; left: 0; width: 100%; max-height: 72%;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 10px 10px 0 0;
  }
  @media (prefers-reduced-motion: no-preference) {
    @keyframes panel-in { from { transform: translateY(40px); opacity: 0; } }
  }
}

/* ---------- Camera detail ---------- */
.panel h2, .editor h2, .login h2 {
  font-family: var(--display); font-weight: 700; letter-spacing: .01em;
  font-size: 1.625rem; line-height: 1.15; margin: 18px 0 4px;
}
.panel h3 { font-family: var(--display); font-size: 1.0625rem; font-weight: 600; margin: 26px 0 8px; letter-spacing: .01em; }
.where { margin: 0; color: var(--muted); }

.gallery { margin: 0 -24px; }
.gallery-main { display: block; width: 100%; padding: 0; border: 0; background: #000; cursor: zoom-in; }
.gallery-main img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.thumbs { display: flex; gap: 6px; padding: 8px 24px 0; }
.thumbs button { padding: 0; border: 1px solid var(--line); width: 64px; height: 48px; background: #000; cursor: zoom-in; }
.thumbs button:hover { border-color: var(--signal); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery.empty { padding: 40px 24px; background: var(--night); color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); }
.gallery.empty p { margin: 0; }

.check {
  display: inline-flex; align-items: center; gap: 8px; margin: 14px 0 0;
  padding: 4px 12px 4px 10px; border-radius: 999px;
  background: var(--raised); border: 1px solid var(--line); font-size: .875rem; color: var(--muted);
}
.check::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.check.is-verified { color: var(--text); border-color: rgba(255, 176, 32, .5); }
.check.is-verified::before { background: var(--signal); box-shadow: 0 0 6px var(--signal); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 20px; margin: 22px 0 0; }
.facts div { display: contents; }
.facts dt { color: var(--muted); font-size: .875rem; padding-top: 2px; }
.facts dd { margin: 0; }
.features { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.features li {
  border: 1px solid rgba(255, 176, 32, .55); color: var(--signal);
  border-radius: 999px; padding: 3px 11px; font-size: .875rem; background: var(--signal-soft);
}
.notes { margin: 22px 0 0; white-space: pre-line; color: #C9D4E1; }

.about p { margin: 0 0 14px; max-width: 60ch; color: #C9D4E1; }
.about p:first-of-type { color: var(--text); font-size: 1.0625rem; }
.about h3 { margin-top: 26px; }

/* ---------- Forms ---------- */
.lede { margin: 4px 0 8px; color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 24px 0 0; min-width: 0; }
legend { font-family: var(--display); font-weight: 600; letter-spacing: .01em; padding: 0; margin-bottom: 10px; }
.field { display: block; margin-top: 22px; }
.field > span { display: block; font-family: var(--display); font-weight: 600; letter-spacing: .01em; margin-bottom: 8px; }
legend em, .field em { font-family: var(--body); font-style: normal; font-weight: 400; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.help { margin: -4px 0 10px; font-size: .875rem; color: var(--muted); }

input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 11px 12px; background: var(--raised); color: var(--text);
  border: 1px solid var(--line); border-radius: 3px;
}
input::placeholder, textarea::placeholder { color: #66778E; }
input:focus, select:focus, textarea:focus { border-color: var(--signal); outline: none; box-shadow: 0 0 0 3px var(--signal-soft); }
textarea { resize: vertical; }
input[type=checkbox] { accent-color: var(--signal); width: 18px; height: 18px; flex: none; margin: 3px 0 0; }
.checks label { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; cursor: pointer; }
.check-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 24px; font-size: .9375rem; cursor: pointer; color: #C9D4E1; }

/* 16-point compass dial */
.dial { display: flex; justify-content: center; padding: 4px 0; }
.dial-face {
  position: relative; width: 208px; height: 208px; border-radius: 50%;
  background: radial-gradient(circle at center, var(--raised) 60%, var(--panel) 100%);
  border: 1px solid var(--line); touch-action: none;
}
/* Each tick sits on the rim at its own angle (--a), rotated upright by its label. */
.tick {
  position: absolute; left: 50%; top: 50%; width: 34px; height: 104px;
  margin: -104px 0 0 -17px; transform-origin: 50% 100%; transform: rotate(var(--a));
  background: none; border: 0; padding: 0; cursor: pointer;
  display: flex; justify-content: center; align-items: flex-start;
}
.tick span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 20px; border-radius: 3px;
  transform: rotate(calc(-1 * var(--a)));
  font-family: var(--display); font-weight: 600; font-size: .6875rem; color: var(--muted);
}
.tick-cardinal span { font-size: .8125rem; color: var(--text); }
.tick:hover span { color: var(--signal); }
.tick[aria-checked=true] span {
  background: var(--signal); color: var(--night); font-weight: 700;
  box-shadow: 0 0 12px rgba(255, 176, 32, .55);
}
.dial-needle {
  position: absolute; left: 50%; top: 50%; width: 3px; height: 78px;
  background: linear-gradient(var(--signal), rgba(255,176,32,.2));
  border-radius: 3px; transform-origin: 50% 100%; pointer-events: none;
  box-shadow: 0 0 10px rgba(255, 176, 32, .6);
}
.dial-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line); cursor: pointer;
  font-family: var(--display); font-weight: 600; font-size: .75rem; line-height: 1.1; color: var(--muted);
}
.dial-center:hover { border-color: var(--signal); color: var(--text); }
.dial-center[aria-pressed=true] {
  background: var(--signal); border-color: var(--signal); color: var(--night); font-weight: 700;
  box-shadow: 0 0 16px rgba(255, 176, 32, .5);
}

.photo-picks { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-picks:not(:empty) { margin-bottom: 12px; }
.pick { position: relative; width: 88px; height: 88px; }
.pick img { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; display: block; border: 1px solid var(--line); }
.pick button {
  position: absolute; top: -8px; right: -8px; width: 28px; height: 28px;
  border-radius: 50%; border: 2px solid var(--panel); background: var(--text); color: var(--night);
  cursor: pointer; line-height: 1;
}
.file-btn {
  position: relative; display: inline-block; cursor: pointer;
  padding: 9px 16px; border: 1px dashed var(--muted); border-radius: 3px;
  font-family: var(--display); font-weight: 600; letter-spacing: .02em;
}
.file-btn:hover { border-color: var(--signal); color: var(--signal); }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 2px solid var(--signal); outline-offset: 2px; }

.form-error { color: var(--rec); font-weight: 500; margin: 16px 0 0; }

.sent p { margin: 6px 0 0; color: #C9D4E1; }
.sent-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 13, 20, .96);
}
.lightbox img { max-width: 90vw; max-height: 86vh; display: block; }
.lightbox button {
  position: absolute; background: none; border: 0; color: var(--text);
  font-size: 2.4rem; line-height: 1; width: 56px; height: 56px; cursor: pointer;
}
.lightbox button:hover { color: var(--signal); }
.lb-close { top: 10px; right: 10px; }
.lb-prev { left: 6px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 6px; top: 50%; transform: translateY(-50%); }

/* ---------- Moderation page ---------- */
.login { max-width: 380px; width: 100%; margin: 12vh auto 0; padding: 0 20px; }
.login h2 { margin-top: 0; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; }
.queue { overflow-y: auto; border-right: 1px solid var(--line); background: var(--night); }
.tabs { display: flex; position: sticky; top: 0; z-index: 1; background: var(--night); border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; padding: 14px 6px; border: 0; background: none; cursor: pointer; color: var(--muted); white-space: nowrap;
  font-family: var(--display); font-weight: 600; letter-spacing: .02em; border-bottom: 2px solid transparent;
}
.tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--signal); }
.tabs button { font-size: .9375rem; }
.tab-count { margin-left: 4px; }
.tab-count { font-family: var(--body); font-weight: 400; color: var(--muted); margin-left: 6px; }
.queue ul { list-style: none; margin: 0; padding: 0; }
.queue li > button {
  display: flex; flex-direction: column; width: 100%; gap: 1px; text-align: left;
  padding: 14px 20px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer;
}
.queue li > button strong { font-family: var(--display); font-weight: 600; letter-spacing: .01em; }
.queue li > button:hover { background: var(--panel); }
.queue li > button[aria-current=true] { background: var(--panel); box-shadow: inset 3px 0 0 var(--signal); }
.queue .meta { font-size: .875rem; color: var(--muted); }
.list-empty { padding: 24px 20px; color: var(--muted); }

.editor { overflow-y: auto; background: var(--panel); }
.editor-inner { max-width: 720px; padding: 24px 32px 56px; }
.editor h2 { margin-top: 0; }
.empty-state { padding: 48px 32px; color: var(--muted); }
.mini-map { height: 300px; margin-top: 16px; border: 1px solid var(--line); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.photo-review { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.photo-review figure { margin: 0; }
.photo-open { display: block; width: 100%; padding: 0; border: 1px solid var(--line); background: #000; cursor: zoom-in; }
.photo-open:hover { border-color: var(--signal); }
.photo-open img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-review label { display: flex; gap: 8px; align-items: flex-start; padding-top: 8px; font-size: .9375rem; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2000;
  padding: 12px 20px; border-radius: 3px; background: var(--raised); color: var(--text);
  border: 1px solid var(--signal); font-family: var(--display); font-weight: 600;
}

@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow-y: auto; }
  .queue { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .editor { overflow: visible; }
  .editor-inner { padding: 20px 18px 48px; }
  .two { grid-template-columns: 1fr; }
}

/* ---------- Buildings on the map ---------- */
.bldg-mark span {
  display: block; width: 24px; height: 24px; border-radius: 4px;
  background: var(--panel); border: 2px solid var(--signal);
  box-shadow: 0 0 10px rgba(255, 176, 32, .5);
  position: relative;
}
.bldg-mark span::before {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 9px; height: 9px; border: 2px solid var(--signal); border-radius: 1px;
}

/* ---------- Floor-plan viewer (public panel) ---------- */
.floorplan { margin: 16px -24px 0; }
.plan-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 24px 12px; }
.plan-tabs button {
  padding: 6px 14px; border: 1px solid var(--line); border-radius: 3px; background: var(--raised);
  font-family: var(--display); font-weight: 600; letter-spacing: .01em; cursor: pointer;
}
.plan-tabs button:hover { border-color: var(--signal); }
.plan-tabs button[aria-pressed=true] { background: var(--signal); border-color: var(--signal); color: var(--night); }
.plan-stage { position: relative; background: #0A1018; }
.plan-img { display: block; width: 100%; height: auto; }
.plan-pins { position: absolute; inset: 0; pointer-events: none; }  /* stage 2 draws pins here */
.plan-empty { padding: 40px 24px; background: var(--night); color: var(--muted); text-align: center; }
.plan-empty p { margin: 0; }

/* ---------- Building editor (moderation) ---------- */
.list-add { padding: 12px 20px; border-bottom: 1px solid var(--line); }
.list-add .ghost { width: 100%; }
.danger-link { color: var(--rec); }
.danger-link:hover { color: var(--rec); text-decoration: underline; }

.floor-row { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.floor-thumb {
  width: 92px; height: 70px; flex: none; border: 1px solid var(--line); background: #0A1018;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.floor-thumb img { width: 100%; height: 100%; object-fit: cover; }
.floor-thumb span { color: var(--muted); font-size: .8125rem; }
.floor-meta { flex: 1; min-width: 0; }
.floor-meta strong { font-family: var(--display); font-weight: 600; }
.floor-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-top: 6px; }
.floor-actions .file-btn { padding: 6px 12px; font-size: .875rem; }
.floor-actions .link { padding: 6px 2px; font-size: .875rem; }

/* ---------- Contact note (camera editor) & inbox ---------- */
.contact-note {
  display: flex; flex-direction: column; gap: 2px; margin: 22px 0 0;
  padding: 12px 14px; background: var(--raised); border: 1px solid var(--line);
  border-left: 3px solid var(--signal); border-radius: 3px;
}
.contact-label { font-family: var(--display); font-weight: 600; font-size: .8125rem; color: var(--muted); }
.contact-value { font-size: 1.0625rem; word-break: break-word; }

.message-view h2 { margin-top: 0; }
.message-body {
  white-space: pre-wrap; word-break: break-word; margin: 18px 0;
  padding: 16px; background: var(--raised); border: 1px solid var(--line); border-radius: 3px;
  color: #C9D4E1; line-height: 1.6;
}
