/* ================================================================
   Keizaal Atlas - Glass Atlas UI
   ================================================================ */

/* ── Design Tokens ── */
:root {
  color-scheme: dark;

  --bg:             #070909;
  --glass:          rgba(8, 10, 13, 0.88);
  --glass-2:        rgba(11, 14, 18, 0.94);
  --line:           rgba(255, 255, 255, 0.07);
  --gold-line:      rgba(197, 170, 104, 0.22);
  --gold-glow:      rgba(197, 170, 104, 0.09);

  --text:           #eef0ec;
  --muted:          #8b97a1;
  --accent:         #c5aa68;
  --accent-dim:     rgba(197, 170, 104, 0.16);
  --accent-2:       #70b6c8;
  --danger:         #c66b59;
  --danger-strong:  #ff7d66;
  --ready:          #83bf7a;

  /* Panels are 88-94% opaque (see --glass/--glass-2), so the backdrop blur is
     barely visible yet forces a full-screen blur composite behind every panel
     each frame. A smaller radius with no extra saturate pass keeps the frosted
     look at roughly half the GPU cost during map repaints. */
  --blur:           blur(10px);
  --shadow:         0 4px 24px rgba(0,0,0,.52), 0 1px 4px rgba(0,0,0,.28);
  --shadow-lg:      0 8px 48px rgba(0,0,0,.72), 0 2px 10px rgba(0,0,0,.38);

  --r:              12px;
  --r-sm:           8px;
  --r-xs:           6px;
  --r-pill:         999px;

  --ease:           cubic-bezier(0, 0, 0.3, 1);
  --t:              200ms;
  --t-slow:         320ms;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* ── Map Canvas — base layer ── */
#map-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  background: #0c1215;
}

.time-overlay {
  position: fixed;
  z-index: 5;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.time-chip {
  min-width: 0;
  max-width: min(42vw, 360px);
  padding: 7px 12px;
  border: 1px solid rgba(197, 170, 104, 0.28);
  border-radius: var(--r-sm);
  background: rgba(5, 7, 8, 0.82);
  box-shadow: var(--shadow);
  color: #efe7cf;
  font: 700 12px/1.25 "Cinzel", Georgia, serif;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-chip.is-real-time {
  border-color: rgba(112, 182, 200, 0.28);
  color: #d8f3fb;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
}

/* ── Shared: Icon Button ── */
.icon-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  flex: 0 0 auto;
  transition: border-color var(--t), color var(--t), background var(--t);
}
.icon-btn:hover {
  border-color: var(--gold-line);
  color: var(--text);
  background: var(--accent-dim);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Shared: Base Button ── */
button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  transition: border-color var(--t), background var(--t), transform 120ms;
}
button:hover {
  border-color: var(--gold-line);
  background: var(--accent-dim);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ── Shared: Inputs & Selects ── */
input:not([type="checkbox"]):not([type="radio"]),
select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  outline: none;
  transition: border-color var(--t);
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus {
  border-color: rgba(197, 170, 104, 0.5);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23c5aa68' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px 14px;
  background-color: rgba(255, 255, 255, 0.04);
}
select::-ms-expand { display: none; }
select option {
  color: #eef0ec;
  background: #0b0e12;
}

/* ================================================================
   TOP BAR
   ================================================================ */
.top-bar {
  position: fixed;
  top: 12px;
  left: 50%;
  right: auto;
  z-index: 220;
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: calc(100vw - 24px);
  min-height: 48px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--gold-line);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  transform: translateX(-50%);
}

.top-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.top-center {
  flex: 0 0 auto;
  min-width: 0;
}

.top-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  pointer-events: none;
  user-select: none;
}

.brand-title {
  font-family: "Cinzel", "Palatino Linotype", "Palatino", Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0;
  line-height: 1.2;
}

.brand-sub {
  display: none;
  font-size: 11px;
  color: var(--muted);
  line-height: 1;
}

.top-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.queue-status-row {
  position: fixed;
  top: 112px;            /* stacked BELOW the game/real-time overlay (was overlapping it) */
  left: 50%;
  z-index: 218;
  display: flex;
  justify-content: center;
  width: min(560px, calc(100vw - 24px));
  pointer-events: none;
  transform: translateX(-50%);
}

.queue-status-chip {
  height: 34px;
  max-width: 236px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(112, 182, 200, 0.32);
  border-radius: var(--r-pill);
  background: rgba(7, 10, 12, 0.86);   /* solid dark glass (was near-invisible white wash) */
  box-shadow: var(--shadow);
  color: #d8f3fb;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  pointer-events: auto;
  transition: border-color var(--t), background var(--t), color var(--t);
}
.queue-status-chip:hover {
  border-color: rgba(112, 182, 200, 0.55);
  background: rgba(112, 182, 200, 0.10);
}
.queue-status-dot {
  width: 7px;
  min-width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 10px rgba(139, 151, 161, 0.35);
}
.queue-status-label,
.queue-status-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-status-meta {
  color: var(--muted);
  font-weight: 700;
}
.queue-status-chip.is-in-queue .queue-status-dot {
  background: var(--accent-2);
  box-shadow: 0 0 12px rgba(112, 182, 200, 0.65);
}
.queue-status-chip.is-entering .queue-status-dot,
.queue-status-chip.is-character-ready .queue-status-dot,
.queue-status-chip.is-in-game .queue-status-dot {
  background: var(--ready);
  box-shadow: 0 0 12px rgba(131, 191, 122, 0.65);
}
.queue-status-chip.is-missing-log .queue-status-dot,
.queue-status-chip.is-waiting .queue-status-dot {
  background: var(--danger);
  box-shadow: 0 0 12px rgba(198, 107, 89, 0.52);
}
.queue-status-chip.is-urgent {
  border-color: rgba(197, 170, 104, 0.55);
  background: rgba(197, 170, 104, 0.12);
  color: #fff3cb;
}
.queue-status-chip.is-stats-mode {
  max-width: min(430px, 34vw);
}

.queue-live-status {
  min-height: 32px;
  padding: 8px 10px;
  border: 1px solid rgba(112, 182, 200, 0.20);
  border-radius: var(--r-sm);
  background: rgba(112, 182, 200, 0.07);
  color: #d8f3fb;
  font-size: 12px;
}
.queue-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.queue-stat-grid > div {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--r-xs);
  background: rgba(0, 0, 0, 0.16);
}
.queue-stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.queue-stat-grid strong {
  display: block;
  min-width: 0;
  margin-top: 2px;
  overflow: hidden;
  color: #eefbff;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-stat-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.top-search-wrap {
  position: relative;
  width: clamp(180px, 18vw, 300px);
  min-width: 0;
}
.top-search-wrap input.drawer-search {
  height: 34px;
  padding-left: 34px;
  padding-right: 12px;
}
.top-search-wrap .drawer-search-icon {
  left: 11px;
  top: 50%;
  margin-top: 0;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 280;
  display: grid;
  gap: 4px;
  max-height: min(46vh, 360px);
  overflow-y: auto;
  padding: 7px;
  border: 1px solid var(--gold-line);
  border-radius: var(--r-sm);
  background: rgba(11, 14, 18, 0.98);
  box-shadow: var(--shadow-lg);
}
.search-suggestions[hidden] {
  display: none;
}
.search-suggestion {
  width: 100%;
  min-height: 40px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 7px 9px;
}
.search-suggestion:hover {
  border-color: rgba(197, 170, 104, 0.55);
  background: rgba(197, 170, 104, 0.08);
}
.search-suggestion-title,
.search-suggestion-meta {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-suggestion-title {
  font-weight: 650;
  font-size: 13px;
}
.search-suggestion-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 1px;
}
.search-suggestion-kind {
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.search-suggestion-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
}

/* Position LED indicator */
.position-led,
#position-status {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 10px;
  cursor: help;
  font-size: 0;
  overflow: hidden;
  transition: background var(--t), box-shadow var(--t);
}

.position-active {
  background: var(--ready) !important;
  box-shadow: 0 0 8px rgba(131, 191, 122, 0.55);
}

/* Compact filters in top bar */
.top-filter-btn {
  height: 30px;
  min-height: 30px;
  width: auto;
  padding: 0 26px 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.top-filter-select {
  height: 32px;
  min-height: 32px;
  font-size: 12px;
  width: auto;
  min-width: 90px;
}
#ore-filter-summary {
  display: inline-block;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

/* Ore filter inside top bar — dropdown needs high z-index */
.top-bar .ore-filter-panel { position: relative; }
.top-bar .ore-filter-menu  { z-index: 280; min-width: 220px; left: 0; right: auto; }

/* Layer filter — right side of top bar, dropdown opens to the left */
.layer-filter-panel { position: relative; }
.layer-filter-menu {
  position: absolute;
  left: 0;
  right: auto;
  top: calc(100% + 5px);
  z-index: 280;
  min-width: 310px;
  border: 1px solid var(--gold-line);
  border-radius: var(--r-sm);
  background: rgba(12, 15, 19, 0.98);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-lg);
  padding: 8px;
}

#ore-filter-summary {
  display: block;
  min-width: 0;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: baseline;
}

