/* ==========================================================
   Smart Calculator Pro – HP Consulting AI
   Stylesheet v3.3 – gemäß HP-Consulting-Styleguide V15
   Aufbau: 1 Schriften · 2 Variablen · 3 Basis · 4 Header · 5 Navigation
           6 Inhalt · 7 Rechner · 8 Konverter · 9 Historie · 10 Footer
           11 Overlays · 12 Hinweise · 13 Offline-Seite · 14 Responsive
   Hinweis: Keine Inline-Styles im HTML/JS (CSP: style-src 'self').
   ========================================================== */

/* ---------- 1. SCHRIFTEN (selbst gehostet, kein Google Fonts) ---------- */
@font-face {
    font-family: 'DM Serif Display';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../assets/fonts/dm-serif-display-latin-400-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../assets/fonts/dm-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../assets/fonts/dm-sans-latin-600-normal.woff2') format('woff2');
}

/* ---------- 2. VARIABLEN ---------- */
:root {
    color-scheme: dark;

    /* Palette (Styleguide Abschnitt 2) */
    --gold: #c9a84c;
    --gold2: #e8c97a;
    --ink: #08090d;
    --panel: #0f1116;
    --card: #13161d;
    --mist: #8b94a8;
    --border: rgba(201, 168, 76, 0.15);
    --border2: rgba(255, 255, 255, 0.06);

    /* Inhalt (wechselt mit dem Theme) */
    --text: #e2e4ea;
    --text-strong: #f0f1f5;
    --accent-text: var(--gold);
    --on-gold: #08090d;
    --focus: var(--gold2);
    --field: #1a1e27;
    --key: rgba(255, 255, 255, 0.05);
    --key-hover: rgba(255, 255, 255, 0.1);
    --key-border: rgba(255, 255, 255, 0.1);
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
    --glow-gold: rgba(201, 168, 76, 0.08);
    --glow-blue: rgba(30, 58, 138, 0.09);
    --grid: rgba(201, 168, 76, 0.025);

    /* Header, Footer, Overlays: theme-unabhängig (Styleguide 2a) */
    --bar-base: #08090d;
    --bar-bg: rgba(8, 9, 13, 0.72);
    --bar-text: #ffffff;
    --bar-hover: #e8c97a;
    --bar-border: rgba(201, 168, 76, 0.05);
    --modal-bg: #0f1116;
    --modal-text: #e2e4ea;

    --font-main: 'DM Sans', system-ui, sans-serif;
    --font-display: 'DM Serif Display', serif;
    --footer-h: 4.5rem;
}

/* Hell-Modus überschreibt nur Inhaltsvariablen, nicht die Farben von Header, Footer und Dialogen. */
[data-theme="light"] {
    color-scheme: light;
    --ink: #f4f1ea;
    --panel: #ffffff;
    --card: #faf8f3;
    --mist: #5b6475;
    --border: rgba(122, 95, 18, 0.28);
    --border2: rgba(0, 0, 0, 0.08);
    --text: #1f2430;
    --text-strong: #141821;
    --accent-text: #7a5f12;
    --focus: #7a5f12;
    --field: #ffffff;
    --key: rgba(0, 0, 0, 0.04);
    --key-hover: rgba(0, 0, 0, 0.09);
    --key-border: rgba(0, 0, 0, 0.14);
    --ok: #15803d;
    --warn: #a16207;
    --err: #b91c1c;
    --glow-gold: rgba(201, 168, 76, 0.14);
    --glow-blue: rgba(30, 58, 138, 0.05);
    --grid: rgba(122, 95, 18, 0.05);
}

