:root {
  --ink: #14202b;
  --ink-2: #4a5763;
  --ink-3: #7b8792;
  --paper: #ffffff;
  --paper-2: #f4f2ee;
  --line: #e4e1db;
  --accent: #397EA0;
  --stage: var(--accent);
  --radius: 14px;
  --panel-w: 400px;
  --shadow: 0 10px 30px rgba(20, 32, 43, .18), 0 2px 6px rgba(20, 32, 43, .08);
  font-family: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper-2); }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

#app { position: fixed; inset: 0; display: grid; grid-template-columns: var(--panel-w) 1fr; }
#map { height: 100%; width: 100%; background: #dfe7ea; }

/* ---------- Panel ---------- */
#panel {
  position: relative; z-index: 500; background: var(--paper);
  display: flex; flex-direction: column; min-height: 0;
  box-shadow: 2px 0 18px rgba(20, 32, 43, .10);
}
.grabber { display: none; }
.brand { padding: 22px 22px 14px; background: var(--ink); color: #fff; }
.eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: #a9c3d2; font-weight: 600; }
.eyebrow a { text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
.brand h1 {
  font-family: "Barlow Condensed", sans-serif; font-weight: 800; text-transform: uppercase;
  font-size: 34px; line-height: .95; margin: 8px 0 10px; letter-spacing: .01em;
}
.meta { display: flex; gap: 14px; font-size: 14px; color: #cfdbe3; flex-wrap: wrap; }
.meta b { color: #fff; font-weight: 700; }

.tabs {
  display: flex; gap: 6px; padding: 12px 14px; overflow-x: auto; border-bottom: 1px solid var(--line);
  scrollbar-width: none; flex-shrink: 0;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0; border: 1.5px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-2); transition: background .15s, border-color .15s, color .15s;
}
.tab .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--ink)); }
.tab:hover { border-color: var(--c, var(--ink)); color: var(--ink); }
.tab[aria-pressed="true"] { background: var(--c, var(--ink)); border-color: var(--c, var(--ink)); color: #fff; }
.tab[aria-pressed="true"] .dot { background: #fff; }

#panel-body { overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }

/* stage blocks */
.stage { padding: 18px 18px 6px; }
.stage + .stage { border-top: 8px solid var(--paper-2); }
.stage-head { display: flex; align-items: baseline; gap: 10px; }
.stage-num {
  font-family: "Barlow Condensed", sans-serif; font-weight: 800; font-size: 13px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--stage);
}
.stage h2 {
  font-family: "Barlow Condensed", sans-serif; font-weight: 700; text-transform: uppercase;
  font-size: 24px; margin: 2px 0 6px; line-height: 1;
}
.stage p.intro { margin: 0 0 10px; color: var(--ink-2); font-size: 15px; line-height: 1.45; }
.stage-actions { display: flex; gap: 8px; margin: 4px 0 8px; flex-wrap: wrap; }
.link-btn {
  border: 0; background: none; padding: 4px 0; font-size: 14px; font-weight: 600; color: var(--stage);
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }

.stops { list-style: none; margin: 0; padding: 0; }
.stop-row {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; width: 100%;
  border: 0; background: none; text-align: left; padding: 10px 6px; border-radius: 10px;
}
.stop-row:hover, .stop-row:focus-visible { background: var(--paper-2); outline: none; }
.stop-row .name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.stop-row .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.stop-row .chev { color: var(--ink-3); }

.badge {
  width: 30px; height: 30px; border-radius: 50%; background: var(--stage); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  box-shadow: 0 0 0 2.5px #fff, 0 1px 4px rgba(0,0,0,.35);
}

/* detail */
.detail { padding: 16px 20px 28px; }
.back {
  border: 0; background: none; padding: 6px 0; font-weight: 600; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px;
}
.back:hover { color: var(--ink); }
.detail .kicker {
  margin-top: 10px; display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--stage);
}
.detail h2 {
  font-family: "Barlow Condensed", sans-serif; text-transform: uppercase; font-weight: 800;
  font-size: 38px; line-height: .95; margin: 10px 0 8px;
}
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: color-mix(in srgb, var(--stage) 14%, white); color: color-mix(in srgb, var(--stage) 75%, black);
}
.detail p.summary { font-size: 17px; line-height: 1.5; margin: 14px 0; }
.facts { display: grid; gap: 10px; margin: 16px 0 20px; }
.fact { display: grid; grid-template-columns: 22px 1fr; gap: 10px; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.fact svg { color: var(--stage); margin-top: 2px; }
.fact b { color: var(--ink); }

.nav-buttons { display: grid; gap: 10px; }
.nav-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px;
  border-radius: 12px; font-weight: 700; font-size: 16px; text-decoration: none; border: 1.5px solid var(--ink);
  transition: transform .08s, background .15s;
}
.nav-btn:active { transform: scale(.98); }
.nav-btn.primary { background: var(--ink); color: #fff; }
.nav-btn.primary:hover { background: #22323f; }
.nav-btn.secondary { background: #fff; color: var(--ink); }
.nav-btn.secondary:hover { background: var(--paper-2); }

.stepper { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.stepper button {
  flex: 1; border: 0; background: var(--paper-2); border-radius: 10px; padding: 10px 12px; text-align: left;
  font-size: 13px; color: var(--ink-3); min-height: 54px;
}
.stepper button:last-child { text-align: right; }
.stepper button b { display: block; font-size: 15px; color: var(--ink); margin-top: 2px; }
.stepper button:disabled { visibility: hidden; }

.foot { padding: 18px 20px 26px; font-size: 13px; color: var(--ink-3); line-height: 1.5; border-top: 8px solid var(--paper-2); }

/* ---------- Map tools ---------- */
.map-tools { position: fixed; top: 14px; right: 14px; z-index: 600; display: flex; gap: 8px; align-items: flex-start; }
.tool {
  height: 44px; border: 0; border-radius: 12px; background: #fff; box-shadow: var(--shadow);
  display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; font-weight: 600; font-size: 15px;
}
.tool.icon-only { width: 44px; padding: 0; justify-content: center; }
.tool:hover { background: var(--paper-2); }
.tool[aria-expanded="true"] { background: var(--ink); color: #fff; }
.layers-menu {
  position: absolute; top: 52px; right: 0; width: 250px; background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px;
}
.layers-menu h3 { margin: 4px 8px 8px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.layer-opt {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: 500;
}
.layer-opt:hover { background: var(--paper-2); }
.layer-opt input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }
.layer-opt .sw { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.layer-opt .count { margin-left: auto; color: var(--ink-3); font-size: 13px; }

/* ---------- Leaflet markers ---------- */
.stop-marker { background: none; border: 0; }
.stop-marker .badge { transition: transform .15s; cursor: pointer; }
.stop-marker.active .badge { transform: scale(1.35); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--stage), 0 2px 8px rgba(0,0,0,.4); }
.stop-marker.dim .badge { opacity: .35; }
.poi-marker { background: none; border: 0; }
.poi-dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--c); color: #fff;
  display: grid; place-items: center; box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(0,0,0,.35);
}
.poi-dot svg { width: 13px; height: 13px; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; box-shadow: 0 0 0 3px #fff, 0 0 0 9px rgba(26,115,232,.2); }

.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 14px 16px; font-family: "Barlow", sans-serif; min-width: 200px; }
.pop .k { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--c); }
.pop h4 { margin: 4px 0 6px; font-size: 17px; line-height: 1.2; }
.pop p { margin: 0 0 10px !important; color: var(--ink-2); font-size: 14px; line-height: 1.4; }
.pop .row { display: flex; gap: 6px; }
.pop .row a {
  flex: 1; text-align: center; padding: 8px 6px; border-radius: 8px; font-weight: 700; font-size: 13px;
  text-decoration: none; border: 1.5px solid var(--ink); color: var(--ink);
}
.pop .row a.p { background: var(--ink); color: #fff; }
.leaflet-container a.leaflet-popup-close-button { top: 6px; right: 6px; }

.ferry-label {
  background: #fff; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; color: var(--ink-2);
  box-shadow: 0 1px 4px rgba(0,0,0,.25); white-space: nowrap; border: 0;
}

/* ---------- Mobile: bottom sheet ---------- */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  #map { position: absolute; inset: 0; height: auto; }
  #panel {
    position: absolute; left: 0; right: 0; bottom: 0; height: var(--sheet-h, 46vh);
    border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(20,32,43,.2); overflow: hidden;
    transition: height .25s ease; padding-bottom: env(safe-area-inset-bottom);
  }
  #panel.dragging { transition: none; }
  .grabber {
    display: block; position: absolute; top: 0; left: 0; right: 0; height: 26px; z-index: 2; cursor: grab; touch-action: none;
  }
  .grabber::after {
    content: ""; position: absolute; top: 8px; left: 50%; width: 42px; height: 5px; margin-left: -21px;
    border-radius: 3px; background: rgba(255,255,255,.55);
  }
  .brand { padding: 22px 18px 12px; touch-action: none; }
  .brand h1 { font-size: 26px; margin: 6px 0 6px; }
  .meta { font-size: 13px; }
  .map-tools { top: max(12px, env(safe-area-inset-top)); right: 12px; }
  .tool { padding: 0 13px 0 11px; font-size: 14px; font-weight: 700; }
  .detail h2 { font-size: 32px; }
  .leaflet-control-zoom { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Home: guide list ---------- */
.guide-list { padding: 12px; display: grid; gap: 10px; }
.guide-card {
  display: grid; grid-template-columns: 8px 1fr auto; gap: 14px; align-items: center; text-decoration: none;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px 14px 14px 0; overflow: hidden;
  transition: border-color .15s, transform .08s;
}
.guide-card:hover { border-color: var(--ink); }
.guide-card:active { transform: scale(.99); }
.guide-card .strip { display: flex; flex-direction: column; align-self: stretch; margin: -14px 0; }
.guide-card .strip i { flex: 1; }
.gc-body { display: grid; gap: 2px; }
.gc-kicker { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.gc-title { font-family: "Barlow Condensed", sans-serif; font-weight: 800; text-transform: uppercase; font-size: 22px; line-height: 1.05; }
.gc-meta { font-size: 14px; color: var(--ink-2); }
.guide-card .chev { color: var(--ink-3); }

/* ---------- Unlock screen ---------- */
.gate {
  position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 20px;
  background: rgba(20, 32, 43, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  overflow-y: auto;
}
.gate-card {
  position: relative; width: 100%; max-width: 420px; background: var(--paper); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px 26px 22px; overflow: hidden;
}
.gate-card .strip { position: absolute; top: 0; left: 0; right: 0; height: 6px; display: flex; }
.gate-card .strip i { flex: 1; }
.gate-eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.gate-card h2 {
  font-family: "Barlow Condensed", sans-serif; font-weight: 800; text-transform: uppercase;
  font-size: 32px; line-height: .95; margin: 8px 0 10px;
}
.gate-card p { margin: 0 0 18px; color: var(--ink-2); line-height: 1.45; }
.gate-card label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.gate-card input {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.gate-card input[name="code"] { text-transform: uppercase; letter-spacing: .08em; }
.gate-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(57, 126, 160, .2); }
.gate-error { color: #b3261e; font-size: 14px; font-weight: 600; min-height: 1.2em; margin: -4px 0 10px; }
.gate-card .primary-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 14px; border: 0; border-radius: 10px; background: var(--ink); color: #fff;
  font-weight: 700; font-size: 16px;
}
.gate-card .primary-btn:hover { background: #24384a; }
.gate-card .primary-btn:disabled { opacity: .6; }
.gate-card .gate-small { font-size: 12.5px; color: var(--ink-3); margin: 14px 0 12px; }
.gate-back { font-size: 14px; font-weight: 600; color: var(--accent); text-decoration: none; }
.gate-back:hover { text-decoration: underline; }
.lock {
  display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 1px 6px; border-radius: 99px;
  background: var(--paper-2); color: var(--ink-2); letter-spacing: .04em; vertical-align: 1px;
}
.pop .row a { flex: 1; text-align: center; }
.pop .web { display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }
.stage-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 10px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.stage-nav span { display: inline-flex; align-items: center; gap: 6px; color: var(--stage); margin-right: 2px; }
.stage-nav a {
  padding: 6px 11px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff;
  color: var(--ink); text-decoration: none; font-weight: 700; font-size: 13px;
}
.stage-nav a:hover { border-color: var(--stage); }
.lock.ok { background: #e3f1e6; color: #2f6b3c; }
.acct { display: block; width: 100%; margin-top: 6px; color: #cfdbe3; }
.linkish { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--accent); text-decoration: underline; cursor: pointer; }
.linkish.light { color: #fff; }
.gate-switch { font-size: 14px; color: var(--ink-2); margin: 12px 0 0 !important; }
.gate-card .gate-switch .linkish { color: var(--accent); }
.gate-card .gate-back { display: inline-block; margin-top: 12px; }
.buy-box {
  display: flex; flex-direction: column; gap: 10px; margin: 0 0 18px; padding: 14px; border-radius: 12px;
  background: var(--paper-2); border: 1.5px solid var(--line); text-decoration: none; color: var(--ink-2); font-size: 14px; line-height: 1.4;
}
.buy-box b { color: var(--ink); }
.buy-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
}
.buy-box:hover .buy-btn { background: #2f6c8b; }
