/* ============================================================================
   EchoRP Crime Map — stylesheet
   Identity: night-ops case file. Graphite panels, hairline borders,
   police-tape amber as the single accent. Category colors come from data.
   Type: Oswald (display) · Inter (body) · JetBrains Mono (coords / case ids)
   ============================================================================ */

:root {
  --ink-0: #07090d;
  --ink-1: #0c1016;
  --ink-2: #121722;
  --ink-3: #1a2130;
  --ink-4: #232c3f;

  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.3);

  --tape: #f5b52e;            /* police-tape amber */
  --tape-bright: #ffc94d;
  --tape-dim: rgba(245, 181, 46, 0.14);
  --tape-line: rgba(245, 181, 46, 0.45);

  --danger: #f26d6d;
  --danger-dim: rgba(242, 109, 109, 0.14);
  --ok: #57d98a;

  --text: #eef2f7;
  --text-dim: #9aa5b5;
  --text-faint: #647082;

  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 18px 44px rgba(2, 4, 8, 0.72);
  --shadow-soft: 0 8px 22px rgba(2, 4, 8, 0.5);

  --topbar-h: 58px;
  --sidebar-w: 316px;
}

* , *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  overflow: hidden;
}

::selection { background: var(--tape); color: #14100a; }

button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

/* Thin, quiet scrollbars everywhere */
* { scrollbar-width: thin; scrollbar-color: var(--ink-4) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 999px; }
*::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
  outline: 2px solid var(--tape);
  outline-offset: 1px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----------------------------------------------------------------------------
   Map
---------------------------------------------------------------------------- */
#map {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: #0a0d12;
}

#map::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 400;
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.85);
}

.leaflet-container { background: #0a0d12 !important; font-family: var(--font-body); }

.leaflet-control-zoom {
  border: 1px solid var(--line-strong) !important;
  border-radius: var(--radius-sm) !important;
  overflow: hidden;
  box-shadow: var(--shadow-soft) !important;
}
.leaflet-control-zoom a {
  background: var(--ink-2) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
.leaflet-control-zoom a:hover { background: var(--ink-3) !important; }

.leaflet-div-icon { background: transparent; border: none; }

.custom-div-icon svg { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6)); }

.leaflet-marker-icon.highlighted { animation: pin-bounce 0.6s ease; z-index: 999999 !important; }
.leaflet-marker-icon.pin-selected svg { filter: drop-shadow(0 0 6px rgba(245, 181, 46, 0.9)); }

@keyframes pin-bounce {
  0%   { transform: translateY(0)     scale(1); }
  30%  { transform: translateY(-14px) scale(1.12); }
  50%  { transform: translateY(0)     scale(1); }
  70%  { transform: translateY(-6px)  scale(1.05); }
  100% { transform: translateY(0)     scale(1); }
}

.pin-temp-icon .pin-temp {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--tape);
  border: 3px solid #14100a;
  box-shadow: 0 0 0 4px rgba(245, 181, 46, 0.35);
  animation: temp-pulse 1.4s ease-in-out infinite;
}
@keyframes temp-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(245, 181, 46, 0.35); }
  50%      { box-shadow: 0 0 0 10px rgba(245, 181, 46, 0.12); }
}

/* ----------------------------------------------------------------------------
   Top bar
---------------------------------------------------------------------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px 0 14px;
  background: rgba(10, 13, 19, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--tape);
  color: #14100a;
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.15;
  white-space: nowrap;
}
.brand-title span { color: var(--tape); }

.brand-sub {
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}

.topbar-actions { display: flex; align-items: center; gap: 9px; }

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--ink-1);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}
.source-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
}
.source-pill.live { border-color: rgba(87, 217, 138, 0.4); color: #a7ecc3; }
.source-pill.live .source-dot { background: var(--ok); box-shadow: 0 0 8px rgba(87, 217, 138, 0.8); }
.source-pill.warn { border-color: var(--tape-line); color: var(--tape-bright); }
.source-pill.warn .source-dot { background: var(--tape); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--ink-2);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--ink-3); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-accent {
  background: var(--tape);
  border-color: var(--tape);
  color: #14100a;
  font-weight: 600;
}
.btn-accent:hover { background: var(--tape-bright); border-color: var(--tape-bright); }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: var(--ink-2); }

.btn-danger {
  background: var(--danger-dim);
  border-color: rgba(242, 109, 109, 0.4);
  color: #ffb3b3;
}
.btn-danger:hover { background: rgba(242, 109, 109, 0.25); }

.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 26px; height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-faint);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--ink-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-dim); color: #ffb3b3; }

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: var(--ink-1);
  color: var(--text-dim);
}

/* User chip */
.user-area { display: flex; align-items: center; gap: 9px; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 11px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--ink-1);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.user-chip:hover { border-color: var(--tape-line); background: var(--ink-2); }

