* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
-webkit-font-smoothing: antialiased;    -moz-osx-font-smoothing: grayscale;    transform: translateZ(0);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #e8e0d5;
    color: #4f4b43;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark mode */
body.dark-mode {
    background: #050505;
    color: #97d8ea;
}

body.dark-mode .subtitle {
    color: #94a3b8;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

/* Theme toggle */
.theme-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    border: 1px solid #d4cdc1;
    background: #f5f5f5;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: #e5e5e5;
    transform: scale(1.05);
}

.theme-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fbbf24;
    position: relative;
    transition: all 0.3s ease;
}

.theme-icon::before {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 28px;
    height: 28px;
    border: 3px solid #fbbf24;
    border-radius: 50%;
    border-color: #fbbf24 transparent transparent transparent;
    transform: rotate(45deg);
}

body.dark-mode .theme-toggle {
    background: #0d0d0d;
    border-color: #1a1a1a;
}

body.dark-mode .theme-toggle:hover {
    background: #334155;
}

body.dark-mode .theme-icon {
    background: #64748b;
    transform: scale(0.6);
}

body.dark-mode .theme-icon::before {
    border-color: #97d8ea transparent transparent transparent;
    transform: rotate(135deg) scale(1.2);
}

.logo {
    max-width: 300px;
    width: 100%;
    height: auto;
    margin-bottom: 10px;
    border-radius: 40px;
    clip-path: inset(15px round 40px);
    transition: opacity 0.55s ease, background-color 0.3s ease, padding 0.3s ease;
}


.service-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 8px;
}

.service-indicator.workday {
    background: #f0f9ff;
    color: #1e40af;
    border: 1px solid #bae6fd;
}

body.dark-mode .service-indicator.workday {
    background: #1e3a5f;
    color: #93c5fd;
    border-color: #1e3a5f;
}

.service-indicator.weekend {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

body.dark-mode .service-indicator.weekend {
    background: #422006;
    color: #fde68a;
    border-color: #713f12;
}

.service-indicator.holiday {
    background: #fce7f3;
    color: #9f1239;
    border: 1px solid #fbcfe8;
}

body.dark-mode .service-indicator.holiday {
    background: #4c0519;
    color: #fda4af;
    border-color: #881337;
}

.service-indicator.summer {
    background: #ffedd5;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

body.dark-mode .service-indicator.summer {
    background: #431407;
    color: #fdba74;
    border-color: #7c2d12;
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.service-indicator.workday .indicator-dot {
    background: #1e40af;
}

.service-indicator.weekend .indicator-dot {
    background: #92400e;
}

.service-indicator.holiday .indicator-dot {
    background: #9f1239;
}

.service-indicator.summer .indicator-dot {
    background: #9a3412;
}

.indicator-text {
    font-size: 0.85rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: #4f4b43;
}

.subtitle {
    font-size: 1rem;
    color: #6b7280;
}

h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: #4f4b43;
}

body.dark-mode h2 {
    color: #97d8ea;
}

.section-title {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 20px;
}

body.dark-mode .section-title {
    color: #94a3b8;
}

.view {
    animation: fadeIn 0.3s ease-in;
}

.view.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Instructions */
.instructions {
    padding: 16px 20px;
    margin-bottom: 24px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.typewriter-text {
    font-size: 0.95rem;
    color: #a8a8a8;
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
}

body.dark-mode .typewriter-text {
    color: #a8a8a8;
}

.search-box {
    margin-bottom: 12px;
}

.quick-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 8px 0;
    transition: opacity 0.2s ease;
}

.quick-links.hidden {
    display: none;
}

.quick-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.quick-link:hover {
    color: #2563eb;
    background: #eff6ff;
}

.quick-link-icon {
    font-size: 1rem;
}

.quick-link-separator {
    color: #d1d5db;
    font-size: 0.8rem;
}

body.dark-mode .quick-link {
    color: #94a3b8;
}

body.dark-mode .quick-link:hover {
    color: #60a5fa;
    background: #1e3a5f;
}

body.dark-mode .quick-link-separator {
    color: #4b5563;
}

#search-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.1rem;
    border: 1px solid #d4cdc1;
    background: #ffffff;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s;
}

#search-input:focus {
    background: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

body.dark-mode #search-input {
    background: #ffffff;
    border-color: #1a1a1a;
    color: #4f4b43;
}

body.dark-mode #search-input:focus {
    background: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.result-item, .direction-item, .departure-card {
    background: #f5f5f5;
    border: 1px solid #d4cdc1;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.direction-item {
    background: #f5f5f5;
}

body.dark-mode .direction-item {
    background: #0d0d0d;
}

.result-item:hover, .direction-item:hover {
    border-color: #2563eb;
    transform: translateY(-2px);
    filter: brightness(0.97);
}

body.dark-mode .result-item,
body.dark-mode .departure-card {
    background: #0d0d0d;
    border-color: #1a1a1a;
}

body.dark-mode .direction-item {
    border-color: #1a1a1a;
}

