/* ── Tokens ────────────────────────────────────────────────── */
:root {
    color-scheme: light;
    --bg:            #f6f7f9;
    --ink:           #0f1525;
    --ink-mid:       #2e364a;
    --ink-soft:      #4f586e;
    --muted:         #5a6478;
    --panel:         #ffffff;
    --line:          #e3e6ec;
    --line-strong:   #cdd2dc;
    --surface:       #f1f3f7;
    --surface-2:     #f8f9fc;

    --blue:          #2c4dc9;
    --red:           #9a2f2f;
    --warn-fg:       #7a4810;

    --cta:           #14182a;
    --cta-hover:     #000;
    --cta-fg:        #ffffff;

    --nav-bg:        rgba(255,255,255,.82);
    --input-bg:      #ffffff;
    --toggle-bg:     #eaeef4;
    --notice-bg:     #fcf6e6;
    --notice-fg:     #5d3f0d;
    --notice-border: #e9d9aa;

    --tag-border:    #d6dae3;
    --tag-bg:        #ffffff;
    --tag-fg:        #232a3e;

    /* Rating semantic backgrounds (white text, AA on white panel) */
    --rate-none:     #6c7585;
    --rate-low:      #2a7a55;
    --rate-medium:   #8e6822;
    --rate-high:     #9a5125;
    --rate-critical: #973434;

    --shadow-sm:     0 1px 2px rgba(15,21,37,.04);
    --shadow:        0 1px 3px rgba(15,21,37,.04), 0 4px 14px rgba(15,21,37,.05);
    --radius:        14px;
    --radius-sm:     10px;
    --radius-pill:   999px;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg:            #0a0d14;
    --ink:           #e8ecf4;
    --ink-mid:       #b8c1d2;
    --ink-soft:      #92a0b6;
    --muted:         #98a3b8;
    --panel:         #11151f;
    --line:          #232a3c;
    --line-strong:   #313a52;
    --surface:       #181d2a;
    --surface-2:     #151a25;

    --blue:          #93aaf8;
    --red:           #ec8080;
    --warn-fg:       #e6bd6b;

    --cta:           #3a4b73;
    --cta-hover:     #4d6090;
    --cta-fg:        #f0f4ff;

    --nav-bg:        rgba(13,17,26,.82);
    --input-bg:      #181d2a;
    --toggle-bg:     #181d2a;
    --notice-bg:     #2a2208;
    --notice-fg:     #e6bd6b;
    --notice-border: #463607;

    --tag-border:    #2a3248;
    --tag-bg:        #181d2a;
    --tag-fg:        #d2dae8;

    /* Slightly desaturated/lifted rating colors for dark panels (white text stays AA) */
    --rate-none:     #565e6e;
    --rate-low:      #2c8f63;
    --rate-medium:   #a47828;
    --rate-high:     #b46031;
    --rate-critical: #b03f3f;

    --shadow-sm:     0 1px 2px rgba(0,0,0,.3);
    --shadow:        0 1px 3px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.35);
}

/* ── Base ──────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html { transition: background-color .2s, color .2s; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    line-height: 1.5;
    font-size: 15px;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

h1, h2, h3, h4 { letter-spacing: -.018em; line-height: 1.25; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: .98rem; font-weight: 700; }

p { margin: .5em 0; }

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
    padding: 14px clamp(16px,4vw,40px) 32px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.topbar, .hero-grid, .container {
    max-width: 1200px;
    margin: 0 auto;
}

.topbar {
    position: sticky;
    top: 10px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 32px;
    padding: 7px 7px 7px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--nav-bg);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    box-shadow: var(--shadow-sm);
}

.brand {
    color: var(--ink);
    font-weight: 700;
    letter-spacing: -.02em;
    font-size: 1.02rem;
    flex-shrink: 0;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.top-filter, .language-switch a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--tag-border);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--tag-fg);
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}

.top-filter:hover, .language-switch a:hover { background: var(--surface); text-decoration: none; }

.top-filter.active,
.language-switch a.active {
    background: var(--cta);
    color: var(--cta-fg);
    border-color: var(--cta);
}

.theme-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid var(--tag-border);
    border-radius: 50%;
    background: transparent;
    color: var(--tag-fg);
    cursor: pointer;
    font-size: .95rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--surface); }

.load-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--tag-border);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--tag-fg);
    font-size: .82rem;
    font-weight: 650;
    white-space: nowrap;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--rate-low);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--rate-low) 18%, transparent);
}

.status-spinner {
    display: none;
    width: 13px;
    height: 13px;
    border: 2px solid var(--line-strong);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: status-spin .75s linear infinite;
}

.load-status.loading .status-dot { display: none; }
.load-status.loading .status-spinner { display: inline-block; }

@keyframes status-spin {
    to { transform: rotate(360deg); }
}

.language-switch {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: .85rem;
}
.language-switch span { margin-right: 4px; }

.hero-grid { display: block; }

/* ── Search card ─────────────────────────────────────────── */
.search-card {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 24px 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.search-card h2 {
    margin: 0 0 18px;
    font-size: 1.25rem;
    letter-spacing: -.024em;
}

label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--ink-mid);
    margin: 0 0 6px;
}