/* ---------- 3. BASIS ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--ink);
    color: var(--text);
    font-family: var(--font-main);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.65;
}

/* Atmosphärische Hintergrund-Glows + feines Raster (Styleguide Abschnitt 2) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 60% 50% at 85% 0%, var(--glow-gold), transparent 70%),
        radial-gradient(ellipse 55% 55% at 0% 100%, var(--glow-blue), transparent 70%),
        repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px 48px),
        repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 48px);
}

body.modal-open { overflow: hidden; }

h1, h2 { margin: 0; font-family: var(--font-display); font-weight: 400; }
p { margin: 0; }
[hidden] { display: none !important; }

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

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 2000;
    padding: 0.6rem 1rem;
    background: var(--gold);
    color: var(--on-gold);
    font-weight: 600;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.noscript {
    position: relative;
    z-index: 1;
    padding: 1rem;
    text-align: center;
    background: var(--card);
    color: var(--text);
}

/* ---------- Buttons (Styleguide Abschnitt 4: eckig, versal, weites Letter-Spacing) ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.85rem 1.8rem;
    border: 0;
    border-radius: 2px;
    font-family: var(--font-main);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.btn-primary {
    background: var(--gold);
    color: var(--on-gold);
    border: 0;
    font-weight: 700;
}
.btn-primary:hover {
    background: var(--gold2);
    border-color: var(--gold2);
    box-shadow: 0 8px 28px rgba(201, 168, 76, 0.3);
    transform: translateY(-1px);
}
.btn-ghost {
    background: none;
    color: var(--mist);
    border: 1px solid rgba(139, 148, 168, 0.25);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--accent-text); }
.btn-block { width: 100%; margin-top: 1rem; }
.btn-small { min-height: 44px; padding: 0.5rem 1rem; }

/* ---------- 4. HEADER (bleibt in beiden Themes dunkel) ---------- */
.header {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 1.5rem;
    background: linear-gradient(var(--bar-bg), var(--bar-bg)), var(--bar-base);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--bar-border);
    color: var(--bar-text);
}
.header-left { flex: 0 0 auto; display: flex; align-items: center; }
.header-logo { display: block; width: 216px; height: 80px; object-fit: cover; object-position: center; }

.header-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 0;
}
.brand-name {
    font-size: 1.5rem;
    line-height: 1.2;
    font-family: var(--font-display);
    color: var(--gold);
    white-space: nowrap;
}
.app-name {
    margin-top: 0.15rem;
    font-size: 0.85rem;
    line-height: 1.3;
    color: var(--bar-text);
}
.header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 80px;
}
.bar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: 2px;
    color: var(--bar-text);
    font-size: 1.05rem;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.bar-btn:hover { border-color: var(--gold); color: var(--bar-hover); background: rgba(201, 168, 76, 0.1); }
.bar-btn:focus-visible { outline-color: var(--gold2); }

/* ---------- 5. NAVIGATION (Tabs) ---------- */
.cats {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: safe center;
    gap: 0.25rem;
    padding: 0 1rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border2);
    overflow-x: auto;
    scrollbar-width: thin;
}
.cat {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0.8rem 1rem;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--mist);
    font-family: var(--font-main);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.cat:hover { color: var(--accent-text); }
.cat.active { color: var(--accent-text); border-bottom-color: var(--gold); }
.cat:focus-visible { outline-offset: -3px; }

/* ---------- 6. INHALT ---------- */
.dash {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1.25rem calc(1rem + env(safe-area-inset-right)) calc(var(--footer-h) + 1.5rem) calc(1rem + env(safe-area-inset-left));
}
.card {
    width: 100%;
    max-width: 460px;
    padding: 1.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 2px;
}
.card h2 { margin-bottom: 1rem; font-size: 1.55rem; line-height: 1.25; color: var(--text-strong); }

/* ---------- 7. RECHNER ---------- */
.calculator-card { max-width: 360px; padding: 0.9rem; }

.display-area {
    margin-bottom: 0.6rem;
    padding: 0.5rem 0.8rem 0.6rem;
    background: var(--ink);
    border: 1px solid var(--border);
    border-radius: 2px;
}
.display-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 1.6rem; }
.angle-toggle {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0.15rem 0.55rem;
    background: none;
    border: 1px solid rgba(139, 148, 168, 0.3);
    border-radius: 2px;
    color: var(--mist);
    font-family: var(--font-main);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    cursor: pointer;
}
.angle-toggle:hover { border-color: var(--gold); color: var(--accent-text); }
.history-display {
    flex: 1;
    min-width: 0;
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--mist);
    text-align: right;
    overflow-wrap: anywhere;
}
.current-display {
    min-height: 2.6rem;
    padding: 0.3rem 0;
    font-size: 2rem;
    line-height: 1.25;
    color: var(--text-strong);
    text-align: right;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.current-display[data-len="m"] { font-size: 1.5rem; }
.current-display[data-len="l"] { font-size: 1.1rem; }

.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.keypad button {
    min-height: 48px;
    padding: 0.4rem;
    border: 1px solid var(--key-border);
    border-radius: 2px;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.2s ease;
}
.keypad button:active { transform: scale(0.97); }
.keypad button:focus-visible { outline-offset: 1px; }

.btn-num { background: var(--key); color: var(--text-strong); }
.btn-num:hover { background: var(--key-hover); }

.btn-op { background: rgba(201, 168, 76, 0.12); border-color: rgba(201, 168, 76, 0.3) !important; color: var(--accent-text); }
.btn-op:hover { background: rgba(201, 168, 76, 0.22); border-color: var(--gold) !important; }

.keypad .btn-sci {
    min-height: 44px;
    font-size: 0.8rem;
    background: rgba(139, 148, 168, 0.1);
    border-color: rgba(139, 148, 168, 0.25);
    color: var(--mist);
}
.keypad .btn-sci:hover { border-color: var(--gold); color: var(--accent-text); }

.keypad .btn-eq {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--on-gold);
    font-size: 1.15rem;
}
.keypad .btn-eq:hover { background: var(--gold2); border-color: var(--gold2); box-shadow: 0 6px 20px rgba(201, 168, 76, 0.3); }

