/* Nota Map — dark (default) + light theme via [data-theme] */
:root {
  --app-bg: #050505;
  --app-fg: #ebebeb;
  --panel-bg: #0f172a;
  --panel-fg: #ebebeb;
  --panel-border: rgba(255, 255, 255, 0.08);
  --surface-1: rgba(15, 23, 42, 0.9);
  --surface-2: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.1);
  --border-1: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.12);
  --muted: rgba(235, 235, 235, 0.6);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --sv-border: rgba(255, 255, 255, 0.06);
}
[data-theme="light"] {
  --app-bg: #f8fafc;
  --app-fg: #0f172a;
  --panel-bg: rgba(255, 255, 255, 0.97);
  --panel-fg: #0f172a;
  --panel-border: rgba(0, 0, 0, 0.1);
  --surface-1: rgba(255, 255, 255, 0.95);
  --surface-2: rgba(0, 0, 0, 0.03);
  --surface-hover: rgba(0, 0, 0, 0.08);
  --border-1: rgba(0, 0, 0, 0.1);
  --border-2: rgba(0, 0, 0, 0.15);
  --muted: rgba(15, 23, 42, 0.65);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  --sv-border: rgba(0, 0, 0, 0.1);
}
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--app-bg);
  color: var(--app-fg);
}
* { box-sizing: border-box; }

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* Top bar */
#topbar {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 14px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
#topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
#topbar .sub {
  margin-top: 2px;
  font-size: 11px;
  color: rgba(235, 235, 235, 0.6);
}

/* Side panel */
#panel {
  position: fixed;
  top: 0;
  right: -420px;
  bottom: 0;
  width: 380px;
  background: #0f172a;
  color: #ebebeb;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1200;
  overflow-y: auto;
  transition: right 0.28s ease;
  padding: 20px 20px 100px;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.6);
}
#panel.open { right: 0; }

#panel .close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 0;
  color: #ebebeb;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
#panel .close-btn:hover { background: rgba(255, 255, 255, 0.12); }

#panel h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
  padding-right: 76px; /* room for star + close in .panel-header-actions */
}
#panel .rc {
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 12px;
  color: rgba(235, 235, 235, 0.55);
  margin-bottom: 10px;
}
#panel .barrio {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  font-size: 11px;
  margin-bottom: 16px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.stat .val { font-size: 16px; font-weight: 600; }
