/* ------------------------------------------------------------------------
   FitTool — quiet utility UI.
   Goal: a readable, native-feeling tool. No editorial conceits.
   Mono is used only where it earns its keep (numerals & code-y readouts).
   ------------------------------------------------------------------------ */
:root {
  --brand: #ff5722;
  --accent: #c43c14;
  --accent-soft: rgba(196, 60, 20, 0.10);
  --accent-strong: #9c2d0c;
  --teal: #1f6b6b;
  --danger: #b8232a;

  /* Slightly warm off-white — avoids the cold #f6f7f9 default,
     without going full "cream paper". */
  --bg: #eeece6;
  --bg-elev: #f5f3ec;
  --bg-soft: #e6e3d9;
  --bg-overlay: rgba(245, 243, 236, 0.96);

  --fg: #1c1d22;
  --fg-muted: #4d5057;
  --fg-faint: #87887f;
  --border: rgba(26, 28, 32, 0.12);
  --border-strong: rgba(26, 28, 32, 0.26);
  --rule: rgba(26, 28, 32, 0.09);

  --shadow-sm: 0 1px 0 rgba(26, 28, 32, 0.05);
  --shadow-md: 0 2px 8px rgba(26, 28, 32, 0.08);
  --shadow-lg: 0 14px 36px rgba(26, 28, 32, 0.22);

  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius: 5px;
  --radius-lg: 6px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  /* System stack — native, readable, no font-shopping. Chinese falls
     back to PingFang / Microsoft Yahei naturally. Mono only for numbers. */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable",
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft Yahei UI",
    system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
    "Courier New", monospace;

  --header-h: 50px;
  --sidebar-w: 332px;

  --easing: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #15171c;
  --bg-elev: #1c1f26;
  --bg-soft: #232631;
  --bg-overlay: rgba(28, 31, 38, 0.94);
  --fg: #e6e3d6;
  --fg-muted: #a6a89f;
  --fg-faint: #6a6b62;
  --border: rgba(230, 227, 214, 0.10);
  --border-strong: rgba(230, 227, 214, 0.22);
  --rule: rgba(230, 227, 214, 0.07);
  --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);
  --accent: #e35a2a;
  --accent-soft: rgba(227, 90, 42, 0.18);
  --accent-strong: #f57946;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { color-scheme: dark; }
}

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

html,
body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

input, textarea {
  font: inherit;
  color: inherit;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.005em;
}

p { margin: 0; }

[hidden] { display: none !important; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-pill); }
::-webkit-scrollbar-track { background: transparent; }

.dim { color: var(--fg-faint); }

.hint {
  font-size: 12px;
  color: var(--fg-faint);
  line-height: 1.55;
}

/* ------------------------------------------------------------------------
   App bar
   ------------------------------------------------------------------------ */
.app-bar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--rule);
  position: relative;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.brand-mark {
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.005em;
  color: var(--fg);
}

.app-bar-spacer { flex: 1; }

.app-bar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.app-bar-divider {
  width: 1px;
  height: 18px;
  background: var(--rule);
  margin: 0 6px;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s var(--easing), color 0.12s var(--easing);
}

.ghost-btn svg { opacity: 0.8; }

.ghost-btn:hover {
  background: var(--bg-soft);
  color: var(--fg);
}

.ghost-btn:hover svg { opacity: 1; }

.ghost-btn.icon-only { padding: 6px; }

#themeBtn [data-icon="dark"] { display: none; }
[data-theme="dark"] #themeBtn [data-icon="light"] { display: none; }
[data-theme="dark"] #themeBtn [data-icon="dark"] { display: inline; }

/* ------------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------------ */
.layout {
  height: calc(100vh - var(--header-h));
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}

.sidebar-scroll {
  height: 100%;
  overflow-y: auto;
  padding: var(--space-3) var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ------------------------------------------------------------------------
   Sections (formerly "cards") — flat, hairline-separated.
   No numbering, no kickers, no icon chips.
   ------------------------------------------------------------------------ */
.card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: var(--space-4) 0 var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.card + .card {
  border-top: 1px solid var(--rule);
}

.card-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 0;
}

.card-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-muted);
  letter-spacing: 0.005em;
}

/* legacy slots no longer present in HTML; keep CSS resilient */
.card-icon,
.card-num,
.card-kicker { display: none; }

/* ------------------------------------------------------------------------
   Form fields
   ------------------------------------------------------------------------ */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2) var(--space-3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fg-muted);
}

.field-input {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 5px 10px;
  transition: border-color 0.12s var(--easing);
}

[data-theme="dark"] .field-input { background: rgba(255, 255, 255, 0.02); }

.field-input:hover { border-color: var(--border-strong); }

.field-input:focus-within {
  border-color: var(--fg);
}