/* ---------- 8. KONVERTER ---------- */
.converter-group { margin-bottom: 1rem; }
.converter-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--mist);
}
.converter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.input-field {
    width: 100%;
    min-height: 44px;
    padding: 0.7rem 0.8rem;
    background: var(--field);
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
}
.input-field:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }

.result-display {
    margin-top: 1.25rem;
    padding: 1rem;
    min-height: 3.6rem;
    background: var(--ink);
    border: 1px solid var(--border);
    border-radius: 2px;
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.3rem;
    line-height: 1.35;
    color: var(--accent-text);
    overflow-wrap: anywhere;
}
.result-display[data-state="info"] { color: var(--mist); font-family: var(--font-main); font-size: 0.95rem; }
.result-display[data-state="error"] { color: var(--err); font-family: var(--font-main); font-size: 0.95rem; }
.result-sub { margin-top: 0.35rem; font-family: var(--font-main); font-size: 0.8rem; color: var(--mist); }

.api-status { margin-bottom: 1rem; font-size: 0.85rem; color: var(--mist); }
.api-status[data-state="ok"] { color: var(--ok); }
.api-status[data-state="warn"] { color: var(--warn); }

.attribution { margin-top: 1rem; text-align: center; font-size: 0.7rem; color: var(--mist); }
.attribution a { color: var(--accent-text); text-decoration: none; }
.attribution a:hover { text-decoration: underline; }

/* ---------- 9. HISTORIE ---------- */
.history-list { max-height: 55vh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.history-item { padding: 0.75rem 0.25rem; border-bottom: 1px solid var(--border2); }
.history-item:last-child { border-bottom: 0; }
.history-expr { font-size: 0.85rem; color: var(--mist); overflow-wrap: anywhere; }
.history-result { font-size: 1.1rem; font-weight: 600; color: var(--accent-text); overflow-wrap: anywhere; }
.history-time { margin-top: 0.2rem; font-size: 0.7rem; color: var(--mist); }
.history-empty { padding: 2.5rem 1rem; text-align: center; color: var(--mist); }
.history-empty-icon { display: block; margin-bottom: 0.6rem; font-size: 2rem; }

/* ---------- 10. FOOTER (fixiert, bleibt in beiden Themes dunkel) ---------- */
.footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: minmax(max-content, 2fr) repeat(3, minmax(max-content, 1fr));
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 3rem;
    background: linear-gradient(var(--bar-bg), var(--bar-bg)), var(--bar-base);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--bar-border);
    color: var(--bar-text);
}
.footer-copyright { display: flex; align-items: center; gap: 0.75rem; justify-self: start; }
.footer > .footer-link { justify-self: center; }
.footer > .footer-link-right { justify-self: end; }
.copyright, .footer-link {
    font-family: var(--font-main);
    font-size: 0.58rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bar-text);
}
.copyright { white-space: nowrap; }
.version { font-family: var(--font-main); font-size: 0.55rem; color: var(--mist); }
.footer-link {
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
    transition: color 0.2s ease;
}
.footer-link:hover { color: var(--bar-hover); }
.footer-link:focus-visible { outline-color: var(--gold2); }