.stat .lbl {
  font-size: 10px;
  color: rgba(235, 235, 235, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  color: rgba(235, 235, 235, 0.5);
  letter-spacing: 0.6px;
  margin: 16px 0 6px;
}
.desglose {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(235, 235, 235, 0.85);
}

.links-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.link-btn {
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  text-decoration: none;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex: 1;
  text-align: center;
  white-space: nowrap;
}
.link-btn:hover { background: rgba(255, 255, 255, 0.1); }

#panel .foto {
  margin-top: 16px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.order-btn {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 14px;
  border-radius: 8px;
  background: #2563eb;
  color: white;
  font-size: 14px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  letter-spacing: 0.2px;
}
.order-btn:hover { background: #1d4ed8; }
.order-btn:disabled {
  background: #334155;
  color: rgba(235, 235, 235, 0.5);
  cursor: not-allowed;
}

/* Educational fallback block shown in the panel when the paid Nota Simple
   CTA is disabled (flags.showNotaCta = false in release.json). Intentionally
   muted / non-actionable — we're pointing users at the official free channel,
   not selling anything. */
.nota-info {
  margin-top: 22px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--panel-fg);
}
.nota-info-title {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 13px;
  letter-spacing: 0.2px;
}
.nota-info-body {
  margin-top: 6px;
  color: var(--muted);
}
.nota-info-body a {
  color: var(--panel-fg);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.nota-info-body a:hover {
  color: #60a5fa;
}

.existing-notice {
  margin-top: 20px;
  padding: 12px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 8px;
  font-size: 12px;
}
.existing-notice a {
  display: inline-block;
  margin-top: 8px;
  color: #4ade80;
  font-weight: 600;
  text-decoration: none;
}

/* Modal */
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1500;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
#modal-backdrop.open { display: flex; }

.modal {
  width: 420px;
  max-width: 92vw;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
.modal h3 {
  margin: 0 0 4px;
  font-size: 18px;
}
.modal .subtitle {
  margin-bottom: 18px;
  font-size: 12px;
  color: rgba(235, 235, 235, 0.6);
}
.modal label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: rgba(235, 235, 235, 0.6);
  margin: 12px 0 4px;
  letter-spacing: 0.5px;
}
.modal input, .modal select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #ebebeb;
  font-size: 14px;
  font-family: inherit;
}
.modal input:focus, .modal select:focus {
  outline: none;
  border-color: #2563eb;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 22px;
}
.modal-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 6px;
  border: 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-cancel {
  background: rgba(255, 255, 255, 0.06);
  color: #ebebeb;
}
.btn-submit {
  background: #2563eb;
  color: white;
}
.btn-submit:disabled { background: #334155; cursor: not-allowed; }

.status-box {
  margin-top: 20px;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  text-align: center;
}
.status-box.delivered {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}
.status-box.failed {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.download-link {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 14px;
  background: #22c55e;
  color: #052e16;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.download-link:hover { background: #16a34a; }

/* Inline order form (lives inside #panel now, no modal) */
.order-form {
  margin-top: 22px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}
.order-form label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: rgba(235, 235, 235, 0.6);
  margin: 8px 0 4px;
  letter-spacing: 0.5px;
}
.order-form input,
.order-form select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #ebebeb;
  font-size: 14px;
  font-family: inherit;
}
.order-form input:focus,
.order-form select:focus {
  outline: none;
  border-color: #2563eb;
}
.order-form .modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.order-form .modal-actions button {
  flex: 1;
  padding: 11px;
  border-radius: 6px;
  border: 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ---- Filter rail (left) ---- */
#filter-rail {
  position: fixed;
  top: 82px;
  left: 12px;
  bottom: 12px;
  width: 260px;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  color: #ebebeb;
  display: flex;
  flex-direction: column;
}
#filter-rail .rail-section {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
#filter-rail .rail-section:last-child { border-bottom: 0; }
#filter-rail .rail-footer { margin-top: auto; }

#filter-rail .section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(235, 235, 235, 0.55);
  margin: 0 0 8px;
}

#filter-rail .uso-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#filter-rail .uso-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 12px;
}
#filter-rail .uso-row label:hover { color: #f1f5f9; }
#filter-rail .uso-row input[type=checkbox] {
  accent-color: #3b82f6;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
#filter-rail .uso-row .cnt {
  margin-left: auto;
  color: rgba(235, 235, 235, 0.4);
  font-size: 11px;
}

#filter-rail .range-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
#filter-rail .range-row input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
  font-family: inherit;
}
#filter-rail .range-row input:focus {
  outline: none;
  border-color: #2563eb;
}
#filter-rail .range-row span {
  color: rgba(235, 235, 235, 0.4);
  font-size: 12px;
}
#filter-rail .note {
  font-size: 10px;
  color: rgba(235, 235, 235, 0.4);
  margin-top: 6px;
  font-style: italic;
}

#reset-btn {
  width: 100%;
  padding: 8px;
  background: #1e40af;
  color: #fff;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
#reset-btn:hover { background: #2563eb; }

#filter-counter {
  margin-top: 10px;
  color: rgba(235, 235, 235, 0.6);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}
#filter-counter b { color: #f1f5f9; font-weight: 600; }

/* ---- Search box (top center) ---- */
#search-box {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  z-index: 1100;
}
#search-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #f1f5f9;
  font-size: 13px;
  font-family: "Fira Code", ui-monospace, monospace;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
#search-input::placeholder { color: rgba(235, 235, 235, 0.4); }
#search-input:focus {
  outline: none;
  border-color: #2563eb;
}
#search-results {
  margin-top: 4px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
