/* Shared screen design: use compact controls only in dense toolbars.
   Paper previews reset these tokens; print uses the original var() fallbacks. */
@media screen {
    :root {
        --ui-font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        --ui-font-serif: Georgia, "Times New Roman", serif;
        --ui-font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;
        --ui-font-size-micro: 11px;
        --ui-font-size-xs: 12px;
        --ui-font-size-sm: 14px;
        --ui-font-size-base: 16px;
        --ui-font-size-lg: 18px;
        --ui-font-size-xl: 20px;
        --ui-font-size-heading-sm: 24px;
        --ui-font-size-heading-md: 28px;
        --ui-font-size-heading-lg: 32px;
        --ui-line-heading: 1.2;
        --ui-line-compact: 1.4;
        --ui-line-body: 1.5;
        --ui-line-relaxed: 1.6;
        --ui-weight-normal: 400;
        --ui-weight-medium: 600;
        --ui-weight-bold: 700;
        --ui-space-2: 2px;
        --ui-space-4: 4px;
        --ui-space-8: 8px;
        --ui-space-12: 12px;
        --ui-space-16: 16px;
        --ui-space-20: 20px;
        --ui-space-24: 24px;
        --ui-space-32: 32px;
        --ui-space-40: 40px;
        --ui-space-48: 48px;
        --ui-space-64: 64px;
        --ui-radius-sm: 6px;
        --ui-radius-md: 8px;
        --ui-radius-lg: 12px;
        --ui-radius-pill: 999px;
        --ui-control-height: 44px;
        --ui-control-height-compact: 36px;
        --ui-control-height-lg: 48px;
        --ui-control-height-icon: 32px;
        --ui-control-padding-y: var(--ui-space-8);
        --ui-control-padding-y-compact: var(--ui-space-4);
        --ui-control-padding-x-compact: var(--ui-space-8);
        --ui-control-padding-x: var(--ui-space-12);
        --ui-input-padding-scale: .65;
        --ui-input-padding-y: calc(var(--ui-control-padding-y) * var(--ui-input-padding-scale));
        --ui-input-padding-y-compact: calc(var(--ui-control-padding-y-compact) * var(--ui-input-padding-scale));
        --ui-input-height: calc(var(--ui-control-height) - 2 * (var(--ui-control-padding-y) - var(--ui-input-padding-y)));
        --ui-input-height-lg: calc(var(--ui-control-height-lg) - 2 * (var(--ui-control-padding-y) - var(--ui-input-padding-y)));
        --ui-input-height-compact: calc(var(--ui-control-height-compact) - 2 * (var(--ui-control-padding-y-compact) - var(--ui-input-padding-y-compact)));
        --ui-control-radius: var(--ui-radius-sm);
        --ui-focus-width: 3px;
        --ui-focus-offset: 3px;
    }
    :where(body) {
        font-family: var(--ui-font-sans);
        font-size: var(--ui-font-size-base);
        line-height: var(--ui-line-body);
    }
    :where(h1, h2, h3) { line-height: var(--ui-line-heading); }
    :where(h1) { font-size: var(--ui-font-size-heading-lg); }
    :where(h2) { font-size: var(--ui-font-size-heading-sm); }
    :where(h3) { font-size: var(--ui-font-size-xl); }
    :where(button, input, select, textarea, .field-rich-editor) {
        box-sizing: border-box;
        font-family: inherit;
        font-size: inherit;
        line-height: var(--ui-line-body);
    }
    :where(button, .button, select, input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="image"], [type="hidden"])) {
        min-height: var(--ui-control-height);
        border-radius: var(--ui-control-radius);
    }
    /* Text-entry fields share a smaller vertical inset; buttons keep their padding. */
    :where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="image"], [type="hidden"], [type="button"], [type="submit"], [type="reset"]), textarea, .field-rich-editor, .report-text-editor) {
        --ui-control-height: var(--ui-input-height);
        --ui-control-height-lg: var(--ui-input-height-lg);
        --ui-control-height-compact: var(--ui-input-height-compact);
        --ui-control-padding-y: var(--ui-input-padding-y);
        --ui-control-padding-y-compact: var(--ui-input-padding-y-compact);
    }
    :where(.admin-navigation-settings-toggle, .admin-navigation-close, .admin-navigation-toggle) {
        min-height: var(--ui-control-height-compact);
    }
    :where(button, .button) { font-weight: var(--ui-weight-medium); }
    :where(button, .button, input, select, textarea, summary, a):focus-visible {
        outline: var(--ui-focus-width) solid var(--theme-warning);
        outline-offset: var(--ui-focus-offset);
    }
    :is(.report-paper, .report-page, .sheet, .magazin-label) {
        --ui-font-sans: initial;
        --ui-font-serif: initial;
        --ui-font-mono: initial;
        --ui-font-size-micro: initial;
        --ui-font-size-xs: initial;
        --ui-font-size-sm: initial;
        --ui-font-size-base: initial;
        --ui-font-size-lg: initial;
        --ui-font-size-xl: initial;
        --ui-font-size-heading-sm: initial;
        --ui-font-size-heading-md: initial;
        --ui-font-size-heading-lg: initial;
        --ui-line-heading: initial;
        --ui-line-compact: initial;
        --ui-line-body: initial;
        --ui-line-relaxed: initial;
        --ui-weight-normal: initial;
        --ui-weight-medium: initial;
        --ui-weight-bold: initial;
        --ui-space-2: initial;
        --ui-space-4: initial;
        --ui-space-8: initial;
        --ui-space-12: initial;
        --ui-space-16: initial;
        --ui-space-20: initial;
        --ui-space-24: initial;
        --ui-space-32: initial;
        --ui-space-40: initial;
        --ui-space-48: initial;
        --ui-space-64: initial;
        --ui-radius-sm: initial;
        --ui-radius-md: initial;
        --ui-radius-lg: initial;
        --ui-radius-pill: initial;
        --ui-control-height: initial;
        --ui-control-height-compact: initial;
        --ui-control-height-lg: initial;
        --ui-control-height-icon: initial;
        --ui-control-padding-y: initial;
        --ui-control-padding-y-compact: initial;
        --ui-control-padding-x-compact: initial;
        --ui-control-padding-x: initial;
        --ui-input-padding-scale: initial;
        --ui-input-padding-y: initial;
        --ui-input-padding-y-compact: initial;
        --ui-input-height: initial;
        --ui-input-height-lg: initial;
        --ui-input-height-compact: initial;
        --ui-control-radius: initial;
        --ui-focus-width: initial;
        --ui-focus-offset: initial;
    }
}

