:root {
  --blue: #1a73e8;
  --blue-dark: #1558b0;
  --green: #188038;
  --yellow: #fbbc04;
  --red: #d93025;
  --ink: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --panel: #fff;
  --land: #eef3ea;
  --road: #fff7df;
  --water: #cfe9f7;
  --shadow: 0 2px 9px rgba(60, 64, 67, .18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: #f8fafd;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input {
  font: inherit;
}

.appbar {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--blue);
  border-radius: 7px;
  font-weight: 800;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 14px;
}

.shell {
  min-height: 100vh;
  padding-top: 56px;
  display: grid;
  grid-template-columns: 380px 1fr;
}

.sidebar {
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 3px 0 12px rgba(60, 64, 67, .08);
}

.sidebar-head h1,
.action-header h1,
.state-page h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

.sidebar-head p,
.action-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.directions-form,
.action-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, .16);
}

.primary-button,
.secondary-button {
  height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  color: #fff;
  background: var(--blue);
}

.primary-button:hover {
  background: var(--blue-dark);
}

.secondary-button {
  color: var(--blue);
  background: #fff;
  border-color: var(--line);
}

.route-card,
.action-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.route-card {
  min-height: 174px;
  transition: background-color 1.2s ease, border-color 1.2s ease, box-shadow 1.2s ease;
}

.route-card--updated {
  animation: route-card-flash 1.8s ease-out;
}

@keyframes route-card-flash {
  0% {
    background: #fff8d8;
    border-color: #fbbc04;
    box-shadow: 0 0 0 4px rgba(251, 188, 4, .26), var(--shadow);
  }
  100% {
    background: #fff;
    border-color: var(--line);
    box-shadow: none;
  }
}

.empty-state,
.loading-state,
.route-result {
  padding: 18px;
}

.empty-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  color: var(--blue);
  background: #e8f0fe;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 700;
}

.empty-state h2,
.section-title h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.empty-state p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulse 1s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(.7); opacity: .5; }
  50% { transform: scale(1); opacity: 1; }
}

.route-mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.mode-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #fff;
  background: var(--green);
  border-radius: 50%;
}

.time-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 12px 0 14px;
}

.time-row strong {
  color: var(--green);
  font-size: 34px;
  line-height: 1;
}

.time-row span {
  color: var(--muted);
  font-size: 14px;
}

.route-stops {
  display: grid;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.route-stops div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 14px;
}

.route-stops span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stop-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.stop-dot.start {
  background: var(--blue);
}

.stop-dot.end {
  background: var(--red);
}

.map {
  position: relative;
  min-height: calc(100vh - 56px);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255,255,255,.58) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,.58) 1px, transparent 1px),
    var(--land);
  background-size: 72px 72px;
}

.map-controls {
  position: absolute;
  z-index: 6;
  right: 18px;
  top: 18px;
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.map-controls button {
  width: 42px;
  height: 40px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 22px;
}

.map-controls button:last-child {
  border-bottom: 0;
}

.road {
  position: absolute;
  z-index: 2;
  border-radius: 999px;
  background: var(--road);
  border: 2px solid #e4d7b0;
  box-shadow: inset 0 0 0 2px #fff;
}

.road-main {
  width: 140%;
  height: 52px;
  left: -18%;
  top: 47%;
  transform: rotate(-14deg);
}

.road-east {
  width: 52px;
  height: 130%;
  right: 28%;
  top: -15%;
  transform: rotate(28deg);
}

.road-west {
  width: 46px;
  height: 120%;
  left: 24%;
  top: -10%;
  transform: rotate(-27deg);
}

.road-north {
  width: 90%;
  height: 36px;
  left: 5%;
  top: 24%;
  transform: rotate(8deg);
}

.park,
.water,
.place-label {
  position: absolute;
  z-index: 1;
  color: #47634a;
  font-size: 13px;
  font-weight: 700;
}

.park {
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: #cfe7c8;
}

.park-one {
  width: 210px;
  height: 120px;
  left: 13%;
  top: 12%;
}

.park-two {
  width: 180px;
  height: 100px;
  right: 12%;
  bottom: 18%;
}

.water {
  right: -80px;
  top: 8%;
  width: 260px;
  height: 380px;
  display: grid;
  place-items: center;
  color: #2b6f8f;
  background: var(--water);
  border-radius: 44% 0 0 56%;
}

.place-label {
  z-index: 4;
  padding: 3px 7px;
  color: var(--muted);
  background: rgba(255,255,255,.78);
  border-radius: 5px;
  font-weight: 600;
}

.label-one { left: 42%; top: 35%; }
.label-two { left: 57%; top: 58%; }
.label-three { left: 18%; bottom: 22%; }

.pin {
  position: absolute;
  z-index: 7;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  border-radius: 50% 50% 50% 4px;
  box-shadow: var(--shadow);
  transform: rotate(-45deg);
  font-weight: 800;
}

.pin-start {
  left: 34%;
  top: 45%;
  background: var(--blue);
}

.pin-end {
  left: 66%;
  top: 40%;
  background: var(--red);
}

.pin {
  line-height: 34px;
}

.pin-start,
.pin-end {
  text-indent: 0;
}

.pin-start,
.pin-end {
  color: transparent;
}

.pin-start::after,
.pin-end::after {
  transform: rotate(45deg);
  color: #fff;
}

.pin-start::after { content: "A"; }
.pin-end::after { content: "B"; }

.route-line-map {
  position: absolute;
  z-index: 5;
  left: 36%;
  top: 48%;
  width: 31%;
  height: 8px;
  background: var(--blue);
  border-radius: 999px;
  transform: rotate(-9deg);
  box-shadow: 0 0 0 4px rgba(26, 115, 232, .18);
}

.action-page,
.state-page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 88px 20px 40px;
}

.action-page {
  display: grid;
  gap: 18px;
}

.action-header {
  display: grid;
  gap: 6px;
}

.action-card {
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.action-form {
  grid-template-columns: minmax(180px, 1fr) 160px auto;
  align-items: end;
}

.status-line {
  min-height: 20px;
  margin-top: 12px;
  color: var(--green);
  font-size: 14px;
}

.status-line[data-kind="error"] {
  color: var(--red);
}

.table-wrap {
  overflow-x: auto;
}

.state-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.state-table th,
.state-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.state-table th {
  color: var(--muted);
  background: #f8fafd;
  font-size: 12px;
  text-transform: uppercase;
}

.state-table td:last-child {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafd;
  font-size: 12px;
}

.link-button {
  border: 0;
  padding: 0;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.link-button.danger {
  color: var(--red);
}

.state-page pre {
  margin: 18px 0 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .appbar {
    position: sticky;
  }

  .shell {
    grid-template-columns: 1fr;
    padding-top: 0;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map {
    min-height: 520px;
  }

  .action-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .appbar {
    padding: 0 12px;
  }

  .top-links {
    gap: 10px;
    font-size: 13px;
  }

  .sidebar {
    padding: 16px;
  }

  .time-row {
    display: grid;
    gap: 4px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
