/* Copyright 2026 AeroVect. All rights reserved. */
/* Dark theme for the web lanelet editor. */

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

body {
  background: #000;
  color: #f0f0f5;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  font-size: 12px;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ---- Main layout ---- */
#viewer-canvas {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 24px;
  width: 100%;
  height: calc(100% - 24px);
  display: block;
  cursor: crosshair;
}

/* ---- Left panel ---- */
#left-panel {
  position: absolute;
  top: 10px; left: 10px;
  z-index: 100;
  background: rgba(14, 16, 26, 0.98);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 8px;
  padding: 10px;
  min-width: 190px;
  max-width: 210px;
  backdrop-filter: blur(6px);
  max-height: calc(100vh - 44px);
  overflow-y: auto;
}

#left-panel h2 {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ---- Served-tree badge (SW-6380) ----
 * Names the worktree this page is served from, directly under the title.
 * Quiet by design: the developer already knows their branch, so a correct
 * value should read as furniture and only a WRONG one should catch the eye.
 * Long branch names wrap rather than truncate — an ellipsis would eat the
 * short SHA, which is the half that disambiguates two copies of one branch.
 */
.served-version {
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.3;
  color: #6c7590;
  margin: -4px 0 8px;
  overflow-wrap: anywhere;
  cursor: help;
}
.served-version[data-state="dirty"]   { color: #b99a55; }
.served-version[data-state="unknown"] { color: #b07a5a; }

.btn-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.section { margin-bottom: 10px; }
.section-title {
  font-size: 10px;
  color: #b8bccc;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
}

/* ---- Bottom edit dock (JOSM-style) ----
 * why span full canvas width: 16+ buttons; previously the centered dock
 * with max-width left dead space on either side OR wrapped to multiple
 * rows. Stretching from the right edge of the left panel to the left
 * edge of the right panel uses the whole available width, lets buttons
 * sit on one row (justify-content: space-around distributes the gaps),
 * and clears the bottom-left of the canvas for the cursor overlay /
 * status text.
 */
#edit-dock {
  position: fixed;
  bottom: 34px;
  left: 10px;
  right: 10px;             /* full viewport width — overlays the side panels at the bottom strip */
  z-index: 110;
  display: flex;
  gap: 2px;
  align-items: center;
  /* The dock must grow UPWARD, never sideways off the screen (SW-6375).
   * It used to be `flex-wrap: nowrap`, which made its width the sum of its
   * buttons — 1600px once SW-6375 added "New yield_stop", against a 1578px
   * content box at the 1600px test viewport. `position: fixed` means nothing
   * scrolls, so #btn-undo / #btn-redo — the right-most and most-used controls —
   * simply sat outside the viewport and could not be clicked at all. Wrapping
   * makes every row at most as wide as the dock, so adding a button costs a
   * row of height instead of silently deleting a control; pinned by
   * tests/integration/dock_reachability.spec.js.
   * `flex-start` (not `space-between`) so wrapped rows stay grouped left
   * behind their CREATE / EDIT / INSPECT labels instead of being spread out. */
  justify-content: flex-start;
  flex-wrap: wrap;
  row-gap: 3px;
  white-space: nowrap;
  background: rgba(8, 10, 18, 0.98);
  border: 1px solid rgba(255,255,255,0.40);
  border-radius: 10px;
  padding: 4px 6px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.75), 0 0 0 1px rgba(0,0,0,0.5);
}
#edit-dock button {
  padding: 3px 5px;
  font-size: 10px;
  white-space: nowrap;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
#edit-dock label {
  font-size: 10px !important;
}
#edit-dock button.active {
  background: #fa0;
  color: #111;
  border-color: #fa0;
}
#edit-dock .kbd {
  margin-right: 2px;
}
#edit-dock .dock-sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.35);
  margin: 0 4px;
  flex-shrink: 0;
}
/* ---- Centerline options panel (shown above dock when W is active) ---- */
#centerline-tune {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
}

