*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #eef1f7;
  --bg-glow: rgba(37, 99, 235, 0.08);
  --surface: #ffffff;
  --surface-2: #f3f6fb;
  --surface-3: #e9eef6;
  --border: #e2e8f1;
  --text: #0f1b2d;
  --muted: #5d6b80;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-weak: rgba(37, 99, 235, 0.10);
  --primary-grad: linear-gradient(135deg, #2563eb, #4f46e5);
  --accent: #f59e0b;
  --success: #16a34a;
  --success-weak: rgba(22, 163, 74, 0.12);
  --warning: #d97706;
  --warning-weak: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-weak: rgba(220, 38, 38, 0.10);
  --on-primary: #ffffff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 28px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.14);
  --ring: rgba(37, 99, 235, 0.30);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f17;
    --bg-glow: rgba(59, 130, 246, 0.14);
    --surface: #121a26;
    --surface-2: #1a2433;
    --surface-3: #222e3f;
    --border: #283443;
    --text: #e8eef6;
    --muted: #93a1b5;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-weak: rgba(59, 130, 246, 0.16);
    --primary-grad: linear-gradient(135deg, #3b82f6, #6366f1);
    --accent: #fbbf24;
    --success: #22c55e;
    --success-weak: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --warning-weak: rgba(245, 158, 11, 0.14);
    --danger: #ef4444;
    --danger-weak: rgba(239, 68, 68, 0.14);
    --on-primary: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 52px rgba(0, 0, 0, 0.55);
    --ring: rgba(96, 165, 250, 0.40);
  }
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -200px, var(--bg-glow), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(48px + env(safe-area-inset-bottom));
}

/* ===== App bar ===== */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid transparent;
}

.appbar.scrolled {
  border-bottom-color: var(--border);
}

.appbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand-text {
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

.back-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ===== Hero ===== */
.hero {
  margin: 6px 2px 22px;
}

.hero-title {
  margin: 0 0 6px;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 52ch;
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.card-title {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .ic {
  font-size: 1.1rem;
  line-height: 1;
}

.card-sub {
  color: var(--muted);
  font-size: 0.875rem;
  margin: -8px 0 16px;
}

/* ===== Form ===== */
.form-grid {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
  animation: rise 0.25s ease both;
}

label,
.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.field-hint {
  margin: -4px 0 4px;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238b9cb3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
  background: var(--surface);
}

/* ===== Buttons ===== */
button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--primary-grad);
  color: var(--on-primary);
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s, background 0.15s;
  box-shadow: 0 6px 16px var(--primary-weak);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 10px 22px var(--primary-weak);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

button.secondary,
.btn-ghost {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text);
  box-shadow: none;
}

button.secondary:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
  filter: none;
}

button.danger-ghost {
  background: var(--danger-weak);
  color: var(--danger);
  box-shadow: none;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== Chips ===== */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.12s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover {
  border-color: var(--primary);
}

.chip:active {
  transform: scale(0.97);
}

.chip.selected {
  border-color: transparent;
  background: var(--primary-grad);
  color: var(--on-primary);
  box-shadow: 0 6px 14px var(--primary-weak);
}

.chip-sub {
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.75;
}

/* ===== Selected box (chosen stop) ===== */
.selected-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary-weak);
  animation: rise 0.2s ease both;
}

.selected-box .sb-name {
  font-weight: 700;
}

.selected-box .sb-meta {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  opacity: 0.72;
  margin-top: 4px;
}

.pick-change-btn {
  flex-shrink: 0;
  padding: 8px 14px !important;
  font-size: 0.8125rem !important;
}

/* ===== Stop picker list ===== */
.search {
  position: relative;
}

.route-list,
.stop-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 10px;
  padding-right: 2px;
}

.route-search-hint {
  margin-top: 8px;
  margin-bottom: 0;
}

.route-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
  box-shadow: none !important;
  font-weight: 500;
  color: var(--text);
}

.route-row:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface);
  transform: none !important;
  filter: none;
}

.route-row:active:not(:disabled) {
  transform: scale(0.99) !important;
}

.route-row-code {
  flex-shrink: 0;
  min-width: 52px;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  background: var(--primary-weak);
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 800;
  text-align: center;
}

.route-row-name {
  flex: 1;
  min-width: 0;
  font-size: 0.9375rem;
  line-height: 1.35;
}

.stop-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.stop-row:hover {
  border-color: var(--primary);
}

.stop-row:active {
  transform: scale(0.99);
}

.stop-row.selected {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.stop-seq {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--muted);
}

.stop-row.selected .stop-seq {
  background: var(--primary);
  color: var(--on-primary);
}

.stop-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stop-name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
}

