/* ————————————————————————————————
   Within — UK travel-time map
   Palette: ink on paper, petrol-teal time bands, plum second person
———————————————————————————————— */
:root {
  --ink: #0b1220;
  --ink-60: rgba(11, 18, 32, 0.6);
  --ink-40: rgba(11, 18, 32, 0.4);
  --paper: rgba(255, 255, 255, 0.86);
  --hairline: rgba(11, 18, 32, 0.1);
  --teal-900: #0e5c50;
  --teal-700: #0e7c66;
  --teal-500: #14a08a;
  --teal-300: #57c4ad;
  --teal-100: #a5e3d3;
  --plum-700: #7c3f6d;
  --plum-300: #c98ab8;
  --overlap: #1d2f8f;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(11, 18, 32, 0.14), 0 2px 8px rgba(11, 18, 32, 0.08);
  --spring: cubic-bezier(0.2, 0.9, 0.3, 1);
  --font-display: "Bricolage Grotesque", "SF Pro Display", system-ui, sans-serif;
  --font-body: "Inter", "SF Pro Text", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#map { position: absolute; inset: 0; }

/* ——— Floating panel ——— */
.panel {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 320px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--paper);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 10;
}

.panel-brand h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.panel-brand .strap {
  margin-top: 3px;
  font-size: 13px;
  color: var(--ink-60);
}

/* ——— Search ——— */
.person { position: relative; }

.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 0 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-row:focus-within {
  border-color: var(--teal-700);
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.15);
}

.pin-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.pin-a { background: var(--teal-700); }
.pin-b { background: var(--plum-700); }

.search {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  height: 42px;
  color: var(--ink);
}
.search::placeholder { color: var(--ink-40); }
.search::-webkit-search-cancel-button { display: none; }

.remove-b {
  border: none;
  background: none;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-40);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.remove-b:hover { color: var(--ink); }

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  list-style: none;
  overflow: hidden;
  z-index: 30;
}

.suggestions li {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.suggestions li:hover, .suggestions li.active { background: rgba(14, 124, 102, 0.08); }
.suggestions .s-name { font-weight: 500; }
.suggestions .s-detail { font-size: 12px; color: var(--ink-60); }

.hidden-person { display: none; }
.hidden-person.visible { display: block; }

.add-person {
  align-self: flex-start;
  border: none;
  background: none;
  font: inherit;
  font-weight: 500;
  color: var(--plum-700);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: opacity 0.15s ease;
}
.add-person:hover { opacity: 0.7; }
.add-person.hidden { display: none; }

/* ——— Segmented control ——— */
.segmented {
  display: flex;
  background: rgba(11, 18, 32, 0.06);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.seg {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 7px;
  border: none;
  background: none;
  border-radius: 9px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-60);
  cursor: pointer;
  transition: background 0.2s var(--spring), color 0.2s ease, box-shadow 0.2s ease;
}

.seg.active {
  background: #fff;
  color: var(--teal-900);
  box-shadow: 0 1px 4px rgba(11, 18, 32, 0.12);
}

.seg.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ——— Time slider ——— */
.control-group { display: flex; flex-direction: column; gap: 8px; }

.time-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.time-row label { font-weight: 500; color: var(--ink-60); font-size: 13px; }
.time-row output {
  font-family: var(--font-display);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.time-row output b { font-weight: 700; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--teal-700) var(--fill, 45%), rgba(11, 18, 32, 0.1) var(--fill, 45%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--teal-700);
  box-shadow: 0 1px 4px rgba(11, 18, 32, 0.2);
  margin-top: -8px;
  transition: transform 0.15s var(--spring);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]:focus-visible { outline: 2px solid var(--teal-700); outline-offset: 4px; border-radius: 4px; }

/* ——— Legend ——— */
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend-title { font-size: 13px; font-weight: 500; color: var(--ink-60); }

.legend-bands { display: flex; gap: 4px; }

.band-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-60);
}
.band-chip .swatch {
  width: 100%;
  height: 8px;
  border-radius: 4px;
}

.overlap-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.overlap-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--overlap);
  opacity: 0.75;
  flex: none;
}

