header,
main {
    max-width: 1100px;
    width: 100%;
    box-sizing: border-box;
}

.io-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.city-select {
    font-family: Monaco, monospace;
    font-size: 13px;
    padding: 8px 12px;
    border: 2px solid black;
    background: white;
    cursor: pointer;
}

.status-line {
    font-family: Monaco, monospace;
    font-size: 13px;
    color: #555;
}

.tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border-bottom: 2px solid black;
}

.tab-btn {
    font-family: Monaco, monospace;
    font-size: 13px;
    padding: 7px 18px;
    border: 2px solid black;
    border-bottom: none;
    background: white;
    cursor: pointer;
    margin-bottom: -2px;
    color: #555;
}

.tab-btn:hover {
    background: #f5f5f5;
}

.tab-btn.active {
    background: white;
    color: black;
    font-weight: bold;
    border-bottom: 2px solid white;
}

.tab-pane {
    /* no special styling needed */
}

.date-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-family: Monaco, monospace;
    font-size: 13px;
}

.date-label {
    color: #555;
}

.date-input {
    font-family: Monaco, monospace;
    font-size: 13px;
    padding: 6px 10px;
    border: 2px solid black;
    background: white;
    cursor: pointer;
}

.progress-bar-wrap {
    height: 6px;
    border: 1px solid black;
    background: white;
    margin-bottom: 16px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #16a34a;
    width: 0%;
    transition: width 0.3s ease;
}

.map-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    position: relative;
}

#map,
#mapHistory {
    flex: 1;
    min-width: 0;
    height: 600px;
    border: 2px solid black;
}

#sidePanel,
#sidePanelHistory {
    width: 280px;
    flex-shrink: 0;
    height: 600px;
    border: 2px solid black;
    background: white;
    display: flex;
    flex-direction: column;
}

.street-search-wrap {
    border-bottom: 2px solid black;
    padding: 6px 8px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.street-search-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.street-search-row .street-search-input {
    flex: 1;
}

.street-search-map-label {
    font-family: Monaco, monospace;
    font-size: 11px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    user-select: none;
}

.walked-filter-toggle {
    display: flex;
    gap: 0;
    border: 1px solid #ccc;
    border-radius: 3px;
    overflow: hidden;
}

.walked-filter-btn {
    flex: 1;
    padding: 4px 0;
    font-family: Monaco, monospace;
    font-size: 11px;
    background: white;
    border: none;
    border-right: 1px solid #ccc;
    cursor: pointer;
    color: #555;
    user-select: none;
}

.walked-filter-btn:last-child {
    border-right: none;
}

.walked-filter-btn:hover {
    background: #f5f5f5;
}

.walked-filter-btn--active {
    background: black;
    color: white;
}

.walked-filter-btn--active:hover {
    background: #222;
}

.street-search-input {
    box-sizing: border-box;
    font-family: Monaco, monospace;
    font-size: 12px;
    padding: 5px 8px;
    border: 1px solid #ccc;
    background: white;
}

.street-search-input:focus {
    outline: none;
    border-color: black;
}

#sideList,
#sideListHistory {
    flex: 1;
    overflow-y: auto;
}

/* --- Street group (collapsible) --- */
.street-group {
    border-bottom: 1px solid #e5e5e5;
}

.street-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    cursor: pointer;
    font-family: Monaco, monospace;
    font-size: 12px;
    user-select: none;
}

.street-header {
    background: #f5f5f5;
}

.street-header:hover {
    background: #ebebeb;
}

.street-header.some-walked {
    background: white;
}

.street-header.some-walked:hover {
    background: #f5f5f5;
}

.street-header.some-walked .street-name {
    color: #166534;
}

.street-header.all-walked {
    background: #f0fdf4;
}

.street-header.all-walked:hover {
    background: #dcfce7;
}

.street-header.all-walked .street-name {
    color: #166534;
}

.street-arrow {
    flex-shrink: 0;
    font-size: 10px;
    color: #888;
    width: 10px;
}

.street-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.street-prog {
    flex-shrink: 0;
    font-size: 11px;
    color: #888;
    white-space: nowrap;
}

.street-header.some-walked .street-prog,
.street-header.all-walked .street-prog {
    color: #16a34a;
}

/* --- Segment rows --- */
.seg-list {
    border-top: 1px solid #e5e5e5;
    background: #f5f5f5;
}

.seg-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px 5px 24px;
    cursor: pointer;
    font-family: Monaco, monospace;
    font-size: 11px;
    user-select: none;
    border-bottom: 1px solid #ebebeb;
    background: #f5f5f5;
}

.seg-row:last-child {
    border-bottom: none;
}

.seg-row:hover {
    background: #ebebeb;
}