.stop-no {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  opacity: 0.72;
  letter-spacing: 0.01em;
}

.muted-note {
  color: var(--muted);
  margin: 8px 2px;
  font-size: 0.9rem;
}

/* ===== Badges / pills ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.active { background: var(--success-weak); color: var(--success); }
.badge.waiting { background: var(--warning-weak); color: var(--warning); }
.badge.completed { background: var(--primary-weak); color: var(--primary); }
.badge.expired { background: var(--warning-weak); color: var(--warning); }
.badge.cancelled { background: var(--surface-3); color: var(--muted); }

/* ===== Job list (home) ===== */
.job-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.job-swipe {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-width: 0;
}

.job-swipe-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
  background: transparent;
}

.job-swipe-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0 !important;
  border: none !important;
  border-radius: var(--radius-xs) !important;
  background: transparent !important;
  color: var(--muted) !important;
  box-shadow: none !important;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.job-swipe-delete:hover:not(:disabled),
.job-swipe-delete:active:not(:disabled) {
  color: var(--danger) !important;
  background: var(--surface-3) !important;
  transform: none !important;
}

.job-swipe-delete-ic {
  display: block;
  width: 20px;
  height: 20px;
}

.job-swipe-content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
  touch-action: pan-y;
}

.job-swipe.is-open .job-swipe-content {
  transform: translateX(-48px);
}

.job-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}

@media (max-width: 640px) {
  .job-swipe {
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
  }

  .job-card {
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  .job-card:hover {
    transform: none;
    border-color: transparent;
  }
}

@media (min-width: 641px) {
  .job-swipe {
    display: flex;
    align-items: stretch;
    gap: 8px;
    overflow: visible;
    background: transparent;
  }

  .job-swipe-actions {
    position: static;
    width: auto;
    z-index: 1;
  }

  .job-swipe-delete {
    align-self: center;
  }

  .job-swipe-delete:hover:not(:disabled) {
    transform: none !important;
  }

  .job-swipe-content {
    flex: 1;
    min-width: 0;
    transform: none !important;
    transition: none;
    touch-action: auto;
  }

  .job-swipe.is-open .job-swipe-content {
    transform: none !important;
  }
}

.job-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

@media (min-width: 641px) {
  .job-card:hover {
    transform: translateY(-2px);
  }
}

.route-badge {
  flex-shrink: 0;
  min-width: 52px;
  height: 44px;
  padding: 0 10px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
  background: var(--primary-grad);
  color: var(--on-primary);
  letter-spacing: -0.01em;
}

.job-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.job-target {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-meta {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.job-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.chevron {
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
}

/* ===== Empty state ===== */
.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
}

.empty .empty-ic {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
  opacity: 0.8;
}

.empty-state {
  color: var(--muted);
  font-size: 0.9375rem;
  margin: 0;
  padding: 12px 0;
}

/* ===== Status messages ===== */
.status-msg {
  padding: 11px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.875rem;
  margin-top: 12px;
  border: 1px solid transparent;
}

.status-msg.error {
  background: var(--danger-weak);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.status-msg.info {
  background: var(--primary-weak);
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 25%, transparent);
}

.status-msg.success {
  background: var(--success-weak);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

/* ===== Tracking: hero remaining ===== */
.track-hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 22px 20px 24px;
}

.track-hero-top {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.remaining-ring {
  width: 168px;
  height: 168px;
  margin: 8px auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--surface) 56%, transparent 57%),
    conic-gradient(var(--ring-color, var(--primary)) var(--ring-pct, 0deg), var(--surface-3) 0);
  transition: --ring-pct 0.5s ease;
}

.remaining-ring.near {
  --ring-color: var(--warning);
}

.remaining-inner {
  display: grid;
  place-items: center;
  gap: 2px;
}

.remaining-num {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--primary);
}

.remaining-num.warn { color: var(--warning); }
.remaining-num.ok { color: var(--success); }

.remaining-unit {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.remaining-cap {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 4px 0 0;
}

.remaining-cap strong {
  color: var(--text);
}

/* ===== Tracking: summary strip ===== */
.summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.summary-item {
  background: var(--surface);
  padding: 13px 14px;
}

.summary-item .s-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 3px;
}

.summary-item .s-value {
  font-size: 0.95rem;
  font-weight: 700;
}

/* ===== Notify card ===== */
.notify-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.notify-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  background: var(--primary-weak);
}

.notify-head .nh-text {
  flex: 1;
}

.notify-head .nh-title {
  font-weight: 700;
  font-size: 1.02rem;
}

.notify-head .nh-sub {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 2px;
}

