/* ==========================================================================
 * Setup My Topo Custom Map — page styles
 * Mirrors Figma node 3873:59840 using Modus 2.0 tokens (light mode).
 * ========================================================================== */

/* The shared base.html always renders a `.site-header` for the home page
 * breadcrumb.  This page has its own `.cfg-topbar`, so hide the default
 * one rather than refactor base.html. */
body.configure-page > .site-header {
  display: none;
}

/* On desktop the page is locked to the viewport: the top bar is fixed
 * height, the map (right column) is fixed to the remaining viewport,
 * and only `.cfg-left` scrolls internally.  The browser's scroll wheel
 * is therefore free to act as Mapbox's zoom when the cursor is over
 * the map.  Mobile/tablet (<1240px) reverts to normal page scroll
 * since columns stack vertically. */
body.configure-page {
  background: #ffffff;
  color: #171c1e;
  /* Fill the *visible* viewport.  CSS viewport units all misbehave on iOS
   * (they count the browser's top/bottom chrome as usable space — worst in
   * Chrome iOS), which pushed the bottom-anchored controls behind the toolbar
   * and left the panel's "Add to Cart" unreachable.  So the authoritative
   * value is `--app-height`, set by configure_map.js from
   * `window.innerHeight` (the actually-visible height on iOS, kept fresh on
   * resize / orientation change).  The 100vh → 100svh declarations below it
   * are pre-JS fallbacks: 100svh (the smallest viewport, chrome shown) is the
   * closest static approximation, 100vh the ancient-browser floor. */
  height: 100vh;
  height: 100svh;
  height: var(--app-height, 100svh);
  /* base.css sets `body { min-height: 100vh }`.  `100vh` is the LARGE viewport
   * (as if the browser's dynamic toolbars were retracted), which on mobile is
   * TALLER than the actually-visible area — and because min-height beats
   * height when it's larger, that base rule silently forced the shell taller
   * than the screen no matter what `--app-height`/`100svh` resolved to.  The
   * extra strip then overflowed behind the browser chrome and the whole
   * document became scrollable at the viewport level, so you could see the top
   * bar OR the bottom controls but never both.  Cancel that inherited floor so
   * the `height` above (the visible viewport) actually governs. */
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: hidden;
  /* Height of the floating frosted top bar (10px padding × 2 + 40px content
   * + 1px border).  The map fills the full viewport *behind* the bar so its
   * frosted glass shows the map through it; every top-anchored overlay below
   * is shifted down by this amount so nothing hides under the bar. */
  --cfg-topbar-h: 61px;
}

body.configure-page main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ---------------------------------------------------------------------------
 * 1. Top bar — mytopo logo + breadcrumb + Shopping Cart button
 * ------------------------------------------------------------------------- */
.cfg-topbar {
  /* Float over the map (top edge, full width) so the map paints behind it
     and the frosted glass reveals the map underneath. */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: var(--cfg-topbar-h);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 30px;
  /* Same frosted-glass surface as the home page header (and the options
     panel) — translucent white + blur, hairline border, soft drop shadow
     that floats the bar above the map below. */
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.18);
}

.cfg-topbar__left {
  display: flex;
  align-items: center;
  gap: 60px;
}

.cfg-topbar__logo {
  display: flex;
  width: 73px;
  height: 40px;
  text-decoration: none;
}

.cfg-topbar__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Draft-order cart badge (top-right). Hidden unless the cart flow is on. */
.cfg-topbar__right {
  display: flex;
  align-items: center;
}

.cfg-cart-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.75);
  color: #0f172a;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.cfg-cart-link:hover {
  background: #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
}

.cfg-cart-link__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #c0392b;
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

.cfg-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #171c1e;
}

.cfg-breadcrumbs__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 4px;
  color: #171c1e;
  text-decoration: none;
  line-height: 24px;
  transition: background-color 120ms ease;
}

.cfg-breadcrumbs__item:hover,
.cfg-breadcrumbs__item:focus-visible {
  background-color: rgba(0, 0, 0, 0.05);
  outline: none;
}

.cfg-breadcrumbs__item--current {
  color: #171c1e;
  cursor: default;
}

.cfg-breadcrumbs__item--current:hover {
  background: transparent;
}

.cfg-breadcrumbs__sep {
  color: #6a6e79;
  font-size: 14px;
  user-select: none;
}

.cfg-breadcrumbs__home {
  color: #171c1e;
}

.cfg-cart-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: #f1f1f6;
  color: #171c1e;
  font-family: var(--mt-font-primary);
  font-size: 16px;
  font-weight: 600;
  line-height: 28px;
  cursor: pointer;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.cfg-cart-btn:hover,
.cfg-cart-btn:focus-visible {
  background-color: #e6e7ee;
  outline: none;
}

.cfg-cart-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(12, 119, 190, 0.4);
}

/* ---------------------------------------------------------------------------
 * 2. Page layout — full-bleed map with a floating, collapsible options panel
 *
 *    The map (`.cfg-preview`) is the base layer: it fills the entire area
 *    below the top bar edge-to-edge.  The customise options live in a
 *    frosted-glass panel (`.cfg-panel`) that floats over the LEFT edge of
 *    the map and can be collapsed out of the way.  Because both are
 *    absolutely positioned inside `.cfg-layout`, DOM order is irrelevant —
 *    z-index keeps the panel above the map.
 *
 *    `--cfg-map-offset` is the horizontal inset (in px) that JS keeps in
 *    sync with the expanded panel's rendered width.  The Mapbox camera is
 *    given a matching `padding.left`, and the CSS-centered overlays (info
 *    card, Preview CTA, WMS image/grid/frame) are shifted by this amount so
 *    the map's geographic centre stays parked in the RIGHT region of the
 *    screen — exactly where it sat in the old split layout.
 * ------------------------------------------------------------------------- */
.cfg-layout {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  width: 100%;
  --cfg-map-offset: 0px;
}

/* ---- Frosted, collapsible options panel --------------------------------- */
.cfg-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
  width: min(924px, 60%);
  display: flex;
  flex-direction: column;
  /* Panel spans the full viewport height (behind the floating top bar); pad
   * the top so its scrolling content starts just below the bar. */
  padding-top: var(--cfg-topbar-h);
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  border-right: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 4px 0 32px rgba(15, 23, 42, 0.18);
  transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  /* Shared element for the cross-document morph from the home page's
     search box (see base.css → `@view-transition`).  Confirming a
     search makes that box fly left and grow into this panel. */
  view-transition-name: vt-panel;
}

/* Collapsed — slide the whole panel (and its in-panel toggle) off the left
 * edge.  The floating `.cfg-panel-launcher` reappears to bring it back. */
.cfg-panel[data-collapsed="true"] {
  transform: translateX(-100%);
}

/* Internal scroll lives on the wrapper, not `.cfg-left`, so the toggle tab
 * can stay pinned while the form scrolls. */
.cfg-panel__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  /* Neat frosted-glass scrollbar (Firefox) — slim, translucent-white
   * thumb on a transparent track instead of the default dark bar. */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.75) transparent;
}

/* WebKit/Blink (Chrome, Safari, Edge) — match the frosted panel: a
 * rounded translucent-white thumb floated on a transparent track, with
 * a hairline inner outline so the white pill stays visible over the
 * light glass.  The transparent border + padding-box clip insets the
 * thumb so it reads as a slim floating pill rather than a full-width bar. */
.cfg-panel__scroll::-webkit-scrollbar {
  width: 10px;
}

.cfg-panel__scroll::-webkit-scrollbar-track {
  background: transparent;
}

.cfg-panel__scroll::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.7);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.14);
}

.cfg-panel__scroll::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.92);
}

/* Collapse tab — pinned to the panel's outer (right) edge so it reads as a
 * handle on the frosted sheet. */
