* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', Arial, sans-serif; background: #1a1a2e; color: #e0e0e0; overflow: hidden; }

/* ── Header ── */
#header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2000;
  background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
  border-bottom: 2px solid #e94560;
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
}
#header-top {
  display: flex; align-items: stretch; gap: 0;
  padding: 0; min-height: 56px;
}
#title-group {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.12);
}
.logo {
  background: #e94560; color: white; font-weight: 800; font-size: 12px;
  padding: 3px 9px; border-radius: 4px; letter-spacing: 0.5px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; line-height: 1.35;
}
.logo-title { white-space: nowrap; }
.logo-count  { font-weight: 500; font-size: 9px; opacity: 0.92; letter-spacing: 0; white-space: nowrap; }
#title-group h1 { font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; }
#title-group .subtitle { font-size: 10px; color: #8ab4d8; white-space: nowrap; }

/* ── Active set title (central in header) ── */
#active-set-title-wrap {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 0 16px;
}
#active-set-title {
  font-size: 17px; font-weight: 700; color: #e8edf5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center; letter-spacing: 0.15px; line-height: 1.2;
}
#map-subtitle {
  font-size: 10px; color: #6a90b8; text-align: center; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.1px;
}

/* ── Cart empty badge ── */
#cart-empty-badge {
  flex-shrink: 0; align-self: center; color: rgba(255,255,255,0.28);
  font-size: 11px; font-weight: 500; padding: 0 9px; height: 26px;
  display: inline-flex; align-items: center; box-sizing: border-box;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  white-space: nowrap; user-select: none;
}

