/* Gleitcast - Light Theme (City Guide Style) */

:root {
    /* Colors - Light palette (Aviation Blue) */
    --color-primary: #0369a1;
    --color-primary-vivid: #075985;
    --color-primary-light: #e0f2fe;
    --color-primary-glow: rgba(3, 105, 161, 0.12);
    --color-bg: #f7f8fc;
    --color-bg-elevated: #ffffff;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-light: #475569;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;
    --color-border: #e5e7eb;
    --color-border-hover: #d1d5db;
    --color-card: #ffffff;

    /* Light glass */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-bg-light: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-blur: 14px;

    /* Spacing - 8px base system */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-12: 48px;
    --space-16: 64px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 100px;
    --card-radius: 16px;

    /* Shadows - Soft, layered */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.06);

    /* Safety Semantic Colors (ONE palette everywhere) */
    --color-safety-excellent: #22c55e;
    --color-safety-good: #84cc16;
    --color-safety-marginal: #f59e0b;
    --color-safety-critical: #ef4444;
    --color-safety-unknown: #94a3b8;

    /* Safety Badge Backgrounds */
    --color-safety-excellent-bg: #dcfce7;
    --color-safety-excellent-text: #166534;
    --color-safety-marginal-bg: #fef3c7;
    --color-safety-marginal-text: #92400e;
    --color-safety-critical-bg: #fee2e2;
    --color-safety-critical-text: #991b1b;
    --color-safety-unknown-bg: #f3f4f6;
    --color-safety-unknown-text: #6b7280;
    --color-safety-nodata-bg: #ffedd5;
    --color-safety-nodata-text: #9a3412;

    /* Fly Tier Colors */
    --color-fly-gray: #B08D57;          /* Bronze — Abgleiter (was slate #94a3b8) */
    --color-fly-gray-bg: #F5EDE0;       /* warm cream bg */
    --color-fly-gray-text: #6B5430;     /* dark bronze text */
    --color-fly-green: #22c55e;
    --color-fly-green-bg: #dcfce7;
    --color-fly-green-text: #166534;
    --color-fly-violet: #8b5cf6;
    --color-fly-violet-bg: #ede9fe;
    --color-fly-violet-text: #6d28d9;

    /* Weather Tier Tokens — drive meteogram cell coloring per LLM rating.
       Three tiers map 1:1 to KERNREGEL (_hazard_blocks.md): RUHIG / SPORTLICH / UNFLIEGBAR.
       Fill intensity is the primary glance channel (empty / 40% / 100%); hue is the
       secondary channel. Amber ↔ Rose luminance delta keeps tiers distinguishable
       for red-green and tritanope color vision. */
    --tier-calm:         #10B981;            /* emerald — RUHIG (text on empty cells) */
    --tier-calm-strong:  #047857;            /* dark emerald — strong wind number on calm bg */
    --tier-caution:      #F59E0B;            /* amber hue — SPORTLICH */
    --tier-caution-bg:   rgba(245, 158, 11, 0.38);  /* 38% fill — distinct from empty */
    --tier-caution-text: #78350F;            /* amber-900 — 7.2:1 contrast on caution-bg */
    --tier-danger:       #E11D48;            /* rose — UNFLIEGBAR (distinct from amber for CB) */
    --tier-danger-bg:    #E11D48;            /* 100% saturated fill */
    --tier-danger-text:  #FFFFFF;            /* 5.77:1 on danger-bg */

    /* Typography Scale (7 steps) */
    --text-xs: 0.6875rem;    /* 11px */
    --text-sm: 0.75rem;      /* 12px */
    --text-base: 0.8125rem;  /* 13px */
    --text-md: 0.875rem;     /* 14px */
    --text-lg: 1rem;         /* 16px */
    --text-xl: 1.25rem;      /* 20px */
    --text-2xl: 1.5rem;      /* 24px */

    /* Misc */
    --grid-line: rgba(0, 0, 0, 0.06);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--color-primary);
    color: white;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}


/* ===== NAVIGATION ===== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.navbar-brand span {
    background: linear-gradient(135deg, var(--color-primary), #0284c7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-day-tabs {
    display: flex;
    gap: 2px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    padding: 2px;
}

.navbar-day-btn {
    padding: 5px 12px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.navbar-day-btn:hover {
    color: var(--color-text);
    background: rgba(0, 0, 0, 0.05);
}

.navbar-day-btn.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

.navbar-links {
    display: flex;
    gap: 4px;
}

.navbar-links a {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.navbar-links a:hover {
    color: var(--color-text);
    background: rgba(0, 0, 0, 0.04);
}

.navbar-links a.active {
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.navbar-links .navbar-link-btn {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.navbar-links .navbar-link-btn:hover {
    color: var(--color-text);
    background: rgba(0, 0, 0, 0.04);
}

/* Avatar-Button + Dropdown-Menu (eingeloggter User) */
.navbar-avatar-wrap {
    position: relative;
    margin-left: 4px;
    display: inline-flex;
    align-items: center;
}
.navbar-avatar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 4px 4px;
    border: none;
    background: transparent;
    border-radius: 999px;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: background 0.15s;
    font-family: inherit;
}
.navbar-avatar:hover,
.navbar-avatar-wrap.is-open .navbar-avatar {
    background: rgba(0, 0, 0, 0.04);
}
.navbar-avatar__initial {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary-vivid) 0%, var(--color-primary) 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 3px var(--color-primary-glow);
}
.navbar-avatar__chev {
    color: var(--color-text-muted);
    transition: transform 0.15s;
}
.navbar-avatar-wrap.is-open .navbar-avatar__chev {
    transform: rotate(180deg);
}

.navbar-menu[hidden] { display: none; }
.navbar-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 6px;
    z-index: 3000;
    animation: navMenuIn 0.12s ease-out;
}
@keyframes navMenuIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.navbar-menu__email {
    padding: 10px 12px 8px;
    font-size: 12px;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 4px;
}
.navbar-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--color-text);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.1s;
}
.navbar-menu__item:hover {
    background: var(--color-primary-light);
    color: var(--color-primary-vivid);
}
.navbar-menu__item svg { flex-shrink: 0; opacity: 0.7; }
.navbar-menu__item--muted { color: var(--color-text-secondary); }
.navbar-menu__item--muted:hover { background: rgba(0, 0, 0, 0.04); color: var(--color-text); }

/* Globaler Footer (Rechtliches) — dezent, auf jeder Seite */
.app-footer {
    text-align: center;
    padding: 16px 12px 24px;
    font-size: 11.5px;
    color: var(--color-text-muted);
    background: transparent;
    line-height: 1.6;
}
.app-footer a {
    color: var(--color-text-muted);
    text-decoration: none;
    margin: 0 6px;
    border-bottom: 1px dotted transparent;
    transition: color 0.15s, border-color 0.15s;
}
.app-footer a:hover {
    color: var(--color-text);
    border-bottom-color: var(--color-text-muted);
}
/* Auf Seiten mit Fixed-Layout (chat) Footer ueberlagert nicht den Hauptinhalt */
.page-fixed-nav .app-footer {
    display: none;
}

