:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff4ff;
  --ink: #111827;
  --ink-soft: #4b5563;
  --grey-1: #f3f4f6;
  --grey-2: #e5e7eb;
  --grey-3: #9ca3af;
  --white: #ffffff;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 8px 30px rgba(17, 24, 39, 0.10), 0 1px 3px rgba(17, 24, 39, 0.06);
  --shadow-pop: 0 12px 40px rgba(17, 24, 39, 0.16);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--grey-1);
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left {
  z-index: 5;
}

.panel-stack {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.search-card {
  pointer-events: auto;
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 14px 16px 16px;
  transition: box-shadow var(--transition);
}

.search-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.search-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 2px;
  width: 14px;
  flex-shrink: 0;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-from {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.dot-to {
  background: #ef4444;
  box-shadow: 0 0 0 3px #fef2f2;
}

.dot-connector {
  flex: 1;
  width: 2px;
  background: var(--grey-2);
  margin: 4px 0;
  min-height: 14px;
}

.search-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--grey-1);
  border-radius: var(--radius-md);
}

.input-wrap {
  position: relative;
}

.input-divider {
  height: 1px;
  background: var(--grey-2);
  margin: 0 12px;
}

.search-inputs input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 12px 64px 12px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
}

.search-inputs input::placeholder {
  color: var(--grey-3);
}

.input-actions {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 2px;
}

.input-action-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--grey-3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.input-action-btn:hover,
.input-action-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.swap-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  align-self: center;
  border: none;
  background: var(--grey-1);
  color: var(--ink-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.swap-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.swap-btn:active {
  transform: scale(0.92);
}

.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  max-height: 240px;
  overflow-y: auto;
  z-index: 20;
}

.suggestions li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--transition);
}

.suggestions li:hover,
.suggestions li.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.suggestions li .item-icon {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--grey-3);
}

.suggestions li .item-icon.icon-address {
  width: 14px;
  height: 14px;
  border-radius: 0;
  background: none;
  color: var(--grey-3);
}

.suggestions li .item-icon.icon-current {
  width: 14px;
  height: 14px;
  border-radius: 0;
  background: none;
  color: var(--accent);
}

.suggestions li .item-icon.icon-postcode {
  width: 14px;
  height: 14px;
  border-radius: 0;
  background: none;
  color: var(--grey-3);
}

.suggestions li .item-icon.icon-favorite {
  width: 14px;
  height: 14px;
  border-radius: 0;
  background: none;
  color: var(--accent);
}

.suggestions li.current-location-item {
  font-weight: 600;
  color: var(--accent);
}

.suggestions li.current-location-item:hover {
  color: var(--accent-dark);
}

.suggestions li .item-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.segmented {
  display: flex;
  background: var(--grey-1);
  border-radius: var(--radius-md);
  padding: 3px;
  flex: 1;
}

.segmented-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink-soft);
  border-radius: calc(var(--radius-md) - 3px);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.segmented-btn.active {
  background: var(--white);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.12);
}

.time-input {
  border: 1px solid var(--grey-2);
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.mode-strip[hidden] {
  display: none;
}

.mode-strip {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.mode-tab[hidden] {
  display: none;
}

.mode-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 6px;
  border: 1.5px solid var(--grey-2);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.mode-tab:hover {
  border-color: var(--accent);
}

.mode-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.mode-tab.unavailable {
  opacity: 0.4;
  cursor: not-allowed;
}

.mode-tab-time {
  line-height: 1;
}

.reset-btn {
  flex-shrink: 0;
  width: 46px;
  border: none;
  background: var(--grey-1);
  color: var(--ink-soft);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.reset-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.reset-btn:active {
  transform: scale(0.92);
}

.settings-wrap {
  position: relative;
  flex-shrink: 0;
}

.settings-popover[hidden] {
  display: none;
}

.settings-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 200px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: 10px 12px;
  z-index: 30;
}

.settings-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--grey-3);
  margin-bottom: 6px;
}

.settings-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 2px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}

.settings-option input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.settings-option-disabled {
  color: var(--grey-3);
  cursor: not-allowed;
}

.settings-option-disabled input {
  cursor: not-allowed;
}

.settings-soon {
  font-size: 11px;
  color: var(--grey-3);
  margin-left: auto;
}

.account-popover {
  width: 260px;
  max-height: 70vh;
  overflow-y: auto;
}

.account-input {
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--grey-2);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--grey-1);
}

.account-input:focus {
  outline: none;
  border-color: var(--accent);
}

.account-error {
  font-size: 12px;
  color: #dc2626;
  margin-bottom: 8px;
}

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