.field-input input,
.field-input select {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.field-input input::placeholder { color: var(--fg-faint); }

.field-suffix {
  font-size: 11.5px;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

input[type="date"],
input[type="time"] {
  color-scheme: light dark;
  font-family: var(--font-mono);
}

/* ------------------------------------------------------------------------
   Slider — small, native-feeling
   ------------------------------------------------------------------------ */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  outline: none;
  margin: 10px 0 4px;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1.5px solid var(--fg);
  cursor: grab;
}

.slider::-webkit-slider-thumb:active { cursor: grabbing; }

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1.5px solid var(--fg);
  cursor: grab;
}

/* ------------------------------------------------------------------------
   Textarea
   ------------------------------------------------------------------------ */
textarea {
  width: 100%;
  resize: vertical;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.12s var(--easing);
  font-family: inherit;
}

textarea:focus { border-color: var(--fg); }

/* ------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------ */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 12.5px;
  transition: background 0.12s var(--easing), transform 0.05s var(--easing);
}

.primary-btn:hover { background: var(--accent-strong); }
.primary-btn:active { transform: translateY(1px); }

.primary-btn.outline {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
}

.primary-btn.outline:hover {
  color: var(--fg);
  background: var(--bg-soft);
  border-color: var(--fg);
}

.primary-btn:disabled {
  background: var(--border-strong);
  color: var(--fg-faint);
  cursor: not-allowed;
}

/* ------------------------------------------------------------------------
   Charts
   ------------------------------------------------------------------------ */
.chart-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  color: var(--fg-muted);
}

.chart-meta .dim {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

.chart-frame {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  height: 96px;
}

[data-theme="dark"] .chart-frame { background: rgba(0, 0, 0, 0.18); }

.chart-frame svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-line { fill: none; stroke-width: 1.4; }
.chart-area { opacity: 0.18; }
.chart-grid { stroke: var(--rule); stroke-width: 1; }

/* ------------------------------------------------------------------------
   Map area
   ------------------------------------------------------------------------ */
.map-area {
  position: relative;
  background: var(--bg);
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  contain: layout paint style;
}

/* HUD — quiet hairline strip with Chinese labels */
.hud {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 6px 14px;
  border-left: 1px solid var(--rule);
  min-width: 80px;
}

.hud-stat:first-child { border-left: none; }

.hud-label {
  font-size: 11px;
  color: var(--fg-faint);
}

.hud-value {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  margin-top: 1px;
}

.hud-value.accent { color: var(--accent); }

.hud-tag,
.hud-divider { display: none; }

/* Command rail */
.command-rail {
  position: absolute;
  bottom: var(--space-3);
  right: var(--space-3);
  display: flex;
  gap: 0;
  padding: 0;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 5;
  overflow: hidden;
}

.rail-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 0;
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 12.5px;
  transition: background 0.12s var(--easing), color 0.12s var(--easing);
  border-left: 1px solid var(--rule);
}

.rail-btn:first-child { border-left: none; }

.rail-btn svg { opacity: 0.75; }

.rail-btn:hover {
  color: var(--fg);
  background: var(--bg-soft);
}

.rail-btn:hover svg { opacity: 1; }

.rail-btn.primary {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  border-left-color: rgba(0, 0, 0, 0.18);
}

.rail-btn.primary svg { opacity: 1; }
.rail-btn.primary:hover { background: var(--accent-strong); color: #fff; }

.rail-btn:disabled {
  color: var(--fg-faint);
  cursor: not-allowed;
  background: transparent;
}

.rail-btn:disabled:hover { background: transparent; color: var(--fg-faint); }

.rail-btn.primary:disabled {
  background: #c63d12;
  color: #fff;
  opacity: 0.65;
}

.rail-btn.primary:disabled:hover { background: #c63d12; color: #fff; }

/* ------------------------------------------------------------------------
   Notifications
   ------------------------------------------------------------------------ */
.notifications {
  position: absolute;
  top: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(420px, 80%);
  z-index: 10;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px 9px 12px;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  font-size: 12.5px;
  opacity: 0;
  transform: translateY(-6px);
  animation: toast-in 0.22s var(--easing) forwards;
}

.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--teal); }

.toast.leaving { animation: toast-out 0.18s var(--easing) forwards; }

@keyframes toast-in { to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

/* ------------------------------------------------------------------------
   Dialogs
   ------------------------------------------------------------------------ */
.dialog {
  border: 1px solid var(--border-strong);
  padding: 0;
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
  max-width: 460px;
  width: min(460px, 92vw);
  overscroll-behavior: contain;
}

.dialog::backdrop {
  background: rgba(20, 22, 28, 0.5);
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--space-1);
}

.dialog-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
}

.shape-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.shape-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--fg-muted);
  font-size: 12px;
  transition: color 0.12s var(--easing), border-color 0.12s var(--easing);
}

.shape-tile:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.shape-tile:active { transform: translateY(1px); }

.shape-icon { color: currentColor; }

