.appearance-options {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    margin: 0 0 1rem;
    padding: .75rem;
    border: 1px solid var(--rule);
    border-radius: var(--r);
}

.appearance-option {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .65rem;
    border: 1px solid var(--rule);
    border-radius: var(--r);
    cursor: pointer;
}

.appearance-option:has(:checked) { border-color: var(--focus); }
.appearance-swatch {
    inline-size: 1.5rem;
    block-size: 1.5rem;
    border: 1px solid var(--steel);
    border-radius: 50%;
}
.appearance-swatch--synergia { background: linear-gradient(135deg, #fbf8f0 50%, #bc943e 50%); }
.appearance-swatch--light { background: linear-gradient(135deg, #fff 50%, #175598 50%); }
.appearance-swatch--dark { background: linear-gradient(135deg, #222e3a 50%, #86caff 50%); }
.appearance-swatch--frieden { background: linear-gradient(135deg, #f8eed9 50%, #443529 50%); }

:root[data-theme="light"] {
    color-scheme: light;
    --paper: #edf2f7; --panel: #fff; --ink: #142333; --steel: #445a70;
    --rule: #a9bbcd; --gold: #225c94; --gold-soft: #e2eef9; --accent: #184c80;
    --focus: #004ca0; --theme-link: #184c80; --theme-button: #184c80; --theme-button-text: #fff;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #141c25; --panel: #202c38; --ink: #f1f5fa; --steel: #bccadc;
    --rule: #60758b; --gold: #9bcaff; --gold-soft: #293e55; --accent: #a8d4ff;
    --focus: #9fd2ff; --theme-link: #aad6ff; --theme-button: #a6d1ff; --theme-button-text: #112232;
    --ok: #9ce1b3; --warn: #ffd489; --bad: #ffb1a6;
}

:root[data-theme="frieden"] {
    color-scheme: light;
    --paper: #efe6d7; --panel: #fffbf3; --ink: #30251c; --steel: #59483a;
    --rule: #bba783; --gold: #8c6528; --gold-soft: #efdfbd; --accent: #6b4816;
    --focus: #704914; --theme-link: #6b4816; --theme-button: #513924; --theme-button-text: #fff;
}

:root[data-contrast="high"] {
    color-scheme: light;
    --paper: #fff; --panel: #fff; --ink: #000; --steel: #252525;
    --rule: #505050; --gold: #003d90; --gold-soft: #deecff; --accent: #00347c;
    --focus: #004bad; --theme-link: #00347c; --theme-button: #000; --theme-button-text: #fff;
    --ok: #12572d; --warn: #664000; --bad: #8e180d;
}

:root[data-theme="dark"][data-contrast="high"] {
    color-scheme: dark;
    --paper: #000; --panel: #101010; --ink: #fff; --steel: #fff;
    --rule: #aeb6bf; --gold: #c5e5ff; --gold-soft: #223347; --accent: #d3ebff;
    --focus: #ffdc73; --theme-link: #c5e5ff; --theme-button: #fff; --theme-button-text: #000;
    --ok: #b1f3c6; --warn: #ffe3a6; --bad: #ffc3bb;
}

:root:is([data-theme="light"], [data-theme="dark"], [data-theme="frieden"], [data-contrast="high"]) {
    --hair: var(--rule);
    --glass-line: var(--rule);
    --glass: var(--panel);
    --card: var(--panel);
}

:root:is([data-theme="light"], [data-theme="dark"], [data-theme="frieden"], [data-contrast="high"]) body {
    background: var(--paper);
}

:root:is([data-theme="light"], [data-theme="dark"], [data-theme="frieden"], [data-contrast="high"]) :is(
    section.block, nav.side, header.top, .crumb, .toolbar, .kgrid fieldset, dialog,
    .note, .sppanel, .spfab, .spb, .spo, .spgrp, .context-menu, .voucher-mail-preview
) {
    color: var(--ink);
    background: var(--panel);
    border-color: var(--rule);
}

:root:is([data-theme="light"], [data-theme="dark"], [data-theme="frieden"], [data-contrast="high"]) :is(
    #app input:not([type="checkbox"], [type="radio"]), #app select, #app textarea,
    .sppanel input:not([type="checkbox"], [type="radio"]), .sppanel select, .sppanel textarea
) {
    color: var(--ink);
    background: var(--panel);
    border-color: var(--rule);
}

:root:is([data-theme="light"], [data-theme="dark"], [data-theme="frieden"], [data-contrast="high"]) .btn {
    color: var(--ink);
    background: var(--panel);
    border-color: var(--rule);
}

:root:is([data-theme="light"], [data-theme="dark"], [data-theme="frieden"], [data-contrast="high"]) .btn.primary {
    color: var(--theme-button-text);
    background: var(--theme-button);
    border-color: var(--theme-button);
}

:root:is([data-theme="light"], [data-theme="dark"], [data-theme="frieden"], [data-contrast="high"]) :is(
    .btn:not(.primary):hover, nav.side a[aria-current="page"], .module-navigation details:has([aria-current="page"]) > summary,
    .tab.on, .plan-entry, .plan-add, .spb:hover:not(:disabled), .voucher-mail-preview h3, .voucher-mail-expand > summary
) {
    color: var(--ink);
    background: var(--gold-soft);
}

:root:is([data-theme="light"], [data-theme="dark"], [data-theme="frieden"], [data-contrast="high"]) main a:not(.btn, .plan-entry) {
    color: var(--theme-link);
}

:root[data-theme="dark"] :is(.chip.warn, .warn) { color: var(--warn); }
:root[data-theme="dark"] :is(.master-record-row:hover, .master-record-row:focus-within, .article-choice:hover, .article-choice:focus-within),
:root[data-theme="dark"] .voucher-items tr:nth-child(even) td { background: var(--gold-soft); }
:root[data-theme="dark"] .orders-results :is(.order-paid, .order-advance, .order-linked-receipt, .order-completed) > td { background: #213e32; }
:root[data-theme="dark"] .orders-results .order-overdue > td { background: #522e30; }
:root[data-theme="dark"] .orders-results .order-invoiced > td { background: #493a22; }
:root[data-theme="dark"] .plan-entry.plan-overlay { background: #493a22; }

:root[data-contrast="high"] :focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}
:root[data-contrast="high"] :is(h1, h2, h3, th, strong, .item .title) { font-weight: 650; }
:root[data-contrast="high"] main a:not(.btn) { text-decoration: underline; }
