:root {
    --brand-primary: #EC1628;
    --brand-secondary: #064789;
    --sys-bg: #F2F2F7;
    --sys-surface: #FFFFFF;
    --sys-surface-hover: #E5E5EA;
    --sys-separator: #C6C6C8;
    --sys-text-primary: #000000;
    --sys-text-secondary: rgba(60, 60, 67, 0.6);
    --sys-text-tertiary: rgba(60, 60, 67, 0.3);
    --radius-sheet: 24px;
    --radius-card: 16px;
    --radius-btn: 12px;
    --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-sheet: 0 -4px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
    --sys-bg: #000000;
    --sys-surface: #1C1C1E;
    --sys-surface-hover: #2C2C2E;
    --sys-separator: #38383A;
    --sys-text-primary: #FFFFFF;
    --sys-text-secondary: rgba(235, 235, 245, 0.6);
    --sys-text-tertiary: rgba(235, 235, 245, 0.3);
    --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-sheet: 0 -4px 24px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%; 
    height: 100dvh; 
    overflow: hidden;
    background: var(--sys-bg);
    color: var(--sys-text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
    transition: background 0.3s ease, color 0.3s ease;
}

button,
a,
input {
    font-family: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

.mono {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

#mapContainer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

[data-theme="dark"] .leaflet-layer,
[data-theme="dark"] .leaflet-control-zoom-in,
[data-theme="dark"] .leaflet-control-zoom-out,
[data-theme="dark"] .leaflet-control-attribution {
    filter: invert(100%) hue-rotate(180deg) brightness(90%) contrast(90%);
}

.top-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
}

.floating-pill {
    background: var(--sys-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--sys-separator);
    border-radius: 999px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-float);
    min-height: 48px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    background-color: var(--brand-primary);
    -webkit-mask: url('../images/iett_logo.svg') no-repeat center / contain;
    mask: url('../images/iett_logo.svg') no-repeat center / contain;
    transition: background-color 0.3s ease;
}

[data-theme="dark"] .brand-logo-img {
    background-color: #FFFFFF;
}

.brand-text {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.02em;
    display: none;
}

@media(min-width: 768px) {
    .brand-text {
        display: block;
    }
}

.action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sys-text-primary);
    background: var(--sys-surface-hover);
    transition: all 0.2s ease;
}

    .action-btn:hover {
        filter: brightness(0.9);
    }

    .action-btn svg {
        width: 20px;
        height: 20px;
    }

.app-panel {
    position: absolute;
    z-index: 100;
    background: var(--sys-surface);
    box-shadow: var(--shadow-sheet);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


@media(min-width: 768px) {
    .app-panel {
        top: 20px;
        left: 20px;
        bottom: 20px;
        width: 420px;
        border-radius: var(--radius-sheet);
        border: 1px solid var(--sys-separator);
    }
}


/* Mobile Bottom Sheet */
@media(max-width: 767px) {
    .app-panel {
        bottom: 0;
        left: 0;
        right: 0;
        height: 80dvh;
        max-height: 85dvh;
        transform: translateY(calc(85dvh - 45vh));
        border-top-left-radius: var(--radius-sheet);
        border-top-right-radius: var(--radius-sheet);
        border-top: 1px solid var(--sys-separator);
        will-change: transform;
    }

        .app-panel.expanded {
            transform: translateY(0);
            height: 92dvh;
            max-height: 92dvh;
        }

        .app-panel.collapsed {
            transform: translateY(calc(85dvh - 75px));
        }

        .app-panel.animating {
            transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), height 0.3s cubic-bezier(0.32, 0.72, 0, 1);
        }

    .sheet-handle {
        width: 40px;
        height: 5px;
        background: var(--sys-separator);
        border-radius: 10px;
    }

    .drag-zone {
        touch-action: none;
        cursor: grab;
        display: flex;
        justify-content: center;
        width: 100%;
        padding: 12px 0 8px;
        flex-shrink: 0;
        background: var(--sys-surface);
    }

        .drag-zone:active {
            cursor: grabbing;
        }
}