.layers-pane {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 105;
  --layer-pill-width: 194px;
  width: min(250px, calc(100vw - 24px));
  border: 1px solid var(--gold-line);
  border-radius: var(--r);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: background var(--t), border-color var(--t), box-shadow var(--t);
}
.layers-pane:not(.is-open) {
  background: rgba(8, 10, 13, 0.52);
  border-color: rgba(197, 170, 104, 0.15);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.34);
}
.layers-pane.is-open {
  bottom: 12px;
  display: flex;
  flex-direction: column;
  background: rgba(8, 10, 13, 0.74);
}
.layers-pane::before,
.layers-pane::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  z-index: 1;
}
.layers-pane::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid rgba(197, 170, 104, 0.55);
  border-left: 2px solid rgba(197, 170, 104, 0.55);
  border-top-left-radius: var(--r);
}
.layers-pane::after {
  bottom: -1px;
  right: -1px;
  border-bottom: 2px solid rgba(197, 170, 104, 0.55);
  border-right: 2px solid rgba(197, 170, 104, 0.55);
  border-bottom-right-radius: var(--r);
}
.layers-pane-toggle {
  position: relative;     /* anchor .select-chevron here, not the full-height pane */
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 36px 9px 13px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.layers-pane-toggle:hover {
  background: rgba(197, 170, 104, 0.06);
}
.layers-pane-title {
  display: block;
  color: var(--accent);
  font-family: "Cinzel", "Palatino Linotype", Georgia, serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  line-height: 1.1;
  text-transform: uppercase;
}
.layers-pane-summary {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.layers-pane-body {
  display: grid;
  gap: 10px;
  align-content: start;   /* pack categories at the top; don't stretch collapsed ones tall */
  flex: 1 1 auto;
  min-height: 0;
  /* When open the pane is a full-height flex column; the body fills it and
     scrolls, so the usable area reaches the bottom (no dead space). The cap
     below only bounds the collapsed/auto case. */
  max-height: min(72vh, 680px);
  overflow-y: auto;
  padding: 0 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(197,170,104,.3) transparent;
}
.layers-pane-body[hidden] {
  display: none;
}
.layers-pane.is-open .layers-pane-body {
  /* Fill the full-height pane down to the bottom; flex grows it, overflow scrolls. */
  max-height: none;
  flex: 1 1 auto;
}
/* One flat scrollable list of collapsible categories (Places/Utility/Resources). */
.layer-cat {
  display: grid;
  gap: 6px;
}
.layer-cat-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 2px 2px 1px;
  background: linear-gradient(180deg, rgba(8, 10, 13, 0.92) 78%, transparent);
}
.layer-cat-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 17px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--accent);
  font-family: "Cinzel", Georgia, serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.layer-cat-toggle:hover { color: #fff0b6; }
.layer-cat-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);            /* points down = expanded */
  transition: transform 180ms var(--ease);
  flex: 0 0 auto;
}
.layer-cat.is-collapsed .cat-chevron {
  transform: rotate(-45deg);           /* points right = collapsed */
}
.layer-cat-body {
  display: grid;
  gap: 6px;
}
.layer-cat-body[hidden] {
  display: none;
}
/* Layer is still enabled but cannot show at the current (too-far-out) zoom. */
.layer-cat.below-zoom .layer-cat-body,
#ore-filter .resource-layer-group.below-zoom {
  opacity: 0.4;
  filter: saturate(0.55);
  transition: opacity 160ms var(--ease);
}
.layers-pane-section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}
.layers-pane-section-head h2 {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
}
.layers-pane-actions {
  display: flex;
  gap: 5px;
}
.layers-pane-actions button {
  min-width: 42px;
  min-height: 26px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
}
.layers-pane .ore-checks {
  max-height: none;
  overflow-y: visible;
}
.layers-pane .layer-checks,
.layers-pane .resource-type-checks {
  /* No inner scroll — the whole .layers-pane-body scrolls as one list. */
  max-height: none;
  overflow: visible;
  padding-right: 2px;
}
.layers-pane .ore-check {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.layers-pane .ore-check > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layers-pane .layer-group {
  justify-items: start;
  width: 100%;
  max-width: 100%;
}
.layers-pane .layer-category-row {
  align-items: center;
  width: 100%;
  max-width: 100%;
}
.layers-pane .layer-category-check {
  flex: 1 1 auto;
  width: auto;
}
.layers-pane .layer-subchecks {
  justify-items: start;
}
.layers-pane .resource-layer-group {
  width: 100%;
}
.layers-pane .resource-layer-group .layer-subchecks {
  max-height: none;
  overflow: visible;
  padding-right: 2px;
}
.layers-pane .resource-layer-group.is-collapsed .layer-subchecks {
  max-height: 0;
  overflow: hidden;
}

.toggle-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--t), color var(--t), background var(--t);
}
.toggle-pill:hover {
  border-color: var(--gold-line);
  color: var(--text);
}
.toggle-pill input[type="checkbox"] {
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent);
}

/* Heatmap accordion: Personal (teal) / Everyone's (orange) pills, lit in their LINE color
   when on and dim when off — matching the colours of the trails they draw. */
.heatmap-accordion-body[hidden] { display: none; }   /* collapsed */
.heatmap-accordion-body:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 4px 4px;
}
.heatmap-pill-personal input[type="checkbox"] { accent-color: #5fd0e6; }
.heatmap-pill-everyone input[type="checkbox"] { accent-color: #ff8e57; }
.heatmap-pill:not(:has(input:checked)) { opacity: 0.5; }
.heatmap-pill-personal:has(input:checked) {
  border-color: rgba(95, 208, 230, 0.7);
  color: #c6eefb;
  background: rgba(95, 208, 230, 0.14);
}
.heatmap-pill-everyone:has(input:checked) {
  border-color: rgba(255, 142, 87, 0.7);
  color: #ffd9c2;
  background: rgba(255, 142, 87, 0.14);
}

@media (max-width: 880px) {
  .top-bar {
    gap: 6px;
    padding: 0 8px;
  }
  .brand-title {
    font-size: 17px;
  }
  .top-search-wrap {
    width: 160px;
  }
  .queue-status-row {
    top: 108px;
  }
  .queue-status-chip {
    max-width: 160px;
    padding: 0 10px;
  }
  .queue-status-chip.is-stats-mode {
    max-width: 190px;
  }
  .queue-status-meta {
    display: none;
  }
  #ore-filter-summary {
    max-width: 92px;
  }
}

@media (max-width: 660px) {
  .top-search-wrap {
    width: 128px;
  }
  .top-filter-btn {
    padding-left: 8px;
    padding-right: 22px;
  }
  .brand-title {
    font-size: 15px;
  }
  .queue-status-row {
    top: 102px;
  }
  .queue-status-chip {
    max-width: 116px;
  }
  .queue-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ================================================================
   LEFT DRAWER
   ================================================================ */
.left-drawer {
  position: fixed;
  top: 24px;
  bottom: 24px;
  left: 50%;
  z-index: 650;
  width: min(980px, calc(100vw - 48px));
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--glass-2);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--gold-line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, calc(-100% - 56px));
  transition: transform var(--t-slow) var(--ease);
  overflow: hidden;
}
.left-drawer.is-open {
  transform: translate(-50%, 0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  min-height: 56px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-title {
  display: block;
  font-family: "Cinzel", "Palatino Linotype", Georgia, serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.drawer-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
}
.settings-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.settings-tab {
  flex: 0 0 auto;
  min-width: 0;
  height: 30px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
  font-weight: 700;
}
.settings-tab.is-active {
  color: var(--text);
  border-color: rgba(197, 170, 104, 0.62);
  background: rgba(197, 170, 104, 0.14);
}

.settings-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}
.settings-page {
  display: none;
}
.settings-page.is-active {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
  align-items: start;
  /* Pack shorter sections up into gaps left by taller ones (was leaving large
     empty columns, most noticeable on the Setup page). */
  grid-auto-flow: row dense;
}
.settings-section {
  display: grid;
  gap: 8px;
  align-self: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.15);
}
.settings-section.is-collapsed {
  gap: 0;
}
.settings-page[data-settings-page="diagnostics"] .settings-section:first-child,
.settings-section.setup-section {
  grid-column: 1 / -1;
}
.settings-section h3 {
  margin: 0;
  color: var(--accent);
  font-family: "Cinzel", "Palatino Linotype", Georgia, serif;
  font-size: 11.5px;
  letter-spacing: 0;
}
.settings-section-heading {
  display: grid;
  gap: 0;
  position: relative;
  min-height: 20px;
  padding-left: 16px;
  cursor: pointer;
  user-select: none;
}
.settings-section-heading::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 4px;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  border-radius: 1px;
  transform-origin: center;
  transform: rotate(45deg);
  transition: transform 140ms ease;
}
.settings-section.is-collapsed > :not(.settings-section-heading) {
  display: none !important;
}
.settings-section.is-collapsed .settings-section-heading::before {
  transform: rotate(-45deg);
}
.settings-section-heading p {
  display: none;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.settings-label {
  color: var(--muted);
  font-size: 10.5px;
}
.settings-note {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
}
.settings-divider {
  height: 1px;
  margin: 14px 0 10px;
  background: var(--gold-line);
}
.settings-subheading {
  font-family: "Cinzel", Georgia, serif;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 4px;
}
.settings-note.is-ok { color: var(--ready); }
.settings-note.is-warn { color: var(--danger-strong); }

/* ── Login gate: full-screen blur + lock over the entire app until signed in ── */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(197, 170, 104, 0.10), transparent 60%),
    rgba(6, 8, 9, 0.92);
  /* Heavy blur + near-opaque overlay (defence-in-depth; the real lock is the server
     refusing map data/tiles to unauthenticated requests — see gate_map_assets). */
  backdrop-filter: blur(30px) saturate(1.1) brightness(0.82);
  -webkit-backdrop-filter: blur(30px) saturate(1.1) brightness(0.82);
  animation: login-gate-in 240ms var(--ease);
}
.login-gate[hidden] { display: none; }
body.is-locked { overflow: hidden; }
@keyframes login-gate-in { from { opacity: 0; } to { opacity: 1; } }

