/* Rådhuset API Browser
   Colours follow the Rådhuset brand: the warm greys of the app icon (#8a897f,
   #636254) carry the interface; teal and amber are reserved for the map and for
   selection, where they have to stand out against the base map. */

@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('../../assets/fonts/figtree-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('../../assets/fonts/figtree-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, 'SF Mono', monospace;

  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --sunken: #efeee9;
  --hover: #f1f0eb;
  --border: #e3e1da;
  --border-subtle: #efede7;
  --border-strong: #d0cdc3;
  --text: #22211c;
  --text-muted: #6b6a60;
  --text-subtle: #8a897f;
  --link: #4f4e42;

  --brand: #636254;
  --brand-hover: #545347;
  --brand-active: #46453b;
  --brand-contrast: #ffffff;
  --brand-soft: #ecebe4;
  --brand-soft-strong: #dfded4;
  --brand-text: #4f4e42;

  --accent: #0b8ea6;
  --row-highlight: #ebeae2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warning-soft: #fbf3dc;
  --warning-border: #ecd9a3;
  --success: #1a7f37;

  --toast-bg: #2b2a24;
  --toast-text: #f4f3ef;

  --map-result: #e0782c;
  --map-checked: #0b8ea6;
  --map-area: #3f3e35;
  --map-bg: #e9e7e0;

  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(34, 33, 28, 0.08);
  --shadow-md: 0 4px 16px rgba(34, 33, 28, 0.12), 0 1px 3px rgba(34, 33, 28, 0.08);
  --shadow-lg: 0 16px 48px rgba(34, 33, 28, 0.2), 0 2px 8px rgba(34, 33, 28, 0.08);
  --focus: 0 0 0 3px rgba(99, 98, 84, 0.3);

  --appbar-height: 52px;
  --sidebar-width: 344px;
  --drawer-width: 400px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1c1c19;
    --surface: #242420;
    --surface-2: #2a2a25;
    --sunken: #191916;
    --hover: #2f2f29;
    --border: #36352f;
    --border-subtle: #2e2d28;
    --border-strong: #4a4940;
    --text: #edece5;
    --text-muted: #aaa99d;
    --text-subtle: #8a897f;
    --link: #d4d3c8;
    --brand: #b9b8aa;
    --brand-hover: #cac9bc;
    --brand-active: #a8a799;
    --brand-contrast: #1c1c19;
    --brand-soft: #34332d;
    --brand-soft-strong: #3f3e36;
    --brand-text: #d4d3c8;
    --accent: #3fb8cc;
    --row-highlight: #36352e;
    --danger: #f97066;
    --danger-soft: #3b211e;
    --warning-soft: #362f1c;
    --warning-border: #5c4f28;
    --success: #4cc26b;
    --toast-bg: #edece5;
    --toast-text: #1c1c19;
    --map-bg: #2a2a25;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
    --focus: 0 0 0 3px rgba(185, 184, 170, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #1c1c19;
  --surface: #242420;
  --surface-2: #2a2a25;
  --sunken: #191916;
  --hover: #2f2f29;
  --border: #36352f;
  --border-subtle: #2e2d28;
  --border-strong: #4a4940;
  --text: #edece5;
  --text-muted: #aaa99d;
  --text-subtle: #8a897f;
  --link: #d4d3c8;
  --brand: #b9b8aa;
  --brand-hover: #cac9bc;
  --brand-active: #a8a799;
  --brand-contrast: #1c1c19;
  --brand-soft: #34332d;
  --brand-soft-strong: #3f3e36;
  --brand-text: #d4d3c8;
  --accent: #3fb8cc;
  --row-highlight: #36352e;
  --danger: #f97066;
  --danger-soft: #3b211e;
  --warning-soft: #362f1c;
  --warning-border: #5c4f28;
  --success: #4cc26b;
  --toast-bg: #edece5;
  --toast-text: #1c1c19;
  --map-bg: #2a2a25;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  --focus: 0 0 0 3px rgba(185, 184, 170, 0.35);
  color-scheme: dark;
}

/* ── Base ───────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 400 14px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--link); text-underline-offset: 2px; }
p { margin: 0; }
strong { font-weight: 650; }
h1, h2, h3 { margin: 0; }

.icon {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error-text { color: var(--danger); font-size: 13px; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 560;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s, color 0.12s;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-primary:not(:disabled):hover { background: var(--brand-hover); }
.btn-primary:not(:disabled):active { background: var(--brand-active); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:not(:disabled):hover { background: var(--hover); }
.btn-ghost { background: transparent; }
.btn-ghost:not(:disabled):hover { background: var(--hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:not(:disabled):hover { filter: brightness(1.08); }
.btn.is-danger { color: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn-lg { height: 42px; font-size: 15px; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn-block { width: 100%; }
.btn[aria-pressed='true'] { background: var(--brand-soft-strong); border-color: var(--brand); color: var(--text); }

.link-button {
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--brand-soft-strong);
  color: var(--brand-text);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex: none;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */

input:not([type='checkbox']):not([type='radio']):not([type='file']),
select,
.qb-multi-summary {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input[readonly] { background: var(--surface-2); color: var(--text-muted); }
input:disabled, select:disabled { opacity: 0.6; }
input::placeholder { color: var(--text-subtle); }
input:focus, select:focus, .qb-multi-summary:focus-visible, .qb-multi-summary.is-open {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus);
}
select, .qb-multi-summary {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a897f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.5 9.5 12 15l5.5-5.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  text-overflow: ellipsis;
}
input[type='checkbox'], input[type='radio'] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type='search']::-webkit-search-cancel-button { cursor: pointer; }

