* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: #0f1115;
  color: #e6e8ef;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 12px 16px;
  background: #15181f;
  border-bottom: 1px solid #232732;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
header h1 { margin: 0; font-size: 1.05rem; font-weight: 600; letter-spacing: 0.3px; }
header .build { font-size: 0.7rem; color: #5a6377; font-family: ui-monospace, monospace; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

#route-form { display: flex; flex-direction: column; gap: 10px; }

.field-row { display: flex; gap: 6px; align-items: stretch; }
.field-row .field { flex: 1; min-width: 0; }
.field-row .icon-btn {
  align-self: flex-end;
  width: 44px; height: 44px;
  padding: 0; font-size: 1.15rem;
  background: #1a1d27; color: #b8c0d0;
  border: 1px solid #2a2f3d; border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.field-row .icon-btn:hover { background: #232732; color: #fff; }
.field-row .icon-btn.busy { opacity: 0.5; cursor: progress; }

.swap-btn {
  align-self: center;
  background: transparent;
  border: 1px dashed #2a2f3d;
  color: #8a93a6;
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.3px;
}
.swap-btn:hover { color: #fff; border-color: #4f8cff; border-style: solid; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span {
  font-size: 0.7rem; color: #8a93a6;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.field input {
  padding: 11px 12px; font-size: 1rem;
  background: #1a1d27; color: #e6e8ef;
  border: 1px solid #2a2f3d; border-radius: 8px;
  outline: none; -webkit-appearance: none;
}
.field input:focus { border-color: #4f8cff; }

.seg {
  border: 1px solid #2a2f3d; border-radius: 8px; padding: 6px;
  margin: 0; display: grid; gap: 4px;
}
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg legend {
  font-size: 0.7rem; color: #8a93a6;
  padding: 0 4px; text-transform: uppercase; letter-spacing: 0.6px;
}
.seg label {
  position: relative; display: flex; align-items: center; justify-content: center;
  padding: 9px 4px; font-size: 0.85rem; color: #b8c0d0;
  background: #1a1d27; border-radius: 6px; cursor: pointer; text-align: center;
}
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: #2c5be0; color: #fff; }

.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.9rem; color: #b8c0d0; user-select: none; cursor: pointer;
}
.check input { width: 16px; height: 16px; }

button#go-btn {
  padding: 13px; font-size: 1rem; font-weight: 600;
  border: none; border-radius: 8px;
  background: #2ec27e; color: #0f1115; cursor: pointer;
}
button#go-btn:hover { background: #3ed28e; }
button#go-btn:disabled { background: #3b4150; color: #8a93a6; cursor: progress; }

#results {
  background: #15181f; border: 1px solid #232732; border-radius: 8px;
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
#results .summary {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline;
  color: #fff;
}
#results .summary .total { font-size: 1.4rem; font-weight: 700; }
#results .summary .sub { font-size: 0.85rem; color: #8a93a6; font-weight: 400; }
#results .summary .compare { flex-basis: 100%; font-size: 0.8rem; color: #8a93a6; }

#results .by-mode { display: flex; flex-wrap: wrap; gap: 6px; }
#results .by-mode .chip {
  font-size: 0.78rem; font-weight: 600;
  padding: 3px 8px; border-radius: 4px;
  background: #1a1d27; border: 1px solid #2a2f3d; color: #c8cedb;
}
#results .by-mode .chip-scooter { border-color: #2ec27e; color: #2ec27e; }
#results .by-mode .chip-transit { border-color: #4f8cff; color: #4f8cff; }
#results .by-mode .chip-walking { border-color: #8a93a6; color: #8a93a6; }

#results .actions { display: flex; flex-wrap: wrap; gap: 6px; }
#results .actions a {
  display: inline-block; padding: 6px 10px;
  background: #1a1d27; border: 1px solid #2a2f3d; border-radius: 6px;
  font-size: 0.8rem; color: #b8c0d0; text-decoration: none;
}
#results .actions a:hover { background: #232732; color: #fff; }

#results .steps {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 0.88rem; color: #c8cedb;
}
#results .steps li {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 6px 8px; background: #1a1d27;
  border-radius: 6px; border-left: 3px solid #2a2f3d;
}
#results .steps li.scooter { border-left-color: #2ec27e; }
#results .steps li.transit { border-left-color: #4f8cff; }
#results .steps li.walking { border-left-color: #8a93a6; }
#results .steps .tag {
  flex: 0 0 auto; font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 6px; border-radius: 3px;
  background: #2a2f3d; color: #b8c0d0;
}
#results .steps li.scooter .tag { background: #2ec27e; color: #0f1115; }
#results .steps li.transit .tag { background: #4f8cff; color: #fff; }
#results .steps li.walking .tag { background: #8a93a6; color: #0f1115; }
#results .steps .desc { flex: 1; min-width: 0; word-wrap: break-word; }
#results .steps .meta { color: #8a93a6; font-size: 0.78rem; margin-top: 2px; }

.error {
  color: #ff9e9e; background: #2a1a1a;
  border: 1px solid #4a2a2a; padding: 10px;
  border-radius: 6px; font-size: 0.9rem;
}

#map {
  flex: 1; min-height: 360px;
  border-radius: 8px; overflow: hidden;
  border: 1px solid #232732;
}

@media (min-width: 900px) {
  main {
    display: grid;
    grid-template-columns: 360px 1fr;
    grid-template-rows: auto 1fr;
    gap: 12px;
    height: calc(100vh - 56px);
    overflow: hidden;
  }
  #route-form { grid-column: 1; grid-row: 1; }
  #results { grid-column: 1; grid-row: 2; overflow-y: auto; }
  #map { grid-column: 2; grid-row: 1 / 3; }
}
