/* Web Map Kit: change the look here. Colours and sizes are set once as variables. */
:root {
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f1f5f9;
  --accent: #0f766e;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .12);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; }
#map { position: absolute; inset: 0; }
button { font-family: inherit; }

/* Loading bar */
#loading { position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 10; overflow: hidden; opacity: 0; transition: opacity .3s; }
#loading.on { opacity: 1; }
#loading::after { content: ""; position: absolute; top: 0; left: -40%; width: 40%; height: 100%; background: var(--accent); animation: wm-load 1.1s ease-in-out infinite; }
@keyframes wm-load { to { left: 100%; } }

/* Title */
#titlebar {
  position: absolute; top: 12px; left: 12px; max-width: min(400px, calc(100% - 440px)); min-width: 200px; z-index: 2;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px;
}
#title { font-size: 16px; font-weight: 650; margin: 0; line-height: 1.3; letter-spacing: -.01em; }
#description { font-size: 13px; color: var(--muted); margin: 3px 0 0; line-height: 1.45; }
#description:empty { display: none; }

/* Search */
#search { position: absolute; top: 12px; right: 60px; width: 320px; z-index: 3; }
.search-icon { position: absolute; left: 12px; top: 11px; width: 18px; height: 18px; fill: var(--muted); pointer-events: none; }
#search-input {
  width: 100%; padding: 10px 12px 10px 38px; font: 15px var(--font); color: var(--ink);
  border: 1px solid transparent; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--panel); outline: none;
}
#search-input:focus { border-color: var(--accent); }
#search-results { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 50vh; overflow: auto; }
#search-results:empty { display: none; }
#search-results li { padding: 8px 10px; cursor: pointer; font-size: 14px; border-radius: 8px; display: flex; justify-content: space-between; gap: 8px; }
#search-results li[aria-selected="true"], #search-results li:hover { background: var(--soft); }
#search-results small { color: var(--muted); font-size: 12px; }

/* Legend */
#legend {
  position: absolute; right: 12px; bottom: 32px; z-index: 2; width: 240px; max-height: calc(100% - 200px); overflow: auto;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; font-size: 13px;
}
#legend h2 { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 6px; }
.lg-layer { padding: 8px 0; border-top: 1px solid var(--line); }
.lg-layer:first-of-type { border-top: 0; padding-top: 2px; }
.lg-head { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; color: var(--ink); }
.lg-head input { accent-color: var(--accent); margin: 0; width: 15px; height: 15px; }
.lg-name { flex: 1; }
.lg-headrow { display: flex; align-items: center; gap: 4px; }
.lg-headrow .lg-head { flex: 1; min-width: 0; }
.lg-opbtn { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.lg-opbtn svg { width: 15px; height: 15px; }
.lg-opbtn:hover, .lg-opbtn.active { background: var(--soft); color: var(--ink); }
.lg-opacity { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px 23px; }
.lg-opacity[hidden] { display: none; }
.lg-opacity input { flex: 1; accent-color: var(--accent); height: 18px; margin: 0; }
.lg-oppct { width: 36px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lg-items { list-style: none; margin: 6px 0 0 23px; padding: 0; }
.lg-items li { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--ink-2); }
.lg-size { margin: 8px 0 2px 23px; }
.lg-size-title { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.lg-size svg { display: block; overflow: visible; }
.lg-layer.off .lg-items, .lg-layer.off .sw-wrap { opacity: .4; }
.sw-wrap { flex: none; width: 20px; min-height: 14px; display: inline-flex; justify-content: center; align-items: center; }
.sw { display: inline-block; background: var(--c); }
.sw-polygon { width: 18px; height: 13px; border-radius: 3px; border: 1.5px solid var(--o); }
.sw-line { width: 18px; height: 4px; border-radius: 2px; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px var(--line); }
.sw-point { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .35); }

#legend-toggle {
  display: none; position: absolute; right: 12px; bottom: 32px; z-index: 3; align-items: center; gap: 6px;
  background: var(--panel); color: var(--ink); border: 0; border-radius: 999px; box-shadow: var(--shadow);
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
#legend-toggle svg { width: 17px; height: 17px; fill: currentColor; }
#legend-toggle.active { background: var(--ink); color: #fff; }

/* Hover tooltip */
#tooltip {
  position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none; max-width: 240px;
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 500; padding: 5px 9px; border-radius: 7px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Notice */
#notice {
  position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 6; max-width: calc(100% - 24px);
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow);
}