/* ---- Collapsible <details> sections inside the panels ---- */
details.collapsible-section > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 0;
  user-select: none;
}
details.collapsible-section > summary::-webkit-details-marker { display: none; }
details.collapsible-section > summary::before {
  content: "▸";
  display: inline-block;
  width: 12px;
  font-size: 10px;
  color: #b8bccc;
  transition: transform 0.15s;
}
details.collapsible-section[open] > summary::before {
  transform: rotate(90deg);
}
details.collapsible-section > summary:hover { color: #fff; background: rgba(255,255,255,0.05); border-radius: 4px; }

/* ---- Right panel (lane list) ---- */
#right-panel {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 100;
  background: rgba(14, 16, 26, 0.98);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 8px;
  padding: 10px;
  width: var(--right-panel-width, 280px);
  min-width: 220px;
  max-width: 700px;
  /* Bottom clearance leaves room for the edit-dock fixed at bottom:34px
     (~30px tall + a bit of breathing space). */
  height: calc(100vh - 90px);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(6px);
  transition: transform 0.15s ease-out;
}
/* The inspector block stays anchored at the top of the right panel — the
 * lists below scroll independently when their combined height exceeds
 * the panel. This way the inspector is always reachable regardless of
 * how many lanes / hidden / polygons / poses are listed. */
#right-panel-inspector-fixed {
  flex: 0 0 auto;
  display: flex; flex-direction: column;
}
#right-panel-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
#right-panel.hidden {
  transform: translateX(calc(100% + 20px));
}
/* Drag handle on the LEFT edge of the right panel for resizing. */
#right-panel-resize {
  position: absolute;
  top: 0; left: -4px; bottom: 0;
  width: 8px;
  cursor: ew-resize;
  z-index: 1;
}
#right-panel-resize::after {
  content: '';
  position: absolute;
  top: 50%; left: 3px;
  width: 2px; height: 32px;
  background: rgba(255,255,255,0.25);
  border-radius: 1px;
  transform: translateY(-50%);
}
#right-panel-resize:hover::after {
  background: rgba(120,200,255,0.7);
}
/* Floating chevron button to toggle visibility, sits on the right edge
   even when the panel is hidden. */
#right-panel-toggle {
  position: absolute;
  top: 14px;
  right: 0;
  z-index: 105;
  background: rgba(14, 16, 26, 0.98);
  border: 1px solid rgba(255,255,255,0.28);
  border-right: none;
  border-radius: 6px 0 0 6px;
  padding: 6px 4px;
  font-size: 12px;
  color: #cce;
  cursor: pointer;
  display: none;
  user-select: none;
}
#right-panel.hidden ~ #right-panel-toggle {
  display: block;
}
#right-panel-toggle-inline {
  background: transparent !important;
  border: none !important;
  color: #b8bccc !important;
  font-size: 14px !important;
  padding: 0 4px !important;
  cursor: pointer;
  margin-left: auto;
}
#right-panel-toggle-inline:hover { color: #fff !important; }

#right-panel h2 {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

#lane-list         { display: flex; flex-direction: column; gap: 2px; max-height: 25vh; overflow-y: auto; }
#polygon-list      { display: flex; flex-direction: column; gap: 2px; max-height: 20vh; overflow-y: auto; }
#validation-list   { display: flex; flex-direction: column; gap: 2px; max-height: 20vh; overflow-y: auto; }
#hidden-lanelet-list { display: flex; flex-direction: column; gap: 2px; max-height: 25vh; overflow-y: auto; }

.lane-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  cursor: default;
}
.lane-row:hover { background: rgba(255,255,255,0.20); border-color: rgba(255,255,255,0.30); }

.lane-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #888;
}

.lane-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #f0f0f5;
  font-size: 11px;
}

.lane-pts {
  color: #99a;
  font-size: 10px;
  flex-shrink: 0;
}