.cfg-panel__toggle {
  position: absolute;
  top: calc(14px + var(--cfg-topbar-h));
  right: 14px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  /* Match the in-panel items (accordion headers): a flat translucent-white
     surface with a hairline border and a soft drop + inner-top highlight. */
  border: 1px solid rgba(23, 28, 30, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
  color: #171c1e;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: background-color 140ms ease;
}

.cfg-panel__toggle:hover {
  background: rgba(255, 255, 255, 0.8);
}

.cfg-panel__toggle:focus-visible {
  outline: 2px solid rgba(12, 119, 190, 0.7);
  outline-offset: 2px;
}

/* Floating launcher — opaque pill over the map, shown only while collapsed. */
.cfg-panel-launcher {
  position: absolute;
  top: calc(16px + var(--cfg-topbar-h));
  left: 16px;
  z-index: 11;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  color: #171c1e;
  font-family: var(--mt-font-primary);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.cfg-panel-launcher:hover,
.cfg-panel-launcher:focus-visible {
  background-color: #f1f1f6;
  outline: none;
}

.cfg-panel-launcher[hidden] {
  display: none;
}

.cfg-left {
  padding: 10px 20px 20px;
}

.cfg-title {
  margin: 0 0 8px;
  font-family: var(--mt-font-primary);
  font-size: 17px;
  font-weight: 700;
  line-height: 24px;
  color: #353a40;
}

/* ---------------------------------------------------------------------------
 * 2b. Accordion — two independently collapsible sections (Stock Maps +
 *     Custom Map) stacked inside the one frosted panel.  Distinct from
 *     `.cfg-panel__toggle`, which slides the WHOLE sheet off the left edge.
 *     Each header is a full-width glassy bar; its chevron flips 180° when the
 *     section is open, and the body is shown/hidden via the `hidden` attribute
 *     toggled in `configure_map.js` (section 13c).
 * ------------------------------------------------------------------------- */
.cfg-accordion {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Reserve a right gutter on the header bars so their right edge (and chevron)
 * clears the whole-panel collapse toggle pinned at top:14px/right:14px (34px
 * wide ⇒ ~48px of panel-edge footprint).  Applied to both bars so they stay
 * the same length; the bodies/form below keep full width. */
.cfg-accordion__heading {
  margin: 0 44px 0 0;
}

.cfg-accordion__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(23, 28, 30, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-family: var(--mt-font-primary);
  text-align: left;
  transition: background-color 140ms ease;
}

.cfg-accordion__header:hover {
  background: rgba(255, 255, 255, 0.8);
}

.cfg-accordion__header:focus-visible {
  outline: 2px solid rgba(12, 119, 190, 0.7);
  outline-offset: 2px;
}

.cfg-accordion__title {
  font-size: 15px;
  font-weight: 700;
  line-height: 20px;
  color: #353a40;
}

.cfg-accordion__chevron {
  flex-shrink: 0;
  color: #353a40;
  transition: transform 200ms ease;
}

/* Open section: flip the chevron to point up. */
.cfg-accordion__item[data-expanded="true"] .cfg-accordion__chevron {
  transform: rotate(180deg);
}

.cfg-accordion__body {
  padding: 0 2px;
}

.cfg-accordion__body[hidden] {
  display: none;
}

/* ---- Stock-map list ----------------------------------------------------- */
.cfg-stock__intro {
  margin: 8px 2px 12px;
  font-family: var(--mt-font-primary);
  font-size: 12px;
  line-height: 16px;
  /* Dark slate (was #6a6e79) so it stays legible when the translucent
   * panel floats over dark satellite / hybrid imagery. */
  color: #2f343a;
}

/* Horizontal strip: cards lay out in a single row and overflow scrolls
 * sideways instead of stacking vertically.  Scroll-snap gives a tidy
 * card-by-card feel; `-webkit-overflow-scrolling` keeps it momentum-smooth
 * on touch. */
.cfg-stock-list {
  list-style: none;
  margin: 0;
  padding: 4px 2px 10px;
  display: flex;
  flex-direction: row;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.cfg-stock-list[hidden] {
  display: none;
}

.cfg-stock-list::-webkit-scrollbar {
  height: 8px;
}

.cfg-stock-list::-webkit-scrollbar-thumb {
  background: rgba(23, 28, 30, 0.25);
  border-radius: 8px;
}

.cfg-stock-card {
  flex: 0 0 auto;
  width: 158px;
  scroll-snap-align: start;
}

/* Card body is now a vertical mini-card (thumbnail on top, text below) so a
 * row of them reads cleanly in the horizontal scroller. */
.cfg-stock-card__link {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 10px;
  border: 1px solid rgba(23, 28, 30, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  text-decoration: none;
  transition: background-color 140ms ease, transform 140ms ease;
}

.cfg-stock-card__link:hover {
  background: rgba(255, 255, 255, 0.85);
  transform: translateY(-1px);
}

.cfg-stock-card__link:focus-visible {
  outline: 2px solid rgba(12, 119, 190, 0.7);
  outline-offset: 2px;
}

.cfg-stock-card__thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 90px;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(12, 119, 190, 0.1);
  color: #0063a3;
  overflow: hidden;
}

.cfg-stock-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cfg-stock-card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cfg-stock-card__title {
  font-family: var(--mt-font-primary);
  font-size: 13px;
  font-weight: 600;
  line-height: 17px;
  color: #171c1e;
  /* Clamp to two lines so uneven titles keep the cards the same height. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cfg-stock-card__meta {
  font-size: 11px;
  line-height: 14px;
  color: #6a6e79;
}

/* ---- Stock-list status rows (loading / empty / error) ------------------- */
.cfg-stock__status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 2px;
  font-family: var(--mt-font-primary);
  font-size: 12px;
  line-height: 16px;
  color: #6a6e79;
}

.cfg-stock__status[hidden] {
  display: none;
}

.cfg-stock__spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid rgba(12, 119, 190, 0.25);
  border-top-color: #0063a3;
  border-radius: 50%;
  animation: cfg-stock-spin 0.7s linear infinite;
}

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

.cfg-stock__retry {
  margin-left: 4px;
  padding: 2px 8px;
  border: 1px solid rgba(12, 119, 190, 0.5);
  border-radius: 6px;
  background: transparent;
  color: #0063a3;
  font: inherit;
  cursor: pointer;
}

.cfg-stock__retry:hover {
  background: rgba(12, 119, 190, 0.1);
}

/* ---------------------------------------------------------------------------
 * 3. Form — rows of (label | control | optional hint)
 * ------------------------------------------------------------------------- */
.cfg-form {
  display: flex;
  flex-direction: column;
  gap: 30px;
  padding: 20px 0;
  margin: 0;
}

.cfg-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 10px;
}

.cfg-row__label {
  width: 167px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 16px;
  color: #171c1e;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.cfg-row__req {
  color: #da212c;
  font-weight: 700;
  line-height: 1;
}

.cfg-row__control {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  width: 370px;
  min-width: 0;
}

.cfg-row__control--group {
  flex: 1 1 auto;
  width: auto;
  max-width: 600px;
}

.cfg-row__hint {
  margin: 0;
  flex: 0 1 238px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 400;
  /* Dark slate (was #6a6e79) so hint text — e.g. "Current map center (read
   * only)" and "Special characters & and + not allowed" — stays legible when
   * the translucent panel floats over dark satellite / hybrid imagery. */
  color: #2f343a;
}

/* ---- Text input ---------------------------------------------------------- */
.cfg-input {
  width: 100%;
  height: 32px;
  padding: 4px 12px;
  background: var(--mt-input-bg);
  border: 1px solid var(--mt-input-border-default);
  border-radius: var(--mt-input-radius);
  font-family: var(--mt-font-primary);
  font-size: 13px;
  line-height: 24px;
  color: #000000;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.cfg-input::placeholder {
  color: var(--mt-input-placeholder);
}

.cfg-input:not(:placeholder-shown) {
  border-color: var(--mt-input-border-filled);
}

.cfg-input:focus {
  border: 1px solid var(--mt-input-border-focus);
  outline: 2px solid var(--mt-input-shadow-focus);
  outline-offset: 3px;
}

.cfg-input:invalid:not(:focus):not(:placeholder-shown) {
  border-color: var(--mt-input-border-invalid);
}

/* Required-title cue — set by `flagTitleRequired()` in configure_map.js when a
 * preview or add-to-cart is attempted with an empty title.  Previews silently
 * focused the title before, which on the collapsed preview menu looked like
 * "nothing happened"; this makes the reason explicit.  `!important` so the red
 * border wins over the `:focus` rule (we focus the field at the same time).
 * Cleared on the next input event. */
.cfg-input--error,
.cfg-input--error:focus {
  border-color: var(--mt-input-border-invalid) !important;
  outline-color: var(--mt-input-border-invalid);
}

.cfg-row__hint--error {
  color: var(--mt-input-border-invalid);
  font-weight: 600;
}

/* Read-only fields (e.g. the live map-centre coordinates) — visually
   distinct, non-editable, and skipped by keyboard tabbing. */
.cfg-input--readonly,
.cfg-input[readonly] {
  background: #f1f3f4;
  color: #3c4043;
  border-color: var(--mt-input-border-default);
  cursor: default;
}

.cfg-input--readonly:focus,
.cfg-input[readonly]:focus {
  border-color: var(--mt-input-border-default);
  outline: none;
}

/* ---- Select dropdown ----------------------------------------------------- */
.cfg-select-wrapper {
  position: relative;
  width: 100%;
}

.cfg-select {
  width: 100%;
  height: 32px;
  padding: 0 36px 0 12px;
  background: #f1f1f6;
  border: 0;
  border-radius: 8px;
  font-family: var(--mt-font-primary);
  font-size: 14px;
  font-weight: 600;
  line-height: 14px;
  color: #171c1e;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.cfg-select:hover {
  background-color: #e6e7ee;
}

.cfg-select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(12, 119, 190, 0.4);
}

.cfg-select-caret {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #171c1e;
}

/* ---- Segmented button group --------------------------------------------- */
.cfg-segmented {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
}

.cfg-seg {
  flex: 1 1 0;
  min-width: 0;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-right: 1px solid #939393;
  background: #f1f1f6;
  font-family: var(--mt-font-primary);
  font-size: 12px;
  font-weight: 600;
  line-height: 14px;
  color: #171c1e;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  transition: background-color 120ms ease, color 120ms ease;
}

.cfg-seg:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

.cfg-seg:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  border-right: 0;
}

