/* Saarthi — white + crimson, map-first design system */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --crimson: #DC143C;
  --crimson-dark: #A60D2E;
  --crimson-deep: #8E0B26;
  --crimson-soft: #FDEDF1;
  --ink: #16181D;
  --muted: #6B7280;
  --line: #E9EAEE;
  --bg: #F7F7F9;
  --white: #FFFFFF;
  --green: #16A34A;
  --green-soft: #EAF7EF;
  --amber: #D97706;
  --amber-soft: #FEF4E6;
  --shadow-card: 0 8px 30px rgba(22, 24, 29, 0.10);
  --shadow-float: 0 16px 48px rgba(22, 24, 29, 0.16);
}

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

html, body { height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

.lucide { width: 18px; height: 18px; stroke-width: 2; flex: none; }
.hidden { display: none !important; }

/* avoid flash of un-rendered icons before lucide.createIcons() runs */
i[data-lucide] { display: inline-block; width: 18px; height: 18px; visibility: hidden; }

:focus-visible { outline: 2px solid var(--crimson); outline-offset: 2px; border-radius: 6px; }

/* ============ map canvas ============ */
#map { position: fixed; inset: 0; z-index: 1; }

/* ============ top bar ============ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.logo {
  display: flex; align-items: center; gap: 10px;
  background: var(--white); padding: 8px 16px 8px 9px; border-radius: 14px;
  box-shadow: var(--shadow-card); font-weight: 800; font-size: 1.05rem;
}
.logo-mark {
  width: 32px; height: 32px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #FF4D6D 0%, var(--crimson) 45%, var(--crimson-deep) 100%);
  box-shadow: 0 4px 12px rgba(220, 20, 60, 0.4);
}
.logo-mark .lucide { stroke: #fff; width: 17px; height: 17px; }
.logo-text {
  background: linear-gradient(120deg, var(--ink) 30%, var(--crimson) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: -0.01em;
}
.ask-pill {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #2A0A14 0%, var(--ink) 60%);
  color: var(--white); border: 1px solid rgba(220, 20, 60, 0.35);
  padding: 11px 18px; border-radius: 14px; font-weight: 700; font-size: 0.85rem;
  box-shadow: var(--shadow-card); cursor: pointer;
  font-family: inherit; transition: transform 0.15s, box-shadow 0.15s;
}
.ask-pill:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(220, 20, 60, 0.25); }
.ask-pill .lucide { stroke: #FF6B86; width: 16px; height: 16px; }

/* LLM warning toast */
.toast-warn {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  z-index: 1200; max-width: 480px;
  background: var(--white); border: 1.5px solid #F3C988;
  color: #92600A; border-radius: 14px; padding: 11px 18px;
  font-size: 0.78rem; font-weight: 600; box-shadow: var(--shadow-card);
  display: flex; gap: 8px; align-items: center;
}
.toast-warn .lucide { stroke: #D97706; width: 16px; height: 16px; }

/* ============ floating panel ============ */
.panel {
  position: fixed; top: 76px; left: 22px; z-index: 900;
  width: 400px; max-height: calc(100vh - 100px);
  background: var(--white); border-radius: 22px;
  box-shadow: var(--shadow-float);
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin;
}
.panel-inner { padding: 22px; }
.panel h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: 4px; }
.panel .sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 18px; font-weight: 500; }
.grab { display: none; width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 0; }

