* { margin: 0; padding: 0; box-sizing: border-box; }

    .back-link {
      color: rgba(255,255,255,0.7); text-decoration: none;
      font-size: 13px; font-weight: 500;
      background: rgba(255,255,255,0.06); backdrop-filter: blur(20px);
      border: 1px solid rgba(255,255,255,0.08);
      padding: 7px 14px; border-radius: 100px;
      transition: background 0.15s;
    }
    .back-link:hover { background: rgba(255,255,255,0.12); }

    body {
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
      background: #0a0a0a;
      color: #fff;
      overflow: hidden;
      height: 100vh;
    }

    #map { width: 100%; height: 100vh; z-index: 1; }

    /* ── Top bar ── */
    .top-bar {
      position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
      display: flex; align-items: center; justify-content: space-between;
      padding: 14px 20px;
      background: linear-gradient(180deg, rgba(10,10,10,0.95) 0%, rgba(10,10,10,0) 100%);
      pointer-events: none;
    }
    .top-bar > * { pointer-events: auto; }

    .clock {
      display: flex; align-items: center; gap: 10px;
      font-weight: 700; font-size: 18px; letter-spacing: -0.3px;
    }
    .clock-icon {
      width: 34px; height: 34px; background: #3b82f6; border-radius: 9px;
      display: flex; align-items: center; justify-content: center;
    }
    .clock-icon svg { width: 18px; height: 18px; fill: #fff; }
    .clock-time { font-variant-numeric: tabular-nums; font-size: 20px; }

    .status-badge {
      display: flex; align-items: center; gap: 8px;
      background: rgba(255,255,255,0.06); backdrop-filter: blur(20px);
      border: 1px solid rgba(255,255,255,0.08);
      padding: 7px 14px; border-radius: 100px;
      font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.7);
    }
    .status-dot {
      width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
      animation: pulse-dot 2s ease-in-out infinite;
    }
    @keyframes pulse-dot {
      0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
      50% { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
    }

    /* ── Info panel ── */
    .info-panel {
      position: fixed; bottom: 20px; left: 20px; z-index: 1000;
      background: rgba(12,12,12,0.92); backdrop-filter: blur(24px);
      border: 1px solid rgba(255,255,255,0.08); border-radius: 16px;
      padding: 16px; min-width: 290px; max-width: 340px;
    }
    .info-panel h3 {
      font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.35);
      text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 12px;
    }
    .bus-list {
      display: flex; flex-direction: column; gap: 6px;
      max-height: 300px; overflow-y: auto;
    }
    .bus-list::-webkit-scrollbar { width: 3px; }
    .bus-list::-webkit-scrollbar-track { background: transparent; }
    .bus-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

    .bus-item {
      display: flex; align-items: center; gap: 12px;
      padding: 10px 12px; background: rgba(255,255,255,0.03);
      border-radius: 12px; cursor: pointer; transition: background 0.15s;
    }
    .bus-item:hover { background: rgba(255,255,255,0.07); }

    .bus-item-icon {
      width: 38px; height: 38px; border-radius: 10px;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0; position: relative;
    }
    .bus-item-icon svg { width: 20px; height: 20px; fill: #fff; }
    .bus-item-badge {
      position: absolute; top: -4px; right: -4px;
      min-width: 18px; height: 18px; border-radius: 9px;
      background: rgba(0,0,0,0.7); border: 1.5px solid rgba(255,255,255,0.2);
      display: flex; align-items: center; justify-content: center;
      font-size: 10px; font-weight: 700; padding: 0 4px;
    }

    .bus-item-info { flex: 1; min-width: 0; }
    .bus-item-route {
      font-size: 13px; font-weight: 600;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .bus-item-status { font-size: 11px; color: rgba(255,255,255,0.35); margin-top: 2px; }
    .bus-item-speed { font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.4); flex-shrink: 0; }

    /* ── Bus marker on map ── */
    .bus-pin {
      position: relative;
      filter: drop-shadow(0 3px 8px rgba(0,0,0,0.5));
    }
    .bus-pin-body {
      display: flex; align-items: center; gap: 5px;
      padding: 6px 10px 6px 8px;
      border-radius: 20px;
      color: #fff; white-space: nowrap;
    }
    .bus-pin-body svg { width: 16px; height: 16px; fill: #fff; flex-shrink: 0; }
    .bus-pin-num { font-size: 13px; font-weight: 700; font-family: 'Inter', sans-serif; }
    .bus-pin-arrow {
      position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
      width: 0; height: 0;
      border-left: 5px solid transparent; border-right: 5px solid transparent;
    }

    /* Pulse ring when at stop */
    .bus-pin.at-stop::before {
      content: ''; position: absolute;
      top: 50%; left: 50%; transform: translate(-50%, -50%);
      width: 52px; height: 52px; border-radius: 50%;
      border: 2px solid; opacity: 0.3;
      animation: stop-pulse 2s ease-out infinite;
    }
    @keyframes stop-pulse {
      0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.4; }
      100% { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
    }

    /* At-stop pulse uses CSS variable set inline */
    .bus-pin.at-stop::before { border-color: var(--pin-color, #3b82f6); }

    /* ── Stop markers ── */
    .stop-dot {
      width: 8px; height: 8px; border-radius: 50%;
      background: rgba(255,255,255,0.5);
      border: 1.5px solid rgba(100,160,255,0.6);
      transition: transform 0.2s, background 0.2s;
    }
    .stop-dot:hover { transform: scale(1.8); background: #fff; }

    /* ── Leaflet popup override ── */
    .leaflet-popup-content-wrapper {
      background: rgba(12,12,12,0.95) !important;
      backdrop-filter: blur(24px);
      border: 1px solid rgba(255,255,255,0.1) !important;
      border-radius: 14px !important;
      color: #fff !important;
      box-shadow: 0 12px 40px rgba(0,0,0,0.6) !important;
      padding: 0 !important;
    }
    .leaflet-popup-tip {
      background: rgba(12,12,12,0.95) !important;
      border: 1px solid rgba(255,255,255,0.1) !important;
      border-top: none !important; border-left: none !important;
    }
    .leaflet-popup-content { margin: 0 !important; min-width: 230px; }
    .leaflet-popup-close-button { display: none !important; }

    .popup-content { padding: 16px; }
    .popup-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
    .popup-icon {
      width: 36px; height: 36px; border-radius: 10px;
      display: flex; align-items: center; justify-content: center;
    }
    .popup-icon svg { width: 20px; height: 20px; fill: #fff; }
    .popup-titles { flex: 1; }
    .popup-line-name { font-weight: 700; font-size: 15px; }
    .popup-route-name { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 1px; }

    .popup-details { display: flex; flex-direction: column; gap: 8px; }
    .popup-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
    .popup-label { color: rgba(255,255,255,0.35); }
    .popup-value { font-weight: 500; }
    .popup-value.at-stop-yes { color: #22c55e; }
    .popup-value.delayed { color: #ef4444; }
    .popup-value.delayed-minor { color: #f59e0b; }

    .bus-item-delay {
      font-size: 10px; font-weight: 600; color: #ef4444;
      padding: 2px 6px; background: rgba(239,68,68,0.12);
      border-radius: 6px; flex-shrink: 0;
    }
    .bus-item-delay.minor { color: #f59e0b; background: rgba(245,158,11,0.12); }

    .bus-pin-late {
      position: absolute; top: -6px; right: -8px;
      font-size: 9px; font-weight: 700; color: #fff;
      background: #ef4444; border-radius: 8px;
      padding: 1px 4px; font-family: 'Inter', sans-serif;
      line-height: 1.2;
    }
    .popup-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 2px 0; }

    .stop-popup-name {
      font-weight: 600; font-size: 14px; padding: 12px 16px 0;
    }
    .stop-popup-code {
      color: rgba(255,255,255,0.35); font-weight: 400;
      font-size: 11px; display: block; margin-top: 3px;
    }
    .stop-popup-deps {
      padding: 10px 16px 14px; display: flex; flex-direction: column; gap: 4px;
    }
    .stop-popup-deps-title {
      font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.3);
      text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px;
    }
    .stop-popup-dep {
      display: flex; align-items: center; gap: 8px; font-size: 12px;
    }
    .stop-popup-dep-badge {
      min-width: 18px; height: 18px; border-radius: 5px;
      display: flex; align-items: center; justify-content: center;
      font-size: 9px; font-weight: 700; color: #fff; flex-shrink: 0;
    }
    .stop-popup-dep-time { font-weight: 600; }
    .stop-popup-dep-mins { margin-left: auto; color: rgba(255,255,255,0.4); font-size: 11px; }
    .stop-popup-dep-mins.soon { color: #22c55e; }
    .stop-popup-none { font-size: 11px; color: rgba(255,255,255,0.25); padding: 4px 0; }

    /* ── Stop search ── */
    .stop-search-wrap { position: relative; margin-bottom: 10px; }
    .stop-search {
      width: 100%; padding: 9px 12px 9px 32px; border-radius: 10px;
      background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
      color: #fff; font-family: inherit; font-size: 13px; outline: none;
    }
    .stop-search::placeholder { color: rgba(255,255,255,0.25); }
    .stop-search:focus { border-color: rgba(255,255,255,0.2); }
    .stop-search-icon {
      position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
      color: rgba(255,255,255,0.25); font-size: 13px; pointer-events: none;
    }
    .stop-suggestions {
      position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
      background: rgba(12,12,12,0.97); backdrop-filter: blur(24px);
      border: 1px solid rgba(255,255,255,0.1); border-radius: 10px;
      margin-top: 4px; max-height: 180px; overflow-y: auto; display: none;
    }
    .stop-suggestions.active { display: block; }
    .stop-suggestion {
      padding: 9px 12px; cursor: pointer; font-size: 13px;
      border-bottom: 1px solid rgba(255,255,255,0.04);
    }
    .stop-suggestion:last-child { border-bottom: none; }
    .stop-suggestion:hover, .stop-suggestion:active { background: rgba(255,255,255,0.06); }

    /* ── Timetable view ── */
    .timetable-view { display: none; }
    .timetable-view.active { display: block; }
    .timetable-header {
      display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
    }
    .timetable-back {
      width: 28px; height: 28px; border-radius: 8px;
      background: rgba(255,255,255,0.06); border: none;
      color: #fff; font-size: 14px; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
    }
    .timetable-stop-name { font-weight: 600; font-size: 14px; }
    .timetable-next { margin-bottom: 14px; }
    .timetable-section-title {
      font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.35);
      text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px;
    }
    .next-dep {
      display: flex; align-items: center; justify-content: space-between;
      padding: 8px 10px; background: rgba(255,255,255,0.03); border-radius: 8px;
      margin-bottom: 4px;
    }
    .next-dep-time { font-weight: 600; font-size: 14px; }
    .next-dep-eta { font-size: 12px; color: rgba(255,255,255,0.4); }
    .next-dep-eta.soon { color: #22c55e; font-weight: 600; }
    .tt-grid {
      display: flex; flex-wrap: wrap; gap: 4px;
      max-height: 200px; overflow-y: auto;
    }
    .tt-grid::-webkit-scrollbar { width: 3px; }
    .tt-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
    .tt-time {
      padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 500;
      background: rgba(255,255,255,0.04);
    }
    .tt-time.past { opacity: 0.25; }
    .tt-time.next { background: rgba(226,25,139,0.2); color: #e2198b; font-weight: 700; }

    /* ── Legend ── */
    .legend {
      display: flex; gap: 6px;
    }
    .legend-desktop {
      position: fixed; bottom: 20px; right: 20px; z-index: 1000;
    }
    .legend-inline {
      display: none;
    }
    .legend-item {
      display: flex; align-items: center; gap: 6px;
      background: rgba(255,255,255,0.06);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 100px; padding: 6px 12px;
      font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.55);
    }
    .legend-desktop .legend-item {
      background: rgba(12,12,12,0.9); backdrop-filter: blur(20px);
    }
    .legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

    /* ── Dark map ── */
    .leaflet-tile-pane { filter: saturate(0.25) brightness(0.6) contrast(1.15); }

    .leaflet-control-zoom { border: none !important; box-shadow: none !important; }
    .leaflet-control-zoom a {
      background: rgba(12,12,12,0.9) !important; backdrop-filter: blur(20px);
      border: 1px solid rgba(255,255,255,0.08) !important;
      color: rgba(255,255,255,0.7) !important;
      width: 34px !important; height: 34px !important; line-height: 34px !important;
      font-size: 16px !important;
    }
    .leaflet-control-zoom a:first-child { border-radius: 10px 10px 0 0 !important; }
    .leaflet-control-zoom a:last-child { border-radius: 0 0 10px 10px !important; }
    .leaflet-control-attribution {
      background: rgba(0,0,0,0.4) !important;
      color: rgba(255,255,255,0.2) !important; font-size: 10px !important;
    }
    .leaflet-control-attribution a { color: rgba(255,255,255,0.3) !important; }

    /* ── Panel handle (hidden on desktop) ── */
    .panel-handle { display: none; }

    /* ── Responsive ── */
    @media (max-width: 600px) {
      body { height: 100dvh; }
      #map { height: 100dvh; }

      .top-bar {
        padding: 10px 14px;
        padding-top: max(10px, env(safe-area-inset-top));
      }
      .clock { font-size: 16px; }
      .clock-icon { width: 30px; height: 30px; border-radius: 8px; }
      .clock-icon svg { width: 16px; height: 16px; }
      .clock-time { font-size: 17px; }
      .status-badge { padding: 5px 10px; font-size: 12px; }

      /* Bottom sheet panel */
      .info-panel {
        position: fixed; bottom: 0; left: 0; right: 0;
        max-width: none; min-width: auto;
        border-radius: 20px 20px 0 0;
        padding: 0 16px 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        max-height: 55dvh;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        transform: translateY(0);
      }
      .info-panel.collapsed {
        transform: translateY(calc(100% - 52px));
      }
      .info-panel h3 { margin-bottom: 10px; }

      .bus-list { max-height: 35dvh; }

      /* Drag handle */
      .panel-handle {
        display: flex; justify-content: center; padding: 12px 0 8px;
        cursor: grab; touch-action: none;
      }
      .panel-handle-bar {
        width: 36px; height: 4px; border-radius: 2px;
        background: rgba(255,255,255,0.2);
      }

      .bus-item { padding: 12px; gap: 10px; }
      .bus-item-icon { width: 34px; height: 34px; border-radius: 8px; }
      .bus-item-route { font-size: 13px; }

      /* Legend: inline inside panel on mobile */
      .legend-desktop { display: none; }
      .legend-inline {
        display: flex; flex-wrap: wrap; gap: 6px;
        margin-bottom: 12px;
      }
      .legend-inline .legend-item { padding: 4px 10px; font-size: 10px; }

      /* Popups */
      .leaflet-popup-content { min-width: 200px; }

      /* Zoom controls - push below top bar */
      .leaflet-top.leaflet-right { top: 56px !important; }
      .leaflet-control-zoom { margin-right: 10px !important; }
    }

    @media (max-width: 380px) {
      .clock-label { display: none; }
    }