.cfg-seg:hover {
  background-color: #e6e7ee;
}

.cfg-seg.is-active {
  background: #0063a3;
  color: #ffffff;
}

.cfg-seg.is-active:hover {
  background: #0c77be;
}

.cfg-seg:focus-visible {
  outline: 2px solid rgba(12, 119, 190, 0.4);
  outline-offset: 2px;
  z-index: 1;
}

/* ---- Sliding selection highlight ("thumb") -------------------------------
 * A single blue pill per group (injected by JS) that travels from the old
 * selection to the new one instead of the active button snapping blue.
 * The group clips it to its rounded corners via `overflow: hidden`. */
.cfg-seg__thumb {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  z-index: 0;
  background: #0063a3;
  pointer-events: none;
  opacity: 0;
  transform: translateX(0);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1),
    width 300ms cubic-bezier(0.4, 0, 0.2, 1),
    background-color 120ms ease;
}

/* With the travelling thumb active, buttons go transparent (so the thumb
 * shows through and slides across the full track) and the group itself
 * carries the inactive track fill. */
.cfg-segmented.has-thumb {
  background: #f1f1f6;
}

.cfg-segmented.has-thumb .cfg-seg {
  position: relative;
  z-index: 1;
  background: transparent;
}

.cfg-segmented.has-thumb .cfg-seg:hover:not(.is-active):not([disabled]) {
  background: #e6e7ee;
}

.cfg-segmented.has-thumb .cfg-seg.is-active,
.cfg-segmented.has-thumb .cfg-seg.is-active:hover {
  background: transparent;
  color: #ffffff;
}

.cfg-segmented.has-thumb .cfg-seg[disabled] {
  background: #ececf0;
}

/* Brighten the pill while hovering the active option (parity with the old
 * `.is-active:hover` blue shift). */
.cfg-segmented.has-thumb:has(.cfg-seg.is-active:hover) .cfg-seg__thumb {
  background: #0c77be;
}

/* Disabled segmented buttons stay visible (so the user can see the
 * option exists) but are clearly inactive and reveal a hover-hint
 * via their native `title` tooltip.  Click + keyboard activation
 * are blocked in the JS handler (see the `btn.disabled` guards in
 * the `.cfg-segmented` setup loop). */
.cfg-seg[disabled] {
  cursor: not-allowed;
  color: #8a8f93;
  background-color: #ececf0;
  opacity: 0.65;
}

.cfg-seg[disabled]:hover {
  background-color: #ececf0;
}

/* ---- Grid card fieldset (Lat/Lng + UTM grouped) ------------------------- */
.cfg-grid-card {
  margin: 0;
  padding: 14px 0;
  /* No added white "fog" — keep the tint minimal and instead set the card
   * apart from the panel purely with a stronger blur (panel blurs 20px,
   * this 32px) so it reads as a deeper-frosted glass pane. */
  background: rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(32px) saturate(150%);
  backdrop-filter: blur(32px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cfg-grid-card__legend {
  display: none;
}

.cfg-row--grid .cfg-seg {
  height: 40px;
  font-size: 12px;
  line-height: 28px;
  padding: 0 16px;
}

/* ---- Glassmorphism form controls ----------------------------------------
 * The options panel (and the near-transparent grid card inside it) let the
 * map show through, so the default flat light-grey controls lose their
 * edges.  Give every field in the form a "mounted glass chip" look: a
 * translucent white fill so the map shows through, a legible outline, a
 * soft drop shadow, and a faint inner top highlight.  Scoped to `.cfg-form`
 * so buttons in the top bar / preview overlays (`.cfg-btn`, `.cfg-cart-btn`)
 * keep their solid treatment. */
.cfg-form .cfg-segmented {
  box-sizing: border-box;
  border: 1px solid rgba(23, 28, 30, 0.22);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.cfg-form .cfg-seg {
  background: rgba(255, 255, 255, 0.55);
  border-right-color: rgba(23, 28, 30, 0.18);
  transition: background-color 140ms ease, color 140ms ease,
    box-shadow 140ms ease;
}

/* Hovering an unselected option greys the glass fill (matching the standard
 * segmented buttons elsewhere); the selected blue chip brightens on hover
 * via the `.is-active:hover` rule below. */
.cfg-form .cfg-seg:hover {
  background: rgba(230, 231, 238, 0.85);
}

/* Keep the selected state a solid blue chip so it clearly stands out. */
.cfg-form .cfg-seg.is-active {
  background: #0063a3;
}

.cfg-form .cfg-seg.is-active:hover {
  background: #0c77be;
}

/* Disabled options stay flat and unreactive — no glass fill, no hover. */
.cfg-form .cfg-seg[disabled],
.cfg-form .cfg-seg[disabled]:hover {
  background: rgba(236, 236, 240, 0.6);
}

/* Sliding-thumb overrides inside the panel's glass segmented controls: the
 * group keeps the translucent track fill, buttons go transparent so the blue
 * thumb travels across, and the active option's colour is the thumb itself. */
.cfg-form .cfg-segmented.has-thumb {
  background: rgba(255, 255, 255, 0.55);
}

.cfg-form .cfg-segmented.has-thumb .cfg-seg {
  background: transparent;
}

.cfg-form
  .cfg-segmented.has-thumb
  .cfg-seg:hover:not(.is-active):not([disabled]) {
  background: rgba(230, 231, 238, 0.85);
}

.cfg-form .cfg-segmented.has-thumb .cfg-seg.is-active,
.cfg-form .cfg-segmented.has-thumb .cfg-seg.is-active:hover {
  background: transparent;
}

.cfg-form .cfg-segmented.has-thumb .cfg-seg[disabled],
.cfg-form .cfg-segmented.has-thumb .cfg-seg[disabled]:hover {
  background: rgba(236, 236, 240, 0.6);
}

.cfg-form .cfg-select {
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(23, 28, 30, 0.22);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Match the GMU dropdown's hover — grey the fill rather than brightening
 * the translucent white. */
.cfg-form .cfg-select:hover {
  background: rgba(230, 231, 238, 0.85);
}

/* Text inputs get the same glassy fill + mounted shadow.  The border colour
 * is left to the base `.cfg-input` (and its focus/filled/invalid state
 * rules) so validation feedback still reads correctly. */
.cfg-form .cfg-input {
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.cfg-form .cfg-input:hover {
  background: rgba(255, 255, 255, 0.72);
}

/* ---- Checkbox + checkbox grid (overlays, hillshade) --------------------- */
.cfg-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mt-font-primary);
  font-size: 13px;
  line-height: 16px;
  color: #171c1e;
  cursor: pointer;
  user-select: none;
}

.cfg-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #0063a3;
  cursor: pointer;
}

.cfg-check input[type="checkbox"]:disabled {
  cursor: not-allowed;
}

.cfg-check input[type="checkbox"]:disabled + span {
  /* Darker muted slate (was #a3a6b1) — keeps the disabled cue while staying
   * readable over dark satellite / hybrid imagery, e.g. "Add hillshade to
   * topo base" when the option is disabled. */
  color: #4b5159;
}

/* ?base_bridge=4 — overlay has no data inside the red print frame (set by
 * the PostGIS availability check in configure_map.js).  The checkbox is
 * already disabled (greying its label via the rule above); this dims the
 * whole row and flips the cursor so the "not offered here" cue is obvious. */
.cfg-check--unavailable {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ?base_bridge=4 — dismissable error toast, bottom-right of the viewport.
 * Surfaced when the PostGIS overlay-availability check can't be answered
 * (spatial DB / overlay data unreachable), in which case the overlay
 * checkboxes are disabled (fail-closed).  A <dialog> (the cart modal) renders
 * in the top layer above this, which is intended. */
.cfg-toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.cfg-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fde2e4;
  color: #8b0000;
  border: 1px solid #f5c2c7;
  border-radius: 6px;
  padding: 12px 12px 12px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  line-height: 1.45;
  animation: cfg-toast-in 150ms ease-out;
}

.cfg-toast__icon {
  font-weight: 700;
  flex: 0 0 auto;
}

.cfg-toast__body {
  flex: 1 1 auto;
}

.cfg-toast__title {
  font-weight: 700;
  margin-bottom: 2px;
}

.cfg-toast__close {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.7;
}

.cfg-toast__close:hover {
  opacity: 1;
}

/* Warning variant — yellow, used for transient "you can't do that right now"
 * nudges (e.g. clicking Preview / Add to Cart while in move-the-print-box
 * edit mode).  Auto-dismisses after a few seconds (see `showToast` /
 * `_armToastAutoDismiss` in configure_map.js) but keeps the × so it can be
 * closed early. */
.cfg-toast--warning {
  background: #fff6da;
  color: #7a5b00;
  border-color: #f0dd8a;
}

/* Preview + Add to Cart are locked while the print box is being moved (edit
 * mode) — greyed out for an obvious "disabled" cue, but pointer-events stay
 * on so a click still reaches the handler and surfaces the warning toast
 * explaining why (see `cfg-is-editing` toggling in configure_map.js). */
.cfg-is-editing #cfg-preview-cta,
.cfg-is-editing #cfg-submit {
  opacity: 0.5;
  cursor: not-allowed;
}

@keyframes cfg-toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cfg-check-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 24px;
  row-gap: 10px;
  width: 100%;
}