/* ——— Status & hint ——— */
.status {
  font-size: 12.5px;
  color: var(--ink-60);
  min-height: 0;
}
.status:empty { display: none; }
.status.error { color: #a33a2a; }

.status .spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 2px solid rgba(14, 124, 102, 0.25);
  border-top-color: var(--teal-700);
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.panel-foot {
  border-top: 1px solid var(--hairline);
  padding-top: 10px;
  font-size: 11px;
  color: var(--ink-40);
}

.hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 100px;
  box-shadow: var(--shadow);
  z-index: 5;
  transition: opacity 0.4s ease, transform 0.4s var(--spring);
}
.hint.gone { opacity: 0; transform: translateX(-50%) translateY(10px); pointer-events: none; }

/* ——— Map markers ——— */
.marker {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(11, 18, 32, 0.35);
  cursor: grab;
}
.marker:active { cursor: grabbing; }
.marker-a { background: var(--teal-700); }
.marker-b { background: var(--plum-700); }

/* ——— Reduced motion ——— */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ——— Narrow viewports ——— */
@media (max-width: 480px) {
  .panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 60vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .hint { bottom: auto; top: 20px; }
}

/* ——— Layers: POI categories, stations, rail ——— */
.layers {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(11, 18, 32, 0.09);
}
.layers-title {
  margin: 0 0 8px;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(11, 18, 32, 0.55);
}
.layer-toggles { display: flex; gap: 14px; margin-bottom: 10px; }
.toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.84rem; color: #0b1220; cursor: pointer;
}
.toggle input { accent-color: #0e7c66; }

.poi-add { display: grid; gap: 6px; }
.poi-add select,
.poi-brand {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.86rem;
  color: #0b1220;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(11, 18, 32, 0.14);
  border-radius: 8px;
}
.poi-add select:focus,
.poi-brand:focus { outline: 2px solid rgba(14, 124, 102, 0.45); outline-offset: 1px; }
.poi-add-btn {
  padding: 8px 12px;
  font: inherit; font-size: 0.86rem; font-weight: 600;
  color: #fff; background: #0e7c66;
  border: 0; border-radius: 8px; cursor: pointer;
}
.poi-add-btn:hover { background: #0c6a58; }
.poi-add-btn:disabled { opacity: 0.6; cursor: default; }

.poi-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; }
.poi-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 7px;
  background: rgba(11, 18, 32, 0.035);
  font-size: 0.84rem;
}
.poi-swatch {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  box-shadow: 0 0 0 1.5px #fff inset;
}
.poi-swatch.has-logo {
  border-radius: 3px; background-size: cover; background-position: center;
  box-shadow: none;
}
.poi-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-count {
  font-variant-numeric: tabular-nums;
  color: rgba(11, 18, 32, 0.5); font-size: 0.78rem;
}
.poi-style-btn {
  font: inherit; font-size: 0.76rem;
  padding: 2px 7px; border-radius: 5px; cursor: pointer;
  color: #0e7c66; background: transparent;
  border: 1px solid rgba(14, 124, 102, 0.35);
}
.poi-style-btn:hover { background: rgba(14, 124, 102, 0.08); }
.poi-hint { margin: 8px 0 0; font-size: 0.76rem; color: rgba(11, 18, 32, 0.5); }

/* ——— Right-click menu ——— */
.ctx-menu {
  position: fixed; z-index: 60; min-width: 190px;
  padding: 4px; display: grid; gap: 1px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(11, 18, 32, 0.12);
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(11, 18, 32, 0.16);
  backdrop-filter: blur(8px);
}
.ctx-item {
  text-align: left; font: inherit; font-size: 0.84rem;
  padding: 7px 9px; border: 0; border-radius: 6px;
  background: transparent; color: #0b1220; cursor: pointer;
}
.ctx-item:hover { background: rgba(14, 124, 102, 0.1); }

