@import url("https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700&family=Domine:wght@600;700&display=swap");

:root {
  --bg-top: #edf4ef;
  --bg-bottom: #d9e8ee;
  --panel-bg: rgba(255, 255, 255, 0.9);
  --panel-border: #cfdce5;
  --panel-shadow: rgba(31, 48, 70, 0.17);
  --text-primary: #0b2538;
  --text-secondary: #4e6170;
  --accent: #bf6d17;
  --accent-dark: #915111;
  --trip-default: #2f658d;
  --trip-selected: #d17b1e;
  --network-default: #5f7285;
  --warning-bg: #fff1e8;
  --warning-text: #8d4e18;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Barlow", sans-serif;
  color: var(--text-primary);
  background: linear-gradient(170deg, var(--bg-top), var(--bg-bottom));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 8% 18%, rgba(52, 107, 142, 0.18) 0%, transparent 42%),
    radial-gradient(circle at 86% 85%, rgba(191, 109, 23, 0.16) 0%, transparent 34%);
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100svh;
  height: auto;
  gap: 14px;
  padding: 14px;
}

.sidebar {
  width: min(390px, 40vw);
  min-width: 300px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel-bg);
  box-shadow: 0 16px 34px var(--panel-shadow);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 18px 18px 10px;
  border-bottom: 1px solid #e2ebf1;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5f7080;
  font-weight: 700;
  font-size: 0.72rem;
}

.sidebar-header h1 {
  font-family: "Domine", serif;
  font-size: 1.45rem;
  margin: 0.2rem 0 0.4rem;
  line-height: 1.25;
}

.sidebar-copy {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.35;
}

.warnings {
  display: none;
  margin: 10px 14px 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 0.86rem;
  line-height: 1.35;
}

.warnings.visible {
  display: block;
}

.trip-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}

.trip-toolbar h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #425262;
}

.trip-toolbar button {
  border: 1px solid #d7a26a;
  color: var(--accent-dark);
  background: #fff8f1;
  border-radius: 999px;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: 120ms ease;
}

.trip-toolbar button:disabled {
  opacity: 0.5;
  cursor: default;
}

.trip-toolbar button:not(:disabled):hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.trip-list {
  list-style: none;
  margin: 0;
  padding: 0 10px 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 140px;
}

.trip-item button {
  width: 100%;
  text-align: left;
  border: 1px solid #dce4ea;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px 11px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: 140ms ease;
}

.trip-item button:hover {
  border-color: #90a6b9;
}

.trip-item button.is-selected {
  border-color: #d39a5e;
  background: #fff3e7;
  box-shadow: inset 0 0 0 1px rgba(191, 109, 23, 0.2);
}

.trip-name {
  display: block;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.trip-meta {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-secondary);
  font-size: 0.84rem;
}

.trip-item-note {
  margin: 0.5rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px dashed rgba(47, 101, 141, 0.28);
  color: #223748;
  font-size: 0.88rem;
  line-height: 1.35;
  white-space: pre-line;
}

.trip-select-wrap {
  display: none;
  padding: 0 12px 10px;
}

.trip-select {
  width: 100%;
  border: 1px solid #dce4ea;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px 11px;
  color: var(--text-primary);
  font-family: "Barlow", sans-serif;
  font-size: 0.98rem;
  font-weight: 600;
}

.trip-select:focus {
  outline: 2px solid rgba(47, 101, 141, 0.25);
  border-color: #90a6b9;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.trip-details {
  border-top: 1px solid #e2ebf1;
  background: rgba(246, 250, 252, 0.88);
  padding: 12px 15px 14px;
  min-height: 120px;
  max-height: 36vh;
  overflow-y: auto;
}

.trip-details h3 {
  margin: 0;
  font-size: 1.05rem;
}

.trip-details p {
  margin: 0.35rem 0 0;
  color: var(--text-secondary);
}

.trip-details ol {
  margin: 0.7rem 0 0;
  padding-left: 1.1rem;
}

.trip-details li {
  margin: 0.32rem 0;
  color: var(--text-primary);
}

.hint {
  margin: 0;
  color: var(--text-secondary);
}

.map-panel {
  flex: 1;
  min-width: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  box-shadow: 0 16px 34px var(--panel-shadow);
  display: flex;
}

#map {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 320px;
}

.trip-segment-line {
  cursor: pointer;
}

.trip-notes-mobile {
  display: none;
}

.trip-notes-mobile h3 {
  margin: 0;
  font-size: 1rem;
}

.trip-notes-mobile p {
  margin: 0.45rem 0 0;
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.35;
  white-space: pre-line;
}

.leaflet-tooltip.trip-label {
  border: 1px solid rgba(21, 45, 64, 0.18);
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.97);
  color: #143650;
  font-family: "Barlow", sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  max-width: 260px;
  white-space: nowrap;
  line-height: 1.2;
  text-align: center;
}

.leaflet-tooltip.trip-label::before {
  display: none;
}

@media (max-width: 1024px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
  }

  .sidebar {
    width: min(350px, 43vw);
    min-width: 280px;
  }
}

@media (max-width: 860px) {
  .app-shell {
    flex-direction: column;
    min-height: 100svh;
    height: auto;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    min-height: 0;
  }

  .trip-list {
    display: none;
  }

  .trip-select-wrap {
    display: block;
  }

  .map-panel {
    height: 56svh;
    min-height: 56svh;
  }

  .trip-notes-mobile {
    display: block;
    order: 2;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 24px var(--panel-shadow);
    padding: 11px 12px;
  }

  .map-panel {
    order: 3;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  .sidebar {
    border-radius: 14px;
  }

  .sidebar-header {
    padding: 14px 14px 8px;
  }

  .sidebar-header h1 {
    font-size: 1.15rem;
  }

  .sidebar-copy {
    font-size: 0.86rem;
  }

  .trip-toolbar {
    padding: 10px 12px 8px;
  }

  .trip-list {
    min-height: 110px;
    padding: 0 8px 6px;
  }

  .trip-item button {
    padding: 8px 9px;
    margin-bottom: 6px;
  }

  .trip-name {
    font-size: 0.94rem;
  }

  .trip-meta {
    font-size: 0.8rem;
  }

  .trip-item-note {
    font-size: 0.8rem;
    margin-top: 0.42rem;
  }

  .trip-select-wrap {
    padding: 0 10px 8px;
  }

  .trip-select {
    font-size: 0.9rem;
    padding: 9px 10px;
  }

  .trip-details {
    padding: 10px 12px 12px;
    max-height: 28vh;
    min-height: 0;
  }

  .trip-details li {
    margin: 0.24rem 0;
    line-height: 1.25;
  }

  .map-panel {
    border-radius: 14px;
    height: 58svh;
    min-height: 58svh;
  }

  .leaflet-tooltip.trip-label {
    font-size: 0.66rem;
    max-width: 180px;
    white-space: normal;
    line-height: 1.15;
  }

  .trip-notes-mobile {
    padding: 10px 11px;
  }

  .trip-notes-mobile h3 {
    font-size: 0.93rem;
  }

  .trip-notes-mobile p {
    font-size: 0.84rem;
  }
}

@media (min-width: 861px) {
  .app-shell {
    height: 100%;
  }
}
