:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #efece3;
  --text: #21281f;
  --muted: #5d6b58;
  --line: #dcd8cc;
  --brand: #1f6f4a;
  --brand-ink: #10462e;
  --accent: #c25e00;
  --danger: #b03a3a;
  --shadow: 0 6px 24px rgba(20, 30, 20, .14);
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-h: 44px;
}
/* Dark palette: applied when the OS prefers dark AND the user hasn't forced
   light, or when the user explicitly picks dark in the Info tab. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14170f;
    --surface: #1e2218;
    --surface-2: #262b1f;
    --text: #ecefe4;
    --muted: #a9b3a0;
    --line: #333a2a;
    --brand: #4bbd86;
    --brand-ink: #8fd3b0;
    --accent: #e8934a;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #14170f;
  --surface: #1e2218;
  --surface-2: #262b1f;
  --text: #ecefe4;
  --muted: #a9b3a0;
  --line: #333a2a;
  --brand: #4bbd86;
  --brand-ink: #8fd3b0;
  --accent: #e8934a;
  --shadow: 0 6px 24px rgba(0, 0, 0, .5);
}

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

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
h1, h2, h3, h4 { margin: 0 0 .3em; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.2rem; }
h3.sub, .sub { font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 1.2em; }
p { margin: 0 0 .8em; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 14px 16px; }
.hidden { display: none !important; }

.fatal { padding: 3rem 1.5rem; text-align: center; color: var(--muted); }

.skiplink {
  position: fixed; left: 8px; top: -60px; z-index: 100;
  background: var(--surface); color: var(--brand); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 10px; font-weight: 600; transition: top .15s;
}
.skiplink:focus { top: calc(8px + var(--safe-t)); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
#main:focus { outline: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------------- layout ---------------- */
#app { min-height: 100%; }
.app {
  display: flex; flex-direction: column;
  height: 100vh;
  height: 100dvh; /* follows the iOS Safari URL bar so the tab bar stays visible */
}
.app__main { position: relative; flex: 1; min-height: 0; }

.view { position: absolute; inset: 0; display: none; }
.view--active { display: block; }
.view--map.view--active { display: block; }
.view--scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(24px + var(--safe-b)); background: var(--bg); }

.vhead { padding: calc(18px + var(--safe-t)) 16px 6px; }

/* ---------------- tab bar ---------------- */
.tabbar {
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); flex-shrink: 0;
}
.tab {
  flex: 1; border: 0; background: none; color: var(--muted);
  padding: 4px 2px 3px; font: inherit; font-size: .62rem; line-height: 1.1;
  display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer;
  min-height: var(--tabbar-h);
}
.tab__icon svg { width: 19px; height: 19px; }
.tab--active { color: var(--brand); }

/* ---------------- map ---------------- */
/* ID selector on purpose: vendor/maplibre-gl.css is injected at runtime (lazy)
   and its `.maplibregl-map { position: relative }` would otherwise win on source
   order over a `.map` class rule and collapse the map to 0 height. */
#map { position: absolute; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* --- retro / parchment look (CSS only, no style or tile changes) ---------- */
/* Warm the rendered tiles; keep controls, markers and the user dot crisp. */
#map .maplibregl-canvas {
  filter: sepia(.3) saturate(1.05) contrast(.92) brightness(1.05) hue-rotate(-8deg);
}
/* Aged-paper grain + edge vignette + faint warm wash, multiplied over the map.
   The grain is a procedural SVG (feTurbulence) inlined as a data URI — nothing
   to license. */
