:root {
  --bg: #1e1f24;
  --panel: #2a2c33;
  --border: #3a3d46;
  --text: #e7e9ee;
  --muted: #9aa0ad;
  --accent: #2f6bff;
  --danger: #d23b3b;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win over display rules below (e.g. the
   auth/dashboard views toggle via [hidden], and .card-wrap sets display:flex). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 18px; letter-spacing: 0.5px; }
.spacer { flex: 1; }

/* Editor toolbar on TWO levels (title/nav row on top, all the tools on the row
   below) instead of one long, spread-out line. Scoped to the editor page
   (body.editor) and to desktop widths — the existing <=820px rules already wrap
   the toolbar on small screens. Body becomes a column so the map flexes to fill
   whatever height is left once the toolbar grows past one row (the base rule
   hard-codes calc(100% - 52px), which assumes a single-row toolbar). */
@media (min-width: 821px) {
  body.editor { display: flex; flex-direction: column; }
  body.editor #main { flex: 1; height: auto; min-height: 0; }
  body.editor #topbar {
    flex-wrap: wrap;
    height: auto;
    row-gap: 4px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  /* Full-width, zero-height break: nav items sit above it, tools below it. */
  body.editor #topbar .spacer { flex: 0 0 100%; height: 0; }
  /* Condense the toolbar buttons a touch so more fit per row. */
  body.editor #topbar .btn,
  body.editor #topbar select.btn { padding: 6px 9px; font-size: 12.5px; }
}

.layout-name {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  width: 200px;
}

.btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
select.btn { background: var(--bg); color: var(--text); }
/* Logo library picker (modal). */
#logo-picker {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
}
.logo-picker-card {
  width: min(560px, 92vw); max-height: 86vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.logo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px; margin: 12px 0;
}
.logo-cell {
  position: relative; aspect-ratio: 1; border: 1px solid var(--border);
  border-radius: 8px; background:
    repeating-conic-gradient(#3a3d46 0% 25%, #2a2c33 0% 50%) 50% / 16px 16px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.logo-cell img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: pointer; }
.logo-cell .logo-del {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
  border: none; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer;
}
.logo-cell .logo-del:hover { background: var(--danger); }
.logo-cell-name {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 10px; line-height: 1.2; padding: 2px 4px;
  background: rgba(0, 0, 0, 0.6); color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
  pointer-events: none;
}
.lp-search {
  width: 100%; box-sizing: border-box; margin: 4px 0 0;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 13px;
}

/* Live presence avatars (who's on the map right now). */
.presence { display: flex; align-items: center; }
.presence-dot:first-child { margin-left: 0; }
.presence-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  border: 2px solid var(--panel); margin-left: -6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  text-transform: uppercase; cursor: default;
  animation: presence-pop 0.18s ease-out;
}
.presence-dot.more { background: var(--bg); color: var(--muted); }
@keyframes presence-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Layers panel rows. */
.layer-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.layer-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px;
}
.layer-row.active { border-color: var(--accent); }
.layer-vis { display: flex; align-items: center; margin: 0; }
.layer-vis input { width: 16px; height: 16px; cursor: pointer; }
.layer-name { flex: 1; font-size: 13px; word-break: break-word; }
.layer-count {
  font-size: 11px; color: var(--muted); background: var(--panel);
  border-radius: 10px; padding: 1px 7px; min-width: 18px; text-align: center;
}
.lyr-act {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 5px; font-size: 12px; line-height: 1; padding: 4px 6px; cursor: pointer;
}
.lyr-act:hover { border-color: var(--accent); }
.lyr-act[disabled] { opacity: 0.35; cursor: not-allowed; }
.lyr-active { color: var(--accent); }