/* ---------- 11. OVERLAYS (Impressum, Datenschutz, Kontakt – immer dunkel) ---------- */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.88);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}
.overlay.open { display: flex; }
.modal {
    width: 100%;
    max-width: 860px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--modal-bg);
    color: var(--modal-text);
    border: 1px solid var(--border);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7), 0 0 60px rgba(201, 168, 76, 0.06);
}
.modal-hd {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.6rem 2rem;
    background: var(--modal-bg);
    border-bottom: 1px solid var(--border);
}
.modal-hd h2 { font-size: 1.55rem; color: #f0f1f5; }
.close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: 2px;
    color: #8b94a8;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}
.close-btn:hover { border-color: var(--gold); color: var(--gold); }
.modal-bd { padding: 2rem; line-height: 1.7; }
.modal-bd .blk { margin-bottom: 1.4rem; }
.modal-bd .blk strong { display: block; margin-bottom: 0.2rem; color: var(--gold2); font-weight: 600; }
.modal-bd a { color: var(--gold2); }
.modal :focus-visible { outline-color: var(--gold2); }

/* ---------- 12. HINWEISE ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--footer-h) + 0.75rem);
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: calc(100% - 2rem);
    padding: 0.6rem 0.6rem 0.6rem 1rem;
    background: var(--modal-bg);
    color: var(--modal-text);
    border: 1px solid var(--gold);
    font-size: 0.85rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ---------- 13. OFFLINE-SEITE ---------- */
.offline-page { align-items: center; justify-content: center; }
.offline {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 420px;
    padding: 1.5rem;
    text-align: center;
}
.offline-icon { margin-bottom: 1rem; font-size: 3.5rem; }
.offline h1 { margin-bottom: 0.8rem; font-size: 2rem; color: var(--gold); }
.offline p { margin-bottom: 1.5rem; color: var(--mist); }
.offline .offline-status { margin: 1.5rem 0 0; font-size: 0.8rem; }

/* ---------- 14. RESPONSIVE ---------- */
@media (min-width: 768px) and (max-height: 820px) {
    .header { padding-top: 0.25rem; padding-bottom: 0.25rem; }
    .header-logo { width: 180px; height: 72px; }
    .cats .cat { min-height: 40px; padding-top: 0.45rem; padding-bottom: 0.45rem; }
    .dash { align-items: center; padding: 0.6rem 1rem calc(var(--footer-h) + 0.6rem); }
    .card { padding: 1rem; }
    .card h2 { margin-bottom: 0.65rem; }
    .calculator-card { padding: 0.65rem; }
    .display-area { margin-bottom: 0.4rem; padding: 0.35rem 0.65rem; }
    .current-display { min-height: 2rem; font-size: 1.7rem; }
    .keypad { gap: 0.3rem; }
    .keypad button { min-height: 44px; padding: 0.25rem; }
    .keypad .btn-sci { min-height: 44px; }
    .converter-group { margin-bottom: 0.65rem; }
    .converter-group label { margin-bottom: 0.2rem; }
    .converter-row { gap: 0.75rem; }
    .input-field { min-height: 40px; padding: 0.5rem 0.65rem; }
    .btn { min-height: 40px; padding-top: 0.6rem; padding-bottom: 0.6rem; }
    .api-status { margin-bottom: 0.65rem; }
    .result-display { min-height: 3rem; margin-top: 0.75rem; padding: 0.6rem; }
    .attribution { margin-top: 0.55rem; }
    .history-list { max-height: 42vh; }
}

@media (max-width: 767px) {
    .header { padding: 0.4rem 1rem; gap: 0.5rem; }
    .header-logo { width: 124px; height: 64px; }
    .header-right { min-width: 0; }
    .brand-name { font-size: 1.2rem; }
    .app-name { font-size: 0.75rem; }
    .cats { justify-content: flex-start; }
    .cat { padding: 0.8rem 0.7rem; font-size: 0.62rem; letter-spacing: 0.1em; }
    .dash { padding: 0.75rem calc(0.75rem + env(safe-area-inset-right)) calc(var(--footer-h) + 1.25rem) calc(0.75rem + env(safe-area-inset-left)); }
    .card { padding: 1.1rem; }
    .calculator-card { max-width: 100%; padding: 0.75rem; }
    .modal-hd { padding: 1.1rem 1.25rem; }
    .modal-bd { padding: 1.25rem; }
    .overlay { padding: 0.75rem; }
}

@media (max-width: 600px) {
    .converter-row { grid-template-columns: 1fr; gap: 0; }
    .footer { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.35rem 0.5rem; padding: 0.4rem 0.75rem; }
    .footer-copyright { grid-column: 1 / -1; justify-self: center; }
    .footer > .footer-link { justify-self: center; }
    .footer > .footer-link-right { grid-column: 3; justify-self: center; }
    .copyright, .footer-link { font-size: 0.5rem; }
}

@media (min-width: 1440px) and (min-height: 821px) {
    .calculator-card { max-width: 400px; }
    .keypad button { min-height: 54px; }
    .current-display { font-size: 2.25rem; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .btn-sci { display: none; }
    .keypad button { min-height: 44px; }
}

/* ---------- STYLEGUIDE V13: Header, Navigation, Footer und Safe Areas ---------- */
.header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    min-height: 88px;
    gap: 1rem;
    padding: 6px max(1.25vw, calc((100vw - 1440px) / 2));
    padding-left: calc(max(1.25vw, (100vw - 1440px) / 2) + env(safe-area-inset-left));
    padding-right: calc(max(1.25vw, (100vw - 1440px) / 2) + env(safe-area-inset-right));
    background: rgba(8, 9, 13, 0.94);
    border-bottom-color: rgba(255, 255, 255, 0.07);
}
.header-left {
    width: 266px;
    height: 76px;
    overflow: hidden;
    justify-self: start;
}
.header-logo {
    width: 266px;
    height: 76px;
    object-fit: cover;
    object-position: center;
}
.header-center { grid-column: 2; grid-row: 1; }
.header-right {
    grid-column: 3;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    align-items: center;
    gap: 0.6rem;
}
.header-controls {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
}
.bar-btn { flex: 0 0 44px; }
.bar-btn[title="Darstellung wechseln"] { order: 2; }
#install-btn { order: 1; }

.header .cats {
    position: static;
    z-index: auto;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
    padding: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    background: transparent;
    border: 0;
}
.cat-list {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
}
.header .cat {
    min-height: 44px;
    padding: 0.55rem 0.55rem;
    border-bottom: 2px solid transparent;
    color: #e2e4ea;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
}
.header .cat:hover,
.header .cat.active { color: var(--gold2); }
.header .cat.active { border-bottom-color: var(--gold); }
.mobile-menu-head { display: none; }
.menu-toggle { display: none; order: 3; }

/* Footer-Metazeile und die drei Aktionen bleiben als getrennte Gruppen erhalten. */
.footer {
    grid-template-columns: minmax(0, 40fr) minmax(0, 60fr);
    min-height: 48px;
    gap: 8px;
    padding: 6px max(1.25vw, calc((100vw - 1440px) / 2));
    padding-left: calc(max(1.25vw, (100vw - 1440px) / 2) + env(safe-area-inset-left));
    padding-right: calc(max(1.25vw, (100vw - 1440px) / 2) + env(safe-area-inset-right));
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    background: rgba(8, 9, 13, 0.94);
    border-top-color: rgba(255, 255, 255, 0.07);
    color: #e2e4ea;
}
.footer-meta {
    grid-column: 1;
    display: flex;
    align-items: center;
    justify-self: start;
    flex-wrap: wrap;
    gap: 0.35rem 0.55rem;
    min-width: 0;
}
.footer-actions {
    grid-column: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 8px;
}
.copyright,
.footer-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: #e2e4ea;
}
.copyright { white-space: normal; }
.version { color: #8b94a8; font-size: 0.7rem; }
.footer-link { width: 100%; padding: 0.25rem 0.5rem; }
.footer-link:hover { color: var(--gold2); }

/* Lesbare Überschrift im Inhaltsbereich, ohne das Rechnerlayout zu verändern. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.api-status[data-state="ok"],
.api-status[data-state="warn"] { color: var(--mist); }
.result-display[data-state="error"] { color: var(--accent-text); }

.overlay,
.modal,
.modal-hd {
    --panel: #0f1116;
    --border: rgba(201, 168, 76, 0.15);
    --mist: #8b94a8;
    --modal-bg: #0f1116;
    --modal-text: #e2e4ea;
}
:root { --ok: #e8c97a; --warn: #e8c97a; --err: #e8c97a; }

@media (min-width: 768px) and (max-width: 1279px) {
    .header-left { width: 56px; }
    .header-logo { width: 266px; height: 76px; object-position: left center; transform: translateX(-30px); }
    .brand-name { font-size: 1.2rem; }
    .app-name { font-size: 0.72rem; }
    .header { gap: 0.5rem; }
    .header .cat { padding-inline: 0.35rem; font-size: 0.58rem; letter-spacing: 0.04em; }
    .header-controls { gap: 0.25rem; }
}

@media (max-width: 767px) {
    .header {
        grid-template-columns: 56px minmax(0, 1fr) auto;
        min-height: 76px;
        gap: 0.45rem;
        padding-top: 0;
        padding-bottom: 0;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .header-left { grid-column: 1; grid-row: 1; width: 56px; height: 64px; }
    .header-logo { width: 266px; height: 64px; object-position: left center; transform: translateX(-30px); }
    .header-center { grid-column: 2; grid-row: 1; }
    .brand-name { font-size: 1.15rem; }
    .app-name { margin-top: 0.05rem; font-size: 0.72rem; }
    .header-right { grid-column: 3; grid-row: 1; width: auto; gap: 0.35rem; }
    .header-controls { gap: 0.35rem; }
    .bar-btn { width: 42px; height: 42px; flex-basis: 42px; }
    .header .cats { display: none; }
    .header .cats[aria-hidden="true"] { visibility: hidden; }
    .menu-toggle { display: inline-flex; }
    .header .cats.is-open {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 1.5rem;
        padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
        overflow-y: auto;
        background: rgba(8, 9, 13, 0.98);
        -webkit-backdrop-filter: blur(18px);
        backdrop-filter: blur(18px);
    }
    .mobile-menu-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    }
    .mobile-menu-title {
        color: var(--gold2);
        font-family: var(--font-display);
        font-size: 1.5rem;
    }
    .menu-close {
        min-height: 44px;
        padding: 0.6rem 1rem;
        border: 1px solid rgba(139, 148, 168, 0.35);
        border-radius: 2px;
        background: transparent;
        color: #e2e4ea;
        font: 600 0.7rem var(--font-main);
        letter-spacing: 0.16em;
        text-transform: uppercase;
    }
    .menu-close:hover { border-color: var(--gold); color: var(--gold2); }
    .header .cat-list {
        display: flex;
        flex: 1 0 auto;
        flex-direction: column;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
    }
    .header .cat {
        justify-content: center;
        width: 100%;
        text-align: center;
        min-height: 52px;
        padding: 0.8rem 1rem;
        border: 0;
        color: #e2e4ea;
        font-family: var(--font-display);
        font-size: 1.35rem;
        font-weight: 400;
        letter-spacing: 0.02em;
        text-transform: none;
    }
    .header .cat.active { color: var(--gold2); }
    .header .cat:focus-visible { outline-offset: -2px; }
    body.menu-open { overflow: hidden; }
    body.menu-open .header { z-index: 1001; }

    .footer {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
        padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
        padding-left: calc(12px + env(safe-area-inset-left));
        padding-right: calc(12px + env(safe-area-inset-right));
    }
    .footer-meta,
    .footer-actions { grid-column: 1; }
    .footer-meta { justify-self: center; justify-content: center; text-align: center; }
    .footer-actions { gap: 4px; }
    .footer-link { min-height: 40px; padding-inline: 0.25rem; font-size: 0.62rem; }
    .copyright { font-size: 0.62rem; }
    .version { font-size: 0.62rem; }
    .dash { padding-bottom: calc(var(--footer-h) + 1.25rem + env(safe-area-inset-bottom)); }
    .overlay { padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left)); }
}

@media (max-width: 360px) {
    .header { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 0.25rem; }
    .header-left { width: 48px; }
    .header-logo { width: 266px; height: 64px; transform: translateX(-30px); }
    .brand-name { font-size: 1rem; }
    .app-name { font-size: 0.65rem; }
    .header-controls { gap: 0.2rem; }
    .bar-btn { width: 38px; height: 40px; flex-basis: 38px; }
}

.offline-icon { color: var(--gold2); font-family: var(--font-display); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}


/* ---------- STYLEGUIDE V15: mobile menu icon and update consent ---------- */
.menu-toggle {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--gold2);
}
.hamburger-line {
    display: block;
    flex: 0 0 2px;
    width: 20px;
    min-width: 20px;
    height: 2px;
    border-radius: 0;
    background: var(--gold2);
}
.menu-toggle:hover .hamburger-line,
.menu-toggle:focus-visible .hamburger-line { background: #e8c97a; }
.update-available { color: var(--gold2); font-size: 1.3rem; }
.update-toast {
    left: 50%;
    right: auto;
    width: min(680px, calc(100% - 24px));
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1rem;
    border-color: var(--gold);
    transform: translateX(-50%);
}
.update-copy { display: grid; gap: 0.25rem; }
.update-copy strong { color: var(--gold2); font-family: var(--font-display); font-size: 1.2rem; font-weight: 400; }
.update-copy span { color: #e2e4ea; line-height: 1.5; }
.update-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
.update-actions .btn-ghost { color: #e2e4ea; border: 1px solid rgba(139,148,168,0.4); }
.update-actions .btn-ghost:hover { color: var(--gold2); border-color: var(--gold); }
@media (max-width: 360px) {
    .brand-name { font-size: 0.8rem; }
    .app-name { font-size: 0.58rem; }
    .hamburger-line { width: 20px; min-width: 20px; flex-basis: 2px; }
}


/* ---------- Originalbildmarke und Theme-Button, Release 1.4.13 ---------- */
/* logo.png (3:2) enthält breiten schwarzen Rand; der Ausschnitt (~4:1) wird über --logo-h zugeschnitten. */
.header {
    --logo-h: 40px;
}
.header-left {
    width: calc(var(--logo-h) * 4);
    height: var(--logo-h);
    overflow: hidden;
    position: relative;
    display: block;
}
.header-logo {
    position: absolute;
    display: block;
    width: calc(var(--logo-h) * 5.366);
    max-width: none;
    height: auto;
    left: calc(var(--logo-h) * -0.7686);
    top: calc(var(--logo-h) * -1.1354);
    transform: none;
    mix-blend-mode: lighten;
}
#theme-toggle {
    flex: 0 0 66px;
    width: 66px;
    height: 66px;
    border-color: rgba(201, 168, 76, 0.32);
    color: var(--gold2);
}
.theme-icon {
    display: block;
    width: 29px;
    height: 29px;
    overflow: visible;
    fill: var(--gold2);
    stroke: var(--gold2);
    stroke-width: 3.2;
    stroke-linecap: round;
}
.theme-icon path { fill: none; }
#theme-toggle:hover .theme-icon { fill: #f3d889; stroke: #f3d889; }
@media (min-width: 768px) {
    .header { min-height: 80px; }
    .header-left { height: 68px; }
}
@media (min-width: 768px) and (max-width: 1279px) {
    .header { --logo-h: 36px; }
    .header-left { grid-column: 1; width: calc(var(--logo-h) * 4); height: var(--logo-h); }
    #theme-toggle { flex-basis: 48px; width: 48px; height: 48px; }
    .theme-icon { width: 25px; height: 25px; }
}
@media (max-width: 767px) {
    .header { --logo-h: 34px; grid-template-columns: max-content minmax(0, 1fr) auto; }
    .header-left { grid-column: 1; grid-row: 1; width: calc(var(--logo-h) * 4); height: var(--logo-h); }
    .header-center { grid-column: 2; grid-row: 1; min-width: 0; }
    .brand-name { display: none; }
    .header-right { grid-column: 3; grid-row: 1; }
    #theme-toggle { flex-basis: 44px; width: 44px; height: 44px; }
    .theme-icon { width: 24px; height: 24px; }
}
@media (max-width: 380px) {
    .header { grid-template-columns: max-content minmax(0, 1fr) auto; gap: 0.2rem; padding-left: calc(8px + env(safe-area-inset-left)); padding-right: calc(8px + env(safe-area-inset-right)); }
    .header { --logo-h: 30px; }
    .header-left { width: calc(var(--logo-h) * 4); height: var(--logo-h); }
    .app-name { font-size: 0.54rem; }
    .header-right { gap: 0.18rem; }
    .header-controls { gap: 0.15rem; }
    .bar-btn { width: 36px; height: 40px; flex-basis: 36px; }
    #theme-toggle { width: 44px; height: 44px; flex-basis: 44px; }
    .theme-icon { width: 23px; height: 23px; }
}