input, select {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font: inherit;
    font-size: .92rem;
    background: var(--input-bg);
    color: var(--ink);
    transition: border-color .12s, box-shadow .12s;
}

input::placeholder { color: var(--muted); }

input:focus, select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 16%, transparent);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 12px;
    margin: 14px 0 16px;
}

button[type="submit"] {
    width: 100%;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 11px 18px;
    background: var(--cta);
    color: var(--cta-fg);
    font: inherit;
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    transition: background .12s, transform .08s;
}
button[type="submit"]:hover { background: var(--cta-hover); }
button[type="submit"]:active { transform: scale(.99); }

.form-error { color: var(--red); font-weight: 600; margin-top: 10px; font-size: .9rem; }

.gate-hero {
    min-height: 100vh;
}

.gate-card {
    max-width: 460px;
}

.gate-intro {
    margin: -6px 0 18px;
}

.gate-card input[type="password"] {
    margin-bottom: 16px;
}

/* ── Container ───────────────────────────────────────────── */
.container { padding: 28px clamp(16px,4vw,40px) 80px; }

.top-results, .split, .cards-3 {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

.top-results { grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr); }
.split       { grid-template-columns: repeat(2, minmax(0,1fr)); }
.cards-3     { grid-template-columns: repeat(3, minmax(0,1fr)); }

/* ── Panel ───────────────────────────────────────────────── */
.panel {
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}

.compact-panel { margin-bottom: 0; }

.panel h2 { margin: 0 0 14px; }
.panel h3 { margin: 18px 0 8px; }

.panel > p:first-of-type { margin-top: 0; }

/* heading rows */
.eyebrow {
    margin: 0 0 6px;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .68rem;
    font-weight: 700;
}

.panel-heading, .section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 14px;
}
.panel-heading h2, .section-heading h2 { margin: 0; }
.section-heading h3 { margin: 0; }

/* ── Rating pills ─────────────────────────────────────────── */
.rating-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 84px;
    height: 26px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    color: white;
    font-weight: 700;
    font-size: .78rem;
    letter-spacing: .01em;
}

.rating-none, .cert-neutral   { background: var(--rate-none); }
.rating-low, .cert-supported  { background: var(--rate-low); }
.rating-medium                 { background: var(--rate-medium); }
.rating-high, .cert-warning    { background: var(--rate-high); }
.rating-critical               { background: var(--rate-critical); }

/* subtle accent border on critical panels */
.cert-panel.cert-supported  { border-color: color-mix(in srgb, var(--rate-low) 45%, transparent); }
.cert-panel.cert-warning    { border-color: color-mix(in srgb, var(--rate-high) 45%, transparent); }
.priority-panel.rating-critical { border-color: color-mix(in srgb, var(--rate-critical) 45%, transparent); }
.priority-panel.rating-high     { border-color: color-mix(in srgb, var(--rate-high) 45%, transparent); }

/* ── Inline blocks ────────────────────────────────────────── */
.metric-line, .exposure, .notice {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 13px;
    font-size: .89rem;
}

.notice {
    color: var(--notice-fg);
    background: var(--notice-bg);
    border-color: var(--notice-border);
}

.muted       { color: var(--muted); font-size: .88rem; }
.signal-yes  { color: var(--red); font-weight: 700; }
.big-metric  {
    font-size: 2.4rem;
    line-height: 1;
    margin: 8px 0 6px;
    font-weight: 700;
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums;
}

.flat-list, .link-list {
    padding-left: 18px;
    margin: 8px 0 0;
}
.flat-list li, .link-list li { margin: 6px 0; font-size: .92rem; }
.warning-list li { color: var(--warn-fg); }

/* ── Facts grid ──────────────────────────────────────────── */
.facts-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0,1fr));
    gap: 8px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 4px;
    background: var(--surface-2);
}

.facts-grid div {
    background: transparent;
    border-radius: calc(var(--radius) - 6px);
    padding: 11px 13px;
    min-width: 0;
}

.facts-grid div + div { border-left: 1px solid var(--line); }

.facts-grid span {
    display: block;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 4px;
}

.facts-grid strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: .9rem;
    font-weight: 600;
}

/* ── Description toggle ───────────────────────────────────── */
.description-toggle { margin-top: 16px; }

.toggle-input { position: absolute; opacity: 0; pointer-events: none; }

.toggle-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 3px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--toggle-bg);
}

.toggle-buttons label {
    cursor: pointer;
    border-radius: var(--radius-pill);
    padding: 6px 14px;
    color: var(--ink-mid);
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    margin: 0;
    transition: background .15s, color .15s;
}

