:root {
  --bg-dark: #0f172a;
  --bg-grad-1: #0f172a;
  --bg-grad-2: #1e293b;
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(148, 163, 184, 0.15);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --success: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 18px;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  overscroll-behavior-y: none;
}

body {
  background: radial-gradient(1200px 600px at 50% -10%, #1e293b 0%, var(--bg-dark) 55%);
  min-height: 100vh;
}

#app { padding: 16px 16px 96px; max-width: 560px; margin: 0 auto; }

.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hd { margin: 8px 4px 18px; }
.hd h1 { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -0.02em; }
.hd .sub { color: var(--text-muted); margin: 4px 0 0; font-size: 13px; }

.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hidden { display: none !important; }

/* Route picker */
.route-card { position: relative; display: flex; flex-direction: column; gap: 10px; }
.city-select {
  width: 100%; text-align: left; background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border); border-radius: 14px; padding: 12px 14px;
  color: var(--text-main); display: flex; flex-direction: column; gap: 2px; cursor: pointer;
  transition: border-color .2s, transform .1s;
}
.city-select:active { transform: scale(0.99); }
.cs-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.cs-value { font-size: 17px; font-weight: 600; }
.swap-btn {
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--glass-border);
  background: var(--accent); color: #04222e; font-size: 20px; font-weight: 700; cursor: pointer; z-index: 2;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}
.swap-btn:active { transform: translateY(-50%) scale(0.92); }

.field-label { display: block; font-size: 12px; color: var(--text-muted); margin: 0 0 6px 2px; font-weight: 500; }
.select-input {
  width: 100%; background: rgba(15, 23, 42, 0.6); border: 1px solid var(--glass-border);
  border-radius: 12px; padding: 12px 14px; color: var(--text-main); font-size: 16px;
  font-family: inherit; appearance: none; -webkit-appearance: none;
}
.select-input:focus { outline: none; border-color: var(--accent); }
input[type=date].select-input { min-height: 48px; }

/* Stops */
.stops-toggle { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 600; }
.chev { transition: transform .2s; color: var(--text-muted); }
.chev.open { transform: rotate(180deg); }
.stops-body { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.stops-body select { margin-bottom: 8px; }

/* Results / trips */
.section-title { font-size: 13px; color: var(--text-muted); margin: 18px 4px 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.trip {
  background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer; transition: transform .1s, border-color .2s;
}
.trip:active { transform: scale(0.99); border-color: var(--accent); }
.trip-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.trip-times { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; }
.trip-times .arrow { color: var(--text-muted); font-size: 14px; }
.trip-times .arr { color: var(--text-muted); font-weight: 600; }
.trip-route { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.trip-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.badge { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; }
.badge.ok { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge.no { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.cost { font-weight: 700; font-size: 16px; }
.status-chip { font-size: 11px; color: var(--text-muted); padding: 4px 8px; border: 1px solid var(--glass-border); border-radius: 999px; }

/* Empty / loading */
.empty { text-align: center; color: var(--text-muted); padding: 40px 20px; }
.empty .emoji { font-size: 40px; display: block; margin-bottom: 10px; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--glass-border); border-top-color: var(--accent); border-radius: 50%; margin: 30px auto; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons */
.btn { width: 100%; border: none; border-radius: 14px; padding: 14px; font-size: 16px; font-weight: 700; font-family: inherit; cursor: pointer; margin-top: 10px; transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04222e; }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); color: #04261c; }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--glass-border); }
.btn:disabled { opacity: 0.5; }

/* Toggle row */
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.toggle-row .tr-label { font-weight: 600; }
.toggle-row .tr-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.switch { position: relative; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { display: none; }
.slider { position: absolute; inset: 0; background: rgba(148,163,184,0.3); border-radius: 999px; transition: .25s; }
.slider::before { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .25s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* Overlay (city picker) */
.overlay { position: fixed; inset: 0; background: var(--bg-dark); z-index: 50; display: none; flex-direction: column; }
.overlay.show { display: flex; animation: fade .2s; }
.overlay-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--glass-border); }
.ov-close { background: none; border: none; color: var(--text-main); font-size: 22px; cursor: pointer; width: 36px; }
.city-search { flex: 1; background: rgba(15,23,42,0.6); border: 1px solid var(--glass-border); border-radius: 12px; padding: 11px 14px; color: var(--text-main); font-size: 16px; }
.city-search:focus { outline: none; border-color: var(--accent); }
.city-list { flex: 1; overflow-y: auto; padding: 8px 16px 30px; }
.city-item { padding: 15px 14px; border-radius: 12px; font-size: 17px; font-weight: 500; cursor: pointer; }
.city-item:active { background: var(--glass-bg); }
.city-item + .city-item { border-top: 1px solid rgba(148,163,184,0.08); }
.city-divider { height: 1px; background: var(--glass-border); margin: 10px 4px; }

/* Sheets */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 60; display: none; align-items: flex-end; }
.sheet-backdrop.show { display: flex; animation: fade .2s; }
.sheet { width: 100%; max-width: 560px; margin: 0 auto; background: var(--bg-grad-2); border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); border-top: 1px solid var(--glass-border); animation: slideup .25s ease; }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.sheet h3 { margin: 0 0 6px; font-size: 18px; }
.sheet .muted { color: var(--text-muted); font-size: 13px; margin: 0 0 14px; }
.sheet-route { font-size: 15px; color: var(--text-muted); margin-bottom: 4px; }
.token-input { width: 100%; min-height: 90px; background: rgba(15,23,42,0.7); border: 1px solid var(--glass-border); border-radius: 12px; padding: 12px; color: var(--text-main); font-family: monospace; font-size: 13px; resize: vertical; }

/* Profile */
.profile-head { display: flex; align-items: center; gap: 14px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; color: #04222e; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 20px; font-weight: 700; }
.profile-handle { color: var(--accent); font-size: 14px; }
.stat-row { display: flex; gap: 12px; margin-top: 4px; }
.stat { flex: 1; text-align: center; background: rgba(15,23,42,0.5); border-radius: 14px; padding: 14px; border: 1px solid var(--glass-border); }
.stat .num { font-size: 24px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.token-status { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.on { background: var(--success); } .dot.off { background: var(--danger); }

/* Toast */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1e293b; border: 1px solid var(--glass-border); color: var(--text-main); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: .3s; z-index: 80; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Tab bar */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: rgba(15,23,42,0.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--glass-border); padding-bottom: env(safe-area-inset-bottom); z-index: 40; }
.tab { flex: 1; background: none; border: none; color: var(--text-muted); padding: 10px 0 12px; font-size: 11px; font-weight: 600; font-family: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tab .ti { font-size: 21px; filter: grayscale(0.4); transition: .2s; }
.tab.active { color: var(--accent); }
.tab.active .ti { filter: none; transform: translateY(-1px); }