.cfg-row--align-top {
  align-items: flex-start;
}

.cfg-row--align-top .cfg-row__label {
  padding-top: 2px;
}

.cfg-row__sublabel {
  display: inline-block;
  margin-left: 4px;
  font-weight: 400;
  font-size: 11px;
  color: #6a6e79;
}

.cfg-row[hidden] {
  display: none;
}

/* ---- Action row (Cancel | Add to Cart) ---------------------------------- */
.cfg-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 20px;
  padding-top: 20px;
  border-top: 1px solid #7b7b7b;
}

.cfg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  font-family: var(--mt-font-primary);
  font-size: 16px;
  font-weight: 600;
  line-height: 28px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.cfg-btn--secondary {
  background: #f1f1f6;
  color: #171c1e;
  min-width: 107px;
}

.cfg-btn--secondary:hover,
.cfg-btn--secondary:focus-visible {
  background-color: #e6e7ee;
  outline: none;
}

.cfg-btn--primary {
  background: #0063a3;
  color: #ffffff;
}

.cfg-btn--primary:hover,
.cfg-btn--primary:focus-visible {
  background-color: #0c77be;
  outline: none;
}

.cfg-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(12, 119, 190, 0.4);
}

.cfg-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------------------
 * 4. Map preview pane — fills the right column edge-to-edge.
 *    Info overlay, USGS toggle, and Preview button are absolutely
 *    positioned over the map so the canvas stays uninterrupted.
 * ------------------------------------------------------------------------- */
.cfg-preview {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #d8d6cd;
  overflow: hidden;
}

.cfg-preview__map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The WMS preview image, full-bleed overlay shown only when the
 * view-mode toggle is active.  The WMS request is at the actual
 * paper aspect + the user's literal print scale (see
 * `configure_map.js` `wmsGeometry`), so this image IS the print —
 * `object-fit: contain` letterboxes it into the pane without
 * cropping. */
.cfg-preview__wms {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  /* Inset the WMS image's left edge by the panel offset so its letterboxed
   * (`object-fit: contain`) centre lands in the same right-side region the
   * Mapbox camera centre uses. */
  left: var(--cfg-map-offset, 0px);
  width: auto;
  height: auto;
  object-fit: contain;
  background: #2a2a2a;
  display: block;
  z-index: 1;
}

.cfg-preview__wms-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  padding: 8px 14px;
  background: rgba(33, 33, 33, 0.85);
  color: #fff;
  border-radius: 4px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  font-family: var(--mt-font-primary);
  font-size: 13px;
  color: #171c1e;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.cfg-preview__wms-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #cbcdd6;
  border-top-color: #0063a3;
  border-radius: 50%;
  animation: cfgSpin 800ms linear infinite;
}

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

/* Mapbox built-in control containers (NavigationControl, attribution,
 * scale, plus any custom `addControl` widgets like RecenterControl)
 * live inside the map element and get NO explicit z-index from
 * Mapbox.  That means they stack at `auto` — i.e. UNDER any sibling
 * with an explicit z-index ≥ 1.
 *
 * The print-frame `.cfg-preview__wms-frame` uses an outset
 * `box-shadow: 0 0 0 9999px rgba(20,20,20,.25)` at z-index 2 to
 * paint the "dark mask outside the red box" effect.  Without
 * intervention, that mask draws OVER the Mapbox controls, dimming
 * them and (visually) hiding them whenever the red box is on
 * screen.
 *
 * Lifting all four corner containers to z-index 3 puts the buttons
 * on the same plane as our custom toggles (usgs / view / fullscreen,
 * all z-index 3) — above the mask, but still below the loupe (z:4)
 * and the WMS loading spinner (z:5).  The map's *terrain* underneath
 * stays correctly dimmed by the mask; only the controls poke
 * through. */
.cfg-preview__map .mapboxgl-ctrl-top-right,
.cfg-preview__map .mapboxgl-ctrl-top-left,
.cfg-preview__map .mapboxgl-ctrl-bottom-right,
.cfg-preview__map .mapboxgl-ctrl-bottom-left {
  z-index: 3;
}

/* Push the native top control groups (zoom / recenter stack) clear of the
 * floating top bar that now overlaps the top of the map. */
.cfg-preview__map .mapboxgl-ctrl-top-right,
.cfg-preview__map .mapboxgl-ctrl-top-left {
  margin-top: var(--cfg-topbar-h);
}

/* USGS quad grid toggle — sits to the LEFT of the Mapbox NavigationControl
 * (which Mapbox parks at top:10/right:10 with 32px width).  We use
 * right: 52px (10 edge + 32 nav + 10 gap) so the toggle reads as part of
 * the same control cluster. */
/* Recenter button inside the Mapbox top-right control stack.
 * Mapbox's default `.mapboxgl-ctrl-icon` rule paints an icon via
 * `background-image` (e.g. for the zoom-in `+`); our button uses an
 * inline SVG instead so the icon scales with `currentColor` and we
 * don't need a separate sprite.  These rules size the SVG to fill
 * the 29 × 29 px Mapbox button area and suppress the default
 * background so the SVG isn't drawn behind a Mapbox `+` graphic. */