.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--ink-3);
  flex-shrink: 0;
}
.avatar-sm { width: 20px; height: 20px; }
.avatar-lg { width: 52px; height: 52px; }

.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ink-4);
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-name { font-weight: 500; font-size: 13px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.role-badge {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--ink-3);
  color: var(--text-dim);
}
.role-badge.owner  { background: var(--tape-dim); color: var(--tape-bright); }
.role-badge.editor { background: rgba(87, 217, 138, 0.12); color: #a7ecc3; }
.role-badge.viewer { background: rgba(125, 165, 255, 0.12); color: #b9ccff; }

/* Mobile drawer */
.mobile-only { display: none; }

.mobile-drawer {
  position: fixed;
  top: calc(var(--topbar-h) + 8px);
  right: 10px;
  width: 240px;
  z-index: 1350;
  background: var(--ink-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ----------------------------------------------------------------------------
   Sidebar
---------------------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  background: rgba(10, 13, 19, 0.94);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--line);
  transition: transform 0.22s ease;
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-toggle {
  position: fixed;
  top: calc(var(--topbar-h) + 14px);
  left: var(--sidebar-w);
  z-index: 1201;
  width: 22px; height: 44px;
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 8px 8px 0;
  background: rgba(10, 13, 19, 0.94);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  transition: left 0.22s ease, color 0.15s ease;
}
.sidebar-toggle:hover { color: var(--tape); }
.sidebar.collapsed + .sidebar-toggle,
.sidebar-toggle.collapsed { left: 0; }

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.tab {
  flex: 1;
  padding: 12px 4px 11px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-faint);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--tape); border-bottom-color: var(--tape); }

.sidebar-search {
  position: relative;
  margin: 12px 12px 0;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  padding: 9px 34px 9px 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--ink-1);
  color: var(--text);
  font-size: 13px;
}
.sidebar-search input::placeholder { color: var(--text-faint); }
.sidebar-search input:focus { outline: none; border-color: var(--tape-line); }
.search-icon {
  position: absolute;
  top: 50%; left: 10px;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-faint);
  pointer-events: none;
}
.search-kbd {
  position: absolute;
  top: 50%; right: 9px;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-results {
  margin: 6px 12px 0;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink-1);
  flex-shrink: 0;
}
.search-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 11px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover, .search-item.active { background: var(--ink-3); }
.search-item .cat-dot { flex-shrink: 0; }
.search-item-cat { margin-left: auto; color: var(--text-faint); font-size: 11px; flex-shrink: 0; }
.search-item-sub { display: block; color: var(--text-faint); font-size: 11px; margin-top: 1px; }
.search-empty { padding: 12px; color: var(--text-faint); font-size: 12px; text-align: center; }

.tab-page { display: none; flex: 1; overflow-y: auto; padding: 12px; }
.tab-page.active { display: block; }

/* Category blocks */
.cat-block { margin-bottom: 6px; }

.cat-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink-1);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.cat-head:hover { background: var(--ink-2); border-color: var(--line-strong); }
.cat-block.open .cat-head { border-color: var(--line-strong); background: var(--ink-2); }

.cat-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}

.cat-name {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--ink-3);
  border-radius: 4px;
  padding: 1px 6px;
}

.cat-chevron {
  color: var(--text-faint);
  font-size: 10px;
  transition: transform 0.18s ease;
}
.cat-block.open .cat-chevron { transform: rotate(90deg); }

.cat-tools { display: flex; align-items: center; gap: 2px; }
.cat-eye.off { color: var(--tape); }
.cat-block.cat-hidden .cat-head { opacity: 0.55; }

.cat-panel { display: none; padding: 6px 2px 4px 8px; }
.cat-block.open .cat-panel { display: block; }

.loc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-left: 2px solid var(--line-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.loc-item:hover, .loc-item.selected {
  background: var(--ink-2);
  color: var(--text);
  border-left-color: var(--tape);
}
.loc-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-item-meta { display: inline-flex; align-items: center; gap: 6px; color: var(--text-faint); font-size: 10.5px; flex-shrink: 0; }
.loc-item-meta svg { display: block; }

.empty-state {
  padding: 26px 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.6;
}
.empty-state b { color: var(--text-dim); }

/* Zones */
.zone-controls { margin-bottom: 10px; }

.zone-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px;
  margin-bottom: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink-1);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.zone-item:hover { background: var(--ink-2); border-color: var(--line-strong); }