.seg-row.walked {
    background: #f0fdf4;
}

.seg-row.walked:hover {
    background: #dcfce7;
}

.seg-check {
    flex-shrink: 0;
    width: 13px;
    height: 13px;
    border: 1.5px solid #bbb;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: white;
    background: white;
}

.seg-row.walked .seg-check {
    border-color: #16a34a;
    background: #16a34a;
}

.seg-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #444;
}

.seg-row.walked .seg-label {
    color: #166534;
}

.seg-len {
    flex-shrink: 0;
    color: #aaa;
    font-size: 10px;
}

.map-layout.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 500;
    background: white;
    gap: 0;
}

.map-layout.fullscreen #map,
.map-layout.fullscreen #mapHistory {
    width: 100%;
    height: 100%;
    border: none;
}

.map-layout.fullscreen #sidePanel,
.map-layout.fullscreen #sidePanelHistory {
    display: none;
}

.fullscreen-map-btn {
    font-size: 16px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.loading-msg {
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.loading-msg-text {
    font-family: Monaco, monospace;
    font-size: 12px;
    color: #555;
    text-align: center;
}

.loading-msg-sub {
    font-family: Monaco, monospace;
    font-size: 11px;
    color: #999;
    text-align: center;
}

@media (max-width: 700px) {
    main {
        padding: 0 10px;
    }

    .map-layout {
        flex-direction: column;
    }

    #map,
    #mapHistory {
        width: 100%;
        height: 55vw;
        min-height: 280px;
    }

    #sidePanel,
    #sidePanelHistory {
        width: 100%;
        height: 260px;
    }

    .io-bar {
        flex-wrap: wrap;
    }

    .status-line {
        width: 100%;
    }

    #mapRoute { width: 100%; height: 55vw; min-height: 280px; }
    #sidePanelRoute { width: 100%; height: 260px; }
}

/* Route tab */
#mapRoute { flex: 1; min-width: 0; height: 600px; border: 2px solid black; }
#sidePanelRoute { width: 280px; flex-shrink: 0; height: 600px; border: 2px solid black;
    background: white; display: flex; flex-direction: column; overflow-y: auto; }

.route-controls-row { display: flex; flex-wrap: wrap; align-items: center;
    gap: 8px; margin-bottom: 8px; font-family: Monaco, monospace; font-size: 13px; }
.route-address-input { width: 300px; }
.route-distance-input { width: 70px; }
.route-label { color: #555; white-space: nowrap; font-family: Monaco, monospace; font-size: 13px; }
.route-seg-num { flex-shrink: 0; font-size: 10px; color: #888; width: 20px; text-align: right; }
.route-legend { display: flex; align-items: center; gap: 4px; margin-bottom: 8px;
    font-family: Monaco, monospace; font-size: 12px; color: #555; }
.route-legend-swatch { display: inline-block; width: 24px; height: 4px; border-radius: 2px; flex-shrink: 0; }
.route-legend-swatch--pin { width: 10px; height: 10px; border-radius: 50%; }
.route-btn-active { background: #1e40af; color: white; border-color: #1e40af; }
.route-btn-active:hover { background: #1d4ed8; }

.map-layout.fullscreen #mapRoute { width: 100%; height: 100%; border: none; }
.map-layout.fullscreen #sidePanelRoute { display: none; }

/* GPS tracking overlay */
#gpsStatsOverlay {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 510;
    background: rgba(0, 0, 0, 0.78);
    color: white;
    font-family: Monaco, monospace;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

#gpsStatsOverlay.gps-active {
    display: flex;
}

.gps-stat-block {
    text-align: center;
    flex: 1;
}

.gps-stat-value {
    font-size: 30px;
    font-weight: bold;
    line-height: 1;
    letter-spacing: -0.02em;
}

.gps-stat-label {
    font-size: 10px;
    opacity: 0.65;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
}

/* GPS walk control button */
.gps-track-btn {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    transition: bottom 0.2s ease;
    z-index: 520;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.9);
    background: #1e293b;
    color: white;
    font-size: 28px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.gps-track-btn.gps-btn-active {
    color: #ef4444;
    border-color: #ef4444;
    bottom: 104px;
}

@keyframes gps-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.import-banner {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    background: #f0fdf4;
    border-bottom: 2px solid #16a34a;
    font-family: Monaco, monospace;
    max-height: 80px;
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.4s ease, max-height 0.35s ease 0.4s, padding 0.35s ease 0.4s, border-width 0.35s ease 0.4s;
}

.import-banner.dismissed {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom-width: 0;
}

.import-banner-title {
    font-size: 12px;
    font-weight: bold;
    color: #166534;
}

.import-banner-sub {
    font-size: 11px;
    color: #555;
}

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

.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ddd;
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