.login-card {
  width: min(380px, calc(100vw - 48px));
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 30px 28px 26px;
  text-align: center;
  border: 1px solid var(--gold-line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(16, 19, 23, 0.96), rgba(9, 11, 14, 0.96));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(197, 170, 104, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.login-emblem {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--gold-line);
  background:
    radial-gradient(circle at 50% 38%, rgba(197, 170, 104, 0.35), rgba(197, 170, 104, 0.05) 70%),
    rgba(8, 10, 13, 0.9);
  box-shadow: inset 0 0 18px rgba(197, 170, 104, 0.18);
  margin-bottom: 2px;
}
.login-title {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.login-sub {
  color: var(--text);
  font-size: 13.5px;
  opacity: 0.9;
}
.login-discord-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-top: 8px;
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  background: #5865f2;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--t), transform 120ms var(--ease), box-shadow var(--t);
  box-shadow: 0 6px 20px rgba(88, 101, 242, 0.35);
}
.login-discord-btn:hover {
  background: #6b76f5;
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(88, 101, 242, 0.45);
}
.login-foot {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  margin-top: 6px;
  max-width: 280px;
}

/* Settings range slider (themed) + inline value chip. */
.settings-inline-value {
  display: inline-block;
  min-width: 26px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: rgba(197, 170, 104, 0.16);
  border: 1px solid var(--gold-line);
  color: var(--accent);
  font-weight: 700;
  font-size: 10.5px;
  text-align: center;
}
.settings-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(197, 170, 104, 0.22);
  outline: none;
  margin: 4px 0 2px;
}
.settings-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid rgba(8, 10, 13, 0.6);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.settings-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid rgba(8, 10, 13, 0.6);
  cursor: pointer;
}

/* Animated "Saved" toast in the settings drawer (settings autosave). */
.settings-save-toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%) translateY(10px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(131, 191, 122, 0.5);
  background: rgba(13, 20, 15, 0.94);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  color: var(--ready);
  font-family: "Cinzel", Georgia, serif;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity 220ms var(--ease), transform 260ms var(--ease);
}
.settings-save-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.save-toast-check {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--ready);
  flex: 0 0 auto;
}
.save-toast-check::after {
  content: "";
  position: absolute;
  left: 3.4px;
  top: 0.5px;
  width: 4px;
  height: 7px;
  border-right: 2px solid var(--ready);
  border-bottom: 2px solid var(--ready);
  transform: rotate(42deg);
}
.settings-save-toast.is-visible .save-toast-check {
  animation: save-check-pop 380ms var(--ease);
}
@keyframes save-check-pop {
  0% { transform: scale(0.5); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.settings-wide-toggle {
  justify-content: flex-start;
}
.settings-resource-filter {
  min-width: 0;
}
.settings-section .top-filter-select {
  width: 100%;
}
.position-source-select,
.settings-select {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.055);
}
.settings-section .route-improve-box {
  padding: 0;
  border-bottom: 0;
}
.atlas-mode-status .route-mode-line {
  margin: 0;
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.settings-actions button {
  flex: 0 0 auto;
  min-width: 118px;
}
.settings-actions.compact-actions button {
  flex: 1 1 116px;
}
.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.config-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10.5px;
}
.config-grid input {
  font-size: 12px;
}
.config-grid label:first-child {
  grid-column: 1 / -1;
}
.path-list {
  display: grid;
  gap: 6px;
}
.path-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 31px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.025);
}
.path-row span {
  color: var(--muted);
  font-size: 11px;
}
.path-row code {
  min-width: 0;
  color: var(--text);
  font: 11px/1.35 "Cascadia Mono", Consolas, monospace;
  overflow-wrap: anywhere;
}
.setup-health-list {
  display: grid;
  gap: 6px;
}
.health-row {
  min-height: 31px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.03);
}
.health-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 12px;
}
.health-row strong {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.health-row.is-ok strong { color: var(--ready); }
.health-row.is-warn strong { color: var(--accent); }
.health-row.is-bad strong { color: var(--danger-strong); }

.settings-diagnostics {
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.025);
}
.settings-diagnostics summary {
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.settings-diagnostics summary::-webkit-details-marker { display: none; }
.settings-diagnostics[open] summary {
  color: var(--accent);
  border-bottom: 1px solid var(--line);
}
.settings-diagnostics > div {
  padding: 8px 10px 10px;
}
.diagnostic-log-box {
  display: grid;
  gap: 8px;
}
.diagnostic-paths {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.diagnostic-log-tail {
  min-height: 128px;
  max-height: 260px;
  margin: 0;
  padding: 9px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(0, 0, 0, 0.28);
  color: #cbd5df;
  font: 11px/1.45 "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.drawer-search-wrap {
  position: relative;
  flex: 0 0 auto;
  padding: 12px 12px 0;
}
.drawer-search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  margin-top: 6px;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
}
.drawer-search {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t);
}
.drawer-search::placeholder { color: var(--muted); }
.drawer-search:focus { border-color: rgba(197, 170, 104, 0.5); }

/* Route/navigation toggles in drawer */
.drawer-toggles {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
}
.drawer-toggles .toggle-pill {
  flex: 1 1 calc(50% - 6px);
  min-width: 124px;
  justify-content: center;
  padding: 0 8px;
  white-space: nowrap;
}

/* Ore filter base — used in top bar */
@media (max-width: 980px) {
  .left-drawer {
    top: 12px;
    bottom: 12px;
    width: min(760px, calc(100vw - 24px));
  }
  .settings-page.is-active {
    grid-template-columns: 1fr;
  }
  .config-grid {
    grid-template-columns: 1fr;
  }
}

.ore-filter-panel {
  position: relative;
}

.ore-filter-button {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  padding: 5px 32px 5px 10px;
  position: relative;
  font-size: 12px;
}

.select-chevron {
  width: 14px;
  height: 14px;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23c5aa68' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
}

.ore-filter-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 5px);
  z-index: 250;
  border: 1px solid var(--gold-line);
  border-radius: var(--r-sm);
  background: rgba(12, 15, 19, 0.98);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-lg);
  padding: 8px;
}

.ore-filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.ore-filter-actions button {
  min-width: 0;
  min-height: 28px;
  font-size: 12px;
}

.ore-checks {
  display: grid;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
}

.layer-filter-menu .ore-checks {
  max-height: min(68vh, 520px);
  padding-right: 2px;
}

.ore-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--t), background var(--t);
}
.ore-check:hover { border-color: rgba(112, 182, 200, 0.6); }
.ore-check:has(input:checked) {
  border-color: rgba(197, 170, 104, 0.9);
  background: rgba(197, 170, 104, 0.13);
  color: #fff7da;
}
.ore-check input[type="checkbox"] {
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent);
}

.layer-section-label {
  padding: 8px 2px 2px;
  color: var(--gold);
  font-family: Cinzel, Georgia, serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.layer-section-label:first-child { padding-top: 0; }
.layer-group {
  display: grid;
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.025);
}
.layer-category-row {
  display: flex;
  align-items: stretch;
  gap: 5px;
}
.layer-collapse-btn {
  display: grid;
  place-items: center;
  width: 28px;
  min-width: 28px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.03);
  color: var(--gold);
  cursor: pointer;
}
.layer-collapse-btn::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--t);
}
.layer-group.is-collapsed .layer-collapse-btn::before {
  transform: translateX(-1px) rotate(-45deg);
}
.layer-collapse-btn:hover {
  border-color: rgba(112, 182, 200, 0.6);
  color: #fff7da;
}
.layer-category-check {
  flex: 1;
  min-width: 0;
  border-color: color-mix(in srgb, var(--layer-color, var(--gold)) 52%, rgba(255, 255, 255, 0.12));
}
.layer-subchecks {
  display: grid;
  gap: 4px;
  padding-left: 14px;
}
.layer-type-check {
  min-height: 27px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.14);
}
.layer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-count {
  flex: 0 0 auto;
  color: rgba(222, 229, 229, 0.56);
  font-size: 10.5px;
  font-weight: 700;
}
/* Vein list scrollable area */
#vein-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 14px;
  min-height: 0;
}
#vein-list[hidden] {
  display: none;
}

/* ================================================================
   RIGHT PANEL
   ================================================================ */
.right-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 330px;
  bottom: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: visible; /* each card manages its own scroll */
}

/* ── Panel Card ── */
.panel-card {
  flex: 0 0 auto;
  position: relative;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--gold-line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 13px 14px 14px;
  overflow: visible;
}

/* Corner ornaments */
.panel-card::before,
.panel-card::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  z-index: 1;
}
.panel-card::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid rgba(197, 170, 104, 0.55);
  border-left: 2px solid rgba(197, 170, 104, 0.55);
  border-top-left-radius: var(--r);
}
.panel-card::after {
  bottom: -1px;
  right: -1px;
  border-bottom: 2px solid rgba(197, 170, 104, 0.55);
  border-right: 2px solid rgba(197, 170, 104, 0.55);
  border-bottom-right-radius: var(--r);
}