#search-results[hidden] { display: none; }
.search-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: #cbd5e1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-item:last-child { border-bottom: 0; }
.search-item:hover, .search-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: #f1f5f9;
}
.search-item .rc-txt {
  font-family: "Fira Code", ui-monospace, monospace;
  color: #93c5fd;
  flex-shrink: 0;
}
.search-item .bucket-txt {
  color: rgba(235, 235, 235, 0.65);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.search-item .area-txt {
  margin-left: auto;
  color: rgba(235, 235, 235, 0.5);
  font-size: 11px;
}
.search-item .empty {
  color: rgba(235, 235, 235, 0.4);
  font-style: italic;
}

/* Address-mode suggestion: address prominent, meta muted, RC monospace tail */
.search-item .addr {
  color: #f1f5f9;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.search-item .meta {
  color: rgba(235, 235, 235, 0.55);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.search-item .rc {
  font-family: "Fira Code", ui-monospace, monospace;
  color: rgba(147, 197, 253, 0.65);
  font-size: 10px;
  flex-shrink: 0;
  margin-left: auto;
}

/* RC-mode suggestion: RC prominent, address as secondary line */
.search-item .rc-primary {
  font-family: "Fira Code", ui-monospace, monospace;
  color: #93c5fd;
  font-weight: 500;
  flex-shrink: 0;
}
.search-item .addr-secondary {
  color: rgba(235, 235, 235, 0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}

/* Bucket label in panel */
#panel .bucket-label { font-size: 13px; color: #f1f5f9; font-weight: 500; }
#panel .bucket-raw {
  font-size: 11px;
  color: rgba(235, 235, 235, 0.45);
  margin-top: 2px;
  font-family: "Fira Code", ui-monospace, monospace;
}

/* MapLibre dark tweaks */
.maplibregl-canvas-container canvas { outline: none; }
.maplibregl-ctrl-attrib {
  background: rgba(0, 0, 0, 0.55) !important;
}
.maplibregl-ctrl-attrib a { color: rgba(255, 255, 255, 0.7) !important; }
.maplibregl-ctrl-group {
  background: rgba(15, 23, 42, 0.9) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}
.maplibregl-ctrl-group button { filter: invert(0.85); }

/* ---- Theme toggle (top-right, sits under maplibre nav ctrl) ---- */
#theme-toggle {
  position: fixed;
  top: 108px; /* below MapLibre nav-control (~top:10px + ~90px block) */
  right: 12px;
  width: 40px;
  height: 40px;
  z-index: 1100;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  color: var(--app-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  padding: 0;
}
#theme-toggle:hover { background: var(--surface-hover); }
#theme-toggle svg { display: block; }

/* ---- Language switcher (top-right, above theme toggle) ---- */
#lang-switcher {
  position: fixed;
  top: 156px; /* below theme-toggle (108 + 40 + 8 gap) */
  right: 12px;
  z-index: 1100;
}
#lang-current {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  color: var(--app-fg);
  cursor: pointer;
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
#lang-current:hover { background: var(--surface-hover); }
#lang-current svg { opacity: 0.7; }
#lang-current-flag { font-size: 15px; line-height: 1; }
#lang-menu {
  position: absolute;
  top: 46px;
  right: 0;
  min-width: 168px;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  color: var(--app-fg);
  font-size: 13px;
}
#lang-menu[hidden] { display: none; }
#lang-menu li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}
#lang-menu li:hover { background: var(--surface-hover); }
#lang-menu li.active { color: #60a5fa; font-weight: 600; }
#lang-menu li span { font-size: 15px; line-height: 1; }
[data-theme="light"] #lang-menu li.active { color: #1d4ed8; }

/* ---- Inline Street View in panel ---- */
.panel-streetview {
  margin-top: 14px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--sv-border);
  background: var(--surface-2);
  min-height: 220px;
  position: relative;
}
.panel-streetview iframe {
  display: block;
  width: 100%;
  height: 220px;
  border: 0;
}
.panel-streetview .sv-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.panel-streetview .sv-fallback a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
}