/* screen states */
.state { display: none; }
.state.show { display: block; animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* stepper dots */
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { height: 4px; border-radius: 2px; flex: 1; background: var(--line); }
.steps span.on { background: var(--crimson); }

/* ============ location inputs ============ */
.loc-group { position: relative; padding-left: 30px; }
.loc-group::before {
  content: ""; position: absolute; left: 9px; top: 26px; bottom: 26px;
  border-left: 2px dashed #D9DBE1;
}
.loc-row { position: relative; margin-bottom: 12px; }
.loc-row.loading::after {
  content: ""; position: absolute; right: 14px; top: 17px;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--crimson);
  animation: spin 0.8s linear infinite;
}
.loc-row .node {
  position: absolute; left: -30px; top: 24px; transform: translateY(-50%);
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
}
.node .ring {
  width: 12px; height: 12px; border-radius: 50%;
  border: 3px solid var(--ink); background: var(--white);
}
.node .pin-solid {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--crimson); box-shadow: 0 0 0 4px var(--crimson-soft);
}
.loc-input {
  width: 100%; padding: 14px 16px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--bg);
  font-family: inherit; font-size: 0.95rem; font-weight: 600; color: var(--ink);
}
.loc-input:focus { outline: none; border-color: var(--crimson); background: var(--white); }
.loc-input::placeholder { color: #A6ABB5; font-weight: 500; }
.loc-input.ok { border-color: var(--green); }

/* autocomplete dropdown — anchored under its own input */
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  border: 1.5px solid var(--line); border-radius: 14px;
  overflow: hidden; background: var(--white); box-shadow: var(--shadow-float);
}
.suggest:empty { display: none; }
.suggest-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--bg);
  animation: rise-in 0.18s ease both;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.hot { background: var(--crimson-soft); }
.suggest-item .lucide { stroke: var(--crimson); }
.suggest-item .s-name { font-weight: 700; font-size: 0.88rem; }
.suggest-item .s-addr { color: var(--muted); font-size: 0.75rem; }