/* Chat-Locked-Card (anonyme User auf der Hauptseite) */
.chat-locked {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 28px;
    text-align: center;
    background: linear-gradient(180deg,
        var(--color-bg) 0%,
        var(--color-primary-light) 100%);
}
.chat-locked__icon {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--color-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    margin-bottom: 18px;
    box-shadow: 0 4px 16px var(--color-primary-glow);
}
.chat-locked__title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
}
.chat-locked__lead {
    margin: 0 0 16px;
    font-size: 14.5px;
    color: var(--color-text-secondary);
}
.chat-locked__list {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    text-align: left;
    max-width: 280px;
    width: 100%;
}
.chat-locked__list li {
    position: relative;
    padding: 7px 0 7px 28px;
    font-size: 14px;
    color: var(--color-text);
    line-height: 1.45;
}
.chat-locked__list li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 13px;
    width: 6px;
    height: 11px;
    border: solid var(--color-primary);
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}
.chat-locked__cta {
    padding: 13px 30px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--color-primary-glow);
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.chat-locked__cta:hover {
    background: var(--color-primary-vivid);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--color-primary-glow);
}
.chat-locked__hint {
    margin: 14px 0 0;
    font-size: 12.5px;
    color: var(--color-text-muted);
}

/* Login-Modal */
.login-modal[hidden] { display: none; }
.login-modal {
    position: fixed; inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.login-modal__backdrop {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}
.login-modal__panel {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 28px 26px 22px;
    z-index: 1;
}
.login-modal__close {
    position: absolute;
    top: 8px; right: 12px;
    border: none; background: transparent;
    font-size: 26px; line-height: 1;
    color: #9ca3af; cursor: pointer;
    padding: 4px 8px;
}
.login-modal__close:hover { color: #111827; }
.login-modal__title {
    margin: 0 0 6px;
    font-size: 20px; font-weight: 700; color: #111827;
}
.login-modal__hint {
    margin: 0 0 18px;
    font-size: 13.5px; line-height: 1.5; color: #4b5563;
}
.login-modal__form {
    display: flex; flex-direction: column; gap: 10px;
}
.login-modal__input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: #f9fafb;
    transition: border-color 0.15s, background-color 0.15s;
    box-sizing: border-box;
}
.login-modal__input:focus {
    outline: none;
    border-color: #7c3aed;
    background: #fff;
}
.login-modal__submit {
    padding: 11px 18px;
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px; font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.login-modal__submit:hover { background: #6d28d9; }
.login-modal__msg {
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.5;
    min-height: 1em;
}
.login-modal__msg--info { color: #6b7280; }
.login-modal__msg--ok   { color: #047857; }
.login-modal__msg--err  { color: #b91c1c; }
.login-modal__foot {
    margin: 18px 0 0;
    padding-top: 14px;
    border-top: 1px solid #f3f4f6;
    font-size: 12.5px; color: #6b7280;
    text-align: center;
}
.login-modal__foot a { color: #7c3aed; text-decoration: none; }
.login-modal__foot a:hover { text-decoration: underline; }


/* ===== PAGE LAYOUT (shared across pages with fixed navbar) ===== */
/* Pages that need a fixed navbar + full-height layout use these */
.page-fixed-nav .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    height: 60px;
}

.page-fixed-nav body,
body.page-fixed-nav {
    padding-top: 60px;
}

/* Floating map controls (used on index + regionen) */
.floating-control {
    position: absolute;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.floating-day-tabs {
    top: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 10px;
    max-width: calc(100% - 120px);
    overflow-x: auto;
}

/* Desktop: inline day-name + date (single row per button) */
.floating-day-tabs .navbar-day-btn .day-name,
.floating-day-tabs .navbar-day-btn .day-date {
    display: inline;
}
.floating-day-tabs .navbar-day-btn .day-date::before { content: ' '; }

.floating-day-tab {
    padding: 6px 14px;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: inherit;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: 0.01em;
    min-height: 40px;
    touch-action: manipulation;
}

.floating-day-tab:hover {
    color: var(--color-text);
    background: rgba(0, 0, 0, 0.05);
}

.floating-day-tab.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

/* ===== BUTTON SYSTEM ===== */
/* 4 semantic variants + 2 sizes */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    font-size: var(--text-base);
    cursor: pointer;
    transition: all var(--transition-fast);
    touch-action: manipulation;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Sizes */
.btn-sm {
    padding: 6px 12px;
    min-height: 32px;
    font-size: var(--text-sm);
}

.btn-md, .btn:not(.btn-sm) {
    padding: 8px 16px;
    min-height: 40px;
}

/* Primary: filled accent */
.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-vivid);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(3, 105, 161, 0.3);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

/* Secondary: border + subtle bg */
.btn-secondary {
    background: var(--color-bg-elevated);
    color: var(--color-text-secondary);
    border-color: var(--color-border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-color: rgba(3, 105, 161, 0.3);
}

/* Ghost: transparent, hover-bg */
.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text);
}

.btn-ghost.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* Danger: red subtle */
.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

.btn-danger:hover:not(:disabled) {
    background: #fecaca;
    border-color: #f87171;
}

/* Button spinner */
.btn .spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-text,
.btn.loading .btn-label { display: none; }

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

/* ===== CHAT ===== */
.chat-container {
    max-width: 800px;
    margin: 0 auto;
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    padding: 16px;
}

/* Analysis Area */
.analysis-area {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.analyze-btn {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--color-primary);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.2);
    font-family: inherit;
}

.analyze-btn:hover:not(:disabled) {
    background: var(--color-primary-vivid);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(3, 105, 161, 0.3);
}

.analyze-btn:active:not(:disabled) {
    transform: translateY(0);
}

.analyze-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.analyze-btn.success {
    background: var(--color-safety-excellent);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.2);
}

.analysis-status {
    font-size: 12px;
    color: var(--color-text-muted);
    letter-spacing: 0.01em;
}

/* Messages */
.chat-messages {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding: 12px 2px 20px 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
}

.chat-message,
.message {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.68;
    animation: messageIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-message.user,
.user-message {
    align-self: flex-end;
    max-width: min(92%, 520px);
    background: var(--color-primary);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 12px rgba(3, 105, 161, 0.2);
}

.chat-message.bot,
.bot-message {
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    white-space: normal;
}

.message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    color: var(--color-text);
}

.message-content > *:first-child {
    margin-top: 0;
}

.message-content > *:last-child {
    margin-bottom: 0;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 14px 0 8px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.35;
    color: var(--color-text);
}

.message-content h1 { font-size: 1.15rem; }
.message-content h2 { font-size: 1.05rem; color: #334155; }
.message-content h3 { font-size: 0.98rem; color: #475569; }

.message-content p {
    margin: 0 0 10px;
}

.message-content ul,
.message-content ol {
    margin: 8px 0 12px;
    padding-left: 1.35em;
}

.message-content li {
    margin: 4px 0;
}

.message-content li::marker {
    color: var(--color-primary);
}

.message-content blockquote {
    margin: 12px 0;
    padding: 10px 14px 10px 16px;
    border-left: 3px solid var(--color-primary);
    background: var(--color-primary-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--color-text-light);
    font-size: 0.96em;
}

.message-content hr {
    border: none;
    height: 1px;
    margin: 18px 0;
    background: var(--color-border);
}

.message-content table {
    width: 100%;
    min-width: min(100%, 320px);
    border-collapse: collapse;
    font-size: 12.75px;
    line-height: 1.45;
    margin: 12px 0 16px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.message-content thead {
    background: var(--color-primary-light);
}

.message-content th,
.message-content td {
    border: 1px solid var(--color-border);
    padding: 9px 11px;
    text-align: left;
    vertical-align: top;
}

.message-content th {
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}

.message-content tbody tr:nth-child(even) {
    background: #f8fafc;
}

.message-content tbody tr:hover {
    background: var(--color-primary-light);
}

.message-content code {
    background: #f1f5f9;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.88em;
    font-family: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', monospace;
    border: 1px solid var(--color-border);
    color: #be185d;
}

.message-content pre {
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: #1e293b;
    border: 1px solid #334155;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12.5px;
    line-height: 1.5;
    color: #e2e8f0;
}

.message-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

.message-content strong {
    color: var(--color-text);
    font-weight: 600;
}

.user-message .message-content {
    color: #ffffff;
}

.user-message .message-content h1,
.user-message .message-content h2,
.user-message .message-content h3,
.user-message .message-content h4 {
    color: #ffffff;
}

.user-message .message-content strong {
    color: rgba(255, 255, 255, 0.98);
}

.user-message .message-content blockquote {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.12);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.user-message .message-content code {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

.user-message .message-content li::marker {
    color: rgba(255, 255, 255, 0.7);
}

/* Typing Indicator */
.typing-indicator {
    align-self: flex-start;
    padding: 14px 20px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    display: none;
    box-shadow: var(--shadow-sm);
}

.typing-indicator.visible {
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-text-muted);
    animation: typingPulse 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingPulse {

    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: scale(0.85);
    }

    40% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* Quick Actions — see also mobile overrides at bottom */

/* Chat Input — see textarea + send-btn rules at bottom of file */


/* ===== DATA FRESHNESS INDICATOR (Status Pill) ===== */
.data-freshness {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: default;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.data-freshness:empty {
    display: none;
}

.data-freshness::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-safety-unknown);
    flex-shrink: 0;
}

.data-freshness.fresh {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.25);
    color: var(--color-safety-excellent-text);
}

.data-freshness.fresh::before {
    background: var(--color-safety-excellent);
}

.data-freshness.stale {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
    color: var(--color-safety-marginal-text);
}

.data-freshness.stale::before {
    background: var(--color-safety-marginal);
}

.data-freshness.old {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--color-safety-critical-text);
}

.data-freshness.old::before {
    background: var(--color-safety-critical);
}

/* ===== MAP ===== */
.map-container {
    height: calc(100vh - 60px);
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}


/* ===== METEOGRAM OVERLAY ===== */
.meteogram-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.meteogram-overlay.visible {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlayIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes overlayIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.meteogram-panel {
    width: 96vw;
    max-width: 1800px;
    height: 92vh;
    background: var(--color-bg-elevated);
    border-radius: var(--card-radius);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: panelIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes panelIn {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Mobile slide-up animation */
@media (max-width: 1023px) {
    .meteogram-panel {
        animation: panelSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        max-height: 85dvh;
    }

    @keyframes panelSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

.meteogram-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid var(--color-border);
    background: #fafbfc;
}

.meteogram-header h2 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--color-text);
}

.meteogram-header .spot-info {
    color: var(--color-text-muted);
    font-size: 12px;
    margin-top: 2px;
}

.meteogram-header-text {
    min-width: 0;
    flex: 1;
}

.meteogram-rating-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    padding: 8px 14px;
    margin-right: 12px;
    border-radius: var(--radius-sm, 6px);
    background: var(--color-fly-gray-bg, #F5EDE0);
    color: var(--color-fly-gray-text, #6B5430);
    border: 1px solid var(--color-fly-gray, #B08D57);
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.meteogram-rating-badge.tier-green {
    background: rgba(34, 197, 94, 0.12);
    color: #166534;
    border-color: #22c55e;
}

.meteogram-rating-badge.tier-violet {
    background: rgba(139, 92, 246, 0.14);
    color: #5b21b6;
    border-color: #8b5cf6;
}

.meteogram-rating-badge.tier-not-safe {
    background: rgba(239, 68, 68, 0.12);
    color: #991b1b;
    border-color: #ef4444;
}

.meteogram-rating-badge.is-conditional::after {
    content: "⚠";
    margin-left: 6px;
    font-size: 0.9em;
}

.meteogram-rating-value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.meteogram-rating-label {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.meteogram-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.meteogram-close:hover {
    background: #f1f5f9;
    color: var(--color-text);
    border-color: var(--color-border-hover);
}

.meteogram-share {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    padding: 0;
    margin-right: 6px;
    flex-shrink: 0;
}

.meteogram-share:hover,
.meteogram-share:focus-visible {
    background: #25D366;
    border-color: #25D366;
    color: #fff;
    outline: none;
    box-shadow: 0 2px 6px rgba(37, 211, 102, 0.35);
}

.meteogram-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 28px;
    border-bottom: 1px solid var(--color-border);
    background: #fafbfc;
}

.tab-btn {
    padding: 7px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.tab-btn:hover {
    background: #f1f5f9;
    color: var(--color-text-light);
}

.tab-btn.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-color: rgba(3, 105, 161, 0.2);
}

/* Desktop: day-name + date inline (single line, space-separated). */
.tab-btn .day-name,
.tab-btn .day-date {
    display: inline;
}
.tab-btn .day-date::before { content: ' '; }

.meteogram-chart {
    flex: 1;
    overflow: auto;
    padding: 20px;
    min-height: 0;
    min-width: 0;
    /* Scrollbar dezent — Desktop kann scrollen wenn nötig, aber subtil */
    scrollbar-width: thin;
}

/* MOBILE: Chart wird via JS auf Container-Größe gerendert. Vertikal-Scroll
   nur als Fallback wenn die Analyse aufgeklappt wird und der Chart nicht
   mehr in den verbleibenden Platz passt. */
@media (max-width: 640px) {
    .meteogram-chart {
        overflow-x: hidden;
        overflow-y: auto;
        padding: 8px 10px;
        scrollbar-width: none;
    }
    .meteogram-chart::-webkit-scrollbar { display: none; }
    .meteogram-chart svg {
        max-width: 100%;
        display: block;
    }
}

/* Tier legend — shows what cell colors mean, always visible above meteogram */
.mg-tier-legend {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 0 10px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.mg-tier-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: var(--radius-pill);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-light);
    line-height: 1;
}
.mg-tier-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.mg-tier-caution { color: #78350F; }
.mg-tier-danger  { color: #9f1239; }

/* Numbers-Toggle: blendet Wind/Böe/Thermik-Zahlen in Cells ein/aus.
   Mobile-Default ON. Sitzt rechts in der Tier-Legenden-Bar (margin-left: auto).
   Touch-Target ≥44×44 nach Apple HIG, sichtbarer State über Hintergrund-Farbe. */
.mg-numbers-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    background: var(--color-bg-elevated);
    color: #1E293B;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
    -webkit-tap-highlight-color: transparent;
}
.mg-numbers-toggle:hover {
    background: #E2E8F0;
}
.mg-numbers-toggle:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}
.mg-numbers-toggle--off {
    background: transparent;
    color: #94A3B8;
    border-style: dashed;
}
.mg-numbers-toggle--off:hover {
    background: #F1F5F9;
    color: #64748B;
}
.mg-numbers-toggle svg {
    pointer-events: none;
    overflow: visible;
}

/* Scrubber-Info: überlagert die Tier-Legende während Touch-Drag.
   Position absolute innerhalb der relativen Legend-Bar → Zeigt Werte für
   die aktuell berührte Stunde + Höhe. Finger ist immer UNTER dieser Zeile,
   verdeckt nichts. Layout-shift = 0 (gleiche Box wie Legend-Pills). */
.mg-tier-legend {
    position: relative;
}
.mg-legend-content {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    transition: opacity 120ms ease;
}
.mg-tier-legend.mg-scrubbing .mg-legend-content {
    opacity: 0;
    pointer-events: none;
}
.mg-scrub-info {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, #F0F9FF 0%, #FFFFFF 60%, var(--color-primary-light) 100%);
    border: 1px solid var(--color-primary);
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.18);
    color: var(--color-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 12px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.mg-tier-legend.mg-scrubbing .mg-scrub-info {
    opacity: 1;
}
.mg-scrub-time {
    font-weight: 700;
    color: var(--color-primary);
    flex-shrink: 0;
}
.mg-scrub-divider {
    color: var(--color-text-muted);
    flex-shrink: 0;
}
.mg-scrub-vals {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text);
}
.mg-scrub-vals b {
    color: var(--color-primary-vivid);
    font-weight: 700;
    margin-right: 2px;
}
@media (prefers-reduced-motion: reduce) {
    .mg-legend-content,
    .mg-scrub-info { transition: none; }
}

/* Föhn diagram should never horizontally scroll on mobile — chart scales to fit */
@media (max-width: 639px) {
    #foehnChart {
        overflow-x: hidden;
    }
    #foehnChart svg {
        max-width: 100%;
        height: auto;
    }
}

/* ===== METEOGRAM BODY: chart + analysis aside (responsive) ===== */
.meteogram-body {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0;
    overflow: hidden;
}

.meteogram-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.meteogram-aside {
    flex: 0 0 380px;
    width: 380px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--color-border);
    background: #fafbfc;
    min-height: 0;
    overflow: hidden;
}

.meteogram-aside-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--color-border);
    background: #fff;
}

.meteogram-aside-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.meteogram-aside-toggle {
    display: none; /* hidden on desktop, shown on mobile */
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 14px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
}

.meteogram-aside-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* Narrower aside on smaller desktops */
@media (max-width: 1280px) and (min-width: 1024px) {
    .meteogram-aside {
        flex: 0 0 320px;
        width: 320px;
    }
}

/* Tablet & Mobile: stack vertically, aside becomes collapsible panel below chart */
@media (max-width: 1023px) {
    .meteogram-panel {
        width: 100vw;
        height: 100vh;
        max-width: none;
        border-radius: 0;
        border: none;
    }

    .meteogram-body {
        flex-direction: column;
    }

    .meteogram-main {
        flex: 1 1 auto;
        min-height: 45vh;
    }

    .meteogram-aside {
        flex: 0 0 auto;
        width: 100%;
        max-height: 45vh;
        border-left: none;
        border-top: 1px solid var(--color-border);
    }

    .meteogram-aside-toggle {
        display: flex;
    }

    .meteogram-aside.collapsed .meteogram-aside-body {
        display: none;
    }

    .meteogram-aside.collapsed {
        max-height: none;
        flex: 0 0 auto;
    }

    .meteogram-aside.collapsed .meteogram-aside-toggle {
        transform: rotate(180deg);
    }
}


/* ===== METEOGRAM SVG STYLES ===== */
.grid-line {
    stroke: var(--grid-line);
    stroke-width: 0.5;
}

.axis-label {
    fill: var(--color-text-muted);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
}

.time-label {
    fill: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
}

.wind-value {
    text-anchor: middle;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
}

.therm-value {
    text-anchor: middle;
    font-size: 10px;
    font-weight: 700;
    fill: #1E293B;
    font-family: 'Inter', sans-serif;
}

.ground-bg {
    fill: #f8fafc;
}

.ground-divider {
    stroke: var(--color-border);
    stroke-width: 1.5;
}

.ground-label {
    fill: var(--color-text-muted);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
}

.ground-value {
    text-anchor: middle;
    font-family: 'Inter', sans-serif;
}

.ground-temp {
    fill: #64748b;
}

.crosshair-v,
.crosshair-h {
    stroke: rgba(3, 105, 161, 0.2);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    opacity: 0;
    transition: opacity 0.15s;
}

.crosshair-v.visible,
.crosshair-h.visible {
    opacity: 1;
}

.error-state {
    text-align: center;
    padding: 48px;
    color: var(--color-text-muted);
    font-size: 14px;
}


/* ===== FOEHN DIAGRAM AXIS STYLES ===== */
.foehn-axis text {
    fill: var(--color-text-muted);
    font-size: 10px;
    font-family: 'Inter', sans-serif;
}

.foehn-axis line,
.foehn-axis path {
    stroke: var(--color-border);
}

.foehn-axis-label {
    fill: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
}

/* ===== TOOLTIP ===== */
.tooltip {
    position: fixed;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    font-size: 12.5px;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 300;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    min-width: 190px;
    box-shadow: var(--shadow-lg);
    color: var(--color-text);
}

.tooltip.visible {
    opacity: 1;
}

.tooltip-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--color-text);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 3px 0;
}