body.dark-mode .result-item:hover,
body.dark-mode .direction-item:hover {
    border-color: #3b82f6;
    filter: brightness(1.15);
}

.result-item {
    font-size: 1rem;
    color: #4f4b43;
}

body.dark-mode .result-item {
    color: #97d8ea;
}

/* Route search special item */
.route-search-item {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #3b82f6;
}

body.dark-mode .route-search-item {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    border-color: #3b82f6;
}

.route-search-item .result-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.route-icon {
    width: 20px;
    height: 20px;
    background: #2563eb;
    border-radius: 4px;
    position: relative;
    flex-shrink: 0;
}

.route-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 2px;
    background: white;
    border-radius: 1px;
}

.route-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(90deg);
    width: 12px;
    height: 2px;
    background: white;
    border-radius: 1px;
}

body.dark-mode .route-icon {
    background: #60a5fa;
}

.direction-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Add spacing after last item in route group */
.direction-item.route-group-last {
    margin-bottom: 16px;
}

.route-badge {
    background: #2563eb;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

/* Transport type colors */
.route-badge.tram {
    background: #dc2626;  /* Red for trams */
}

.route-badge.bus {
    background: #2563eb;  /* Blue for buses */
}

.route-badge.trolleybus {
    background: #059669;  /* Green for trolleybuses */
}

.route-badge.night-route {
    background: #1e1b4b;
    color: #fef08a;
}

/* Transport type legend */
.transport-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

body.dark-mode .transport-legend {
    background: #0d0d0d;
    border-color: #1a1a1a;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-badge {
    width: 24px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.legend-badge.tram {
    background: #dc2626;
}

.legend-badge.bus {
    background: #2563eb;
}

.legend-badge.trolleybus {
    background: #059669;
}

.legend-text {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 500;
}

body.dark-mode .legend-text {
    color: #94a3b8;
}

.night-badge {
    background: #1e1b4b;
    color: #fef08a;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.night-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fef08a;
}

/* Night lines collapsible section */
.night-lines-section {
    margin-top: 16px;
    border: 1px solid #d4cdc1;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

body.dark-mode .night-lines-section {
    border-color: #1a1a1a;
}

.night-lines-header {
    background: #fef3c7;
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

body.dark-mode .night-lines-header {
    background: #3a3420;
}

.night-lines-header:hover {
    background: #fde68a;
}

body.dark-mode .night-lines-header:hover {
    background: #4a4428;
}

.night-lines-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #78350f;
}

body.dark-mode .night-lines-title {
    color: #fef08a;
}

.night-lines-arrow {
    font-size: 0.75rem;
    color: #78350f;
    transition: transform 0.3s ease;
}

body.dark-mode .night-lines-arrow {
    color: #fef08a;
}

.night-lines-section.expanded .night-lines-arrow {
    transform: rotate(180deg);
}

.night-lines-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 12px;
}

.night-lines-section.expanded .night-lines-content {
    max-height: 2000px;
    padding: 12px;
}

.stop-name {
    font-size: 1rem;
    flex: 1;
    color: #4f4b43;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stop-name::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6b7280;
    flex-shrink: 0;
}

body.dark-mode .stop-name {
    color: #97d8ea;
}

body.dark-mode .stop-name::before {
    background: #94a3b8;
}

.headsign {
    font-size: 1rem;
    flex: 1;
    color: #4f4b43;
    display: flex;
    align-items: center;
    gap: 8px;
}

.headsign::before {
    content: '→';
    font-size: 1.2rem;
    color: #6b7280;
    flex-shrink: 0;
}

body.dark-mode .headsign {
    color: #97d8ea;
}

body.dark-mode .headsign::before {
    color: #94a3b8;
}

.departure-card {
    cursor: default;
    padding: 20px 24px;
}

.departure-card:hover {
    transform: none;
}

.departure-time {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #4f4b43;
}

body.dark-mode .departure-time {
    color: #97d8ea;
}

.departure-actual-time {
    font-size: 0.85rem;
    color: #9ca3af;
    margin-bottom: 12px;
}

.departure-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.departure-headsign {
    color: #6b7280;
    font-size: 1rem;
}

body.dark-mode .departure-headsign {
    color: #94a3b8;
}

body.dark-mode .departure-actual-time {
    color: #64748b;
}

.back-btn {
    background: none;
    border: none;
    color: #2563eb;
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 20px;
    transition: opacity 0.2s;
}

.back-btn:hover {
    opacity: 0.7;
}

body.dark-mode .back-btn {
    color: #60a5fa;
}

.no-results {
    text-align: center;
    color: #9ca3af;
    padding: 40px 20px;
    font-size: 1rem;
}

body.dark-mode .no-results {
    color: #64748b;
}

.loading {
    text-align: center;
    color: #6b7280;
    padding: 20px;
}

body.dark-mode .loading {
    color: #94a3b8;
}

/* Favorite items styling */

.favorite-item {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.favorite-item:hover {
    background: #fef3c7;
    border-color: #fbbf24;
    transform: translateX(4px);
}

body.dark-mode .favorite-item {
    background: #422006;
    border-color: #713f12;
}

body.dark-mode .favorite-item:hover {
    background: #542a0a;
    border-color: #92400e;
}

.favorite-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.favorite-icon {
    color: #f59e0b;
    font-size: 1.1rem;
}

body.dark-mode .favorite-icon {
    color: #fbbf24;
}

.favorite-name {
    font-size: 0.95rem;
    color: #4f4b43;
}

body.dark-mode .favorite-name {
    color: #fde68a;
}

.remove-favorite-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.remove-favorite-btn:hover {
    color: #dc2626;
    transform: scale(1.2);
}

body.dark-mode .remove-favorite-btn {
    color: #f87171;
}

body.dark-mode .remove-favorite-btn:hover {
    color: #fca5a5;
}

/* Favorite toggle button in search results */
.result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.result-content {
    flex: 1;
    cursor: pointer;
}

.favorite-toggle {
    background: none;
    border: none;
    color: #d1d5db;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.favorite-toggle:hover {
    color: #f59e0b;
    transform: scale(1.2);
}

.favorite-toggle.active {
    color: #f59e0b;
}

body.dark-mode .favorite-toggle {
    color: #4b5563;
}

body.dark-mode .favorite-toggle:hover {
    color: #fbbf24;
}

body.dark-mode .favorite-toggle.active {
    color: #fbbf24;
}

/* Recent searches header */
.recent-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 12px;
}

.clear-recent-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: opacity 0.2s;
}

.clear-recent-btn:hover {
    opacity: 0.7;
}

.recent-item {
    background: #fafafa;
    border: 1px solid #d4cdc1;
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.recent-item:hover {
    background: #eff6ff;
    border-color: #2563eb;
    transform: translateX(4px);
}

body.dark-mode .recent-item {
    background: #0d0d0d;
    border-color: #1a1a1a;
}

body.dark-mode .recent-item:hover {
    background: #1e3a5f;
    border-color: #3b82f6;
}

.recent-icon {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6b7280;
    flex-shrink: 0;
}

.recent-name {
    font-size: 0.95rem;
    color: #4f4b43;
}

body.dark-mode .recent-name {
    color: #97d8ea;
}

body.dark-mode .clear-recent-btn {
    color: #f87171;
}

/* Popup styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.popup-overlay.hidden {
    display: none;
}

.popup-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body.dark-mode .popup-content {
    background: #050505;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

body.dark-mode .popup-header {
    border-bottom-color: #334155;
}

.popup-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #4f4b43;
}

body.dark-mode .popup-header h3 {
    color: #97d8ea;
}

.popup-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
    line-height: 1;
}

.popup-close:hover {
    background: #f3f4f6;
    color: #4f4b43;
}

body.dark-mode .popup-close {
    color: #64748b;
}

body.dark-mode .popup-close:hover {
    background: #0d0d0d;
    color: #97d8ea;
}

.popup-list {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.popup-list .favorite-item,
.popup-list .recent-item {
    margin-bottom: 8px;
}

.popup-list .favorite-item:last-child,
.popup-list .recent-item:last-child {
    margin-bottom: 0;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 20px 24px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .departure-time {
        font-size: 2rem;
    }

    .instructions {
        padding: 12px 16px;
        min-height: 45px;
    }

    .typewriter-text {
        font-size: 0.85rem;
    }
}

/* Nearby stops */
.nearby-stops {
    margin-top: 12px;
    margin-bottom: 20px;
}

.nearby-stops.hidden {
    display: none;
}

.nearby-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #8b8279;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    text-align: center;
}

.nearby-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 6px;
    background: #ffffff;
    border: 1px solid #d4cdc1;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.nearby-item:hover {
    background: #f0ebe3;
    transform: translateY(-1px);
}

