:root {
  --bg: #090d16;
  --card: #111827;
  --card-border: #1f2937;
  --text: #f8fafc;
  --muted: #94a3b8;
  --green: #22c55e;
  --green-border: rgba(34, 197, 94, 0.45);
  --blue: #38bdf8;
  --blue-bg: rgba(56, 189, 248, 0.12);
  --blue-border: rgba(56, 189, 248, 0.4);
  --radius: 16px;
}

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

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter,
    sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px
    max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.line-badge {
  background: var(--text);
  color: var(--bg);
  font-weight: 900;
  font-size: 1.2rem;
  padding: 3px 10px;
  border-radius: 9px;
  letter-spacing: -0.5px;
}

.brand-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--card-border);
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* Direction Switcher */
.direction-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}

.dir-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 10px;
  padding: 10px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dir-btn.active {
  background: #1e293b;
  color: var(--text);
}

.dir-main {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Fallback Banner */
.fallback-banner {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fde68a;
  border-radius: 12px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.76rem;
}

.fallback-title {
  font-weight: 800;
  color: #fbbf24;
}

.fallback-reason {
  color: #fef3c7;
  opacity: 0.85;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  word-break: break-all;
}

/* Hero Card */
.hero-card {
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero-card.state-yes {
  background: linear-gradient(
    160deg,
    rgba(34, 197, 94, 0.18),
    rgba(17, 24, 39, 0.95)
  );
  border-color: var(--green-border);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stop-pill {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.state-yes .stop-pill {
  color: #bbf7d0;
}

.gps-reset-btn {
  background: rgba(56, 189, 248, 0.15);
  color: var(--blue);
  border: 1px solid var(--blue-border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.hero-main-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.hero-verdict {
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1px;
}

.state-yes .hero-verdict {
  color: #4ade80;
}

.hero-time {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--muted);
}

.state-yes .hero-time {
  color: #f8fafc;
}

/* Recommendation Card */
.recommend-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recommend-card.rec-good {
  border-color: var(--blue-border);
  background: linear-gradient(160deg, var(--blue-bg), var(--card));
}

.rec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rec-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.walk-pill {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.74rem;
  cursor: pointer;
}

.rec-body {
  font-size: 0.95rem;
  line-height: 1.38;
}

.rec-stop-Highlight {
  font-weight: 800;
  color: var(--blue);
}

/* Stops List */
.stops-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 0 4px;
}

.gps-status {
  font-weight: 600;
}

.stops-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stop-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.stop-item.is-current {
  border-color: rgba(248, 250, 252, 0.45);
}

.stop-item.is-recommended {
  border-color: var(--blue-border);
}

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

.stop-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stop-name {
  font-size: 0.95rem;
  font-weight: 700;
}

.mini-tag {
  font-size: 0.64rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  text-transform: uppercase;
}

.tag-here {
  background: rgba(248, 250, 252, 0.14);
  color: var(--text);
}

.tag-go {
  background: rgba(56, 189, 248, 0.2);
  color: var(--blue);
}

.stop-meta {
  font-size: 0.76rem;
  color: var(--muted);
}

.stop-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.dep-main {
  font-size: 1.05rem;
  font-weight: 800;
}

.dep-main.soon {
  color: #4ade80;
}

.dep-main.catchable {
  color: var(--blue);
}

.dep-main.missed {
  color: var(--muted);
  text-decoration: line-through;
  opacity: 0.65;
}

.dep-sub {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal-sheet {
  background: #111827;
  border-top: 1px solid var(--card-border);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 18px 16px max(22px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
}

.setting-group {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-title {
  font-size: 0.9rem;
  font-weight: 700;
}

.setting-desc {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 4px;
  flex-shrink: 0;
}

.step-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: none;
  background: #1e293b;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.step-val {
  min-width: 50px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
}

.quick-Chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  flex: 1;
  min-width: 52px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 7px 4px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: rgba(56, 189, 248, 0.16);
  color: var(--blue);
  border-color: var(--blue-border);
}

.primary-btn {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.hidden {
  display: none !important;
}