.tooltip-label {
    color: var(--color-text-muted);
    font-size: 12px;
}

.tooltip-value {
    font-weight: 500;
    font-size: 12px;
    color: var(--color-text);
}


/* ===== MAP TOOLTIP (Light) ===== */
.map-tooltip.leaflet-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.5;
    color: #1e293b;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.map-tooltip.leaflet-tooltip::before {
    border-top-color: rgba(255, 255, 255, 0.95);
}

/* Mobile: popup uses same visual style as tooltip */
.map-tooltip.leaflet-popup .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    font-size: 12px;
    line-height: 1.5;
    color: #1e293b;
}

.map-tooltip.leaflet-popup .leaflet-popup-content {
    margin: 8px 12px;
}

.map-tooltip.leaflet-popup .leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.95);
}


/* ===== MAP LEGEND ===== */
.map-legend {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    font-size: var(--text-sm);
    overflow: hidden;
}

.map-legend-toggle {
    display: block;
    width: 100%;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.map-legend-toggle:hover {
    color: var(--color-text);
}

.map-legend-body {
    padding: 4px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.map-legend.collapsed .map-legend-body {
    display: none;
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-secondary);
}

.map-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Default collapsed on mobile */
@media (max-width: 639px) {
    .map-legend {
        font-size: var(--text-xs);
    }
}

/* Mobile: day tabs at the bottom-center (thumb-reach), above the bottom nav,
   two-line square buttons, no horizontal scroll */
@media (max-width: 639px) {
    .floating-day-tabs {
        top: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        bottom: calc(var(--space-4) + 60px + env(safe-area-inset-bottom, 0px));
        gap: 4px;
        padding: 4px;
        border-radius: 12px;
        max-width: calc(100vw - 16px);
        overflow-x: visible;
    }
    .floating-day-tabs .navbar-day-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        padding: 6px 6px;
        min-width: 46px;
        line-height: 1.15;
        border-radius: 8px;
    }
    .floating-day-tabs .navbar-day-btn .day-name {
        display: block;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.03em;
    }
    .floating-day-tabs .navbar-day-btn .day-date {
        display: block;
        font-size: 10px;
        opacity: 0.85;
        font-variant-numeric: tabular-nums;
    }
    .floating-day-tabs .navbar-day-btn .day-date::before { content: none; }
}