/* ---- Light-theme overrides ---- */
[data-theme="light"] #topbar {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}
[data-theme="light"] #topbar .sub { color: rgba(15, 23, 42, 0.6); }
[data-theme="light"] #panel {
  background: var(--panel-bg);
  color: var(--panel-fg);
  border-left: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
}
[data-theme="light"] #panel .close-btn {
  background: rgba(0, 0, 0, 0.06);
  color: #0f172a;
}
[data-theme="light"] #panel .close-btn:hover { background: rgba(0, 0, 0, 0.12); }
[data-theme="light"] #panel .rc { color: rgba(15, 23, 42, 0.6); }
[data-theme="light"] #panel .barrio {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}
[data-theme="light"] #panel .bucket-label { color: #0f172a; }
[data-theme="light"] #panel .bucket-raw { color: rgba(15, 23, 42, 0.5); }
[data-theme="light"] .stat {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .stat .lbl { color: rgba(15, 23, 42, 0.55); }
[data-theme="light"] .section-title { color: rgba(15, 23, 42, 0.55); }
[data-theme="light"] .desglose {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
  color: rgba(15, 23, 42, 0.85);
}
[data-theme="light"] .link-btn {
  background: rgba(0, 0, 0, 0.05);
  color: #1e293b;
  border-color: rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .link-btn:hover { background: rgba(0, 0, 0, 0.1); }
[data-theme="light"] .order-btn { background: #1d4ed8; }
[data-theme="light"] .order-btn:hover { background: #1e40af; }
[data-theme="light"] .order-btn:disabled {
  background: #cbd5e1;
  color: rgba(15, 23, 42, 0.55);
}
[data-theme="light"] .order-form {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .order-form label { color: rgba(15, 23, 42, 0.6); }
[data-theme="light"] .order-form input,
[data-theme="light"] .order-form select {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.15);
  color: #0f172a;
}
[data-theme="light"] .btn-cancel {
  background: rgba(0, 0, 0, 0.06);
  color: #0f172a;
}
[data-theme="light"] .status-box {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}
[data-theme="light"] #filter-rail {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] #filter-rail .rail-section { border-bottom-color: rgba(0, 0, 0, 0.08); }
[data-theme="light"] #filter-rail .section-title { color: rgba(15, 23, 42, 0.55); }
[data-theme="light"] #filter-rail .uso-row label { color: #1e293b; }
[data-theme="light"] #filter-rail .uso-row label:hover { color: #0f172a; }
[data-theme="light"] #filter-rail .uso-row .cnt { color: rgba(15, 23, 42, 0.5); }
[data-theme="light"] #filter-rail .range-row input {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.15);
  color: #0f172a;
}
[data-theme="light"] #filter-rail .range-row span,
[data-theme="light"] #filter-rail .note { color: rgba(15, 23, 42, 0.55); }
[data-theme="light"] #filter-counter { color: rgba(15, 23, 42, 0.7); }
[data-theme="light"] #filter-counter b { color: #0f172a; }
[data-theme="light"] #reset-btn { background: #1d4ed8; }
[data-theme="light"] #reset-btn:hover { background: #2563eb; }
[data-theme="light"] #search-input {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.12);
  color: #0f172a;
}
[data-theme="light"] #search-input::placeholder { color: rgba(15, 23, 42, 0.5); }
[data-theme="light"] #search-results {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.12);
  color: #0f172a;
}
[data-theme="light"] .search-item {
  color: #1e293b;
  border-bottom-color: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .search-item:hover,
[data-theme="light"] .search-item.active {
  background: rgba(37, 99, 235, 0.1);
  color: #0f172a;
}
[data-theme="light"] .search-item .rc-txt,
[data-theme="light"] .search-item .rc-primary { color: #1d4ed8; }
[data-theme="light"] .search-item .addr,
[data-theme="light"] .search-item .addr-secondary { color: #0f172a; }
[data-theme="light"] .search-item .meta,
[data-theme="light"] .search-item .bucket-txt { color: rgba(15, 23, 42, 0.6); }
[data-theme="light"] .search-item .rc { color: rgba(29, 78, 216, 0.65); }
[data-theme="light"] .search-item .area-txt { color: rgba(15, 23, 42, 0.55); }
[data-theme="light"] .search-item .empty { color: rgba(15, 23, 42, 0.5); }
[data-theme="light"] .maplibregl-ctrl-attrib {
  background: rgba(255, 255, 255, 0.75) !important;
}
[data-theme="light"] .maplibregl-ctrl-attrib a { color: rgba(15, 23, 42, 0.75) !important; }
[data-theme="light"] .maplibregl-ctrl-group {
  background: rgba(255, 255, 255, 0.95) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
}
[data-theme="light"] .maplibregl-ctrl-group button { filter: none; }

/* ---- Preset chips (top of filter rail) ---- */
#preset-bar .preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: transparent;
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.preset-chip:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #f1f5f9;
  border-color: rgba(59, 130, 246, 0.35);
}
.preset-chip.active {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}
.preset-chip-icon {
  font-size: 13px;
  line-height: 1;
}
.preset-chip-label { font-weight: 500; }
[data-theme="light"] .preset-chip {
  color: #1e293b;
  border-color: rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .preset-chip:hover {
  background: rgba(37, 99, 235, 0.1);
  color: #0f172a;
  border-color: rgba(37, 99, 235, 0.35);
}
[data-theme="light"] .preset-chip.active {
  background: #1d4ed8;
  color: #fff;
  border-color: #1e40af;
}

/* ---- Draw + measure toolbar (top-right, below lang switcher) ---- */
#draw-toolbar {
  position: fixed;
  top: 204px; /* below lang switcher (156 + 40 + 8 gap) */
  right: 12px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.draw-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  color: var(--app-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  padding: 0;
}
.draw-btn:hover { background: var(--surface-hover); }
/* 2026-07-31 fix: SVG icons inside toolbar buttons must not intercept
   pointer events, otherwise the parent <button> click handler doesn't
   fire (browser targets the SVG). Broke #bookmarks-btn overlap zone. */
.draw-btn > svg,
.draw-btn > span,
#bookmarks-btn > span,
#bookmarks-btn > svg { pointer-events: none; }
.draw-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}
[data-theme="light"] .draw-btn.active {
  background: #1d4ed8;
  border-color: #1e40af;
}
#draw-readout {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--app-fg);
  border: 1px solid var(--border-2);
  font-size: 12px;
  font-family: "Fira Code", ui-monospace, monospace;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  min-width: 140px;
  text-align: right;
}
#draw-readout[hidden] { display: none; }
.draw-inline-cta {
  padding: 8px 12px;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  border: 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-family: inherit;
}
.draw-inline-cta:hover { background: #1d4ed8; }
.draw-inline-cta[hidden] { display: none; }

/* ---- View toggle (map / list) ---- */
#view-toggle {
  position: fixed;
  top: 356px; /* below draw toolbar (204 + 3*40 + 2*6 gaps + 6 gap = ~342, round up) */
  right: 12px;
  z-index: 1100;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  color: var(--app-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  padding: 0;
}
#view-toggle:hover { background: var(--surface-hover); }
#view-toggle[data-mode="list"] {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}

/* ---- List view panel (right side) ---- */
#list-view {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 500px;
  max-width: 90vw;
  background: rgba(15, 23, 42, 0.96);
  color: #ebebeb;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1150; /* below detail panel (1200) so click-throughs still open */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}
#list-view[hidden] { display: none; }
[data-theme="light"] #list-view {
  background: rgba(255, 255, 255, 0.97);
  color: #0f172a;
  border-left-color: rgba(0, 0, 0, 0.1);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
}
#list-view .list-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
[data-theme="light"] #list-view .list-header { border-bottom-color: rgba(0, 0, 0, 0.1); }
#list-view .list-count {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}
#list-view .list-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#list-view .list-controls label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(235, 235, 235, 0.55);
}
[data-theme="light"] #list-view .list-controls label { color: rgba(15, 23, 42, 0.55); }
#list-view .list-controls select {
  flex: 0 1 auto;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #f1f5f9;
  font-size: 12px;
  font-family: inherit;
}
[data-theme="light"] #list-view .list-controls select {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.15);
  color: #0f172a;
}
#list-view .list-controls #list-export-btn {
  margin-left: auto;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: #22c55e;
  color: #052e16;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
