:root {
  color-scheme: light;
  --harbour-950: #0b252b;
  --harbour-900: #12343b;
  --harbour-800: #1b4650;
  --harbour-100: #dce9e9;
  --paper: #fffefa;
  --sand: #f4f1e8;
  --sand-2: #ebe6d9;
  --ink: #17252a;
  --muted: #63747a;
  --line: #d8ddd8;
  --teal: #087c72;
  --teal-soft: #d9efeb;
  --coral: #b23b33;
  --coral-soft: #f8e2de;
  --amber: #a26a0a;
  --amber-soft: #f7e9c8;
  --blue: #28658c;
  --shadow: 0 18px 48px rgba(11, 37, 43, 0.17);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --display-font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  --body-font: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  --utility-font: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--sand);
  color: var(--ink);
  font-family: var(--body-font);
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(40, 101, 140, 0.45);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 9999;
  top: 10px;
  left: 10px;
  transform: translateY(-150%);
  border-radius: 8px;
  background: var(--harbour-950);
  color: white;
  padding: 10px 14px;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  min-height: 540px;
}

.topbar {
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  gap: 24px;
  padding: 13px 22px 12px;
  border-bottom: 1px solid rgba(11, 37, 43, 0.14);
  background: rgba(255, 254, 250, 0.96);
}

.brand-block {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--teal);
  font-family: var(--utility-font);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.3;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  overflow: hidden;
  margin-bottom: 0;
  font-family: var(--display-font);
  font-size: clamp(1.25rem, 2.2vw, 1.65rem);
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.topbar-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
}

.topbar-meta strong {
  margin-right: 4px;
  color: var(--harbour-900);
}

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

.rail {
  z-index: 5;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid rgba(11, 37, 43, 0.13);
  background: var(--paper);
  scrollbar-width: thin;
  scrollbar-color: #aab9b8 transparent;
}

.route-brief {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 106px;
  gap: 16px;
  margin: 18px 18px 12px;
  padding: 17px 17px 16px;
  border: 1px solid var(--harbour-100);
  border-radius: var(--radius-md);
  background: var(--harbour-900);
  color: white;
}

.route-brief .section-kicker {
  color: #97d7cd;
}

.route-brief h2 {
  margin: 5px 0 3px;
  font-family: var(--display-font);
  font-size: 1rem;
  line-height: 1.25;
}

.route-brief p:last-child {
  margin-bottom: 0;
  color: #c8dadc;
  font-size: 0.78rem;
}

.campus-stamp {
  display: grid;
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  color: #e8f3ef;
  font-family: var(--utility-font);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 18px 13px;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 650;
}

.filter-chip:hover {
  border-color: #91a5a5;
  background: var(--sand);
}

.filter-chip.is-active {
  border-color: var(--harbour-900);
  background: var(--harbour-900);
  color: white;
}

.property-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 14px;
}

.property-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 96px;
  gap: 12px;
  width: 100%;
  padding: 12px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.property-card--fallback {
  color: inherit;
  text-decoration: none;
}

.property-card::after {
  position: absolute;
  right: 12px;
  bottom: -5px;
  left: 62px;
  height: 1px;
  background: #e6e9e4;
  content: "";
}

.property-card:hover {
  border-color: var(--line);
  background: var(--sand);
}

.property-card.is-selected {
  border-color: #a9ceca;
  background: var(--teal-soft);
}

.property-card.is-selected::after {
  display: none;
}

.rank-medallion {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--harbour-900);
  color: white;
  font-family: var(--utility-font);
  font-size: 0.8rem;
  font-weight: 750;
}

.property-card[data-tier="B"] .rank-medallion {
  background: var(--blue);
}

.property-card[data-tier="P"] .rank-medallion {
  background: var(--amber);
}

.card-copy {
  min-width: 0;
}

.card-overline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  color: var(--muted);
  font-family: var(--utility-font);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card-title {
  overflow: hidden;
  margin: 0 0 6px;
  font-family: var(--display-font);
  font-size: 0.92rem;
  line-height: 1.28;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--muted);
  font-size: 0.72rem;
}