/* ---- Buttons ---- */
button {
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.32);
  color: #f0f0f5;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.1s, border-color 0.1s;
  white-space: nowrap;
}
button:hover { background: rgba(255,255,255,0.28); border-color: rgba(255,255,255,0.50); }
button:disabled { opacity: 0.40; cursor: default; }
/* A control whose server feature this site does not serve (js/app_config.js). */
.server-gated { cursor: not-allowed; }
button.active {
  background: rgba(96, 200, 255, 0.55);
  border-color: rgba(96, 200, 255, 0.95);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(96, 200, 255, 0.5) inset;
}
button.full-width { width: 100%; text-align: left; }
.btn-primary {
  background: #2566aa !important;
  border-color: #4a92dd !important;
  color: #fff !important;
}
.btn-primary:hover { background: #2e7bc8 !important; }

/* Inline keyboard-shortcut chip inside a button */
.kbd {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.55);
  color: #fff;
  border-radius: 3px;
  padding: 1px 4px;
  margin-right: 5px;
  vertical-align: 1px;
  letter-spacing: 0.05em;
}
button:hover .kbd { background: rgba(0,0,0,0.65); border-color: rgba(255,255,255,0.75); }
button.active .kbd { background: rgba(0,0,0,0.7); border-color: rgba(255,255,255,0.95); color: #fff; }

/* Shortcut reference table */
.shortcut-table {
  width: 100%;
  font-size: 10px;
  color: #888;
  border-collapse: collapse;
}
.shortcut-table td { padding: 2px 0; vertical-align: top; }
.shortcut-table td:first-child {
  color: #aac;
  font-family: 'SF Mono', monospace;
  white-space: nowrap;
  padding-right: 8px;
}

/* file input disguised as button */
.file-btn {
  display: inline-block;
  position: relative;
  overflow: hidden;
}
.file-btn input[type=file] {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ---- Sliders ---- */
.slider-group {
  margin-bottom: 6px;
}
.slider-group label {
  display: flex;
  justify-content: space-between;
  color: #999;
  font-size: 10px;
  margin-bottom: 2px;
}
input[type=range] {
  width: 100%;
  height: 4px;
  accent-color: #4af;
}

/* ---- Select ---- */
select {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #ccc;
  padding: 3px 4px;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  width: 100%;
  cursor: pointer;
}
select:focus { outline: none; border-color: rgba(80,180,255,0.5); }
/* Browser-default <option> uses the OS palette (white bg + faint gray text
   on most Linux/Chrome setups) which is unreadable on our dark theme.
   Force a dark background + light text so the dropdown contents match the
   rest of the editor. */
select option,
select optgroup {
  background-color: #1a1d2e;
  color: #e3e6f0;
}
select optgroup {
  font-style: italic;
  color: #9ad;
}

/* ---- Status bar ---- */
#status-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 24px;
  background: rgba(8, 10, 18, 1.0);
  border-top: 1px solid rgba(255,255,255,0.28);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11px;
  color: #d8dae6;
  z-index: 200;
  gap: 20px;
}

/* ---- Cursor overlay ----
 * why right-anchored on the status bar: the dock now spans the full
 * canvas width and would overlap the previous bottom:28px;left:10px
 * placement. Anchoring to the right edge of the status bar keeps the
 * coord readout always visible without colliding with anything.
 */
#cursor-overlay {
  position: absolute;
  bottom: 0; right: 0;
  height: 24px;
  z-index: 201;             /* one above #status-bar */
  display: flex;
  align-items: center;
  background: transparent;
  color: #aef;
  font-size: 11px;
  padding: 0 12px;
  pointer-events: none;
  white-space: nowrap;
}

/* ---- Origin display ---- */
#origin-display {
  color: #5a8;
  font-size: 10px;
  padding: 2px 0;
  margin-bottom: 4px;
}

/* ---- Context menu ---- */
#ctx-menu {
  display: none;
  position: fixed;
  z-index: 1000;
  background: rgba(20, 20, 35, 0.97);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 140px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
#ctx-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  border-radius: 0;
  padding: 6px 14px;
  text-align: left;
  color: #ccc;
}
#ctx-menu button:hover { background: rgba(255,255,255,0.1); }

/* ---- Lanelet dialog ---- */
/* Explicit centering — some browsers position <dialog> at top:0 instead
   of the spec-defined viewport-center, and some of our inline-styled
   dialogs override the user-agent stylesheet. Pinning the same rule on
   every dialog keeps modals centered regardless. */