#list-view .list-controls #list-export-btn:hover { background: #16a34a; }
#list-view .list-warning {
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 6px;
  font-size: 11px;
  color: rgba(235, 235, 235, 0.85);
}
[data-theme="light"] #list-view .list-warning { color: #713f12; }
#list-view .list-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
#list-view .list-row {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.1s;
}
[data-theme="light"] #list-view .list-row { border-bottom-color: rgba(0, 0, 0, 0.05); }
#list-view .list-row:hover { background: rgba(59, 130, 246, 0.12); }
[data-theme="light"] #list-view .list-row:hover { background: rgba(37, 99, 235, 0.08); }
#list-view .list-row-primary {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#list-view .list-row-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: rgba(235, 235, 235, 0.55);
  margin-bottom: 3px;
}
[data-theme="light"] #list-view .list-row-meta { color: rgba(15, 23, 42, 0.55); }
#list-view .list-row-rc {
  font-family: "Fira Code", ui-monospace, monospace;
  color: rgba(147, 197, 253, 0.75);
}
[data-theme="light"] #list-view .list-row-rc { color: rgba(29, 78, 216, 0.75); }
#list-view .list-row-stats {
  display: flex;
  gap: 4px;
  font-size: 11px;
  color: rgba(235, 235, 235, 0.65);
  flex-wrap: wrap;
}
[data-theme="light"] #list-view .list-row-stats { color: rgba(15, 23, 42, 0.65); }