.panel-card-title {
  font-family: "Cinzel", "Palatino Linotype", Georgia, serif;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

/* Info cards (Selected + Closest) — fixed size, never pushed by workbench */
.panel-card.info-card {
  flex: 0 0 auto;
  overflow: visible; /* keeps ::before/::after ornaments unclipped */
  /* Slightly more translucent than default glass, still a solid readable card. */
  background: rgba(8, 10, 13, 0.82);
}

/* When nothing is selected the Selected card recedes to the faint, translucent
   look of the COLLAPSED Layers pane — quieter, but still a visible chip (not
   fully invisible, which read as a bug). */
.panel-card.info-card:has(#selected-detail .empty) {
  background: rgba(8, 10, 13, 0.5);
  border-color: rgba(197, 170, 104, 0.15);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.34);
}
.panel-card.info-card:has(#selected-detail .empty)::before,
.panel-card.info-card:has(#selected-detail .empty)::after {
  opacity: 0.4;
}

/* Inner scroll wrapper — sizes to the detail content so you don't scroll for normal
   selections; only very long content (near full height) scrolls. */
.info-card .card-body {
  overflow-y: auto;
  overflow-x: hidden;          /* no sideways scrollbar — content wraps instead */
  max-height: min(72vh, 640px);
  scrollbar-width: thin;
  scrollbar-color: rgba(197,170,104,.3) transparent;
}
.info-card .selected-title,
.info-card .selected-meta { overflow-wrap: anywhere; }
.info-card .selected-actions { flex-wrap: wrap; }

/* Workbench card — JS drives height animation; flex is set by .is-open at rest */
.workbench-card {
  padding: 0;
  flex: 0 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.workbench-card.is-open {
  flex: 0 1 auto;
  min-height: 120px;
  max-height: min(38vh, 430px);
}
.is-planner-session .workbench-card {
  display: none;
}

.workbench-card-toggle {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  border-bottom: 1px solid transparent;
  transition: background var(--t), border-color var(--t);
  min-height: 0;
}
.workbench-card.is-open .workbench-card-toggle {
  border-bottom-color: var(--line);
}
.workbench-card-toggle:hover {
  background: rgba(197, 170, 104, 0.04);
  border-color: transparent;
}

.card-chevron svg {
  width: 16px;
  height: 16px;
  display: block;
  transition: transform var(--t) var(--ease);
}
.workbench-card.is-open .card-chevron svg {
  transform: rotate(180deg);
}

.workbench-body {
  display: none;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
  padding: 12px 14px 14px;
  max-height: min(31vh, 360px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(197,170,104,.3) transparent;
}
.workbench-card.is-open .workbench-body {
  display: flex;
}
/* ================================================================
   FAB CLUSTER
   ================================================================ */
.fab-cluster {
  position: fixed;
  right: 14px;
  bottom: 18px;
  z-index: 180;
  width: 42px;
  height: 42px;
}

.tools-actions {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: grid;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.96);
  transform-origin: right bottom;
  transition: opacity var(--t), transform var(--t) var(--ease);
}

.fab-cluster.is-open .tools-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.tools-toggle-btn {
  border-color: rgba(197, 170, 104, 0.38);
}

.fab-cluster.is-open .tools-toggle-btn,
.tools-toggle-btn.is-active {
  border-color: rgba(197, 170, 104, 0.82);
  background: rgba(197, 170, 104, 0.18);
  color: #fff0b6;
  box-shadow: 0 0 0 3px rgba(197, 170, 104, 0.10), var(--shadow);
}

.route-primary-action {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 210;
  min-width: min(400px, calc(100vw - 36px));
  min-height: 54px;
  transform: translateX(-50%);
  border: 1px solid rgba(197, 170, 104, 0.62);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(197, 170, 104, 0.22), rgba(197, 170, 104, 0.10));
  color: #fff0c8;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(197, 170, 104, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-family: "Cinzel", "Palatino Linotype", Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity var(--t), transform var(--t) var(--ease), background var(--t), border-color var(--t), box-shadow var(--t);
}

.route-primary-action[hidden] {
  display: none;
}

.route-primary-action:hover {
  transform: translateX(-50%) translateY(-2px);
  border-color: rgba(230, 202, 130, 0.96);
  background: linear-gradient(180deg, rgba(197, 170, 104, 0.30), rgba(197, 170, 104, 0.16));
  color: #fff6dc;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.58), 0 0 0 3px rgba(197, 170, 104, 0.16);
}

.route-primary-action.is-cancel {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(8, 12, 15, 0.42);
  color: rgba(235, 246, 250, 0.86);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
}

.route-primary-action.is-cancel:hover {
  border-color: rgba(255, 142, 64, 0.72);
  background: rgba(255, 142, 64, 0.10);
  color: #ffe6cc;
}

.fab {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(197, 170, 104, 0.24);
  background: rgba(8, 10, 13, 0.82);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 5px 22px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  color: #d5c9aa;
  transition: border-color var(--t), background var(--t), color var(--t), transform 120ms, box-shadow var(--t);
}
.fab:hover {
  border-color: rgba(197, 170, 104, 0.62);
  background: rgba(14, 18, 22, 0.98);
  color: #fff0b6;
  transform: translateY(-2px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.64), 0 0 0 3px rgba(197, 170, 104, 0.08);
}
.fab svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.locate-icon { stroke-width: 1.9; }
.locate-icon circle:last-child { fill: currentColor; stroke: none; }

.fab.drop-mode {
  border-color: rgba(255, 221, 122, 0.9);
  background: rgba(197, 170, 104, 0.2);
  color: #fff0b6;
  box-shadow: 0 0 0 3px rgba(197, 170, 104, 0.12), var(--shadow);
}

/* "Here" waypoint FAB — accented to distinguish from map-click drop */
.fab-here {
  border-color: rgba(112, 182, 200, 0.35);
  color: var(--accent-2);
}

/* Favorites filter FAB — active state */
.fab.is-active {
  border-color: rgba(255, 120, 160, 0.85);
  background: rgba(255, 80, 130, 0.18);
  color: #ffb0c8;
}
.fab.is-active:hover {
  border-color: rgba(255, 140, 180, 1);
  background: rgba(255, 80, 130, 0.28);
}
#planner-toggle-btn.is-active {
  border-color: rgba(90, 235, 255, 0.72);
  background: rgba(90, 235, 255, 0.14);
  color: #dff8ff;
  box-shadow: 0 0 0 3px rgba(90, 235, 255, 0.10), var(--shadow);
}
#planner-toggle-btn.is-active:hover {
  border-color: rgba(120, 245, 255, 0.96);
  background: rgba(90, 235, 255, 0.22);
}

#heatmap-fab.is-active {
  border-color: rgba(255, 157, 77, 0.8);
  background: rgba(255, 142, 64, 0.16);
  color: #ffe0ba;
  box-shadow: 0 0 0 3px rgba(255, 142, 64, 0.10), var(--shadow);
}
#heatmap-fab.is-active:hover {
  border-color: rgba(255, 190, 110, 0.95);
  background: rgba(255, 142, 64, 0.23);
}
#waypoint-toggle-btn.is-active {
  border-color: rgba(197, 170, 104, 0.82);
  background: rgba(197, 170, 104, 0.17);
  color: #fff0b6;
  box-shadow: 0 0 0 3px rgba(197, 170, 104, 0.11), var(--shadow);
}
#waypoint-toggle-btn.is-active:hover {
  border-color: rgba(230, 202, 130, 0.96);
  background: rgba(197, 170, 104, 0.24);
}

.route-tool-panel,
.waypoint-tool-panel {
  position: relative;
  width: 42px;
  height: 42px;
}

.route-tool-actions,
.waypoint-actions {
  position: absolute;
  right: calc(100% + 8px);
  left: auto;
  top: 0;
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px) scaleX(0.88);
  transform-origin: right center;
  transition: opacity var(--t), transform var(--t) var(--ease);
}
.route-tool-panel.is-open .route-tool-actions,
.waypoint-tool-panel.is-open .waypoint-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scaleX(1);
}
.route-sub-fab,
.waypoint-sub-fab {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
}
.route-sub-fab svg,
.waypoint-sub-fab svg {
  width: 18px;
  height: 18px;
}

.route-sub-fab {
  border-color: rgba(90, 235, 255, 0.48);
  background: rgba(90, 235, 255, 0.10);
  color: #dff8ff;
}

.route-sub-fab:hover,
.route-sub-fab.is-active {
  border-color: rgba(120, 245, 255, 0.92);
  background: rgba(90, 235, 255, 0.20);
  box-shadow: 0 0 0 3px rgba(90, 235, 255, 0.10), var(--shadow);
}

.tag-tool-panel {
  position: relative;
  width: 42px;
  height: 42px;
}

.tag-actions {
  position: absolute;
  right: calc(100% + 8px);
  left: auto;
  top: 0;
  z-index: 220;
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px) scaleX(0.88);
  transform-origin: right center;
  transition: opacity var(--t), transform var(--t) var(--ease);
}

.tag-tool-panel.is-open .tag-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scaleX(1);
}

/* Tags toggle uses the shared .fab resting style so it matches the other tools. */

#tags-toggle-btn.is-active {
  border-color: rgba(197, 170, 104, 0.82);
  background: rgba(197, 170, 104, 0.18);
  color: #fff0b6;
  box-shadow: 0 0 0 3px rgba(197, 170, 104, 0.10), var(--shadow);
}

#tags-toggle-btn.is-active:hover {
  border-color: rgba(230, 202, 130, 0.96);
  background: rgba(197, 170, 104, 0.24);
}

/* Tag sub-fabs share the same dark-glass / gold-active treatment as every other
   map tool (route, waypoint, heatmap) for cohesion. Each icon keeps its own
   identity color; the button chrome is uniform. Off = dimmed, On = gold active. */
.tag-sub-fab {
  position: relative;
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  overflow: visible;
  opacity: 0.5;
  border-color: rgba(197, 170, 104, 0.28);
  background: rgba(8, 10, 13, 0.82);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: opacity 160ms var(--ease), transform 140ms var(--ease),
    border-color 160ms, background 160ms, box-shadow 160ms;
}

.tag-sub-fab svg {
  width: 18px;
  height: 18px;
}