/* Plain alpha overlay (no blend mode) so it stays cheap while the map animates. */
#map::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: .55;
  background-image:
    linear-gradient(0deg, rgba(120,92,40,.16), rgba(120,92,40,.16)),
    radial-gradient(ellipse 130% 120% at 50% 45%, rgba(74,52,22,0) 55%, rgba(74,52,22,.5) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='170'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='0.22' intercept='0.4'/%3E%3CfeFuncG type='linear' slope='0.22' intercept='0.34'/%3E%3CfeFuncB type='linear' slope='0.22' intercept='0.26'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat, repeat;
  background-size: 100% 100%, 100% 100%, 170px 170px;
}
/* Lift interactive bits above the paper overlay so they stay legible. */
#map .maplibregl-marker,
#map .maplibregl-control-container { z-index: 3; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #map .maplibregl-canvas {
    filter: sepia(.36) saturate(.9) contrast(.96) brightness(.84) hue-rotate(-6deg);
  }
  :root:not([data-theme="light"]) #map::after {
    opacity: .6;
    background-image:
      linear-gradient(0deg, rgba(90,70,40,.2), rgba(90,70,40,.2)),
      radial-gradient(ellipse 130% 120% at 50% 45%, rgba(10,6,2,0) 45%, rgba(10,6,2,.55) 100%),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='170'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='0.22' intercept='0.4'/%3E%3CfeFuncG type='linear' slope='0.22' intercept='0.34'/%3E%3CfeFuncB type='linear' slope='0.22' intercept='0.26'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.4'/%3E%3C/svg%3E");
  }
}
:root[data-theme="dark"] #map .maplibregl-canvas {
  filter: sepia(.36) saturate(.9) contrast(.96) brightness(.84) hue-rotate(-6deg);
}

/* --- unified map controls: one group holds zoom / north / locate / nav / view */
#map .maplibregl-ctrl-group {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
#map .lt-tools { display: flex; flex-direction: column; }
#map .lt-tool {
  width: 33px; height: 33px; padding: 0; border: 0; background: transparent;
  color: var(--text); display: grid; place-items: center; cursor: pointer;
}
#map .lt-tool + .lt-tool { border-top: 1px solid var(--line); }
#map .lt-tool:hover { background: var(--surface-2); }
#map .lt-tool svg { width: 18px; height: 18px; opacity: .85; }
#map .lt-tool--compass svg { transition: transform .1s linear; transform-origin: 50% 50%; }
#map .lt-tool--nav.on { background: var(--brand); }
#map .lt-tool--nav.on svg { color: var(--surface); opacity: 1; }
/* view-cycle button (flat / tilt / street) — a symbol, tinted so it reads as the
   stateful mode control */
#map .lt-3d-btn { color: var(--brand); }
#map .lt-3d-btn svg { opacity: 1; }
/* pull the retro paper vignette back at street level — it fights the horizon */
#map.map--street::after { opacity: .25; }

#map .maplibregl-ctrl-bottom-right { margin-bottom: calc(2px + var(--safe-b)); margin-right: 0; }
#map .maplibregl-ctrl-bottom-left { margin-bottom: calc(var(--safe-b) + 1px); margin-left: 0; }
#map .maplibregl-ctrl-bottom-left .maplibregl-ctrl { margin: 0 0 3px 6px; }
#map .maplibregl-ctrl-bottom-left .lt-tools { margin-bottom: 1px; }
#map .maplibregl-ctrl-bottom-right .maplibregl-ctrl { margin: 0 6px 3px 0; }
#map .maplibregl-ctrl-attrib-button { opacity: .65; }
#map .maplibregl-ctrl-attrib.maplibregl-compact {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); color: var(--muted);
  overflow: hidden; max-width: 28px;
  transition: max-width .34s cubic-bezier(.4, 0, .2, 1);
}
#map .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show {
  max-width: min(80vw, 360px);
}
/* keep the credit text laid out (not display:none) so the box has a width to
   animate to/from; fade it with the reveal */
#map .maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner {
  display: block !important; white-space: nowrap;
  opacity: 0; transition: opacity .16s ease;
}
#map .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show .maplibregl-ctrl-attrib-inner {
  opacity: 1; transition: opacity .3s ease .1s;
}
@media (prefers-reduced-motion: reduce) {
  #map .maplibregl-ctrl-attrib.maplibregl-compact,
  #map .maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner { transition: none; }
}
#map .maplibregl-ctrl-attrib.maplibregl-compact a { color: var(--muted); }
#map .maplibregl-ctrl-scale {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; color: var(--muted); font-size: 10px;
}

/* --- Opowieści i legendy: side drawer on the map --------------------------- */
/* The container is clipped at the left edge so ONLY the handle ribbon pokes out;
   the panel (and its shadow) is fully hidden until opened. */