.search-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--sys-separator);
    position: relative;
    flex-shrink: 0; 
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--sys-bg);
    border-radius: var(--radius-btn);
    padding: 0 16px;
    min-height: 52px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

    .search-box:focus-within {
        border-color: var(--brand-secondary);
        background: var(--sys-surface);
    }

    .search-box svg {
        width: 22px;
        height: 22px;
        color: var(--sys-text-secondary);
        flex-shrink: 0;
    }

    .search-box input {
        flex: 1;
        background: none;
        border: none;
        outline: none;
        color: var(--sys-text-primary);
        font-size: 17px;
        font-weight: 500;
        height: 100%;
    }

        .search-box input::placeholder {
            color: var(--sys-text-secondary);
        }

.search-clear {
    color: var(--sys-text-secondary);
    display: none;
    padding: 10px;
    margin-right: -8px;
}

    .search-clear.show {
        display: flex;
    }


.content-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    position: relative;
    min-height: 0;
}

.search-results {
    flex: 1;
    background: var(--sys-surface);
    z-index: 50;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    display: none;
}

    .search-results.open {
        display: flex;
        flex-direction: column;
    }

    .content-scroll::-webkit-scrollbar,
    .search-results::-webkit-scrollbar {
        width: 6px;
    }

    .content-scroll::-webkit-scrollbar-track,
    .search-results::-webkit-scrollbar-track {
        background: transparent;
    }

    .content-scroll::-webkit-scrollbar-thumb,
    .search-results::-webkit-scrollbar-thumb {
        background: var(--sys-separator);
        border-radius: 999px;
    }

.empty-state {
    text-align: center;
    padding: 40px 10px;
    color: var(--sys-text-secondary);
}

    .empty-state svg {
        width: 48px;
        height: 48px;
        color: var(--brand-secondary);
        margin-bottom: 20px;
        opacity: 0.8;
    }

    .empty-state h2 {
        font-size: 22px;
        color: var(--sys-text-primary);
        font-weight: 700;
        margin-bottom: 12px;
        letter-spacing: -0.02em;
    }

    .empty-state p {
        font-size: 16px;
        line-height: 1.5;
        margin-bottom: 30px;
    }

.suggestion-chips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.suggestion-chip {
    padding: 12px 20px;
    background: var(--sys-bg);
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    color: var(--sys-text-primary);
    border: 1px solid var(--sys-separator);
    transition: all 0.2s ease;
}

    .suggestion-chip:active {
        transform: scale(0.96);
        background: var(--sys-surface-hover);
    }

.footer-credit {
    text-align: center;
    padding: 40px 20px 20px;
    color: var(--sys-text-secondary);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.footer-logo {
    height: 36px;
    object-fit: contain;
    filter: grayscale(100%);
    opacity: 0.6;
    transition: all 0.3s ease;
}

.heart-icon {
    display: inline-block;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: default;
}

    .heart-icon:hover {
        transform: scale(1.35);
    }

[data-theme="dark"] .footer-logo {
    filter: grayscale(100%) invert(1);
    opacity: 0.8;
}

.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sys-separator);
    width: 100%;
    text-align: left;
    min-height: 72px;
    flex-shrink: 0;
}

    .result-row:active {
        background: var(--sys-surface-hover);
    }

.result-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .result-main b {
        font-size: 17px;
        font-weight: 600;
        color: var(--sys-text-primary);
    }

    .result-main span {
        font-size: 14px;
        color: var(--sys-text-secondary);
    }

.result-code {
    font-size: 14px;
    color: #fff;
    background: var(--brand-secondary);
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: 700;
}

.stop-header {
    margin-bottom: 24px;
}

.stop-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.stop-title {
    flex: 1;
}