/* Admin: create-account form + credential result. */
.admin-create { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.admin-create h3 { margin: 0 0 4px; font-size: 15px; }
.admin-create .row { gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.admin-create input { flex: 1; min-width: 140px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 7px 10px; }
.ac-result { margin-top: 12px; background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; padding: 12px; }
.ac-cred { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.ac-cred span { width: 70px; color: var(--muted); font-size: 12px; }
.ac-cred code { background: var(--panel); border: 1px solid var(--border); border-radius: 5px; padding: 3px 8px; font-size: 13px; user-select: all; }

/* Active tool (e.g. + Area while drawing) glows so the mode is obvious. */
.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(47, 107, 255, 0.35), 0 0 12px rgba(47, 107, 255, 0.75);
}

#add-tent { background: var(--accent); border-color: var(--accent); }
#add-structure { background: var(--danger); border-color: var(--danger); }

.goto { display: flex; gap: 4px; }
.goto input {
  width: 190px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
}

.rotate { display: flex; gap: 4px; align-items: center; }
.rotate input {
  width: 52px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
}
.rotate .btn { font-size: 16px; line-height: 1; padding: 6px 9px; }

#main { display: flex; height: calc(100% - 52px); }
#map { flex: 1; background: #000; touch-action: none; }

#sidebar {
  width: 300px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 14px;
  overflow-y: auto;
}
#sidebar h2 { margin: 0 0 12px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
}
.field input[type="color"] { padding: 2px; height: 34px; }
.field input[type="range"] { padding: 0; }

.row { display: flex; gap: 8px; }
.row .field { flex: 1; }

.coords {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  margin-bottom: 12px;
  font-size: 13px;
}
.coords span { flex: 1; font-variant-numeric: tabular-nums; }
.coords button { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; }

