/* =====================================================================
   Neue Oberfläche (Beta-Schalter „neue_oberflaeche“)
   Greift nur, wenn ui2.js <body> die Klasse .ml-ui2 gibt (App-Modus).
   ===================================================================== */

/* Versteckte Tabs bleiben auch im App-Modus versteckt (z. B. Fahrtenbuch ohne Freigabe) */
.ml-app-mode #ml-tabs .ml-tab[hidden] { display: none !important; }

:root { --ml-nav-h: 64px; }

/* Platz für die Leiste am Seitenende */
body.ml-ui2 { padding-bottom: calc(var(--ml-nav-h) + 16px + env(safe-area-inset-bottom, 0px)) !important; }
body.ml-ui2.ml-ui2-trip { padding-bottom: calc(var(--ml-nav-h) + 72px + env(safe-area-inset-bottom, 0px)) !important; }

/* ---------- Untere Tableiste ---------- */
.ml-ui2 #ml-tabs {
    position: fixed !important; left: 0; right: 0; bottom: 0; z-index: 9500;
    display: flex !important; width: 100% !important; margin: 0 !important; gap: 0 !important;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 0 !important; border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(13,18,24,0.97) !important;
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    box-shadow: 0 -6px 24px rgba(0,0,0,0.35);
}
.ml-ui2 #ml-tabs .ml-tab {
    position: relative; flex: 1 1 0; min-width: 0;
    display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 3px !important;
    min-height: 52px; padding: 4px 0 !important; border-radius: 12px !important;
    background: transparent !important; box-shadow: none !important;
    color: #75818d !important; font-size: 11.5px !important; font-weight: 700 !important; line-height: 1.1 !important;
    white-space: nowrap;
}
.ml-ui2 #ml-tabs .ml-tab .ml-tab-text { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ml-ui2 #ml-tabs .ml-tab .ml-tab-svg { width: 25px !important; height: 25px !important; opacity: 0.72; filter: none; transition: opacity .2s, transform .2s; }
.ml-ui2 #ml-tabs .ml-tab.active { color: var(--primary, #00e5ff) !important; background: transparent !important; box-shadow: none !important; }
.ml-ui2 #ml-tabs .ml-tab .ml-tab-icon { font-size: 0 !important; line-height: 0; }
.ml-ui2 #ml-tabs .ml-tab .ml-tab-text { display: block !important; font-size: 11.5px !important; opacity: 1; }
.ml-ui2 #ml-tabs .ml-tab.active .ml-tab-svg { opacity: 1; transform: translateY(-1px); filter: drop-shadow(0 0 5px rgba(0,229,255,0.45)); }
.ml-ui2 #ml-tabs .ml-tab.active::before {
    content: ""; position: absolute; top: -6px; left: 50%; width: 28px; height: 3px; margin-left: -14px;
    border-radius: 0 0 3px 3px; background: var(--primary, #00e5ff);
}
.ml-ui2 #ml-tabs .ml-tab:focus-visible { outline: 2px solid var(--primary, #00e5ff); outline-offset: -2px; }
/* Hilfe steckt unter „Mehr“ */
.ml-ui2 #ml-tabs .ml-tab[data-tab="help"] { display: none !important; }
/* Bei sehr schmalen Geräten etwas kleinere Schrift */
@media (max-width: 360px) { .ml-ui2 #ml-tabs .ml-tab .ml-tab-text { font-size: 10.5px !important; } }

/* Am PC/Tablet im Querformat: Leiste schmal mittig */
@media (min-width: 820px) {
    .ml-ui2 #ml-tabs { left: 50% !important; right: auto !important; width: 560px !important; transform: translateX(-50%); border-radius: 18px 18px 0 0 !important; border: 1px solid rgba(255,255,255,0.08); border-bottom: none; }
}

/* ---------- „Mehr“: Umschalter Einstellungen | Hilfe ---------- */
.ml-ui2-more {
    display: flex; gap: 6px; padding: 4px; margin: 0 auto 18px; max-width: 600px;
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 14px;
}
.ml-ui2-more button {
    flex: 1; min-height: 42px; border: none; border-radius: 10px; cursor: pointer;
    background: transparent; color: #9aa4b2; font-family: inherit; font-size: 0.95rem; font-weight: 800;
}
.ml-ui2-more button.active { background: #2b3440; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
.ml-ui2-more button:focus-visible { outline: 2px solid var(--primary, #00e5ff); outline-offset: 2px; }

/* Start-Tab-Auswahl in den Einstellungen */
.ml-ui2 .ml-ui2-select {
    min-width: 132px; padding: 9px 10px; border-radius: 10px; font-family: inherit; font-size: 0.95rem;
    background: #222; color: #fff; border: 1px solid #444;
}

/* ---------- Fahrtenbuch als Tab (statt Vollbild) ---------- */
.ml-ui2 #ml-tab-logbook { margin: -2px -2px 0; }
.ml-lb.ml-lb-inline {
    position: static !important; inset: auto; display: block; background: none; padding-top: 0;
    min-height: 60vh;
}
.ml-lb-inline .ml-lb-head { border-bottom: none; padding: 2px 2px 10px; }
.ml-lb-inline .ml-lb-title { font-size: 1.35rem; }
.ml-lb-inline #ml-lb-close { display: none; }
.ml-lb-inline .ml-lb-scroll { overflow: visible; padding: 0 0 12px; max-width: 640px; }

/* Schwebender Knopf entfällt, wenn es den Fahrtenbuch-Tab gibt; sonst über die Leiste heben */
.ml-ui2.ml-ui2-lbtab #ml-dash-launch { display: none !important; }
.ml-ui2 #ml-dash-launch { bottom: calc(var(--ml-nav-h) + 14px + env(safe-area-inset-bottom, 0px)); }
.ml-ui2.ml-ui2-trip .ml-lb-toast { bottom: calc(var(--ml-nav-h) + 76px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Leiste „Fahrt läuft“ über der Tableiste ---------- */
#ml-ui2-trip {
    position: fixed; left: 10px; right: 10px; z-index: 9400;
    bottom: calc(var(--ml-nav-h) + 8px + env(safe-area-inset-bottom, 0px));
    display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 6px 6px 6px 14px;
    border-radius: 14px; background: rgba(16,36,42,0.97); border: 1px solid rgba(0,229,255,0.42);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5); color: #fff; font-family: inherit; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
#ml-ui2-trip[hidden] { display: none; }
#ml-ui2-trip .dot { width: 10px; height: 10px; border-radius: 50%; background: #ff3b3b; flex-shrink: 0; box-shadow: 0 0 0 4px rgba(255,59,59,0.18); animation: mlUi2Blink 1.2s infinite; }
@keyframes mlUi2Blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
#ml-ui2-trip .txt { flex: 1; min-width: 0; font-weight: 800; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
#ml-ui2-trip .txt span { color: #9fb2bf; font-weight: 600; }
#ml-ui2-trip .cp {
    flex-shrink: 0; min-height: 38px; padding: 0 14px; border: none; border-radius: 10px; cursor: pointer;
    background: var(--gradient-primary, linear-gradient(135deg,#00e5ff,#00b4d8)); color: #04222a;
    font-family: inherit; font-weight: 900; font-size: 0.9rem;
}
@media (min-width: 820px) { #ml-ui2-trip { left: 50%; right: auto; width: 540px; transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { #ml-ui2-trip .dot { animation: none; } }

/* Info-Banner unten (App installieren) über die Leiste heben */
.ml-ui2 #ml-install-banner { bottom: calc(var(--ml-nav-h) + env(safe-area-inset-bottom, 0px)); }

/* =====================================================================
   Schritt 2: Live-Übersicht (ui2live.js, Klasse .ml-ov am <body>)
   ===================================================================== */
.ml-ov #ml-left > h3, .ml-ov #ml-left > .ml-net-switch + h3 { display: none !important; }
.ml-ov #ml-quickcheck-bar, .ml-ov #ml-route-chips { display: none !important; }
.ml-ov #autobahnList h4.ml-ov-hide { display: none !important; }
.ml-ov #ml-right > h3 { display: none !important; }
@media (min-width: 900px) { .ml-ov:not(.ml-ov-road) #ml-right { display: none !important; } #ml-panel-head { display: none !important; } }
.ml-ov.ml-ov-searching #ml-ov-mid { display: none; }

#ml-ov-top .ml-ov-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 2px 12px; }
#ml-ov-top h2 { margin: 0 !important; font-size: 1.45rem !important; font-weight: 800; letter-spacing: .2px; color: #fff; }
.ml-ov-stand { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 700; color: #75818d; white-space: nowrap; }
.ml-ov-stand i { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 4px rgba(61,220,132,.15); }
.ml-ov-stand i.old { background: #ff9f0a; box-shadow: 0 0 0 4px rgba(255,159,10,.15); }
.ml-ov-search { display: flex; gap: 8px; margin-bottom: 12px; }
.ml-ov-search #ml-button-filter {
    flex: 1; min-width: 0; height: 48px; margin: 0 !important; padding: 0 14px !important; font-size: 1rem !important;
    border-radius: 12px !important; background: #141a21 !important; border: 1px solid rgba(255,255,255,.12) !important; color: #fff !important;
}
.ml-ov-search #ml-button-filter:focus { outline: none; border-color: rgba(0,229,255,.55) !important; }
.ml-ov-near {
    flex: 0 0 48px; height: 48px; border-radius: 12px; cursor: pointer; font-size: 1.25rem; line-height: 1;
    background: rgba(0,229,255,.1); border: 1px solid rgba(0,229,255,.4); color: #fff;
}
.ml-ov-near.on { background: var(--primary, #00e5ff); }
.ml-ov-near.busy { animation: mlOvPulse 1s ease-in-out infinite; }
@keyframes mlOvPulse { 50% { opacity: .45; } }

/* Lage auf einen Blick */
.ml-ov-lage { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 6px; }
.ml-ov-tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 11px 9px; min-height: 66px;
    border-radius: 14px; background: #141a21; border: 1px solid rgba(255,255,255,.08); color: #fff; font-family: inherit; cursor: pointer; text-align: left;
}
.ml-ov-tile b { font-size: 1.55rem; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.ml-ov-tile span { font-size: .74rem; font-weight: 700; color: #9aa6b2; white-space: nowrap; }
.ml-ov-tile i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.ml-ov-tile i.r { background: #ff453a; } .ml-ov-tile i.o { background: #ff9f0a; }
.ml-ov-tile.on { border-color: rgba(0,229,255,.55); background: rgba(0,229,255,.08); }
.ml-ov-tile:focus-visible, .ml-ov-row:focus-visible, .ml-ov-fav:focus-visible, .ml-ov-near:focus-visible { outline: 2px solid var(--primary, #00e5ff); outline-offset: 2px; }

/* Abschnittsköpfe */
.ml-ov-sec { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 18px 2px 8px; }
.ml-ov-sec h2 { margin: 0 !important; font-size: .8rem !important; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: #8f9aa6; }
.ml-ov-sec h2 small { text-transform: none; letter-spacing: 0; font-weight: 600; color: #6b7783; margin-left: 4px; }
.ml-ov-link { background: none; border: none; padding: 4px 0; color: var(--primary, #00e5ff); font-family: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; }
.ml-ov-hint { padding: 12px 14px; border-radius: 14px; background: rgba(255,214,10,.06); border: 1px dashed rgba(255,214,10,.3); color: #e6dcb0; font-size: .88rem; line-height: 1.4; }
.ml-ov-mini { font-size: .74rem; color: #6b7783; margin: 6px 2px 0; }
.ml-ov-empty { padding: 14px; border-radius: 14px; background: #141a21; border: 1px solid rgba(255,255,255,.08); color: #9aa6b2; font-size: .9rem; text-align: center; }

/* Autobahn-Schild klein */
.ml-ov-sign {
    flex-shrink: 0; min-width: 46px; height: 32px; padding: 0 8px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .95rem; color: #fff;
}
.ml-ov-sign.crit { background: var(--gradient-critical, linear-gradient(135deg,#ff453a,#b00020)); }
.ml-ov-sign.warn { background: var(--gradient-warning, linear-gradient(135deg,#ff9f0a,#b25000)); }
.ml-ov-sign.ok { background: #2a323c; }

/* Meine Autobahnen */
.ml-ov-favs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.ml-ov-fav {
    display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 10px; border-radius: 14px; text-align: left; cursor: pointer;
    background: #141a21; border: 1px solid rgba(255,255,255,.08); color: #fff; font-family: inherit;
}
.ml-ov-fav .ml-ov-sign { width: 100%; height: 28px; font-size: .9rem; }
.ml-ov-fav-dir { font-size: .72rem; font-weight: 700; color: #5fe3f5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ml-ov-fav-t { font-size: .78rem; color: #9aa6b2; line-height: 1.3; }
.ml-ov-fav-t b { color: #fff; }

/* Brennpunkte / In meiner Nähe */
.ml-ov-row {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; margin-bottom: 8px; border-radius: 14px; cursor: pointer; text-align: left;
    background: #141a21; border: 1px solid rgba(255,255,255,.08); color: #fff; font-family: inherit;
}
.ml-ov-row-m { flex: 1; min-width: 0; }
.ml-ov-row-m b { display: block; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ml-ov-row-m span { display: block; font-size: .8rem; color: #9aa6b2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.ml-ov-row-t { flex-shrink: 0; text-align: right; font-size: .76rem; color: #75818d; white-space: nowrap; }
.ml-ov-row-t b { display: block; font-size: .85rem; color: #ffb35c; }
.ml-ov-row-t b.red { color: #ff7a70; }
.ml-ov-row-t span { display: block; }

/* Kompaktes Raster: 6 Spalten */
.ml-ov .ml-ov-sec-all { margin-top: 20px; }
.ml-ov #autobahnList > div { grid-template-columns: repeat(6, 1fr) !important; gap: 6px !important; margin-bottom: 10px !important; }
.ml-ov #autobahnList button { height: 42px !important; line-height: 40px !important; font-size: .86rem !important; border-radius: 10px !important; padding: 0 !important; }
.ml-ov #autobahnList button.ml-fav-btn::after { width: 15px !important; height: 15px !important; font-size: 9px !important; line-height: 15px !important; top: -5px !important; right: -5px !important; }
@media (max-width: 360px) { .ml-ov #autobahnList > div { grid-template-columns: repeat(5, 1fr) !important; } }

/* Regional & Zubringer: zugeklappt */
.ml-ov #autobahnList h4.ml-ov-fold {
    display: flex !important; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer;
    margin: 10px 0 0 !important; padding: 13px 14px !important; border: 1px solid rgba(255,255,255,.08) !important; border-radius: 12px;
    background: #141a21; color: #cfd6dd !important; font-size: .95rem !important; letter-spacing: 0 !important; text-transform: none !important;
}
.ml-ov-fold-r { font-size: .82rem; font-weight: 600; color: #75818d; white-space: nowrap; }
.ml-ov-fold-r b { color: #ffb35c; }
.ml-ov-fold-r i { font-style: normal; display: inline-block; transition: transform .2s; }
.ml-ov #autobahnList h4.ml-ov-fold.open .ml-ov-fold-r i { transform: rotate(180deg); }
.ml-ov #autobahnList .ml-ov-regional { display: none !important; }
.ml-ov #autobahnList h4.ml-ov-fold.open + .ml-ov-regional,
.ml-ov.ml-ov-searching #autobahnList .ml-ov-regional { display: grid !important; margin-top: 8px !important; }
.ml-ov #ml-construction-btn-wrap { margin-top: 12px; }
#ml-ov-alerts:empty { display: none; } #ml-ov-alerts { margin-top: 10px; }
.ml-ov-fav { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* =====================================================================
   Schritt 3: Autobahn als eigene Ansicht (nur Handy, < 900 px)
   ===================================================================== */
@media (max-width: 899px) {
    .ml-ov #ml-right { display: none !important; }
    .ml-ov.ml-panel-open #ml-right {
        display: block !important; position: fixed !important; left: 0; right: 0; top: 0;
        bottom: calc(var(--ml-nav-h) + env(safe-area-inset-bottom, 0px)); z-index: 9300;
        width: auto !important; min-width: 0 !important; margin: 0 !important;
        overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
        background: #0b1015 !important; border-radius: 0 !important; padding: 0 14px 24px !important;
        animation: mlPanelIn .22s cubic-bezier(.2,.8,.2,1);
    }
    html.ml-panel-lock, html.ml-panel-lock body { overflow: hidden !important; }
    .ml-panel-open #ml-right #ml-search, .ml-panel-open #ml-right #ml-gps-btn, .ml-panel-open #ml-right .ml-status-bar { display: none !important; }
}
@keyframes mlPanelIn { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ml-ov.ml-panel-open #ml-right { animation: none; } }

.ml-panel-head {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
    margin: 0 -14px 12px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
    background: rgba(11,16,21,.97); border-bottom: 1px solid rgba(255,255,255,.08);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.ml-panel-head .ml-ov-sign { min-width: 52px; height: 36px; font-size: 1.05rem; }
.ml-ph-t { flex: 1; min-width: 0; }
.ml-ph-t b { display: block; font-size: 1.02rem; line-height: 1.15; color: #fff; }
.ml-ph-t span { display: block; font-size: .8rem; color: #9aa6b2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ml-ph-t span b { display: inline; font-size: inherit; }
.ml-ph-t span.crit, .ml-ph-t span.crit b { color: #ff8a80; }
.ml-ph-t span.warn, .ml-ph-t span.warn b { color: #ffb35c; }
.ml-ph-btn {
    flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px; cursor: pointer;
    background: #141a21; border: 1px solid rgba(255,255,255,.12); color: #fff; font-family: inherit; font-size: 1.15rem; line-height: 1;
}
.ml-ph-btn.on { color: #ffd60a; border-color: rgba(255,214,10,.6); }
.ml-ph-btn:focus-visible { outline: 2px solid var(--primary, #00e5ff); outline-offset: 2px; }

/* Inhalt der Ansicht etwas ruhiger */
.ml-panel-open #ml-right .ml-barometer { font-size: .95rem !important; padding: 10px 12px !important; margin-bottom: 10px !important; border-radius: 12px !important; }
.ml-panel-open #ml-right .ml-direction-filter { gap: 6px !important; padding: 4px !important; background: #141a21; border-radius: 12px; margin-bottom: 12px !important; }
.ml-panel-open #ml-right .ml-dir-btn { border: none !important; background: transparent !important; color: #9aa6b2 !important; font-weight: 700; border-radius: 9px !important; }
.ml-panel-open #ml-right .ml-dir-btn.active,
.ml-panel-open #ml-right .ml-direction-filter:not(:has(.active)) .ml-dir-btn[data-dir="all"] { background: #2b3440 !important; color: #fff !important; }