/* ===== CUSTOM MARKER & HIGHLIGHT ANIMATION ===== */
.custom-spot-marker {
    background: transparent;
    border: none;
    cursor: pointer;
}

.custom-spot-marker:hover {
    z-index: 1000 !important;
}

.custom-spot-marker svg {
    transition: transform var(--transition-base), filter var(--transition-base);
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.15));
}

.custom-spot-marker:hover svg {
    transform: scale(1.15);
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}

.custom-spot-marker:active svg {
    transform: scale(0.95);
}

.highlight-pulse {
    animation: markerPulse 1.5s infinite;
    transform-origin: center;
}

@keyframes markerPulse {
    0% {
        filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.3));
    }

    50% {
        filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.6));
    }

    100% {
        filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.3));
    }
}


/* ===== CHAT VISUALIZATIONS ===== */

/* D3/SVG chart containers in chat */
.chat-chart-placeholder {
    margin: 12px 0;
    border-radius: 8px;
    background: #fafbfc;
    border: 1px solid var(--color-border);
    overflow: hidden;
    min-height: 100px;
}

.chat-chart-placeholder svg {
    display: block;
    width: 100%;
}

.chart-loading {
    padding: 40px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
}

.chart-error {
    padding: 24px;
    text-align: center;
    color: #ef4444;
    background: #fef2f2;
    border-radius: 8px;
    font-size: 13px;
}