/* Nudge the topbar down slightly on tight screens when list view is active */
body.list-view-active #panel { z-index: 1250; }


/* Condition badge in property panel (Task follow-up: expose year + condition) */
.condition-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
}
.condition-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.condition-raw {
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 11px;
  color: rgba(235, 235, 235, 0.45);
}
[data-theme="light"] .condition-raw { color: rgba(15, 23, 42, 0.45); }

/* Close button on list view (parity with #panel-close) */
#list-view .close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 14px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #ebebeb;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
#list-view .close-btn:hover { background: rgba(255, 255, 255, 0.16); }
[data-theme="light"] #list-view .close-btn {
  background: rgba(0, 0, 0, 0.06);
  color: #0f172a;
}
[data-theme="light"] #list-view .close-btn:hover { background: rgba(0, 0, 0, 0.12); }

/* ---- Choropleth mode switcher (Task #19 §2.3) ----
   Sits top-right, above the language switcher. Hides itself at zoom >= 11
   via app.js — no CSS media hooks needed. */
#choropleth-switch {
  position: fixed;
  top: 204px; /* below lang-switcher (156 + 40 + 8 gap) */
  right: 12px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  color: var(--app-fg);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  min-width: 176px;
  font-family: "Fira Code", ui-monospace, monospace;
}
#choropleth-switch label {
  font-size: 10px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
#choropleth-switch select {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  color: var(--app-fg);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#choropleth-switch[hidden] { display: none; }

/* ---- SNCZI (flood zones) overlay toggle (Task #19 P1) ----
   Small pill-button next to the choropleth switch. Active state uses the
   blue-ish accent so the user knows the raster is on. */
#inundable-toggle {
  position: fixed;
  top: 296px; /* below choropleth-switch */
  right: 12px;
  width: 40px;
  height: 40px;
  z-index: 1100;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  color: var(--app-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  padding: 0;
  font-size: 20px;
  line-height: 1;
}
#inundable-toggle:hover { background: var(--surface-hover); }
#inundable-toggle.active {
  background: rgba(59, 130, 246, 0.28);
  border-color: #60a5fa;
}
/* 2026-07-31 fix: MITECO WMS is intermittently broken (500s / null-ref);
   show a warning state so the icon signals the upstream is unavailable. */
#inundable-toggle.unavailable {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.55);
  opacity: 0.75;
}

/* ---- Panel: municipio context block (Task #19 §2.3 #7) ---- */
.panel-muni-context {
  margin: 14px 0 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border-2);
}
.panel-muni-context .muni-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  opacity: 0.7;
  margin-bottom: 6px;
}
.panel-muni-context .muni-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.panel-muni-context .muni-stats {
  display: flex;
  gap: 14px;
  font-size: 12px;
  opacity: 0.85;
  flex-wrap: wrap;
}
.panel-muni-context .muni-compare {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.75;
}

/* ======================================================================
 * Wave C1 — Bookmarks / Compare / Property export
 * ==================================================================== */

/* Panel header actions — houses star + close, absolutely positioned so the
 * existing h2 padding-right:32px keeps working. */
#panel .panel-header-actions {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  gap: 6px;
  z-index: 2;
}
#panel .panel-star-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 0;
  color: rgba(235, 235, 235, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s, background 0.15s;
}
#panel .panel-star-btn:hover { background: rgba(255, 255, 255, 0.12); color: rgba(235, 235, 235, 0.85); }
#panel .panel-star-btn.active {
  color: #facc15;
  background: rgba(250, 204, 21, 0.14);
}
#panel .panel-star-btn.active:hover { background: rgba(250, 204, 21, 0.22); }
[data-theme="light"] #panel .panel-star-btn { background: rgba(0, 0, 0, 0.05); color: rgba(15, 23, 42, 0.4); }
[data-theme="light"] #panel .panel-star-btn:hover { background: rgba(0, 0, 0, 0.1); color: rgba(15, 23, 42, 0.85); }
[data-theme="light"] #panel .panel-star-btn.active { color: #d97706; background: rgba(217, 119, 6, 0.14); }
/* When header-actions exist, existing .close-btn shouldn't also be absolute. */
#panel .panel-header-actions .close-btn {
  position: static;
  top: auto;
  right: auto;
}

