/* A single, compact drawer. Pages replace one another; layer choices never nest. */
.layer-panel-v2, .layer-panel-v2-backdrop { display: none; }
body.layer-panel-ui-v2 .layer-panel-v2 {
  --lp2-text: #edf1eb;
  --lp2-muted: #a5b5b1;
  --lp2-accent: #b8d2a8;
  --lp2-line: rgba(228, 238, 227, .12);
  --lp2-label-size: 12px;
  --lp2-card-height: 42px;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: 42px 64px minmax(0, 1fr) auto;
  position: fixed;
  z-index: 1200;
  /* Keep the Calques/Settings row above, and the compass/3D rail to the right. */
  --lp2-top: calc(var(--app-header-height, 58px) + 68px);
  --lp2-right: calc(72px + env(safe-area-inset-right, 0px));
  --lp2-left-clearance: max(8px, env(safe-area-inset-left, 0px));
  --lp2-width: min(340px, calc(100vw - var(--lp2-right) - var(--lp2-left-clearance)));
  top: var(--lp2-top);
  right: var(--lp2-right);
  width: var(--lp2-width);
  height: auto;
  max-height: min(660px, calc(100dvh - var(--lp2-top) - max(12px, env(safe-area-inset-bottom, 0px))));
  min-height: 0;
  overflow: hidden;
  color: var(--lp2-text);
  background: #1b2b2e;
  border: 1px solid rgba(225, 235, 225, .18);
  border-radius: 12px;
  box-shadow: 0 12px 36px #07161955, 0 2px 8px #07161933;
  font: 12px/1.35 var(--font-ui, Inter, system-ui, sans-serif);
  visibility: hidden;
  opacity: 0;
  transform: translateX(18px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 180ms ease, visibility 0s linear 180ms;
}
body.layer-panel-ui-v2 .layer-panel-v2.is-open {
  visibility: visible; opacity: 1; transform: none; pointer-events: auto;
  transition: opacity 140ms ease, transform 180ms ease;
}
body.layer-panel-ui-v2 .layer-panel-v2-backdrop {
  display: block; position: fixed; z-index: 1190;
  inset: var(--app-header-height, 58px) 0 0;
  border: 0; padding: 0; background: transparent;
  visibility: hidden; pointer-events: none;
}
body.layer-panel-ui-v2 .layer-panel-v2-backdrop.is-open { visibility: visible; background: transparent; }
.layer-panel-v2 *, .layer-panel-v2 *::before, .layer-panel-v2 *::after { box-sizing: border-box; }
.layer-panel-v2 [hidden] { display: none !important; }
.layer-panel-v2 button {
  appearance: none; -webkit-appearance: none; font: inherit; color: inherit;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.layer-panel-v2 button:focus-visible, .layer-panel-v2 input:focus-visible {
  outline: 2px solid var(--lp2-accent); outline-offset: 2px;
}
.layer-panel-v2 button:disabled { opacity: .45; cursor: default; }
.lp2-header {
  display: grid; grid-template-columns: auto auto 1fr 28px;
  gap: 6px; align-items: center; padding: 0 10px;
}
.lp2-title { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.3px; }
.lp2-active-count { color: var(--lp2-muted); font-size: 10px; white-space: nowrap; }
.lp2-reset { justify-self: end; padding: 6px 0; border: 0; background: none; font-size: 10px !important; color: var(--lp2-muted) !important; }
.lp2-close { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; }
.lp2-close:hover { background: #ffffff0c; }
.lp2-icon, .lp2-row-icon { display: inline-flex; align-items: center; justify-content: center; }
.lp2-icon, .lp2-icon svg { width: 18px; height: 18px; }
.lp2-row-icon, .lp2-row-icon svg { width: 19px; height: 19px; }
.lp2-navigation { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, 31px); gap: 1px; padding: 0 6px; border-bottom: 1px solid var(--lp2-line); }
.lp2-category { min-width: 0; padding: 0 1px; border: 0; border-bottom: 2px solid transparent; background: none; font-size: var(--lp2-label-size) !important; color: var(--lp2-muted) !important; }
.lp2-category[aria-selected="true"] { border-bottom-color: var(--lp2-accent); color: var(--lp2-accent) !important; font-weight: 650; }
.lp2-body { min-width: 0; min-height: 0; padding: 11px 10px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.lp2-page { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.lp2-action-status { margin: 0; padding: 0 12px 8px; font-size: 11px; color: #efc6a0; }
.lp2-action-status:empty { display: none; }
.lp2-basemap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.lp2-basemap-tile {
  --lp2-thumb: 26px; --lp2-card-pad: 6px; --lp2-card-gap: 6px;
  position: relative; min-width: 0; height: var(--lp2-card-height); border: 1px solid var(--lp2-line); border-radius: 7px;
  background: transparent;
}
.lp2-basemap-tile--featured { grid-column: 1 / -1; }
.lp2-basemap-tile:has(> .lp2-basemap-card.is-active) { border-color: #b8d2a860; background: #b8d2a812; }
.lp2-basemap-tile:hover { background: #ffffff06; }
.lp2-basemap-card {
  position: relative; display: grid; grid-template-columns: var(--lp2-thumb) minmax(0, 1fr);
  align-items: center; gap: var(--lp2-card-gap); width: 100%; height: 100%; min-height: 0;
  padding: 5px var(--lp2-card-pad); border: 0; border-radius: inherit; background: none; text-align: left;
}
.lp2-basemap-card__image, .lp2-basemap-card__fallback {
  width: var(--lp2-thumb); height: var(--lp2-thumb); border-radius: 4px; object-fit: cover; display: block;
  background: #536761; box-shadow: inset 0 0 0 1px #ffffff0e;
}
.lp2-basemap-card__fallback { display: grid; place-items: center; }
.lp2-basemap-card__label { min-width: 0; font-size: var(--lp2-label-size); line-height: 1.3; }
.lp2-basemap-card__check {
  position: absolute; top: calc(50% + var(--lp2-thumb) / 2 - 10px); left: calc(var(--lp2-card-pad) + var(--lp2-thumb) - 10px);
  display: none; place-items: center; width: 12px; height: 12px; border-radius: 50%;
  background: var(--lp2-accent); color: #1b2b2e; font-size: 9px; font-weight: 800;
}
.lp2-basemap-card.is-active .lp2-basemap-card__check { display: grid; }
.lp2-basemap-card.is-active .lp2-basemap-card__label { color: var(--lp2-accent); }
.lp2-basemap-tile--hybrid .lp2-basemap-card { padding-right: 34px; }
.lp2-basemap-hybrid {
  position: absolute; z-index: 1; right: 2px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 30px; height: 30px;
  margin: 0; padding: 0; border: 0; border-radius: 5px; background: none;
}
.lp2-basemap-hybrid:hover { background: #ffffff0a; }
.lp2-basemap-hybrid__switch { display: flex; align-items: center; flex: none; width: 22px; height: 13px; padding: 2px; border-radius: 8px; background: #ffffff20; }
.lp2-basemap-hybrid__switch > span { width: 9px; height: 9px; border-radius: 50%; background: #b3c1bc; }
.lp2-basemap-hybrid.is-active { color: var(--lp2-accent) !important; }
.lp2-basemap-hybrid.is-active .lp2-basemap-hybrid__switch { background: var(--lp2-accent); }
.lp2-basemap-hybrid.is-active .lp2-basemap-hybrid__switch > span { transform: translateX(9px); background: #263a32; }
.lp2-live { border-top: 1px solid var(--lp2-line); padding-top: 7px; }
.lp2-toggle-list { display: grid; }
.lp2-toggle-row {
  width: 100%; min-width: 0; height: 33px; display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 28px; gap: 7px; align-items: center;
  padding: 0 2px; text-align: left; border: 0; background: transparent;
}
.lp2-toggle-row__label { min-width: 0; font-size: var(--lp2-label-size); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lp2-row-icon { color: var(--lp2-muted); }
.lp2-switch { width: 28px; height: 17px; display: flex; align-items: center; padding: 2px; border-radius: 10px; background: #ffffff20; }
.lp2-switch > span { width: 13px; height: 13px; border-radius: 50%; background: #b3c1bc; transition: transform 120ms ease; }
.lp2-toggle-row.is-active .lp2-switch { background: var(--lp2-accent); }
.lp2-toggle-row.is-active .lp2-switch > span { background: #263a32; transform: translateX(11px); }
.lp2-toggle-row.is-active .lp2-row-icon { color: var(--lp2-accent); }
.lp2-toggle-row:hover, .lp2-choice:hover { background: #ffffff06; }
.lp2-data-main { display: flex; flex-direction: column; gap: 12px; }
.lp2-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.lp2-section-label { margin: 0; color: var(--lp2-muted); font-size: 10px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.lp2-analysis__status { color: var(--lp2-muted); font-size: 10px; max-width: 65%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp2-analysis.has-active-layer .lp2-analysis__status { color: var(--lp2-accent); }
.lp2-analysis__choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.lp2-analysis[data-analysis-group="terrain"] .lp2-analysis__choices { grid-template-columns: 1fr; }
.lp2-choice {
  min-width: 0; position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr) 10px;
  align-items: center; gap: 6px; min-height: var(--lp2-card-height); padding: 5px 6px;
  border: 1px solid var(--lp2-line); border-radius: 7px; background: transparent; text-align: left;
}
.lp2-choice__image { display: block; width: 26px; height: 26px; object-fit: cover; border-radius: 4px; }
.lp2-choice__tool-icon { display: grid; place-items: center; width: 22px; height: 22px; color: var(--lp2-accent); }
.lp2-choice__tool-icon svg { width: 21px; height: 21px; }
.lp2-analysis[data-analysis-group="tools"] .lp2-choice { grid-template-columns: 22px minmax(0, 1fr); min-height: 42px; padding-right: 7px; }
.lp2-analysis[data-analysis-group="tools"] .lp2-choice__indicator { display: none; }
.lp2-analysis[data-analysis-group="tools"] .lp2-analysis__status { display: none; }
.lp2-choice__label { font-size: var(--lp2-label-size); line-height: 1.3; }
.lp2-choice__indicator { visibility: hidden; color: var(--lp2-accent); font-size: 11px; }
.lp2-choice.is-active { border-color: #b8d2a860; background: #b8d2a812; }
.lp2-choice.is-active .lp2-choice__indicator { visibility: visible; }
.lp2-analysis[data-analysis-group="heatmap"] .lp2-choice { min-height: 32px; grid-template-columns: 18px minmax(0, 1fr) 10px; }
.lp2-analysis[data-analysis-group="heatmap"] .lp2-choice__image { width: 18px; height: 18px; object-fit: contain; filter: brightness(0) invert(1); opacity: .75; }
.lp2-analysis-controls:not(:empty), .lp2-snowmap-controls:not(:empty) { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--lp2-line); }
.lp2-analysis-controls--tools { min-width: 0; }
.lp2-webcam-controls { min-width: 0; }
.lp2-webcam-controls:empty { display: none; }
.lp2-webcam-empty { margin: 0; font-size: 11px; line-height: 1.5; color: var(--lp2-muted); }
.lp2-webcam-controls:has(> :not([hidden])) + .lp2-webcam-empty { display: none; }
.lp2-analysis-controls .analytical-legend {
  min-width: 0; width: 100%; padding: 0; border: 0; border-radius: 0;
  background: none; box-shadow: none; backdrop-filter: none; animation: none;
}
.lp2-analysis-controls .analysis-settings, .lp2-analysis-controls .sun-controls {
  min-width: 0; width: 100%; padding: 0; border: 0; border-radius: 0;
  background: none; box-shadow: none;
}
.lp2-analysis-controls .analysis-settings__header { margin-bottom: 8px; }
.lp2-analysis-controls .analysis-settings__header h3 { font-size: 11px; }
.lp2-analysis-controls .analysis-settings__ticks { font-size: 10px; }
.lp2-analysis-controls .sun-timeline {
  grid-template-columns: 41px minmax(0, 1fr) 52px; padding: 8px 0;
  background: none; border: 0; box-shadow: none; backdrop-filter: none;
}
.lp2-analysis-controls .sun-timeline__time { font-size: 15px; }
.lp2-analysis-controls .sun-controls__solar-times { font-size: 10px; line-height: 1.5; }
.lp2-analysis-controls .sun-controls__direct { gap: 8px; }
.lp2-analysis-controls .sun-controls__field { min-width: 0; }
.lp2-analysis-controls .sun-controls__field input { font-size: 11px; min-width: 0; }
.lp2-analysis-controls .sun-controls__section { margin-top: 10px; }
.lp2-analysis-controls .sun-controls__details-body { max-width: 310px; right: -4px; }
.lp2-trail-legend__summary, .lp2-info-back {
  justify-self: start; padding: 5px 0; border: 0; background: none;
  color: var(--lp2-muted) !important; font-size: 10px !important; text-align: left;
}
.lp2-data-info { display: flex; flex-direction: column; gap: 12px; }
.lp2-legend-selectors { display: flex; gap: 8px; }
.lp2-legend-selector { border: 1px solid var(--lp2-line); border-radius: 5px; padding: 6px 10px; background: none; font-size: 11px !important; }
.lp2-legend-selector[aria-pressed="true"] { color: var(--lp2-accent); border-color: #b8d2a860; }
.lp2-trail-legend__row { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 5px 0; }
.lp2-trail-legend__swatch { width: 29px; height: 19px; border-radius: 4px; flex: 0 0 auto; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: white; }
.lp2-trail-legend__text { min-width: 0; display: grid; gap: 2px; font-size: 10px; color: var(--lp2-muted); }
.lp2-trail-legend__text strong { font-size: 11px; font-weight: 550; color: var(--lp2-text); }
.lp2-trail-legend__swatch--line { height: 3px; background: var(--lp2-text); }
.lp2-trail-legend__swatch--badge { background: transparent; }
@media (hover: none) {
  .lp2-toggle-row { height: 38px; }
  .lp2-choice { min-height: 44px; }
  .lp2-close { width: 32px; height: 32px; }
}
@media (max-height: 650px) {
  .lp2-body { padding: 8px 10px; }
  .lp2-toggle-row { height: 31px; gap: 7px; grid-template-columns: 18px minmax(0, 1fr) 28px; }
  .lp2-row-icon, .lp2-row-icon svg { width: 16px; height: 16px; }
  .lp2-data-main { gap: 10px; }
  .lp2-choice { min-height: 38px; }
  .lp2-analysis-controls:not(:empty), .lp2-snowmap-controls:not(:empty) { margin-top: 10px; padding-top: 8px; }
  .lp2-section-heading { margin-bottom: 7px; }
  .lp2-trail-legend__row { min-height: 34px; }
}
@media (max-width: 767px), (hover: none) and (pointer: coarse) and (max-width: 1024px) {
  body.layer-panel-ui-v2 .layer-panel-v2 {
    --lp2-top: calc(64px + env(safe-area-inset-top, 0px));
    --lp2-right: calc(64px + env(safe-area-inset-right, 0px));
    --lp2-left-clearance: calc(64px + env(safe-area-inset-left, 0px));
  }
  /* Both the routing/library rail and the compass/3D rail stay reachable. */
  body.layer-panel-ui-v2 .layer-panel-v2-backdrop.is-open { background: transparent !important; }
}
@media (max-width: 420px) {
  body.layer-panel-ui-v2 .layer-panel-v2 { grid-template-rows: 42px 86px minmax(0, 1fr) auto; }
  .lp2-header { grid-template-columns: auto 1fr 28px; }
  .lp2-active-count { display: none; }
  .lp2-navigation { padding-inline: 4px; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, 28px); }
  .lp2-body { padding-inline: 9px; }
  .lp2-toggle-row__label { white-space: normal; line-height: 1.25; overflow: visible; text-overflow: clip; }
  .lp2-basemap-grid { grid-template-columns: 1fr; }
  .lp2-basemap-tile { --lp2-thumb: 24px; --lp2-card-pad: 5px; --lp2-card-gap: 5px; }
  .lp2-analysis__choices { grid-template-columns: 1fr; }
  .lp2-analysis[data-analysis-group="heatmap"] .lp2-analysis__choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lp2-analysis[data-analysis-group="heatmap"] .lp2-choice { grid-template-columns: minmax(0, 1fr); min-height: 38px; }
  .lp2-analysis[data-analysis-group="heatmap"] :is(.lp2-choice__image, .lp2-choice__indicator) { display: none; }
}
@media (max-width: 359px) {
  .lp2-navigation { padding-inline: 2px; }
  .lp2-header { gap: 4px; padding-inline: 8px; }
  .lp2-title { font-size: 14px; }
  .lp2-choice { gap: 4px; padding-inline: 4px; }
}
@media (max-width: 420px) and (max-height: 650px) {
  body.layer-panel-ui-v2 .layer-panel-v2 { --lp2-card-height: 34px; }
  .lp2-basemap-grid { gap: 3px; }
  .lp2-basemap-card { padding-block: 3px; }
  .lp2-page { gap: 8px; }
  .lp2-live { padding-top: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  body.layer-panel-ui-v2 .layer-panel-v2, .lp2-switch > span { transition: none; }
}
@media (max-height: 500px) and (min-width: 480px) {
  body.layer-panel-ui-v2 .layer-panel-v2 { --lp2-width: min(460px, calc(100vw - var(--lp2-right) - var(--lp2-left-clearance))); }
  .lp2-analysis[data-analysis-group="sun"] .lp2-analysis__choices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lp2-analysis[data-analysis-group="terrain"] .lp2-analysis__choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lp2-analysis-controls .sun-controls { gap: 6px; }
  .lp2-analysis-controls .sun-controls__section { margin-top: 4px; padding-top: 5px; gap: 4px; }
  .lp2-analysis[data-analysis-group="snow"] { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px 14px; }
  .lp2-analysis[data-analysis-group="snow"] > .lp2-section-heading,
  .lp2-analysis[data-analysis-group="snow"] > .lp2-analysis__choices { grid-column: 1 / -1; }
  .lp2-analysis[data-analysis-group="snow"] > .lp2-analysis-controls,
  .lp2-analysis[data-analysis-group="snow"] > .lp2-snowmap-controls { margin-top: 0; }
  #lp2SnowControls:empty { display: none; }
  .lp2-analysis:has(> #lp2SnowControls:empty) > #lp2SnowmapControls { grid-column: 1 / -1; }
}
.lp2-snowmap-controls:has(> [hidden]) { display: none; }
.snowmap-controls { display: grid; gap: 9px; }
.snowmap-controls label { display: grid; gap: 6px; font-size: 11px; color: var(--lp2-text); }
.snowmap-controls select { color: var(--lp2-text); background: #24383a; border: 1px solid var(--lp2-line); border-radius: 5px; font: inherit; height: 30px; padding: 3px 8px; }
.snowmap-controls p { margin: 0; color: var(--lp2-muted); font-size: 10px; line-height: 1.5; }