/* Per-tag icon identity (independent of the uniform button chrome). */
.tag-sub-fab.tag-favorites svg { color: #ff9fb9; }
.tag-sub-fab.tag-caution svg { color: #ff9c9c; }
.tag-sub-fab.tag-private svg { color: #ffe2a0; }

.tag-sub-fab.is-visible {
  opacity: 1;
  border-color: rgba(197, 170, 104, 0.82);
  background: rgba(197, 170, 104, 0.16);
  box-shadow: 0 0 0 3px rgba(197, 170, 104, 0.10), var(--shadow);
}

/* Heatmap pop-out — mirrors the tags pattern; the two sub-fabs are lit in their LINE
   colour (Personal = teal, Everyone's = orange) and dimmed when off. */
.heatmap-tool-panel { position: relative; width: 42px; height: 42px; }
.heatmap-actions {
  position: absolute;
  right: calc(100% + 8px);
  left: auto;
  top: 0;
  z-index: 220;
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px) scaleX(0.88);
  transform-origin: right center;
  transition: opacity var(--t), transform var(--t) var(--ease);
}
.heatmap-tool-panel.is-open .heatmap-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scaleX(1);
}
.heatmap-sub-fab {
  position: relative;
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  opacity: 0.5;
  border-color: rgba(197, 170, 104, 0.28);
  background: rgba(8, 10, 13, 0.82);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: opacity 160ms var(--ease), border-color 160ms, background 160ms, box-shadow 160ms;
}
.heatmap-sub-fab svg { width: 18px; height: 18px; }
.heatmap-sub-personal svg { color: #7fd6ea; }
.heatmap-sub-everyone svg { color: #ff9e6a; }
.heatmap-sub-personal.is-active {
  opacity: 1;
  border-color: rgba(95, 208, 230, 0.85);
  background: rgba(95, 208, 230, 0.18);
  box-shadow: 0 0 0 3px rgba(95, 208, 230, 0.12), var(--shadow);
}
.heatmap-sub-everyone.is-active {
  opacity: 1;
  border-color: rgba(255, 142, 87, 0.85);
  background: rgba(255, 142, 87, 0.18);
  box-shadow: 0 0 0 3px rgba(255, 142, 87, 0.12), var(--shadow);
}

.tag-sub-fab:hover {
  opacity: 0.85;
  transform: translateY(-1px);
  border-color: rgba(197, 170, 104, 0.6);
}
.tag-sub-fab.is-visible:hover {
  opacity: 1;
  border-color: rgba(230, 202, 130, 0.96);
  background: rgba(197, 170, 104, 0.24);
}

/* Toggle feedback: a clear scale pop that plays in BOTH directions (on + off),
   driven by a transient .tag-pulse class added on click. */
.tag-sub-fab.tag-pulse {
  animation: tag-toggle-pop 260ms var(--ease);
}
@keyframes tag-toggle-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ================================================================
   DIAGNOSTICS
   ================================================================ */
.diagnostics-panel {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 300;
  max-width: 520px;
  border: 1px solid var(--gold-line);
  border-radius: var(--r-sm);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
}
.diagnostics-panel summary {
  min-height: 34px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 14px;
  list-style: none;
  user-select: none;
  transition: color var(--t);
}
.diagnostics-panel summary::-webkit-details-marker { display: none; }
.diagnostics-panel[open] summary {
  color: var(--accent);
  border-bottom: 1px solid var(--line);
}
.diagnostics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 14px 14px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

/* ================================================================
   CONTEXT MENU
   ================================================================ */
.vein-context-menu {
  position: fixed;
  z-index: 300;
  width: 182px;
  border: 1px solid rgba(197, 170, 104, 0.48);
  border-radius: var(--r-sm);
  background: rgba(11, 14, 18, 0.98);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-lg);
  padding: 6px;
}
.context-menu-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 8px 7px;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.vein-context-menu button {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  border-radius: var(--r-xs);
}
.vein-context-menu button:hover {
  border-color: rgba(197, 170, 104, 0.38);
  background: rgba(197, 170, 104, 0.11);
}

/* ================================================================
   VEIN LIST
   ================================================================ */
.vein-list {
  display: grid;
  gap: 5px;
  align-content: start;
}

.vein-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  padding: 7px 8px;
  transition: border-color var(--t), background var(--t);
}
.vein-row:hover {
  border-color: rgba(112, 182, 200, 0.65);
  background: rgba(112, 182, 200, 0.05);
}
.vein-row.is-selected {
  border-color: var(--accent);
  background: rgba(197, 170, 104, 0.07);
  box-shadow: inset 0 0 0 1px rgba(197, 170, 104, 0.25);
}
.vein-row.is-cooling {
  border-color: rgba(255, 125, 102, 0.65);
  background: linear-gradient(90deg, rgba(198, 107, 89, 0.13), rgba(255, 255, 255, 0.02) 52%);
}
.vein-row.is-private {
  border-color: rgba(255, 221, 122, 0.38);
  background: linear-gradient(90deg, rgba(197, 170, 104, 0.09), rgba(255, 255, 255, 0.02) 46%);
}

.swatch {
  width: 10px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid rgba(255, 245, 205, 0.5);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.65), 0 0 8px rgba(255, 245, 205, 0.14);
}

.row-title { font-size: 13px; font-weight: 650; }

.row-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.row-ref { margin-right: 2px; }

