:root { --ink: #17212b; --muted: #64748b; --accent: #2563eb; --line: #e2e8f0; }
* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; height: 100vh; height: 100dvh; color: var(--ink); background: #f8fafc; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.app-header { flex: 0 0 3.5rem; z-index: 2; }
.brand { font-size: 1.1rem; font-weight: 650; white-space: nowrap; }
.brand-mark { display: block; flex-shrink: 0; width: 2rem; height: 2rem; background: #da291c; }
.main-nav .nav-link { padding: .5rem .65rem; font-size: .9rem; color: var(--muted); font-weight: 500; white-space: nowrap; }
.main-nav .active { color: var(--accent); background: #eff6ff; border-radius: .375rem; }
.unavailable { cursor: default; }
.header-note { font-size: .8rem; color: var(--muted); }
.app-main { min-height: 0; overflow: hidden; }
.map-panel { flex: 1 1 0; min-width: 0; min-height: 0; background: #e9eef0; }
#map { position: absolute; inset: 0; }
.map-caption { position: absolute; top: 1rem; left: 1rem; padding: .55rem .8rem; border: 1px solid #e2e8f0; border-radius: .5rem; background: #fffffff2; box-shadow: 0 2px 8px #17212b0a; font-size: .75rem; pointer-events: none; }
.legend-symbol { display: inline-block; margin-right: .4rem; vertical-align: middle; }
.legend-symbol-point { width: .5rem; height: .5rem; border-radius: 50%; background: #2563eb; }
.legend-symbol-line { width: 1.1rem; height: 0; border-top: 2px solid #1d4ed8; }
.legend-symbol-polygon { width: 1rem; height: .75rem; border: 2px solid #1d4ed8; background: rgb(37 99 235 / 12%); }
.boundary-legend { display: grid; gap: .35rem; min-width: 9rem; pointer-events: auto; }
.boundary-legend-title { margin-bottom: .15rem; font-size: .72rem; font-weight: 650; }
.boundary-legend label { display: flex; align-items: center; gap: .45rem; margin: 0; color: var(--ink); cursor: pointer; line-height: 1.25; }
.boundary-legend input { width: .85rem; height: .85rem; margin: 0; accent-color: var(--accent); }
.boundary-popup { display: grid; gap: .2rem; min-width: 9rem; }
.boundary-popup-heading { display: flex; align-items: center; gap: .55rem; padding-right: 1rem; }
.boundary-popup .boundary-popup-detail-link { color: var(--ink); font-size: inherit; text-decoration: none; }
.boundary-popup .boundary-popup-detail-link:hover { opacity: .72; text-decoration: none; }
.boundary-popup-heading img { width: 34px; max-height: 40px; object-fit: contain; flex-shrink: 0; }
.boundary-popup strong { font-size: .85rem; }
.boundary-popup span { color: var(--muted); font-size: .7rem; }
.boundary-popup-parents { display: grid; gap: .18rem; margin-top: .35rem; }
.boundary-popup-parent { display: flex; align-items: baseline; gap: .2rem; white-space: nowrap; }
.boundary-popup a { color: var(--accent); font-size: .75rem; text-decoration: none; }
.boundary-popup a:hover { text-decoration: underline; }
.boundary-popup-actions { display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin-top: .4rem; padding-top: .4rem; border-top: 1px solid var(--line); }
.boundary-hover-popup { pointer-events: none; }
.boundary-hover-popup .mapboxgl-popup-content { padding: .5rem .65rem; }
.boundary-hover-content { display: grid; gap: .15rem; }
.boundary-hover-content strong { color: var(--ink); font-size: .8rem; }
.boundary-hover-content span { color: var(--muted); font-size: .68rem; }
.mapboxgl-popup-content { padding: .7rem .8rem .75rem; border-radius: .6rem; box-shadow: 0 4px 18px rgb(15 23 42 / 16%); }
.mapboxgl-popup-close-button { top: .2rem; right: .25rem; width: 1.4rem; height: 1.4rem; border-radius: 50%; color: var(--muted); font-size: 1.1rem; line-height: 1.2rem; }
.mapboxgl-popup-close-button:hover { background: #f1f5f9; color: var(--ink); }
.map-status { position: absolute; left: 1rem; right: 1rem; bottom: 3rem; width: fit-content; max-width: calc(100% - 2rem); margin: 0; padding: .65rem .85rem; border-radius: .5rem; background: white; color: var(--muted); font-size: .85rem; }
.directory-panel { flex: 0 0 430px; width: 430px; min-width: 0; min-height: 0; border-left: 1px solid var(--line); }
.directory-heading { padding: 1.6rem 1.5rem 0; flex-shrink: 0; }
.eyebrow { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 650; margin-bottom: .75rem; }
h1 { font-size: 1.8rem; font-weight: 650; letter-spacing: -.045em; }
.count-badge { color: #1d4ed8; background: #eff6ff; border: 1px solid #dbeafe; padding: .15rem .5rem; border-radius: 2rem; font-size: .8rem; }
.intro { color: var(--muted); line-height: 1.6; font-size: .875rem; margin: .6rem 0 1.2rem; }
.download-panel { margin-bottom: 1.25rem; padding: 1rem; border: 1px solid var(--line); border-radius: .5rem; background: #f8fafc; }
.download-panel h2 { margin: 0 0 .35rem; font-size: .875rem; font-weight: 650; }
.download-panel p { margin: 0 0 .75rem; color: var(--muted); font-size: .75rem; }
.download-panel .btn { font-size: .75rem; padding: .45rem .65rem; }
.download-panel small { display: block; margin-top: .65rem; font-size: .7rem; line-height: 1.5; color: var(--muted); }
.selection-download { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.selection-download-status { display: block; margin-top: .4rem; color: var(--muted); font-size: .7rem; }
.form-control { font-size: .875rem; min-height: 2.7rem; border-color: var(--line); background: #f8fafc; }
.list-meta { font-size: .72rem; color: var(--muted); padding: 1rem 0 .7rem; border-bottom: 1px solid var(--line); }
.filter-count-badge { width: fit-content; padding: .18rem .5rem; border: 1px solid #bfdbfe; border-radius: 999px; background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.directory-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 1.5rem; flex: 1; }
.picked-directory { border-bottom: 2px solid #facc15; }
.directory-group-title { position: sticky; top: 0; z-index: 2; margin: 0; padding: .8rem 0 .65rem; background: white; font-size: .9rem; font-weight: 650; }
.directory-group-title span { color: var(--muted); font-weight: 500; }
.selected-group-title { z-index: 3; }
.selected-group-title:not([hidden]) ~ .rest-directory .directory-group-title { top: 2.4rem; }
.picked-directory .canton-item:last-child { border-bottom: 0; }
.canton-item { display: flex; align-items: center; gap: .9rem; padding: .9rem 0; border-bottom: 1px solid #edf1f5; }
.canton-item[hidden] { display: none; }
.canton-coat-of-arms { flex: 0 0 40px; width: 40px; height: auto; object-fit: contain; }
.canton-details { min-width: 0; }
.canton-details h2 { margin: 0 0 .25rem; font-size: .9rem; font-weight: 600; line-height: 1.4; }
.canton-details h2 a { color: inherit; text-decoration: none; }
.canton-details h2 a:hover { color: var(--accent); text-decoration: underline; }
.canton-details h2 a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.canton-details p { margin: 0; color: var(--muted); font-size: .73rem; }
.canton-details .canton-stats { margin-top: .3rem; font-variant-numeric: tabular-nums; }
.canton-stats a { color: var(--accent); text-decoration: none; }
.canton-stats a:hover { text-decoration: underline; }
.canton-stats > span:not(.detail-separator) { white-space: nowrap; }
.detail-separator { margin: 0 .2rem; color: #94a3b8; }
.canton-next { color: var(--muted); margin-left: auto; flex: 0 0 32px; align-self: stretch; display: grid; place-items: center; font-size: 1.65rem; text-decoration: none; border-radius: .25rem; }
.canton-next:hover { color: var(--accent); background: #eff6ff; }
.canton-next:focus-visible, .back-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.detail-scroll { overflow-y: auto; padding: 1.5rem; min-height: 0; }
.back-link { display: inline-block; margin-bottom: 1.5rem; color: var(--accent); font-size: .9rem; text-decoration: none; }
.detail-title { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.detail-title h1 { margin: 0; overflow-wrap: anywhere; font-size: 1.7rem; }
.detail-coat-of-arms { width: 85px; height: auto; object-fit: contain; flex-shrink: 0; }
.detail-code { margin: 0 0 .4rem; color: var(--muted); font-size: .875rem; }
.canton-facts { margin: 0 0 1.5rem; font-size: .9rem; }
.canton-facts > div { display: flex; justify-content: space-between; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.canton-facts dt { color: var(--muted); font-weight: 400; }
.canton-facts dd { margin: 0; text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; }
.canton-facts dd a { color: var(--accent); text-decoration: none; }
.canton-facts dd a:hover { text-decoration: underline; }
.canton-facts small { display: block; margin-top: .25rem; color: var(--muted); font-size: .75rem; font-weight: 400; }
.detail-downloads .btn { display: block; margin-top: .65rem; font-size: .875rem; padding: .6rem; }
.detail-downloads h2 { font-size: 1rem; }
.detail-downloads .coat-credit { display: block; margin: .55rem 0 .9rem; font-size: .75rem; line-height: 1.6; overflow-wrap: anywhere; }
.external-references { margin: 1.2rem 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.external-references h2 { margin: 0 0 .55rem; font-size: 1rem; }
.external-references .reference-links { display: grid; justify-items: start; gap: .65rem; }
.external-references a { color: var(--accent); font-size: .8rem; text-decoration: none; }
.external-references a:hover { text-decoration: underline; }
.wikipedia-reference { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .8rem; }
.segmented-links { display: inline-flex; overflow: hidden; border: 1px solid #bfdbfe; border-radius: .4rem; background: white; }
.segmented-links a { padding: .3rem .5rem; white-space: nowrap; }
.segmented-links a + a { border-left: 1px solid #bfdbfe; }
.segmented-links a:hover { background: #eff6ff; text-decoration: none; }
.mask-option { display: flex; align-items: center; gap: .45rem; margin-top: .65rem; font-size: .875rem; cursor: pointer; width: fit-content; }
.mask-option input { width: 1rem; height: 1rem; accent-color: var(--accent); }
.map-caption-detail { max-width: calc(100% - 5rem); }
.map-caption-detail .mask-option { pointer-events: auto; font-size: .65rem; color: var(--muted); margin: .4rem 0 0 auto; gap: .35rem; }
.map-caption-detail .mask-option input { width: .8rem; height: .8rem; }
.detail-downloads .mask-status { margin-top: .6rem; }
.canton-subdivisions { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.canton-subdivisions h2 { margin: 0 0 .55rem; font-size: 1rem; }
.canton-subdivisions h2 span { color: var(--muted); font-weight: 500; }
.canton-subdivisions h2 a { color: inherit; text-decoration: none; }
.canton-subdivisions h2 a:hover { color: var(--accent); text-decoration: underline; }
.subdivision-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .25rem .75rem; margin: 0; padding: 0; list-style: none; }
.district-links { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.district-links::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--line); pointer-events: none; }
.district-column { display: grid; grid-template-columns: 1fr; align-content: start; gap: .25rem; }
.district-column + .district-column { padding-left: .5rem; }
.subdivision-list a { color: var(--ink); font-size: .78rem; line-height: 1.3; text-decoration: none; }
.subdivision-list a:hover { color: var(--accent); text-decoration: underline; }
.subdivision-list small { color: var(--muted); font-size: .68rem; white-space: nowrap; }
.municipality-links { grid-template-columns: 1fr; }
.municipality-links a, .canton-links a { display: flex; align-items: center; gap: .55rem; min-height: 2.25rem; padding: .2rem 0; }
.municipality-links img, .canton-links img { width: 30px; max-height: 34px; object-fit: contain; flex: 0 0 30px; }
.canton-links { grid-template-columns: 1fr; }
.subdivision-text small { display: block; margin-top: .1rem; }
.canton-subdivision-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: .55rem; min-height: 2.6rem; }
.canton-subdivision-emblem { align-self: stretch; display: grid !important; place-items: center; }
.canton-subdivision-name { display: inline; font-size: .82rem !important; font-weight: 550; }
.canton-subdivision-item p { display: flex; flex-wrap: wrap; align-items: baseline; margin: .08rem 0 0; color: var(--muted); font-size: .68rem; }
.canton-subdivision-item p a { display: inline; min-height: 0; padding: 0; color: var(--accent); font-size: inherit; }
#boundary-download[aria-disabled="true"] { opacity: .65; cursor: wait; }
.directory-note, .empty-state { font-size: .75rem; line-height: 1.6; color: var(--muted); padding: 1.2rem 0; margin: 0; }
.detail-metadata { margin-top: 1.2rem; border-top: 1px solid var(--line); }
.app-footer { flex: 0 0 2.25rem; color: var(--muted); }
.app-footer small { font-size: .72rem; }
@media (max-width: 1050px) { .header-note { display: none; } .directory-panel { flex-basis: 380px; width: 380px; } }
@media (max-width: 767.98px) {
  body { min-height: 100dvh; height: auto; }
  .app-header { padding: .7rem 0; }
  .app-header > div { flex-wrap: wrap; gap: .5rem !important; }
  .main-nav { overflow-x: auto; width: 100%; }
  .main-nav .nav-link { padding: .45rem .6rem; font-size: .82rem; }
  .app-main { overflow: visible; }
  .map-panel { flex: none; height: 38vh; min-height: 250px; }
  .directory-panel { flex: none; width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  .directory-scroll { overflow: visible; }
  .app-footer { padding-top: .65rem; padding-bottom: .65rem; flex-wrap: wrap; }
}

.country-sections { margin: 1rem 0 0; padding: 0; border: 0; min-width: 0; }
.country-section + .country-section { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 2px solid var(--line); }
.country-section-label { display: flex; align-items: center; gap: .55rem; font-size: .85rem; font-weight: 600; cursor: pointer; }
.country-section-label input { width: 1rem; height: 1rem; accent-color: var(--accent); }
.country-section .canton-list { margin-left: 1.55rem; }
.country-section .canton-item:last-child { border-bottom: 0; }
.home-heading { padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.home-heading .intro { margin-bottom: 0; }
.home-search { margin-top: 1.1rem; }
.home-search .btn { font-size: .85rem; }
.home-scroll { padding-top: 1rem; }
.source-download { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: 1.2rem; padding: .85rem; border-radius: .5rem; background: #eff6ff; }
.source-download h2, .source-download p { margin: 0; }
.source-download h2 { font-size: .84rem; font-weight: 650; }
.source-download p { margin-top: .2rem; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.source-download .btn { flex-shrink: 0; font-size: .72rem; white-space: nowrap; }
.source-download-secondary { margin: .2rem 0 0; background: #f8fafc; }
.home-metadata { padding-top: .9rem; }
.dataset-heading { margin: 0 0 .5rem; color: var(--muted); font-size: .72rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.dataset-grid { display: grid; border-top: 1px solid var(--line); }
.dataset-card { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.dataset-card strong, .dataset-card small { display: block; }
.dataset-card strong { font-size: .84rem; }
.dataset-card small { margin-top: .1rem; color: var(--muted); font-size: .68rem; }
.dataset-actions { display: flex; align-items: center; gap: .7rem; flex-shrink: 0; font-size: .72rem; }
.dataset-actions a { color: var(--accent); text-decoration: none; white-space: nowrap; }
.dataset-actions a:hover { text-decoration: underline; }
.dataset-actions a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 420px) {
  .directory-heading { padding: 1.25rem 1rem 0; }
  .directory-scroll { padding-right: 1rem; padding-left: 1rem; }
  .source-download { align-items: flex-start; }
  .dataset-actions { gap: .5rem; }
}
.text-directory { max-width: 1180px; padding: 2.5rem 2rem; }
.text-directory-header { max-width: 680px; }
.directory-groups { display: grid; gap: 2.5rem; margin-top: 2rem; }
.directory-group h2 { padding-bottom: .6rem; border-bottom: 1px solid var(--line); font-size: 1.25rem; }
.directory-group h3 { margin: 1.5rem 0 .5rem; color: var(--muted); font-size: .8rem; letter-spacing: .08em; }
.directory-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 1.5rem; margin: 0; padding: 0; list-style: none; }
.directory-link { padding: .55rem 0; }
.directory-link a { display: flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; }
.directory-link img { flex: 0 0 28px; max-height: 32px; object-fit: contain; }
.directory-link a:hover strong { color: var(--accent); text-decoration: underline; }
.directory-link strong, .directory-link small { display: block; }
.directory-link strong { font-size: .84rem; font-weight: 600; }
.directory-link small { margin-top: .15rem; color: var(--muted); font-size: .7rem; }
