:root {
  --ui-bg: #ffffff;
  --ui-fg: #1c2330;
  --ui-muted: #63708a;
  --ui-line: #e6e9f0;
  --ui-shadow: 0 6px 24px rgba(20, 32, 60, 0.16);
  --accent: #b4442e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
#map { position: absolute; inset: 0; }

/* --- Floating panel --- */
#panel {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  width: min(300px, calc(100vw - 32px));
  background: var(--ui-bg);
  color: var(--ui-fg);
  border: 1px solid var(--ui-line);
  border-radius: 14px;
  box-shadow: var(--ui-shadow);
  padding: 16px 18px;
}
#panel header { margin-bottom: 10px; }
#panel h1 { font-size: 18px; margin: 0; letter-spacing: -0.01em; }
#panel p { margin: 2px 0 0; font-size: 13px; color: var(--ui-muted); }

.legend { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.legend button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 6px 8px;
  background: transparent; border: 0; border-radius: 8px;
  font: inherit; font-size: 13px; color: var(--ui-fg);
  text-align: left; cursor: pointer;
}
.legend button:hover { background: #f4f6fa; }
.legend button[aria-pressed="false"] { opacity: 0.42; }
.legend .swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(255,255,255,0.85); }
.legend .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .n { color: var(--ui-muted); font-variant-numeric: tabular-nums; }

.count { margin-top: 10px !important; padding-top: 10px; border-top: 1px solid var(--ui-line); }

.status {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 10; max-width: 440px;
  background: var(--ui-bg); color: var(--ui-fg);
  border: 1px solid var(--ui-line); border-radius: 12px;
  box-shadow: var(--ui-shadow);
  padding: 20px 24px; font-size: 14px; line-height: 1.5;
}
.status code { background: #f1f3f8; padding: 1px 5px; border-radius: 4px; }
.status a { color: var(--accent); }

/* --- Popups --- */
.maplibregl-popup-content {
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--ui-shadow);
  overflow: hidden auto;          /* safety net: scroll if taller than the map */
  max-height: 86vh;
  font-family: inherit;
}
.maplibregl-popup { max-width: 92vw !important; }  /* never wider than the view */
.maplibregl-popup-close-button { font-size: 18px; padding: 2px 8px; color: var(--ui-muted); }

.pin-preview { display: flex; gap: 10px; padding: 10px; width: 240px; align-items: center; }
.pin-preview img { width: 46px; height: 64px; object-fit: cover; border-radius: 4px; background: #eee; flex: none; }
.pin-preview .t { font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--ui-fg); }
.pin-preview .p { font-size: 12px; color: var(--ui-muted); margin-top: 3px; }

.pin-card { width: 280px; color: var(--ui-fg); }
.pin-card .pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; background: #f4f6fa; border-bottom: 1px solid var(--ui-line); font-size: 12px; color: var(--ui-muted); font-weight: 600; }
.pin-card .pager button { border: 1px solid var(--ui-line); background: #fff; border-radius: 6px; width: 26px; height: 26px; font-size: 13px; cursor: pointer; color: var(--ui-fg); line-height: 1; }
.pin-card .pager button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pin-card .cover { display: block; width: 100%; max-height: 220px; object-fit: contain; background: #f4f6fa; padding: 12px 12px 0; }
.pin-card .body { padding: 12px 14px 14px; }
.pin-card .series {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: #fff; background: var(--accent); padding: 2px 8px; border-radius: 20px; margin-bottom: 8px;
}
.pin-card h2 { font-size: 15px; margin: 0 0 2px; line-height: 1.3; }
.pin-card .sub { font-size: 13px; color: var(--ui-muted); margin: 0 0 8px; }
.pin-card .place { font-size: 13px; margin: 0 0 6px; }
.pin-card .place b { font-weight: 600; }
.pin-card .meta { font-size: 12px; color: var(--ui-muted); margin: 0 0 12px; }
.pin-card .buy {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 10px; border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 14px;
  text-decoration: none;
}
.pin-card .buy:hover { filter: brightness(0.94); }
.pin-card .price { font-variant-numeric: tabular-nums; }