.account-primary-btn,
.account-secondary-btn {
  flex: 1;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.account-primary-btn {
  background: var(--accent);
  color: var(--white);
}

.account-primary-btn:hover {
  background: var(--accent-dark);
}

.account-secondary-btn {
  background: var(--grey-1);
  color: var(--ink);
}

.account-secondary-btn:hover {
  background: var(--grey-2);
}

.account-signed-in-as {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
  word-break: break-all;
}

.account-logout-btn {
  width: 100%;
}

.account-section-title {
  margin-top: 14px;
}

.account-list {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  max-height: 140px;
  overflow-y: auto;
}

.account-list:empty::after {
  content: "None yet";
  display: block;
  font-size: 12px;
  color: var(--grey-3);
  padding: 4px 2px;
}

.account-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
}

.account-list li:hover {
  background: var(--accent-soft);
}

.account-list .account-item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-list .account-item-label {
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.account-list .account-item-remove {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--grey-3);
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.account-list .account-item-remove:hover {
  background: var(--grey-2);
  color: var(--ink);
}

.account-save-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.account-save-btn {
  flex: 1;
  padding: 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--grey-2);
  background: var(--white);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.account-save-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.plan-btn {
  flex: 1;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--white);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.plan-btn:hover {
  background: var(--accent-dark);
}

.plan-btn:active {
  transform: scale(0.985);
}

.plan-btn:disabled {
  background: var(--grey-3);
  cursor: not-allowed;
}

/* Results sheet: bottom drawer on mobile */
.results-sheet[hidden] {
  display: none;
}

.results-sheet {
  pointer-events: auto;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 62vh;
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -8px 30px rgba(17, 24, 39, 0.14);
  display: flex;
  flex-direction: column;
  transform: translateY(0);
  transition: transform var(--transition), opacity var(--transition);
  animation: sheet-in 260ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes sheet-in {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--grey-2);
  margin: 10px auto 2px;
  flex-shrink: 0;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  flex-shrink: 0;
  border-bottom: 1px solid var(--grey-1);
}

.sheet-close {
  border: none;
  background: var(--grey-1);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.itinerary-list {
  overflow-y: auto;
  padding: 10px 12px 20px;
  -webkit-overflow-scrolling: touch;
}

.itinerary-card {
  border: 1px solid var(--grey-2);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  background: var(--white);
}

.itinerary-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.10);
}

.itinerary-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

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

.card-duration {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.card-times {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
}

.card-modes {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--white);
  background: var(--accent);
}

.mode-arrow {
  color: var(--grey-3);
  font-size: 12px;
}

.mode-walk-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-soft);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--grey-3);
}

.card-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 260ms cubic-bezier(0.4, 0, 0.2, 1), margin-top var(--transition);
}

.itinerary-card.expanded .card-detail {
  max-height: 600px;
  margin-top: 12px;
}

.leg-timeline {
  border-top: 1px dashed var(--grey-2);
  padding-top: 10px;
}

.leg-row {
  display: flex;
  gap: 10px;
  padding: 6px 0;
}

.leg-marker {
  flex-shrink: 0;
  width: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.leg-marker .leg-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  background: var(--grey-3);
  flex-shrink: 0;
}

.leg-body {
  flex: 1;
  font-size: 13px;
  padding-bottom: 2px;
}

.leg-title {
  font-weight: 600;
  color: var(--ink);
}

.leg-sub {
  color: var(--ink-soft);
  margin-top: 1px;
}

.leg-time {
  font-size: 12px;
  color: var(--grey-3);
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
}

.status-toast {
  pointer-events: none;
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  animation: toast-in 200ms ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.map-marker {
  border-radius: 50%;
  box-sizing: border-box;
}

.map-marker-origin {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: 3px solid var(--white);
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.35);
}

.map-marker-dest {
  width: 16px;
  height: 16px;
  background: #ef4444;
  border: 3px solid var(--white);
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.35);
}

.map-marker-transfer {
  width: 11px;
  height: 11px;
  background: var(--white);
  border: 3px solid var(--ink-soft);
  box-shadow: 0 1px 4px rgba(17, 24, 39, 0.3);
}

/* Desktop layout: search card + results as a left column, map fills the rest */
@media (min-width: 760px) {
  .search-card {
    left: 20px;
    right: auto;
    top: 20px;
    width: 400px;
  }

  .results-sheet {
    left: 20px;
    right: auto;
    bottom: 20px;
    top: 216px;
    width: 400px;
    max-height: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
  }

  .sheet-handle {
    display: none;
  }
}