.zone-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}

.zone-item-name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-item-kind {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
}

/* Zone name labels drawn on the map (Leaflet tooltips, restyled).
   The outer box keeps its natural size so Leaflet centers it correctly;
   .zone-label-inner is scaled via transform to track the zoom level. */
.leaflet-tooltip.zone-label {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  color: #fff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 12px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}
.leaflet-tooltip.zone-label::before { display: none; }

.zone-label-inner {
  display: inline-block;
  transform-origin: center center;
  white-space: nowrap;
}

/* Crew documents (Notes tab) — sidebar list */
.pinned-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tape-bright);
  background: var(--tape-dim);
  border-radius: 4px;
  padding: 2px 7px;
}

.doc-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 10px 11px;
  margin-bottom: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink-1);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.doc-row:hover { background: var(--ink-2); border-color: var(--line-strong); }
.doc-row.pinned { border-color: var(--tape-line); }

.doc-row-icon { color: var(--text-faint); flex-shrink: 0; margin-top: 1px; }
.doc-row-main { flex: 1; min-width: 0; }
.doc-row-title {
  display: block;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-row-star { color: var(--tape); }
.doc-row-sub {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Document viewer / editor modal */
.doc-modal {
  position: fixed;
  inset: 0;
  z-index: 2800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(8px);
  animation: fade-in 0.16s ease;
}

.doc-panel {
  width: min(920px, 100%);
  height: min(88vh, 100%);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--ink-1);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: modal-in 0.18s ease;
}

.doc-head {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.doc-head-row { display: flex; align-items: center; gap: 12px; }

.doc-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-title-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.doc-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

.doc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.doc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
  flex-shrink: 0;
}
.doc-tool {
  min-width: 30px;
  height: 28px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}
.doc-tool:hover { background: var(--ink-3); color: var(--text); }
.doc-tool b, .doc-tool i, .doc-tool u, .doc-tool s { font-size: 13px; }
.doc-tool-sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 6px; }

.doc-content {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px 48px;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text);
  word-wrap: break-word;
}
.doc-content:focus { outline: none; }
.doc-content.editing { caret-color: var(--tape); background: var(--ink-0); }

/* Document typography */
.doc-content h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.doc-content h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 16px 0 8px;
  color: var(--tape-bright);
}
.doc-content h3 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 14px 0 6px;
}
.doc-content h1:first-child, .doc-content h2:first-child, .doc-content h3:first-child { margin-top: 0; }
.doc-content p, .doc-content div { margin: 0 0 8px; }
.doc-content ul, .doc-content ol { margin: 0 0 10px; padding-left: 24px; }
.doc-content li { margin-bottom: 3px; }
.doc-content blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--tape-line);
  background: var(--ink-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
}
.doc-content pre, .doc-content code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.doc-content code { padding: 1px 5px; }
.doc-content pre { padding: 10px 12px; overflow-x: auto; }
.doc-content hr {
  border: none;
  border-top: 1px solid var(--line-strong);
  margin: 16px 0;
}
.doc-content a { color: var(--tape-bright); }

@media (max-width: 720px) {
  .doc-modal { padding: 0; }
  .doc-panel { width: 100%; height: 100%; border-radius: 0; border: none; }
}

/* Activity feed */
.activity-item {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 10px 8px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
}
.activity-item:hover { background: var(--ink-1); }
.activity-item b { color: var(--text); font-weight: 600; }
.activity-item .act-time {
  display: block;
  color: var(--text-faint);
  font-size: 10.5px;
  font-family: var(--font-mono);
  margin-top: 2px;
}
.activity-item .act-quote {
  display: block;
  color: var(--text-faint);
  font-style: italic;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------------------------
   Drawers (dossier + editor)
---------------------------------------------------------------------------- */
.drawer {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: 12px;
  bottom: 12px;
  width: 372px;
  max-width: calc(100vw - 24px);
  z-index: 1250;
  background: rgba(12, 16, 22, 0.97);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.22s ease;
}
@keyframes drawer-in {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.drawer-tape { height: 5px; flex-shrink: 0; background: var(--ink-4); }

.tape-stripes {
  background: repeating-linear-gradient(
    -45deg,
    var(--tape) 0 14px,
    #14100a 14px 28px
  );
}

.drawer-close {
  position: absolute;
  top: 13px; right: 12px;
  z-index: 5;
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--text-dim);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.drawer-close:hover { background: var(--danger-dim); color: #ffb3b3; }

.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 18px; }

/* Dossier content */
.dossier-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 30px 7px 0;
}
.dossier-eyebrow .cat-chip { cursor: default; }
.dossier-case { font-family: var(--font-mono); letter-spacing: 0.06em; font-weight: 400; }

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--ink-3);
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.dossier-title {
  margin: 0 26px 10px 0;
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.15;
}

