:root {
    --bg: #1C1B1F; --surface: #2B2930; --primary: #D0BCFF;
    --on-primary: #381E72; --on-surface: #E6E1E5; --outline: #938F99;
    --error: #FFB4AB; --green: #81C784; --base-font: 16px; 
    --tram: #F2B8B5; --bus: #D0BCFF; --trolley: #C2E7FF;
}

body.oled { --bg: #000000; --surface: #111111; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
input, .expert-text, .b-input, .res-item, .bm-res-item { user-select: auto; }

body {
    background: var(--bg); color: var(--on-surface);
    font-family: 'Roboto', sans-serif; margin: 0;
    display: flex; justify-content: center; height: 100dvh;
    overflow: hidden; font-size: var(--base-font);
    transition: background 0.3s ease;
}

#app { background: var(--bg); width: 100%; max-width: 500px; height: 100%; display: flex; flex-direction: column; position: relative; border-left: 1px solid rgba(255,255,255,0.05); border-right: 1px solid rgba(255,255,255,0.05); }

#board::-webkit-scrollbar, #settings-page::-webkit-scrollbar, #results::-webkit-scrollbar, .sheet::-webkit-scrollbar { display: none; }
#board, #settings-page, #results, .sheet { scrollbar-width: none; -ms-overflow-style: none; }

header { padding: calc(10px + env(safe-area-inset-top)) 20px 10px; display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.header-top { width: 100%; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.branding { font-size: 10px; font-weight: 900; opacity: 0.3; letter-spacing: 4px; text-transform: uppercase; margin-bottom: 8px; }
#stop-display { margin: 0; font-size: 1.6rem; font-weight: 900; letter-spacing: -0.5px; text-align: center; }

#settings-page {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg); z-index: 2000; display: none;
    flex-direction: column; padding: calc(10px + env(safe-area-inset-top)) 20px 24px; overflow-y: auto;
}
.settings-header { display: flex; align-items: center; width: 100%; margin-bottom: 30px; position: relative; min-height: 44px; }
.settings-header h2 { width: 100%; text-align: center; margin: 0; font-size: 1.3rem; font-weight: 900; }
.back-btn { position: absolute; left: 0; background: transparent; border: none; color: var(--on-surface); font-size: 28px; cursor: pointer; z-index: 10; padding: 5px; }

.settings-item { background: var(--surface); padding: 1.2em; border-radius: 20px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.s-label { flex: 1; padding-right: 10px; }
.s-title { font-weight: 700; font-size: 1rem; }
.s-desc { font-size: 0.75rem; opacity: 0.5; font-weight: 400; margin-top: 2px; }
.settings-section-label { margin: 25px 0 12px; font-weight: 900; opacity: 0.3; font-size: 0.75rem; letter-spacing: 2px; }
.bookmarks-settings { margin-top: 20px; }
.bookmarks-settings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.bookmarks-settings-title { font-size: 1.1rem; }
.changelog-card { margin-top: 18px; background: var(--surface); border-radius: 20px; border: 1px solid rgba(255,255,255,0.05); }
.changelog-toggle { width: 100%; border: none; background: transparent; color: var(--on-surface); padding: 1.05em 1.1em; display: flex; justify-content: space-between; align-items: center; gap: 14px; cursor: pointer; text-align: left; }
.changelog-title { font-size: 0.98rem; font-weight: 800; }
.changelog-subtitle { font-size: 0.75rem; opacity: 0.5; margin-top: 2px; }
.changelog-chevron { font-size: 1.1rem; opacity: 0.7; transition: transform 0.2s ease; flex-shrink: 0; }
.changelog-card.is-open .changelog-chevron { transform: rotate(180deg); }
.changelog-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.changelog-body:not(.hidden) { max-height: 600px; padding: 0 1.1em 1.05em; }
.changelog-list { display: flex; flex-direction: column; gap: 10px; }
.changelog-item { font-size: 0.9rem; line-height: 1.5; opacity: 0.85; padding-left: 16px; position: relative; word-wrap: break-word; }
.changelog-item::before { content: "•"; position: absolute; left: 0; top: 0; color: var(--primary); }
.settings-footer { height: 120px; opacity: 0.3; text-align: center; font-size: 11px; padding-top: 20px; }
.b-inputs-group { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.b-inputs-top { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.b-input { background: rgba(0,0,0,0.25) !important; border: 1px solid rgba(255,255,255,0.12) !important; color: white !important; padding: 12px; border-radius: 14px; font-size: 14px; width: 100%; outline: none; }
.b-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; }
.b-move-group { display: flex; gap: 12px; }

.btn-reorder { background: #4A4458; color: var(--primary); border: none; width: 42px; height: 38px; border-radius: 12px; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.btn-reorder:active { background: var(--primary); color: var(--on-primary); }
.btn-delete { background: rgba(255, 180, 171, 0.15); color: var(--error); border: 1px solid var(--error); padding: 8px 16px; border-radius: 12px; font-weight: 900; font-size: 11px; cursor: pointer; text-transform: uppercase; }

.icon-selector { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 8px; scrollbar-width: none; border-bottom: 1px solid rgba(255,255,255,0.05); }
.selectable-icon { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.05); border-radius: 14px; font-size: 22px; cursor: pointer; border: 2px solid transparent; flex-shrink: 0; }
.selectable-icon.active { border-color: var(--primary); background: rgba(208, 188, 255, 0.15); }

.header-btn { background: transparent; border: none; font-size: 24px; cursor: pointer; color: var(--on-surface); display: flex; align-items: center; justify-content: center; }

#bookmarks-bar { display: flex; justify-content: center; gap: 14px; padding: 10px 20px 20px; overflow-x: auto; flex-shrink: 0; width: 100%; }
.bookmark-item { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; min-width: 60px; }
.bookmark-icon { width: 54px; height: 54px; background: var(--surface); border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 26px; border: 1px solid rgba(255,255,255,0.05); }
.bookmark-label { font-size: 11px; opacity: 0.7; font-weight: 500; }

#board { flex: 1; overflow-y: auto; padding: 0 16px 160px; -webkit-overflow-scrolling: touch; }
.board-status { text-align: center; padding-top: 100px; opacity: 0.4; font-weight: 500; }
.board-status.error { font-weight: 600; color: var(--error); }
.card { 
    background: var(--surface); border-radius: 1.6em; padding: 1.1em 1.3em; margin-bottom: 0.9em; 
    display: flex; justify-content: space-between; align-items: center; border: 1px solid rgba(255,255,255,0.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2); gap: 10px;
}

.line-badge { width: 2.8em; height: 2.8em; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 1.1em; margin-right: 4px; flex-shrink: 0; background: var(--bus); color: #000; }
.line-badge.tram { background: var(--tram); color: #601410; }
.line-badge.trolley { background: var(--trolley); color: #001D35; }

.info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.dest { font-weight: 700; font-size: 1.15em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.meta { font-size: 0.75em; opacity: 0.6; text-transform: uppercase; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.meta-row { display: flex; align-items: center; gap: 7px; min-width: 0; margin-top: 2px; }
.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68em;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: rgba(230,225,229,0.85);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    padding: 0.22em 0.58em;
    line-height: 1.1;
    white-space: nowrap;
}
.meta-status.live::before {
    content: "";
    width: 0.5em;
    height: 0.5em;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(129,199,132,0.2);
}
.meta-status.planned { color: rgba(230,225,229,0.7); }
.meta-icons { display: inline-flex; align-items: center; gap: 3px; margin-left: 1px; }
.meta-icon { font-size: 0.95em; line-height: 1; }
.expert-text {
    font-size: 0.65em;
    color: var(--primary);
    margin-top: 5px;
    font-weight: 400;
    opacity: 0.8;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    line-height: 1.2;
    word-break: break-word;
    width: 100%;
}

.time-box { text-align: right; min-width: 6.2em; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; }
.eta-mins { color: var(--green); font-weight: 900; font-size: 1.45rem; line-height: 1; white-space: nowrap; }
.eta-clock { font-size: 0.85rem; opacity: 0.6; font-weight: 500; margin-top: 4px; }
.delay-tag { color: var(--error); font-size: 0.72rem; font-weight: 800; margin-top: 2px; white-space: nowrap; text-transform: uppercase; }
.planned .eta-mins { color: var(--outline); }

.dots-container { display: inline-flex; gap: 4px; color: var(--green); font-weight: 900; font-size: 2rem; line-height: 0.8; animation: blinker 1.2s step-start infinite; }
@keyframes blinker { 50% { opacity: 0; } }

/* --- UNIFIKOVANÉ VYHĽADÁVANIE (DOPLŇAČ) --- */

/* 1. Hlavné výsledky a výsledky v plánovači */
#results, .planner-res { 
    position: absolute; 
    background: var(--surface); 
    border-radius: 24px; 
    border: 1px solid #555; 
    overflow-y: auto; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.6); 
    z-index: 4000;
    padding: 8px 0;
}

/* Pozícia pre hlavné hľadanie */
#results { 
    bottom: 95px; 
    left: 20px; 
    right: 20px; 
    max-height: 380px; 
}

/* Pozícia pre hľadanie v plánovači */
.planner-res { 
    top: 100%; 
    left: 0; 
    right: 0; 
    max-height: 200px; 
    margin-top: 5px;
    border-radius: 16px;
}

/* Spoločný štýl pre položky v zozname */
.res-item, .bm-res-item { 
    padding: 16px 24px; 
    border-bottom: 1px solid #444; 
    font-size: 1.15rem; 
    font-weight: 700; 
    text-align: left; 
    color: var(--on-surface);
    cursor: pointer;
    display: block;
    width: 100%;
    transition: background 0.1s;
}

.res-item:last-child, .bm-res-item:last-child { border-bottom: none; }

.res-item:active, .bm-res-item:active { 
    background: var(--primary); 
    color: var(--on-primary); 
}

/* --- PLÁNOVAČ --- */
.fab { position: absolute; bottom: 100px; right: 20px; width: 56px; height: 56px; background: var(--primary); border-radius: 16px; border: none; box-shadow: 0 4px 15px rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 99; font-size: 24px; color: var(--on-primary); }
.sheet { position: absolute; bottom: 0; left: 0; right: 0; background: var(--surface); border-radius: 28px 28px 0 0; padding: 16px 24px calc(30px + env(safe-area-inset-bottom)); z-index: 3000; box-shadow: 0 -10px 40px rgba(0,0,0,0.6); transition: transform 0.3s ease; overflow: visible; }
.sheet.hidden { transform: translateY(100%); }
.sheet-handle { width: 32px; height: 4px; background: var(--outline); border-radius: 2px; margin: 0 auto 16px; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; width: 100%; }
.sheet-header h3 { margin: 0; font-size: 1.4rem; font-weight: 900; color: var(--on-surface); }
.close-btn-circle { width: 40px; height: 40px; background: var(--outline) !important; border-radius: 50%; border: none; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 20px; }

.planner-form { display: flex; flex-direction: column; gap: 20px; width: 100%; }
.input-group { position: relative; width: 100%; display: block; }
.input-group label { display: block; font-size: 0.75rem; color: var(--primary); font-weight: 800; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
.input-with-icon { display: flex; gap: 8px; align-items: center; width: 100%; }

.planner-form input { width: 100% !important; display: block !important; background: rgba(0, 0, 0, 0.2) !important; border: 1px solid var(--outline) !important; border-radius: 14px !important; padding: 14px 16px !important; color: white !important; font-size: 1rem !important; outline: none !important; }
#p-gps-btn { width: 54px !important; height: 50px !important; background: var(--surface) !important; border: 1px solid var(--outline) !important; border-radius: 14px !important; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: white; }

.btn-filled { width: 100% !important; background: var(--primary) !important; color: var(--on-primary) !important; border: none !important; padding: 16px !important; border-radius: 16px !important; font-weight: 900 !important; font-size: 1rem !important; cursor: pointer !important; margin-top: 10px; }

/* BOTTOM NAV */
.bottom-nav { position: absolute; bottom: 0; width: 100%; padding: 20px; background: linear-gradient(to top, var(--bg) 75%, transparent); z-index: 1000; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.search-box { background: var(--surface); border-radius: 30px; padding: 14px 24px; border: 1px solid #444; display: flex; }
.search-box input { background: transparent !important; border: none !important; color: white !important; font-size: 1rem !important; width: 100%; outline: none; }

.btn-font { background: #4A4458; color: var(--primary); border: none; width: 36px; height: 36px; border-radius: 12px; font-size: 20px; cursor: pointer; }
.btn-font-circle { background: #4A4458; color: var(--primary); border: none; width: 38px; height: 38px; border-radius: 50%; font-size: 22px; cursor: pointer; }

.m3-switch { position: relative; width: 52px; height: 32px; display: inline-block; }
.m3-switch input { opacity: 0; width: 0; height: 0; }
.m3-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #4A4458; border-radius: 32px; transition: .4s; }
.m3-slider:before { position: absolute; content: ""; height: 24px; width: 24px; left: 4px; bottom: 4px; background: white; border-radius: 50%; transition: .4s; }
input:checked + .m3-slider { background: var(--primary); }
input:checked + .m3-slider:before { transform: translateX(20px); background: var(--on-primary); }

.hidden { display: none; }

@media (max-width: 560px) {
    .card {
        padding: 1em 1.05em;
        border-radius: 1.45em;
        gap: 8px;
    }

    .line-badge {
        width: 2.65em;
        height: 2.65em;
        font-size: 1.04em;
    }

    .dest {
        font-size: 1.08em;
    }

    .meta-row {
        flex-wrap: wrap;
        gap: 6px;
        overflow: visible;
        width: 100%;
    }

    .meta-icons {
        margin-left: 0;
        width: auto;
        justify-content: flex-start;
        flex: 0 0 auto;
    }

    .meta-badge {
        font-size: 0.66em;
        padding: 0.2em 0.52em;
        flex: 0 0 auto;
    }

    .expert-text {
        display: block;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    .time-box {
        min-width: 5.4em;
    }
}