.stop-eyebrow {
    font-size: 13px;
    font-weight: 700;
    color: var(--brand-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    display: block;
}

.stop-title h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
    line-height: 1.1;
}

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 54px;
    background: var(--brand-secondary);
    color: #fff;
    border-radius: var(--radius-btn);
    font-size: 17px;
    font-weight: 600;
    text-decoration: none;
    margin-bottom: 30px;
    transition: opacity 0.2s ease;
}

    .btn-primary:active {
        opacity: 0.8;
    }

.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lines-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 30px;
}

.line-badge {
    min-width: 52px;
    height: 40px;
    border-radius: 10px;
    background: rgba(6, 71, 137, 0.1);
    color: var(--brand-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
}

.stop-marker-pulse {
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    border-radius: 50%;
    background: rgba(236, 22, 40, 0.3);
    animation: markerPulse 2s ease-out infinite;
    z-index: 1;
}

@keyframes markerPulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.info-card {
    background: var(--sys-bg);
    border-radius: var(--radius-card);
    border: 1px solid var(--sys-separator);
    padding: 0 16px;
    margin-bottom: 24px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--sys-separator);
}

    .info-row:last-child {
        border-bottom: none;
    }

    .info-row span {
        color: var(--sys-text-secondary);
        font-size: 13px;
        font-weight: 500;
    }

    .info-row b {
        color: var(--sys-text-primary);
        font-size: 13px;
        font-weight: 600;
    }

.duty-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 7px;
    background: var(--sys-bg);
    border-radius: var(--radius-card);
    border: 1px solid var(--sys-separator);
    text-align: left;
    min-height: 50px;
    margin-bottom: 2px;
    transition: all 0.2s ease;
}

    .duty-card.active {
        background: #FFB800;
        border-color: #FFB800;
        color: #000;
    }

        .duty-card.active .line-badge {
            background: rgba(0, 0, 0, 0.1);
            color: #000;
        }

.duty-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

    .duty-meta span {
        font-size: 15px;
        font-weight: 600;
        color: var(--sys-text-primary);
    }

.duty-card.active .duty-meta span {
    color: #000;
}

.duty-time b {
    font-size: 18px;
    font-weight: 700;
    color: var(--sys-text-primary);
}

.duty-card.active .duty-time b {
    color: #000;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

.feature-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 4px;
    background: var(--sys-bg);
    border-radius: var(--radius-card);
    border: 1px solid var(--sys-separator);
    color: var(--sys-text-secondary);
    transition: all 0.2s ease;
}

    .feature-card svg {
        width: 24px;
        height: 24px;
        opacity: 0.4;
    }

    .feature-card span {
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .feature-card.active {
        border-color: #FFB800;
    }

        .feature-card.active svg,
        .feature-card.active span {
            color: #FFB800;
            opacity: 1;
        }

.duties-header {
    display: flex;
    justify-content: space-between;
    padding: 0 16px;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--sys-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

    .duties-header .h-line {
        width: 68px;
        text-align: left;
    }

    .duties-header .h-dest {
        flex: 1;
        text-align: left;
    }

    .duties-header .h-time {
        width: 60px;
        text-align: right;
    }

.leaflet-top.leaflet-right {
    top: 80px;
}

@media(max-width: 767px) {
    .leaflet-top.leaflet-right {
        top: 80px;
        right: 0px;
    }
}

.captcha-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

    .captcha-overlay.show {
        opacity: 1;
        pointer-events: auto;
    }

.captcha-box {
    background: var(--sys-surface);
    border: 1px solid var(--sys-separator);
    border-radius: var(--radius-card);
    padding: 24px;
    width: 320px;
    box-shadow: var(--shadow-float);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.captcha-overlay.show .captcha-box {
    transform: scale(1);
}

.captcha-header {
    font-size: 16px;
    font-weight: 700;
    color: var(--sys-text-primary);
}

.directions-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--brand-secondary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}

    .directions-btn:active {
        opacity: 0.8;
    }


.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

    .modal-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

    .modal-backdrop .modal-content {
        transform: scale(0.9) translateY(-20px);
        transition: transform 0.25s ease;
    }

    .modal-backdrop.show .modal-content {
        transform: scale(1) translateY(0);
    }
