:root {
  --ink: #1c1917;
  --muted: #57534e;
  --line: #e7e5e4;
  --panel: #f7f5f2;
  --paper: #fffdfb;
  --a: #1d4ed8;
  --b: #dc2626;
  --home: #3f6212;
  --shadow: 0 16px 40px rgba(28, 25, 23, 0.08);
  color: var(--ink);
  font-family: "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  min-height: 100%;
  background: var(--panel);
}

button, input, select { font: inherit; color: inherit; }

.panel {
  width: min(460px, 100%);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 20px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--home);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 650;
}

.lede {
  margin: 8px 0 0;
  color: var(--muted);
}

.search {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
}

.search input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d6d3d1;
  border-radius: 10px;
  background: #fff;
}

.search input:focus,
.mode:focus-visible,
.tab:focus-visible,
.reset:focus-visible,
.add-dest:focus-visible,
.dest-remove:focus-visible,
.dest-name:focus-visible {
  outline: 2px solid var(--a);
  outline-offset: 2px;
}

.places,
.destination-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dest-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}

.dest-card.is-active {
  border-color: #1c1917;
  box-shadow: inset 0 0 0 1px #1c1917;
}

.dest-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.dest-select {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.dest-name {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: text;
}

.dest-remove {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #d6d3d1;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.dest-remove:hover { color: var(--ink); }

.route-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.route-toggles label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
}

.route-toggles input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--ink);
}

.add-dest {
  width: 100%;
  padding: 10px 12px;
  border: 1px dashed #d6d3d1;
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}

.add-dest:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.mode {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}

.mode.is-active {
  border-color: #1c1917;
  box-shadow: inset 0 0 0 1px #1c1917;
}

.mode-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mode-copy strong { font-size: 14px; }

.mode-copy small, .meta, .results-kicker, .status {
  color: var(--muted);
}

.mode-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 750;
}

.swatch-home { background: var(--home); }

h2 .swatch {
  width: 22px;
  height: 22px;
  margin-right: 6px;
  font-size: 11px;
  vertical-align: -4px;
}

.results {
  padding: 12px;
  border-radius: 14px;
  background: var(--panel);
}

.results-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card {
  padding: 10px;
  border-radius: 12px;
  background: #fff;
}

.card + .card { margin-top: 8px; }

.leg[hidden] { display: none; }

.leg {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  align-items: baseline;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.leg-name {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.line {
  display: inline-block;
  width: 18px;
  height: 4px;
  margin-right: 6px;
  border-radius: 99px;
  vertical-align: 2px;
}

.line { background: currentColor; }

.leg-name, .leg .meta { min-width: 0; }

.leg .time {
  margin: 0;
  font-size: 22px;
  text-align: right;
}

.leg .meta { grid-column: 1; margin: 2px 0 0; }
.leg .maps-link { grid-column: 2; margin: 2px 0 0; text-align: right; }

.card.is-missing .leg,
.card.is-loading .maps-link { display: none; }

.note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.card h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.time {
  margin: 8px 0 0;
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.meta { margin: 6px 0 0; font-size: 13px; }

.card.is-missing .time,
.card.is-error .time { color: var(--muted); font-size: 16px; }

.maps-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--a);
  font-size: 13px;
  font-weight: 650;
}

.total {
  margin: 10px 0 0;
  font-weight: 700;
}

.steps-section { flex: none; }

.step-rows { display: flex; flex-direction: column; gap: 8px; }

.step-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.step-row[hidden] { display: none; }

.step-place { flex: none; padding-top: 3px; }

.step-place .swatch {
  width: 22px;
  height: 22px;
  font-size: 11px;
}

.tabs { display: flex; flex: 1; flex-wrap: wrap; gap: 6px; }

.tab, .reset {
  border: 1px solid #d6d3d1;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.tab { padding: 6px 10px; font-size: 13px; }
.tab.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

.steps {
  max-height: 220px;
  margin-top: 8px;
  overflow: auto;
  font-size: 13px;
}

.steps ol {
  margin: 0;
  padding-left: 1.2rem;
}

.steps li { margin: 6px 0; }

.status { margin: 0; min-height: 2.8em; font-size: 14px; }

.reset {
  align-self: flex-start;
  padding: 8px 14px;
}

.map-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 320px;
}

#map { position: absolute; inset: 0; }

.gm-err-container { display: none !important; }

.pin-name {
  background: #fffdfb;
  padding: 2px 7px;
  border: 1px solid #e7e5e4;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.22);
  white-space: nowrap;
}

.time-label {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 3px 8px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  font: 700 12px/1.2 "Segoe UI", sans-serif;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(28, 25, 23, 0.35);
  pointer-events: none;
}

.map-error {
  position: absolute;
  top: 16px;
  left: 16px;
  width: min(560px, calc(100% - 32px));
  margin: 0;
  padding: 16px 18px;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

@media (max-width: 800px) {
  body { flex-direction: column; }
  .panel {
    width: auto;
    max-height: 48vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .map-wrap { min-height: 52vh; }
}
