:root {
  --ink: #17352d;
  --ink-soft: #52645e;
  --paper: #f4f1e9;
  --panel: #fbfaf6;
  --line: #dcded5;
  --mint: #a9d9c3;
  --mint-dark: #2c6b58;
  --coral: #e97655;
  --white: #fff;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
button, input { font: inherit; }
button { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { height: 100vh; min-height: 680px; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 72px; flex: 0 0 72px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(244,241,233,.96); z-index: 1001;
}
.brand { display: flex; gap: 11px; align-items: center; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 22px; letter-spacing: -.04em; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: var(--mint); }
.brand-mark svg { width: 27px; height: 27px; stroke-width: 1.4; }
.topbar-note { font-size: 12px; font-weight: 650; letter-spacing: .04em; color: var(--ink-soft); }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #57a37f; box-shadow: 0 0 0 3px rgba(87,163,127,.15); }
.mobile-menu { display: none !important; }

.workspace { display: grid; grid-template-columns: 410px 1fr; min-height: 0; flex: 1; }
.planner { min-height: 0; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); z-index: 501; }
.planner-scroll { overflow-y: auto; padding: 38px 36px 22px; scrollbar-width: thin; }
.eyebrow { color: var(--coral); text-transform: uppercase; font-size: 10px; font-weight: 800; letter-spacing: .17em; }
h1 { font-family: Georgia, "Times New Roman", serif; margin: 8px 0 12px; font-size: 44px; line-height: .98; letter-spacing: -.04em; font-weight: 500; }
h1 em { color: var(--coral); font-weight: 500; }
.intro { max-width: 310px; margin: 0 0 31px; color: var(--ink-soft); font-size: 13px; line-height: 1.55; }

.form-section { margin-top: 26px; }
.section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 12px; font-weight: 750; }
.step { color: var(--coral); font-family: Georgia, serif; font-style: italic; font-size: 12px; }
.optional { margin-left: 4px; color: #8a948f; font-size: 8px; font-weight: 600; letter-spacing: .02em; }
.split-heading { justify-content: space-between; }
.search-wrap { position: relative; }
.search-wrap > svg { position: absolute; left: 14px; top: 14px; width: 17px; height: 17px; color: var(--ink-soft); pointer-events: none; }
.search-wrap input {
  width: 100%; height: 45px; padding: 0 48px 0 41px; border: 1px solid #ccd1c9; border-radius: 9px;
  background: white; outline: none; font-size: 13px; color: var(--ink); transition: .2s;
}
.search-wrap input:focus { border-color: var(--mint-dark); box-shadow: 0 0 0 3px rgba(44,107,88,.1); }
.locate-button { position: absolute; right: 6px; top: 6px; width: 33px; height: 33px; display: grid; place-items: center; border: 0; border-radius: 7px; background: #eef3ef; cursor: pointer; }
.locate-button:hover { background: var(--mint); }
.locate-button svg { width: 17px; }
.clear-button { background: #f5ece8; color: var(--coral); }
.field-hint { margin: 7px 2px 0; font-size: 10px; color: #78847f; }
.search-results {
  position: absolute; z-index: 2000; top: 50px; left: 0; right: 0; overflow: hidden; border: 1px solid var(--line);
  border-radius: 9px; background: white; box-shadow: 0 16px 40px rgba(23,53,45,.15);
}
.search-result { display: block; width: 100%; padding: 11px 13px; border: 0; border-bottom: 1px solid #eee; text-align: left; background: white; font-size: 11px; line-height: 1.35; cursor: pointer; }
.search-result:last-child { border: 0; }
.search-result:hover { background: #f1f7f3; }

.distance-readout { display: flex; align-items: baseline; gap: 5px; margin: -3px 0 4px; }
.distance-readout strong { font-family: Georgia, serif; font-size: 34px; font-weight: 500; }
.distance-readout span { color: var(--ink-soft); font-size: 12px; }
.range { width: 100%; height: 4px; margin: 9px 0 4px; accent-color: var(--coral); cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; color: #8b948f; font-size: 9px; }

.surface-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.surface-option {
  min-width: 0; height: 83px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid #d8dbd4; border-radius: 9px; background: white; cursor: pointer; transition: .18s;
}
.surface-option:hover { transform: translateY(-1px); border-color: #9ab2a8; }
.surface-option.active { border: 1.5px solid var(--ink); background: #f0f6f2; box-shadow: 0 3px 0 rgba(23,53,45,.1); }
.surface-option strong { margin-top: 6px; font-size: 10px; }
.surface-option small { margin-top: 2px; color: #7d8984; font-size: 7px; white-space: nowrap; }
.surface-icon { width: 34px; height: 24px; display: flex; align-items: flex-end; justify-content: space-evenly; color: var(--ink); }
.surface-icon i { display: block; width: 5px; background: currentColor; border-radius: 5px 5px 1px 1px; }
.surface-icon i:nth-child(1) { height: 12px; }.surface-icon i:nth-child(2) { height: 20px; }.surface-icon i:nth-child(3) { height: 15px; }
.surface-icon.gravel i { width: 7px; height: 7px; border-radius: 50%; transform: rotate(20deg); }
.surface-icon.gravel i:nth-child(2) { margin-bottom: 8px; }
.surface-icon.trail i { clip-path: polygon(50% 0,100% 100%,0 100%); border-radius: 0; }
.surface-icon.road i { width: 3px; }
.switch { position: relative; width: 32px; height: 18px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border-radius: 10px; background: #d6dbd6; cursor: pointer; transition: .2s; }
.switch span:after { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: .2s; }
.switch input:checked + span { background: var(--coral); }
.switch input:checked + span:after { transform: translateX(14px); }
.elevation-control { display: flex; align-items: center; gap: 12px; transition: .2s; }
.elevation-control.disabled { opacity: .42; }
.elevation-input { width: 112px; height: 39px; display: flex; align-items: center; border: 1px solid #ccd1c9; border-radius: 8px; background: white; overflow: hidden; }
.elevation-input input { min-width: 0; width: 75px; height: 100%; padding: 0 0 0 11px; border: 0; outline: 0; background: transparent; font-weight: 700; }
.elevation-input span { color: var(--ink-soft); font-size: 10px; }
.elevation-control .field-hint { margin: 0; }

.planner-action { padding: 18px 36px 25px; margin-top: auto; border-top: 1px solid #e5e5dd; background: var(--panel); }
.primary-button, .secondary-button {
  border: 0; border-radius: 8px; height: 49px; display: flex; align-items: center; justify-content: center; gap: 11px; font-weight: 750; font-size: 12px; cursor: pointer; transition: .18s;
}
.primary-button { width: 100%; background: var(--ink); color: white; box-shadow: 0 5px 0 #0d241e; }
.primary-button:hover { background: #234a3f; transform: translateY(-1px); box-shadow: 0 6px 0 #0d241e; }
.primary-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #0d241e; }
.primary-button svg { width: 18px; }
.primary-button.small { height: 42px; padding: 0 18px; width: auto; box-shadow: none; }
.secondary-button { height: 42px; padding: 0 15px; background: #edf2ee; border: 1px solid #d8e1da; }
.secondary-button:hover { background: #dfeae3; }
.secondary-button svg { width: 16px; }

.map-panel { position: relative; min-width: 0; overflow: hidden; background: #e8ebe4; }
#map { position: absolute; inset: 0; z-index: 1; background: #e6e9e3; }
.leaflet-tile-pane { filter: saturate(.45) sepia(.08) brightness(1.05); }
.leaflet-control-zoom { border: 0 !important; box-shadow: 0 4px 18px rgba(23,53,45,.14) !important; }
.leaflet-control-zoom a { color: var(--ink) !important; border-color: #e3e5df !important; }
.leaflet-control-attribution { display: none; }
.empty-state, .loading-state {
  position: absolute; z-index: 400; left: 50%; top: 48%; transform: translate(-50%,-50%); text-align: center; pointer-events: none;
}
.empty-state { min-width: 260px; padding: 21px 25px; border: 1px solid rgba(255,255,255,.7); border-radius: 13px; background: rgba(251,250,246,.9); box-shadow: 0 12px 35px rgba(23,53,45,.12); backdrop-filter: blur(7px); }
.empty-state h2 { font-family: Georgia, serif; margin: 7px 0; font-size: 22px; font-weight: 500; }
.empty-state p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.55; }
.loading-state { padding: 26px 35px; border-radius: 14px; background: rgba(251,250,246,.95); box-shadow: 0 18px 60px rgba(23,53,45,.15); }
.loading-state strong, .loading-state span { display: block; }
.loading-state strong { margin-top: 13px; font-family: Georgia, serif; font-size: 18px; }
.loading-state span { margin-top: 5px; color: var(--ink-soft); font-size: 10px; }
.spinner { width: 32px; height: 32px; margin: auto; border: 3px solid #d8e7df; border-top-color: var(--coral); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.route-card {
  position: absolute; z-index: 500; left: 25px; bottom: 25px; width: min(590px, calc(100% - 50px)); max-height: calc(100% - 50px); padding: 19px;
  overflow-y: auto; border-radius: 14px; background: rgba(251,250,246,.97); box-shadow: 0 16px 55px rgba(23,53,45,.2); backdrop-filter: blur(8px);
}
.route-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.route-card h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 23px; font-weight: 500; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; }
.icon-button svg { width: 17px; }
.route-stats { display: grid; grid-template-columns: repeat(3,1fr); margin: 16px 0; padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.route-stats > div { padding-left: 14px; border-right: 1px solid var(--line); }
.route-stats > div:first-child { padding-left: 0; }.route-stats > div:last-child { border: 0; }
.route-stats strong, .route-stats span { display: block; }
.route-stats strong { font-family: Georgia, serif; font-size: 20px; font-weight: 500; }
.route-stats span { margin-top: 2px; color: #77837e; font-size: 8px; text-transform: uppercase; letter-spacing: .1em; }
.route-details { display: grid; grid-template-columns: 1.45fr 1fr; gap: 17px; margin: 2px 0 17px; }
.detail-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.detail-title small { color: #7c8883; font-size: 8px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.elevation-profile svg { display: block; width: 100%; height: 80px; border-bottom: 1px solid #d8ded9; overflow: visible; }
.elevation-line { fill: none; stroke: var(--coral); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.elevation-area { fill: url(#elevation-fill); stroke: none; }
.profile-axis { display: flex; justify-content: space-between; margin-top: 4px; color: #89938f; font-size: 7px; }
.surface-bars { display: grid; gap: 8px; }
.surface-row { display: grid; grid-template-columns: 62px 1fr 28px; gap: 6px; align-items: center; font-size: 8px; }
.surface-row > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.surface-track { height: 6px; overflow: hidden; border-radius: 4px; background: #e2e5e1; }
.surface-fill { height: 100%; border-radius: inherit; background: var(--mint-dark); }
.surface-row:nth-child(2) .surface-fill { background: #7ba78f; }
.surface-row:nth-child(3) .surface-fill { background: #c3a477; }
.surface-row:nth-child(4) .surface-fill { background: #9b8f82; }
.surface-row strong { text-align: right; font-size: 8px; }
.bike-infra { margin-top: 9px; padding-top: 8px; border-top: 1px solid #dce1dd; color: var(--mint-dark); font-size: 8px; font-weight: 750; }
.route-quality { grid-column: 1 / -1; padding: 8px 10px; border-radius: 7px; background: #edf5f0; color: #356b59; font-size: 8px; font-weight: 700; }
.route-quality.warning { background: #fff0e9; color: #a54e35; }
.route-actions { display: flex; justify-content: flex-end; gap: 9px; }
.map-tip { position: absolute; z-index: 400; top: 14px; left: 50%; transform: translateX(-50%); padding: 8px 12px; border-radius: 20px; background: rgba(251,250,246,.93); box-shadow: 0 4px 15px rgba(23,53,45,.1); font-size: 9px; opacity: 0; transition: .2s; }
.map-tip.visible { opacity: 1; }
.map-tip span { color: var(--coral); font-weight: 900; }
.attribution { position: absolute; z-index: 400; right: 7px; bottom: 5px; padding: 3px 5px; border-radius: 3px; background: rgba(255,255,255,.75); color: #69756f; font-size: 8px; }
.attribution a { color: inherit; }

.start-pin, .waypoint-pin { display: grid; place-items: center; border-radius: 50%; border: 3px solid white; box-shadow: 0 3px 12px rgba(23,53,45,.35); }
.start-pin { width: 23px; height: 23px; background: var(--coral); }
.start-pin:after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: white; }
.waypoint-pin { width: 18px; height: 18px; background: var(--ink); cursor: grab; }
.destination-pin { position: relative; width: 25px; height: 25px; border: 3px solid white; border-radius: 50% 50% 50% 5px; background: #397e9a; box-shadow: 0 3px 12px rgba(23,53,45,.35); transform: rotate(-45deg); }
.destination-pin:after { content: ""; position: absolute; width: 6px; height: 6px; left: 6.5px; top: 6.5px; border-radius: 50%; background: white; }
.toast { position: fixed; z-index: 3000; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 11px 17px; border-radius: 8px; background: var(--ink); color: white; font-size: 11px; opacity: 0; pointer-events: none; transition: .25s; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .app-shell { height: auto; min-height: 100vh; overflow: visible; }
  .topbar { height: 60px; flex-basis: 60px; padding: 0 18px; }
  .topbar-note { display: none; }.mobile-menu { display: grid !important; }
  .workspace { display: flex; flex: none; flex-direction: column; overflow: visible; }
  .planner { min-height: auto; border-right: 0; }
  .planner-scroll { padding: 26px 22px 18px; overflow: visible; }
  h1 { font-size: 38px; }
  .planner-action { padding: 15px 22px 22px; }
  .map-panel { min-height: 560px; }
  .route-card { left: 12px; bottom: 22px; width: calc(100% - 24px); }
  .route-details { grid-template-columns: 1fr; }
  .route-quality { grid-column: 1; }
}

@media (min-width: 821px) and (max-height: 760px) {
  .planner-scroll { padding-top: 28px; padding-bottom: 14px; }
  h1 { font-size: 39px; }
  .intro { margin-bottom: 20px; }
  .form-section { margin-top: 18px; }
  .surface-option { height: 75px; }
  .planner-action { padding-top: 14px; padding-bottom: 20px; }
}