.row-chip {
  display: inline-flex;
  align-items: center;
  min-height: 17px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #c8d0d5;
  background: rgba(255, 255, 255, 0.04);
  padding: 0 5px;
  font-size: 11px;
  line-height: 1;
}
.row-chip.is-map      { color: #cceefa; border-color: rgba(112,182,200,.32); background: rgba(112,182,200,.08); }
.row-chip.is-entrance { color: #f4df9e; border-color: rgba(197,170,104,.38); background: rgba(197,170,104,.10); }
.row-chip.is-interior { color: #d6c7f4; border-color: rgba(162,137,214,.35); background: rgba(162,137,214,.09); }
.row-chip.is-unresolved { color: #b8bec4; border-color: rgba(155,163,170,.25); background: rgba(155,163,170,.07); }
.row-chip.is-cooling,
.row-chip.is-depleted { color: #fff2ee; border-color: rgba(255,125,102,.52); background: rgba(198,107,89,.19); }
.row-chip.is-partial  { color: #f5dda2; border-color: rgba(214,169,84,.42); background: rgba(214,169,84,.10); }
.row-chip.is-ready    { color: #d9f4d5; border-color: rgba(131,191,122,.38); background: rgba(131,191,122,.10); }
.row-chip.is-private  { gap: 4px; color: #fff0b6; border-color: rgba(255,221,122,.5); background: rgba(197,170,104,.15); }

.key-icon-mini {
  position: relative;
  display: inline-block;
  width: 13px;
  height: 9px;
  flex: 0 0 auto;
}
.key-icon-mini::before {
  content: "";
  position: absolute;
  left: 0; top: 1px;
  width: 6px; height: 6px;
  border: 1.6px solid currentColor;
  border-radius: 50%;
}
.key-icon-mini::after {
  content: "";
  position: absolute;
  left: 6px; top: 4px;
  width: 7px; height: 1.7px;
  background: currentColor;
  box-shadow: -1px 3px 0 -0.2px currentColor, 4px 3px 0 -0.2px currentColor;
}

.resource-chip {
  display: inline-block;
  color: #f7f3d0;
  background: rgba(197, 170, 104, 0.15);
  border: 1px solid rgba(197, 170, 104, 0.42);
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 11px;
  white-space: nowrap;
}

.distance-chip { color: var(--accent-2); font-size: 12px; }

.distance-stack {
  display: grid;
  justify-items: end;
  gap: 3px;
  min-width: 68px;
}

.cooldown-chip {
  color: #fff2ee;
  background: rgba(198, 107, 89, 0.3);
  border: 1px solid rgba(255, 125, 102, 0.6);
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 11px;
}

/* ================================================================
   SELECTED DETAIL
   ================================================================ */
.detail,
.evidence-list,
.marker-summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.selected-detail { margin-top: 0; }

.detail dl {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 5px 10px;
  margin: 0;
}
.detail dl.selected-basic {
  grid-template-columns: 72px 1fr;
  margin-top: 8px;
}
.detail dt { color: var(--muted); }
.detail dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

.selected-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.selected-meta { color: var(--muted); font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; }

/* Action strip — horizontal pill row below the info */
.selected-actions {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 9px -2px 0;
  padding: 8px 2px 9px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(8, 10, 13, 0.98), rgba(8, 10, 13, 0.90));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Base style for all action buttons in the selected panel */
.sel-act-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 0 9px;
  font-size: 11px;
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  transition: border-color var(--t), background var(--t), color var(--t);
}
.sel-act-btn:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
}
.sel-act-btn.is-active {
  border-color: rgba(197, 170, 104, 0.55);
  background: rgba(197, 170, 104, 0.13);
  color: var(--accent);
}

/* Navigate button — accent tint, stands out as primary action */
.sel-act-btn.sel-act-navigate {
  flex: 1 1 100%;
  justify-content: center;
  min-height: 32px;
  margin-bottom: 3px;
  color: #e6fbff;
  font-weight: 760;
  letter-spacing: 0.02em;
  border-color: rgba(112, 210, 230, 0.72);
  background: linear-gradient(180deg, rgba(78, 172, 195, 0.22), rgba(45, 115, 140, 0.16));
  box-shadow: inset 0 0 0 1px rgba(220, 255, 255, 0.08), 0 0 16px rgba(90, 235, 255, 0.08);
}
.sel-act-btn.sel-act-navigate:hover {
  border-color: rgba(136, 236, 255, 0.95);
  background: linear-gradient(180deg, rgba(90, 200, 226, 0.30), rgba(55, 135, 162, 0.22));
  color: #ffffff;
}

/* Favourite buttons — pink tint */
.sel-act-btn.sel-act-fav {
  color: rgba(255, 160, 190, 0.65);
  border-color: rgba(255, 120, 160, 0.22);
}
.sel-act-btn.sel-act-fav:hover {
  border-color: rgba(255, 120, 160, 0.7);
  background: rgba(255, 80, 130, 0.1);
  color: #ffb0c8;
}
.sel-act-btn.sel-act-fav.is-active {
  border-color: rgba(255, 120, 160, 0.75);
  background: rgba(255, 80, 130, 0.16);
  color: #ffb0c8;
}

.nav-route-status {
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-muted);
  padding: 2px 0 0;
  min-height: 0;
  transition: color 0.2s;
}
.nav-route-status:empty { display: none; }
.nav-route-status.is-pending { color: var(--accent-2); }
.nav-route-status.is-found   { color: #72e89a; }
.nav-route-status.is-none    { color: rgba(255,180,100,0.7); }
.nav-route-status.is-direct  { color: rgba(180,190,205,0.8); }

.route-mode-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.route-mode-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.2;
}
.route-mode-chip.is-smart {
  color: #72e89a;
  border-color: rgba(114,232,154,0.42);
  background: rgba(114,232,154,0.08);
}
.route-mode-chip.is-direct {
  color: rgba(255,180,100,0.86);
  border-color: rgba(255,180,100,0.35);
  background: rgba(255,180,100,0.08);
}
.route-mode-chip.is-learning {
  color: var(--accent-2);
  border-color: rgba(112,182,200,0.42);
  background: rgba(112,182,200,0.08);
}
.route-mode-chip.is-heatmap {
  color: #ffb064;
  border-color: rgba(255, 135, 90, 0.42);
  background: rgba(255, 110, 80, 0.09);
}

.debug-route-controls { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.debug-route-status { font-size: 10px; color: var(--text-muted); }
.debug-route-status.is-placing { color: #00eeff; }
.debug-route-status.is-placed  { color: #72e89a; }
.route-debug-subtool {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.route-debug-subheading {
  display: grid;
  gap: 2px;
}
.route-debug-subheading strong {
  color: var(--text);
  font-size: 12px;
}
.route-debug-subheading span,
.path-hint-empty {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.path-hint-list {
  display: grid;
  gap: 5px;
  max-height: 170px;
  overflow: auto;
  padding-right: 2px;
}
.path-hint-list-heading {
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.path-hint-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 157, 77, 0.22);
  border-radius: var(--r-xs);
  background: rgba(255, 142, 64, 0.055);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}
.path-hint-row.is-selected {
  border-color: rgba(255, 211, 122, 0.7);
  background: rgba(255, 190, 80, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 232, 160, 0.08);
}
.path-hint-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.path-hint-row strong {
  flex: 0 0 auto;
  color: rgba(255, 190, 122, 0.92);
  font-size: 10px;
}
.path-hint-overlay {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 70;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: min(900px, calc(100vw - 32px));
  max-height: min(44vh, 360px);
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid rgba(255, 157, 77, 0.38);
  border-radius: var(--r-sm);
  background:
    linear-gradient(180deg, rgba(26, 20, 16, 0.96), rgba(11, 13, 16, 0.96));
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  color: var(--text);
  transform: translateX(-50%);
}
.path-hint-overlay[hidden] {
  display: none !important;
}
.path-hint-overlay-copy {
  display: grid;
  gap: 2px;
  min-width: min(300px, 50vw);
  min-width: 0;
  max-width: min(390px, 100%);
}
.path-hint-overlay-copy strong {
  color: rgba(255, 221, 166, 0.96);
  font-family: "Cinzel", "Palatino Linotype", Georgia, serif;
  font-size: 12px;
  letter-spacing: 0;
}
.path-hint-overlay-copy span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.path-hint-direction {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.035);
}
.path-hint-direction span {
  padding: 0 5px;
  color: var(--muted);
  font-size: 10px;
}
.path-hint-direction button {
  min-height: 28px;
  padding: 0 9px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}
.path-hint-direction button.is-active {
  color: #fff3e9;
  border-color: rgba(255, 157, 77, 0.5);
  background: rgba(255, 142, 64, 0.12);
}
.path-hint-overlay-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.path-hint-overlay-actions button {
  min-height: 30px;
  min-width: 66px;
  padding: 0 10px;
  border-color: rgba(255, 157, 77, 0.35);
  background: rgba(255, 142, 64, 0.08);
}
.path-hint-overlay-actions button:disabled {
  opacity: 0.45;
}
.debug-route-overlay {
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(0, 2fr);
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  max-width: min(1040px, calc(100vw - 28px));
  border-color: var(--gold-line);
  background:
    linear-gradient(180deg, rgba(16, 18, 22, 0.97), rgba(9, 11, 14, 0.97));
}
.debug-route-overlay .path-hint-overlay-copy {
  align-content: center;
  min-width: 0;
  max-width: none;
  padding: 8px 11px;
  border: 1px solid var(--gold-line);
  border-radius: var(--r-xs);
  background: rgba(197, 170, 104, 0.05);
}
.debug-route-overlay .path-hint-overlay-copy strong {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.debug-route-overlay-actions button {
  border-color: var(--gold-line);
  background: rgba(197, 170, 104, 0.08);
}
.debug-route-toolbar {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 1fr);
  align-items: start;
  gap: 10px;
  min-width: 0;
  max-width: none;
}
.debug-action-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* one full-width button per row — no text wrapping */
  align-content: start;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 8px;
  border: 1px solid var(--gold-line);
  border-radius: var(--r-xs);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
}
.debug-action-group.debug-exit-group {
  align-content: stretch;
  background: none;
  border-color: rgba(198, 107, 89, 0.3);
}
.debug-action-group[hidden] {
  display: none !important;
}
.debug-action-label {
  min-width: 0;
  margin-bottom: 1px;
  color: var(--accent);
  font-family: "Cinzel", Georgia, serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.debug-action-group button {
  min-width: 0;
  max-width: none;
  min-height: 34px;
  padding: 5px 10px;
  white-space: nowrap;
  line-height: 1.1;
  border-color: rgba(197, 170, 104, 0.34);
  background: rgba(197, 170, 104, 0.08);
}
.debug-exit-group button {
  height: 100%;
  border-color: rgba(198, 107, 89, 0.5);
  background: rgba(198, 107, 89, 0.12);
  color: #f4c4b6;
}
.debug-action-group button:hover:not(:disabled) {
  border-color: rgba(230, 202, 130, 0.85);
  background: rgba(197, 170, 104, 0.16);
}
.debug-exit-group button:hover:not(:disabled) {
  border-color: rgba(255, 125, 102, 0.85);
  background: rgba(198, 107, 89, 0.22);
}
.debug-action-group button.is-active,
#debug-teach-path-btn.is-active,
#debug-adjust-route-btn.is-active {
  color: #fff5d6;
  border-color: rgba(255, 214, 122, 0.76);
  background: rgba(255, 190, 80, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 235, 150, 0.08);
}
#debug-improve-routes-btn {
  border-color: rgba(230, 202, 130, 0.6);
  background: rgba(197, 170, 104, 0.16);
  color: #fff0c8;
  font-weight: 700;
}
#debug-improve-routes-btn:hover:not(:disabled) {
  border-color: rgba(230, 202, 130, 0.95);
  background: rgba(197, 170, 104, 0.24);
}
/* Route smoothing tool inside the debug-session toolbar. */
.debug-smoothing-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  font-size: 11px;
  color: #d5c9aa;
  cursor: pointer;
}
.debug-smoothing-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}
.debug-smoothing-group .settings-range {
  margin: 2px 0;
}
.debug-smoothing-value {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.debug-smoothing-value span {
  color: var(--accent);
  font-weight: 700;
}
.debug-tool-panel {
  border-color: rgba(255, 157, 77, 0.26);
  background: rgba(255, 142, 64, 0.045);
}
.debug-exit-group {
  grid-template-columns: 1fr;
  border-color: rgba(255, 120, 120, 0.28);
  background: rgba(255, 100, 90, 0.045);
}
.debug-exit-group button {
  min-height: 68px;
  border-color: rgba(255, 130, 120, 0.42);
  background: rgba(255, 90, 80, 0.10);
  color: #ffd3ce;
  font-weight: 800;
}
.planner-session-overlay {
  border-color: rgba(197, 170, 104, 0.46);
  background:
    linear-gradient(180deg, rgba(24, 23, 18, 0.96), rgba(10, 12, 13, 0.96));
}
.route-builder-overlay .path-hint-overlay-copy strong {
  color: rgba(222, 244, 255, 0.96);
}
.waypoint-edit-overlay .path-hint-overlay-copy strong {
  color: rgba(255, 232, 173, 0.96);
}
.planner-session-name,
.planner-session-select {
  min-height: 31px;
  min-width: min(220px, 45vw);
  max-width: 260px;
  border: 1px solid rgba(197, 170, 104, 0.35);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  padding: 0 10px;
  font-size: 12px;
  outline: none;
}
.planner-session-select {
  color-scheme: dark;
}
.planner-session-actions button.is-active,
#route-builder-open-btn.is-active,
#waypoint-overlay-drop-btn.is-active {
  color: #fff5d6;
  border-color: rgba(255, 214, 122, 0.68);
  background: rgba(255, 190, 80, 0.14);
}
@media (max-width: 700px) {
  .path-hint-overlay {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }
  .debug-route-overlay {
    grid-template-columns: 1fr;
  }
  .debug-route-toolbar {
    grid-template-columns: 1fr;
  }
  .debug-exit-group button {
    min-height: 38px;
  }
  .path-hint-overlay-copy {
    min-width: 0;
  }
  .path-hint-direction,
  .path-hint-overlay-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  .debug-route-overlay-actions {
    grid-template-columns: repeat(2, 1fr);
  }
  .planner-session-name,
  .planner-session-select {
    max-width: none;
    width: 100%;
  }
  .path-hint-direction span {
    align-self: center;
  }
}

.route-learn-status {
  min-height: 18px;
  margin: -2px 2px 8px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}
.route-learn-status.is-recording { color: var(--accent-2); }
.route-learn-status.is-saved { color: #72e89a; }
.route-learn-status.is-warn { color: rgba(255,180,100,0.8); }
.heatmap-status {
  margin-top: -6px;
}

.route-improve-box {
  flex: 0 0 auto;
  display: grid;
  gap: 6px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
}
.route-improve-box button {
  min-height: 32px;
  border: 1px solid rgba(255, 158, 64, 0.35);
  border-radius: 7px;
  background: rgba(255, 110, 80, 0.10);
  color: #ffd2a2;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.route-improve-box button:hover:not(:disabled) {
  border-color: rgba(255, 190, 110, 0.62);
  background: rgba(255, 130, 80, 0.16);
}
.route-improve-box button:disabled {
  opacity: 0.52;
  cursor: default;
}
.route-improve-status {
  min-height: 16px;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.35;
}
.route-improve-status.is-running { color: var(--accent-2); }
.route-improve-status.is-complete { color: #72e89a; }
.route-improve-status.is-error { color: rgba(255, 120, 120, 0.9); }

/* Keep old class names working during transition */
.selected-fav-btn { color: rgba(255, 160, 190, 0.65); border-color: rgba(255, 120, 160, 0.22); }

.row-chip.is-favorite {
  color: #ffb0c8;
  border-color: rgba(255, 120, 160, 0.4);
  background: rgba(255, 80, 130, 0.1);
}

.mining-notes {
  margin: 8px 0 0;
  padding: 0 0 0 14px;
  list-style: disc;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.mining-notes li + li { margin-top: 3px; }

.status-note             { color: var(--danger); font-size: 12px; }
.status-note.is-cooling  { color: var(--danger-strong); }
.status-note.is-live     { color: var(--accent); }
.status-note.is-private  { color: #fff0b6; }
.status-note.is-not-found { color: #ffaa50; }
.status-note.is-caution   { color: #ff6b6b; }

.row-chip.is-not-found {
  color: #ffaa50;
  border-color: rgba(255, 165, 80, 0.4);
  background: rgba(255, 130, 30, 0.1);
}

.selected-caution-btn {
  border-color: rgba(255, 70, 70, 0.35) !important;
  color: rgba(255, 107, 107, 0.8) !important;
  background: transparent !important;
}
.selected-caution-btn:hover {
  border-color: rgba(255, 70, 70, 0.8) !important;
  background: rgba(255, 50, 50, 0.12) !important;
  color: #ff6b6b !important;
}
.selected-caution-btn.is-active {
  border-color: rgba(255, 70, 70, 0.8) !important;
  background: rgba(255, 50, 50, 0.18) !important;
  color: #ff6b6b !important;
}

.row-chip.is-caution {
  color: #ff6b6b;
  border-color: rgba(255, 70, 70, 0.4);
  background: rgba(255, 50, 50, 0.1);
}

.live-monitor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.live-monitor > div {
  border: 1px solid rgba(197, 170, 104, 0.28);
  border-radius: var(--r-xs);
  background: rgba(197, 170, 104, 0.06);
  padding: 7px;
}
.live-monitor span  { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.live-monitor strong { display: block; color: var(--text); font-size: 13px; margin-top: 2px; }

/* ================================================================
   BEST NEXT
   ================================================================ */
.best-next {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.best-note {
  border: 1px solid rgba(255, 125, 102, 0.24);
  border-radius: var(--r-xs);
  background: rgba(198, 107, 89, 0.08);
  color: #ffd6cd;
  padding: 6px 8px;
  font-size: 12px;
}

.best-row {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
  transition: border-color var(--t), background var(--t);
}
.best-row:hover {
  border-color: rgba(112, 182, 200, 0.6);
  background: rgba(112, 182, 200, 0.05);
}
.best-row.is-selected {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(197,170,104,.11), rgba(255,255,255,.02));
}
.best-title  { display: block; color: var(--text); font-weight: 700; font-size: 13px; }
.best-meta,
.best-route,
.best-reason { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.best-reason { color: #c5b786; }
.best-route  { color: var(--accent-2); text-align: right; white-space: nowrap; }

/* ================================================================
   WORKBENCH
   ================================================================ */
.section-label {
  font-family: "Cinzel", "Palatino Linotype", Georgia, serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 14px 0 6px;
}

.route-home,
.route-builder { display: grid; gap: 8px; }

.route-build-open {
  min-height: 36px;
  border-color: rgba(112, 182, 200, 0.44);
  background: rgba(112, 182, 200, 0.10);
  color: #dff8ff;
  font-weight: 700;
}

.route-summary {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(197, 170, 104, 0.24);
  border-radius: var(--r-xs);
  background: rgba(197, 170, 104, 0.07);
  padding: 8px;
}
.route-summary.is-active {
  border-color: rgba(90, 235, 255, 0.55);
  background: rgba(90, 235, 255, 0.10);
}
.route-summary-title {
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}
.route-summary-meta {
  color: var(--muted);
  font-size: 12px;
}
.route-home-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.route-home-actions button {
  min-width: 0;
  font-size: 12px;
}
.route-home-actions button:disabled {
  opacity: 0.42;
  cursor: default;
}
.route-home-actions .is-active {
  border-color: rgba(90, 235, 255, 0.72);
  background: rgba(90, 235, 255, 0.13);
}

.route-step-controls[hidden] {
  display: none;
}
.route-step-card {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(90, 235, 255, 0.32);
  border-radius: var(--r-xs);
  background: rgba(90, 235, 255, 0.075);
  padding: 8px;
}
.route-step-card.is-active {
  border-color: rgba(90, 235, 255, 0.58);
  background: linear-gradient(90deg, rgba(90, 235, 255, 0.12), rgba(255, 255, 255, 0.025));
}
.route-step-title {
  display: block;
  color: var(--text);
  font-weight: 750;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-step-meta {
  display: block;
  color: var(--accent-2);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-step-nav {
  display: flex;
  align-items: center;
  gap: 5px;
}
.route-step-nav button {
  min-width: 32px;
  min-height: 28px;
  padding: 0 8px;
  font-weight: 700;
}
.route-step-nav button:disabled {
  opacity: 0.35;
  cursor: default;
}

.route-builder-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}
.route-builder-header input {
  min-width: 0;
}
.route-more {
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.025);
  padding: 6px;
}
.route-more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.route-more[open] summary { margin-bottom: 6px; }

.route-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.route-actions button { min-width: 0; font-size: 12px; min-height: 28px; }

.route-primary-actions .route-pick-btn,
.route-run-btn {
  border-color: rgba(112, 182, 200, 0.42);
  background: rgba(112, 182, 200, 0.09);
}
.route-run-btn.is-active,
.route-pick-btn.is-active,
#debug-route-start-btn.is-active,
#debug-adjust-route-btn.is-active,
#path-hint-btn.is-active {
  color: #e9fbff;
  border-color: rgba(90, 235, 255, 0.72);
  background: rgba(90, 235, 255, 0.13);
  box-shadow: inset 0 0 0 1px rgba(90, 235, 255, 0.12);
}
#path-hint-btn.is-active,
#debug-teach-path-btn.is-active {
  color: #fff3e9;
  border-color: rgba(255, 157, 77, 0.72);
  background: rgba(255, 142, 64, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 142, 64, 0.12);
}

.route-draft,
.saved-routes,
.waypoints-list {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}
.route-draft {
  max-height: min(18vh, 180px);
  overflow-y: auto;
}
.route-session-draft {
  min-width: min(520px, calc(100vw - 48px));
  max-width: min(680px, calc(100vw - 48px));
  max-height: min(28vh, 260px);
  padding: 6px;
  border: 1px solid rgba(197, 170, 104, 0.24);
  border-radius: var(--r-xs);
  background: rgba(4, 7, 9, 0.34);
}
.route-session-draft.empty {
  min-width: min(320px, calc(100vw - 48px));
}
.route-drag-handle {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 26px;
  color: rgba(255, 232, 173, 0.58);
  cursor: grab;
  font-weight: 800;
  letter-spacing: 0;
}
.route-point.is-dragging .route-drag-handle {
  cursor: grabbing;
}
.saved-routes {
  max-height: min(20vh, 220px);
  overflow-y: auto;
}
.waypoints-list {
  max-height: min(40vh, 440px);
  overflow-y: auto;
}

.route-guidance {
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(90, 235, 255, 0.5);
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, rgba(90,235,255,.11), rgba(255,255,255,.02));
  padding: 8px;
}
.route-guidance.is-complete {
  border-color: rgba(131, 191, 122, 0.5);
  background: linear-gradient(90deg, rgba(131,191,122,.11), rgba(255,255,255,.02));
}
.route-guidance-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}
.route-guidance-actions button { min-width: 40px; min-height: 26px; padding: 0 8px; font-size: 12px; }

.route-point,
.saved-route-row,
.waypoint-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.025);
  padding: 7px 8px;
  transition: border-color var(--t), background var(--t), opacity var(--t), box-shadow var(--t), transform var(--t) var(--ease);
}
.route-point { cursor: grab; }
.saved-route-row {
  min-height: 48px;
  cursor: pointer;
}
.saved-route-row:hover,
.saved-route-row:focus-visible {
  border-color: rgba(90, 235, 255, 0.42);
  background: rgba(90, 235, 255, 0.065);
}
.saved-route-main {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.route-point:active { cursor: grabbing; }
.route-point.is-dragging { opacity: 0.44; }
.route-point.is-drop-target {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 2px rgba(197, 170, 104, 0.1);
}
.landmark-row {
  border-color: rgba(112, 182, 200, 0.24);
  background: rgba(112, 182, 200, 0.06);
}
.saved-route-row.is-active {
  border-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-dim), rgba(255,255,255,.02));
  box-shadow: inset 0 0 0 1px rgba(197, 170, 104, 0.14);
}
.saved-route-row.is-running {
  border-color: rgba(90, 235, 255, 0.62);
  background: linear-gradient(90deg, rgba(90,235,255,.12), rgba(255,255,255,.025));
}
.saved-route-actions {
  flex-wrap: nowrap;
}
.route-row-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.045);
}
.route-row-icon svg {
  width: 15px;
  height: 15px;
}
.route-row-icon:hover {
  border-color: rgba(90, 235, 255, 0.58);
  background: rgba(90, 235, 255, 0.11);
  color: #dff8ff;
}
.route-row-icon.is-danger:hover {
  border-color: rgba(255, 105, 105, 0.66);
  background: rgba(255, 80, 80, 0.11);
  color: #ffc1c1;
}
.route-point-title,
.saved-route-title,
.waypoint-title { color: var(--text); font-weight: 650; font-size: 13px; }
.route-point-meta,
.saved-route-meta,
.waypoint-meta  {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}
.row-actions button { min-width: 30px; min-height: 26px; padding: 0 6px; font-size: 12px; }
.route-point {
  grid-template-columns: auto minmax(0, 1fr) auto;
}
.route-point > span:not(.row-actions):not(.route-drag-handle) {
  min-width: 0;
}
.route-session-draft .route-point {
  background: rgba(255, 255, 255, 0.035);
}

.waypoint-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 5px;
  padding-top: 8px;
  border-top: 1px solid rgba(197, 170, 104, 0.16);
  background: linear-gradient(180deg, rgba(8, 10, 13, 0), rgba(8, 10, 13, 0.96) 35%);
}
.waypoint-toolbar button {
  min-width: 0;
  font-size: 12px;
}
.waypoint-toolbar.is-editing {
  grid-template-columns: 1fr 1fr;
}
.waypoint-toolbar [data-waypoint-edit-mode] {
  border-color: rgba(112, 182, 200, 0.36);
  background: rgba(112, 182, 200, 0.08);
  color: #dff8ff;
  font-weight: 700;
}
.waypoint-category-card {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(197, 170, 104, 0.16);
  border-radius: var(--r-xs);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.034), rgba(255, 255, 255, 0.018));
  padding: 8px;
}
.waypoint-category-card.is-active {
  border-color: rgba(197, 170, 104, 0.42);
  background: rgba(197, 170, 104, 0.065);
}
.waypoint-category-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.waypoint-category-toggle {
  min-width: 0;
  min-height: 34px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.waypoint-category-toggle:hover {
  background: transparent;
}
.waypoint-category-chevron {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: transform var(--t) var(--ease), color var(--t);
}
.waypoint-category-chevron::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
}
.waypoint-category-card.is-collapsed .waypoint-category-chevron {
  transform: rotate(-90deg);
}
.waypoint-category-toggle:hover .waypoint-category-chevron {
  color: var(--accent);
}
.waypoint-category-swatch,
.waypoint-dot {
  background: var(--waypoint-color, #ffdd7a);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.48), 0 0 12px color-mix(in srgb, var(--waypoint-color, #ffdd7a) 38%, transparent);
}
.waypoint-category-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.waypoint-category-copy {
  min-width: 0;
}
.waypoint-category-title,
.waypoint-category-meta {
  display: block;
}
.waypoint-category-title {
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.waypoint-category-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 1px;
}
.waypoint-category-items {
  display: grid;
  gap: 5px;
}
.waypoint-row {
  grid-template-columns: 1fr;
  align-items: start;
  border-color: rgba(255, 255, 255, 0.075);
  background: rgba(0, 0, 0, 0.16);
}
.waypoint-row:hover {
  border-color: rgba(112, 182, 200, 0.36);
  background: rgba(112, 182, 200, 0.055);
}
.waypoint-row-main {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "dot title"
    "dot meta";
  column-gap: 8px;
  align-items: center;
}
.waypoint-dot {
  grid-area: dot;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.waypoint-row .waypoint-title {
  grid-area: title;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.waypoint-row .waypoint-meta {
  grid-area: meta;
}
.waypoint-row .row-actions {
  justify-content: flex-start;
  opacity: 0.72;
}
.waypoint-row:hover .row-actions,
.waypoint-row:focus-within .row-actions {
  opacity: 1;
}
.waypoint-row.is-active-category {
  border-color: rgba(197, 170, 104, 0.20);
}

.drop-mode {
  border-color: var(--accent) !important;
  background: var(--accent-dim) !important;
}

.empty { color: var(--muted); padding: 8px 0; font-size: 13px; }
.route-summary.empty { padding: 8px; }

.evidence-item {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.evidence-item:last-child { border-bottom: 0; }
.evidence-title { color: var(--text); font-weight: 650; }

/* ── Map hover tooltip ── */
.map-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 300;
  background: rgba(8, 10, 13, 0.94);
  border: 1px solid var(--gold-line);
  border-radius: var(--r-xs);
  color: var(--text);
  font-size: 12px;
  padding: 4px 9px;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

/* ── Location rows in drawer search ── */
.list-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 2px 4px;
}
.list-section-label:first-child { padding-top: 2px; }

.location-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 40px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  padding: 6px 8px;
  transition: border-color var(--t), background var(--t);
}
.location-row:hover {
  border-color: rgba(197, 170, 104, 0.5);
  background: rgba(197, 170, 104, 0.06);
}
.location-row.is-selected {
  border-color: var(--accent);
  background: rgba(197, 170, 104, 0.09);
}
.location-row-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

/* Map QC mode overlay (reuses .path-hint-overlay positioning) */
.mapqc-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.mapqc-tool {
  height: 30px; padding: 0 11px; border-radius: var(--r-sm);
  border: 1px solid rgba(197,170,104,0.32); background: rgba(8,10,13,0.7);
  color: #e7e3d8; font-size: 12px; font-weight: 700; cursor: pointer;
  transition: border-color var(--t), background var(--t), color var(--t);
}
.mapqc-tool:hover { border-color: rgba(230,202,130,0.8); background: rgba(197,170,104,0.14); }
.mapqc-tool.is-active { border-color: rgba(230,202,130,0.95); background: rgba(197,170,104,0.22); color: #fff0b6; }
.mapqc-tool.danger { border-color: rgba(220,120,110,0.5); color: #ffb9ad; }
.mapqc-tool.danger:hover { background: rgba(220,120,110,0.16); }
.mapqc-end { height: 30px; padding: 0 11px; border-radius: var(--r-sm); border: 1px solid rgba(220,120,110,0.5);
  background: rgba(40,12,10,0.6); color: #ffb9ad; font-size: 12px; font-weight: 800; cursor: pointer; margin-left: auto; }
.mapqc-panel {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(197,170,104,0.18);
  display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto;
}
.mapqc-form-title { font-weight: 800; color: #f3ecd7; font-size: 12.5px; }
.mapqc-form-title .kzmuted { color: var(--muted); font-weight: 600; }
.mapqc-panel input, .mapqc-panel select {
  height: 30px; padding: 0 8px; border-radius: var(--r-sm);
  border: 1px solid rgba(197,170,104,0.3); background: rgba(5,7,8,0.8); color: #efe7cf; font-size: 13px;
}
.mapqc-form-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mapqc-msec { font-size: 12px; color: #cfc9bb; line-height: 1.6; }
.mapqc-msec b { color: #e7e3d8; }
.mapqc-msec a { color: #7fd6ea; text-decoration: none; margin-left: 6px; }
.mapqc-msec a:hover { text-decoration: underline; }

/* Staff-only layer toggle — hidden unless the body is flagged is-staff (owner/admin). */
.staff-only { display: none; }
body.is-staff .staff-only { display: block; }

/* Map QC — Manage modal (a roomy pane, not the cramped overlay panel). */
.mapqc-manage-modal {
  position: fixed; inset: 0; z-index: 100200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 5, 6, 0.6); backdrop-filter: blur(2px); padding: 24px;
}
.mapqc-manage-modal[hidden] { display: none; }
.mapqc-manage-card {
  width: min(720px, 96vw); max-height: 86vh; display: flex; flex-direction: column;
  background: #15191a; border: 1px solid rgba(197,170,104,0.34); border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.6);
}
.mapqc-manage-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid rgba(197,170,104,0.18);
}
.mapqc-manage-head h3 { margin: 0; color: #f3ecd7; font: 700 16px "Cinzel", Georgia, serif; }
.mapqc-manage-body { padding: 14px 18px 20px; overflow-y: auto; }
.mapqc-mgrp { margin-bottom: 16px; }
.mapqc-mgrp-title { text-transform: uppercase; font-size: 11px; letter-spacing: .6px; color: #c5aa68; margin-bottom: 6px; }
.mapqc-mrow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid rgba(197,170,104,0.14); border-radius: 8px;
  background: rgba(8,10,13,0.5); margin-bottom: 6px;
}
.mapqc-mrow span { color: #e7e3d8; font-size: 13px; }
.mapqc-mrow .kzmuted { color: var(--muted); }
.mapqc-mrow button {
  height: 28px; padding: 0 12px; border-radius: 6px; border: 1px solid rgba(197,170,104,0.3);
  background: rgba(8,10,13,0.7); color: #e7e3d8; font-size: 12px; font-weight: 700; cursor: pointer;
}
.mapqc-mrow button:hover { border-color: rgba(230,202,130,0.8); background: rgba(197,170,104,0.14); }
.mapqc-empty { color: var(--muted); font-size: 13px; }

.selected-coords { color: var(--muted); font-size: 12px; margin: 1px 0 2px; letter-spacing: 0.2px; }