.chart-legend {
    display: flex;
    gap: 12px;
    padding: 6px 12px;
    font-size: 11px;
    border-top: 1px solid var(--color-border);
    flex-wrap: wrap;
    color: var(--color-text-secondary);
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chart-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(30, 41, 59, 0.92);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    z-index: 1000;
    white-space: nowrap;
}

/* Meteogram in chat */
.chat-meteogram {
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    overflow-x: auto;
    min-height: 400px;
    background: var(--color-bg-elevated);
}

.chat-meteogram .meteogram-chart {
    padding: 12px;
}

/* Mini-map in chat */
.chat-minimap {
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    height: 250px;
    overflow: hidden;
}

.chat-minimap .leaflet-container {
    border-radius: 8px;
}

/* Chart.js in chat */
.chartjs-container {
    margin: 12px 0;
    border-radius: 8px;
    background: #fafbfc;
    border: 1px solid var(--color-border);
    padding: 12px;
}

.chartjs-container canvas {
    max-height: 280px;
}

/* Chart title */
.chat-chart-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    padding: 8px 12px 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}


/* ===== RESPONSIVE ===== */
/* Tablet: 640-1023px */
@media (max-width: 1023px) {
    .chat-container {
        padding: 8px;
    }

    .chat-message.user,
    .user-message {
        max-width: 92%;
        font-size: var(--text-base);
    }

    .chat-message.bot,
    .bot-message {
        max-width: 100%;
        font-size: var(--text-base);
    }

    .meteogram-panel {
        width: 98vw;
        height: 92vh;
        border-radius: var(--radius-lg);
    }

    .navbar {
        padding: 0 16px;
    }

    .meteogram-header {
        padding: 16px 20px;
    }

    .meteogram-tabs {
        padding: 8px 20px;
    }

    .meteogram-chart {
        padding: 12px;
    }
}