.dup {
  width: 100%;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 9px;
  cursor: pointer;
  margin-top: 6px;
}
.dup:hover { background: var(--accent); color: #fff; }

.danger {
  width: 100%;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  padding: 9px;
  cursor: pointer;
  margin-top: 6px;
}
.danger:hover { background: var(--danger); color: #fff; }

/* Object labels on the map */
.pit-label { pointer-events: none; }
.pit-label-box {
  transform: translate(-50%, -50%);
  font-size: 11px;
  line-height: 1.1;
  text-align: center;
  /* nowrap: lines break ONLY where the user pressed Enter (rendered as <br>),
     never auto-wrapped at spaces — so the label matches the Name field exactly. */
  white-space: nowrap;
  overflow: hidden;
  font-weight: 700;
}
.pit-logo { display: block; margin: 0 auto 1px; max-width: 100%; object-fit: contain; }
.pit-label-name {
  font-weight: 700;
  display: block;
  /* Break only on the user's own line breaks (<br>), not auto-wrapped. */
  white-space: nowrap;
}
.logo-preview { margin-bottom: 6px; }
.logo-preview img { max-width: 100%; max-height: 80px; border-radius: 6px; border: 1px solid var(--border); }
.pit-label-dims {
  font-size: 0.85em;
  opacity: 0.85;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* "Scaled" labels: an always-visible pill that never clips, so the name is
   readable at any zoom (white on dark, legible over any imagery). */
.pit-pill {
  display: inline-block;
  background: rgba(15, 17, 23, 0.82);
  color: #fff;
  padding: 1px 7px;
  border-radius: 7px;
  /* Break only where the user pressed Enter (<br>); never auto-wrap at spaces. */
  white-space: nowrap;
  text-align: center;
  font-weight: 700;
  line-height: 1.15;
}
.pit-pill-dims { display: block; font-size: 0.82em; opacity: 0.92; }
/* Name field is a small textarea so you can press Enter for a second line. */
textarea.name-field {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  line-height: 1.2;
}

/* Rotation handle */
.rot-handle div {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.rot-handle div:active { cursor: grabbing; }

/* Group rotate handle (multi-selection) — green, to set it apart from the
   white single-object handle. */
.group-rot div {
  border-color: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.3), 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* "Rotate group" control in the Properties panel. */
.grp-rotate { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.grp-rotate input { width: 58px; }
.grp-rotate .btn { font-size: 16px; line-height: 1; padding: 4px 11px; }
.grp-deg { opacity: 0.8; }

/* Area vertex handles */
.vert-handle div {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: move;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Clone & align: the "+" drop button that appears on an object's edge, and the
   cursor shown while the tool is armed. */
.clone-plus div {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2px solid #fff;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
  transition: transform 0.08s ease;
}
.clone-plus div:hover { transform: scale(1.15); }
.leaflet-container.clone-mode { cursor: copy; }

.pit-keynum { font-weight: 800; font-size: 15px; line-height: 1; }

/* While rasterizing an export image, hide on-map controls/handles and the HTML
   label markers — html2canvas mis-renders the transform-centered labels, so the
   names are drawn directly onto the canvas instead (see drawLabelsOnCanvas). */
body.exporting .leaflet-control-zoom,
body.exporting .rot-handle,
body.exporting .clone-plus,
body.exporting .vert-handle { display: none !important; }
/* Labels are hidden only when we redraw them onto the export canvas (print
   box / numbered-key modes). In the plain WYSIWYG export the on-screen labels
   are captured directly, so they stay visible. (Road arrows are excluded from
   the capture in app.js itself — ignoreElements — so a stale stylesheet can
   never hide them without the matching redraw.) */
body.exporting.redraw-labels .pit-label { display: none !important; }

/* Container used to rasterize the legend into its own image. Sits at the
   top-left under the export overlay (z-index 5000) so it's never visible, but
   stays on-screen at a normal coordinate so html2canvas measures it correctly. */
.export-legend-capture {
  position: fixed; left: 0; top: 0; z-index: 1; width: 520px;
  background: #fff; color: #000; padding: 20px 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.export-legend-capture h3 { margin: 0 0 12px; font-size: 18px; }
.export-legend-capture ol { columns: 2; column-gap: 28px; font-size: 14px; line-height: 1.7; margin: 0; padding-left: 22px; }

/* Full-screen cover shown while an export image renders. */
#export-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(20, 21, 26, 0.72);
  display: flex; align-items: center; justify-content: center;
}
.export-overlay-box {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  padding: 16px 22px; border-radius: 10px; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Export dropdown menu. */
.menu-wrap { position: relative; display: inline-block; }
.dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px; min-width: 190px;
  z-index: 1500; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.dropdown .menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; color: var(--text);
  padding: 9px 10px; border-radius: 6px; font: inherit; cursor: pointer;
}
.dropdown .menu-item:hover { background: var(--bg); }

/* --- Buttons (shared) ----------------------------------------------------- */
.btn.primary {
  background: linear-gradient(180deg, #3f7bff, #2a60ea);
  border-color: #2a60ea;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.block { width: 100%; }
.btn.danger-sm { border-color: var(--danger); color: var(--danger); }
.btn.danger-sm:hover { background: var(--danger); color: #fff; }

/* --- Dashboard / auth pages ----------------------------------------------- */
.user-chip { color: var(--muted); font-size: 13px; }

#content { height: calc(100% - 52px); overflow-y: auto; padding: 24px; }

.card-wrap { display: flex; justify-content: center; align-items: flex-start; padding-top: 6vh; }
.card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}
.card h1 { margin: 0 0 8px; font-size: 20px; }
.card .hint { margin: 0 0 16px; }
.card .field { margin-bottom: 12px; }
.card .row { gap: 8px; margin-top: 4px; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.msg { color: var(--danger); font-size: 13px; min-height: 16px; margin: 10px 0 0; }

.dash-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dash-head h1 { margin: 0; font-size: 22px; }
.dash-head-actions { display: flex; gap: 8px; }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-bottom: 14px; font-size: 14px; }
.crumb { background: transparent; border: 0; color: var(--accent); cursor: pointer; padding: 4px 8px; border-radius: 6px; font: inherit; }
.crumb:hover { background: var(--panel); }
.crumb.current { color: var(--text); font-weight: 600; cursor: default; }
.crumb.drop-hover { background: var(--accent); color: #fff; }
.crumb-sep { color: var(--muted); }

.map-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.shared-wrap { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 22px; }
.shared-head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 14px; }
.shared-head { margin: 0; font-size: 18px; color: var(--text); }

.tile {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  cursor: pointer;
  user-select: none;
}
.tile:hover { border-color: var(--accent); }
.tile.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.tile.drop-hover { border-color: var(--accent); background: rgba(47, 107, 255, 0.12); }
.tile-icon { font-size: 42px; line-height: 1; }
.tile-name { font-weight: 600; font-size: 13px; word-break: break-word; }
.tile-meta { color: var(--muted); font-size: 11px; }
.tile-check { position: absolute; top: 8px; left: 8px; width: 16px; height: 16px; cursor: pointer; }
.tile-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 2px; opacity: 0; transition: opacity 0.1s; }
.tile:hover .tile-actions, .tile.selected .tile-actions { opacity: 1; }
.tile-act {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  cursor: pointer;
}
.tile-act:hover { border-color: var(--accent); }
.tile-open { margin-top: 8px; padding: 5px 18px; font-size: 12px; }

.selection-bar {
  position: sticky;
  bottom: 12px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.sel-count { font-weight: 600; margin-right: auto; }

.folder-picker-list.tree { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.tree-row {
  text-align: left;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 8px;
  cursor: pointer;
}
.tree-row:hover { border-color: var(--border); }
.tree-row.active { background: var(--accent); color: #fff; }
.tree-row.disabled { opacity: 0.4; cursor: not-allowed; }

/* Folders/maps shared with me read slightly muted so the owned ones lead. */
.tile.shared-in { background: rgba(47, 107, 255, 0.06); }
.tile.shared-in:hover { background: rgba(47, 107, 255, 0.12); }
/* My folders that I'm sharing OUT get a subtle accent stripe so I can tell
   at a glance which folders have other people on them. */
.tile.shared-out { box-shadow: inset 3px 0 0 var(--accent); }

/* Share modal */
.share-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.share-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px 6px 10px;
  font-size: 13px;
}
.share-chip > span { flex: 1; word-break: break-all; }
.share-chip-x {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.share-chip-x:hover { background: var(--panel); color: var(--danger); }

/* Transparent layer placed over the map while the Select tool is armed; it
   captures the marquee drag directly so Leaflet can't swallow the events. Sits
   above the map panes but below Leaflet's controls (~1000), so zoom still works. */
.select-overlay {
  position: absolute;
  inset: 0;
  z-index: 640;
  cursor: crosshair;
}
/* Box-select marquee rectangle in the editor (its border/fill come from this
   class; app.js only sets the box's position and size inline). Drawn as a child
   of the overlay, so it renders above it. */
.marquee-box {
  position: absolute;
  z-index: 650;
  border: 1px solid #2f6bff;
  background: rgba(47, 107, 255, 0.15);
  pointer-events: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
}
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.newmap-results { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; max-height: 230px; overflow-y: auto; }
.newmap-result {
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
}
.newmap-result:hover { border-color: var(--accent); }

#invite-panel { margin-top: 32px; border-top: 1px solid var(--border); padding-top: 20px; }
#invite-panel h2 { font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 0 0 6px; }
.invite-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.invite-open { display: flex; gap: 6px; align-items: center; }
.invite-open select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
}
.invite-list { display: flex; flex-direction: column; gap: 8px; }
.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.invite-main { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.invite-link {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  width: 100%;
}
.invite-meta { color: var(--muted); font-size: 12px; }
.invite-actions { display: flex; gap: 6px; }

#admin-panel { margin-top: 32px; border-top: 1px solid var(--border); padding-top: 20px; }
#admin-panel h2 { font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.request-list { display: flex; flex-direction: column; gap: 8px; }
.request-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.request-info { font-size: 14px; }
.request-actions { display: flex; gap: 6px; }

/* --- Editor overlay panels (share / library) ------------------------------ */
#main { position: relative; }
.overlay-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 320px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 1000;
}
.overlay-panel h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 14px 0 8px; }
.overlay-panel .field { margin-bottom: 12px; }
.overlay-panel input[readonly] { color: var(--muted); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head strong { font-size: 15px; }
.checkline { display: flex; align-items: center; gap: 8px; }
.checkline input { width: auto; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.editor-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 12px;
}
.editor-chip button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.editor-chip button:hover { color: var(--danger); }

.lib-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.lib-name { font-size: 14px; }
.lib-actions { display: flex; gap: 6px; }
.lib-actions .btn { padding: 4px 8px; font-size: 12px; }

/* --- Mobile / small screens ----------------------------------------------- */
@media (max-width: 820px) {
  /* Lay both pages out as a column so the toolbar can grow and the map/content
     flexes to fill the rest (the fixed calc(100% - 52px) breaks once the
     toolbar wraps to more than one row). */
  body { display: flex; flex-direction: column; }
  #topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 48px;
    padding: 6px 8px;
    gap: 6px;
  }
  .spacer { display: none; } /* let controls wrap naturally, no forced gap */
  #main { flex: 1; min-height: 0; height: auto; flex-direction: column; }
  #map { min-height: 0; }
  #content { flex: 1; min-height: 0; height: auto; padding: 14px; }

  .brand { font-size: 16px; }
  .btn { padding: 9px 11px; } /* larger tap targets */
  .layout-name { flex: 1 1 120px; width: auto; min-width: 0; }
  .goto { flex: 1 1 160px; }
  .goto input { flex: 1; width: auto; min-width: 0; }

  /* Properties become a bottom sheet beneath the map. */
  #sidebar {
    width: 100%;
    max-height: 42vh;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 12px;
  }

  /* Tool panels (share / library / export) span the screen. */
  .overlay-panel {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: calc(100% - 16px);
  }

  /* Easier-to-grab map handles on touch. */
  .rot-handle div { width: 22px; height: 22px; }
  .vert-handle div { width: 16px; height: 16px; }

  /* Dashboard density. */
  .dash-head h1 { font-size: 19px; }
  .map-list { grid-template-columns: 1fr; }
  .invite-row, .request-row { flex-wrap: wrap; }
}

/* Direction arrows on a road (rendered as L.divIcon → SVG, transparent box). */
.road-arrow { background: none; border: none; pointer-events: none; }

/* Floating banner shown while a drawing tool (road, area, ruler) is active —
   anchored to the bottom-centre of the map container. */
.draw-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 800;
  background: rgba(15, 17, 23, 0.92);
  color: #e7e9ee;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #3a3d46;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
}

/* Ruler tool: running-total badge that floats next to the last clicked point. */
.ruler-label { pointer-events: none; }
.ruler-tag {
  position: absolute;
  left: 8px;
  top: -14px;
  white-space: nowrap;
  background: #1e1f24;
  color: #ffd24a;
  border: 1px solid #ffd24a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* --- Assigned parking (claim link + editor claim tools) --------------------- */

/* Park mode makes the page a column so the legend banner gets its own row and
   the map flexes to fill the rest (the base #main rule assumes topbar-only). */
body.editor.park { display: flex; flex-direction: column; }
body.editor.park #main { flex: 1; height: auto; min-height: 0; }

#park-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.park-legend { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.park-swatch {
  width: 14px; height: 14px; border-radius: 3px; display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.4);
}
.park-swatch.park-open {
  background: repeating-conic-gradient(#5f6675 0% 25%, #9aa0ad 0% 50%) 50% / 8px 8px;
}
.park-status { color: var(--text); }
.park-mine { color: var(--text); }

/* Claim / fill dialogs — same overlay pattern as the logo picker. */
#park-modal {
  position: fixed; inset: 0; z-index: 4200;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
}
.park-card {
  width: min(420px, 92vw); max-height: 86vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.park-card h3 { margin: 0 0 8px; font-size: 17px; }
.park-card input {
  width: 100%; margin: 6px 0;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 9px 10px; font-size: 14px;
}
.park-card .row { display: flex; gap: 10px; }
.park-card .row .field { flex: 1; }
.park-card .field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.park-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.park-actions .btn { flex: 1; }
.park-actions .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

#park-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  z-index: 4300; max-width: min(480px, 90vw);
  background: rgba(20, 21, 26, 0.95); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-size: 13.5px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
#park-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Parking space labels: bg-less outlined number on the stall; a claimed
   space's name floats in a small talk bubble off the stall's end (tail
   pointing back at it) so names never cover spaces people are choosing. */
.pit-park-label {
  position: relative;
  text-align: center;
  font-weight: 700;
  line-height: 1.05;
  white-space: nowrap;
}
/* Area "talk bubble" label: white bubble floating just above the area's
   northern edge, tail pointing down into it. Names the lot without covering
   the spaces inside. */
/* Zero-size pivot at the anchor point: the inline rotate() swings the whole
   bubble around the area's edge so its bottom (and tail) always face the lot. */
.pit-area-bubble-rot {
  position: relative;
  width: 0;
  height: 0;
}
.pit-area-bubble {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, calc(-100% - 0.55em));
  background: rgba(255, 255, 255, 0.95);
  color: #111;
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 0.4em;
  padding: 0.1em 0.5em;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  text-align: center;
}
.pit-area-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 0.45em solid transparent;
  border-top-color: rgba(255, 255, 255, 0.95);
}

/* Interactive labels (an area's talk bubble): the base .pit-label rule blocks
   pointer events, so re-enable them only when Leaflet marks the marker
   interactive. */
.pit-label.leaflet-interactive { pointer-events: auto; cursor: pointer; }

/* Free-trial banner at the top of the dashboard. */
.trial-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #3a2f12; border: 1px solid #8a5a00; color: #ffd98a; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }

/* --- Landing page (signed-out) --------------------------------------------- */
.brand-logo { width: 22px; height: 22px; flex: 0 0 auto; display: block; }

.landing {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 400px);
  gap: 56px;
  align-items: start;
  max-width: 1060px;
  margin: 0 auto;
  padding-top: 7vh;
}
.landing-hero h1 {
  margin: 0 0 14px;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.5px;
  font-weight: 750;
}
.landing-sub { color: var(--muted); font-size: 16px; line-height: 1.6; margin: 0 0 22px; max-width: 56ch; }
.landing-price { margin: 22px 0 0; font-size: 15px; color: var(--muted); }
.landing-price strong { color: var(--text); font-size: 18px; }

.feature-list { list-style: none; margin: 0; padding: 0; }
.feature-list li {
  position: relative;
  padding: 5px 0 5px 30px;
  font-size: 15px;
  line-height: 1.45;
}
.feature-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(47, 107, 255, 0.18);
  color: #7ea4ff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.feature-list.compact li { font-size: 13.5px; padding: 3px 0 3px 28px; }
.feature-list.compact { margin: 6px 0 18px; }

.card .hint.legal { margin: 14px 0 0; font-size: 11.5px; }

/* Subscribe screen pricing card */
.price-card { max-width: 400px; }
.price-line { font-size: 26px; font-weight: 750; margin: 4px 0 4px; min-height: 32px; }
.price-card .btn.block { margin-top: 8px; }

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 1060px;
  margin: 56px auto 0;
  padding: 18px 0 6px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

@media (max-width: 900px) {
  .landing { grid-template-columns: 1fr; gap: 28px; padding-top: 3vh; }
  .landing-hero h1 { font-size: 28px; }
  .landing .card { max-width: 460px; }
}