/* ============ vehicle carousel ============ */
.v-hint {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); font-size: 0.75rem; margin-bottom: 6px; font-weight: 600;
}
.v-hint .lucide { width: 14px; height: 14px; }
.v-carousel {
  display: flex; gap: 12px; overflow-x: auto; padding: 14px 4px 18px;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.v-carousel::-webkit-scrollbar { display: none; }
.v-card {
  min-width: 112px; scroll-snap-align: center; text-align: center;
  border: 2px solid var(--line); border-radius: 18px; padding: 18px 10px 14px;
  background: var(--white); cursor: pointer; transition: all 0.18s ease;
}
.v-card .lucide { width: 38px; height: 38px; stroke: var(--muted); stroke-width: 1.6; margin-bottom: 8px; }
.v-illus {
  width: 54px; height: 54px; margin-bottom: 6px;
  filter: grayscale(0.7) opacity(0.65); transition: filter 0.25s, transform 0.25s;
}
.v-card.active .v-illus { filter: none; transform: scale(1.05); }
.v-card .v-name { font-weight: 700; font-size: 0.85rem; }
.v-card .v-eta { color: var(--muted); font-size: 0.7rem; margin-top: 2px; }
.v-card:hover { transform: translateY(-3px); }
.v-card.active {
  border-color: var(--crimson); transform: scale(1.07);
  background: linear-gradient(165deg, #FFF6F8 0%, #FFE9EE 100%);
  box-shadow: 0 12px 28px rgba(220, 20, 60, 0.18);
}
.v-card.active .lucide { stroke: var(--crimson); }
.v-card.active .v-name { color: var(--crimson); }

/* ============ chips / time ============ */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  display: flex; align-items: center; gap: 7px;
  background: linear-gradient(135deg, #FFF6F8, #FDEDF1);
  border: 1px solid #F6D5DD;
  padding: 8px 13px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
}
.chip .lucide { width: 14px; height: 14px; stroke: var(--crimson); }
.time-input {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--line); border-radius: 14px;
  padding: 14px 16px; background: var(--bg); margin-bottom: 18px;
}
.time-input .lucide { stroke: var(--crimson); }
.time-input input {
  border: none; background: none; font-family: inherit;
  font-size: 0.95rem; font-weight: 700; color: var(--ink); width: 100%;
}
.time-input input:focus { outline: none; }

/* ============ 3D button (with shine sweep) ============ */
.btn-3d {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 17px; border: none; border-radius: 16px;
  background: linear-gradient(135deg, #FF3D60 0%, #DC143C 45%, #A60D2E 100%);
  color: var(--white); font-family: inherit; font-size: 1rem; font-weight: 800;
  letter-spacing: 0.02em; cursor: pointer;
  box-shadow: 0 6px 0 var(--crimson-deep), 0 14px 26px rgba(220, 20, 60, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s;
}
.btn-3d::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -80%;
  width: 40%; transform: skewX(-20deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  transition: left 0.5s ease;
}
.btn-3d:hover::before { left: 130%; }
.btn-3d:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--crimson-deep), 0 5px 12px rgba(220, 20, 60, 0.3);
}
.btn-3d:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-3d .lucide { stroke: #fff; }
.btn-ghost {
  display: block; width: 100%; text-align: center; margin-top: 12px;
  background: none; border: none; color: var(--muted);
  font-family: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer;
}
.btn-ghost:hover { color: var(--ink); }

/* ============ agent progress ============ */
.task { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.task .t-icon {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex: none;
  background: var(--bg);
}
.task .t-icon .lucide { stroke: var(--muted); width: 16px; height: 16px; }
.task.done .t-icon { background: var(--green-soft); }
.task.done .t-icon .lucide { stroke: var(--green); }
.task.busy .t-icon { background: var(--crimson-soft); }
.task.busy .t-icon .lucide { stroke: var(--crimson); animation: spin 1s linear infinite; }
.task.wait { opacity: 0.4; }
.task .t-label { font-weight: 600; font-size: 0.88rem; }
.task .t-sub { color: var(--muted); font-size: 0.74rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  height: 64px; border-radius: 14px; margin-top: 14px;
  background: linear-gradient(90deg, var(--bg) 25%, #EFEFF3 50%, var(--bg) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.error-box {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--crimson-soft); border: 1.5px solid #F2B8C4;
  border-radius: 14px; padding: 14px; margin-top: 12px;
  font-size: 0.84rem; font-weight: 600; color: var(--crimson-dark); line-height: 1.4;
}
.error-box .lucide { stroke: var(--crimson); margin-top: 1px; }

/* ============ verdict ============ */
.gauge-wrap { text-align: center; margin-bottom: 6px; }
.gauge-wrap svg { width: 190px; }
.gauge-track { stroke: var(--line); }
#gauge-arc { transition: stroke-dashoffset 1s ease; }
.gauge-score { font-size: 1.9rem; font-weight: 800; }
.gauge-level {
  display: inline-block; padding: 4px 14px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em;
}
.lv-high { background: var(--crimson-soft); color: var(--crimson); }
.lv-med  { background: var(--amber-soft); color: var(--amber); }
.lv-low  { background: var(--green-soft); color: var(--green); }

.leave-block {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #1B070D 0%, #2B0712 55%, #4A0D1E 100%);
  color: var(--white); border: 1px solid rgba(220, 20, 60, 0.3);
  border-radius: 18px; padding: 16px 20px; margin: 16px 0;
  box-shadow: 0 14px 30px rgba(74, 13, 30, 0.35);
}
.leave-block .lb-label { font-size: 0.72rem; opacity: 0.65; font-weight: 600; letter-spacing: 0.05em; }
.leave-block .lb-time { font-size: 2.1rem; font-weight: 800; line-height: 1.1; }
.leave-block .lb-eta { font-size: 0.78rem; opacity: 0.75; margin-top: 2px; }
.countdown {
  display: flex; align-items: center; gap: 7px;
  background: linear-gradient(135deg, #FF3D60, var(--crimson-dark));
  padding: 9px 14px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 800; white-space: nowrap;
  box-shadow: 0 0 18px rgba(255, 61, 96, 0.45);
  animation: countdown-pulse 2.4s ease-in-out infinite;
}
@keyframes countdown-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 61, 96, 0.35); }
  50% { box-shadow: 0 0 24px rgba(255, 61, 96, 0.65); }
}
.countdown .lucide { width: 14px; height: 14px; stroke: #fff; }

.verdict-summary { font-size: 0.86rem; line-height: 1.5; color: var(--muted); font-weight: 600; }

.sec-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.1em;
  color: var(--muted); margin: 18px 0 10px;
}
.sec-title .lucide { width: 14px; height: 14px; stroke: var(--crimson); }

.factor {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 9px; background: var(--white);
}
.factor .f-icon {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.f-icon.red { background: var(--crimson-soft); } .f-icon.red .lucide { stroke: var(--crimson); }
.f-icon.amber { background: var(--amber-soft); } .f-icon.amber .lucide { stroke: var(--amber); }
.f-icon.gray { background: var(--bg); } .f-icon.gray .lucide { stroke: var(--muted); }
.factor .f-text { font-size: 0.84rem; font-weight: 600; line-height: 1.35; }
.factor .f-tag {
  margin-left: auto; font-size: 0.62rem; font-weight: 800;
  padding: 3px 9px; border-radius: 999px; letter-spacing: 0.05em; flex: none;
}

/* departure curve */
.curve-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 0.82rem; }
.curve-row .c-dep { width: 44px; font-weight: 800; }
.curve-row .c-track { flex: 1; height: 22px; background: var(--bg); border-radius: 7px; overflow: hidden; }
.curve-row .c-bar { height: 100%; border-radius: 7px; }
.curve-row .c-eta { width: 110px; text-align: right; color: var(--muted); font-weight: 600; font-size: 0.74rem; }
.curve-row.rec .c-dep { color: var(--crimson); }
.curve-row.rec .c-eta { color: var(--crimson); font-weight: 800; }

.tip {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--crimson-soft); border-radius: 12px;
  padding: 12px 14px; font-size: 0.82rem; font-weight: 600; line-height: 1.4;
  margin-bottom: 8px;
}
.tip .lucide { stroke: var(--crimson); margin-top: 1px; }
.provider-note { margin-top: 12px; font-size: 0.72rem; color: var(--muted); font-weight: 600; }

/* ============ map pins ============ */
.pin-marker .pin-body {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0;
  background: var(--crimson); transform: rotate(-45deg);
  border: 3px solid var(--white);
  box-shadow: 0 4px 12px rgba(22, 24, 29, 0.35);
}
.pin-marker.pin-start .pin-body { background: var(--ink); }

/* ============ ask modal ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(22, 24, 29, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  width: 100%; max-width: 520px; max-height: 80vh; overflow-y: auto;
  background: var(--white); border-radius: 22px; padding: 24px;
  box-shadow: var(--shadow-float);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h3 { font-size: 1.1rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.modal-head h3 .lucide { stroke: var(--crimson); }
.modal-close { background: none; border: none; cursor: pointer; padding: 6px; }
.modal-close .lucide { stroke: var(--muted); }
.ask-row { display: flex; gap: 10px; margin-top: 14px; }
.ask-row input {
  flex: 1; padding: 13px 15px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--bg);
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
}
.ask-row input:focus { outline: none; border-color: var(--crimson); background: var(--white); }
.ask-row button {
  border: none; border-radius: 14px; padding: 0 22px;
  background: linear-gradient(180deg, #E82850, #C01236); color: #fff;
  font-family: inherit; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 0 var(--crimson-deep);
}
.ask-row button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--crimson-deep); }
.ask-row button:disabled { opacity: 0.5; }
.ask-answer {
  margin-top: 16px; padding: 16px; background: var(--bg); border-radius: 14px;
  font-size: 0.86rem; line-height: 1.55; font-weight: 500; white-space: pre-wrap;
}
.ask-answer .steps-note { margin-top: 10px; font-size: 0.72rem; color: var(--muted); font-weight: 600; }

/* ============================================================
   AGENT CONSOLE — dark crimson "cooking" screen
   ============================================================ */
#state-progress {
  position: relative; overflow: hidden;
  margin: -22px; padding: 26px 22px 22px;
  border-radius: 22px; color: #fff;
  background: linear-gradient(168deg, #170409 0%, #2B0712 48%, #4A0D1E 100%);
  background-size: 130% 130%;
  animation: cook-bg 6s ease-in-out infinite alternate;
}
@keyframes cook-bg { from { background-position: 0% 0%; } to { background-position: 100% 100%; } }
#state-progress::before {
  content: ""; position: absolute; top: -120px; right: -120px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 61, 96, 0.35), transparent 65%);
  animation: glow-float 5s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes glow-float {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(-40px, 30px) scale(1.25); }
}