/* Mobile: <640px */
@media (max-width: 639px) {
    .navbar-brand {
        font-size: 17px;
    }

    /* Sheet-Look: Panel sitzt unten, Karte bleibt oben sichtbar (~80px peek).
       Bottom-Sheet-Pattern statt Vollbild-Modal — User behält Map-Kontext. */
    .meteogram-overlay.visible {
        align-items: flex-end;
        background: rgba(0, 0, 0, 0.35);
    }
    .meteogram-panel {
        width: 100vw;
        height: calc(100dvh - 60px);
        max-height: calc(100dvh - 60px);
        border-radius: 20px 20px 0 0;
        border: none;
        border-top: 1px solid var(--color-border);
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    /* Drag-Handle prominenter machen — visuelles Sheet-Affordance */
    .meteogram-panel .overlay-swipe-handle {
        display: block;
        width: 40px;
        height: 4px;
        background: var(--color-border-hover, #cbd5e1);
        border-radius: 2px;
        margin: 8px auto 4px;
    }

    /* Header kompakter — mehr Platz für Chart */
    .meteogram-header {
        padding: 8px 16px 10px;
    }
    .meteogram-header h2 {
        font-size: 15px;
    }
    .meteogram-header .spot-info {
        font-size: 11px;
        margin-top: 1px;
    }
    .meteogram-rating-badge {
        padding: 4px 10px;
    }
    .meteogram-rating-value {
        font-size: 18px;
    }
    .meteogram-share,
    .meteogram-close {
        width: 32px;
        height: 32px;
    }

    /* View-Tabs kompakter (Meteogramm/Text) */
    .meteogram-view-tabs {
        padding: 6px 12px;
    }

    /* Day tabs sollen ohne Scroll auf den Bildschirm passen — gleiche
       Optik wie .floating-day-tabs auf der Karte: Wochentag oben, DD.MM unten. */
    .meteogram-tabs {
        flex-wrap: nowrap;
        justify-content: center;
        padding: 6px 8px;
        gap: 4px;
        overflow-x: visible;
        scrollbar-width: none;
    }
    .meteogram-tabs::-webkit-scrollbar { display: none; }

    .tab-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 5px 4px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        line-height: 1.15;
    }
    .tab-btn .day-name {
        display: block;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.03em;
    }
    .tab-btn .day-date {
        display: block;
        font-size: 10px;
        opacity: 0.85;
        font-variant-numeric: tabular-nums;
    }
    .tab-btn .day-date::before { content: none; }

    /* Aside läuft im Flex-Flow (unter dem Chart). Beim Aufklappen schrumpft
       das Meteogramm nach oben — kein Overlay über dem Chart mehr. */
    .meteogram-aside {
        position: static;
        flex: 0 0 auto;
        width: 100%;
        max-height: 55vh;
        background: var(--color-bg-elevated, #fff);
        border-top: 1px solid var(--color-border);
        border-left: none;
        border-radius: 0;
        box-shadow: none;
        transition: max-height 250ms cubic-bezier(0.4, 0, 0.2, 1);
    }
    .meteogram-aside.collapsed {
        max-height: 44px;
        border-radius: 0;
    }
    .meteogram-main {
        flex: 1 1 auto;
        min-height: 0;
        padding-bottom: 0;
    }
    .meteogram-aside-header {
        padding: 10px 16px;
        cursor: pointer;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    .meteogram-aside-toggle {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: var(--color-primary, #0369a1);
        color: #fff;
        border: none;
        font-size: 14px;
        font-weight: 700;
        box-shadow: 0 1px 3px rgba(0,0,0,0.15);
        transition: transform 200ms cubic-bezier(0.4,0,0.2,1);
    }
    .meteogram-aside.collapsed .meteogram-aside-toggle {
        transform: rotate(0deg);
    }
    .meteogram-aside:not(.collapsed) .meteogram-aside-toggle {
        transform: rotate(180deg);
    }
    /* Aside-Body bekommt nur dezenten Scrollbar wenn Inhalt überläuft */
    .meteogram-aside-body {
        scrollbar-width: thin;
        padding: 12px 16px env(safe-area-inset-bottom, 16px);
    }
    .meteogram-aside-body::-webkit-scrollbar { width: 4px; }
    .meteogram-aside-body::-webkit-scrollbar-thumb {
        background: var(--color-border-hover, #cbd5e1);
        border-radius: 2px;
    }
}

/* ============================================================================
   VIEW TABS (Meteogramm / Text)
   ============================================================================ */

.meteogram-view-tabs {
    display: flex;
    gap: 2px;
    padding: 8px 28px 0;
    background: #fafbfc;
    border-bottom: 1px solid var(--color-border);
}

.view-tab {
    padding: 6px 16px;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.view-tab:hover {
    color: var(--color-text-light);
    background: rgba(0, 0, 0, 0.02);
}

.view-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

/* Model toggle (D2 / CH1) inline in view-tabs row */
.model-toggle {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-left: auto;
    padding-right: 4px;
}
.model-label {
    font-size: 10px;
    color: var(--color-text-muted);
    margin-right: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.model-btn {
    padding: 2px 10px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    line-height: 1.4;
}
.model-btn:hover:not(:disabled) {
    color: var(--color-text-light);
    border-color: var(--color-border-hover);
}
.model-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.model-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ============================================================================
   TEXT VIEW (Meteogramm als Tabelle)
   ============================================================================ */

.mg-text-view {
    padding: 12px 16px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}

.mg-text-header {
    font-size: 13px;
    color: var(--color-text-secondary);
    padding: 0 0 8px 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 8px;
}

.mg-text-header strong {
    color: var(--color-text);
    font-weight: 700;
}

.mg-text-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.mg-text-hint {
    font-size: 11px;
    color: var(--color-text-muted);
    font-style: italic;
}

.mg-text-copy-btn {
    appearance: none;
    border: 1px solid var(--color-border);
    background: #f8fafc;
    color: var(--color-text);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.mg-text-copy-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.mg-text-copy-btn:active {
    background: #cbd5e1;
}

.mg-text-json {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 10px 12px;
    background: #0f172a;
    color: #e2e8f0;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', 'Menlo', monospace;
    font-size: 11px;
    line-height: 1.45;
    border-radius: 6px;
    overflow: auto;
    white-space: pre;
    word-break: normal;
    user-select: text;
    -webkit-user-select: text;
    tab-size: 2;
}

@media (max-width: 639px) {
    .mg-text-view {
        padding: 8px 10px 12px;
    }
    .mg-text-header { font-size: 12px; }
    .mg-text-json { font-size: 10px; padding: 8px 10px; }
    .mg-text-hint { display: none; }
}

/* ============================================================================
   ANALYSE VIEW (LLM Spot-Analyse) — Pilot Decision Flow
   ============================================================================ */

.mg-analysis-view {
    padding: 14px 18px 18px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--color-text);
    line-height: 1.5;
    box-sizing: border-box;
}

.mg-analysis-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg);
    background: #fafbfc;
    line-height: 1.6;
}

/* ── Level 1: Decision Hero Banner ─────────────────────── */
.mga-decision {
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.mga-decision-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
    line-height: 1;
}

.mga-decision-text {
    flex: 1;
    min-width: 0;
}

.mga-decision-status {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    line-height: 1.2;
}

.mga-decision-sub {
    font-size: 12px;
    margin-top: 2px;
    opacity: 0.85;
}

/* Decision variants */
.mga-decision.safe {
    background: var(--color-safety-excellent-bg);
    color: var(--color-safety-excellent-text);
    border: 1px solid #86efac;
}
.mga-decision.safe .mga-decision-icon {
    background: var(--color-safety-excellent);
    color: #fff;
}

.mga-decision.conditional {
    background: var(--color-safety-marginal-bg);
    color: var(--color-safety-marginal-text);
    border: 1px solid #fcd34d;
}
.mga-decision.conditional .mga-decision-icon {
    background: var(--color-safety-marginal);
    color: #fff;
}

.mga-decision.not_safe {
    background: var(--color-safety-critical-bg);
    color: var(--color-safety-critical-text);
    border: 1px solid #fca5a5;
}
.mga-decision.not_safe .mga-decision-icon {
    background: var(--color-safety-critical);
    color: #fff;
}

.mga-decision.unknown {
    background: var(--color-safety-unknown-bg);
    color: var(--color-safety-unknown-text);
    border: 1px solid #d1d5db;
}
.mga-decision.unknown .mga-decision-icon {
    background: var(--color-safety-unknown);
    color: #fff;
}

/* ── Level 2: Best Window Highlight ──────────────────── */
.mga-window {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #166534;
}

.mga-window-icon {
    font-size: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.mga-window-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #15803d;
    opacity: 0.75;
}

.mga-window-time {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

/* ── Level 3: Key Metrics Grid ────────────────────────── */
.mga-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 12px;
}

.mga-metric {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: #f8fafc;
    border: 1px solid var(--color-border);
}

.mga-metric-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}

.mga-metric-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
}

.mga-metric.full-width {
    grid-column: 1 / -1;
}

/* ── Level 4: Safety Alerts ──────────────────────────── */
.mga-alerts {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.mga-alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 12.5px;
    line-height: 1.45;
}

.mga-alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    margin-top: 1px;
}

.mga-alert.nogo {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.mga-alert.nogo .mga-alert-icon {
    background: #ef4444;
    color: #fff;
}

.mga-alert.caution {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.mga-alert.caution .mga-alert-icon {
    background: #f59e0b;
    color: #fff;
}

.mga-alert.flyability {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
}

.mga-alert.flyability .mga-alert-icon {
    background: #f97316;
    color: #fff;
}

.mga-alert.positive {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.mga-alert.positive .mga-alert-icon {
    background: #22c55e;
    color: #fff;
}

/* ── Level 5: AI Insights (Expandable) ───────────────── */
.mga-insights {
    margin-bottom: 8px;
}

.mga-insight {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 6px;
}

.mga-insight:last-child {
    margin-bottom: 0;
}

.mga-insight-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fafbfc;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    text-align: left;
    transition: background 0.15s;
}

.mga-insight-toggle:hover {
    background: #f1f5f9;
}

.mga-insight-toggle::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid var(--color-text-muted);
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    transition: transform 0.15s;
    flex-shrink: 0;
}

.mga-insight.open .mga-insight-toggle::before {
    transform: rotate(90deg);
}

.mga-insight-body {
    display: none;
    padding: 8px 12px 10px;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--color-text-light);
    border-top: 1px solid var(--color-border);
}

.mga-insight.open .mga-insight-body {
    display: block;
}

.mga-insight.safety .mga-insight-toggle {
    color: var(--color-primary);
}

.mga-insight.flyability .mga-insight-toggle {
    color: var(--color-safety-excellent-text);
}

/* ── Fly Quality Badge Row ────────────────────────────── */
.mga-fly-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.mga-fly-badge.gray  { background: var(--color-fly-gray-bg);   color: var(--color-fly-gray-text); }
.mga-fly-badge.green { background: var(--color-fly-green-bg);  color: var(--color-fly-green-text); }
.mga-fly-badge.violet { background: var(--color-fly-violet-bg); color: var(--color-fly-violet-text); }

/* ── Streckenflug-Metric + Badge ─────────────────────────── */
.mga-metric.streckenflug .mga-metric-value {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mga-sf-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.mga-sf-badge.kein_xc  { background: #eef1f4; color: #64748b; }
.mga-sf-badge.lokal    { background: #e0f2fe; color: #0369a1; }
.mga-sf-badge.moderat  { background: #dcfce7; color: #15803d; }
.mga-sf-badge.top      { background: #f3e8ff; color: #7c3aed; }

.mga-sf-rating {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.mga-sf-ctx-warn {
    font-size: 13px;
    color: #d97706;
    cursor: help;
}

.mga-insight.streckenflug .mga-insight-toggle {
    color: #7c3aed;
}

.mga-sf-limit-note {
    margin-top: 8px;
    padding: 6px 10px;
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    border-radius: 2px;
    font-size: 11.5px;
    color: #92400e;
    font-weight: 600;
}

/* ── Datestamp ────────────────────────────────────────── */
.mg-analysis-datestamp {
    padding: 6px 18px 14px;
    font-size: 11px;
    color: var(--color-text-muted);
    text-align: right;
}

/* ── Mobile adjustments ──────────────────────────────── */
@media (max-width: 639px) {
    .mg-analysis-view {
        padding: 10px 12px 14px;
        font-size: 12px;
    }
    .mga-decision { padding: 12px 14px; }
    .mga-decision-status { font-size: 15px; }
    .mga-decision-icon { width: 34px; height: 34px; font-size: 16px; }
    .mga-metrics { gap: 4px; }
    .mga-metric { padding: 6px 8px; }
    .mga-metric-value { font-size: 12px; }
    .mga-window-time { font-size: 14px; }
}


/* Responsive: view tabs + model toggle on mobile */
@media (max-width: 639px) {
    .meteogram-view-tabs {
        padding: 6px 16px 0;
    }
    .view-tab {
        padding: 5px 10px;
        font-size: 12px;
    }
    .model-label {
        display: none;
    }
    .model-btn {
        padding: 2px 8px;
        font-size: 10px;
    }
}

/* ============================================================================
   Stale-Banner für Meteogramm (Fix #3: Cache nicht vollständig refresht)
   ============================================================================ */
.meteogram-stale-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-left: 4px solid #ffc107;
    color: #856404;
    padding: 10px 14px;
    margin: 8px 16px 4px;
    font-size: 12px;
    line-height: 1.45;
    border-radius: 4px;
}
.meteogram-stale-banner strong {
    color: #664d03;
}

/* ============================================================================
   SKIP LINK (Accessibility)
   ============================================================================ */

.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 100000;
    padding: 8px 16px;
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 8px;
}

/* Visually hidden but accessible to screen readers */
.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;
}

/* ============================================================================
   MOBILE BOTTOM NAVIGATION (global, in base.html)
   ============================================================================ */

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid var(--color-border);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    padding: 4px 8px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    gap: 0;
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    min-height: 48px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 10px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: color var(--transition-fast);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}

.mobile-nav-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.mobile-nav-item.active {
    color: var(--color-primary);
}

.mobile-nav-item:hover {
    color: var(--color-text-light);
}

.mobile-nav-item.active:hover {
    color: var(--color-primary);
}

@media (max-width: 639px) {
    .mobile-nav {
        display: flex;
    }

    /* Hide navbar links on mobile — navigation is in bottom nav */
    .navbar-links {
        display: none;
    }

    .navbar {
        height: 48px;
        padding: 0 12px;
        padding-top: env(safe-area-inset-top, 0px);
    }

    .navbar-day-tabs {
        gap: 1px;
        padding: 2px;
    }

    .navbar-day-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* ============================================================================
   CHAT TEXTAREA (replaces input)
   ============================================================================ */

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 0 4px;
    align-items: flex-end;
}

textarea.chat-input {
    flex: 1;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
    color: var(--color-text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-sm);
    resize: none;
    overflow-y: hidden;
    min-height: 42px;
    max-height: 160px;
    line-height: 1.5;
}

textarea.chat-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.1);
}

textarea.chat-input::placeholder {
    color: var(--color-text-muted);
}

/* Send button as icon on mobile */
.chat-send-btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--color-primary);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 2px 10px rgba(3, 105, 161, 0.2);
    font-family: inherit;
    min-height: 42px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--color-primary-vivid);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(3, 105, 161, 0.25);
}