.field { display: grid; gap: 5px; min-width: 0; }
.field > label, .field > span:first-child, legend {
  font-size: 12.5px;
  font-weight: 620;
  color: var(--text-muted);
}
.field-hint { font-size: 12px; color: var(--text-muted); }

.form { display: grid; gap: 14px; }
.form-group { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline-form { display: flex; align-items: flex-end; gap: 8px; }
.inline-form .field { flex: 1; }
.input-row { display: flex; gap: 6px; }
.input-row select { flex: 1; min-width: 0; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }

.input-group { position: relative; }
.input-group input { padding-right: 38px; }
.input-adornment {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.input-adornment:hover { background: var(--hover); color: var(--text); }

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 4px 2px;
  border-radius: 6px;
  cursor: pointer;
}
.check input { margin-top: 2px; }
.check-text { display: grid; min-width: 0; }
.check-sub { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-list { display: grid; gap: 4px; }

.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.choice-cards legend { grid-column: 1 / -1; margin-bottom: 6px; padding: 0; }
.choice-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}
.choice-card > span { display: grid; gap: 2px; }
.choice-card input { margin-top: 2px; }
.choice-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice-card:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }

.or-divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12px; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.notice {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
}
.notice > div { display: grid; gap: 4px; }
.notice .icon { margin-top: 1px; }
.notice-warning { border-color: var(--warning-border); background: var(--warning-soft); }

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 36px 16px;
  color: var(--text-muted);
  text-align: center;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-rows: var(--appbar-height) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.appbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.brand img { width: 28px; height: 28px; flex: none; }
.brand-name { font-size: 16px; font-weight: 680; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}
.appbar-logo {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  flex: none;
}
.appbar-logo img { display: block; height: 100%; width: auto; }
:root[data-theme='dark'] .appbar-logo img { filter: invert(0.92); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .appbar-logo img { filter: invert(0.92); } }
.appbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
#sidebar-toggle { display: none; }

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) auto;
  min-height: 0;
}