.credit-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
  font-size: 12px;
  color: var(--text-dim);
}
.credit-line .credit-who {
  background: none; border: none; padding: 0;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.credit-line .credit-who:hover { color: var(--tape); text-decoration: underline; }
.credit-sub { font-size: 11px; color: var(--text-faint); margin: -8px 0 13px 0; }

.dossier-img-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--ink-1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 13px;
}
.dossier-img-wrap img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.dossier-img-note { color: var(--text-faint); font-size: 12px; }

.dossier-info {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 2px solid var(--tape-line);
  background: var(--ink-1);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 8px;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section-label .count { color: var(--tape); }

.dossier-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.dossier-coords {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  cursor: pointer;
}
.dossier-coords:hover { color: var(--text-dim); }

/* Recipes (view) */
.recipe-view {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink-1);
  padding: 11px 12px;
  margin-bottom: 8px;
}
.recipe-view-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.recipe-view-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.recipe-view-qty { font-family: var(--font-mono); font-size: 11px; color: var(--tape-bright); }
.recipe-view-time { font-size: 11px; color: var(--text-faint); margin-bottom: 8px; }
.recipe-view-time b {
  color: #a7ecc3;
  background: rgba(87, 217, 138, 0.12);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-weight: 600;
}
.recipe-ings { display: flex; flex-wrap: wrap; gap: 6px; }
.recipe-ing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ink-2);
  font-size: 12px;
  color: var(--text-dim);
}
.recipe-ing img {
  width: 22px; height: 22px;
  object-fit: contain;
  border-radius: 4px;
  background: var(--ink-1);
  cursor: zoom-in;
}
.recipe-ing .qty { font-family: var(--font-mono); font-size: 10.5px; color: var(--tape-bright); }

/* Notes */
.note-item {
  display: flex;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.note-item:last-child { border-bottom: none; }
.note-main { flex: 1; min-width: 0; }
.note-head { display: flex; align-items: baseline; gap: 7px; margin-bottom: 2px; }
.note-author {
  background: none; border: none; padding: 0;
  font: inherit;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.note-author:hover { color: var(--tape); }
.note-time { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); }
.note-body { font-size: 13px; color: var(--text-dim); line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.note-del { margin-left: auto; align-self: flex-start; }

.note-composer { display: flex; flex-direction: column; gap: 7px; margin-top: 9px; }
.note-composer textarea {
  width: 100%;
  min-height: 58px;
  resize: vertical;
}
.note-composer .btn { align-self: flex-end; }
.notes-hint { color: var(--text-faint); font-size: 11.5px; margin: 6px 0 0; }

/* ----------------------------------------------------------------------------
   Forms (editor drawer, modals)
---------------------------------------------------------------------------- */
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-field label {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.input, textarea.input, select.input {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--ink-1);
  color: var(--text);
  font-size: 13px;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--tape-line); box-shadow: 0 0 0 3px var(--tape-dim); }
textarea.input { resize: vertical; min-height: 64px; }
select.input { cursor: pointer; }

input[type="color"].input {
  padding: 3px;
  height: 37px;
  cursor: pointer;
}

.field-hint { font-size: 11px; color: var(--text-faint); }

.editor-title {
  margin: 2px 26px 14px 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.img-preview {
  width: 100%;
  max-height: 150px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--ink-1);
  margin-top: 6px;
}

.editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.editor-actions .btn-accent { flex: 1; }

.coords-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.coords-note { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

/* Recipe builder */
.recipe-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink-1);
  padding: 10px;
  margin-bottom: 9px;
}
.recipe-head { display: flex; gap: 7px; margin-bottom: 8px; }
.recipe-head .input { flex: 1; }
.recipe-grid { display: grid; grid-template-columns: 1fr 84px; gap: 8px; margin-bottom: 8px; }
.r-item { display: grid; grid-template-columns: 1fr 56px 1fr 26px; gap: 6px; margin-bottom: 6px; align-items: center; }
.r-item .input { padding: 7px 9px; font-size: 12px; }