dialog {
  background: rgba(20, 20, 35, 0.98);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  color: #ccc;
  padding: 20px;
  min-width: 280px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
dialog::backdrop { background: rgba(0,0,0,0.5); }

dialog h3 { margin-bottom: 14px; font-size: 13px; color: #ddd; }

.dialog-field {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.dialog-field label { font-size: 10px; color: #888; text-transform: uppercase; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.dialog-actions .btn-primary,
button.btn-primary {
  background: rgba(80,180,255,0.2);
  border-color: rgba(80,180,255,0.4);
  color: #8cf;
}
.dialog-actions .btn-primary:hover,
button.btn-primary:hover { background: rgba(80,180,255,0.3); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

/* ---- Responsive canvas resize ---- */
#viewer-canvas { touch-action: none; }

/* ---- Regulatory-element authoring panel (F-04, F-05, F-06, F-08, F-10) ---- */
.reg-panel-float {
  position: absolute;
  top: 10px;
  left: 230px;
  z-index: 120;
  background: rgba(20, 25, 40, 0.95);
  border: 1px solid rgba(120, 200, 255, 0.4);
  border-radius: 8px;
  padding: 10px 12px;
  width: 280px;
  backdrop-filter: blur(6px);
  font-size: 11px;
}

.reg-panel-title {
  font-weight: 700;
  color: #9cf;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.reg-label {
  display: block;
  font-size: 10px;
  color: #aaa;
  margin-bottom: 4px;
}

.reg-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ccc;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
  margin-bottom: 8px;
}

/* F-05: locked subtype label shown after first pick */
.reg-subtype-locked {
  font-size: 10px;
  color: #8ab;
  margin-bottom: 8px;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.reg-change-link {
  display: inline-block;
  margin-left: 6px;
  font-size: 9px;
  color: #69b;
  text-decoration: underline;
  cursor: pointer;
}
.reg-change-link:hover { color: #9cf; }

/* F-04: per-role progress list */
.reg-role-list {
  list-style: none;
  margin: 0 0 6px 0;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
}

.reg-role-list li {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 0;
  font-size: 10px;
  color: #9ad;
  line-height: 1.4;
}

/* Active role gets slightly brighter color */
.reg-role-list li.reg-role-active {
  color: #cce;
}

.reg-role-marker {
  width: 10px;
  flex-shrink: 0;
  text-align: center;
  font-size: 10px;
}

.reg-role-name {
  font-weight: 600;
  min-width: 80px;
}

.reg-role-target {
  color: #678;
  font-size: 9px;
}

.reg-role-count {
  margin-left: auto;
  color: #9ad;
}

.reg-role-min {
  color: #678;
  font-size: 9px;
}

/* Picked-item chips, one per pick in a role's bucket. */
.reg-pick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
  margin-top: 4px;
  padding-left: 14px;
}
.reg-pick-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border: 1px solid #3a4868;
  border-radius: 3px;
  background: #1a2030;
  color: #cce;
  font-size: 10px;
  line-height: 1.3;
}
.reg-pick-chip button {
  all: unset;
  cursor: pointer;
  color: #f88;
  font-size: 11px;
  padding: 0 2px;
}
.reg-pick-chip button:hover { color: #fcc; }

/* F-06: completion summary */
.reg-completion {
  font-size: 10px;
  color: #7ab;
  margin-bottom: 6px;
  text-align: right;
}

/* F-08: click-to-remove hint */
.reg-hint {
  font-size: 9px;
  color: #888;
  margin-bottom: 6px;
}

/* F-06: Confirm muted when disabled */
.reg-confirm-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* Error strip */
.reg-error {
  margin-top: 6px;
  padding: 4px 6px;
  background: rgba(255, 90, 80, 0.15);
  border: 1px solid rgba(255, 120, 110, 0.4);
  border-radius: 4px;
  color: #fcc;
  font-size: 10px;
}

/* ---- Display toggle checkboxes ---- */
.display-toggle-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 2px;
}
.display-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #b8bccc;
  cursor: pointer;
  padding: 2px 0;
  user-select: none;
}
.display-toggle-label:hover { color: #dde; }
.display-toggle-label input[type="checkbox"] {
  width: 13px;
  height: 13px;
  accent-color: #4af;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

/* ---- Dock group labels ---- */
.dock-group-label {
  font-size: 8px;
  color: rgba(255,255,255,0.30);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 6px 0 2px;
  align-self: center;
  flex-shrink: 0;
  pointer-events: none;
}

/* ---- Left panel nested section descriptor ---- */
.section-desc {
  font-size: 10px;
  color: #556677;
  line-height: 1.4;
  margin-bottom: 7px;
}

/* ---- Inspector entity chip ---- */
.inspector-entity-chip {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 7px;
  border: 1px solid;
  opacity: 0.9;
}

/* ---- Inspector tab strip ---- */
.inspector-tab-strip {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  padding-bottom: 4px;
}
.inspector-tab {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px 4px 0 0;
  color: #778;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.inspector-tab:hover { color: #aac; background: rgba(255,255,255,0.04); }
.inspector-tab.active {
  color: #dde;
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
}

/* ---- Label overlays (Feature B + Overlay A + Overlay B) ---- */
/* Shared full-canvas container used by all three label overlays. */
.label-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

/* Overlay 0 — OSM-id per-lanelet labels */
.lanelet-id-label {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(20, 25, 40, 0.85);
  border: 1px solid rgba(120, 200, 255, 0.4);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 10px;
  color: #cce;
  font-family: monospace;
  white-space: nowrap;
}

/* Overlay A — laneletBuffer per-way labels (warm amber so they stand out
   from the blue OSM-id labels without clashing with the cyan type labels). */
.way-buffer-label {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(30, 20, 10, 0.88);
  border: 1px solid rgba(255, 180, 60, 0.55);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 10px;
  color: #ffd084;
  font-family: monospace;
  white-space: nowrap;
}

/* Overlay B — boundaryType per-way labels (neutral cyan; TODO: integrate
   boundary_style.js type-colour once that agent ships). */
.way-type-label {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(10, 25, 30, 0.88);
  border: 1px solid rgba(60, 200, 220, 0.50);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 10px;
  color: #7ee8f0;
  font-family: monospace;
  white-space: nowrap;
}

/* Overlay C — gate ID per-lanelet labels (green-tinted; gate values are
   navigational identifiers so they get a distinct colour from OSM ids). */
.gate-label {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(10, 30, 20, 0.88);
  border: 1px solid rgba(80, 210, 140, 0.55);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  color: #7ee8b8;
  font-family: monospace;
  white-space: nowrap;
  font-weight: 600;
}

/* ── Inspector redesign ──────────────────────────────────────── */

/* Full-width entity header replacing the inline chip.
   Negative margins let it bleed to the edges of the panel's 8px padding. */
.inspector-entity-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: -8px -8px 10px -8px;
  padding: 10px 10px 8px;
  border-radius: 4px 4px 0 0;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.inspector-entity-header-type {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.inspector-entity-header-id {
  font-size: 20px;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  letter-spacing: -0.02em;
  cursor: pointer;
  line-height: 1.1;
}
.inspector-entity-header-id:hover { opacity: 0.75; }

/* Section dividers — consistent top spacing + bottom border to help scanning. */
.inspector-section {
  font-weight: 700;
  color: #9ad;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 14px 0 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(154,190,221,0.18);
}

/* Danger zone — groups destructive actions, visually separated from safe ones. */
.inspector-danger-zone {
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 5px 8px 7px;
  background: rgba(200,60,60,0.07);
  border: 1px solid rgba(200,60,60,0.20);
  border-radius: 4px;
}
.inspector-danger-label {
  font-size: 9px;
  font-weight: 700;
  color: #c88;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

/* ── SW-7286: inbound references — rule liveness and area status ──────────
 * The headline signal in the inspector, so it is sized and weighted like one
 * rather than set in the panel's muted body gray. Every state names itself in
 * WORDS (LIVE / ORPHANED / INERT / area=yes MISSING) with the colour as
 * reinforcement, never as the only carrier of the meaning. */
.insp-rule-status {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
  margin: 0 0 4px;
  padding: 4px 8px;
  border-left: 3px solid currentColor;
  border-radius: 0 3px 3px 0;
}
.insp-rule-status.is-live   { color: #6fe3a4; background: rgba(60,200,130,0.10); }
.insp-rule-status.is-orphan { color: #ff8f85; background: rgba(220,70,60,0.12); }
.insp-rule-status.is-inert  { color: #ffc857; background: rgba(220,160,50,0.12); }

/* Per-rule lanelets. Deliberately smaller than the pooled "Applies to" rows:
   same information at a different altitude — which lanelets THIS rule reaches,
   not the union across every rule on the element. */
.insp-chip-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 8px 8px;
}
.insp-lanelet-chip {
  font-size: 10px;
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  padding: 2px 7px;
  border-radius: 10px;
  cursor: pointer;
  color: #8ff0c4;
  background: rgba(50,180,120,0.16);
  border: 1px solid rgba(80,220,150,0.45);
}
.insp-lanelet-chip:hover { background: rgba(50,180,120,0.30); }
/* Referenced but not where the rule acts — right_of_way's non-priority side.
   Marked by a dashed border as well as by colour. */
.insp-lanelet-chip.is-passive {
  color: #d8dbe2;
  background: rgba(255,255,255,0.07);
  border: 1px dashed rgba(255,255,255,0.40);
}
.insp-lanelet-chip:focus-visible,
.insp-rule-status button:focus-visible { outline: 2px solid #9ad; outline-offset: 1px; }

.insp-area-status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  padding: 4px 8px;
  border-left: 3px solid currentColor;
  border-radius: 0 3px 3px 0;
}
.insp-area-status.is-ok  { color: #6fe3a4; background: rgba(60,200,130,0.10); }
.insp-area-status.is-bad { color: #ff8f85; background: rgba(220,70,60,0.12); }
.insp-area-status-flag {
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Mono', monospace;
}
/* Not gray-on-gray: the detail is quieter than the flag but still well clear
   of the panel background. */
.insp-area-status-detail { color: #cfd4dd; font-weight: 400; }

/* Boundary hint callout — amber left border distinguishes it from data rows. */
.boundary-hint-callout {
  margin-top: 8px;
  padding: 6px 10px;
  font-size: 10px;
  color: #c9aa80;
  line-height: 1.5;
  border-left: 3px solid rgba(220,160,60,0.55);
  background: rgba(200,140,40,0.08);
  border-radius: 0 3px 3px 0;
  font-style: italic;
}

/* Subtle hover feedback on tag table rows. */
.inspector-tag-row:hover { background: rgba(255,255,255,0.04); }

/* Separator above the Validate map button (permanent footer of the panel). */
.inspector-validate-sep {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.10);
  margin: 6px 0 8px;
}

/* ═══ Layer HUD ══════════════════════════════════════════════════════════
 * Colouring-layer chip, legend and popover.
 *
 * Tokens are namespaced --lyr-* rather than added to a global set: style.css
 * currently has zero custom properties, so a global token refactor would be a
 * large, risky, unrelated diff. Surface/border/ink values are lifted verbatim
 * from the existing #left-panel and #right-panel literals so the HUD reads as
 * native chrome rather than a bolted-on widget.
 *
 * Type runs 9-11px monospace, deviating from a general 16px baseline on
 * purpose: the host tool's entire chrome is 9-12px mono and a 16px legend
 * would look like a foreign object. Density is the requirement here.
 * ═══════════════════════════════════════════════════════════════════════ */
:root {
  --lyr-s1: 2px;  --lyr-s2: 4px;  --lyr-s3: 8px;  --lyr-s4: 12px;
  --lyr-fs-meta: 9px; --lyr-fs-sm: 10px; --lyr-fs-md: 11px;
  --lyr-radius: 6px; --lyr-radius-sm: 3px;

  --lyr-surface:     rgba(14, 16, 26, 0.98);
  --lyr-surface-2:   rgba(255, 255, 255, 0.05);
  --lyr-surface-3:   rgba(255, 255, 255, 0.10);
  --lyr-border:      rgba(255, 255, 255, 0.28);
  --lyr-border-soft: rgba(255, 255, 255, 0.12);
  --lyr-ink:         #f0f0f5;   /* 17.8:1 on the panel surface */
  --lyr-ink-2:       #b8bccc;   /* 10.0:1 */
  --lyr-ink-3:       #7b8296;   /*  4.9:1 — AA floor, meta text only */
  --lyr-accent:      #60c8ff;   /* matches button.active elsewhere */
  --lyr-shadow:      0 4px 24px rgba(0, 0, 0, 0.75);
}

#layer-hud {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 118;                 /* above #edit-dock (110), below modals (120) */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--lyr-s2);
  pointer-events: none;         /* the canvas stays draggable around the HUD */
  max-height: calc(100vh - 60px);
}
#layer-hud > * { pointer-events: auto; }
#layer-hud.is-open { z-index: 210; }

/* ── chip: the persistent "what am I looking at" indicator ── */
#layer-chip {
  display: flex;
  align-items: center;
  gap: var(--lyr-s3);
  padding: var(--lyr-s2) var(--lyr-s4);
  background: var(--lyr-surface);
  border: 1px solid var(--lyr-border);
  border-radius: var(--lyr-radius);
  backdrop-filter: blur(6px);
  box-shadow: var(--lyr-shadow);
  color: var(--lyr-ink);
  font: inherit;
  font-size: var(--lyr-fs-md);
  cursor: pointer;
  white-space: nowrap;
}
#layer-chip:hover  { background: var(--lyr-surface-3); }
#layer-chip:active { transform: scale(.97); }
#layer-chip:focus-visible { outline: 2px solid var(--lyr-accent); outline-offset: 2px; }
/* Active state is carried by the border, not only by the pip, so the chip
   still reads as "on" for a user who cannot distinguish the pip colour. */
#layer-hud:not([data-fill-layer="none"]) #layer-chip { border-color: var(--lyr-accent); }

.lyr-pip {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid var(--lyr-ink-3);
  flex: none;
}
.lyr-chip-meta { color: var(--lyr-ink-3); font-size: var(--lyr-fs-sm); }

/* ── popover ── */
#layer-popover {
  width: 260px;
  padding: var(--lyr-s3);
  background: var(--lyr-surface);
  border: 1px solid var(--lyr-border);
  border-radius: var(--lyr-radius);
  backdrop-filter: blur(6px);
  box-shadow: var(--lyr-shadow);
  max-height: 60vh;
  overflow-y: auto;
}
#layer-popover[hidden] { display: none; }

.lyr-group { margin-bottom: var(--lyr-s3); }
.lyr-group-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: var(--lyr-fs-meta);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--lyr-ink-3);
  margin-bottom: var(--lyr-s2);
}
.lyr-group-hint { text-transform: none; letter-spacing: 0; font-size: var(--lyr-fs-meta); }

.lyr-option {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  gap: var(--lyr-s3);
  padding: var(--lyr-s2) var(--lyr-s3);
  margin-bottom: var(--lyr-s1);
  background: var(--lyr-surface-2);
  border: 1px solid transparent;
  border-radius: var(--lyr-radius-sm);
  color: var(--lyr-ink-2);
  font: inherit;
  font-size: var(--lyr-fs-md);
  text-align: left;
  cursor: pointer;
}
.lyr-option:hover { background: var(--lyr-surface-3); color: var(--lyr-ink); }
.lyr-option.is-active {
  border-color: var(--lyr-accent);
  color: var(--lyr-ink);
  background: var(--lyr-surface-3);
}
.lyr-option:focus-visible { outline: 2px solid var(--lyr-accent); outline-offset: 1px; }

.lyr-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--lyr-s3);
  padding-top: var(--lyr-s3);
  border-top: 1px solid var(--lyr-border-soft);
}
.lyr-check {
  display: flex; align-items: center; gap: var(--lyr-s2);
  font-size: var(--lyr-fs-sm); color: var(--lyr-ink-2); cursor: pointer;
}
.lyr-check input { accent-color: var(--lyr-accent); }
.lyr-clear {
  background: none; border: 1px solid var(--lyr-border-soft);
  border-radius: var(--lyr-radius-sm);
  color: var(--lyr-ink-3);
  font: inherit; font-size: var(--lyr-fs-sm);
  padding: var(--lyr-s1) var(--lyr-s3);
  cursor: pointer;
}
.lyr-clear:hover { color: var(--lyr-ink); border-color: var(--lyr-border); }

/* ── legend ──
 * Always shows a count per class AND the untagged count. For most layers here
 * the untagged number is the actual finding ("no tag 1617 (59.8%)"), so it is
 * never collapsed behind a hover. */
#layer-legend {
  width: 260px;
  padding: var(--lyr-s3);
  background: var(--lyr-surface);
  border: 1px solid var(--lyr-border-soft);
  border-radius: var(--lyr-radius);
  backdrop-filter: blur(6px);
  box-shadow: var(--lyr-shadow);
  font-size: var(--lyr-fs-sm);
  overflow-y: auto;
}
#layer-legend[hidden] { display: none; }

.lyr-legend-block + .lyr-legend-block {
  margin-top: var(--lyr-s3);
  padding-top: var(--lyr-s3);
  border-top: 1px solid var(--lyr-border-soft);
}
.lyr-legend-title {
  font-size: var(--lyr-fs-meta);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--lyr-ink-3);
  margin-bottom: var(--lyr-s2);
}
.lyr-row {
  display: flex; align-items: center; gap: var(--lyr-s3);
  padding: 1px 0;
  color: var(--lyr-ink-2);
}
.lyr-row.is-muted { opacity: .45; }   /* a zero class stays listed, not hidden */
.lyr-row-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lyr-row-count { color: var(--lyr-ink-3); font-size: var(--lyr-fs-meta); flex: none; }

.lyr-swatch {
  width: 12px; height: 12px;
  border-radius: 2px;
  border: 1px solid var(--lyr-border-soft);
  flex: none;
}
/* Line-channel classes are strokes on the map, so their swatch is an outline —
   the legend mark matches the mark it stands for. */
.lyr-swatch.is-outline { background: transparent; border-width: 2px; }
/* No-data is hatched, not just pale: pattern is categorically "not a colour",
   so it cannot be misread as a position on the ramp. */
.lyr-swatch.is-hatched {
  background-image: repeating-linear-gradient(
    45deg, var(--lyr-ink-3) 0 1px, transparent 1px 3px);
  background-color: transparent;
}

.lyr-displaced {
  padding: var(--lyr-s2);
  margin-bottom: var(--lyr-s2);
  border-radius: var(--lyr-radius-sm);
  background: var(--lyr-surface-3);
  color: var(--lyr-ink);
  font-size: var(--lyr-fs-meta);
  text-align: center;
}
.lyr-displaced[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  #layer-chip:active { transform: none; }
}

/* Denominator line under each legend block. Three layers here count against
   three different populations (lanelets, boundary ways, flagged-only); without
   stating it, "360 (100.0%)" and "435 (16.1%)" render identically and mean
   completely different things. */
.lyr-scope {
  margin-top: var(--lyr-s1);
  font-size: var(--lyr-fs-meta);
  color: var(--lyr-ink-3);
  font-style: italic;
}

/* Per-RULE counts under a per-lanelet layer. Indented and rule-separated so
   they cannot be misread as more class rows counting the same population. */
.lyr-summary-row {
  padding-left: 20px;   /* clears the swatch column — these rows have none */
}
.lyr-summary-row.is-first {
  margin-top: var(--lyr-s2);
  padding-top: var(--lyr-s2);
  border-top: 1px solid var(--lyr-border-soft);
}

/* ── Reg-element role labels (SW-6397) ────────────────────────────
   Painted on the governed lanelets while a regulatory element is selected,
   so the role each lanelet plays is readable without clicking through them
   one at a time. Colours match ROLE_COLORS in reg_element_mode.js — the map
   fill, the inspector legend and these labels are one vocabulary. */
.regrole-label {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-family: monospace;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}
.regrole-label.role-right_of_way {
  background: rgba(0, 40, 55, 0.92);
  border: 2px solid #22ddff;
  color: #7cf0ff;
}
.regrole-label.role-yield {
  background: rgba(60, 30, 0, 0.92);
  border: 2px solid #ffa040;
  color: #ffc27a;
}
.regrole-label.role-other {
  background: rgba(30, 45, 10, 0.92);
  border: 2px solid #88ff44;
  color: #b6ff8a;
}