.sidebar {
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 10;
}
.sidebar-inner { display: flex; flex-direction: column; height: 100%; }
.sidebar-top { padding: 12px 12px 10px; }
.sidebar-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 12px 12px;
  overflow: auto;
}
.sidebar-footer {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer-row { display: flex; align-items: center; gap: 10px; }
.footer-row label { flex: none; }
.footer-row select { height: 30px; font-size: 13px; }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.card-header { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 8px 0 12px; color: var(--text-muted); }
.card-title { flex: 1; color: var(--text); font-size: 13px; font-weight: 680; }
.card-body { display: grid; gap: 9px; padding: 6px 12px 12px; }
.auth-note { display: flex; align-items: center; gap: 6px; color: var(--text-muted); }

.date-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.date-row input { width: 100%; min-width: 0; height: 32px; font-size: 13px; }

.coll-list {
  display: grid;
  gap: 1px;
  max-height: 264px;
  padding: 4px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.coll-list .check { padding: 5px 6px; font-size: 13px; }
.coll-list .check:hover { background: var(--hover); }

/* ── Map ────────────────────────────────────────────────────────────────── */

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(160px, 1fr) 7px var(--results-height, 300px);
  min-width: 0;
  min-height: 0;
}
.map-area { position: relative; min-height: 0; }
.map { position: absolute; inset: 0; background: var(--map-bg); }
.map.is-drawing, .map.is-drawing canvas { cursor: crosshair !important; }
.basemap-muted .basemap { filter: grayscale(0.92) contrast(0.9) brightness(1.04); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .basemap { filter: brightness(0.86) contrast(1.05); } :root:not([data-theme='light']) .basemap-muted .basemap { filter: grayscale(0.9) brightness(0.8) contrast(1.05); } }
:root[data-theme='dark'] .basemap { filter: brightness(0.86) contrast(1.05); }
:root[data-theme='dark'] .basemap-muted .basemap { filter: grayscale(0.9) brightness(0.8) contrast(1.05); }

.map-tools {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: grid;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.map-tool {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.map-tool:hover { background: var(--hover); }
.map-tool[aria-pressed='true'] { background: var(--brand); color: var(--brand-contrast); }
.map-tools-sep { height: 1px; margin: 2px 4px; background: var(--border); }

.search-area-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* Without an explicit width, an absolutely positioned box with only `left`
     set (not `right`) shrinks-to-fit against just the *half* of the map to
     the right of that 50% mark, not the full width behind the centering
     transform — so it wraps once content passes ~50%, long before actually
     reaching max-width. Asking for the content's natural (unwrapped) width
     up front sidesteps that and lets max-width do the only clamping. */
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
}
.search-area-bar .btn[aria-pressed='true'] { background: var(--brand); color: var(--brand-contrast); }
.search-area-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Its own small floating bar, centred above .search-area-bar — only shown on
   narrow screens (see the 900px breakpoint below), where the sidebar with
   the "real" search button isn't open by default. bottom is pinned rather
   than flowing from .search-area-bar, which stays a separate, independently
   positioned element: 44px tall (30px btn-sm + 12px padding + 2px border) +
   12px base offset + 8px gap. */
.mobile-search-bar {
  position: absolute;
  left: 50%;
  bottom: 64px;
  z-index: 5;
  display: none;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
}

.draw-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 140px);
  padding: 6px 6px 6px 16px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-text);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 540;
}
.draw-hint .btn { color: inherit; }
.draw-hint .btn:hover { background: rgba(127, 127, 127, 0.25); }

.drop-zone {
  position: absolute;
  inset: 12px;
  z-index: 7;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  border: 2px dashed var(--brand);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--text);
  font-weight: 620;
  pointer-events: none;
}

/* OpenLayers controls, restyled. */
.ol-zoom { top: 12px; left: 12px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-md); }
.ol-zoom:hover { background: var(--surface); }
.ol-control button {
  width: 34px;
  height: 34px;
  margin: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: 500 20px/1 var(--font);
}
.ol-zoom .ol-zoom-in { margin-bottom: 2px; }
.ol-control button:hover, .ol-control button:focus { background: var(--hover); outline: none; color: var(--text); }
.ol-zoom .ol-zoom-in, .ol-zoom .ol-zoom-out { border-radius: 8px; }
/* Docked beside the zoom buttons (44px wide incl. border) instead of the
   bottom-left corner, so the search-area toolbar can use the full bottom
   edge without colliding with it. */
.ol-scale-line { top: 12px; left: 68px; right: auto; bottom: auto; padding: 3px 6px; border-radius: 6px; background: color-mix(in srgb, var(--surface) 85%, transparent); }
.ol-scale-line-inner { border-color: var(--text-muted); color: var(--text); font: 500 11px var(--font); }