/* ── Inline chip sections (history + cart in header) ── */
.hdr-chip-section {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; flex: 1; min-width: 0;
  border-right: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
}
#cart-section { border-right: none; margin-left: auto; flex: 0 0 auto; }
#history-section { display: none !important; } /* kept in DOM for JS, hidden from UI */
.chip-chips-wrap {
  display: flex; flex-wrap: wrap; gap: 4px;
  align-content: flex-start; flex: 1; min-width: 0;
  max-height: 46px; overflow: hidden; /* ~2 rows */
}
.chip-toggle-btn {
  flex-shrink: 0; align-self: center;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.18);
  color: #8ab4d8; border-radius: 6px; padding: 0 10px; height: 26px;
  display: inline-flex; align-items: center; box-sizing: border-box;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  cursor: pointer; white-space: nowrap; transition: all 0.18s;
}
.chip-toggle-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.chip-toggle-btn.hist-active { background: rgba(33,150,243,0.35); border-color: #2196f3; color: #fff; }
.chip-toggle-btn.cart-active { background: rgba(76,175,138,0.35); border-color: #4caf8a; color: #fff; }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px; padding: 0 8px; height: 26px; box-sizing: border-box;
  font-size: 11px; font-family: 'Courier New', monospace; color: #ccc;
  cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: all 0.15s;
}
.chip:hover { border-color: rgba(255,255,255,0.5); color: #fff; }
.chip.hist-lit  { background: rgba(33,150,243,0.3);  border-color: #2196f3; color: #90caf9; }
.chip.cart-chip { border-color: rgba(76,175,138,0.5); color: #9de0c0; }
.chip.cart-lit  { background: rgba(76,175,138,0.3);  border-color: #4caf8a; color: #a5d6a7; }
#btn-download-cart {
  flex-shrink: 0; align-self: center; margin-left: 4px;
  background: rgba(76,175,138,0.15); border: 1px solid rgba(76,175,138,0.4);
  color: #4caf8a; border-radius: 6px; padding: 0 11px; height: 26px;
  display: inline-flex; align-items: center; box-sizing: border-box;
  font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
#btn-download-cart:hover { background: rgba(76,175,138,0.35); color: #fff; border-color: #4caf8a; }
#btn-clear-cart {
  flex-shrink: 0; align-self: center; font-size: 11px; font-weight: 600;
  padding: 0 9px; height: 26px;
  display: inline-flex; align-items: center; box-sizing: border-box;
  background: rgba(220,80,60,0.15); border: 1px solid rgba(220,80,60,0.35);
  color: #e08070; border-radius: 6px; cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
#btn-clear-cart:hover { background: rgba(220,80,60,0.35); color: #fff; border-color: #e05040; }

/* pdf-info-row: second row inside pdf-toolbar */
#pdf-info-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: nowrap;
  padding: 4px 10px 6px; border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 11px; color: #8ab4d8; overflow: hidden;
}
.pi-item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-item b { color: #e0e0e0; font-weight: 600; }
.pi-sep { color: rgba(255,255,255,0.2); flex-shrink: 0; }

/* ── Map container ── */
#map {
  position: fixed; top: var(--hh, 60px); left: 0; right: 0; bottom: 0;
  z-index: 1;
  transition: background-color 2s ease;
}

/* ── Toolbar (floats over map, top-right) ── */
#toolbar {
  position: fixed; top: calc(var(--hh, 60px) + 10px); right: 10px;
  z-index: 1500;
  display: flex; flex-direction: column; gap: 6px;
  transition: right 0.2s;
}
.tb-btn {
  background: rgba(15,52,96,0.93); border: 1px solid rgba(255,255,255,0.18);
  color: #d0d8e8; border-radius: 7px; padding: 7px 13px; cursor: pointer;
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
  backdrop-filter: blur(6px); transition: all 0.18s; white-space: nowrap;
  text-align: left; width: 160px;
}
.tb-btn:hover { background: rgba(233,69,96,0.85); border-color: #e94560; color: #fff; }
.tb-btn.on { background: #e94560; border-color: #c73150; color: #fff; }
.tb-btn-kofi { width: auto; align-self: flex-end; display: inline-flex; align-items: center; background: rgba(15,52,96,0.93); border-color: rgba(255,255,255,0.18); color: #d0d8e8; }
.tb-btn-kofi:hover { background: rgba(233,69,96,0.85); border-color: #e94560; color: #fff; }

/* ── Search (floats over map, top-left) ── */
#search-wrap {
  position: fixed; top: calc(var(--hh, 60px) + 10px); left: 10px;
  z-index: 1500; display: flex; flex-direction: column; gap: 4px;
}
#search-row { display: flex; gap: 5px; align-items: center; }
#search-input {
  background: rgba(15,52,96,0.93); border: 1px solid rgba(255,255,255,0.2);
  color: #ffffff; border-radius: 7px; padding: 7px 13px;
  font-size: 13px; width: 200px; outline: none;
  backdrop-filter: blur(6px);
}
#search-input::placeholder { color: #8ab4d8; }
#search-input:focus { border-color: #e94560; box-shadow: 0 0 0 2px rgba(233,69,96,0.25); }
#btn-clear-pins {
  background: rgba(15,52,96,0.93); border: 1px solid rgba(255,255,255,0.18);
  color: #8ab4d8; border-radius: 7px; padding: 7px 10px; cursor: pointer;
  font-size: 12px; backdrop-filter: blur(6px); white-space: nowrap;
  display: none; transition: all 0.18s;
}
#btn-clear-pins:hover { background: rgba(233,69,96,0.7); color: #fff; border-color: #e94560; }
#search-status {
  font-size: 11px; color: #8ab4d8; padding: 3px 6px;
  background: rgba(15,52,96,0.85); border-radius: 5px;
  display: none; backdrop-filter: blur(4px);
}
/* Search result pin marker */
.search-pin {
  background: #ff9800; border: 2px solid #fff; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
/* Pin list rows in search status */
.pin-row { display:flex; align-items:center; gap:4px; padding:2px 0; line-height:1.4; }
.pin-row + .pin-row { border-top: 1px solid rgba(255,255,255,0.07); }
.pin-label { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#8ab4d8; font-size:11px; }
.pin-x { background:none; border:none; color:#6a8ab0; cursor:pointer; font-size:11px; padding:0 2px; flex-shrink:0; line-height:1; }
.pin-x:hover { color:#e94560; }
.pin-status-msg { font-size:11px; padding:1px 0; }

/* ── PDF Side Panel ── */
#pdf-panel {
  position: fixed; right: 0; top: var(--hh, 60px); bottom: 0;
  width: 52%; background: #111;
  z-index: 1200;
  display: none; flex-direction: column;
  border-left: 3px solid #e94560;
  box-shadow: -4px 0 30px rgba(0,0,0,0.65);
  transition: none;
}
#pdf-panel.open { display: flex; }
#pdf-panel.fullscreen {
  top: 0 !important; left: 0 !important; right: 0 !important; width: 100% !important;
  z-index: 3000;
}

/* Resize handle on left edge */
#pdf-resize-handle {
  position: absolute; left: -5px; top: 0; bottom: 0; width: 10px;
  cursor: col-resize; z-index: 10;
  background: transparent;
}
#pdf-resize-handle:hover, #pdf-resize-handle.dragging {
  background: rgba(233,69,96,0.4);
}

#pdf-toolbar {
  display: flex; flex-direction: column;
  background: #0f3460; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.pdf-badge {
  background: #e94560; color: #fff; font-family: monospace;
  font-size: 13px; font-weight: 800; padding: 2px 9px; border-radius: 4px;
  white-space: nowrap; flex-shrink: 0;
}
.pdf-name { font-size: 12px; color: #8ab4d8; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-close-pdf, #btn-fullscreen-pdf, #btn-fit-pdf, #btn-dl-pdf, #btn-add-cart, #btn-refresh-pdf {
  flex-shrink: 0; border-radius: 6px; cursor: pointer;
  font-size: 12px; padding: 5px 11px; font-weight: 600; white-space: nowrap;
  transition: all 0.18s;
}
#btn-fullscreen-pdf, #btn-fit-pdf { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #8ab4d8; }
#btn-fullscreen-pdf:hover, #btn-fit-pdf:hover { background: rgba(33,150,243,0.4); border-color: #2196f3; color: #fff; }
#btn-refresh-pdf { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #8ab4d8; padding: 5px 9px; }
#btn-refresh-pdf:hover { background: rgba(76,175,138,0.35); border-color: #4caf8a; color: #fff; }
#btn-close-pdf { background: rgba(255,255,255,0.1); border: none; color: #ccc; }
#btn-close-pdf:hover { background: #e94560; color: #fff; }
#btn-dl-pdf { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #8ab4d8; }
#btn-dl-pdf:hover { background: rgba(76,175,138,0.35); border-color: #4caf8a; color: #fff; }
#btn-add-cart { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #8ab4d8; }
#btn-add-cart.in-cart { background: rgba(76,175,138,0.25); border-color: #4caf8a; color: #4caf8a; }
#btn-add-cart:hover { background: rgba(76,175,138,0.35); border-color: #4caf8a; color: #fff; }

/* ── PDF frame + states ── */
#pdf-body { position: relative; flex: 1; overflow: hidden; background: #1a1a1a; cursor: grab; }
#pdf-body.dragging { cursor: grabbing; }
#pdf-canvas-wrap {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#pdf-canvas {
  position: absolute;
  box-shadow: 0 4px 24px rgba(0,0,0,0.7);
  transform-origin: top left;
}
#pdf-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: none; display: none; }

/* Loading spinner / progress */
#pdf-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(17,17,17,0.92); z-index: 10;
}
#pdf-loading-spinner {
  display: flex; flex-direction: column; align-items: center;
}
.spinner {
  width: 42px; height: 42px; border: 3px solid #333;
  border-top-color: #e94560; border-radius: 50%;
  animation: spin 0.75s linear infinite; margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#pdf-loading p { color: #888; font-size: 13px; }

/* Error overlay — sits on top of shaded background */
#pdf-error {
  position: absolute; inset: 0; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  background: rgba(10,10,20,0.88); z-index: 20;
  padding: 24px; text-align: center;
}
#pdf-error.show { display: flex; }
.err-icon { font-size: 48px; margin-bottom: 14px; }
.err-title { font-size: 16px; font-weight: 700; color: #e94560; margin-bottom: 8px; }
.err-msg { font-size: 13px; color: #aaa; margin-bottom: 20px; max-width: 380px; line-height: 1.7; text-align: left; }
.err-msg code { background: #1a1a1a; padding: 5px 9px; border-radius: 4px; font-size: 13px; display: block; margin: 4px 0; color: #4caf8a; }
.err-msg b { color: #ccc; }
.err-links { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 320px; }
.err-link {
  display: block; padding: 9px 16px; border-radius: 7px; font-size: 12px;
  font-weight: 600; text-decoration: none; text-align: center; transition: all 0.18s;
}
.err-link-primary { background: #e94560; color: #fff; border: none; cursor: pointer; }
.err-link-primary:hover { background: #c73150; }
.err-link-secondary {
  background: transparent; color: #8ab4d8; border: 1px solid #8ab4d8;
}
.err-link-secondary:hover { border-color: #e94560; color: #e94560; }
.err-urls { margin-top: 16px; font-size: 10px; color: #555; text-align: left; width: 100%; max-width: 320px; }
.err-urls code { font-family: monospace; color: #666; font-size: 9px; display: block; word-break: break-all; margin-top: 2px; }
/* On-demand download button */
#btn-ondemand-dl { background: #4caf8a; color: #fff; border: none; cursor: pointer; }
#btn-ondemand-dl:hover:not(:disabled) { background: #3d9b76; }
#btn-ondemand-dl:disabled { background: #2a5a48; color: #7fb3a0; cursor: not-allowed; }
#err-dl-status { font-size: 12px; text-align: center; padding: 3px 0; width: 100%; max-width: 320px; }


/* Leaflet popup — thumbnail card style */
.leaflet-popup-content-wrapper {
  background: #0f3460; border: 1px solid rgba(233,69,96,0.5); color: #e0e0e0;
  border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  overflow: hidden; padding: 0;
}
.leaflet-popup-tip { background: #0f3460; }
.leaflet-popup-content { margin: 0; }
.pu-id { font-family: monospace; font-size: 14px; font-weight: 700; color: #e94560; }
.pu-sub { font-size: 11px; color: #8ab4d8; margin: 2px 0 0; }

/* ── Segmented grid mode selector ── */
.tb-grid-select {
  display: inline-flex; gap: 2px; align-items: center;
  background: rgba(255,255,255,0.05); border-radius: 4px; padding: 3px;
}
.tb-grid-btn {
  background: rgba(15,52,96,0.75); border: 1px solid rgba(255,255,255,0.18);
  color: #d0d8e8; padding: 6px 11px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.18s; border-radius: 3px;
  font-family: 'Segoe UI', Arial, sans-serif; backdrop-filter: blur(4px);
}
.tb-grid-btn:hover { background: rgba(233,69,96,0.1); color: #fff; }
.tb-grid-btn.on {
  background: #e94560; color: white; border-color: #e94560;
}

/* ── Modal dialogs (welcome, help, download) ── */
#welcome-modal, #help-modal, #download-dialog {
  display: none;
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
#welcome-modal.show, #help-modal.show, #download-dialog.show {
  display: flex;
}
.modal-content {
  background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
  border: 1px solid rgba(233,69,96,0.3);
  border-radius: 8px; max-width: 520px; width: 90%;
  max-height: 90vh; overflow-y: auto;
  padding: 28px; box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.modal-title {
  font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.modal-body {
  font-size: 13px; line-height: 1.6; color: #d0d0d0; margin-bottom: 20px;
}
.modal-body p { margin-bottom: 12px; }
.modal-body ul { margin: 12px 0 12px 20px; }
.modal-body li { margin-bottom: 6px; }
.modal-close-btn {
  background: #e94560; color: white; border: none;
  padding: 8px 18px; border-radius: 5px; cursor: pointer;
  font-size: 12px; font-weight: 600; transition: background 0.18s;
}
.modal-close-btn:hover { background: #c73150; }
.modal-btn-group {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.modal-btn-group .modal-close-btn { flex: 1; }
.modal-btn-group button { flex: 1 1 auto; }

/* ── Download panel (cart) ── */
#download-dialog {
  display: none; position: fixed; inset: 0; z-index: 5000;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
#download-dialog.show { display: flex; }
#dl-panel {
  background: linear-gradient(160deg, #0e1e36 0%, #0b1929 100%);
  border: 1px solid rgba(72,136,238,0.35);
  border-radius: 10px; width: min(440px, 92vw);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  overflow: hidden; font-family: inherit;
}
#dl-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(72,136,238,0.08);
}
#dl-title { font-size: 16px; font-weight: 700; color: #e8edf5; }
#dl-close-x {
  background: none; border: none; color: #7a9ab8; font-size: 16px;
  cursor: pointer; padding: 2px 6px; border-radius: 4px; transition: color 0.15s;
}
#dl-close-x:hover { color: #fff; }
#dl-body { padding: 18px 20px 14px; }
#dl-body p { margin: 0 0 8px; font-size: 13px; color: #c8d8e8; line-height: 1.5; }
#dl-progress-wrap { margin: 10px 0; }
#dl-sheet-list { max-height: 220px; overflow-y: auto; margin: 10px 0 12px; display: flex; flex-direction: column; gap: 4px; }
.dl-sheet-row { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 8px; background: rgba(255,255,255,0.05); border-radius: 5px; }
.dl-sheet-name { font-size: 12px; color: #c8d8e8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.dl-sheet-meta { font-size: 11px; color: #6a8ab0; flex-shrink: 0; text-align: right; }
.dl-cached { color: #4caf80; font-size: 10px; }
.dl-status-loading { color: #6a8ab0; font-size: 13px; display: inline-block;
  animation: dl-spin 0.9s linear infinite; line-height: 1; }
.dl-status-ready  { color: #4caf80; font-size: 10px; }
.dl-status-error  { color: #e57373; font-size: 10px; }
@keyframes dl-spin { to { transform: rotate(360deg); } }
#dl-progress-track {
  width: 100%; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden;
}
#dl-progress-fill {
  height: 100%; width: 0%; background: #4888ee; border-radius: 2px; transition: width 0.3s;
}
#dl-cart-progress-wrap { margin: 10px 0; }
#dl-cart-progress-track {
  width: 100%; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden;
}
#dl-cart-progress-fill {
  height: 100%; width: 0%; background: #4888ee; border-radius: 2px; transition: width 0.3s;
}
#dl-actions {
  display: flex; gap: 8px; padding: 14px 20px 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.dl-btn {
  flex: 1; padding: 9px 12px; border: none; border-radius: 6px;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.18s;
}
.dl-btn-indiv { background: rgba(72,136,238,0.15); border: 1px solid rgba(72,136,238,0.4); color: #90baf9; font-size: 16px; }
.dl-btn-indiv:hover { background: rgba(72,136,238,0.35); color: #fff; }
.dl-btn-cancel { flex: 0 0 auto; background: transparent; border: 1px solid rgba(255,255,255,0.15); color: #7a9ab8; }
.dl-btn-cancel:hover { border-color: rgba(255,255,255,0.35); color: #fff; }
.dl-btn-kofi { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: rgba(34,160,80,0.15); border: 1px solid rgba(34,160,80,0.4); color: #6dcf96; }
.dl-btn-kofi:hover { background: rgba(34,160,80,0.35); color: #fff; }
.dl-kofi-line1 { font-size: 16px; font-weight: 600; line-height: 1.2; display: block; white-space: nowrap; }
.dl-kofi-line2 { font-size: 12px; font-weight: 600; line-height: 1.3; display: flex; align-items: center; white-space: nowrap; }

/* ── Undo toast ── */
#undo-toast {
  display: none;
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 4000;
  background: rgba(15, 52, 96, 0.95); border: 1px solid rgba(233,69,96,0.3);
  padding: 12px 18px; border-radius: 6px; color: #e0e0e0;
  font-size: 13px; white-space: nowrap;
}
#undo-toast.show { display: block; }
#undo-toast .undo-link {
  color: #4caf50; text-decoration: none; cursor: pointer;
  font-weight: 600; margin-left: 8px;
}
#undo-toast .undo-link:hover { color: #66bb6a; text-decoration: underline; }

/* ── PDF resize handle enhancement ── */
#pdf-resize-handle {
  background: rgba(255,255,255,0.08); border-left: 1px dashed rgba(255,255,255,0.25);
  transition: all 0.18s;
}
#pdf-resize-handle:hover {
  background: rgba(255,255,255,0.15); border-left-color: rgba(255,255,255,0.4);
}

/* ── PDF badge font fix ── */
.pdf-badge {
  font-family: 'Segoe UI', Arial, sans-serif; font-weight: 800;
}

/* ── Chip X hit target ── */
.chip-x {
  padding: 2px 5px; font-size: 12px; min-width: 14px; min-height: 14px;
  border-radius: 3px;
}
.chip-x:hover {
  background: rgba(233,69,96,0.3); color: #fff !important;
}

/* ── Zoom badge — sits beside the +/− buttons in a horizontal row ── */
.leaflet-bottom.leaflet-left {
  flex-direction: row !important;
  align-items: flex-end;
}
.zoom-badge {
  background: rgba(15,52,96,0.90); border: 1px solid rgba(255,255,255,0.18);
  color: #d0d8e8; font-size: 11px; font-weight: 600;
  padding: 4px 9px; border-radius: 5px;
  backdrop-filter: blur(4px); pointer-events: none;
  white-space: nowrap; font-family: 'Segoe UI', Arial, sans-serif;
  box-shadow: 0 1px 6px rgba(0,0,0,0.4);
  margin-left: 6px; margin-bottom: 0;
}

/* ── Browse Maps button ── */
#btn-browse-maps {
  background: rgba(15,52,96,0.90); border: 1px solid rgba(255,255,255,0.18);
  color: #d0d8e8; font-size: 13px; font-weight: 700;
  padding: 7px 14px; border-radius: 5px; cursor: pointer;
  font-family: 'Segoe UI', Arial, sans-serif; white-space: nowrap;
  transition: all 0.18s; line-height: 1.2;
}
#btn-browse-maps:hover { background: rgba(233,69,96,0.85); border-color: #e94560; color: #fff; }

/* ── Satellite roads overlay button (only visible when sat is on) ── */
#btn-roads { display: none; }
#btn-roads.sat-roads-active { background: #2196f3; border-color: #1565c0; color: #fff; }

/* ── Map Key panel ── */
#map-key-panel {
  display: none; position: fixed; z-index: 3500;
  background: #0e1e36; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.6);
  padding: 14px 16px; min-width: 260px; max-width: 320px;
  max-height: 420px; overflow-y: auto;
  top: var(--toolbar-bottom, 100px); left: 50%; transform: translateX(-50%);
}
#map-key-panel.show { display: block; }
#map-key-panel h3 { font-size: 12px; font-weight: 700; color: #8ab4d8; text-transform: uppercase;
  letter-spacing: 0.8px; margin: 0 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.1); }
#map-key-panel h4 { font-size: 11px; font-weight: 700; color: #6a8ab0; text-transform: uppercase;
  letter-spacing: 0.6px; margin: 10px 0 6px; }
.mk-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.mk-swatch { flex-shrink: 0; border-radius: 2px; }
.mk-label { font-size: 11px; color: #c8d8e8; line-height: 1.3; }
.mk-label em { color: #8ab4d8; font-style: normal; }

/* ── Scroll speed selector (toolbar) ── */
#scroll-speed-group {
  display: flex; flex-shrink: 0; align-items: center; gap: 0;
  background: rgba(15,52,96,0.93); border: 1px solid rgba(255,255,255,0.18);
  border-radius: 7px; overflow: hidden; backdrop-filter: blur(6px);
}
#scroll-speed-label {
  font-size: 9px; font-weight: 600; color: #d0d8e8; padding: 2px 6px 2px 8px;
  border-right: 1px solid rgba(255,255,255,0.15); white-space: nowrap; flex-shrink: 0;
  line-height: 1.3; text-align: center;
}
.speed-btn {
  background: transparent; border: none; color: #b0c8e0;
  font-size: 10px; font-weight: 700; padding: 3px 8px;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.speed-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.speed-btn.on { background: rgba(33,150,243,0.35); color: #90caf9; }

/* ── Map Browser pan/zoom hint ── */
#mb-hint {
  position: absolute; top: 12px; left: 12px; z-index: 10;
  background: rgba(10,20,40,0.75); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 7px; padding: 8px 12px; pointer-events: none;
  backdrop-filter: blur(6px);
}
#mb-hint { padding: 12px 16px; }
#mb-hint ul { list-style: none; margin: 0; padding: 0; }
#mb-hint li { display: block; font-size: 14px; color: #7a9ab8; line-height: 1.9; }
#mb-hint li b { color: #a0c4e0; font-weight: 700; }

/* ── Geo SVG outline in browser cards ── */
.mb-geo-svg-wrap {
  flex: 1; display: flex; align-items: flex-end; justify-content: center;
  min-height: 44px; padding-top: 4px;
}
.mb-geo-svg-wrap svg {
  width: 100%; height: auto; max-height: 60px;
  filter: drop-shadow(0 0 4px rgba(72,136,238,0.7)) drop-shadow(0 0 10px rgba(72,136,238,0.35));
  opacity: 0.88;
}

/* ── Map Browser Overlay ── */
#mb-overlay {
  display: none; position: fixed; inset: 0; z-index: 6000;
  background: rgba(5,10,20,0.96); backdrop-filter: blur(8px);
  flex-direction: column;
}
#mb-overlay.show { display: flex; }
#mb-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(15,30,60,0.8);
}
#mb-header h2 { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: 0.3px; }
#mb-header-btns { display: flex; gap: 8px; align-items: center; }
#btn-mb-full {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.2);
  color: #8ab4d8; border-radius: 6px; padding: 6px 14px; font-size: 12px;
  font-weight: 700; cursor: pointer; transition: all 0.18s;
}
#btn-mb-full:hover { background: rgba(33,150,243,0.3); border-color: #2196f3; color: #fff; }
#btn-mb-full.on { background: rgba(33,150,243,0.4); border-color: #2196f3; color: #fff; }
#btn-mb-close {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18);
  color: #ccc; border-radius: 6px; padding: 6px 14px; font-size: 14px;
  font-weight: 700; cursor: pointer; transition: all 0.18s;
}
#btn-mb-close:hover { background: #e94560; color: #fff; border-color: #e94560; }
#mb-canvas {
  flex: 1; position: relative; overflow: hidden; cursor: grab;
  background: radial-gradient(ellipse at 30% 40%, rgba(15,52,96,0.22) 0%, transparent 70%);
}
#mb-canvas.dragging { cursor: grabbing; }
#mb-world { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
#mb-svg { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.mb-card {
  position: absolute; width: 142px; min-height: 192px; height: auto; box-sizing: border-box;
  border-radius: 10px; padding: 11px 12px 9px; cursor: pointer;
  display: flex; flex-direction: column; gap: 0;
  user-select: none; overflow: hidden; transition: border-color 0.15s, box-shadow 0.15s;
  border: 1.5px solid rgba(255,255,255,0.13); background: #0d1e32;
}
.mb-card:hover { border-color: rgba(255,255,255,0.35); box-shadow: 0 0 14px rgba(72,136,238,0.2); }
.mb-card.mb-on-path { border-color: #4888ee; background: #0e2040; box-shadow: 0 0 12px rgba(72,136,238,0.3); }
.mb-card.mb-set-card { background: #0b1e18; border-color: rgba(56,170,114,0.3); }
.mb-card.mb-set-card:hover { border-color: rgba(56,170,114,0.6); }
.mb-card.mb-set-card.mb-on-path { background: #0c2218; border-color: #38aa72; }
.mb-card.mb-active-set { background: #0e2c1e; border-color: #38aa72; box-shadow: 0 0 0 2px rgba(56,170,114,0.35); }
.mb-card.mb-selected-leaf { border-color: #5cddaa !important; box-shadow: 0 0 0 2px rgba(92,221,170,0.55), 0 0 20px rgba(56,170,114,0.22) !important; background: #0f3026 !important; }
.mb-card-title { font-size: 13px; font-weight: 800; color: #e8edf5; line-height: 1.2; overflow-wrap: break-word; }
.mb-card-sub { font-size: 10px; color: #4888ee; font-weight: 600; line-height: 1.35; overflow-wrap: break-word; }
.mb-card-sub2 { font-size: 10px; color: #7a9ab8; font-weight: 500; line-height: 1.3; margin-top: 2px; overflow-wrap: break-word; }
.mb-card-stats { font-size: 10px; color: #6a8ab0; line-height: 1.55; flex: 1; margin-top: 5px; }
.mb-card-stats div { overflow-wrap: break-word; }
.mb-stat-key { color: #4a6a88; }
.mb-stat-val { color: #8ab4d8; font-weight: 600; }
.mb-btn-open {
  align-self: flex-start; margin-top: auto;
  background: rgba(56,170,114,0.18); border: 1px solid rgba(56,170,114,0.4);
  color: #38aa72; border-radius: 4px; padding: 3px 9px; font-size: 10px;
  font-weight: 700; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.mb-btn-open:hover { background: rgba(56,170,114,0.45); color: #fff; border-color: #38aa72; }
#mb-zoom-btns {
  position: absolute; bottom: 16px; right: 16px; z-index: 10;
  display: flex; flex-direction: column; gap: 4px;
}
.mb-zoom-btn {
  background: rgba(15,30,60,0.9); border: 1px solid rgba(255,255,255,0.2);
  color: #8ab4d8; border-radius: 6px; padding: 6px 10px; font-size: 15px;
  font-weight: 700; cursor: pointer; line-height: 1; transition: all 0.15s;
  width: 34px; text-align: center;
}
.mb-zoom-btn:hover { background: rgba(33,150,243,0.4); color: #fff; border-color: #2196f3; }
#mb-zoom-fit {
  background: rgba(15,30,60,0.9); border: 1px solid rgba(255,255,255,0.2);
  color: #8ab4d8; border-radius: 6px; padding: 5px 6px; font-size: 10px;
  font-weight: 700; cursor: pointer; width: 34px; text-align: center; transition: all 0.15s;
}
#mb-zoom-fit:hover { background: rgba(33,150,243,0.4); color: #fff; }
.mb-col-label {
  position: absolute; font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.2px; color: rgba(233,69,96,0.7); pointer-events: none;
}

#btn-fit-set {
  background: rgba(15,52,96,0.90); border: 1px solid rgba(255,255,255,0.18);
  color: #8ab4d8; font-size: 10px; padding: 0 8px; border-radius: 5px;
  cursor: pointer; transition: all 0.18s; line-height: 1.2; flex-shrink: 0;
  align-self: stretch; white-space: nowrap; text-align: center;
  display: flex; align-items: center; justify-content: center;
}
#btn-fit-set:hover { background: rgba(76,175,138,0.4); border-color: #4caf8a; color: #fff; }

/* ── Download progress bar ── */
@keyframes dl-shimmer {
  0%   { transform: translateX(-150%); }
  100% { transform: translateX(600%); }
}
.dl-shimmer {
  width: 20% !important; transition: none !important;
  animation: dl-shimmer 1.4s ease-in-out infinite;
  background: linear-gradient(90deg,
    rgba(76,175,138,0.2), rgba(76,175,138,0.95),
    rgba(33,150,243,0.95), rgba(76,175,138,0.2)) !important;
}
#dl-progress-track {
  height: 6px; background: rgba(255,255,255,0.10);
  border-radius: 3px; overflow: hidden;
}
#dl-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #4caf8a, #2196f3);
  border-radius: 3px; transition: width 0.25s ease;
}

/* ── PDF render-quality badge ── */
@keyframes render-pulse {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 1.0;  }
}
#pdf-render-badge {
  display: none;
  position: absolute; top: 8px; right: 8px; z-index: 20;
  background: rgba(10,30,60,0.82);
  border: 1px solid rgba(255,255,255,0.15);
  color: #8ab4d8; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 10px;
  backdrop-filter: blur(4px); pointer-events: none;
  font-family: 'Segoe UI', Arial, sans-serif;
  animation: render-pulse 1.1s ease-in-out infinite;
  white-space: nowrap;
}
#pdf-render-badge.show { display: block; }

/* ── Focus rings ── */
button:focus-visible, input:focus-visible, select:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid #e94560; outline-offset: 2px; border-radius: 4px;
}

/* ── Chip text contrast ── */
.chip {
  color: #e6e6e6;
}
.chip:hover {
  color: #fff;
}

/* ── Shortcuts table ── */
.shortcuts-table {
  display: grid; grid-template-columns: 100px 1fr;
  gap: 8px 16px; margin: 16px 0; font-size: 12px;
}
.shortcuts-table .key {
  background: rgba(255,255,255,0.08); padding: 4px 8px; border-radius: 3px;
  font-family: monospace; font-weight: 600; color: #e94560;
}
.shortcuts-table .desc {
  color: #d0d0d0; padding: 4px 0;
}

/* ── Map style selector popover ── */
.tb-style-wrap { position: relative; }
#btn-style-current { opacity: 0.85; font-weight: 500; }
#style-popover {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 6px;
  background: rgba(15,52,96,0.97); border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px; padding: 6px; min-width: 240px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  z-index: 1800;
}
#style-popover.show { display: block; }
.style-hint { font-size: 10px; color: #8ab4d8; padding: 4px 8px 6px; text-transform: uppercase; letter-spacing: 0.6px; }
.style-opt {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; color: #e0e0e0;
  padding: 7px 10px; font-size: 12px; border-radius: 5px; cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.style-opt:hover { background: rgba(233,69,96,0.18); color: #fff; }
.style-opt.active { background: rgba(233,69,96,0.4); color: #fff; border-color: #e94560; }
.style-desc { color: #8ab4d8; font-size: 11px; font-weight: 400; margin-left: 2px; }
.style-opt.active .style-desc { color: #ffd9df; }

/* ── PI item improvements ── */
.pi-item {
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#pi-coords {
  flex: 0 1 auto;
}

/* ── Error link styling ── */
.err-link-secondary {
  display: inline-block; background: transparent; color: #8ab4d8;
  border: 1px solid #8ab4d8; padding: 5px 11px; border-radius: 4px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.18s; text-decoration: none; margin: 6px 6px 6px 0;
}
.err-link-secondary:hover {
  border-color: #e94560; color: #e94560;
}

/* ── PDF zoom buttons (bottom-right of viewer) ── */
#pdf-zoom-btns {
  position: absolute; bottom: 12px; right: 12px; z-index: 15;
  display: none; flex-direction: column; gap: 4px; align-items: center;
}
#pdf-panel.open #pdf-zoom-btns { display: flex; }
.pdf-zoom-btn {
  background: rgba(15,52,96,0.90); border: 1px solid rgba(255,255,255,0.18);
  color: #d0d8e8; width: 32px; height: 32px; border-radius: 6px;
  cursor: pointer; font-size: 20px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); transition: all 0.15s; line-height: 1;
  user-select: none;
}
.pdf-zoom-btn:hover { background: rgba(233,69,96,0.85); border-color: #e94560; color: #fff; }
.pdf-zoom-btn:active { transform: scale(0.90); }

/* ── Filmstrip panel ─────────────────────────────────────────────────────── */
#filmstrip-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1900;
  background: rgba(8,16,36,0.97);
  border-top: 2px solid #e94560;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.7);
  display: none; flex-direction: column;
  backdrop-filter: blur(8px);
  /* Height is determined naturally by one row of cards — no max-height needed */
}
#filmstrip-panel.open { display: flex; }
#filmstrip-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid rgba(255,255,255,0.09); flex-shrink: 0;
}
#filmstrip-title { font-size: 14px; font-weight: 700; color: #fff; }
#filmstrip-edition-count {
  font-size: 11px; color: #8ab4d8; background: rgba(255,255,255,0.08);
  border-radius: 10px; padding: 2px 8px; white-space: nowrap;
}
#filmstrip-hint { font-size: 11px; color: #6a8aac; font-style: italic; }
#btn-filmstrip-close {
  margin-left: auto; background: none; border: none; color: #6a8aac;
  font-size: 18px; cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1;
}
#btn-filmstrip-close:hover { color: #e94560; }
#filmstrip-scroll {
  /* Single-row horizontal strip — scroll wheel/trackpad pans left-right */
  display: flex; flex-wrap: nowrap; gap: 10px; overflow-x: auto; overflow-y: hidden;
  padding: 10px 14px 12px; align-items: stretch;
  scrollbar-width: thin; scrollbar-color: #e94560 rgba(255,255,255,0.08);
}
#filmstrip-scroll::-webkit-scrollbar { height: 5px; }
#filmstrip-scroll::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); }
#filmstrip-scroll::-webkit-scrollbar-thumb { background: #e94560; border-radius: 3px; }
.fs-card {
  flex-shrink: 0; cursor: pointer; border-radius: 6px; overflow: hidden;
  border: 2px solid rgba(255,255,255,0.12); transition: border-color 0.15s, transform 0.15s;
  background: rgba(15,30,60,0.8); display: flex; flex-direction: column;
  width: auto; /* width follows the thumbnail */
}
.fs-card:hover { border-color: #e94560; transform: translateY(-3px); }
.fs-card.fs-active { border-color: #4caf8a; }
.fs-thumb {
  /* Full thumbnail, no cropping — letterboxed inside a fixed height */
  height: 160px; width: auto; max-width: 200px; min-width: 80px;
  object-fit: contain; background: #1a1a2e; display: block; flex-shrink: 0;
}
.fs-thumb-placeholder {
  width: 120px; height: 160px; background: #1a2a4a; display: flex;
  align-items: center; justify-content: center; font-size: 28px;
  color: rgba(255,255,255,0.15); flex-shrink: 0;
}
.fs-year { padding: 5px 7px 1px; font-size: 13px; font-weight: 700; color: #fff; text-align: center; }
.fs-series { padding: 1px 7px 4px; font-size: 10px; color: #8ab4d8; text-align: center; }
.fs-compare {
  display: block; width: 100%; background: rgba(33,150,243,0.15); border: none;
  border-top: 1px solid rgba(255,255,255,0.08); color: #8ab4d8;
  font-size: 10px; font-weight: 600; padding: 4px 0; cursor: pointer; flex-shrink: 0;
  letter-spacing: 0.3px; transition: background 0.15s, color 0.15s;
}
.fs-compare:hover { background: rgba(33,150,243,0.4); color: #fff; }

/* ── Secondary PDF panel (left) ─────────────────────────────────────────── */
#pdf-panel-2 {
  position: fixed; left: 0; top: var(--hh, 60px); bottom: 0;
  width: 50%; background: #111;
  z-index: 1200; display: none; flex-direction: column;
  border-right: 3px solid #4caf8a;
  box-shadow: 4px 0 30px rgba(0,0,0,0.65);
}
#pdf-panel-2.open { display: flex; }
#pdf-panel-2.fullscreen {
  top: 0 !important; left: 0 !important; right: 0 !important; width: 100% !important;
  z-index: 3000;
}
#pdf-toolbar-2 {
  display: flex; flex-direction: column;
  background: #0f3460; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
/* Secondary badge shares .pdf-badge class; override color to teal */
#pdf-badge-2.pdf-badge { background: #4caf8a; }
#pdf-info-row-2 {
  display: flex; align-items: center; gap: 14px; flex-wrap: nowrap;
  padding: 4px 10px 6px; border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 11px; color: #8ab4d8; overflow: hidden;
}
/* Secondary panel action buttons (share same styles as primary equivalents) */
#btn-dl-pdf-2 { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #8ab4d8; }
#btn-dl-pdf-2:hover { background: rgba(76,175,138,0.35); border-color: #4caf8a; color: #fff; }
#btn-add-cart-2 { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #8ab4d8; }
#btn-add-cart-2.in-cart { background: rgba(76,175,138,0.25); border-color: #4caf8a; color: #4caf8a; }
#btn-add-cart-2:hover { background: rgba(76,175,138,0.35); border-color: #4caf8a; color: #fff; }
#btn-fit-pdf-2 { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #8ab4d8; }
#btn-fit-pdf-2:hover { background: rgba(76,175,138,0.35); border-color: #4caf8a; color: #fff; }
#btn-fullscreen-pdf-2 { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #8ab4d8; }
#btn-fullscreen-pdf-2:hover { background: rgba(76,175,138,0.35); border-color: #4caf8a; color: #fff; }
#btn-fullscreen-pdf-2 { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #8ab4d8; }
#btn-fullscreen-pdf-2:hover { background: rgba(33,150,243,0.4); border-color: #2196f3; color: #fff; }
#btn-swap-pdf {
  background: rgba(76,175,138,0.12); border: 1px solid rgba(76,175,138,0.35);
  color: #4caf8a; border-radius: 6px; cursor: pointer; font-size: 12px;
  padding: 5px 11px; font-weight: 600; transition: all 0.18s; flex-shrink: 0; white-space: nowrap;
}
#btn-swap-pdf:hover { background: rgba(76,175,138,0.35); color: #fff; border-color: #4caf8a; }
#btn-close-pdf-2 { background: rgba(255,255,255,0.1); border: none; color: #ccc; }
#btn-close-pdf-2:hover { background: #e94560; color: #fff; }
#pdf-body-2 {
  position: relative; flex: 1; overflow: hidden; background: #1a1a1a; cursor: grab;
}
#pdf-body-2.dragging { cursor: grabbing; }
#pdf-canvas-wrap-2 {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
#pdf-canvas-2 { position: absolute; box-shadow: 0 4px 24px rgba(0,0,0,0.7); transform-origin: top left; }
#pdf-loading-2 {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: rgba(17,17,17,0.92); z-index: 10;
}
#pdf-loading-spinner-2 { display: flex; flex-direction: column; align-items: center; }
/* Secondary US progress bar — reuses same structure/style as primary */
#pdf-us-progress-wrap-2 {
  display: none; flex-direction: column; align-items: center; gap: 10px; width: 60%; max-width: 320px;
}
#pdf-us-progress-wrap-2.show { display: flex; }
#pdf-us-track-2 {
  width: 100%; height: 8px; background: rgba(255,255,255,0.12); border-radius: 4px; overflow: hidden;
}
#pdf-us-fill-2 {
  height: 100%; width: 0%; background: linear-gradient(90deg, #2196f3, #4caf8a);
  border-radius: 4px; transition: width 0.3s ease;
}
#pdf-us-label-2 { font-size: 12px; color: #8ab4d8; text-align: center; }
#pdf-us-title-2 { font-size: 13px; color: #ccc; text-align: center; }
/* Secondary render badge — same as primary */
#pdf-render-badge-2 {
  display: none;
  position: absolute; top: 8px; right: 8px; z-index: 20;
  background: rgba(10,30,60,0.82);
  border: 1px solid rgba(255,255,255,0.15);
  color: #8ab4d8; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 10px;
  backdrop-filter: blur(4px); pointer-events: none;
  font-family: 'Segoe UI', Arial, sans-serif;
  animation: render-pulse 1.1s ease-in-out infinite;
  white-space: nowrap;
}
#pdf-render-badge-2.show { display: block; }
/* Secondary zoom buttons — same layout as primary, shown when panel is open */
#pdf-zoom-btns-2 {
  position: absolute; bottom: 12px; right: 12px; z-index: 15;
  display: none; flex-direction: column; gap: 4px; align-items: center;
}
#pdf-panel-2.open #pdf-zoom-btns-2 { display: flex; }

/* ── US PDF loading: progress bar replaces spinner ───────────────────────── */
#pdf-us-progress-wrap {
  display: none; flex-direction: column; align-items: center; gap: 10px; width: 60%; max-width: 320px;
}
#pdf-us-progress-wrap.show { display: flex; }
#pdf-us-track {
  width: 100%; height: 8px; background: rgba(255,255,255,0.12); border-radius: 4px; overflow: hidden;
}
#pdf-us-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, #2196f3, #4caf8a);
  border-radius: 4px; transition: width 0.3s ease;
}
#pdf-us-label { font-size: 12px; color: #8ab4d8; text-align: center; }
#pdf-us-title { font-size: 13px; color: #ccc; text-align: center; }

/* ── Preparing-map animation ─────────────────────────────────────────────── */
.pdf-preparing-wrap {
  display: none; flex-direction: column; align-items: center; gap: 14px;
}
.pdf-preparing-wrap.show { display: flex; }
.topo-ripple {
  position: relative; width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
}
.topo-ring {
  position: absolute; border-radius: 50%;
  border: 2px solid #4caf8a;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: topo-expand 2s ease-out infinite;
}
.topo-ring:nth-child(1) { animation-delay: 0s; }
.topo-ring:nth-child(2) { animation-delay: 0.5s; }
.topo-ring:nth-child(3) { animation-delay: 1s; }
.topo-ring:nth-child(4) { animation-delay: 1.5s; }
@keyframes topo-expand {
  0%   { width: 12px; height: 12px; opacity: 1; border-color: #4caf8a; }
  100% { width: 72px; height: 72px; opacity: 0; border-color: rgba(76,175,138,0.1); }
}
.topo-pin { font-size: 22px; position: relative; z-index: 1;
            filter: drop-shadow(0 0 6px rgba(76,175,138,0.7)); }
.preparing-lbl { font-size: 13px; color: #8ab4d8; }

/* ── Unzip animation ─────────────────────────────────────────────────────── */
.pdf-unzip-wrap {
  display: none; flex-direction: column; align-items: center; gap: 12px;
}
.pdf-unzip-wrap.show { display: flex; }
.unzip-svg { width: 160px; height: 128px; overflow: visible; }
.unzip-zipper-pull { animation: zipper-pull 2s ease-in-out infinite; }
@keyframes zipper-pull {
  0%   { transform: translateX(0); }
  65%  { transform: translateX(-68px); }
  82%  { transform: translateX(-68px); }
  100% { transform: translateX(0); }
}
.unzip-man {
  transform-box: fill-box; transform-origin: 50% 100%;
  animation: man-lean 2s ease-in-out infinite;
}
@keyframes man-lean {
  0%   { transform: rotate(0deg); }
  65%  { transform: rotate(-11deg); }
  82%  { transform: rotate(-11deg); }
  100% { transform: rotate(0deg); }
}
.unzip-lbl { font-size: 13px; color: #8ab4d8; }

/* Dual-PDF body layout: map hidden, both panels fill the screen */
body.dual-pdf #map { display: none !important; }
body.dual-pdf #toolbar { display: none !important; }
body.dual-pdf #search-wrap { display: none !important; }
body.dual-pdf #pdf-panel { left: 50% !important; width: 50% !important; right: 0 !important; }
body.dual-pdf #pdf-panel #pdf-resize-handle { display: none; }

/* ════════════════════════════════════════════════════════════════════════════
   MOBILE LAYOUT  (≤ 768 px)
   ════════════════════════════════════════════════════════════════════════════ */

/* Mobile-only elements — hidden on desktop */
#btn-mobile-menu       { display: none; }
#btn-view-cart-mobile  { display: none; }
#tb-search-row         { display: none; }
#pdf-mobile-bar        { display: none; }
#pdf-mobile-menu       { display: none; }

/* Drawer overlay — darkens map when toolbar drawer is open */
#mobile-drawer-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1400;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
#mobile-drawer-overlay.show { display: block; }

@media (max-width: 768px) {

  /* ── Header ── */
  #header-top {
    flex-wrap: wrap;
    min-height: auto;
  }

  /* Title group: logo + Discover Maps only, no right border */
  #title-group {
    flex: 1; min-width: 0;
    border-right: none;
    padding: 6px 10px;
    gap: 8px;
  }

  /* Active set title — second row, full width */
  #active-set-title-wrap {
    order: 10;
    flex-basis: 100%; width: 100%;
    padding: 4px 10px 7px;
    border-top: 1px solid rgba(255,255,255,0.08);
    align-items: flex-start;
  }
  #active-set-title { font-size: 13px; text-align: left; }
  #map-subtitle { text-align: left; }

  /* Cart section — hidden entirely on mobile (accessed via drawer) */
  #cart-section { display: none !important; }

  /* Hide original search (moved to drawer) */
  #search-wrap { display: none; }

  /* Hamburger — floats over map, top-right corner below header */
  #btn-mobile-menu {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; top: calc(var(--hh, 60px) + 10px); right: 10px; z-index: 1490;
    background: rgba(15,52,96,0.82); border: 1px solid rgba(255,255,255,0.22);
    color: #d0d8e8; width: 44px; height: 44px; border-radius: 8px;
    font-size: 22px; cursor: pointer; transition: all 0.18s;
    box-shadow: 0 2px 12px rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
  }
  #btn-mobile-menu.active,
  #btn-mobile-menu:active { background: rgba(233,69,96,0.9); color: #fff; border-color: #e94560; }
  /* Hide hamburger when PDF is open */
  body.pdf-open #btn-mobile-menu { display: none !important; }

  /* Hide desktop PDF toolbar on mobile — replaced by #pdf-mobile-bar */
  #pdf-toolbar { display: none !important; }

  /* PDF mobile bar — transparent overlay, top-right corner only */
  #pdf-mobile-bar {
    display: flex; align-items: center;
    position: absolute; top: 10px; right: 10px; left: auto;
    width: auto; z-index: 20;
    background: transparent; border: none;
    padding: 0; gap: 6px; height: auto; box-sizing: border-box;
  }
  #btn-pdf-mb-close {
    width: 44px; height: 44px; flex-shrink: 0;
    background: rgba(10,20,40,0.55); border: 1px solid rgba(255,255,255,0.18);
    color: #fff; border-radius: 9px; font-size: 19px; font-weight: 700;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  }
  #btn-pdf-mb-close:active { background: rgba(233,69,96,0.8); }
  #btn-pdf-mb-menu {
    width: 44px; height: 44px; flex-shrink: 0;
    background: rgba(10,20,40,0.55); border: 1px solid rgba(255,255,255,0.18);
    color: #fff; border-radius: 9px; font-size: 22px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  }
  #btn-pdf-mb-menu.active,
  #btn-pdf-mb-menu:active { background: rgba(33,150,243,0.5); border-color: #2196f3; }

  /* PDF mobile menu — dropdown from top-right corner */
  #pdf-mobile-menu {
    display: none;
    position: absolute; top: 64px; right: 10px; left: auto;
    width: 260px; z-index: 19;
    background: rgba(10,20,40,0.96); backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12); border-radius: 10px;
    padding: 12px;
    flex-direction: column; gap: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  }
  #pdf-mobile-menu.open { display: flex; }
  #pdf-mb-info {
    font-size: 11px; color: #8ab4d8; line-height: 1.8;
    padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  #pdf-mb-info strong {
    display: block; font-size: 13px; color: #e0e8f8; font-weight: 600;
    margin-bottom: 4px;
  }
  .pdf-mb-action {
    width: 100%; padding: 10px 14px; border-radius: 7px;
    background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.15);
    color: #d0d8e8; font-size: 13px; font-weight: 600; text-align: left;
    cursor: pointer; transition: background 0.15s;
  }
  .pdf-mb-action:active { background: rgba(255,255,255,0.2); }

  /* pdf-body fills entire panel — no top offset needed */
  #pdf-body { padding-top: 0; }

  /* Native iframe viewer — fills the pdf-body */
  #pdf-frame {
    display: block !important;
    position: absolute; inset: 0; width: 100%; height: 100%; border: none;
  }

  /* Leaflet zoom controls — hidden on mobile (pinch to zoom) */
  .leaflet-control-zoom { display: none !important; }

  /* Zoom badge — sits alone in bottom-left corner */
  .leaflet-bottom.leaflet-left { flex-direction: column !important; align-items: flex-start; }
  .zoom-badge { margin-left: 0; margin-bottom: 6px; }

  /* ── Toolbar → slide-in drawer ── */
  #toolbar {
    position: fixed;
    top: var(--hh, 60px); right: -280px; bottom: 0;
    width: 260px; z-index: 1450;
    flex-direction: column;
    background: rgba(8,16,36,0.98);
    border-left: 2px solid rgba(233,69,96,0.5);
    box-shadow: -4px 0 24px rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    padding: 12px 8px;
    gap: 6px;
    overflow-y: auto;
    transition: right 0.25s ease;
  }
  #toolbar.mobile-open { right: 0 !important; }
  /* Prevent JS from repositioning toolbar on mobile */
  #toolbar:not(.mobile-open) { right: -280px !important; }

  /* Show drawer-only buttons */
  #btn-view-cart-mobile { display: block; }

  /* Hide zoom speed (irrelevant on touch) */
  #scroll-speed-group { display: none; }

  /* Mobile search row at bottom of drawer */
  #tb-search-row {
    display: block;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  #tb-search-input {
    width: 100%; box-sizing: border-box;
    background: rgba(15,52,96,0.93); border: 1px solid rgba(255,255,255,0.2);
    color: #fff; border-radius: 7px; padding: 9px 13px;
    font-size: 13px; outline: none;
  }
  #tb-search-input::placeholder { color: #8ab4d8; }
  #tb-search-input:focus { border-color: #e94560; box-shadow: 0 0 0 2px rgba(233,69,96,0.25); }

  /* Map browser — hide hint card, touch-friendly */
  #mb-hint { display: none !important; }

  /* Full-width toolbar buttons in drawer */
  .tb-btn            { width: 100%; text-align: left; }
  .tb-grid-select    { width: 100%; }
  .tb-grid-btn       { flex: 1; }
  #scroll-speed-group { width: 100%; box-sizing: border-box; }

  /* ── Search ── */
  #search-input { width: calc(100vw - 120px); }

  /* ── Map — never shrink for PDF panel on mobile ── */
  #map { right: 0 !important; }

  /* ── PDF panel — full screen, edge to edge, no header ── */
  #pdf-panel {
    left: 0 !important;
    width: 100% !important;
    right: 0 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
  }
  #pdf-resize-handle { display: none !important; }
  /* Hide header & kill top gap when PDF is open on mobile */
  body.pdf-open #header  { display: none !important; }
  body.pdf-open #pdf-panel { top: 0 !important; }
  /* Ensure PDF panel sits on top and captures ALL touch events */
  body.pdf-open #pdf-panel {
    z-index: 3000 !important;
    pointer-events: all !important;
    touch-action: none !important;
  }
  /* Solid loading background on mobile — no map bleed-through */
  body.pdf-open #pdf-loading { background: #111 !important; }
  body.pdf-open #pdf-body { touch-action: none !important; }
  /* Hide PDF zoom +/- buttons on mobile */
  #pdf-zoom-btns { display: none !important; }
  /* PDF canvas — fills panel body on mobile (PDF.js used, not iframe) */
  body.pdf-open #pdf-canvas-wrap {
    display: flex !important;
    position: absolute; inset: 0;
  }
  /* Hide native iframe — PDF.js canvas used instead */
  #pdf-frame { display: none !important; }

  /* Tighten PDF toolbar for narrow screen */
  #pdf-info-row { display: none; } /* metadata row hidden on mobile */
  #btn-dl-pdf, #btn-add-cart, #btn-fullscreen-pdf, #btn-refresh-pdf {
    display: none; /* tucked away for now — close/fit stay visible */
  }
  #btn-close-pdf, #btn-fit-pdf {
    padding: 8px 14px;
    min-height: 40px;
    font-size: 13px;
  }
  .pdf-zoom-btn { width: 44px; height: 44px; font-size: 22px; }

  /* ── Disable dual-panel compare ── */
  #pdf-panel-2  { display: none !important; }
  #btn-swap-pdf { display: none !important; }
  .fs-compare   { display: none !important; }

  /* ── Touch targets ── */
  #btn-browse-maps { padding: 9px 12px; font-size: 12px; }
  #cart-empty-badge { height: 34px; font-size: 10px; }

  /* ── Filmstrip ── */
  .fs-thumb { height: 120px; }
  .fs-year  { font-size: 12px; }
}