.stories { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.stories__handle {
  pointer-events: auto; position: absolute; left: 0; top: 50%;
  transform: translateY(-50%); z-index: 7;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 14px 7px; border: 1px solid var(--line); border-left: 0;
  border-radius: 0 12px 12px 0; background: var(--surface); color: var(--text);
  box-shadow: 4px 0 12px rgba(20, 30, 20, .18); cursor: pointer;
  font: 600 12px/1 system-ui, sans-serif;
}
.stories__handle-label { writing-mode: vertical-rl; letter-spacing: .04em; }
.stories__handle-icon { font-size: 16px; }
.stories__panel {
  pointer-events: auto; position: absolute; left: 0; top: 0; bottom: 0;
  width: min(340px, 86vw); background: var(--surface); border-right: 1px solid var(--line);
  transform: translateX(-100%); transition: transform .28s ease;
  display: flex; flex-direction: column; overflow: hidden;
  padding-top: var(--safe-t);
}
.stories--open .stories__panel { transform: none; box-shadow: 6px 0 24px rgba(20, 30, 20, .28); }
.stories--open .stories__handle { left: min(340px, 86vw); transition: left .28s ease; }
.stories__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.stories__head h2, .story h3 { margin: 0; font-size: 1.05rem; color: var(--text); }
.stories__x, .stories__back { background: none; border: 0; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 4px; }
.stories__x { font-size: 1.5rem; line-height: 1; }
.stories__list { overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.storycard {
  text-align: left; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; display: grid; gap: 4px;
  color: var(--text); font: inherit;
}
.storycard:hover { border-color: var(--brand); }
.storycard__tag {
  justify-self: start; font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; padding: 3px 8px; border-radius: 999px; color: #fff;
}
/* fixed dark fills so white text keeps ~5:1 contrast in both themes */
.storycard__tag--legenda { background: #a3490a; }
.storycard__tag--historia { background: #166b47; }
.storycard__title { font-weight: 700; font-size: 1rem; color: var(--text); }
.storycard__teaser { font-size: .86rem; color: var(--muted); }
.storycard__icons { font-size: .8rem; color: var(--muted); }
.story { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.story__img { width: 100%; border-radius: 10px; }
.stories__actions { margin: 2px 0 4px; }
.story__links { display: flex; flex-wrap: wrap; gap: 6px; }
.story__link { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: .84rem; cursor: pointer; color: var(--text); }

/* --- Kiedyś i dziś: before/after slider ---------------------------------- */
.poi-compare { margin: 12px 0; }
.poi-compare h4, .poi-model h4 { margin: 0 0 6px; }
.beforeafter {
  position: relative; margin: 0; width: 100%; aspect-ratio: 3 / 2;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  touch-action: pan-y; user-select: none; cursor: ew-resize; background: var(--surface-2);
}
.beforeafter__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.beforeafter__then { clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0); }
.beforeafter__handle {
  position: absolute; top: 0; bottom: 0; left: var(--split, 50%); width: 2px;
  background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); transform: translateX(-1px);
}
.beforeafter__handle::after {
  content: '‹ ›'; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: #fff; color: #333; border-radius: 999px; padding: 2px 8px; font-size: .8rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.3); letter-spacing: 2px;
}
.beforeafter__label {
  position: absolute; bottom: 8px; padding: 2px 8px; font-size: .72rem; font-weight: 700;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 6px;
}
.beforeafter__label--then { left: 8px; }
.beforeafter__label--now { right: 8px; }
.beforeafter__range {
  position: absolute; left: 0; right: 0; bottom: 0; width: 100%; margin: 0;
  opacity: 0; height: 44px; cursor: ew-resize;
}
.beforeafter__range:focus-visible { opacity: .25; }

/* --- switch between overlapping POIs in the sheet ---------------------- */
.sheet__switch {
  display: inline-flex; align-items: center; gap: 2px; margin: 0 0 8px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2);
}
.sheet__switch-btn {
  width: 30px; height: 30px; border: 0; background: none; color: var(--brand);
  font-size: 1.1rem; line-height: 1; cursor: pointer; border-radius: 999px;
}
.sheet__switch-btn:hover { background: var(--surface); }
.sheet__switch-label { font-size: .8rem; color: var(--muted); padding: 0 4px; min-width: 34px; text-align: center; }

/* --- Zabytki: search + sort + plan mode --------------------------------- */
.list__tools { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; flex-wrap: wrap; }
.list__search { flex: 1 1 140px; }
.seg--sm .seg__btn { padding: 6px 10px; font-size: .82rem; }
.list__plan { margin: 2px 0 6px; }
.plan-time { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; }
.plan-time .row { gap: 6px; }
.list__plan--on { background: var(--brand); color: var(--surface); border-color: var(--brand); }
.poi-row--picked { border-color: var(--brand); background: var(--surface-2); }
.poi-list--plan .poi-row__dot { display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .8rem; }
.plan-bar {
  position: sticky; bottom: calc(8px + var(--safe-b)); z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 10px; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.stoplist li { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }

/* --- Transkrypcja / napisy podczas audio -------------------------------- */
.transcript { margin: 0 0 4px; }
.transcript--playing { background: linear-gradient(var(--surface-2), var(--surface-2)) padding-box; border-radius: 8px; padding: 8px; }
.transcript .w--on { background: var(--brand); color: #fff; border-radius: 3px; padding: 0 1px; box-decoration-break: clone; }

/* --- Onboarding + region picker --------------------------------------- */
.intro__list { margin: 0 0 10px; padding-left: 1.15em; display: grid; gap: 8px; }
.intro__list li { line-height: 1.45; }
.region-list { display: grid; gap: 8px; }
.region-list .btn { justify-content: flex-start; }

/* --- Podróż w czasie: historical-map slider ----------------------------- */
#map .lt-timeslider {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; box-shadow: var(--shadow); font: 600 11px/1 system-ui, sans-serif;
  color: var(--muted); pointer-events: auto;
}
#map .lt-timeslider input { width: 130px; accent-color: var(--accent); }
#map .lt-timeslider--active { color: var(--text); border-color: var(--accent); }

/* --- Pocztówka: centred overlay dialog --------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 80; display: flex;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(10, 14, 10, .55); overscroll-behavior: contain;
}
.overlay__dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(520px, 100%); max-height: 90vh; overflow-y: auto; padding: 14px;
}
.overlay__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.overlay__head h3 { margin: 0; font-size: 1.05rem; }
.overlay__x { background: none; border: 0; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 2px 6px; }
.overlay__row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.postcard__img { width: 100%; height: auto; border-radius: 8px; display: block; }

/* --- Global search --------------------------------------------------- */
.search-fab {
  position: absolute; right: 8px; bottom: 10px; z-index: 5;
  width: 44px; height: 44px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.search-fab__ico svg { width: 21px; height: 21px; display: block; }
.has-sheet .search-fab { display: none; }
.overlay--search { align-items: flex-start; padding: 0; }
.overlay__dialog.search {
  width: 100%; max-width: 560px; max-height: 100%; height: 100%;
  border-radius: 0; padding: 0; display: flex; flex-direction: column;
  padding-top: var(--safe-t);
}
.search__bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.search__ico { color: var(--muted); display: flex; }
.search__ico svg { width: 18px; height: 18px; }
.search__input { flex: 1; border: 0; background: none; font-size: 1rem; padding: 6px 0; }
.search__input:focus { outline: none; }
.search__results { flex: 1; overflow-y: auto; padding: 6px 0 calc(16px + var(--safe-b)); overscroll-behavior: contain; }
.search__hint { padding: 16px; }
.search__group {
  margin: 10px 0 2px; padding: 4px 14px; font-size: .72rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.search__row {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 10px 14px; display: flex; flex-direction: column; gap: 2px;
  border-bottom: 1px solid var(--line);
}
.search__row:hover, .search__row:focus-visible { background: var(--panel2, rgba(127,127,127,.1)); }
.search__row-title { font-size: .95rem; color: var(--text); }
.search__row-sub { font-size: .8rem; }
@media (min-width: 640px) {
  .overlay--search { align-items: center; padding: 24px; }
  .overlay__dialog.search { height: min(70vh, 560px); border-radius: var(--radius); }
}

/* 3D model / AR viewer inside the POI sheet */
.poi-model { margin: 12px 0; }
.poi-model h4 { margin: 0 0 6px; }
.poi-model model-viewer {
  width: 100%; height: 16rem; display: block;
  background: var(--panel2, rgba(127,127,127,.12));
  border: 1px solid var(--line); border-radius: 10px;
}
.poi-model__ar {
  position: absolute; right: 10px; bottom: 10px;
  background: var(--surface); box-shadow: var(--shadow);
}

.guidebar {
  position: absolute; left: 8px; right: 8px; z-index: 6; pointer-events: none;
  top: calc(8px + var(--safe-t));
}
.guidebar__card {
  pointer-events: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.guidebar__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.guidebar__text { font-size: .86rem; color: var(--muted); }
.guidebar__progress { font-size: .8rem; color: var(--muted); }
.guidebar__next { font-size: .92rem; font-weight: 600; }

/* Slim "curiosity" strip at the top — route-side stories (e.g. a street). */
.curiobar {
  position: absolute; left: 8px; right: 8px; z-index: 6;
  top: calc(8px + var(--safe-t));
  pointer-events: none;
  opacity: 0; transform: translateY(-8px);
  transition: opacity .2s ease, transform .2s ease;
}
.curiobar.curiobar--in { opacity: 1; transform: none; }
.curiobar.hidden { display: none; }
.curiobar__card {
  pointer-events: auto; display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow);
  padding: 5px 6px 5px 14px; cursor: pointer;
}
.curiobar__text {
  flex: 1; min-width: 0;
  font-size: .8rem; line-height: 1.35; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.curiobar__close {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  border: none; background: transparent; color: var(--muted);
  font-size: 16px; line-height: 1; cursor: pointer;
}

.bearing {
  position: absolute; left: 50%; bottom: calc(74px + var(--safe-b)); transform: translateX(-50%); z-index: 6;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow); padding: 8px 14px; display: flex; align-items: center; gap: 10px;
  font-size: .85rem; font-weight: 600; max-width: 86vw;
}
.bearing__arrow { font-size: 20px; color: var(--brand); transition: transform .25s ease; flex: 0 0 auto; }
.bearing__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bearing__stop {
  flex: 0 0 auto; width: 26px; height: 26px; margin: -4px -6px -4px 0;
  border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}

/* user location marker */
.user-dot { position: relative; width: 22px; height: 22px; }
.user-dot__core {
  position: absolute; inset: 5px; border-radius: 50%; background: #2a7fb8;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.user-dot__pulse {
  position: absolute; inset: 0; border-radius: 50%; background: #2a7fb8;
  opacity: .35; animation: pulse 2.4s ease-out infinite;
}
.user-dot__beam { display: none; }
.user-dot--heading .user-dot__beam {
  display: block; position: absolute; left: 50%; top: 50%;
  width: 0; height: 0; margin-left: -7px; margin-top: -20px;
  border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-bottom: 16px solid #2a7fb8;
}
@keyframes pulse { 0% { transform: scale(.6); opacity: .5; } 100% { transform: scale(2.2); opacity: 0; } }

/* ---------------- cards / routes ---------------- */
.cards { padding: 6px 12px 20px; display: grid; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card__body { padding: 14px 15px; }
.card h3 { display: flex; align-items: center; gap: 8px; }
.meta { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--muted); }
.card__actions, .sheet__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* themed collections — whole card is the tap target */
.cards--collections { padding-top: 0; }
.card--collection { cursor: pointer; transition: border-color .12s, transform .12s; }
.card--collection:hover { border-color: var(--brand); }
.card--collection:active { transform: scale(.995); }
.card--collection h3 { margin-bottom: 4px; }
.view--scroll .sub:first-child { margin-top: .4em; }

.btn {
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 9px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn--ghost { background: transparent; color: var(--brand); }
.btn--link { background: transparent; border-color: transparent; color: var(--brand); text-decoration: underline; padding-left: 4px; padding-right: 4px; }
.btn--sm { padding: 6px 12px; font-size: .85rem; }
.btn--fav-on { background: var(--brand); color: #fff; }

.pill { font-size: .7rem; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill--done { background: var(--brand); color: #fff; }

/* ---------------- list / chips ---------------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 12px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); padding: 6px 12px; border-radius: 999px; font: inherit; font-size: .82rem;
  display: flex; align-items: center; gap: 6px; cursor: pointer;
}
.chip--on { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.chip__dot, .poi-row__dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

.poi-list { padding: 0 8px 20px; display: grid; gap: 2px; }
.poi-row {
  width: 100%; text-align: left; border: 0; background: var(--surface);
  border-radius: 10px; padding: 12px 12px; display: flex; align-items: center; gap: 12px;
  font: inherit; color: var(--text); cursor: pointer;
}
.poi-row:active { background: var(--surface-2); }
.poi-row__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.poi-row__name { font-weight: 600; }
.poi-row__sub { font-size: .82rem; }
.tick { color: var(--brand); }

/* ---------------- passport ---------------- */
.stat { text-align: center; padding: 10px 16px 4px; }
.stat__big { font-size: 2.4rem; font-weight: 800; color: var(--brand); }
.stamp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; padding: 8px 16px; }
.stamp {
  border: 1px dashed var(--line); border-radius: 12px; padding: 10px 6px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px; opacity: .45;
  background: var(--surface);
}
.stamp--on { opacity: 1; border-style: solid; }
.stamp__mark {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--brand);
  display: grid; place-items: center; font-weight: 800; color: var(--brand);
}
.stamp__name { font-size: .72rem; line-height: 1.2; color: var(--muted); }
.badges { display: grid; gap: 8px; padding: 4px 16px; }
.badge { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-weight: 600; }
.badge__icon { color: var(--accent); font-size: 1.2rem; }

/* ---------------- info ---------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 16px; padding: 14px 15px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg__btn { border: 0; background: var(--surface); color: var(--muted); padding: 6px 14px; font: inherit; cursor: pointer; }
.seg__btn--on { background: var(--brand); color: #fff; }

/* ---------------- sheet ---------------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.28);
  transform: translateY(102%); transition: transform .28s ease;
  max-height: 82vh; max-height: 82dvh;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 18px calc(24px + var(--safe-b));
}
.sheet--open { transform: translateY(0); }
/* an empty, closed sheet is only ~1 padding-box tall, so translateY(102%) leaves
   a sliver on screen — keep it out of the layout until it has content */
.sheet:empty { display: none; }
.sheet__close {
  position: absolute; right: 12px; top: 10px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 20px; cursor: pointer;
}
.tag { display: inline-block; color: #fff; font-size: .72rem; padding: 3px 9px; border-radius: 999px; margin-bottom: 8px; }
.sheet__meta { margin-bottom: 10px; }
.stoplist { margin: 8px 0; padding-left: 1.1em; display: grid; gap: 6px; }
.stoplist li { cursor: pointer; }

.photos { display: flex; gap: 10px; overflow-x: auto; margin: 4px 0 12px; -webkit-overflow-scrolling: touch; }
.photos__item { margin: 0; flex: 0 0 auto; width: 210px; }
.photos__item img { width: 210px; height: 140px; object-fit: cover; border-radius: 10px; background: var(--surface-2); display: block; }
.photos__item figcaption { font-size: .78rem; color: var(--muted); margin-top: 4px; line-height: 1.3; }

.row--wrap { flex-wrap: wrap; }
.seg { flex-wrap: wrap; }

.quiz { margin-top: 16px; padding: 12px; background: var(--surface-2); border-radius: 12px; }
.quiz__opt {
  display: block; width: 100%; text-align: left; margin: 6px 0; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  font: inherit; color: var(--text); -webkit-appearance: none; appearance: none; cursor: pointer;
}
.quiz__opt:hover { border-color: var(--brand); }
.quiz__opt:active { background: var(--surface-2); }
.quiz__fb { margin-top: 6px; font-weight: 600; min-height: 1.2em; }
.quiz__fb--ok { color: var(--brand); }
.quiz__fb--no { color: var(--danger); }

/* ---------------- toasts ---------------- */
.toasts {
  position: fixed; left: 0; right: 0; z-index: 30;
  bottom: calc(var(--tabbar-h) + 10px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
  transition: bottom .2s ease;
}
/* lift the toasts above the bottom compass pill so they never cover its text */
.toasts--pill { bottom: calc(var(--tabbar-h) + 58px + var(--safe-b)); }
.toast {
  background: var(--brand-ink); color: #fff; padding: 9px 15px; border-radius: 999px;
  font-size: .85rem; max-width: 90vw; text-align: center; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s;
}
.toast--in { opacity: 1; transform: translateY(0); }

/* ---------------- notices (closures, temporary info) ---------------- */
.noticebar {
  position: absolute; left: 8px; right: 8px; z-index: 6;
  top: calc(8px + var(--safe-t));
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.noticebar.hidden { display: none; }
.noticebar__card {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-left-width: 4px;
  border-radius: 10px; box-shadow: var(--shadow); padding: 8px 10px 8px 12px;
  font-size: .84rem; line-height: 1.35;
}
.noticebar__card--info { border-left-color: var(--brand); }
.noticebar__card--warn { border-left-color: var(--accent); }
.noticebar__text { flex: 1; min-width: 0; }
.noticebar__close {
  flex: 0 0 auto; width: 22px; height: 22px; border: none; background: transparent;
  color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer;
}
/* When a notice is showing, nudge the guide/curiosity cards down a little. */
.noticebar:not(.hidden) ~ .guidebar,
.noticebar:not(.hidden) ~ .curiobar { top: calc(64px + var(--safe-t)); }

/* ---------------- toast action button ---------------- */
.toast--action { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.toast__btn {
  flex: 0 0 auto; border: 1px solid rgba(255,255,255,.5); background: transparent;
  color: #fff; font: inherit; font-weight: 700; font-size: .8rem;
  padding: 4px 10px; border-radius: 999px; cursor: pointer;
}

/* ---------------- callouts ---------------- */
.callout {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--surface-2); border-radius: 10px;
  padding: 9px 11px; margin: 6px 0 12px; font-size: .86rem; line-height: 1.4;
}
.callout--private { border-left: 3px solid var(--accent); }
.callout__icon { flex: 0 0 auto; font-size: 1rem; line-height: 1.3; }

/* ---------------- info extras ---------------- */
.panel__sep { height: 1px; background: var(--line); margin: 12px 0; }
.sources { margin-top: -2px; }
.linklist { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.linklist a { color: var(--brand); }

/* per-POI "Informacje praktyczne" */
.visit { margin: 12px 0; }
.visit__row { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; font-size: .9rem; }
.visit__ico { flex: 0 0 1.2em; text-align: center; }
.visit__row a { color: var(--brand); }
.visit__flags { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.visit__flags li { font-size: .85rem; color: var(--muted); }
.eventlist { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 10px; }
.eventlist li { display: flex; gap: 10px; align-items: baseline; }
.eventlist__date {
  flex: 0 0 auto; min-width: 68px; font-weight: 700; font-size: .8rem;
  color: var(--brand); text-transform: lowercase;
}
.eventlist__body { min-width: 0; }

/* ---------------- print / PDF ---------------- */
#print-area { display: none; }
@media print {
  .app, .sheet, .toasts { display: none !important; }
  html, body { height: auto; background: #fff; color: #000; }
  #print-area { display: block; padding: 0 4mm; font: 11pt/1.5 Georgia, "Times New Roman", serif; }
  #print-area h1 { font-size: 20pt; margin: 0 0 4pt; }
  #print-area h3 { font-size: 13pt; margin: 14pt 0 2pt; }
  #print-area ol { padding-left: 18pt; }
  #print-area li { margin: 0 0 10pt; break-inside: avoid; }
  #print-area a { color: #000; text-decoration: none; }
  #print-area .muted { color: #444; }
}

@media (min-width: 780px) {
  /* The tab bar stays at the bottom on every screen size (like mobile). On a
     wide screen the sheet becomes a floating card in the corner and the top
     cards get a readable max width instead of stretching across the map. */
  .tab { flex: 0 1 160px; }
  .tabbar { justify-content: center; }
  .sheet {
    left: auto; right: 20px; bottom: calc(var(--tabbar-h) + 16px + var(--safe-b));
    width: 380px; max-width: calc(100vw - 40px); border-radius: 18px;
  }
  .guidebar, .curiobar, .noticebar { left: 16px; right: auto; max-width: 460px; width: calc(100% - 32px); }
  .guidebar__card { flex-direction: row; align-items: center; justify-content: space-between; }
}