.cfg-preview__recenter-btn {
  background-image: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cfg-preview__recenter-btn svg {
  width: 18px;
  height: 18px;
}

.cfg-preview__usgs-toggle {
  position: absolute;
  top: calc(10px + var(--cfg-topbar-h));
  right: 52px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: #ffffff;
  color: #171c1e;
  font-family: var(--mt-font-primary);
  font-size: 12px;
  font-weight: 600;
  line-height: 14px;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  transition: background-color 120ms ease, color 120ms ease;
}

.cfg-preview__usgs-toggle[aria-pressed="true"] {
  background: #0063a3;
  color: #ffffff;
}

.cfg-preview__usgs-toggle:hover {
  background-color: #f1f1f6;
}

.cfg-preview__usgs-toggle[aria-pressed="true"]:hover {
  background-color: #0c77be;
}

.cfg-preview__usgs-label {
  display: inline-block;
}

/* Move-the-print-box toggle (pencil) — first control BELOW the entire
 * Mapbox top-right stack (the WMS view-mode toggle that used to sit
 * here was removed).  Matches the 32 px square footprint of the native
 * Mapbox control buttons (mapbox-gl.css `.mapboxgl-ctrl-group button`
 * is 32 × 32 in v3) so the right-edge stack reads as one uniform group.
 * Stack height in Mapbox mode (compass button was removed when we
 * locked rotation off — the nav stack is now two buttons, zoom-in and
 * zoom-out, not three):
 *   leading margin                           = 10 px
 *   NavigationControl (2 × 32 px)            = 64 px
 *   inter-group margin                       = 10 px
 *   RecenterControl (1 × 32 px)              = 32 px
 *   ─────────────────────────────────────────────────
 *   total                                    ≈ 116 px → start at 126 px
 *                                              (keeps the same 10 px gap)
 * Sits directly ABOVE the fullscreen button.  Same square icon-button
 * treatment as its neighbours; `aria-pressed="true"` (blue) signals
 * that edit mode is active. */
.cfg-preview__edit-toggle {
  position: absolute;
  top: calc(126px + var(--cfg-topbar-h));
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #ffffff;
  color: #171c1e;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.cfg-preview__edit-toggle[aria-pressed="true"] {
  background: #0063a3;
  color: #ffffff;
}

.cfg-preview__edit-toggle:hover {
  background-color: #f1f1f6;
}

.cfg-preview__edit-toggle[aria-pressed="true"]:hover {
  background-color: #0c77be;
}

/* Edit-mode toolbar — floats at the top-centre of the preview while
 * the pencil toggle is active.  Holds the contextual hint plus the
 * Revert / Save actions. */
.cfg-preview__edit-bar {
  position: absolute;
  top: calc(15px + var(--cfg-topbar-h));
  /* Centre within the right-side map region (to the right of the panel)
   * rather than the full viewport — mirrors the Print-Preview CTA so it
   * stays in the visible map area whether the panel is collapsed
   * (offset 0 → true centre) or expanded (offset = panel width). */
  left: calc(50% + var(--cfg-map-offset, 0px) / 2);
  transform: translateX(-50%);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 20px);
  padding: 6px 8px 6px 14px;
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  transition: left 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

.cfg-preview__edit-bar[hidden] {
  display: none !important;
}

.cfg-preview__edit-hint {
  font-size: 12px;
  line-height: 16px;
  color: #3c4043;
  max-width: 360px;
}

.cfg-preview__edit-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid #c4c7c5;
  border-radius: 4px;
  background: #ffffff;
  color: #171c1e;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.cfg-preview__edit-btn:hover {
  background-color: #f1f1f6;
}

.cfg-preview__edit-btn--primary {
  border-color: #0063a3;
  background: #0063a3;
  color: #ffffff;
}

.cfg-preview__edit-btn--primary:hover {
  background-color: #0c77be;
}

/* Fullscreen toggle — sits directly below the move/pencil toggle
 * (edit-toggle at top:126, 32 px tall + 10 px gap = top:168 px) so
 * the right-edge control stack reads as a single tool group: Mapbox
 * nav, recenter, move-box, fullscreen.  Same 32 px square treatment as
 * its neighbours for consistency; the `aria-pressed="true"` blue swap
 * doubles as the "currently in fullscreen" indicator when the user is
 * viewing the pane expanded. */
.cfg-preview__fullscreen-toggle {
  position: absolute;
  top: calc(168px + var(--cfg-topbar-h));
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #ffffff;
  color: #171c1e;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  transition: background-color 120ms ease, color 120ms ease;
}

.cfg-preview__fullscreen-toggle[aria-pressed="true"] {
  background: #0063a3;
  color: #ffffff;
}

.cfg-preview__fullscreen-toggle:hover {
  background-color: #f1f1f6;
}

.cfg-preview__fullscreen-toggle[aria-pressed="true"]:hover {
  background-color: #0c77be;
}

/* The single SVG inside the fullscreen button.  The JS rewrites the
 * inner <path>'s `d` attribute on `fullscreenchange` to morph the
 * icon between "expand" arrows (default) and "collapse" arrows (in
 * fullscreen) — no display:none / hidden swaps needed. */
.cfg-preview__fs-icon {
  display: block;
}

.cfg-preview__fs-icon path {
  transition: d 150ms ease;
}

/* ------------------------------------------------------------------ */
/* Hover loupe                                                         */
/* ------------------------------------------------------------------ */

/* Small circular secondary Mapbox map pinned to the bottom-right of
 * the preview pane.  Re-centers on the lng/lat under the cursor at
 * main-zoom + 3.  `pointer-events: none` is critical — without it the
 * loupe would swallow mousemove/click events meant for the main map.
 *
 * Stacking: z-index sits below the fullscreen toggle (z:5) and
 * info-card (z:3 ish), so the toggle remains clickable when the
 * cursor enters the bottom-right corner. */
.cfg-preview__loupe {
  position: absolute;
  bottom: 80px;
  right: 20px;
  z-index: 4;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  pointer-events: none;
  background: #d8d6cd;
  opacity: 0;
  transition: opacity 150ms ease;
}

.cfg-preview__loupe.is-active {
  opacity: 1;
}

/* The Mapbox map injected inside the loupe needs to fill the circle —
 * Mapbox's container defaults to 100% width/height but only when its
 * parent has explicit dimensions, which we provide above. */
.cfg-preview__loupe .mapboxgl-map,
.cfg-preview__loupe .mapboxgl-canvas-container,
.cfg-preview__loupe .mapboxgl-canvas {
  width: 100% !important;
  height: 100% !important;
}

/* WMS-mode loupe — same circle wrapper, but content comes from a
 * CSS background-image (the WMS blob URL the main `<img>` is
 * showing), sized larger than the loupe and offset by JS so the
 * cursor's point lands dead-center.  No child elements; JS only
 * twiddles `backgroundImage`, `backgroundSize`, and
 * `backgroundPosition`.
 *
 * `background-color` matches the WMS pane's letterbox color so any
 * out-of-bounds positioning (cursor near image edge) blends in
 * instead of showing a flash of white. */
.cfg-preview__loupe--wms {
  background-color: #2a2a2a;
  background-repeat: no-repeat;
}

/* Crosshair marking the exact point being magnified — sits dead-
 * center over the secondary map.  Small red ring, no fill, so it
 * reads against any base map color without obscuring the imagery. */
.cfg-preview__loupe::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(193, 20, 20, 0.9);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
  z-index: 2;
}

/* Touch-only devices have no hover state — hide the loupe entirely.
 * Showing a never-triggered widget would just waste pane real
 * estate and confuse the user. */
@media (hover: none) {
  .cfg-preview__loupe {
    display: none;
  }
}

/* When the preview pane is in browser fullscreen mode, the user
 * agent overrides our flex sizing and paints a default black
 * background — paint our own pane background so the map content
 * stays visually connected to the non-fullscreen state instead of
 * being framed by a black border while tiles load. */
.cfg-preview:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #d8d6cd;
}

/* Safari + older WebKit still need the prefixed pseudo-class.  Keep
 * the rule body identical to `:fullscreen` so the visual outcome is
 * the same regardless of which API path the browser took. */
.cfg-preview:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #d8d6cd;
}

/* Fullscreen is requested on `.cfg-layout` (not `.cfg-preview`) so the
 * frosted options panel stays usable when expanded.  The map is
 * `position:absolute; inset:0` inside the layout, so it fills the screen
 * for free; we only need to paint the pane background. */
.cfg-layout:fullscreen,
.cfg-layout:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #d8d6cd;
}

/* Both .cfg-preview__wms and .cfg-preview__wms-loading set explicit
 * display values (block / inline-flex), which overrides the browser's
 * default [hidden] {display:none} — so toggling the `hidden` attribute
 * from JS would have no effect without this rule. */
.cfg-preview__wms[hidden],
.cfg-preview__wms-loading[hidden],
.cfg-preview__wms-frame[hidden],
.cfg-preview__wms-message[hidden],
.cfg-preview__grid-overlay[hidden] {
  display: none !important;
}

/* Grid overlay canvas — centered over the WMS image's rendered area
 * (same letterbox math the print-frame uses).  JS sets explicit
 * width/height and the canvas drawing buffer accounts for
 * `devicePixelRatio` so 1-px grid lines stay sharp on Retina
 * displays.  Pointer-events disabled so it never blocks the loupe
 * hover or any future click handlers on the underlying image. */
.cfg-preview__grid-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
  display: block;
}

/* Print-frame overlay (cf11 "mapbox.gif" analogue, `map.cfm` 1057-1059).
 * Sized by JS as inline width/height % of the WMS preview pane — width
 * tracks the user's printscale so visual feedback is preserved even
 * when the underlying WMS image stays cached. */
.cfg-preview__wms-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px dashed #c11414;
  background: rgba(193, 20, 20, 0.06);
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 0 0 9999px rgba(20, 20, 20, 0.25);
  transition: width 150ms ease, height 150ms ease;
}