/* Reparented below .map-tools, not in its default bottom-right corner, so
   that corner is free for the search-area toolbar. A card matching the
   toolbar's own (.ol-zoom-style) chrome ties it visually to the toolbar
   above, since it's a single OL-styled control rather than one of our own
   icon buttons. */
.map-tools-attribution { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 8px; }
.map-tools-attribution .ol-attribution {
  position: static;
  margin: 0;
  padding: 4px;
  max-width: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.map-tools-attribution .ol-attribution ul {
  position: absolute;
  top: 50%;
  right: 100%;
  margin: 0 8px 0 0;
  padding: 6px 10px;
  transform: translateY(-50%);
  white-space: nowrap;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--text);
  text-shadow: none;
  font-size: 11px;
}
.ol-attribution a { color: var(--text-muted); }

/* ── Results ────────────────────────────────────────────────────────────── */

.splitter {
  position: relative;
  background: var(--surface);
  border-top: 1px solid var(--border);
  cursor: row-resize;
  touch-action: none;
}
.splitter::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 50%;
  width: 36px;
  height: 3px;
  margin-left: -18px;
  border-radius: 3px;
  background: var(--border-strong);
}
.splitter:hover::after, .splitter:focus-visible::after { background: var(--brand); }
.splitter:focus-visible { outline: none; }