.ios-guide {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--primary-weak);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  font-size: 0.875rem;
  line-height: 1.55;
}

.ios-guide ol {
  margin: 8px 0 0;
  padding-left: 20px;
}

.ios-guide li {
  margin-bottom: 6px;
}

/* ===== Bus cards ===== */
.bus-list {
  display: grid;
  gap: 10px;
}

.bus-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
  animation: rise 0.25s ease both;
}

.bus-card.near {
  border-color: color-mix(in srgb, var(--warning) 45%, transparent);
  background: var(--warning-weak);
}

.bus-card.arrived {
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
  background: var(--success-weak);
}

.bus-plate {
  flex-shrink: 0;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.bus-info {
  flex: 1;
  min-width: 0;
}

.bus-stop {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bus-info .bi-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 1px;
}

.bus-remaining {
  flex-shrink: 0;
  text-align: center;
  min-width: 56px;
}

.bus-remaining .br-num {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.bus-card.near .br-num { color: var(--warning); }
.bus-card.arrived .br-num { color: var(--success); font-size: 1rem; }

.bus-remaining .br-cap {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ===== Timeline (events) ===== */
.event-feed-desc {
  color: var(--muted);
  font-size: 0.875rem;
  margin: -8px 0 16px;
}

.timeline {
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  gap: 0;
  max-height: 520px;
  overflow-y: auto;
}

.tl-item {
  position: relative;
  padding: 0 0 18px 28px;
  animation: rise 0.3s ease both;
}

.tl-item::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 18px;
  bottom: -2px;
  width: 2px;
  background: var(--border);
}

.tl-item:first-child::before {
  display: none;
}

.tl-dot {
  position: absolute;
  left: 0;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--muted);
  z-index: 1;
}

.tl-item.THRESHOLD_REACHED .tl-dot { border-color: var(--warning); }
.tl-item.ARRIVED .tl-dot { border-color: var(--success); }
.tl-item.BUS_DISCOVERED .tl-dot { border-color: var(--success); }
.tl-item.STOP_CHANGED .tl-dot { border-color: var(--primary); }
.tl-item.REMAINING_UPDATED .tl-dot { border-color: var(--primary); }
.tl-item.JOB_STARTED .tl-dot { border-color: var(--primary); }
.tl-item.JOB_EXPIRED .tl-dot { border-color: var(--danger); }
.tl-item.JOB_CANCELLED .tl-dot { border-color: var(--danger); }
.tl-item.NO_BUSES .tl-dot { border-color: var(--muted); }
.tl-item.POSITION_UNKNOWN .tl-dot { border-color: var(--warning); }

.tl-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.tl-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.tl-time {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.tl-msg {
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--muted);
}

.tl-item.THRESHOLD_REACHED .tl-msg,
.tl-item.ARRIVED .tl-msg {
  color: var(--text);
}

/* ===== Utilities ===== */
.hidden {
  display: none !important;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 16px auto;
}

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

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Confirm modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
  visibility: hidden;
}

.modal[hidden] {
  display: none !important;
}

.modal.is-open {
  pointer-events: auto;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 27, 45, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

@media (prefers-color-scheme: dark) {
  .modal-backdrop {
    background: rgba(0, 0, 0, 0.58);
  }
}

.modal.is-open .modal-backdrop {
  opacity: 1;
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal.is-open .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: var(--surface-3);
}

.modal-icon-wrap {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--danger-weak);
  color: var(--danger);
}

.modal-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.02em;
}

.modal-text {
  margin: 0 0 22px;
  font-size: 0.9375rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px !important;
  font-size: 0.9375rem !important;
  box-shadow: none !important;
}

.modal-btn:hover:not(:disabled) {
  transform: none !important;
}

.modal-btn-danger {
  background: var(--danger) !important;
  color: #fff !important;
}

.modal-btn-danger:hover:not(:disabled) {
  filter: brightness(1.06);
}

@media (min-width: 641px) {
  .modal {
    align-items: center;
    padding: 24px;
  }

  .modal-sheet {
    border-radius: var(--radius);
    padding: 28px 24px 24px;
    transform: translateY(16px) scale(0.96);
    opacity: 0;
    transition:
      transform 0.24s cubic-bezier(0.32, 0.72, 0, 1),
      opacity 0.24s ease;
  }

  .modal.is-open .modal-sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  .modal-handle {
    display: none;
  }
}

@media (max-width: 640px) {
  .modal-actions {
    grid-template-columns: 1fr;
  }

  .modal-btn-danger {
    order: -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal-backdrop,
  .modal-sheet {
    transition: none !important;
  }
}

@media (max-width: 600px) {
  .hero-title { font-size: 1.5rem; }
  .summary { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