/* Edit mode — the print box is highlighted to show it can be grabbed.
   It deliberately stays `pointer-events: none` (inherited from the base
   rule) so scroll-zoom and drag-pan over the box area are NOT blocked;
   the grab is detected by hit-testing map clicks against the box bounds
   in JS instead. */
.cfg-preview__wms-frame.is-editable {
  border-color: #0063a3;
  background: rgba(0, 99, 163, 0.08);
}

/* Grabbed/moveable state — solid highlighted border + move cursor so it
 * visibly reads as draggable.  Corner handles (the small squares) are
 * drawn with layered radial-gradients so no extra DOM nodes are needed. */
.cfg-preview__wms-frame.is-grabbed {
  /* A single blue boundary only — no second (white) outline, which made
     it hard to align the box against map features. */
  border: 2px solid #0063a3;
  background: rgba(0, 99, 163, 0.12);
  /* Let clicks fall through to the map so clicking anywhere recenters
     the box on that point (click-to-place); panning still slides the
     map under the pinned box. */
  pointer-events: none;
}

.cfg-preview__wms-frame.is-grabbed::after {
  content: "";
  position: absolute;
  inset: -5px;
  pointer-events: none;
  background-image:
    radial-gradient(#0063a3 45%, transparent 47%),
    radial-gradient(#0063a3 45%, transparent 47%),
    radial-gradient(#0063a3 45%, transparent 47%),
    radial-gradient(#0063a3 45%, transparent 47%);
  background-repeat: no-repeat;
  background-size: 10px 10px;
  background-position: left top, right top, left bottom, right bottom;
}

.cfg-preview__wms-frame-label {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: #c11414;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* Inline "no coverage" / error message — sits at the top of the
 * preview pane in WMS mode while the upstream's actual response
 * (often a "MyTopo Image Error NNNNN" tile) is still rendered
 * underneath, so the user sees both signals at once.  Colour
 * scheme deliberately matches `.coord-field__error` on the home
 * page (`static/findamap/css/home.css`) for a consistent error
 * vocabulary across the app. */
.cfg-preview__wms-message {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  max-width: 80%;
  padding: 8px 14px;
  background: #fde2e4;
  color: #8b0000;
  border: 1px solid #f5c2c7;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 3px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.cfg-preview__wms-message::before {
  content: "\26A0";
  margin-right: 6px;
  font-size: 12px;
}

.cfg-preview__info {
  position: absolute;
  top: calc(15px + var(--cfg-topbar-h));
  left: calc(15px + var(--cfg-map-offset, 0px));
  z-index: 2;
  transition: top 320ms cubic-bezier(0.4, 0, 0.2, 1),
    left 320ms cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 230px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(23, 28, 30, 0.15);
  border-radius: 4px;
  font-family: var(--mt-font-primary);
  font-size: 12px;
  line-height: 1.5;
  color: #171c1e;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Collapse toggle for the Map-details card.  Hidden on desktop (the card is
 * always expanded there); revealed only in the mobile portrait media query,
 * where it shows/hides the info rows via `data-collapsed` on the card. */
.cfg-preview__info-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #353a40;
  font-family: var(--mt-font-primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
}

.cfg-preview__info-chevron {
  flex-shrink: 0;
  transition: transform 200ms ease;
}

/* Collapsed → chevron points right and the rows are hidden (rule lives in the
 * portrait media query so the desktop card is never collapsible). */
.cfg-preview__info[data-collapsed="true"] .cfg-preview__info-chevron {
  transform: rotate(-90deg);
}

/* When the options panel is collapsed the launcher pill (`top:16px;
 * left:16px`) occupies the top-left corner where the Map Details card
 * normally sits.  The launcher precedes `.cfg-preview` in the DOM, so a
 * general-sibling selector lets us drop the info card just below the pill
 * (collapsed → `--cfg-map-offset` is 0, so without this they'd overlap). */
.cfg-panel-launcher:not([hidden]) ~ .cfg-preview .cfg-preview__info {
  top: calc(64px + var(--cfg-topbar-h));
  left: 16px;
}

.cfg-preview__info-row {
  display: flex;
  gap: 6px;
  font-weight: 400;
}

.cfg-preview__info-label {
  font-weight: 600;
  color: #353a40;
}

/* Print-Preview CTA: a 220-px-wide button anchored bottom-center of
 * the preview pane.  Wrapped in `.cfg-preview__cta-group` so the
 * group owns the absolute positioning; the CTA itself can stay
 * relatively positioned and act as the anchor for two satellite
 * buttons that fan out radially when the menu opens.  Kept the
 * original (cfg-preview__cta-only) sizing/box-shadow rules so the
 * button looks identical in its idle state. */
.cfg-preview__cta-group {
  position: absolute;
  bottom: 20px;
  /* Centre within the right-side map region (to the right of the panel)
   * rather than the full viewport, matching the offset map centre. */
  left: calc(50% + var(--cfg-map-offset, 0px) / 2);
  transform: translateX(-50%);
  z-index: 2;
  width: 220px;
  transition: left 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

.cfg-preview__cta {
  position: relative;
  width: 100%;
  z-index: 2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Three label-states inside a single CTA element.  Toggled by the
 * JS state machine via `data-state` on the button.  Using sibling
 * spans (instead of swapping innerHTML) keeps the button width
 * stable across state changes — width is driven by the widest
 * label ("Rendering…"), so the radial-fan satellites and the CTA
 * stay aligned without the layout jumping mid-animation. */
.cfg-preview__cta-state {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.cfg-preview__cta[data-state="idle"] .cfg-preview__cta-state--idle,
.cfg-preview__cta[data-state="cancel"] .cfg-preview__cta-state--cancel,
.cfg-preview__cta[data-state="processing"]
  .cfg-preview__cta-state--processing {
  display: inline-flex;
}

/* "Cancel" — destructive red so it reads clearly against the
 * default primary blue.  Matches the inline-error palette used
 * elsewhere on this page (see `.cfg-preview__wms-message`
 * variants). */
.cfg-preview__cta[data-state="cancel"] {
  background: #b8262a;
}
.cfg-preview__cta[data-state="cancel"]:hover,
.cfg-preview__cta[data-state="cancel"]:focus-visible {
  background-color: #cc2c30;
}

/* "Processing" — neutral grey.  Cursor stays as a pointer because
 * clicking the button while in this state focuses the active
 * preview popup window (the only sensible action while a render
 * is in flight). */
.cfg-preview__cta[data-state="processing"] {
  background: #5a6772;
  cursor: pointer;
}
.cfg-preview__cta[data-state="processing"]:hover,
.cfg-preview__cta[data-state="processing"]:focus-visible {
  background-color: #69757f;
}

.cfg-preview__cta-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: cfgSpin 800ms linear infinite;
}

/* Satellite buttons — fan out radially from the CTA when the
 * group is in `data-state="menu"`.  Both share absolute placement
 * over the CTA (so collapsed-state they're invisibly stacked
 * underneath it) and animate via `transform` + `opacity`.
 *
 * Animation choice — `cubic-bezier(0.34, 1.56, 0.64, 1)` is a
 * gentle overshoot ("ease-out-back") so the buttons feel like
 * they're springing out of the CTA instead of sliding linearly.
 * The Quick satellite is delayed 60 ms behind Full to give a
 * cascading fan-out feel; on close they reverse with no delay so
 * the menu collapses crisply. */
.cfg-preview__cta-satellite {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 1;
  opacity: 0;
  transform: translate(0, 0) scale(0.6);
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition:
    transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 220ms ease-out;
}

.cfg-preview__cta-group[data-state="menu"] .cfg-preview__cta-satellite {
  opacity: 1;
  pointer-events: auto;
}

.cfg-preview__cta-group[data-state="menu"]
  .cfg-preview__cta-satellite--full {
  transform: translate(-75%, -130%) scale(1);
}

.cfg-preview__cta-group[data-state="menu"]
  .cfg-preview__cta-satellite--quick {
  transform: translate(75%, -130%) scale(1);
  transition-delay: 60ms;
}

/* When the group is NOT open the satellites must be unreachable
 * by tab/keyboard too — the JS sets tabindex=-1 in markup, this
 * just belts-and-suspenders the visibility for screen readers
 * and prevents focus-ring leaks during the collapse animation. */
.cfg-preview__cta-group[data-state="idle"] .cfg-preview__cta-satellite,
.cfg-preview__cta-group[data-state="processing"]
  .cfg-preview__cta-satellite {
  visibility: hidden;
  transition:
    transform 240ms ease-in,
    opacity 180ms ease-in,
    visibility 0s linear 240ms;
}

/* ---------------------------------------------------------------------------
 * 5. Responsive — the map stays full-bleed at every breakpoint; only the
 *    floating options panel adapts.  On tablet it narrows; on phones it
 *    becomes a near-full-width sheet (so the map centre is no longer
 *    offset — JS sets `--cfg-map-offset: 0` whenever the panel would leave
 *    too little map showing).  The page stays viewport-locked so the map
 *    keeps the scroll wheel for zoom and the panel scrolls internally.
 * ------------------------------------------------------------------------- */
@media (max-width: 1240px) {
  .cfg-panel {
    width: min(924px, 90vw);
  }
}

@media (max-width: 800px) {
  .cfg-topbar {
    padding: 10px 16px;
    gap: 12px;
  }

  .cfg-topbar__left {
    gap: 16px;
  }

  .cfg-cart-btn span {
    display: none;
  }

  .cfg-panel {
    width: 100%;
  }

  .cfg-left {
    padding: 10px 16px 20px;
  }

  .cfg-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-left: 0;
  }

  .cfg-row__label {
    width: auto;
  }

  .cfg-row__control {
    width: 100%;
  }

  .cfg-row__hint {
    flex: 0 0 auto;
  }

  .cfg-preview__usgs-toggle {
    font-size: 13px;
    height: 32px;
    padding: 0 10px;
  }
}

/* ---------------------------------------------------------------------------
 * 5b. Portrait split workflow (phones AND portrait tablets)
 *
 *    Used instead of the desktop "frosted panel floats over a full-bleed map"
 *    model whenever the options panel would cover MORE THAN HALF the screen —
 *    i.e. the side-by-side split would leave the map with less room than the
 *    panel.  The panel is `min(924px, 60%)` (widened to 90vw / 100% at smaller
 *    widths), so it exceeds 50% of the viewport for every portrait width below
 *    ~1848px (the point where the 924px cap finally equals 50%).  Hence the
 *    `max-width: 1847px` ceiling, which pulls in portrait tablets too:
 *
 *      - PORTRAIT  — vertical split: the interactive map takes the TOP half
 *        and the options panel is docked as a sheet across the BOTTOM half.
 *        Collapsing slides the sheet off the bottom edge and hands the full
 *        height back to the map (the floating launcher pulls it back up).
 *
 *      - LANDSCAPE — desktop-style side-by-side: the options panel is pinned
 *        to the LEFT half and the map fills the right half.  `--cfg-map-offset`
 *        (set by JS to the panel's rendered width) keeps the map centre and
 *        the CSS-centred overlays parked in the right region.  Collapsing
 *        still slides the panel off the left edge (inherited behaviour).
 *
 *    These blocks intentionally come AFTER the `max-width: 800px` rules above
 *    so the orientation-specific overrides win at equal specificity.
 * ------------------------------------------------------------------------- */
@media (orientation: portrait) and (max-width: 1847px) {
  /* The map stays FULL-BLEED behind the nav bar and the bottom sheet (it is
   * NOT pushed below the bar).  This is what restores the frosted-glass look
   * to the top bar / panel / launcher — they blur real map pixels instead of a
   * blank background — and removes the "extra space below the nav bar" that
   * came from the map being inset by the bar height while the controls inside
   * were ALSO offset by it.  So `.cfg-preview` is left at its base `inset: 0`. */

  /* Options panel: frosted bottom sheet floating over the lower half of the
   * map (keeps the base `backdrop-filter` blur, just re-docked to the bottom). */
  .cfg-panel {
    top: auto;
    bottom: 0;
    height: 50%;
    width: 100%;
    padding-top: 0;
    border-right: none;
    border-top: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 32px rgba(15, 23, 42, 0.18);
  }

  /* Collapsed: slide the sheet DOWN off the bottom edge (not left). */
  .cfg-panel[data-collapsed="true"] {
    transform: translateY(100%);
  }

  /* While the sheet is sliding (class toggled in setPanelCollapsed for the
   * duration of the transform transition) drop the live backdrop blur.  A 20px
   * backdrop-filter is only cheap over STATIC pixels; during open/close the map
   * behind the sheet is simultaneously panning (the camera easeTo) so the blur
   * is re-sampled every frame — that re-sampling is what makes the slide feel
   * jumpy.  The frosted glass is restored the instant motion settles. */
  .cfg-panel.cfg-panel--sliding {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: rgba(255, 255, 255, 0.82);
  }

  /* Pin the collapse tab to the sheet's own top edge; rotate its chevron to
   * point DOWN (collapse = dismiss the sheet downward). */
  .cfg-panel__toggle {
    top: 10px;
  }
  .cfg-panel__toggle-icon {
    transform: rotate(-90deg);
  }

  /* Map Options launcher: frosted pill (was opaque white) centred at the very
   * bottom, matching the top bar's frosted-glass surface. */
  .cfg-panel-launcher {
    top: auto;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.55);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.45);
    color: #171c1e;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.18);
    /* Glide up + fade as the sheet rises (it "becomes" the menu), and settle
     * back into place as the sheet closes. */
    transition:
      transform 320ms cubic-bezier(0.4, 0, 0.2, 1),
      opacity 200ms ease,
      background-color 120ms ease,
      box-shadow 120ms ease;
  }
  body.cfg-panel-open .cfg-panel-launcher {
    transform: translateX(-50%) translateY(-14px);
    opacity: 0;
    pointer-events: none;
  }

  /* Preview CTA: sit just ABOVE the Map Options launcher when the sheet is
   * collapsed (so the two no longer overlap)... */
  .cfg-preview__cta-group {
    bottom: 72px;
    /* Animate the Preview CTA in step with the sheet instead of an abrupt
     * display:none toggle (the instant vanish is what made OPENING feel jumpy;
     * closing only looked fine because the descending sheet masked the pop).
     * Open  → slide DOWN and fade out of view.
     * Close → rise from the bottom back into place. */
    transition:
      transform 320ms cubic-bezier(0.4, 0, 0.2, 1),
      opacity 200ms ease,
      left 320ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  body.cfg-panel-open .cfg-preview__cta-group {
    transform: translateX(-50%) translateY(180px);
    opacity: 0;
    pointer-events: none;
  }

  /* USGS Quad Grid: top-RIGHT, just below the nav bar, ABOVE the Mapbox
   * action-button stack (its base `top` already places it below the bar
   * because the map is full-bleed; only the right edge changes). */
  .cfg-preview__usgs-toggle {
    right: 10px;
  }

  /* Push the Mapbox native control group (zoom + recenter) DOWN so it clears
   * the USGS pill sitting above it. */
  .cfg-preview__map .mapboxgl-ctrl-top-right {
    margin-top: calc(50px + var(--cfg-topbar-h));
  }

  /* Continue the right-edge stack below the Mapbox zoom + recenter group
   * (pushed down 50 px above to clear the USGS pill, so its 32 px buttons
   * bottom out ~166 px down): move/edit → fullscreen, same 32 + 10 rhythm. */
  .cfg-preview__edit-toggle {
    top: calc(176px + var(--cfg-topbar-h));
  }
  .cfg-preview__fullscreen-toggle {
    top: calc(218px + var(--cfg-topbar-h));
  }

  /* Map-details card: keep it top-left and full size, but reveal its collapse
   * toggle and hide the rows when collapsed.  Override the launcher-sibling
   * push-down (that rule assumes a top-left launcher; here the launcher is at
   * the bottom) so the card stays just below the nav bar. */
  .cfg-panel-launcher:not([hidden]) ~ .cfg-preview .cfg-preview__info {
    top: calc(10px + var(--cfg-topbar-h));
    left: 10px;
  }
  .cfg-preview__info-toggle {
    display: flex;
  }
  .cfg-preview__info:not([data-collapsed="true"]) .cfg-preview__info-toggle {
    margin-bottom: 6px;
  }
  .cfg-preview__info[data-collapsed="true"] .cfg-preview__info-row {
    display: none;
  }

  /* ------------------------------------------------------------------ *
   * Edit (move-the-print-box) mode.  `body.cfg-is-editing` is toggled by
   * enter/exitEditMode in configure_map.js.  While editing we clear the
   * bottom of the screen of the regular workflow controls — the Map
   * Options launcher and the Preview CTA — and dock the Revert/Save bar
   * (with its hint text) to the bottom edge as a frosted bar, so the user
   * focuses solely on placing the print box.
   * ------------------------------------------------------------------ */
  body.cfg-is-editing .cfg-panel-launcher,
  body.cfg-is-editing .cfg-preview__cta-group {
    display: none !important;
  }

  body.cfg-is-editing .cfg-preview__edit-bar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    transform: none;
    /* Frosted glass to match the top bar / options sheet / launcher. */
    background: rgba(255, 255, 255, 0.7);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    backdrop-filter: blur(20px) saturate(150%);
    border-top: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 32px rgba(15, 23, 42, 0.18);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  }

  /* Hint text takes the full first row; the action buttons share the next. */
  body.cfg-is-editing .cfg-preview__edit-hint {
    flex: 1 1 100%;
    max-width: none;
  }

  /* Equal-width, comfortably tappable Revert / Save buttons. */
  body.cfg-is-editing .cfg-preview__edit-btn {
    flex: 1 1 0;
    height: 40px;
    font-size: 14px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  /* Panel pinned to the left half; the map (full-bleed underneath) shows in
   * the right half.  Cap the width so very wide landscape phones don't give
   * the panel more than it needs. */
  .cfg-panel {
    width: 50%;
    max-width: 460px;
  }

  /* Narrow left panel — stack each row's label above its control (mirrors the
   * <=800px treatment, repeated here for landscape phones wider than 800px). */
  .cfg-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-left: 0;
  }
  .cfg-row__label {
    width: auto;
  }
  .cfg-row__control {
    width: 100%;
  }
  /* THE fix for the "huge space between fields": the base hint is `flex: 0 1
   * 238px`, which is a 238px-WIDE column in the horizontal row, but once the
   * row stacks (flex-direction: column) that 238px becomes the hint's HEIGHT —
   * leaving a tall empty block under rows like Coordinates / Title.  Reset to
   * auto height (mirrors the <=800px block, which is why iPhone SE was fine). */
  .cfg-row__hint {
    flex: 0 0 auto;
  }

  /* The base form uses a generous 30px inter-row gap (+20px vertical padding)
   * which, in the short landscape panel with each row now STACKED (label over
   * control), leaves big gaps between fields.  Tighten both for landscape. */
  .cfg-form {
    gap: 14px;
    padding: 12px 0;
  }
}

/* ==========================================================================
 * Cart / contact-information modal
 * Mirrors Angular CustomMapDialogComponent's fourth step (name/email/phone)
 * ========================================================================== */

.cfg-modal {
  border: none;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
  padding: 0;
  max-width: 480px;
  width: calc(100% - 32px);
  color: #171c1e;
  background: #ffffff;
}

.cfg-modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.cfg-modal__panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Header */
.cfg-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e3e5e6;
}

.cfg-modal__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #171c1e;
}

.cfg-modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #52595c;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease;
}
.cfg-modal__close:hover {
  background: #f2f4f5;
  color: #171c1e;
}

/* Body */
.cfg-modal__body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cfg-modal__info {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: #52595c;
}

/* Fields */
.cfg-modal__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cfg-modal__label {
  font-size: 13px;
  font-weight: 500;
  color: #2e3638;
}

.cfg-modal__required {
  color: #c0180c;
}

.cfg-modal__input {
  height: 38px;
  border: 1px solid #b0b8bb;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 14px;
  color: #171c1e;
  background: #ffffff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.cfg-modal__input::placeholder {
  color: #8c9599;
}
.cfg-modal__input:focus {
  border-color: #006ca2;
  box-shadow: 0 0 0 3px rgba(0, 108, 162, 0.18);
}
.cfg-modal__input--error {
  border-color: #c0180c;
  box-shadow: 0 0 0 3px rgba(192, 24, 12, 0.14);
}

.cfg-modal__field-error {
  font-size: 12px;
  color: #c0180c;
  min-height: 16px;
}

/* Submit error banner */
.cfg-modal__submit-error {
  background: #fdf0ee;
  border: 1px solid #f8c9c4;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: #8b2017;
}

/* Cumulative price breakdown (component-cart flow). */
.cfg-modal__price {
  border: 1px solid #dce0e2;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f7f9fa;
  font-size: 13px;
}

.cfg-modal__price-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cfg-modal__price-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: #48545c;
}