/* Map controls: softer look */
.maplibregl-ctrl-group { border-radius: 10px !important; box-shadow: var(--shadow) !important; overflow: hidden; }
.maplibregl-ctrl-group button { width: 34px; height: 34px; }
.maplibregl-ctrl-scale { border-radius: 0 0 4px 4px; font-family: var(--font); }

/* ---- Feature card (popup + mobile sheet) ---- */
.maplibregl-popup { z-index: 4; }
.wm-popup .maplibregl-popup-content { padding: 0; border-radius: 14px; box-shadow: 0 2px 4px rgba(15, 23, 42, .08), 0 12px 32px rgba(15, 23, 42, .18); overflow: hidden; }
.wm-popup .maplibregl-popup-close-button { width: 28px; height: 28px; top: 8px; right: 8px; font-size: 20px; line-height: 1; color: var(--muted); border-radius: 8px; z-index: 2; background: rgba(255, 255, 255, .85); }
.wm-popup .maplibregl-popup-close-button:hover { background: var(--soft); color: var(--ink); }

.wm-card { width: 300px; max-width: 100%; font-size: 13.5px; color: var(--ink); border-top: 4px solid var(--c); }
.wm-head { display: flex; gap: 12px; align-items: center; padding: 14px 44px 10px 16px; }
.wm-badge { flex: none; width: 34px; height: 34px; display: grid; place-items: center; }
.wm-badge svg { display: block; }
.wm-badge.plain { border-radius: 10px; background: color-mix(in srgb, var(--c) 16%, white); }
.wm-dot { display: block; background: var(--c); }
.wm-dot-polygon { width: 16px; height: 12px; border-radius: 3px; }
.wm-dot-line { width: 18px; height: 4px; border-radius: 2px; }
.wm-dot-point { width: 12px; height: 12px; border-radius: 50%; }
.wm-htext { min-width: 0; }
.wm-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.wm-chip { text-transform: none; letter-spacing: 0; font-size: 11.5px; font-weight: 600; color: var(--ink-2); padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 18%, white); }
.wm-title { margin: 3px 0 0; font-size: 16px; font-weight: 650; line-height: 1.3; letter-spacing: -.01em; overflow-wrap: anywhere; }

.wm-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 4px 16px 0; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.wm-row { background: #fff; padding: 8px 10px; min-width: 0; }
.wm-row.wide { grid-column: 1 / -1; }
.wm-row:last-child:nth-child(odd) { grid-column: 1 / -1; }
.wm-row dt { font-size: 11px; color: var(--muted); margin: 0 0 2px; font-weight: 500; }
.wm-row dd { margin: 0; font-weight: 550; color: var(--ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.wm-row dd a { color: var(--accent); }

.wm-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 14px; }
.wm-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; border: 1px solid var(--ink); background: var(--ink); color: #fff; }
.wm-btn:hover { opacity: .9; }
.wm-btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.wm-btn.ghost:hover { background: var(--soft); opacity: 1; }
.wm-btn:focus-visible, .wm-pager button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wm-pager { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding: 6px 10px; font-size: 12px; color: var(--muted); background: #fbfcfd; }
.wm-pager button { width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; font-size: 18px; color: var(--ink-2); cursor: pointer; }
.wm-pager button:hover { background: var(--soft); }

/* Mobile bottom sheet */
#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 8; max-height: 62vh; overflow: auto;
  background: #fff; border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(15, 23, 42, .2);
  transform: translateY(105%); transition: transform .25s ease; padding-bottom: env(safe-area-inset-bottom);
}
#sheet.open { transform: translateY(0); }
.sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; }
#sheet-close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--soft); font-size: 22px; line-height: 1; color: var(--ink-2); cursor: pointer; z-index: 2; }
#sheet .wm-card { width: 100%; border-top: 0; }
#sheet .wm-head { padding-top: 10px; }

@media (max-width: 640px) {
  #titlebar { top: auto; bottom: 28px; left: 12px; max-width: calc(100% - 140px); min-width: 0; padding: 9px 13px; }
  #title { font-size: 14.5px; }
  #description { display: none; }
  #search { left: 12px; right: 58px; width: auto; transform: none; }
  #legend-toggle { display: inline-flex; bottom: 28px; }
  #legend { display: none; bottom: 84px; width: calc(100% - 24px); max-height: 52vh; }
  #legend.open { display: block; }
  #tooltip { display: none; }
}
@media (hover: none) { #tooltip { display: none; } }