/* Keep dialog stepper */
.keep-steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: var(--space-1) 0 var(--space-3);
  padding: 0;
}

.keep-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--fg-faint);
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
}

.keep-step:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 7px;
  left: calc(50% + 11px);
  width: calc(100% - 22px);
  height: 2px;
  background: var(--border);
}

.keep-step.is-complete:not(:last-child)::after {
  background: var(--teal);
}

.keep-step-dot {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-elev);
}

.keep-step.is-active {
  color: var(--accent);
}

.keep-step.is-active .keep-step-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.keep-step.is-complete {
  color: var(--teal);
}

.keep-step.is-complete .keep-step-dot {
  border-color: var(--teal);
  background: var(--teal);
}

.keep-step.is-error {
  color: var(--danger);
}

.keep-step.is-error .keep-step-dot {
  border-color: var(--danger);
  background: var(--danger);
}

.keep-step-label {
  overflow-wrap: anywhere;
}

.keep-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}

.keep-status-title {
  color: var(--fg);
  font-size: 13px;
  font-weight: 600;
}

.keep-status-detail {
  margin-top: 2px;
  color: var(--fg-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  margin-top: 3px;
  border: 1.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#keepStepProgress[data-status="complete"] .spinner,
#keepStepProgress[data-status="error"] .spinner {
  animation: none;
  border-color: transparent;
}

#keepStepProgress[data-status="complete"] .spinner {
  background: var(--teal);
}

#keepStepProgress[data-status="error"] .spinner {
  background: var(--danger);
}

.keep-step-details {
  display: grid;
  gap: 6px;
  margin-top: var(--space-1);
}

.keep-step-details p {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  margin: 0;
  padding: 8px 10px;
  background: var(--bg-soft);
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  color: var(--fg-faint);
  font-size: 12px;
}

.keep-step-details p[data-status="active"] {
  border-color: var(--accent);
  color: var(--accent);
}

.keep-step-details p[data-status="complete"] {
  color: var(--teal);
}

.keep-step-details p[data-status="error"] {
  border-color: var(--danger);
  color: var(--danger);
}

.keep-step-detail-text {
  min-width: 0;
  color: var(--fg-muted);
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------------
   Leaflet overrides
   ------------------------------------------------------------------------ */
.leaflet-container {
  background: var(--bg);
  font-family: inherit;
}

.leaflet-container .leaflet-tile,
.leaflet-container .leaflet-pane { backface-visibility: hidden; }

.leaflet-control-attribution {
  background: rgba(245, 243, 236, 0.92) !important;
  padding: 2px 8px !important;
  border-radius: var(--radius-xs) !important;
  font-size: 11px !important;
}

[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(28, 31, 38, 0.92) !important;
  color: var(--fg-muted) !important;
}

[data-theme="dark"] .leaflet-control-attribution a { color: var(--fg-muted) !important; }

.leaflet-bar a,
.leaflet-bar a:hover {
  background: var(--bg-elev);
  color: var(--fg);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .leaflet-bar a { background: var(--bg-elev); color: var(--fg); }

/* Route point markers — preserve the existing function & feel */
.route-point-marker { background: transparent; border: none; }

.route-point-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--brand);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: grab;
}

.route-point-dot:active { cursor: grabbing; }

.shape-handle { background: transparent; border: none; }

.shape-handle-dot {
  width: 16px;
  height: 16px;
  background: var(--brand);
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  cursor: move;
}

.shape-rotation-dot {
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2.5px solid var(--brand);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: grab;
}

.shape-rotation-dot:active { cursor: grabbing; }

/* Route control bar */
.route-control {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--bg-overlay);
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-md);
}

.route-count {
  min-width: 50px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 26px;
}

.route-tool-button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-elev);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.route-tool-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.route-tool-button:disabled { opacity: 0.35; cursor: default; }

.route-tool-button.danger:hover { border-color: var(--danger); color: var(--danger); }

/* Current location pulse */
.current-location-marker { background: transparent; border: none; }

.location-pulse {
  width: 18px;
  height: 18px;
  background: #2563ad;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(37, 99, 173, 0.7);
  animation: pulse 2s infinite;
  position: relative;
}

.location-pulse::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(37, 99, 173, 0.55); }
  50%  { box-shadow: 0 0 0 10px rgba(37, 99, 173, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 173, 0); }
}

/* ------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------ */
@media (max-width: 880px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(40vh, auto) 1fr;
  }
  .sidebar { border-right: none; border-bottom: 1px solid var(--rule); }
  .sidebar-scroll { max-height: 50vh; }
  .hud { left: var(--space-3); right: auto; }
  .command-rail { left: var(--space-3); right: var(--space-3); justify-content: stretch; bottom: var(--space-3); }
  .rail-btn { flex: 1; justify-content: center; }
  .app-bar-actions .ghost-btn span { display: none; }
}