.cfg-modal__price-line span:last-child {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cfg-modal__price-total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #dce0e2;
  font-weight: 600;
  color: #1f2a30;
}

.cfg-modal__price-total {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Spinner inside button */
.cfg-modal__spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: cfg-modal-spin 0.65s linear infinite;
  vertical-align: middle;
}
/* `display: inline-block` above overrides the browser default `[hidden]`
 * rule — this guard restores the expected behaviour. */
.cfg-modal__spinner[hidden] {
  display: none;
}
@keyframes cfg-modal-spin {
  to { transform: rotate(360deg); }
}

/* Preview-status badge inside the modal */
.cfg-modal__preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  background: #f2f4f5;
  border: 1px solid #dce0e2;
  color: #52595c;
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease;
}
.cfg-modal__preview[hidden] {
  display: none;
}
.cfg-modal__preview--generating {
  background: #f0f6ff;
  border-color: #b8d4f0;
  color: #1a5ca8;
}
.cfg-modal__preview--ready {
  background: #edf8f1;
  border-color: #a8d9b8;
  color: #1a6b3a;
}
.cfg-modal__preview--failed {
  background: #fdf6e3;
  border-color: #f0d880;
  color: #7a5c00;
}
.cfg-modal__preview-spinner {
  display: inline-block;
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(26, 92, 168, 0.25);
  border-top-color: #1a5ca8;
  border-radius: 50%;
  animation: cfg-modal-spin 0.65s linear infinite;
}
.cfg-modal__preview-spinner[hidden] {
  display: none;
}
.cfg-modal__preview-icon {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
}
.cfg-modal__preview-text {
  flex: 1;
  min-width: 0;
}