.card-facts span {
  position: relative;
}

.card-facts span + span::before {
  position: absolute;
  top: 50%;
  left: -6px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #9aabaa;
  content: "";
}

.card-price {
  align-self: start;
  color: var(--harbour-900);
  font-family: var(--utility-font);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.rail-note {
  margin: 0 18px;
  padding: 16px 0 calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

.map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #dce6e1;
}

#map {
  width: 100%;
  height: 100%;
  background: #dce6e1;
}

.map-error {
  display: grid;
  width: min(420px, calc(100% - 40px));
  min-height: 120px;
  margin: 32px auto;
  place-items: center;
  border: 1px solid #c3d3cf;
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--harbour-900);
  padding: 20px;
  text-align: center;
}

.leaflet-container {
  font-family: var(--body-font);
}

.leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid rgba(11, 37, 43, 0.18) !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 22px rgba(11, 37, 43, 0.12) !important;
}

.leaflet-control-zoom a {
  display: grid !important;
  width: 42px !important;
  height: 42px !important;
  place-items: center;
  color: var(--harbour-900) !important;
  line-height: 1 !important;
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.84) !important;
  color: #52666b !important;
  font-size: 9px !important;
}

.leaflet-control-attribution a {
  color: #275e70 !important;
}

.property-marker {
  display: inline-flex;
  align-items: center;
  min-width: 64px;
  height: 34px;
  gap: 6px;
  padding: 0 9px 0 6px;
  border: 2px solid white;
  border-radius: 13px 13px 13px 3px;
  background: var(--harbour-900);
  box-shadow: 0 7px 17px rgba(11, 37, 43, 0.28);
  color: white;
  font-family: var(--utility-font);
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.property-marker[data-tier="B"] {
  background: var(--blue);
}

.property-marker[data-tier="P"] {
  background: var(--amber);
}

.property-marker.is-selected {
  z-index: 800 !important;
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 11px 24px rgba(11, 37, 43, 0.34);
}

.property-marker__rank {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.2);
}

#map.is-compact-markers .property-marker {
  width: 34px;
  min-width: 34px;
  justify-content: center;
  gap: 0;
  padding: 0;
  border-radius: 13px 13px 13px 3px;
}

#map.is-compact-markers .property-marker__rank {
  width: 22px;
}

#map.is-compact-markers .property-marker > span:last-child {
  display: none;
}

.campus-marker {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 8px 22px rgba(96, 37, 31, 0.28);
  color: white;
  font-family: var(--utility-font);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.map-legend {
  position: absolute;
  z-index: 500;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(11, 37, 43, 0.16);
  border-radius: 999px;
  background: rgba(255, 254, 250, 0.92);
  box-shadow: 0 8px 22px rgba(11, 37, 43, 0.1);
  backdrop-filter: blur(10px);
  color: #41575d;
  font-size: 0.68rem;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--harbour-900);
}

.legend-dot--b {
  background: var(--blue);
}

.legend-dot--pending {
  background: var(--amber);
}

.detail-sheet {
  position: absolute;
  z-index: 1200;
  right: 18px;
  bottom: 18px;
  width: min(430px, calc(100% - 36px));
  max-height: calc(100% - 72px);
  overflow-y: auto;
  padding: 20px;
  border: 1px solid rgba(11, 37, 43, 0.16);
  border-radius: var(--radius-lg);
  background: rgba(255, 254, 250, 0.98);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}

.detail-sheet[hidden] {
  display: none;
}

.detail-close {
  position: sticky;
  z-index: 3;
  top: 0;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--sand);
  cursor: pointer;
  color: var(--harbour-900);
  font-size: 1.65rem;
  line-height: 1;
  margin: -9px -9px -35px auto;
}

.detail-topline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 48px 7px 0;
  color: var(--teal);
  font-family: var(--utility-font);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.detail-title {
  margin: 0 48px 5px 0;
  font-family: var(--display-font);
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  line-height: 1.22;
}