.results { display: flex; min-height: 0; background: var(--surface); }
.results-inner { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.results-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 46px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.toolbar-sep { width: 1px; height: 22px; background: var(--border); }
.results-status { display: flex; align-items: center; gap: 8px; font-weight: 620; }
.results-selection { color: var(--text-muted); font-size: 13px; margin-right: 4px; }

.results-table { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.rt-grid {
  display: grid;
  grid-template-columns: 40px minmax(180px, 3fr) minmax(120px, 1.5fr) minmax(100px, 0.9fr) 56px 88px;
  align-items: center;
}
.rt-header {
  height: 34px;
  padding-right: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}
.rt-header .rt-cell[aria-sort='ascending'], .rt-header .rt-cell[aria-sort='descending'] { color: var(--text); }
.rt-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 4px 0;
  border: 0;
  background: none;
  color: inherit;
  font-weight: inherit;
  cursor: pointer;
}
.rt-sort.is-end { flex-direction: row-reverse; }
.rt-header .rt-cell:has(.rt-sort.is-end) { text-align: right; }
.rt-sort-icon { display: inline-flex; width: 14px; }
.rt-viewport { position: relative; flex: 1; min-height: 0; overflow: auto; outline: none; }
.rt-viewport:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }
.rt-spacer { width: 1px; }
.rt-row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13.5px;
  cursor: default;
}
.rt-row:hover { background: var(--hover); }
.rt-row.is-highlighted { background: var(--row-highlight); box-shadow: inset 3px 0 0 var(--brand); }
.rt-row.is-checked .rt-title { font-weight: 620; }
.rt-cell { min-width: 0; padding: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-cell.is-end { text-align: right; font-variant-numeric: tabular-nums; }
.rt-check { display: flex; justify-content: center; padding: 0; }
.rt-collection, .rt-date { color: var(--text-muted); }
.rt-date { font-variant-numeric: tabular-nums; }
.rt-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Properties drawer ──────────────────────────────────────────────────── */

.drawer {
  display: flex;
  flex-direction: column;
  width: var(--drawer-width);
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  z-index: 10;
}
.drawer-header { display: flex; align-items: center; gap: 8px; padding: 10px 8px 6px 16px; }
.drawer-title { flex: 1; font-size: 15px; font-weight: 680; }
.segmented {
  display: flex;
  gap: 2px;
  margin: 0 12px 10px;
  padding: 3px;
  border-radius: 9px;
  background: var(--sunken);
}
.segment {
  flex: 1;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.segment.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.props-list { display: grid; align-content: start; gap: 8px; flex: 1; padding: 0 12px 16px; overflow: auto; }
.prop-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.prop-item > summary {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  list-style: none;
  cursor: pointer;
}
.prop-item > summary::-webkit-details-marker { display: none; }
.prop-item-caret { flex: none; margin-top: 3px; color: var(--text-muted); transition: transform 0.12s ease; }
.prop-item[open] > summary .prop-item-caret { transform: rotate(90deg); }
.prop-item-heading { display: grid; flex: 1; min-width: 0; gap: 1px; }
.prop-item[open] > summary { border-bottom: 1px solid var(--border); }
.prop-item-title { font-weight: 650; overflow-wrap: anywhere; }
.prop-item-meta { color: var(--text-muted); font-size: 12px; }
.prop-item-body { display: grid; gap: 8px; padding: 10px 12px 12px; }
.prop-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.prop-heading { margin-top: 4px; color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.asset-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.asset-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px 4px 6px; border-radius: 7px; color: var(--text-muted); }
.asset-row:hover { background: var(--hover); }
.asset-text { display: grid; flex: 1; min-width: 0; }
.asset-title { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-meta { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.json-tree { font: 12px/1.55 var(--mono); }
.json-node > summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 1px 4px;
  border-radius: 5px;
}
.json-node > summary { cursor: pointer; list-style: none; }
.json-node > summary::-webkit-details-marker { display: none; }
.json-node > summary:hover, .json-leaf:hover { background: var(--hover); }
.json-caret { flex: none; align-self: center; color: var(--text-subtle); transition: transform 0.12s ease; }
.json-node[open] > summary .json-caret { transform: rotate(90deg); }
.json-children { margin-left: 8px; padding-left: 8px; border-left: 1px solid var(--border); }
.json-leaf { position: relative; padding: 3px 26px 3px 21px; border-radius: 5px; }
.json-key { color: var(--text); font-weight: 650; }
.json-key::after { content: ''; margin-right: 6px; }
.json-meta { color: var(--text-subtle); }
.json-value { color: var(--text-muted); overflow-wrap: anywhere; white-space: pre-wrap; }
.json-number, .json-boolean { color: var(--accent); }
.json-null { color: var(--text-subtle); font-style: italic; }
.json-copy {
  display: grid;
  place-items: center;
  width: 22px;
  height: 20px;
  margin-left: auto;
  flex: none;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text-muted);
  opacity: 0;
  cursor: pointer;
}
.json-node > summary:hover .json-copy, .json-leaf:hover .json-copy, .json-copy:focus-visible { opacity: 1; }
.json-leaf .json-copy { position: absolute; top: 2px; right: 2px; margin-left: 0; }
.json-copy:hover { background: var(--brand-soft-strong); color: var(--text); }

/* ── API picker and menus ───────────────────────────────────────────────── */

.api-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.api-picker:hover { border-color: var(--brand); }
.api-picker[aria-expanded='true'] { border-color: var(--brand); box-shadow: var(--focus); }
.api-picker-text { display: grid; flex: 1; gap: 1px; min-width: 0; }
.api-picker-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.api-picker-name { overflow: hidden; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.api-picker-url { overflow: hidden; color: var(--text-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.api-picker-chevron { color: var(--text-muted); }

.menu {
  position: fixed;
  z-index: 1000;
  min-width: 210px;
  max-width: min(480px, calc(100vw - 16px));
  max-height: min(72vh, 600px);
  padding: 5px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.12s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-3px); } }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus { background: var(--hover); outline: none; }
.menu-item:disabled { opacity: 0.45; cursor: default; }
.menu-item.is-danger { color: var(--danger); }
.menu-item .icon { color: var(--text-muted); }
.menu-icon-space { width: 16px; flex: none; }
.menu-text { display: grid; flex: 1; min-width: 0; }
.menu-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-description { overflow: hidden; color: var(--text-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.menu-hint { color: var(--text-subtle); font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; }
.menu-heading { padding: 9px 10px 4px; color: var(--text-subtle); font-size: 10.5px; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; }
.menu-separator { height: 1px; margin: 5px 4px; background: var(--border); }

/* ── Dialogs ────────────────────────────────────────────────────────────── */

.dialog {
  width: min(560px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dialog[open] { animation: dialog-in 0.16s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
.dialog::backdrop { background: rgba(24, 24, 20, 0.42); backdrop-filter: blur(2px); }
.dialog-sm { width: min(460px, calc(100vw - 24px)); }
.dialog-lg { width: min(820px, calc(100vw - 24px)); }
.dialog-xl { width: min(940px, calc(100vw - 24px)); }
.dialog-frame { display: flex; flex-direction: column; max-height: calc(100dvh - 40px); }
.dialog-header { display: flex; align-items: center; gap: 8px; padding: 14px 12px 6px 20px; }
.dialog-title { flex: 1; font-size: 17px; font-weight: 680; letter-spacing: -0.01em; }
.dialog-body { flex: 1; min-height: 0; padding: 8px 20px 18px; overflow: auto; }
.dialog-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.dialog.is-busy .dialog-body { opacity: 0.6; pointer-events: none; }
.message { display: flex; align-items: flex-start; gap: 12px; }
.message > div { display: grid; gap: 10px; overflow-wrap: anywhere; }
.message > .icon { margin-top: 1px; color: var(--text-muted); }
.message-error > .icon { color: var(--danger); }

.split { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; min-height: 420px; }
.split-list { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding-right: 20px; border-right: 1px solid var(--border); }
.profile-list { display: grid; align-content: start; gap: 2px; flex: 1; min-width: 0; margin: 0; padding: 0; overflow: auto; overflow-x: hidden; list-style: none; }
.profile-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.profile-row:hover { background: var(--hover); }
.profile-row.is-selected { background: var(--brand-soft); }
.profile-row .icon { flex: none; margin-top: 2px; color: var(--text-muted); }
.profile-row.is-locked { cursor: default; background: var(--surface-2); }
.profile-name { display: block; font-weight: 620; overflow-wrap: anywhere; }
.list-heading { padding: 10px 10px 4px; color: var(--text-subtle); font-size: 10.5px; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; }
.empty-row { padding: 6px 10px; }
.profile-editor { display: grid; align-content: start; gap: 14px; min-width: 0; }
.editor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 4px; }
.editor-actions [role='status'] { flex-basis: 100%; order: 10; }
.security-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
.security-bar > .icon { color: var(--text-muted); }

.simple-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.simple-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }

.qb { display: grid; gap: 12px; }
.qb-rows { display: grid; gap: 8px; }
.qb-row { display: grid; grid-template-columns: minmax(170px, 1.4fr) minmax(130px, 0.8fr) minmax(170px, 1.4fr) 34px; gap: 8px; align-items: start; }
.qb-multi { position: relative; }
.qb-multi-summary { display: flex; align-items: center; overflow: hidden; cursor: pointer; white-space: nowrap; text-overflow: ellipsis; text-align: left; }
.qb-multi-summary.is-placeholder { color: var(--text-subtle); }
.qb-multi-list {
  /* A popover: rendered in the top layer so it isn't clipped by the dialog's
     `overflow: auto` body and can extend past its edges. Position is set from
     JS on open since popovers are always `position: fixed`. */
  position: fixed;
  inset: auto;
  margin: 0;
  max-height: 240px;
  padding: 4px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
/* display: none is the popover default (UA stylesheet) while closed; this
   only needs to state the open, visible layout. */
.qb-multi-list:popover-open { display: grid; }
.qb-multi-list .check { padding: 5px 6px; }
.qb-multi-list .check:hover { background: var(--hover); }
.qb-preview-wrap summary { color: var(--text-muted); font-size: 13px; cursor: pointer; }
.qb-preview { max-height: 220px; margin: 8px 0 0; padding: 10px 12px; overflow: auto; border-radius: var(--radius-sm); background: var(--sunken); font: 12px/1.5 var(--mono); }
.qb-preview.is-wrapped { white-space: pre-wrap; overflow-wrap: anywhere; }
.qb-match { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; }
.qb-match select { width: auto; min-width: 200px; }

.dl-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.stat-value { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.stat-label { color: var(--text-muted); font-size: 12.5px; }
.dl-destination { display: grid; gap: 10px; }
.folder-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); }
.folder-row > .icon { color: var(--text-muted); }
.dl-headline { font-weight: 620; }
.progress { height: 8px; overflow: hidden; border-radius: 999px; background: var(--sunken); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--brand); transition: width 0.25s ease-out; }
.progress-bar.is-error { background: var(--danger); }
.dl-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.dl-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.dl-row:last-child { border-bottom: 0; }
.dl-icon { display: grid; place-items: center; color: var(--text-muted); }
.dl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-state { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dl-error { grid-column: 2 / -1; color: var(--danger); font-size: 12px; overflow-wrap: anywhere; }
.dl-row[data-status='queued'] .dl-name { color: var(--text-muted); }
.dl-row[data-status='active'] .dl-icon { color: var(--brand); }
.dl-row[data-status='done'] .dl-icon, .dl-row[data-status='skipped'] .dl-icon { color: var(--success); }
.dl-row[data-status='failed'] .dl-icon { color: var(--danger); }

.about { display: grid; gap: 12px; }
.about-logo { width: 220px; max-width: 70%; margin: 4px 0 6px; }
:root[data-theme='dark'] .about-logo { filter: invert(0.92); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .about-logo { filter: invert(0.92); } }

.welcome-dialog .dialog-header { display: none; }
.welcome-dialog .dialog-body { padding-top: 20px; }
.welcome { display: grid; gap: 12px; }
.welcome-logo-link { display: flex; justify-content: center; }
.welcome-logo { display: block; width: 320px; max-width: 100%; margin: 4px 0 6px; }
:root[data-theme='dark'] .welcome-logo { filter: invert(0.92); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .welcome-logo { filter: invert(0.92); } }

/* ── Toasts ─────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1100;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 8px 11px 14px;
  border-radius: var(--radius);
  background: var(--toast-bg);
  color: var(--toast-text);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
  transition: opacity 0.2s, transform 0.2s;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
.toast > .icon { margin-top: 1px; }
.toast-success > .icon { color: #5fcf7f; }
.toast-warning > .icon { color: #f0c05a; }
.toast-error > .icon { color: #ff8a80; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-action, .toast-close { border: 0; border-radius: 6px; background: none; color: inherit; cursor: pointer; }
.toast-action { padding: 2px 8px; font-weight: 650; text-decoration: underline; }
.toast-close { display: grid; place-items: center; width: 24px; height: 24px; opacity: 0.7; }
.toast-close:hover { opacity: 1; background: rgba(127, 127, 127, 0.25); }

.fatal { margin: 48px auto; max-width: 560px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* ── Smaller screens ────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  :root { --sidebar-width: 312px; --drawer-width: 360px; }
  .brand-sub { display: none; }
}

@media (max-width: 900px) {
  #sidebar-toggle { display: inline-flex; }
  .appbar-logo { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: var(--appbar-height);
    bottom: 0;
    left: 0;
    width: min(360px, 92vw);
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease-out;
    z-index: 30;
  }
  .app.sidebar-open .sidebar { transform: none; }
  .draw-hint .btn { display: none; }
  .search-area-bar .btn span { display: none; }
  .mobile-search-bar { display: flex; }
  .drawer {
    position: fixed;
    top: var(--appbar-height);
    right: 0;
    bottom: 0;
    width: min(420px, 100vw);
    box-shadow: var(--shadow-lg);
    z-index: 30;
  }
  .rt-grid { grid-template-columns: 38px minmax(140px, 2fr) minmax(90px, 1fr) 96px 48px 76px; }
  .split { grid-template-columns: 1fr; }
  .split-list { max-height: 220px; padding-right: 0; padding-bottom: 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .qb-row { grid-template-columns: 1fr 1fr; }
  .qb-row .qb-value { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .brand-name { font-size: 15px; }
  .props-toggle { width: 34px; padding: 0; gap: 0; }
  .props-toggle span { display: none; }
  .rt-grid { grid-template-columns: 36px minmax(120px, 1fr) 88px 72px; }
  .rt-collection, .rt-files, .rt-header .rt-cell:nth-child(3), .rt-header .rt-cell:nth-child(5) { display: none; }
  .choice-cards, .grid-2, .dl-summary { grid-template-columns: 1fr; }
}
