:root {
  --ink: #17202a;
  --muted: #5b6672;
  --line: #e3e7eb;
  --bg: #ffffff;
  --soft: #f4f6f8;
  --accent: #0b5d6b;
  --green: #2e9e4f;
  --blue: #2b6fd6;
  --black: #1c1c1c;
  --dblack: #7a1fa2;
  --caution: #f2a900;
  --closed: #d62828;
  --panel-w: 400px;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #dfe5ea; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button { font: inherit; cursor: pointer; }
a { color: var(--accent); }

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

/* ---------- Panel ---------- */
#panel {
  position: absolute; top: 12px; left: 12px; bottom: 12px;
  width: var(--panel-w); max-width: calc(100vw - 24px);
  background: var(--bg); border-radius: 16px;
  box-shadow: 0 8px 30px rgba(10, 25, 40, .22);
  display: flex; flex-direction: column; overflow: hidden; z-index: 5;
}
#panelBody { overflow-y: auto; flex: 1; scrollbar-width: thin; }
.sheet-toggle { display: none; }
.head { padding: 20px 20px 8px; }
.head h1 { margin: 0 0 4px; font-size: 1.4rem; letter-spacing: -.01em; }
.tagline { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.4; }
.notice {
  margin: 12px 0 0; padding: 8px 10px; font-size: .78rem; line-height: 1.35;
  background: #fff4d6; border: 1px solid #f0d58a; border-radius: 8px; color: #6b4e00;
}

.filters { padding: 8px 20px 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px 6px 9px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: .85rem;
}
.chip[aria-pressed="false"] { opacity: .45; background: var(--soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--muted); margin-bottom: 6px; }
.legend { font-size: .84rem; color: var(--muted); margin-bottom: 4px; }
.legend summary { cursor: pointer; padding: 4px 0; }
.legend ul { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 8px; }
.legend li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; }