/* Shared Leaflet, MapLibre and GPS palette; independent of the UI theme. */
:root {
    --map-grid-line: #557984;
    --map-grid-selected-line: #12616a;
    --map-grid-selected-fill: #39a9a0;
    --map-grid-country-line: #a5b5af;
    --map-grid-country-fill: #e2ebe5;
    --map-lake-line: #8cb3cc;
    --map-lake-fill: #b8d7ec;
    --map-river-line: #7aa9c7;
    --map-province-line: #8a8980;
    --map-graticule-line: #748894;
    --map-country-line: #82967b;
    --map-country-fill: #ddecce;
    --map-review-country-line: #728b91;
    --map-review-country-fill: #b5cfbd;
    --map-osm-background: #f4f3eb;
    --map-osm-forest: #d9e7d1;
    --map-osm-grass: #e5edda;
    --map-osm-sand: #f0e8d0;
    --map-osm-scrub: #e0e7d2;
    --map-osm-land: #eaece0;
    --map-osm-water: #d4e8f1;
    --map-osm-glacier: #edf6f8;
    --map-osm-river: #9fc7d8;
    --map-osm-building: #dcd8cc;
    --map-osm-building-line: #c8c4b9;
    --map-osm-main-road: #c9c1a8;
    --map-osm-minor-road: #d4cec1;
    --map-osm-path: #b7b69f;
    --map-osm-railway: #a9a6a1;
    --map-osm-boundary: #b1a8b8;
    --map-osm-label: #627273;
    --map-osm-poi: #7e7970;
    --map-compass-ring: #c4d4d8;
    --map-compass-grid: #dce6e8;
    --map-target: #b63e30;
    --map-position-soft: #287fc51a;
    --map-position: #287fc5;
    --map-connection: #4d626a;
}

/* Central fixed palette: cartography, photo editor, paper and decorative colors. */
:root {
    --theme-shadow: #182b3426;
    --theme-backdrop: #182b34aa;
    --theme-hero-overlay-start: rgba(0,0,0,.62);
    --theme-hero-overlay-end: rgba(0,0,0,.12);
    --theme-hero-bg: #080806;
    --theme-hero-text: #fff;
    --theme-hero-kicker: #e8d5b5;
    --theme-shadow-strong: #182b3466;
    --theme-hero-description: #f4eee4;
    --theme-hero-shadow: #000;
    --theme-paper: #fff;
    --theme-paper-line: #e2e8e3;
    --theme-fill-low: #2f9e44;
    --theme-fill-medium: #f2c94c;
    --theme-fill-high: #d94841;
    --theme-shadow-medium: #182b3433;
    --theme-shadow-subtle: #182b3414;
    --map-picker-bg: #e8f1f5;
    --map-label-halo: #fff;
    --map-grid-text: #23494f;
    --theme-editor-backdrop: #111b20e8;
    --map-review-bg: #dceaf1;
    --map-approximate-color: #e78938;
    --map-marker-text: #182b34;
    --map-marker-border: #853b0f;
    --map-marker-shadow: #0005;
    --map-exact-color: #165a63;
    --map-marker-selected-text: #fff;
    --map-mean-bg: #d2efdf;
    --map-public-bg: #dff1ff;
    --map-approximate-border: #9d4512;
    --map-approximate-soft: #e7893866;
    --map-country-label: #49635c;
    --map-city-label: #344c55;
    --map-city-dot: #526873;
    --editor-canvas: #1c2428;
    --editor-text: #edf3f3;
    --editor-button-line: #60777d;
    --editor-button-bg: #2b3a40;
    --editor-button-hover: #364b53;
    --editor-focus: #e9bd64;
    --editor-line: #39494e;
    --editor-panel: #253138;
    --editor-muted: #b6c7cb;
    --editor-accent: #6cd1bf;
    --editor-selected-bg: #20594f;
    --editor-selected-text: white;
    --editor-stage: #151c20;
    --editor-stage-line: #34454b;
    --editor-danger: #ffb4a3;
    --editor-heading: #c2d5d8;
    --editor-value: #88dacb;
    --editor-slider: #77cdbd;
    --editor-separator: #45575e;
    --editor-apply-bg: #75c9b6;
    --editor-apply-text: #112c27;
    --editor-apply-hover: #98dfce;
}

