:root {
  color-scheme: light;
  --bg: #eef4f3;
  --panel: rgba(255, 255, 255, 0.95);
  --text: #12201f;
  --muted: #667775;
  --primary: #047857;
  --primary-dark: #065f46;
  --border: #d7e2df;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body,
.shell,
#map {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
}

.panel {
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  padding: 18px;
  background: linear-gradient(180deg, rgba(239, 250, 247, 0.98), rgba(232, 241, 239, 0.98));
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, #059669, #2563eb);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
}

h2,
summary {
  font-size: 1rem;
  font-weight: 750;
}

.brand p,
.hint,
.results-empty {
  color: var(--muted);
}

.card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
}

details.card {
  display: block;
}

details.card > *:not(summary) {
  margin-top: 12px;
}

summary {
  cursor: pointer;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: white;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.12);
}

button {
  min-height: 42px;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  color: var(--primary-dark);
  font-weight: 750;
  background: #d9f5ec;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.98);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

.split {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.triple {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 650;
}

.toggle input {
  width: auto;
  min-height: auto;
}

.route-results {
  min-height: 140px;
}

.route-card {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: white;
}

.route-card + .route-card {
  margin-top: 10px;
}

.route-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.12);
}

.route-card div {
  display: grid;
  gap: 4px;
}

.route-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  color: #b91c1c;
}

.map-wrap {
  position: relative;
  min-width: 0;
}

.map-status {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 450;
  max-width: min(520px, calc(100% - 36px));
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.leaflet-popup-content {
  line-height: 1.45;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .panel {
    max-height: 52vh;
  }

  .map-wrap {
    min-height: 48vh;
  }
}

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

  .triple {
    grid-template-columns: 1fr;
  }
}