.nearby-item:active {
    transform: translateY(0);
}

.nearby-name {
    font-size: 1rem;
    font-weight: 500;
    color: #4f4b43;
}

.nearby-distance {
    font-size: 0.85rem;
    color: #8b8279;
    white-space: nowrap;
    margin-left: 12px;
}

body.dark-mode .nearby-title {
    color: #64748b;
}

body.dark-mode .nearby-item {
    background: #111111;
    border-color: #1e293b;
}

body.dark-mode .nearby-item:hover {
    background: #1a1a2e;
}

body.dark-mode .nearby-name {
    color: #97d8ea;
}

body.dark-mode .nearby-distance {
    color: #64748b;
}

.nearby-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.nearby-header .nearby-title {
    margin-bottom: 0;
}

.nearby-refresh {
    background: none;
    border: 1px solid #d4cdc1;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1rem;
    cursor: pointer;
    color: #8b8279;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.nearby-refresh:hover {
    background: #f0ebe3;
    color: #4f4b43;
}

.nearby-refresh:active {
    transform: rotate(180deg);
}

body.dark-mode .nearby-refresh {
    border-color: #1e293b;
    color: #64748b;
}

body.dark-mode .nearby-refresh:hover {
    background: #1a1a2e;
    color: #97d8ea;
}
