/**
 * Mobile Top Nav Island
 * Mobile/Tablet: ab max-width 1024px sichtbar, fixed oben.
 * Profil, Feedback, Chat, AI, ggf. Control Panel + Abstimmung.
 */

/* Desktop: Mobile-Top-Nav ausblenden */
@media (min-width: 1025px) {
    .mobile-top-nav-row {
        display: none !important;
    }
}

@media (max-width: 1024px) {
    /*
     * Kein Pull-to-Refresh / kein „Seite mitziehen“ beim Über-scrollen; kein Doppel-Tap-Zoom auf Klicks.
     * (Pinch-Zoom bleibt möglich.) Gilt für alle Menüs, solange Mobile-Layout aktiv ist.
     */
    html {
        overscroll-behavior: none;
        overscroll-behavior-y: none;
        overscroll-behavior-x: none;
    }

    /* Top-/Bottom-Abstand: Top-Nav-Insel (Icon+Label) — Chat+KI nebeneinander, etwas niedriger als früher Säule */
    body {
        /* KINMA-Zeile + kompakte Inseln (Chat+KI und Top-Nav gleiche Höhe) */
        --kinma-mobile-viewport-inset-band: 84px;
        --kinma-mobile-island-sublabel-fs: 9px;
        --kinma-mobile-island-sublabel-lh: 1.15;
        padding-top: calc(var(--kinma-mobile-viewport-inset-band) + env(safe-area-inset-top, 0));
        padding-bottom: calc(var(--kinma-mobile-viewport-inset-band) + env(safe-area-inset-bottom, 0));
        overscroll-behavior: none;
        overscroll-behavior-y: none;
        overscroll-behavior-x: none;
        touch-action: manipulation;
        -webkit-text-size-adjust: 100%;
    }

    /* If chat input is focused and bottom nav is hidden, reclaim space at bottom */
    body.mobile-chat-input-focused {
        padding-bottom: env(safe-area-inset-bottom, 0) !important;
    }
    /* Media/Hangout: Content geht bis oben, Banner kann hinter Top-Nav laufen */
    body:has(.media-container) {
        padding-top: 0 !important;
    }

    .mobile-top-nav-row {
        /* Innenhöhe der Pille; Kreise = 95 % davon (etwas Luft zum Rand) */
        --kinma-mtn-island-pad-y: 2px;
        --kinma-mtn-island-pad-x: 4px;
        /* Etwas höher: Untertitel + Marquee nicht am unteren Pillenrand abschneiden */
        --kinma-mtn-pill-inner-h: 50px;
        --kinma-mtn-btn: calc(var(--kinma-mtn-pill-inner-h) * 0.95);
        --kinma-mtn-island-height: calc(var(--kinma-mtn-pill-inner-h) + (2 * var(--kinma-mtn-island-pad-y)));
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 10002;
        padding: 10px;
        padding-top: calc(10px + env(safe-area-inset-top, 0));
        padding-left: max(10px, env(safe-area-inset-left, 0));
        padding-right: max(10px, env(safe-area-inset-right, 0));
        padding-bottom: 10px;
        pointer-events: none;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    /* KINMA: nur Flaggenring (außen) + innerer Kreis + Logo – kein äußerer Button-Ring; klickbar für Legal-Slide-up */
    .mobile-kinma-island {
        position: relative;
        flex-shrink: 0;
        align-self: center;
        width: var(--kinma-mtn-island-height);
        height: var(--kinma-mtn-island-height);
        min-width: var(--kinma-mtn-island-height);
        min-height: var(--kinma-mtn-island-height);
        max-width: var(--kinma-mtn-island-height);
        max-height: var(--kinma-mtn-island-height);
        aspect-ratio: 1;
        border-radius: 9999px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
        -webkit-tap-highlight-color: transparent;
        padding: 0;
        cursor: pointer;
        font: inherit;
        pointer-events: auto;
    }
    .mobile-kinma-island .kinma-lang-outline {
        position: absolute;
        inset: -2px;
        border-radius: 50%;
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        z-index: 0;
        pointer-events: none;
        border: 2px solid rgba(255, 255, 255, 0.95);
        box-sizing: border-box;
    }
    .mobile-kinma-island .kinma-lang-inner {
        position: absolute;
        inset: 12%;
        border-radius: 50%;
        background: #ffffff;
        box-sizing: border-box;
        z-index: 1;
        pointer-events: none;
    }
    .mobile-kinma-island-img {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        z-index: 2;
        width: 48%;
        height: 48%;
        margin: 0;
        object-fit: contain;
        display: block;
    }
    .mobile-kinma-island:hover .kinma-lang-outline,
    .mobile-kinma-island:focus-visible .kinma-lang-outline {
        border-color: rgba(255, 255, 255, 1);
        filter: brightness(1.03);
    }

    /*
     * Chat + KI: nebeneinander, je eine quadratische Zelle (1:1) — Icon oben, Kurzlabel unten.
     */
    .mobile-chat-ai-island {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
        flex-shrink: 0;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: center;
        gap: 4px;
        box-sizing: border-box;
        height: var(--kinma-mtn-island-height);
        min-height: var(--kinma-mtn-island-height);
        max-height: var(--kinma-mtn-island-height);
        padding: var(--kinma-mtn-island-pad-y) var(--kinma-mtn-island-pad-x);
        min-width: 0;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 9999px;
        box-shadow:
            0 2px 12px rgba(0, 0, 0, 0.08),
            0 2px 8px rgba(0, 0, 0, 0.04),
            inset 0 1px 0 rgba(255, 255, 255, 0.85);
        pointer-events: auto;
        overflow: hidden;
    }

    .mobile-chat-ai-island .mobile-top-nav-item {
        box-sizing: border-box;
        width: var(--kinma-mtn-btn);
        min-width: var(--kinma-mtn-btn);
        max-width: var(--kinma-mtn-btn);
        height: var(--kinma-mtn-btn);
        min-height: var(--kinma-mtn-btn);
        max-height: var(--kinma-mtn-btn);
        aspect-ratio: 1 / 1;
        padding: 1px 2px 2px;
        gap: 2px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        border-radius: 9999px;
        overflow: hidden;
        touch-action: manipulation;
    }

    .mobile-chat-ai-island .mobile-top-nav-item .mobile-nav-item-label {
        display: block !important;
        flex: 0 1 auto;
        min-height: 0;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        color: inherit;
        font-size: var(--kinma-mobile-island-sublabel-fs, 9px);
        line-height: var(--kinma-mobile-island-sublabel-lh, 1.15);
        text-align: center;
        white-space: nowrap;
        text-overflow: ellipsis;
        opacity: 0.9;
        pointer-events: none;
        align-self: center;
    }

    /* Nav nimmt nur Restplatz bis linke Islands (KINMA + Chat-AI) – max-width implizit */
    .mobile-top-nav {
        flex: 1 1 0%;
        min-width: 0;
        /* auto: zuverlässige Touch-/Klick-Ziele auf Mobilgeräten (nicht nur Kinder mit auto) */
        pointer-events: auto;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .mobile-top-nav-island {
        pointer-events: auto;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 4px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        height: var(--kinma-mtn-island-height);
        min-height: var(--kinma-mtn-island-height);
        max-height: var(--kinma-mtn-island-height);
        padding: var(--kinma-mtn-island-pad-y) var(--kinma-mtn-island-pad-x);
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 9999px;
        box-shadow:
            0 2px 12px rgba(0, 0, 0, 0.08),
            0 2px 8px rgba(0, 0, 0, 0.04),
            inset 0 1px 0 rgba(255, 255, 255, 0.85);
        overflow: hidden;
        color: #1a1a1a;
    }

    /* Links: scrollbarer Bereich wie Bottom-Nav – bei vielen Items horizontal scrollen, sonst Platz aufteilen */
    .mobile-top-nav-items {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 4px;
        flex: 1 1 0%;
        min-width: 0;
        min-height: 0;
        height: 100%;
        width: 100%;
        align-self: stretch;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pinch-zoom;
        scroll-behavior: smooth;
        position: relative;
        padding: 0 2px 0 4px;
        box-sizing: border-box;
    }
    .mobile-top-nav-items::-webkit-scrollbar {
        display: none !important;
        width: 0;
        height: 0;
    }

    /* Trennlinie zwischen scrollbaren Items und Einstellungen/Profil */
    .mobile-top-nav-separator {
        flex-shrink: 0;
        align-self: center;
        height: calc(var(--kinma-mtn-btn) * 0.55);
        min-height: 20px;
        max-height: calc(var(--kinma-mtn-btn) * 0.65);
        margin: 0 2px;
    }

    /* Rechts: Einstellungen + Profil — space-between braucht Mindestbreite, sonst shrink-wrap ohne Freiraum */
    .mobile-top-nav-right-group {
        flex: 0 0 auto;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0;
        min-width: calc(2 * var(--kinma-mtn-btn) + 12px);
        padding: 0 2px 0 4px;
        box-sizing: border-box;
    }

    /* Einstellungen: wie scrollbare Items (Icon oben, Kurzlabel unten, Marquee bei langem Text) */
    #mobile-top-nav .mobile-top-nav-right-group .mobile-top-nav-item:not(.mobile-top-nav-profile-link) {
        box-sizing: border-box;
        width: var(--kinma-mtn-btn);
        min-width: var(--kinma-mtn-btn);
        max-width: var(--kinma-mtn-btn);
        height: var(--kinma-mtn-btn);
        min-height: var(--kinma-mtn-btn);
        max-height: var(--kinma-mtn-btn);
        aspect-ratio: 1 / 1;
        padding: 1px 2px 2px;
        gap: 2px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        border-radius: 9999px;
        overflow: hidden;
        touch-action: manipulation;
    }

    #mobile-top-nav .mobile-top-nav-right-group .mobile-top-nav-item:not(.mobile-top-nav-profile-link) svg {
        width: calc(var(--kinma-mtn-btn) * 0.4);
        height: calc(var(--kinma-mtn-btn) * 0.4);
        max-width: 22px;
        max-height: 22px;
        flex-shrink: 0;
    }

    #mobile-top-nav .mobile-top-nav-right-group .mobile-top-nav-item:not(.mobile-top-nav-profile-link) .mobile-nav-item-label {
        display: block !important;
        font-size: var(--kinma-mobile-island-sublabel-fs, 9px);
        line-height: var(--kinma-mobile-island-sublabel-lh, 1.15);
        max-width: 100%;
        width: 100%;
        padding: 0 2px;
        box-sizing: border-box;
    }

    /* Scrollbare Top-Nav-Items: gleiche Kreiszelle wie Chat+KI-Insel, kein Marquee-Überlagerungschaos */
    #mobile-top-nav .mobile-top-nav-items .mobile-top-nav-item {
        width: var(--kinma-mtn-btn);
        min-width: var(--kinma-mtn-btn);
        max-width: var(--kinma-mtn-btn);
        height: var(--kinma-mtn-btn);
        min-height: var(--kinma-mtn-btn);
        max-height: var(--kinma-mtn-btn);
        aspect-ratio: 1 / 1;
        padding: 0;
        gap: 2px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        border-radius: 9999px;
        overflow: hidden;
        touch-action: manipulation;
    }

    #mobile-top-nav .mobile-top-nav-items .mobile-top-nav-item svg {
        width: calc(var(--kinma-mtn-btn) * 0.4);
        height: calc(var(--kinma-mtn-btn) * 0.4);
        max-width: 22px;
        max-height: 22px;
        flex-shrink: 0;
    }

    #mobile-top-nav .mobile-top-nav-items .mobile-top-nav-item .mobile-nav-item-label {
        font-size: var(--kinma-mobile-island-sublabel-fs, 9px);
        line-height: var(--kinma-mobile-island-sublabel-lh, 1.15);
        max-width: 100%;
        width: 100%;
        padding: 0 2px;
        box-sizing: border-box;
    }

    /*
     * Alle Top-Nav-Buttons (Feedback, Wahlen, Chat, KI, Einstellungen): gleiche Zelle —
     * Icon oben, Label unten, genug Höhe/Breite, nichts abschneiden.
     * Profil-Avatar: 48px-Kreis wie Bottom-Nav, ohne Text-Label.
     */
    /* Wie .mobile-bottom-nav-item: Icon + Label, feste Zelle, Label unten */
    .mobile-top-nav-item {
        flex: 0 0 auto;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        width: auto;
        min-width: 44px;
        max-width: 4.5rem;
        min-height: 48px;
        height: auto;
        max-height: none;
        padding: 4px 6px;
        border: none;
        border-radius: 9999px;
        overflow: visible;
        background: transparent !important;
        color: #1a1a1a;
        text-decoration: none;
        cursor: pointer;
        box-shadow: none !important;
        transition: background 0.2s ease, color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        line-height: normal;
        box-sizing: border-box;
        /* wie .mobile-bottom-nav-item: horizontales Scrollen der Insel + tappable */
        touch-action: pan-x;
    }

    .mobile-chat-ai-island .mobile-top-nav-item svg,
    #mobile-top-nav .mobile-top-nav-right-group .mobile-top-nav-item:not(.mobile-top-nav-profile-link) svg {
        /* Wie Wahlen/Feedback in .mobile-top-nav-items: gleiche visuelle Größe */
        width: calc(var(--kinma-mtn-btn) * 0.4);
        height: calc(var(--kinma-mtn-btn) * 0.4);
        max-width: 22px;
        max-height: 22px;
        flex-shrink: 0;
    }

    .mobile-chat-ai-island .mobile-top-nav-ai-svg {
        width: calc(var(--kinma-mtn-btn) * 0.4);
        height: calc(var(--kinma-mtn-btn) * 0.4);
        max-width: 22px;
        max-height: 22px;
        flex-shrink: 0;
    }

    .mobile-top-nav-profile-link {
        min-width: var(--kinma-mtn-btn) !important;
        max-width: var(--kinma-mtn-btn) !important;
        width: var(--kinma-mtn-btn) !important;
        min-height: var(--kinma-mtn-btn) !important;
        height: var(--kinma-mtn-btn) !important;
        max-height: var(--kinma-mtn-btn) !important;
        aspect-ratio: 1 / 1 !important;
        padding: 0 !important;
        justify-content: center !important;
        border-radius: 9999px !important;
        overflow: hidden !important;
        flex-shrink: 0;
    }

    .mobile-top-nav-item:not(.mobile-top-nav-profile-link) svg {
        width: calc(var(--kinma-mtn-btn) * 0.4);
        height: calc(var(--kinma-mtn-btn) * 0.4);
        max-width: 22px;
        max-height: 22px;
        flex-shrink: 0;
    }

    /* Wie .mobile-bottom-nav-item .mobile-nav-item-label */
    .mobile-top-nav-item:not(.mobile-top-nav-profile-link) .mobile-nav-item-label {
        display: block;
        max-width: 56px;
        overflow: hidden;
        color: inherit;
        font-size: var(--kinma-mobile-island-sublabel-fs, 9px);
        line-height: var(--kinma-mobile-island-sublabel-lh, 1.15);
        text-align: center;
        white-space: nowrap;
        text-overflow: ellipsis;
        opacity: 0.9;
        pointer-events: none;
        align-self: center;
    }

    .mobile-top-nav-item.active .mobile-nav-item-label {
        font-weight: 700;
    }

    .mobile-top-nav-item:not(.mobile-top-nav-profile-link) .mobile-nav-item-label-track {
        display: inline-block;
        white-space: nowrap;
    }

    @keyframes mobile-top-nav-label-marquee {
        0% { transform: translateX(0); }
        100% { transform: translateX(-33.3333%); }
    }

    .mobile-top-nav-item.mobile-label-marquee .mobile-nav-item-label-track {
        animation: mobile-top-nav-label-marquee 6s linear infinite;
    }

    /* Profile button should not show text label */
    .mobile-top-nav-profile-link .mobile-nav-item-label {
        display: none !important;
    }

    .mobile-top-nav-item:hover,
    .mobile-top-nav-item:focus-visible {
        background: rgba(0, 0, 0, 0.06) !important;
    }

    .mobile-top-nav-item.active {
        background: #1a1a1a !important;
        color: #fff !important;
    }

    /* Laufende Wahl: Mobil-Top-Nav – rot (allgemein) bzw. blau (Koalitionswahl) wenn nicht auf elections.php */
    .mobile-top-nav-item.election-btn.election-active:not(.active):not(.election-leadership) {
        color: #dc2626 !important;
        background: rgba(220, 38, 38, 0.1) !important;
    }
    .mobile-top-nav-item.election-btn.election-active:not(.active):not(.election-leadership) svg {
        stroke: #dc2626 !important;
    }
    .mobile-top-nav-item.election-btn.election-leadership.election-active:not(.active) {
        color: #2563eb !important;
        background: rgba(37, 99, 235, 0.1) !important;
    }
    .mobile-top-nav-item.election-btn.election-leadership.election-active:not(.active) svg {
        stroke: #2563eb !important;
    }

    /* Trennlinie: Breite/Farbe (Höhe/Margin siehe Block oben) */
    .mobile-top-nav-separator {
        display: block;
        width: 1px;
        min-width: 1px;
        background: #cbd5e1;
        border-radius: 1px;
    }

    /* Trennlinie links vom Notification-Button */
    .mobile-top-nav-notification {
        position: relative;
        margin-left: 2px;
    }
    .mobile-top-nav-notification::before {
        content: '';
        position: absolute;
        left: -5px;
        top: 50%;
        transform: translateY(-50%);
        width: 1px;
        height: 20px;
        background: #cbd5e1;
        border-radius: 1px;
    }
    body.dark-mode .mobile-top-nav-notification::before {
        background: #1a1a1a;
    }

    .mobile-top-nav-avatar {
        width: 100%;
        height: 100%;
        border-radius: 9999px;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .mobile-top-nav-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .mobile-top-nav-avatar span {
        font-size: 0.7em;
        font-weight: 600;
        color: #fff;
    }

    /* Chat-Icon links: bei Touch leicht größerem Ziel — KI-Rechts darf nicht „darüber“ liegen */
    .mobile-chat-ai-island .mobile-top-nav-chat {
        position: relative;
        z-index: 2;
    }

    .mobile-top-nav-ai {
        position: relative;
        z-index: 1;
        overflow: visible;
    }

    .mobile-top-nav-ai-svg {
        width: calc(var(--kinma-mtn-btn) * 0.4);
        height: calc(var(--kinma-mtn-btn) * 0.4);
        max-width: 22px;
        max-height: 22px;
        flex-shrink: 0;
        display: block;
    }

    /*
     * KI-SVG nutzt dieselbe Klasse wie die Chat-Leiste (.chat-nav-ai-icon).
     * In chat.css/style.css ist dort position:absolute + Zentrier-Transform — außerhalb
     * von .chat-nav-ai bleibt das wirksam und nimmt das Icon aus dem Flexfluss, sodass
     * das Marquee-Label visuell über dem Stern liegt. Hier zurück in normalen Fluss.
     */
    .mobile-top-nav-ai .mobile-top-nav-ai-svg.chat-nav-ai-icon {
        position: static;
        top: auto;
        left: auto;
        transform: none;
        margin: 0;
    }

    /* style.css / chat.css: .chat-nav-ai-icon { 22px !important } — Top-Nav KI wie Wahlen/Feedback */
    .mobile-chat-ai-island .mobile-top-nav-ai-svg.chat-nav-ai-icon {
        width: calc(var(--kinma-mtn-btn) * 0.4) !important;
        height: calc(var(--kinma-mtn-btn) * 0.4) !important;
        max-width: 22px !important;
        max-height: 22px !important;
        min-width: 0 !important;
        min-height: 0 !important;
    }

    /* KI deaktiviert: wie inaktive Fläche — gleiche Logik wie andere graue Zustände */
    .mobile-chat-ai-island .mobile-top-nav-ai.ai-btn-disabled {
        color: #64748b !important;
        opacity: 1 !important;
    }

    /* Kein eigener grauer Kasten — gleich wie Chat/Feedback (nur Icon + Label) */
    .mobile-chat-ai-island .mobile-top-nav-ai.ai-btn-disabled:not(.active) {
        background: transparent !important;
    }

    .mobile-top-nav-ai .mobile-top-nav-ai-svg path {
        fill: url(#mobileTopNavAiGradient);
    }

    body.dark-mode .mobile-kinma-island {
        background: transparent;
    }
    body.dark-mode .mobile-kinma-island .kinma-lang-outline {
        border-color: rgba(26, 26, 26, 0.95);
    }
    body.dark-mode .mobile-kinma-island .kinma-lang-inner {
        background: #1a1a1a;
    }
    body.dark-mode .mobile-chat-ai-island {
        background: #1a1a1a;
        border-color: #1a1a1a;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    }
    body.dark-mode .mobile-chat-ai-island .mobile-top-nav-ai.ai-btn-disabled {
        color: #94a3b8 !important;
    }

    body.dark-mode .mobile-chat-ai-island .mobile-top-nav-ai.ai-btn-disabled:not(.active) {
        background: transparent !important;
    }
    body.dark-mode .mobile-top-nav-island {
        background: #1a1a1a;
        border-color: #1a1a1a;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    }

    body.dark-mode .mobile-top-nav-item {
        color: #e2e8f0;
    }

    body.dark-mode .mobile-top-nav-item:hover,
    body.dark-mode .mobile-top-nav-item:focus-visible {
        background: rgba(255, 255, 255, 0.1) !important;
    }

    body.dark-mode .mobile-top-nav-item.active {
        background: rgba(255, 255, 255, 0.25) !important;
        color: #fff !important;
    }

    body.dark-mode .mobile-top-nav-item.election-btn.election-active:not(.active):not(.election-leadership) {
        color: #f87171 !important;
        background: rgba(248, 113, 113, 0.12) !important;
    }
    body.dark-mode .mobile-top-nav-item.election-btn.election-active:not(.active):not(.election-leadership) svg {
        stroke: #f87171 !important;
    }
    body.dark-mode .mobile-top-nav-item.election-btn.election-leadership.election-active:not(.active) {
        color: #60a5fa !important;
        background: rgba(96, 165, 250, 0.12) !important;
    }
    body.dark-mode .mobile-top-nav-item.election-btn.election-leadership.election-active:not(.active) svg {
        stroke: #60a5fa !important;
    }

    body.dark-mode .mobile-top-nav-separator {
        background: rgba(255, 255, 255, 0.25);
    }

    /* Profilseite: Avatar-Button sichtbar lassen (z. B. im Profil-Menü) */
}

/*
 * Login/Register: gesamte Mobile-Top-Zeile ausblenden (KINMA, Chat+KI, Wahl/Feedback/…).
 * Gäste-Auth: Fokus auf Formular; Sprache/KINMA über settings-controls.
 * (--kinma-mobile-viewport-inset-band sonst leerer 84px-Top für ein unsichtbares fixed Row)
 */
@media (max-width: 1024px) {
    body.page-login .mobile-top-nav-row,
    body.page-register .mobile-top-nav-row {
        display: none !important;
    }

    body.page-login,
    body.page-register {
        --kinma-mobile-viewport-inset-band: 0px;
    }
}

/* Obere Inseln: mit mobile-bottom-nav.css kompakt halten (schmale / niedrige Viewports) */
@media (max-width: 400px) {
    body {
        --kinma-mobile-viewport-inset-band: 84px;
    }

    .mobile-top-nav-row {
        --kinma-mtn-pill-inner-h: 44px;
        padding: 8px;
        padding-top: calc(8px + env(safe-area-inset-top, 0px));
        padding-left: max(6px, env(safe-area-inset-left, 0px));
        padding-right: max(6px, env(safe-area-inset-right, 0px));
        padding-bottom: 8px;
        gap: 6px;
    }

    .mobile-kinma-island {
        width: var(--kinma-mtn-island-height);
        height: var(--kinma-mtn-island-height);
        min-width: var(--kinma-mtn-island-height);
        min-height: var(--kinma-mtn-island-height);
        max-width: var(--kinma-mtn-island-height);
        max-height: var(--kinma-mtn-island-height);
    }

    .mobile-kinma-island-img {
        width: calc(var(--kinma-mtn-island-height) * 0.48);
        height: calc(var(--kinma-mtn-island-height) * 0.48);
    }

    .mobile-chat-ai-island {
        flex-direction: row;
        justify-content: center;
        gap: 3px;
    }

    .mobile-top-nav-right-group {
        justify-content: space-between;
        gap: 0;
        min-width: calc(2 * var(--kinma-mtn-btn) + 10px);
        padding: 0 2px 0 3px;
    }

    .mobile-chat-ai-island .mobile-top-nav-item svg,
    #mobile-top-nav .mobile-top-nav-right-group .mobile-top-nav-item:not(.mobile-top-nav-profile-link) svg,
    .mobile-chat-ai-island .mobile-top-nav-ai-svg,
    #mobile-top-nav .mobile-top-nav-items .mobile-top-nav-item svg,
    .mobile-top-nav-item:not(.mobile-top-nav-profile-link) svg,
    .mobile-top-nav-ai-svg {
        width: 16px;
        height: 16px;
        max-width: 22px;
        max-height: 22px;
    }

    .mobile-chat-ai-island .mobile-top-nav-ai-svg.chat-nav-ai-icon {
        width: 16px !important;
        height: 16px !important;
        max-width: 22px !important;
        max-height: 22px !important;
        min-width: 0 !important;
        min-height: 0 !important;
    }

    .mobile-top-nav-items {
        gap: 3px;
        padding: 0 2px 0 3px;
    }

    .mobile-top-nav-item:not(.mobile-top-nav-profile-link) .mobile-nav-item-label {
        max-width: 50px;
    }

    .mobile-chat-ai-island .mobile-top-nav-item .mobile-nav-item-label {
        max-width: 100%;
    }
}

@media (max-width: 360px) {
    .mobile-top-nav-row {
        gap: 4px !important;
    }

    .mobile-top-nav-items {
        gap: 4px !important;
        padding: 0 2px !important;
    }

    .mobile-top-nav-right-group {
        justify-content: space-between !important;
        gap: 0 !important;
        min-width: calc(2 * var(--kinma-mtn-btn) + 8px) !important;
        padding: 0 2px !important;
    }
}