.section-title { margin: 14px 20px 6px; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Rating shapes (ski-run style) */
.sign { display: inline-block; width: 16px; height: 16px; flex: none; position: relative; }
.sign.green { background: var(--green); border-radius: 50%; }
.sign.blue { background: var(--blue); border-radius: 3px; }
.sign.black { background: var(--black); transform: rotate(45deg) scale(.82); border-radius: 2px; }
.sign.double-black { width: 24px; }
.sign.double-black::before, .sign.double-black::after {
  content: ""; position: absolute; top: 0; width: 13px; height: 13px; background: var(--dblack);
  transform: rotate(45deg) scale(.82); border-radius: 2px;
}
.sign.double-black::before { left: -1px; }
.sign.double-black::after { left: 9px; }
.sign.double-black { background: none; }
.sign.double-black { margin-right: 4px; }

/* Route list */
.route-list { list-style: none; margin: 0; padding: 0 12px 8px; }
.route-card {
  width: 100%; text-align: left; border: 1px solid transparent; background: transparent; border-radius: var(--radius);
  padding: 12px 10px; display: grid; gap: 6px;
}
.route-card:hover, .route-card:focus-visible { background: var(--soft); outline: none; border-color: var(--line); }
.route-card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.route-card .name { font-weight: 650; font-size: 1rem; }
.route-card .kind { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.route-card .sum { font-size: .85rem; color: var(--muted); line-height: 1.4; }
.route-card .signs { display: flex; align-items: center; gap: 8px; }
.status-pill {
  font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted);
}
.status-pill.closed { background: #fde8e8; color: #a31515; }
.status-pill.caution { background: #fff1cc; color: #7a5600; }
.empty { padding: 6px 20px; color: var(--muted); font-size: .9rem; }

/* Detail view */
#detailView { padding: 4px 20px 12px; }
.back { border: 0; background: none; color: var(--accent); padding: 8px 0; font-weight: 600; }
#detailView h2 { margin: 4px 0 4px; font-size: 1.3rem; }
#detailView .summary { color: var(--muted); font-size: .92rem; line-height: 1.45; margin: 6px 0 14px; }
.seg-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 8px; }
.seg {
  display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; font-size: .88rem; cursor: pointer; background: #fff; text-align: left; width: 100%;
}
.seg:hover { background: var(--soft); }
.seg .t { font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.seg .n { color: var(--muted); margin-top: 3px; line-height: 1.4; }
.seg .u { color: #8a949e; font-size: .74rem; margin-top: 3px; }
.sub-title { margin: 18px 0 8px; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.place-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.place-chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 11px; font-size: .84rem; }
.place-chip:hover { background: var(--soft); }
.dl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  font-weight: 600; font-size: .88rem; text-align: center;
}
.btn.secondary { background: #fff; color: var(--accent); }
.btn:hover { filter: brightness(1.08); }
.help { font-size: .8rem; color: var(--muted); line-height: 1.45; margin: 10px 0 0; }
.help summary { cursor: pointer; font-weight: 600; color: var(--ink); }

.foot { padding: 12px 20px 18px; border-top: 1px solid var(--line); font-size: .76rem; color: var(--muted); line-height: 1.45; margin-top: 10px; }
.foot p { margin: 0 0 8px; }
.follow-row { display: flex; flex-wrap: wrap; gap: 6px; }
.follow-row a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 600; }

/* ---------- Map markers ---------- */
.rating-marker { width: 22px; height: 22px; display: grid; place-items: center; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer; border: 2px solid transparent; }
.rating-marker.status-closed { border-color: var(--closed); }
.rating-marker.status-caution { border-color: var(--caution); }
.rating-marker.hidden { display: none; }
.rating-marker .sign { transform-origin: center; }
.rating-marker .sign.black { transform: rotate(45deg) scale(.7); }
.rating-marker .sign.green, .rating-marker .sign.blue { width: 12px; height: 12px; }
.rating-marker .sign.double-black { transform: scale(.55); margin: 0; }

.pin {
  width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,.45); cursor: pointer; padding: 0;
}
.pin.faded { opacity: .35; }
.pin:hover, .pin:focus-visible { transform: scale(1.2); outline: none; }

/* ---------- Pop-up bubbles ---------- */
.maplibregl-popup-content { padding: 0; border-radius: 14px; box-shadow: 0 10px 30px rgba(10,25,40,.3); overflow: hidden; }
.maplibregl-popup-close-button { font-size: 20px; padding: 4px 9px; color: #fff; z-index: 2; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.pp { width: 310px; max-height: 58vh; overflow-y: auto; font-size: .88rem; line-height: 1.45; }
.pp-hero { height: 96px; background-size: cover; background-position: center; display: flex; align-items: flex-end; padding: 10px 14px; color: #fff; }
.pp-hero h3 { margin: 0; font-size: 1.15rem; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.pp-body { padding: 12px 14px 14px; }
.pp-body p { margin: 0 0 8px; }
.pp-body ul { margin: 0 0 10px; padding-left: 18px; }
.pp .tip { background: var(--soft); border-radius: 8px; padding: 8px 10px; }
.pp .routes { margin: 8px 0; color: var(--muted); }
.pp .routes a { cursor: pointer; font-weight: 600; margin-right: 8px; }
.pp .post {
  display: grid; gap: 2px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink);
  margin-bottom: 6px;
}
.pp .post .plat { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.pp .post .go { font-size: .78rem; color: var(--accent); font-weight: 600; }
.pp .post .thumb { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; margin-bottom: 4px; }
.pp .follow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pp .follow a { font-size: .76rem; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 600; }
.pp-seg { padding: 12px 14px; width: 260px; font-size: .86rem; line-height: 1.45; }
.pp-seg h4 { margin: 0 0 6px; font-size: 1rem; }
.pp-seg .row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.pp-seg button { margin-top: 6px; width: 100%; }

/* ---------- Mobile: bottom sheet ---------- */
@media (max-width: 760px) {
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: none; height: 46vh; border-radius: 18px 18px 0 0; transition: height .2s ease; }
  #panel.collapsed { height: 38px; }
  #panel.collapsed #panelBody { display: none; }
  .sheet-toggle { display: block; width: 100%; border: 0; background: none; padding: 10px 0 4px; }
  .sheet-toggle .grip { display: block; width: 44px; height: 5px; border-radius: 3px; background: #c5ccd3; margin: 0 auto; }
  .head { padding-top: 6px; }
  .pp { width: 260px; }
  .maplibregl-ctrl-top-right { top: 6px; }
}

/* ---------- Ski-map additions ---------- */
.report { margin: 10px 0 0; padding: 8px 10px; font-size: .8rem; line-height: 1.5; background: var(--soft); border-radius: 8px; border: 1px solid var(--line); }
.report .rr-date { color: var(--muted); font-size: .74rem; margin-left: 4px; }
.report .rr { font-weight: 700; margin-right: 10px; }
.report .rr.open { color: var(--green); }
.report .rr.caution { color: #9a6a00; }
.report .rr.closed { color: var(--closed); }
.section-title .hint { text-transform: none; letter-spacing: 0; font-weight: 500; }
.route-card .road { font-size: .78rem; color: var(--muted); }
.road-sub { color: var(--muted); font-size: .9rem; margin-bottom: 4px; }
.lift-ico { display: inline-flex; vertical-align: middle; color: #27323b; }
.lift-card .name { display: inline-flex; align-items: center; gap: 6px; }
.winter { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.winter-inline { color: #5b3a8a !important; font-weight: 600; }

/* Trail-sign run labels */
.run-label {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 7px; border: 2px solid #17202a; border-radius: 999px;
  background: #fff; color: #17202a; font-weight: 800; font-size: .8rem; letter-spacing: .01em; white-space: nowrap; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.run-label:hover, .run-label:focus-visible { background: #17202a; color: #fff; outline: none; }
.run-label.hidden { display: none; }
.zoomed-out .rating-marker { display: none; }

.lift-marker { width: 26px; height: 26px; border-radius: 6px; border: 2px solid #27323b; background: #fff; color: #27323b; display: grid; place-items: center; padding: 0; box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer; }

.pin.hub { width: 24px; height: 24px; background: #17202a; border-width: 4px; }
.hub-tag { display: inline-block; font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: #fff; color: #17202a; padding: 2px 7px; border-radius: 999px; margin-bottom: 4px; }
.pp-hero > div { display: block; }
.pp-seg .lift-ico { color: #27323b; }

@media (max-width: 760px) {
  .run-label { font-size: .72rem; padding: 3px 9px 3px 6px; }
}

.run-label.lowzoom { display: none; }

/* ---------- Network additions ---------- */
.search { display: block; width: calc(100% - 40px); margin: 6px 20px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: .9rem; background: var(--soft); }
.search:focus { outline: 2px solid var(--accent); background: #fff; }
.run-label.collided { visibility: hidden; }
.zoomed-out .pin:not(.hub) { display: none; }
.acc { margin: 0 0 12px; padding: 7px 10px; font-size: .78rem; line-height: 1.4; border-left: 3px solid var(--line); background: var(--soft); border-radius: 0 8px 8px 0; color: var(--muted); }
.acc-approx, .acc-mixed { border-left-color: var(--caution); }
.acc-road-network { border-left-color: var(--green); }
.help.warn { color: #7a5600; background: #fff8e1; padding: 7px 10px; border-radius: 8px; }
.report .rr-draft { color: var(--muted); font-size: .74rem; }