/* ----------------------------------------------------------------------------
   Placement banner, move bar, context menu
---------------------------------------------------------------------------- */
.placement-banner, .move-bar {
  position: fixed;
  top: calc(var(--topbar-h) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1400;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--tape-line);
  background: rgba(12, 16, 22, 0.96);
  box-shadow: var(--shadow);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  animation: banner-in 0.2s ease;
  white-space: nowrap;
}
@keyframes banner-in {
  from { transform: translate(-50%, -8px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}
.tape-chip {
  width: 34px; height: 12px;
  border-radius: 3px;
  background: repeating-linear-gradient(-45deg, var(--tape) 0 6px, #14100a 6px 12px);
  flex-shrink: 0;
}
.map-crosshair { cursor: crosshair !important; }

.context-menu {
  position: fixed;
  z-index: 3400;
  min-width: 190px;
  padding: 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--ink-1);
  box-shadow: var(--shadow);
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.ctx-item:hover { background: var(--ink-3); }
.ctx-item svg { color: var(--text-faint); flex-shrink: 0; }
.ctx-coords {
  padding: 6px 10px 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

/* ----------------------------------------------------------------------------
   Gate (private map)
---------------------------------------------------------------------------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 10, 0.78);
  backdrop-filter: blur(8px);
}
.gate-card {
  width: min(400px, calc(100vw - 40px));
  padding: 28px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--ink-1);
  box-shadow: var(--shadow);
  text-align: center;
}
.gate-tape {
  height: 12px;
  border-radius: 3px;
  background: repeating-linear-gradient(-45deg, var(--tape) 0 10px, #14100a 10px 20px);
  margin: -8px 0 18px;
}
.gate-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.gate-card p { margin: 0 0 18px; color: var(--text-dim); font-size: 13.5px; line-height: 1.6; }
.gate-actions { display: flex; justify-content: center; gap: 9px; }

/* ----------------------------------------------------------------------------
   Modals
---------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 6, 10, 0.68);
  backdrop-filter: blur(6px);
  animation: fade-in 0.16s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--ink-1);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: modal-in 0.18s ease;
}
@keyframes modal-in {
  from { transform: translateY(10px) scale(0.985); opacity: 0; }
  to   { transform: translateY(0)    scale(1);     opacity: 1; }
}
.modal.modal-wide { width: min(640px, 100%); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 18px 13px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.modal-tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.modal-tabs .tab { flex: none; padding: 10px 13px 9px; }

/* Admin rows */
.admin-list { display: flex; flex-direction: column; }
.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.admin-row:last-child { border-bottom: none; }
.admin-row .who { flex: 1; min-width: 0; }
.admin-row .who .name { font-weight: 600; }
.admin-row .who .sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-add {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
.admin-add .full { grid-column: 1 / -1; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 14px; }
.stat-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink-2);
  text-align: center;
}
.stat-num { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--tape); }
.stat-label {
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 2px;
}

/* Profile modal */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.profile-name { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: 0.05em; }
.profile-sub { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); }
.profile-stats { display: flex; gap: 9px; margin-bottom: 6px; }
.profile-pin-list { max-height: 260px; overflow-y: auto; }

/* ----------------------------------------------------------------------------
   Image modal, toasts, busy pill
---------------------------------------------------------------------------- */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: rgba(2, 3, 6, 0.92);
  cursor: zoom-out;
}
.image-modal img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: modal-in 0.2s ease;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--tape);
  background: var(--ink-1);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-soft);
  animation: toast-in 0.2s ease;
  max-width: 320px;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
.toast.out { opacity: 0; transform: translateX(12px); transition: opacity 0.25s ease, transform 0.25s ease; }
@keyframes toast-in {
  from { transform: translateX(16px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.busy-pill {
  position: fixed;
  top: calc(var(--topbar-h) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(12, 16, 22, 0.96);
  box-shadow: var(--shadow-soft);
  font-size: 12.5px;
  color: var(--text-dim);
}
.busy-pill::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--tape-dim);
  border-top-color: var(--tape);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------------------
   Responsive
---------------------------------------------------------------------------- */
@media (max-width: 940px) {
  :root { --sidebar-w: 272px; }
}

@media (max-width: 720px) {
  .mobile-only { display: inline-flex; }
  .topbar .user-area, .topbar #btn-add-pin, .topbar #btn-admin { display: none; }
  .brand-sub { display: none; }
  .source-pill span:last-child { display: none; }

  .sidebar {
    top: auto;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 46vh;
    border-right: none;
    border-top: 1px solid var(--line-strong);
    border-radius: 16px 16px 0 0;
  }
  .sidebar.collapsed { transform: translateY(calc(100% - 42px)); }
  .sidebar-toggle { display: none; }

  .drawer {
    top: auto;
    left: 10px; right: 10px; bottom: 10px;
    width: auto;
    max-height: 72vh;
  }

  .placement-banner, .move-bar { width: calc(100vw - 24px); justify-content: center; flex-wrap: wrap; white-space: normal; }
}
