:root {
  --brand: #003c5b;
  --brand-dark: #002a41;
  --active: #2563eb;
  --active-soft: #e7f0ff;
  --surface: #ffffff;
  --surface-muted: #f6f8fb;
  --surface-subtle: #eef4f8;
  --text: #111827;
  --text-soft: #4b5563;
  --text-muted: #6b7280;
  --border: #d9e1e8;
  --border-strong: #b8c5d1;
  --accent-green: #13795b;
  --accent-gold: #9a6700;
  --accent-rose: #b42318;
  --accent-coral: #c2410c;
  --route: #c2410c;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  background: var(--surface-muted);
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button {
  cursor: pointer;
  font: inherit;
  letter-spacing: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 800;
}

.eyebrow,
.section-label {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  margin-bottom: 2px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.1;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.header-link {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  padding: 8px 12px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.header-link:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.26);
  outline-offset: 2px;
}

.roadtrip-workspace {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(300px, 36vh);
  height: calc(100vh - 76px);
  min-height: 680px;
  overflow: hidden;
}

.trip-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  min-height: 0;
}

.trip-panel {
  z-index: 5;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 18px;
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.08);
}

.panel-heading,
.dock-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-label {
  color: var(--accent-green);
}

.panel-heading h2,
.dock-header h2,
.resource-summary h3 {
  margin: 4px 0 0;
  color: var(--brand);
  line-height: 1.15;
}

.panel-heading h2 {
  font-size: 26px;
}

.dock-header h2 {
  font-size: 22px;
}

.api-status {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.api-status.is-loading {
  border-color: rgba(37, 99, 235, 0.3);
  background: var(--active-soft);
  color: var(--active);
}

.api-status.is-error {
  border-color: rgba(180, 35, 24, 0.32);
  background: #fff1f0;
  color: var(--accent-rose);
}

.trip-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.trip-stats div {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 11px;
}

.trip-stats dt {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.trip-stats dd {
  margin: 3px 0 0;
  color: var(--brand-dark);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
}

.campus-detail {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
  padding: 12px;
}

.campus-place {
  margin: 0;
  color: var(--text);
  font-weight: 800;
}

.campus-provider {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 14px;
}

.trip-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 13px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
}

.button-primary {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #ffffff;
}

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

.button-secondary {
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text);
}

.button-secondary:hover,
.icon-button:hover {
  border-color: var(--active);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.stop-list {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.stop-button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 8px;
  color: var(--text);
  text-align: left;
}

.stop-button:hover {
  border-color: var(--border);
  background: var(--surface-muted);
}

.stop-button.active {
  border-color: rgba(194, 65, 12, 0.38);
  background: #fff7ed;
}

.stop-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

.stop-button.active .stop-index {
  background: var(--accent-coral);
  color: #ffffff;
}

.stop-name {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.stop-place {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.api-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 10px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
}

.api-chip code {
  min-width: 0;
  overflow: hidden;
  color: var(--brand-dark);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

#map {
  width: 100%;
  height: 100%;
  min-height: 390px;
}

.map-overlay {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(620px, calc(100% - 36px));
  border: 1px solid rgba(0, 60, 91, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  padding: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

.map-overlay span {
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--surface-subtle);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.campus-marker {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.28);
  font-size: 12px;
  font-weight: 900;
}

.campus-marker.is-active {
  background: var(--accent-coral);
}

.finish-marker {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--accent-green);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.28);
  font-size: 13px;
  font-weight: 900;
}

.campus-tooltip {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
  color: var(--text);
  font-weight: 800;
}

.map-dock {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 14px clamp(16px, 3vw, 28px);
}

.viewer-tools {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.dock-body {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.viewer-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #dce5eb;
  cursor: grab;
}

.viewer-stage.is-dragging {
  cursor: grabbing;
}

.viewer-image {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  max-width: none;
  max-height: none;
  width: min(92%, 760px);
  transform: translate(-50%, -50%) translate(0, 0) scale(1);
  transform-origin: center;
  user-select: none;
  -webkit-user-drag: none;
}

.viewer-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 20px;
  color: var(--text-soft);
  text-align: center;
}

.viewer-empty[hidden] {
  display: none;
}

.viewer-empty svg {
  width: 34px;
  height: 34px;
  color: var(--brand);
}

.viewer-empty p {
  margin: 0;
  font-weight: 800;
}

.resource-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  gap: 10px;
}

.resource-summary {
  min-width: 0;
}

.resource-summary h3 {
  font-size: 18px;
}

.resource-summary p {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 14px;
}

.resource-strip {
  display: grid;
  grid-auto-columns: minmax(190px, 240px);
  grid-auto-flow: column;
  gap: 10px;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 3px;
}

.resource-button {
  display: grid;
  grid-template-rows: 118px minmax(0, auto);
  min-width: 0;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 0;
  color: var(--text);
  text-align: left;
  overflow: hidden;
}

.resource-button:hover {
  border-color: var(--border-strong);
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.1);
}

.resource-button.active {
  border-color: rgba(194, 65, 12, 0.55);
  box-shadow: inset 0 0 0 2px rgba(194, 65, 12, 0.18);
}

.resource-button img {
  width: 100%;
  height: 118px;
  background: var(--surface-subtle);
  object-fit: cover;
}

.resource-body {
  min-width: 0;
  padding: 9px;
}

.resource-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.resource-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.resource-meta span {
  border-radius: 999px;
  background: var(--surface-subtle);
  padding: 3px 7px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 800;
}

.empty-strip {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  color: var(--text-soft);
  font-weight: 800;
  text-align: center;
}

@media (max-width: 1100px) {
  .roadtrip-workspace {
    height: auto;
    grid-template-rows: auto auto;
    overflow: visible;
  }

  .trip-shell {
    grid-template-columns: 1fr;
  }

  .trip-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
  }

  .stop-list {
    grid-auto-columns: minmax(210px, 260px);
    grid-auto-flow: column;
    overflow-x: auto;
    overflow-y: hidden;
  }

  #map {
    height: 430px;
  }

  .dock-body {
    grid-template-columns: 1fr;
  }

  .viewer-stage {
    height: 260px;
  }
}

@media (max-width: 720px) {
  .app-header,
  .panel-heading,
  .dock-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .trip-stats {
    grid-template-columns: 1fr;
  }

  .trip-controls {
    grid-template-columns: 1fr;
  }

  .viewer-tools {
    justify-content: flex-start;
  }

  .viewer-tools .button {
    width: 100%;
  }

  #map {
    height: 360px;
  }

  .resource-strip {
    grid-auto-columns: minmax(176px, 220px);
  }
}