.cook-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; position: relative; }
.cook-head h2 { color: #fff; margin-bottom: 2px; }
.cook-line {
  color: rgba(255, 255, 255, 0.65); font-size: 0.8rem; font-weight: 600;
  min-height: 1.2em; transition: opacity 0.3s;
}
.cook-dots i { font-style: normal; animation: dot-blink 1.4s infinite; }
.cook-dots i:nth-child(2) { animation-delay: 0.2s; }
.cook-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* the AI orb */
.ai-orb {
  position: relative; width: 54px; height: 54px; flex: none;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, #FF5C7C, var(--crimson) 55%, #6E0A1F);
  box-shadow: 0 0 26px rgba(255, 61, 96, 0.55), inset 0 2px 6px rgba(255,255,255,0.35);
  animation: orb-breathe 2.6s ease-in-out infinite;
}
.ai-orb .lucide { stroke: #fff; width: 22px; height: 22px; }
@keyframes orb-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 18px rgba(255, 61, 96, 0.45), inset 0 2px 6px rgba(255,255,255,0.35); }
  50% { transform: scale(1.07); box-shadow: 0 0 34px rgba(255, 61, 96, 0.75), inset 0 2px 6px rgba(255,255,255,0.35); }
}
.orb-ring {
  position: absolute; inset: -7px; border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #FF6B86; border-right-color: rgba(255, 107, 134, 0.3);
  animation: spin 1.6s linear infinite;
}