.description-toggle:focus-within .toggle-buttons {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

#desc-official:checked ~ .toggle-buttons label[for="desc-official"],
#desc-ai:checked ~ .toggle-buttons label[for="desc-ai"] {
    background: var(--panel);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

.description-panel { display: none; }

#desc-official:checked ~ .description-panels .official-description,
#desc-ai:checked ~ .description-panels .ai-description-panel { display: block; }

.ai-description {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--blue);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin: 0 0 10px;
}

.ai-text {
    margin: 0 0 10px;
    font-size: .94rem;
    line-height: 1.6;
    color: var(--ink);
}

.ai-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: .8rem;
    color: var(--muted);
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 7px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--blue) 16%, transparent);
    color: var(--blue);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .06em;
}

.ai-disclaimer {
    margin: 6px 2px 0;
    font-size: .78rem;
    line-height: 1.5;
}


/* ── Tables ──────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th, td {
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
    padding: 11px 14px;
    font-size: .88rem;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }

th {
    color: var(--ink-soft);
    background: var(--surface-2);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    padding-top: 9px;
    padding-bottom: 9px;
}

.score-badge {
    display: inline-flex;
    min-width: 46px;
    justify-content: center;
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    color: #fff;
    font-weight: 700;
    font-size: .82rem;
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
}

/* ── Source chips ────────────────────────────────────────── */
.columns { columns: 2 280px; }

.source-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px,1fr));
    gap: 8px;
}

.source-chip {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    background: var(--surface-2);
    transition: box-shadow .25s ease, border-color .2s ease, background .2s ease;
}

.source-chip strong, .source-chip span, .source-chip small { display: block; }
.source-chip strong { font-size: .89rem; }
.source-chip span   { color: var(--muted); margin-top: 3px; font-size: .82rem; }
.source-chip small  { color: var(--red); margin-top: 6px; overflow-wrap: anywhere; font-size: .78rem; }

/* dezent grünes Leuchten — Quelle hat Daten geliefert */
.source-chip.has-data {
    background: color-mix(in srgb, var(--rate-low) 10%, var(--surface-2));
    border-color: color-mix(in srgb, var(--rate-low) 40%, var(--line));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--rate-low) 35%, transparent),
                0 0 14px color-mix(in srgb, var(--rate-low) 22%, transparent);
}
.source-chip.has-data strong { color: var(--ink); }
.source-chip.has-data span   { color: var(--rate-low); }

/* ausgegraut — kein Treffer / skipped / not_found */
.source-chip.status-ok:not(.has-data),
.source-chip.status-not_found,
.source-chip.status-skipped {
    opacity: .55;
}

/* Fehler bleibt rot, nicht ausgegraut */
.source-chip.status-error {
    border-color: rgba(171,66,66,.45);
    background: rgba(171,66,66,.06);
    opacity: 1;
}

/* ── Collapsible ──────────────────────────────────────────── */
.collapsible-wrapper { display: block; }
.collapsible-table tbody tr:nth-child(n+6) { display: none; }
.collapsible-wrapper:has(.more-toggle[open]) .collapsible-table tbody tr { display: table-row; }

.more-toggle, .collapsible {
    margin-top: 10px;
}
.more-toggle > summary,
.collapsible > summary {
    cursor: pointer;
    color: var(--accent, var(--ink));
    list-style: none;
    font-size: .88rem;
    padding: 4px 0;
    user-select: none;
}
.more-toggle > summary::-webkit-details-marker,
.collapsible > summary::-webkit-details-marker { display: none; }
.more-toggle > summary::after,
.collapsible > summary::after { content: " ▾"; }
.more-toggle[open] > summary::after,
.collapsible[open] > summary::after { content: " ▴"; }
.more-toggle[open] .more-label,
.collapsible[open] .more-label { display: none; }
.more-toggle:not([open]) .less-label,
.collapsible:not([open]) .less-label { display: none; }

.inline-more { display: inline; }
.inline-more > summary {
    display: inline;
    cursor: pointer;
    color: var(--ink-soft);
    list-style: none;
    font-size: .88rem;
    margin-left: 6px;
}
.inline-more > summary::-webkit-details-marker { display: none; }
.inline-more[open] > summary { color: var(--muted); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .top-results, .split, .cards-3, .facts-grid {
        grid-template-columns: 1fr;
    }
    .facts-grid div + div { border-left: 0; border-top: 1px solid var(--line); }
    .hero { padding-bottom: 24px; }
    .topbar { margin-bottom: 24px; position: static; }
}

@media (max-width: 560px) {
    .form-grid       { grid-template-columns: 1fr; }
    .panel-heading   { display: block; }
    .section-heading { display: block; }
    .rating-pill     { margin-top: 10px; }
    .language-switch span { display: none; }
    .topbar {
        align-items: flex-start;
        border-radius: var(--radius);
        flex-direction: column;
        padding: 12px;
    }
    .topbar-actions { width: 100%; justify-content: flex-start; }
    .top-filter { flex: 1; }
    .panel { padding: 18px 16px; }
}