/* Tokens apply to screens only: exports and printed labels retain their colors. */
:root { color-scheme: light; }
@media screen {
    :root {
        --theme-canvas: #f5f7f7;
        --theme-surface: #fff;
        --theme-soft: #e5f2ed;
        --theme-text: #182b34;
        --theme-muted: #52666b;
        --theme-on-accent: #fff;
        --theme-line: #a8babc;
        --theme-accent: #165a63;
        --theme-accent-bg: #165a63;
        --theme-accent-soft: #e4f1ed;
        --theme-danger: #ae3029;
        --theme-danger-bg: #a62c25;
        --theme-danger-soft: #fff0ef;
        --theme-warning: #913030;
        --theme-warning-bg: #ff1d1d;
        --theme-warning-soft: #FFF1F1;
    }
    :root[data-theme="dark"] {
        color-scheme: dark;
        --theme-shadow-subtle: #0003;
        --theme-shadow: #0005;
        --theme-shadow-medium: #0006;
        --theme-shadow-strong: #0009;
        --theme-backdrop: #000b;
        /* Blue-black surfaces and lime accents, matching the reference palette. */
        --theme-canvas: #12141f;
        --theme-surface: #1a1d2a;
        --theme-soft: #242836;
        --theme-text: #f2f3f5;
        --theme-muted: #a6a9b6;
        --theme-on-accent: #12141f;
        --theme-line: #626a7a;
        --theme-accent: #b5f57b;
        --theme-accent-bg: #b5f57b;
        --theme-accent-soft: #29352b;
        --theme-danger: #ffb4ab;
        --theme-danger-bg: #ffb4ab;
        --theme-danger-soft: #36252d;
        --theme-warning: #e8c77a;
        --theme-warning-bg: #e8c77a;
        --theme-warning-soft: #332e26;
    }
    /* Native dark form controls can have a platform-specific purple tint. */
    :root[data-theme="dark"] :where(
        input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="image"], [type="button"], [type="submit"], [type="reset"], [type="hidden"]),
        select, textarea, .field-rich-editor
    ) {
        background-color: var(--theme-surface);
        color: var(--theme-text);
    }
    /* Paper previews and QR codes must match their printed output. */
    :is(.report-paper, .report-page, .sheet, .magazin-label) {
        color-scheme: light;
        --theme-canvas: initial;
        --theme-surface: initial;
        --theme-soft: initial;
        --theme-text: initial;
        --theme-muted: initial;
        --theme-on-accent: initial;
        --theme-line: initial;
        --theme-accent: initial;
        --theme-accent-bg: initial;
        --theme-accent-soft: initial;
        --theme-danger: initial;
        --theme-danger-bg: initial;
        --theme-danger-soft: initial;
        --theme-warning: initial;
        --theme-warning-bg: initial;
        --theme-warning-soft: initial;
    }
    :root[data-theme="dark"] .magazin-label {
        color: #182b34;
    }
    :root[data-theme="dark"] .brand img[src$="hnc-logo.svg"] { filter: brightness(0) invert(.85); }
}
/* Deliberately scoped to avoid each area's form and label layout. */
html body .theme-picker {
    display: inline-flex; align-items: center; gap: var(--ui-space-8,8px); flex: 0 0 auto;
    margin: 0; padding: 0; color: inherit; font: var(--ui-font-size-sm,13px)/var(--ui-line-compact,1.4) var(--ui-font-sans,system-ui,sans-serif);
    white-space: nowrap;
}
html body .theme-picker select {
    display: inline-block; width: auto; max-width: 100%; min-height: var(--ui-control-height-compact,36px);
    margin: 0; padding:var(--ui-control-padding-y-compact,6px) var(--ui-space-24,26px) var(--ui-control-padding-y-compact,6px) var(--ui-space-8,8px); border: 1px solid var(--theme-line,#a8babc);
    border-radius: var(--ui-control-radius,4px); background: var(--theme-surface,#fff); color: var(--theme-text,#182b34);
    font: inherit; cursor: pointer;
}
html body .theme-picker select:focus-visible { outline: var(--ui-focus-width,3px) solid var(--theme-warning,#b66b13); outline-offset: var(--ui-focus-offset,3px); }
body > header:has(.theme-picker) { flex-wrap: wrap; gap: var(--ui-space-12,12px); }
html body > main > .theme-picker { display: flex; justify-content: flex-end; margin-bottom: var(--ui-space-16,16px); }
a {text-decoration: none}
@media print { html body .theme-picker { display: none !important; } }