.chat-send-btn:active {
    transform: translateY(0);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-send-btn .send-icon {
    display: none;
    width: 20px;
    height: 20px;
}

.chat-send-btn .send-label {
    display: inline;
}

@media (max-width: 639px) {
    textarea.chat-input {
        font-size: 16px; /* prevent iOS zoom */
    }

    .chat-send-btn {
        padding: 10px 12px;
    }

    .chat-send-btn .send-icon {
        display: block;
    }

    .chat-send-btn .send-label {
        display: none;
    }
}

/* Quick Actions: above input, always visible */
.quick-actions {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar {
    display: none;
}

/* Compact mode: smaller chips after first message */
.quick-actions.compact {
    gap: 6px;
    padding: 4px 0;
}

.quick-actions.compact .quick-btn {
    padding: 6px 12px;
    min-height: 32px;
    font-size: var(--text-sm);
    border-radius: var(--radius-pill);
    background: transparent;
    border-color: var(--color-border);
    box-shadow: none;
}

.quick-actions.compact .quick-btn:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-color: rgba(3, 105, 161, 0.3);
    transform: none;
    box-shadow: none;
}

/* ============================================================================
   TOUCH TARGETS (minimum 44x44px)
   ============================================================================ */

.quick-btn {
    padding: 10px 16px;
    min-height: 44px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    box-shadow: var(--shadow-sm);
    touch-action: manipulation;
}

.quick-btn:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-color: rgba(3, 105, 161, 0.3);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.tab-btn {
    padding: 10px 18px;
    min-height: 44px;
    touch-action: manipulation;
}

.view-tab {
    padding: 10px 16px;
    min-height: 44px;
    touch-action: manipulation;
}

.floating-day-tab {
    padding: 8px 14px;
    min-height: 40px;
    touch-action: manipulation;
}

.meteogram-close {
    width: 44px;
    height: 44px;
    touch-action: manipulation;
}

.reset-btn {
    min-height: 40px;
    padding: 8px 14px;
    touch-action: manipulation;
}

/* Global touch-action on interactive elements */
button, a, input, textarea, select, [role="button"] {
    touch-action: manipulation;
}

/* ============================================================================
   OVERLAY SCROLL LOCK & BOTTOM-SHEET MOBILE
   ============================================================================ */

body.overlay-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Swipe handle on overlay header (mobile) */
.overlay-swipe-handle {
    display: none;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.15);
    margin: 8px auto 0;
}

