:root {
  --bg: #0b1a2b;
  --bg-2: #102338;
  --card: #15293f;
  --card-2: #1b344f;
  --line: #24405e;
  --text: #e8eef5;
  --muted: #93a7bf;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --warn: #fbbf24;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #173251 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 80px;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 26, 43, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: #fff; font-weight: 800; font-size: 22px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}
.brand h1 { font-size: 17px; margin: 0; line-height: 1.1; }
.brand p { font-size: 12px; margin: 2px 0 0; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 8px; }
.lang-select {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  height: 42px;
  border-radius: 12px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.lang-select:focus { outline: none; border-color: var(--accent); }

.icon-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  width: 42px; height: 42px;
  border-radius: 12px;
  font-size: 20px;
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.icon-btn:active { transform: rotate(180deg) scale(.95); background: var(--card-2); }

/* Sekmeler */
.tabs {
  display: flex;
  gap: 6px;
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 16px 0;
  position: sticky;
  top: 75px;
  z-index: 9;
  background: rgba(11, 26, 43, 0.85);
  backdrop-filter: blur(10px);
}
.tabs[hidden] { display: none; } /* hidden attribute'u display:flex'i ezmesin */
.tab {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding: 11px 10px;
  border-radius: 12px 12px 0 0;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.tab.on {
  color: var(--text);
  background: linear-gradient(180deg, #1c3a57 0%, var(--card) 100%);
  border-color: var(--accent);
  border-bottom-color: transparent;
}
.tab:active { transform: scale(.98); }

.panel { animation: rise .25s ease both; }

main { max-width: 680px; margin: 0 auto; padding: 16px; }

/* Location bar */
.location-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}
#locationText { font-size: 13px; color: var(--muted); }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.ghost-btn:active { background: rgba(56,189,248,.12); }

/* Meta bar: son güncelleme + oto-yenile */
.meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.last-updated { display: flex; align-items: center; gap: 6px; }
.last-updated::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 0 0 rgba(34,197,94,.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.auto-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.auto-toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

/* "son güncelleme" altındaki ince açıklama */
.disclaimer {
  margin: -4px 2px 12px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
  opacity: .78;
  letter-spacing: .2px;
}
.disclaimer-ico { opacity: .85; }

/* Kayar yazı (ticker): hat aksamaları + ani duyurular */
.ticker {
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  background: linear-gradient(90deg, #3a1620 0%, #2a1a10 100%);
  border: 1px solid #7f1d1d;
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.ticker::before, .ticker::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 28px; z-index: 2; pointer-events: none;
}
.ticker::before { left: 0; background: linear-gradient(90deg, #3a1620, transparent); }
.ticker::after { right: 0; background: linear-gradient(270deg, #2a1a10, transparent); }
.ticker-track {
  display: inline-block;
  padding: 9px 0;
  will-change: transform;
  animation: ticker-scroll 40s linear infinite; /* JS içerik uzunluğuna göre güncelleyebilir */
}
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.ticker-item { display: inline-block; padding: 0 26px; font-size: 13px; font-weight: 600; }
.ticker-item.alert { color: #fca5a5; }
.ticker-item.ann { color: #bae6fd; }
.tk-badge {
  display: inline-block; color: #fff; font-weight: 800; font-size: 11px;
  padding: 1px 7px; border-radius: 6px; vertical-align: middle; margin: 0 2px;
}
/* "Aktif duyuru/aksama yok" — sakin, ince, kaymayan satır */
.ticker.clear {
  background: rgba(34, 197, 94, .08);
  border-color: rgba(34, 197, 94, .35);
  box-shadow: none;
  white-space: normal;
}
.ticker.clear::before, .ticker.clear::after { display: none; }
.ticker-clear {
  padding: 8px 14px; text-align: center;
  font-size: 12px; font-weight: 600; color: var(--accent-2);
  letter-spacing: .2px;
}

[dir="rtl"] .ticker-track { animation-name: ticker-scroll-rtl; }
@keyframes ticker-scroll-rtl {
  from { transform: translateX(-50%); }
  to { transform: translateX(0); }
}

/* Bilgi bandı: duyurular + sistem durumu */
.info-band {
  background: linear-gradient(180deg, #16314c 0%, var(--card) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.info-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; font-size: 13px; font-weight: 800;
  border-bottom: 1px solid var(--line);
}
.info-x {
  background: none; border: none; color: var(--muted);
  font-size: 15px; cursor: pointer; padding: 2px 6px; border-radius: 8px;
}
.info-x:hover { color: var(--text); background: var(--card-2); }
.info-body { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.eq-line { font-size: 13px; }
.eq-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.eq-chip {
  font-size: 11.5px; font-weight: 700; color: #fcd34d;
  background: rgba(251, 191, 36, .1); border: 1px solid var(--warn);
  padding: 3px 8px; border-radius: 8px;
}
.ann { border-top: 1px dashed var(--line); padding-top: 8px; }
.ann:first-child { border-top: none; padding-top: 0; }
.ann-t { font-size: 12.5px; font-weight: 700; cursor: pointer; color: #bae6fd; }
.ann-c {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  max-height: 0; overflow: hidden; transition: max-height .25s ease; margin-top: 0;
}
.ann.open .ann-c { max-height: 400px; margin-top: 6px; overflow-y: auto; }

/* İstasyon tesisleri (erişilebilirlik) */
.facilities {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 16px 4px;
}
.fac {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--card-2); border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 8px; cursor: default;
}

/* Son tren */
.last-train { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.last-train.soon { color: var(--warn); font-weight: 700; }

/* RTL (Arapça) küçük düzeltmeler */
[dir="rtl"] .dir-name .arrow { transform: scaleX(-1); display: inline-block; }
[dir="rtl"] .station-meta { text-align: left; }

/* Hat filtresi çipleri */
.line-filter {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 0 2px 14px;
}
.chip {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 700; font-size: 13px;
  padding: 6px 13px;
  border-radius: 20px;
  cursor: pointer;
  transition: transform .12s;
}
.chip:active { transform: scale(.94); }
.chip.on { color: #fff; }

/* Status */
.status {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 14px;
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.results { display: flex; flex-direction: column; gap: 16px; }

.station-card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: rise .35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.station-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px 10px;
}
.station-title { display: flex; align-items: center; gap: 8px; }
.station-name { font-size: 17px; font-weight: 700; margin: 0; }
.station-meta { text-align: right; }
.station-dist { font-size: 13px; color: var(--accent); white-space: nowrap; font-weight: 600; }
.station-walk { font-size: 11px; color: var(--muted); display: block; }

.fav-btn {
  background: none; border: none; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--muted);
  padding: 0; transition: transform .15s, color .15s;
}
.fav-btn.on { color: var(--warn); }
.fav-btn:active { transform: scale(1.3); }

/* Servis durumu uyarısı */
.line-warn {
  font-size: 11px; font-weight: 700; color: #0b1a2b;
  background: var(--warn); padding: 2px 8px; border-radius: 6px;
  cursor: help;
}
.mar-tag {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px;
}
.warn-text {
  font-size: 12px; color: #fcd34d;
  background: rgba(251,191,36,.08);
  border-left: 3px solid var(--warn);
  padding: 7px 10px; border-radius: 6px;
  margin: 4px 0 6px;
}

.line-block { padding: 4px 16px 14px; }
.line-head { display: flex; align-items: center; gap: 8px; margin: 10px 0 8px; }
.line-badge {
  font-size: 12px; font-weight: 800; color: #fff;
  padding: 3px 9px; border-radius: 7px;
  letter-spacing: .3px;
}

.dir { margin: 8px 0; }
.dir-name {
  font-size: 12.5px; color: var(--muted); margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.dir-name .arrow { color: var(--accent); }

.times { display: flex; gap: 8px; flex-wrap: wrap; }
.time-chip {
  background: var(--card-2, #1b344f);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 11px;
  min-width: 62px;
  text-align: center;
  line-height: 1.15;
}
.time-chip .eta { font-size: 16px; font-weight: 800; color: var(--accent-2); display: block; }
.time-chip.soon .eta { color: var(--warn); }
.time-chip.now .eta { color: #ef4444; }
.time-chip .clock { font-size: 11px; color: var(--muted); }

.no-times { font-size: 12.5px; color: var(--muted); font-style: italic; }

/* Canlı otobüs listesi */
.bus-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.bus-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
}
.bus-row.tappable { cursor: pointer; }
.bus-row.tappable:hover { border-color: var(--accent); }
.bus-row.tappable:active { transform: scale(.99); }
.bus-plate { font-weight: 700; white-space: nowrap; }

/* Otobüs harita modalı */
.map-modal {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: rise .2s ease both;
}
.map-modal[hidden] { display: none; } /* hidden attribute'u display:flex'i ezmesin */
.map-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: var(--card); font-weight: 700; font-size: 15px;
}
.map-canvas { flex: 1; min-height: 0; background: #0a1622; }
.map-info {
  padding: 12px 16px; font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--line); background: var(--card);
  text-align: center;
}
.leaflet-popup-content { font-size: 13px; }
/* radar dot tıklanabilir imleç */
.radar-bus { cursor: pointer; }
.bus-near { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bus-time { color: var(--accent-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bus-status { font-size: 12.5px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bus-status.approaching { color: var(--accent-2); }
.bus-status.away { color: #f87171; }

/* Canlı radar */
.radar-wrap { display: flex; flex-direction: column; align-items: center; margin: 8px 0 10px; }
.radar { width: 200px; height: 200px; max-width: 70%; }
.radar-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.radar-axis { stroke: var(--line); stroke-width: 1; opacity: .5; }
.radar-me { fill: var(--accent); stroke: #fff; stroke-width: 1.5; }
.radar-bus { fill: var(--muted); }
.radar-bus.approaching { fill: var(--accent-2); }
.radar-bus.away { fill: #f87171; }
.radar-legend { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: center; }

#busNearby { margin-top: 18px; }
.nearby-head { font-size: 13px; font-weight: 700; color: var(--muted); margin: 2px 0 8px; }

/* Durak-bazlı varışlar */
.arr-list { display: flex; flex-direction: column; gap: 6px; }
.arr-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
}
.arr-dest { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arr-eta { font-size: 15px; font-weight: 800; color: var(--accent-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.arr-eta.soon { color: var(--warn); }
.arr-eta.now { color: #ef4444; }
.arr-clock { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.tappable { cursor: pointer; transition: border-color .15s, transform .1s; }
.tappable:hover { border-color: var(--accent); }
.tappable:active { transform: scale(.99); }

/* Hat arama (katlanır) */
.line-search-wrap { margin: 6px 0 4px; }
.line-search-wrap > summary {
  cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 700;
  padding: 8px 2px; list-style: none;
}
.line-search-wrap > summary::-webkit-details-marker { display: none; }
.line-search-wrap[open] > summary { color: var(--text); }

/* Search */
.search-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 14px;
}
.search-hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
#searchInput {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}
#searchInput:focus { border-color: var(--accent); }
.search-results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.fav-head { font-size: 12px; color: var(--warn); font-weight: 700; margin: 4px 0 2px; }
.search-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.search-item:active { border-color: var(--accent); }
.search-item .badges { display: inline-flex; gap: 5px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* Errors / banners */
.banner {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}
.banner.error { background: rgba(239,68,68,.12); border: 1px solid #ef4444; color: #fca5a5; }
.banner.info  { background: rgba(56,189,248,.1); border: 1px solid var(--accent); color: #bae6fd; }

.footer {
  text-align: center;
  padding: 18px;
  font-size: 11.5px;
  color: var(--muted);
}
.footer a { color: var(--accent); }