/* ——— Pin style editor ——— */
.style-editor {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  width: 260px; padding: 12px 14px 10px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(11, 18, 32, 0.12);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(11, 18, 32, 0.18);
  backdrop-filter: blur(10px);
}
.style-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 600; font-size: 0.9rem;
}
.style-close {
  font-size: 1.15rem; line-height: 1; padding: 0 4px;
  border: 0; background: transparent; cursor: pointer;
  color: rgba(11, 18, 32, 0.45);
}
.style-close:hover { color: #0b1220; }
.style-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 8px; font-size: 0.84rem;
}
.style-row select,
.style-row input[type="color"] { font: inherit; font-size: 0.84rem; }
.style-row select {
  padding: 5px 8px; border-radius: 7px;
  border: 1px solid rgba(11, 18, 32, 0.14);
  background: #fff;
}
.style-row input[type="color"] {
  width: 40px; height: 26px; padding: 0; cursor: pointer;
  border: 1px solid rgba(11, 18, 32, 0.14); border-radius: 6px; background: none;
}
.style-row input[type="range"] { width: 120px; accent-color: #0e7c66; }
.style-row input[type="file"] { max-width: 150px; font-size: 0.74rem; }
.style-logo-row {
  display: flex; align-items: center; gap: 10px; margin: 4px 0 8px;
}
.style-logo-row img {
  width: 30px; height: 30px; object-fit: contain;
  border: 1px solid rgba(11, 18, 32, 0.12); border-radius: 6px; background: #fff;
}
.style-logo-clear {
  font: inherit; font-size: 0.76rem; cursor: pointer;
  padding: 3px 8px; border-radius: 6px;
  color: #8a2f2f; background: transparent;
  border: 1px solid rgba(138, 47, 47, 0.3);
}
.style-note { margin: 2px 0 0; font-size: 0.72rem; color: rgba(11, 18, 32, 0.45); }

/* Link across to the postcode analysis tool. */
.panel-foot .tool-link {
  display: block; margin-bottom: 6px;
  font-size: 0.8rem; font-weight: 600; color: #0e7c66; text-decoration: none;
}
.panel-foot .tool-link:hover { text-decoration: underline; }

/* ——— Map branding panel ——— */
.design {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid rgba(11, 18, 32, 0.09);
}
.design-toggle {
  width: 100%; font: inherit; font-size: 0.82rem; font-weight: 600;
  text-align: left; cursor: pointer; padding: 7px 0;
  color: #0e7c66; background: transparent; border: 0;
}
.design-toggle::before { content: "＋ "; font-weight: 400; }
.design-toggle[aria-expanded="true"]::before { content: "－ "; }
.design-toggle:hover { text-decoration: underline; }

.design-panel { display: flex; flex-direction: column; gap: 7px; padding-top: 4px; }
.design-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: rgba(11, 18, 32, 0.45);
}
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font: inherit; font-size: 0.74rem; cursor: pointer;
  padding: 4px 9px; border-radius: 20px;
  color: rgba(11, 18, 32, 0.7); background: rgba(11, 18, 32, 0.045);
  border: 1px solid transparent;
}
.chip:hover { background: rgba(14, 124, 102, 0.1); }
.chip.on { background: #0e7c66; color: #fff; }

.ramps { display: flex; flex-wrap: wrap; gap: 5px; }
.ramp {
  display: flex; padding: 2px; cursor: pointer; border-radius: 6px;
  background: none; border: 2px solid transparent;
}
.ramp i { display: block; width: 15px; height: 15px; }
.ramp i:first-child { border-radius: 4px 0 0 4px; }
.ramp i:last-child { border-radius: 0 4px 4px 0; }
.ramp:hover { border-color: rgba(11, 18, 32, 0.16); }
.ramp.on { border-color: #0e7c66; }

.design-input {
  width: 100%; font: inherit; font-size: 0.8rem; color: #0b1220;
  padding: 7px 9px; border-radius: 7px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(11, 18, 32, 0.14);
}
.design-input:focus { outline: 2px solid rgba(14, 124, 102, 0.4); outline-offset: 1px; }
.design-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.design-file { position: relative; overflow: hidden; display: inline-block; }
.design-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.design-file span, .design-ghost {
  display: inline-block; font: inherit; font-size: 0.74rem; font-weight: 600;
  cursor: pointer; padding: 4px 10px; border-radius: 6px;
  color: #0e7c66; background: transparent;
  border: 1px solid rgba(14, 124, 102, 0.3);
}
.design-file:hover span, .design-ghost:hover { background: rgba(14, 124, 102, 0.08); }
.design-logo { max-height: 26px; max-width: 76px; object-fit: contain; }

.design-download {
  font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer;
  padding: 9px 12px; border-radius: 8px; border: 0;
  color: #fff; background: #1d2f8f; margin-top: 3px;
}
.design-download:hover { background: #182773; }
.design-note { margin: 0; font-size: 0.7rem; color: rgba(11, 18, 32, 0.42); }