@media (max-width: 1023px) {
    .meteogram-panel {
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    .overlay-swipe-handle {
        display: block;
    }

    .meteogram-overlay.visible {
        align-items: flex-end;
    }
}

/* ============================================================================
   ONBOARDING HINTS
   ============================================================================ */

.onboarding-hint {
    position: absolute;
    z-index: 10001;
    background: var(--color-primary);
    color: white;
    font-size: var(--text-sm);
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
    animation: hintFadeIn 0.3s ease-out;
    pointer-events: none;
}

.onboarding-hint::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--color-primary);
}

@keyframes hintFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================================
   MORNING BRIEFING CARD
   ============================================================================ */

.morning-briefing {
    padding: 18px 20px;
    border-radius: var(--radius-lg);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    animation: messageIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.morning-briefing-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.morning-briefing-header .briefing-icon {
    font-size: 16px;
}

.morning-briefing-header .briefing-timestamp {
    margin-left: auto;
    font-size: 11px;
    font-weight: 400;
    opacity: 0.6;
    text-transform: none;
    letter-spacing: 0;
}

.briefing-spot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    margin-bottom: 12px;
}

.briefing-tier-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.briefing-tier-badge.tier-green {
    background: var(--color-fly-green-bg);
    color: var(--color-fly-green-text);
}

.briefing-tier-badge.tier-violet {
    background: var(--color-fly-violet-bg);
    color: var(--color-fly-violet-text);
}

.briefing-tier-badge.tier-gray {
    background: var(--color-fly-gray-bg);
    color: var(--color-fly-gray-text);
}

.briefing-tier-badge.tier-not-safe {
    background: var(--color-safety-critical-bg);
    color: var(--color-safety-critical-text);
}

.briefing-spot-info {
    flex: 1;
    min-width: 0;
}

.briefing-spot-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
}

.briefing-spot-summary {
    font-size: 12.5px;
    color: var(--color-text-secondary);
    line-height: 1.45;
}

.briefing-details {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.briefing-detail-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    font-size: 11.5px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.briefing-detail-chip .chip-icon {
    font-size: 13px;
}

.briefing-actions {
    display: flex;
    gap: 8px;
}

.briefing-actions .btn {
    flex: 1;
}

/* Best-day label above the expanded region card */
.briefing-best-day-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-tertiary);
    margin-bottom: 6px;
}

/* Flyable region names hint below the best card */
.briefing-region-hint {
    font-size: 11.5px;
    color: var(--color-text-tertiary);
    margin: -6px 0 10px;
    padding-left: 52px; /* align with spot-info text */
}

/* Week divider line between today + future rows */
.briefing-week-divider {
    height: 1px;
    background: var(--color-border);
    margin: 14px 0 10px;
}

/* Compact tier dot for week rows */
.briefing-tier-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 11px;
    flex-shrink: 0;
}

.briefing-tier-dot.tier-green {
    background: var(--color-fly-green-bg);
    color: var(--color-fly-green-text);
}

.briefing-tier-dot.tier-violet {
    background: var(--color-fly-violet-bg);
    color: var(--color-fly-violet-text);
}

.briefing-tier-dot.tier-gray {
    background: var(--color-fly-gray-bg);
    color: var(--color-fly-gray-text);
}

.briefing-tier-dot.tier-not-safe {
    background: var(--color-safety-critical-bg);
    color: var(--color-safety-critical-text);
}

/* Single compact week row */
.briefing-week-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.briefing-week-row:hover {
    background: var(--color-bg);
}

.week-row-day {
    width: 42px;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.week-row-spot {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--color-text);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.week-row-meta {
    font-size: 11px;
    color: var(--color-text-tertiary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* CTA variant: pulsing border for "Analyse starten" */
.briefing-cta {
    text-align: center;
    padding: 20px;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
    animation: messageIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.briefing-cta-text {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.briefing-cta .btn {
    min-width: 200px;
}


/* ============================================================================
   SKELETON LOADING (replaces typing dots for chat)
   ============================================================================ */

.skeleton-loading {
    padding: 16px 18px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    margin-bottom: 10px;
}

.skeleton-line:last-child {
    margin-bottom: 0;
    width: 60%;
}

.skeleton-line:nth-child(2) {
    width: 85%;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================================
   RESPONSIVE OVERRIDES (consolidated)
   ============================================================================ */

@media (max-width: 639px) {
    /* Content padding consistency */
    .chat-container {
        padding: 12px;
    }

    .meteogram-header {
        padding: 12px 16px;
    }

    .meteogram-tabs {
        padding: 8px 16px;
    }

    .meteogram-chart {
        padding: 12px;
    }

    .meteogram-view-tabs {
        padding: 6px 16px 0;
    }

    /* Resizer wider touch area on mobile */
    .resizer {
        width: 100%;
        height: 12px;
        cursor: row-resize;
    }

    .resizer::after {
        width: 40px;
        height: 4px;
    }
}