/* Rendered preview image inside the cart modal */
.cfg-modal__preview-img-wrap {
  border-radius: 8px;
  overflow: hidden;
  background: #d8d6cd;
  border: 1px solid #dce0e2;
  /* Center the image and give it a consistent shadow */
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.cfg-modal__preview-img-wrap[hidden] {
  display: none;
}
.cfg-modal__preview-img {
  display: block;
  width: 100%;
  height: auto;
  /* Portrait maps are naturally taller; cap height so the modal
   * doesn't overflow the viewport. */
  max-height: 340px;
  object-fit: contain;
  cursor: zoom-in;
  transition: opacity 250ms ease;
}
/* Landscape orientation — wider aspect, slightly shorter cap */
.cfg-modal__preview-img[data-orientation="L"] {
  max-height: 260px;
}
/* Portrait orientation — taller, use the full cap */
.cfg-modal__preview-img[data-orientation="P"] {
  max-height: 340px;
}

/* Footer */
.cfg-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid #e3e5e6;
}

.cfg-modal__btn-text {
  vertical-align: middle;
}

.cfg-modal__btn-icon {
  margin-left: 6px;
  vertical-align: middle;
}

/* Disabled Purchase Map button — matches the overall muted disabled style */
.cfg-btn--primary:disabled,
.cfg-btn--primary[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==========================================================================
 * No-preview confirmation dialog
 * ========================================================================== */
.cfg-confirm-dialog {
  border: none;
  border-radius: 10px;
  box-shadow: 0 6px 32px rgba(0, 0, 0, 0.22);
  padding: 0;
  max-width: 400px;
  width: calc(100% - 32px);
  color: #171c1e;
  background: #ffffff;
}
.cfg-confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
}
.cfg-confirm-dialog__panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.cfg-confirm-dialog__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 18px 20px 12px;
  font-size: 15px;
  font-weight: 600;
  color: #7a5c00;
  border-bottom: 1px solid #f0e8cc;
  background: #fffbee;
  border-radius: 10px 10px 0 0;
}
.cfg-confirm-dialog__body {
  margin: 0;
  padding: 16px 20px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #52595c;
}
.cfg-confirm-dialog__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid #e3e5e6;
}

/* Override the full-height 16px main-bar button size for the dialog. */
.cfg-confirm-dialog__footer .cfg-btn {
  height: 34px;
  font-size: 13px;
  font-weight: 500;
  padding: 0 14px;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .cfg-confirm-dialog__footer {
    flex-direction: column-reverse;
    gap: 6px;
  }
  .cfg-confirm-dialog__footer .cfg-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 540px) {
  .cfg-modal {
    border-radius: 12px 12px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }
  .cfg-modal__footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .cfg-modal__footer .cfg-btn {
    width: 100%;
    justify-content: center;
  }
}