/* Panel tools row (add-to-compare + export dropdown). */
.panel-tools {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.panel-tool-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: #ebebeb;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
}
.panel-tool-btn:hover { background: rgba(255, 255, 255, 0.1); }
.panel-tool-btn.active {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.6);
  color: #dbeafe;
}
[data-theme="light"] .panel-tool-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.15);
  color: #0f172a;
}
[data-theme="light"] .panel-tool-btn:hover { background: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .panel-tool-btn.active {
  background: rgba(29, 78, 216, 0.14);
  color: #1d4ed8;
}

/* Export menu (dropdown). */
.export-menu-wrap { position: relative; }
.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 140px;
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 4px;
  box-shadow: var(--shadow);
  z-index: 20;
  display: none;
  flex-direction: column;
}
.export-menu.open { display: flex; }
.export-menu button {
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
}
.export-menu button:hover { background: var(--surface-hover); }

/* Bookmarks toolbar button — top-right, next to theme toggle.
   2026-07-31 fix: was at (right:12, top:204) which overlapped the first
   button of #draw-toolbar (draw-polygon-btn) at the same coordinates,
   so bookmarks clicks were intercepted. Moved to right:60 (immediately
   left of theme-toggle at right:12) and raised z-index. */
#bookmarks-btn {
  position: fixed;
  top: 108px; /* same row as theme-toggle */
  right: 60px; /* left of theme-toggle (which is at right:12, width:40 + 8 gap) */
  width: 40px;
  height: 40px;
  z-index: 1150;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  color: var(--app-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  padding: 0;
  font-size: 18px;
  line-height: 1;
}
#bookmarks-btn:hover { background: var(--surface-hover); }
#bookmarks-btn .bookmarks-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #ef4444;
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Bookmarks panel (right slide-in, mirrors #list-view). */
#bookmarks-view {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 90vw;
  background: rgba(15, 23, 42, 0.96);
  color: #ebebeb;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1150;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}
#bookmarks-view[hidden] { display: none; }
[data-theme="light"] #bookmarks-view {
  background: rgba(255, 255, 255, 0.97);
  color: #0f172a;
  border-left-color: rgba(0, 0, 0, 0.1);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
}
#bookmarks-view .close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  z-index: 2;
}
#bookmarks-view .close-btn:hover { background: rgba(255, 255, 255, 0.16); }
[data-theme="light"] #bookmarks-view .close-btn { background: rgba(0, 0, 0, 0.06); }
[data-theme="light"] #bookmarks-view .close-btn:hover { background: rgba(0, 0, 0, 0.12); }
.bookmarks-header {
  padding: 14px 52px 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
[data-theme="light"] .bookmarks-header { border-bottom-color: rgba(0, 0, 0, 0.1); }
.bookmarks-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.bookmarks-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
#bookmarks-search {
  flex: 1 1 160px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: inherit;
  font-size: 12px;
  font-family: inherit;
  min-width: 0;
}
[data-theme="light"] #bookmarks-search { background: #fff; border-color: rgba(0, 0, 0, 0.15); }
#bookmarks-sort {
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: inherit;
  font-size: 12px;
  font-family: inherit;
}
[data-theme="light"] #bookmarks-sort { background: #fff; border-color: rgba(0, 0, 0, 0.15); }
.bookmarks-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.bookmarks-empty {
  padding: 32px 20px;
  text-align: center;
  opacity: 0.6;
  font-size: 13px;
}
.bookmark-row {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
[data-theme="light"] .bookmark-row { border-bottom-color: rgba(0, 0, 0, 0.05); }
.bookmark-row:hover { background: rgba(250, 204, 21, 0.10); }
.bookmark-row-main { flex: 1; min-width: 0; }
.bookmark-row-primary {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bookmark-row-rc {
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 11px;
  color: rgba(147, 197, 253, 0.75);
  margin-bottom: 3px;
}
[data-theme="light"] .bookmark-row-rc { color: rgba(29, 78, 216, 0.75); }
.bookmark-row-stats {
  display: flex;
  gap: 4px;
  font-size: 11px;
  opacity: 0.7;
  flex-wrap: wrap;
}
.bookmark-row-remove {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 0;
  color: rgba(235, 235, 235, 0.6);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}
.bookmark-row-remove:hover { background: rgba(239, 68, 68, 0.25); color: #fff; }
.bookmarks-footer {
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
[data-theme="light"] .bookmarks-footer { border-top-color: rgba(0, 0, 0, 0.1); }
.bookmarks-footer button,
.bookmarks-footer .bookmarks-import-btn {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.bookmarks-footer button:hover,
.bookmarks-footer .bookmarks-import-btn:hover { background: rgba(255, 255, 255, 0.1); }
.bookmarks-footer .bookmarks-clear-btn { margin-left: auto; color: #fca5a5; }
.bookmarks-footer .bookmarks-clear-btn:hover { background: rgba(239, 68, 68, 0.2); }
[data-theme="light"] .bookmarks-footer button,
[data-theme="light"] .bookmarks-footer .bookmarks-import-btn {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .bookmarks-footer .bookmarks-clear-btn { color: #b91c1c; }

/* Compare floating toggle (bottom-center, appears when >=2). */
#compare-toggle-btn {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: #3b82f6;
  color: #fff;
  border: 0;
  border-radius: 24px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
  z-index: 1180;
  transition: transform 0.15s, box-shadow 0.15s;
}
#compare-toggle-btn:hover { background: #2563eb; box-shadow: 0 8px 26px rgba(59, 130, 246, 0.55); }
#compare-toggle-btn[hidden] { display: none; }

/* Compare fullscreen overlay. */
#compare-view {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.85);
  z-index: 1250;
  overflow-y: auto;
  backdrop-filter: blur(4px);
  padding: 40px 20px;
}
#compare-view[hidden] { display: none; }
[data-theme="light"] #compare-view { background: rgba(15, 23, 42, 0.55); }
.compare-shell {
  max-width: 1400px;
  margin: 0 auto;
  background: rgba(15, 23, 42, 0.98);
  color: #ebebeb;
  border-radius: 12px;
  padding: 20px 24px 32px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
[data-theme="light"] .compare-shell {
  background: #fff;
  color: #0f172a;
}
.compare-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 12px;
}
[data-theme="light"] .compare-topbar { border-bottom-color: rgba(0, 0, 0, 0.08); }
.compare-title { font-size: 16px; font-weight: 600; }
.compare-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.compare-actions button {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.compare-actions button:hover { background: rgba(255, 255, 255, 0.1); }
[data-theme="light"] .compare-actions button {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.15);
}
.compare-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.compare-close:hover { background: rgba(255, 255, 255, 0.16); }
.compare-hint {
  font-size: 12px;
  opacity: 0.65;
  margin-bottom: 14px;
}
.compare-empty {
  padding: 40px 20px;
  text-align: center;
  opacity: 0.65;
  font-size: 14px;
}
.compare-grid {
  display: grid;
  gap: 12px;
  align-items: stretch;
}
.compare-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s;
}
.compare-card:hover { border-color: rgba(59, 130, 246, 0.4); }
[data-theme="light"] .compare-card {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}
.compare-card-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  border: 0;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.compare-card-remove:hover { background: rgba(239, 68, 68, 0.4); color: #fff; }
.compare-card-title {
  font-size: 14px;
  font-weight: 600;
  padding-right: 24px;
  line-height: 1.3;
}
.compare-card-rc {
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 11px;
  color: rgba(147, 197, 253, 0.85);
}
[data-theme="light"] .compare-card-rc { color: #1d4ed8; }
.compare-card-thumb {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(59, 130, 246, 0.04);
}
.compare-thumb-svg { display: block; width: 100%; height: 60px; }
.compare-card-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.compare-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid transparent;
}
[data-theme="light"] .compare-stat { background: rgba(0, 0, 0, 0.03); }
.compare-stat.compare-diff {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.08);
}
.compare-stat-label { opacity: 0.65; }
.compare-stat-val { font-weight: 600; }
.compare-sv {
  border: 0;
  width: 100%;
  height: 140px;
  border-radius: 6px;
}