.detail-suburb {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.8rem;
}

.detail-verdict {
  margin: -4px 0 14px;
  padding: 11px 12px;
  border-left: 3px solid var(--teal);
  border-radius: 3px 10px 10px 3px;
  background: var(--teal-soft);
  color: #25474b;
  font-size: 0.76rem;
  font-weight: 620;
  line-height: 1.5;
}

.commute-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid #cbd9d6;
  border-radius: 14px;
  background: #f7fbf9;
}

.commute-board > div {
  padding: 12px 13px;
}

.commute-board > div + div {
  border-left: 1px solid #cbd9d6;
}

.metric-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.65rem;
}

.metric-value {
  color: var(--harbour-900);
  font-family: var(--utility-font);
  font-size: 0.95rem;
  font-weight: 850;
}

.fact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 14px;
}

.fact-item {
  min-height: 58px;
  padding: 9px 10px;
  border-radius: 11px;
  background: var(--sand);
}

.fact-item strong,
.fact-item span {
  display: block;
}

.fact-item span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.63rem;
}

.fact-item strong {
  font-size: 0.75rem;
  line-height: 1.34;
}

.fact-item--warning {
  background: var(--amber-soft);
}

.decision-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.decision-block {
  min-width: 0;
}

.decision-block h3 {
  margin-bottom: 6px;
  font-family: var(--utility-font);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.decision-block--pro h3 {
  color: var(--teal);
}

.decision-block--con h3 {
  color: var(--coral);
}

.decision-block ul {
  margin: 0;
  padding-left: 17px;
  color: #405258;
  font-size: 0.72rem;
  line-height: 1.48;
}

.decision-block li + li {
  margin-top: 3px;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--harbour-900);
  font-size: 0.76rem;
  font-weight: 750;
  text-align: center;
  text-decoration: none;
}

.action-button:hover {
  border-color: #96aaa9;
  background: var(--sand);
}

.action-button--primary {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.action-button--primary:hover {
  border-color: #076d64;
  background: #076d64;
}

.detail-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.45;
}

.noscript {
  position: fixed;
  z-index: 9999;
  inset: 20px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-lg);
  background: var(--paper);
  color: var(--ink);
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100dvh;
  }

  .topbar {
    position: sticky;
    top: 0;
    min-height: 68px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 9px;
    backdrop-filter: blur(14px);
  }

  .eyebrow {
    font-size: 0.58rem;
  }

  h1 {
    font-size: 1.12rem;
  }

  .topbar-meta span:last-child {
    display: none;
  }

  .workspace {
    display: flex;
    min-height: auto;
    flex-direction: column;
  }

  .map-stage {
    order: 1;
    height: min(54svh, 510px);
    min-height: 360px;
    border-bottom: 1px solid rgba(11, 37, 43, 0.14);
  }

  .rail {
    order: 2;
    overflow: visible;
    border-right: 0;
  }

  .route-brief {
    min-height: 92px;
    margin-top: 14px;
  }

  .map-legend {
    top: 10px;
    right: 10px;
    gap: 8px;
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.62rem;
  }

  .detail-sheet {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(78dvh, 700px);
    padding: 22px 16px calc(16px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
    animation: sheet-in 180ms ease-out both;
  }

  .detail-sheet::before {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 38px;
    height: 4px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: #ccd5d2;
    content: "";
  }

  .property-card {
    min-height: 92px;
  }
}

@media (max-width: 430px) {
  .topbar-meta span {
    padding: 0 8px;
  }

  .map-stage {
    height: 49svh;
    min-height: 330px;
  }

  .leaflet-control-zoom a {
    width: 44px !important;
    height: 44px !important;
  }

  .property-marker {
    min-width: 58px;
    height: 32px;
    padding-right: 7px;
    font-size: 0.63rem;
  }

  .map-legend span:nth-child(2) {
    display: none;
  }

  .decision-grid {
    grid-template-columns: 1fr;
    gap: 9px;
  }

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

@keyframes sheet-in {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