/* gradient progress bar */
.cook-bar {
  height: 7px; border-radius: 4px; overflow: hidden;
  background: rgba(255, 255, 255, 0.10); margin-bottom: 16px;
}
#cook-bar-fill {
  display: block; height: 100%; width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, #FF8FA3, #FF3D60, #FF8FA3);
  background-size: 200% 100%;
  animation: bar-flow 1.6s linear infinite;
  box-shadow: 0 0 12px rgba(255, 61, 96, 0.8);
  transition: width 0.5s ease;
}
@keyframes bar-flow { to { background-position: -200% 0; } }

/* tasks, dark variants */
#state-progress .task { padding: 9px 0; }
#state-progress .task .t-label { color: rgba(255, 255, 255, 0.92); }
#state-progress .task .t-sub { color: rgba(255, 255, 255, 0.45); }
#state-progress .task .t-icon { background: rgba(255, 255, 255, 0.08); }
#state-progress .task .t-icon .lucide { stroke: rgba(255, 255, 255, 0.55); }
#state-progress .task.wait { opacity: 0.35; }
#state-progress .task.busy .t-icon {
  background: rgba(255, 61, 96, 0.22);
  box-shadow: 0 0 14px rgba(255, 61, 96, 0.5);
}
#state-progress .task.busy .t-icon .lucide { stroke: #FF6B86; animation: busy-pulse 1.1s ease-in-out infinite; }
@keyframes busy-pulse {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50% { transform: scale(1.2); opacity: 1; }
}
#state-progress .task.busy .t-label { color: #fff; }
#state-progress .task.done { animation: task-pop 0.3s ease; }
#state-progress .task.done .t-icon { background: rgba(52, 211, 153, 0.18); }
#state-progress .task.done .t-icon .lucide { stroke: #34D399; animation: none; }
@keyframes task-pop { from { transform: translateX(-6px); opacity: 0.4; } to { transform: none; opacity: 1; } }

#state-progress .error-box {
  background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 107, 134, 0.4);
  color: #FFB3C0;
}
#state-progress .error-box .lucide { stroke: #FF6B86; }
#state-progress .btn-ghost { color: rgba(255, 255, 255, 0.65); }
#state-progress .btn-ghost:hover { color: #fff; }

/* ============ micro-animations ============ */
.pin-marker { animation: pin-drop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
@keyframes pin-drop {
  from { transform: translateY(-18px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.factor { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.factor:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.state.show { animation: rise-in 0.32s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============ route context pill (over the map) ============ */
.route-pill {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 950; display: flex; align-items: center; gap: 8px;
  background: var(--white); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; max-width: 46vw;
  box-shadow: var(--shadow-card); animation: rise-in 0.3s ease;
}
.route-pill .lucide { width: 14px; height: 14px; stroke: var(--crimson); }
.route-pill span { max-width: 40vw; }

/* verdict actions */
.verdict-actions { display: flex; gap: 10px; margin-top: 16px; }
.verdict-actions .btn-3d { padding: 13px; font-size: 0.85rem; }
.btn-recheck {
  background: linear-gradient(135deg, #FF3D60 0%, #A60D2E 100%);
}

/* ============ time presets ============ */
.preset-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.preset {
  border: 1.5px solid var(--line); background: var(--white);
  border-radius: 999px; padding: 8px 14px; cursor: pointer;
  font-family: inherit; font-size: 0.76rem; font-weight: 700; color: var(--muted);
  transition: all 0.15s ease;
}
.preset:hover { border-color: var(--crimson); color: var(--crimson); }
.preset.on {
  background: linear-gradient(135deg, #FFF6F8, #FDEDF1);
  border-color: var(--crimson); color: var(--crimson);
}

/* secondary 3D button (dark) */
.btn-secondary {
  margin-top: 14px;
  background: linear-gradient(135deg, #2A0A14 0%, var(--ink) 70%);
  box-shadow: 0 5px 0 #07080A, 0 12px 22px rgba(22, 24, 29, 0.3);
}
.btn-secondary:active { box-shadow: 0 1px 0 #07080A, 0 5px 10px rgba(22, 24, 29, 0.3); }

/* loading state on 3D buttons */
.btn-3d.loading { pointer-events: none; opacity: 0.85; }
.btn-3d.loading .lucide { animation: spin 0.9s linear infinite; }

/* truncation helpers */
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .chip-label {
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============ map controls ============ */
.leaflet-bar { border: none !important; box-shadow: var(--shadow-card) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-bar a {
  width: 36px !important; height: 36px !important; line-height: 36px !important;
  color: var(--ink) !important; font-weight: 700;
}
.map-fit-btn {
  width: 36px; height: 36px; border: none; border-radius: 12px;
  background: var(--white); cursor: pointer;
  box-shadow: var(--shadow-card);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; color: var(--ink);
}
.map-fit-btn:hover { color: var(--crimson); }

/* ============================================================
   ASK SAARTHI — chat UI
   ============================================================ */
.chat-card {
  display: flex; flex-direction: column;
  height: min(680px, 84vh); padding: 0; overflow: hidden;
}
.chat-card .modal-head {
  padding: 18px 20px 14px; margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}
.chat-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FF5C7C, var(--crimson) 60%, #6E0A1F);
  box-shadow: 0 0 12px rgba(255, 61, 96, 0.4);
}
.chat-avatar .lucide { stroke: #fff; width: 15px; height: 15px; }

.chat-log {
  flex: 1; overflow-y: auto; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--bg); scrollbar-width: thin;
}

.chat-empty { text-align: center; margin: auto; color: var(--muted); }
.chat-empty p { font-size: 0.85rem; font-weight: 600; line-height: 1.5; margin: 12px 0 18px; }
.chat-empty-orb {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, #FF5C7C, var(--crimson) 60%, #6E0A1F);
  box-shadow: 0 0 24px rgba(255, 61, 96, 0.4);
  animation: orb-breathe 2.6s ease-in-out infinite;
}
.chat-empty-orb .lucide { stroke: #fff; width: 22px; height: 22px; }
.chat-suggests { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.suggest-chip {
  border: 1.5px solid var(--line); background: var(--white);
  border-radius: 999px; padding: 9px 16px; cursor: pointer;
  font-family: inherit; font-size: 0.8rem; font-weight: 600; color: var(--ink);
  transition: all 0.15s ease;
}
.suggest-chip:hover { border-color: var(--crimson); color: var(--crimson); transform: translateY(-1px); }

/* bubbles */
.msg { display: flex; gap: 9px; max-width: 88%; animation: rise-in 0.25s ease; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .bubble {
  padding: 11px 15px; border-radius: 16px;
  font-size: 0.86rem; line-height: 1.5; font-weight: 500;
}
.msg.user .bubble {
  background: linear-gradient(135deg, #FF3D60, var(--crimson-dark));
  color: #fff; border-bottom-right-radius: 5px;
  box-shadow: 0 4px 14px rgba(220, 20, 60, 0.3);
}
.msg.bot .bubble {
  background: var(--white); border: 1px solid var(--line);
  border-bottom-left-radius: 5px; box-shadow: var(--shadow-card);
}
.msg.bot .chat-avatar { flex: none; margin-top: 2px; }
.bubble p { margin: 0 0 6px; } .bubble p:last-child { margin: 0; }
.bubble ul { margin: 4px 0 6px 18px; }
.bubble li { margin-bottom: 3px; }
.bubble code {
  background: var(--bg); padding: 1px 6px; border-radius: 5px;
  font-size: 0.8em; color: var(--crimson-dark);
}
.bubble .provider-tag { margin-top: 8px; font-size: 0.68rem; color: var(--muted); font-weight: 600; }

/* tool chips streaming inside the thread */
.tool-feed { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--crimson-soft); color: var(--crimson-dark);
  border-radius: 999px; padding: 5px 11px;
  font-size: 0.7rem; font-weight: 700;
  animation: rise-in 0.25s ease;
}
.tool-chip .lucide { width: 12px; height: 12px; stroke: var(--crimson); }
.tool-chip.running .lucide { animation: spin 1s linear infinite; }

/* typing indicator */
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--crimson); opacity: 0.4;
  animation: typing-bounce 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: none; opacity: 0.35; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* input row pinned at the bottom */
.chat-card .ask-row {
  margin: 0; padding: 14px 16px;
  border-top: 1px solid var(--line); background: var(--white);
}
.ask-row button {
  width: 46px; display: flex; align-items: center; justify-content: center;
}
.ask-row button .lucide { stroke: #fff; width: 18px; height: 18px; }

/* curve bar grow-in (widths set via CSS var by JS) */
.curve-row .c-bar { width: 0; transition: width 0.7s cubic-bezier(0.2, 0.8, 0.3, 1); }
.curve-row.grown .c-bar { width: var(--w); }
.factor { animation: rise-in 0.3s ease both; }

/* ============ mobile: panel becomes bottom sheet ============ */
@media (max-width: 820px) {
  .panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; max-height: 60vh;
    border-radius: 26px 26px 0 0;
    box-shadow: 0 -12px 40px rgba(22, 24, 29, 0.18);
  }
  .panel.snapping { transition: max-height 0.28s cubic-bezier(0.2, 0.8, 0.3, 1); }
  .panel.dragging { transition: none; }
  .grab {
    display: block; position: sticky; top: 0; z-index: 5;
    /* bigger invisible hit area for dragging */
    padding: 10px 0 8px; margin: 0 auto; width: 100%;
    background: linear-gradient(var(--white) 75%, transparent);
    touch-action: none; cursor: grab;
  }
  .grab::after {
    content: ""; display: block; width: 42px; height: 5px;
    border-radius: 3px; background: var(--line); margin: 0 auto;
  }
  .route-pill { display: none; }
  .panel-inner { padding: 14px 18px 26px; }
  .topbar { padding: 12px 14px; }
  .logo { padding: 9px 14px; font-size: 0.92rem; }
  .ask-pill { padding: 9px 14px; font-size: 0.78rem; }
  .toast-warn { max-width: calc(100vw - 28px); top: 64px; }
  .leave-block .lb-time { font-size: 1.8rem; }
  .gauge-wrap svg { width: 150px; }
  #state-progress { margin: -14px -18px -26px; padding: 22px 18px 28px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .chat-card { height: 92vh; max-width: 100%; border-radius: 22px 22px 0 0; }
}
