/* Co w Warszawie
   Pomysł: lista jak tablica odjazdów warszawskiego tramwaju. Godzina to najważniejsza
   informacja, więc jest duża i równa w kolumnie. Kolory z warszawskiej komunikacji:
   tramwajowa czerwień do akcji i zaznaczeń, żółć do tego, co wybrane teraz. */

:root {
  /* Ciemny motyw: granatowo-łupkowy, spójny z nocną mapą. Akcenty z warszawskiego tramwaju. */
  --paper: #161d26;        /* tło pod panelami */
  --card: #1c2530;         /* panele */
  --raise: #243040;        /* podświetlenia, pola */
  --ink: #e9edf1;
  --muted: #94a1ae;
  --line: #2c3948;
  --tram: #2dd4bf;         /* akcent: morska mięta */
  --tram-soft: rgba(45, 212, 191, .14);
  --sun: #2dd4bf;
  --sun-soft: rgba(45, 212, 191, .10);
  --on-accent: #042f2a;    /* tekst na tle akcentu */
  --fav: #fbbf24;          /* złota gwiazdka ulubionych */
  --like: #3ccf7f;
  --like-soft: rgba(60, 207, 127, .14);

  --font: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --r-md: 12px;
  font-family: var(--font);
  color: var(--ink);
  font-optical-sizing: auto;
  --ink-soft: #c9d2db;
  --accent-ink: #5eead4;
  --map-bg: #242f3e;
  color-scheme: dark;
}

/* Jasny motyw: te same akcenty tramwajowe na chłodnym, jasnym tle */
[data-theme="light"] {
  --paper: #eef1f0;
  --card: #ffffff;
  --raise: #f3f5f4;
  --ink: #1e2630;
  --ink-soft: #3b4651;
  --muted: #5f6b76;
  --line: #dde2e0;
  --tram: #0d9488;
  --tram-soft: #ccfbf1;
  --sun: #14b8a6;
  --sun-soft: #e7faf6;
  --accent-ink: #0f766e;
  --on-accent: #ffffff;
  --fav: #f59e0b;
  --like: #187a44;
  --like-soft: #e6f4ec;
  --map-bg: #e8ece9;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; background: var(--paper); font-size: 15px; line-height: 1.4; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 4px; }

/* --- nagłówek ------------------------------------------------------------- */
.top {
  display: flex; align-items: center; gap: 14px 24px; flex-wrap: wrap;
  padding: 14px 20px 10px; background: var(--card);
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-mark {                      /* dwa pasy tramwaju: czerwony i żółty */
  width: 14px; height: 38px; border-radius: 4px;
  background: linear-gradient(var(--tram) 0 62%, var(--sun) 62% 100%);
}
.top h1 { margin: 0; font-size: 26px; font-weight: 750; letter-spacing: -0.02em; line-height: 1; }
.crawl { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.crawl.busy { color: var(--ink); }
.crawl.busy::before {              /* pulsująca kropka, dopóki skanowanie trwa */
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%;
  background: var(--tram); vertical-align: 1px; animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }

.when { display: flex; gap: 2px; background: var(--paper); padding: 3px; border-radius: 999px; }
.when button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--muted);
}
.when button:hover { color: var(--ink); }
.when button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.search {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 38px; width: 280px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--card);
}
.search:focus-within { border-color: var(--ink); }
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 14.5px; }

.score { font-size: 13.5px; color: var(--muted); display: flex; gap: 12px; }
.score b { color: var(--ink); font-weight: 650; }

/* --- filtry --------------------------------------------------------------- */
.filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 20px 12px; background: var(--card); border-bottom: 1px solid var(--line);
}
/* wybór kategorii: przycisk w stylu pozostałych pigułek + lista z ikonami */
.catpick { position: relative; }
.catpick-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px 0 13px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 13.5px;
}
.catpick-btn:hover, .catpick-btn[aria-expanded="true"] { color: var(--ink); border-color: var(--ink-soft); }
.catpick-btn.active { border-color: var(--sun); color: var(--accent-ink); background: var(--sun-soft); font-weight: 600; }
.catpick-btn:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.catpick-current { display: inline-flex; align-items: center; gap: 7px; }
.catpick-current .cat-badge { width: 20px; height: 20px; margin-left: -6px; box-shadow: none; }
.catpick-current .cat-badge svg { width: 11px; height: 11px; }
.catpick-chev { width: 16px; height: 16px; flex: none; transition: transform .15s ease; }
.catpick-btn[aria-expanded="true"] .catpick-chev { transform: rotate(180deg); }
.catpick-list {
  position: absolute; z-index: 50; top: calc(100% + 6px); left: 0; min-width: 240px;
  max-height: min(420px, 60vh); overflow-y: auto; margin: 0; padding: 6px; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
}
.catpick-list:focus { outline: none; }
.catpick-opt {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; cursor: pointer;
  font-size: 14px; color: var(--ink);
}
.catpick-opt .cat-badge { width: 26px; height: 26px; box-shadow: none; flex: none; }
.catpick-opt .cat-badge svg { width: 14px; height: 14px; }
.catpick-opt .cat-badge.any { border: 1.5px dashed var(--line); background: transparent; }
.catpick-opt small { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.catpick-opt:hover, .catpick-opt.hl { background: var(--raise); }
.catpick-opt[aria-selected="true"] { font-weight: 650; color: var(--accent-ink); }

/* „Za darmo” włączone: zakres cen nie ma znaczenia */
.price.disabled > :not(.price-unknown) { opacity: .4; transition: opacity .15s ease; }
.price.disabled:hover > :not(.price-unknown) { opacity: .6; }
.pill { position: relative; cursor: pointer; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
  display: inline-block; height: 32px; line-height: 29px; padding: 0 13px; font-size: 13.5px;
  border: 1.5px solid var(--line); border-radius: 999px; color: var(--muted); user-select: none;
}
.pill:hover span { color: var(--ink); }
.pill input:checked + span { border-color: var(--sun); color: var(--accent-ink); background: var(--sun-soft); font-weight: 600; }
.pill input:focus-visible + span { outline: 3px solid var(--sun); outline-offset: 2px; }
.price {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 12px;
  border: 1.5px solid var(--line); border-radius: 999px;
}
.price.active { border-color: var(--sun); }
.price-label { font-size: 13.5px; min-width: 76px; color: var(--muted); font-variant-numeric: tabular-nums; }
.price.active .price-label { color: var(--accent-ink); font-weight: 600; }
.price-track { position: relative; width: 150px; height: 20px; }
.price-track::before {
  content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 3px; border-radius: 2px; background: var(--line);
}
.price-fill { position: absolute; top: 9px; height: 3px; border-radius: 2px; background: var(--sun); }
.price-track input {
  position: absolute; inset: 0; width: 100%; margin: 0; background: transparent;
  -webkit-appearance: none; appearance: none; pointer-events: none;
}
.price-track input::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--sun); cursor: grab;
}
.price-track input::-moz-range-thumb {
  pointer-events: auto; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--sun); cursor: grab;
}
.price-track input::-webkit-slider-runnable-track { background: transparent; }
.price-track input::-moz-range-track { background: transparent; }
.price-track input:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--sun); outline-offset: 2px; }
.price-unknown { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.price-unknown input { accent-color: var(--sun); margin: 0; }

.count { margin-left: auto; font-size: 13px; color: var(--muted); }
.tabs { display: none; }

/* --- układ ---------------------------------------------------------------- */
.layout { flex: 1; display: grid; grid-template-columns: minmax(380px, 480px) 1fr; min-height: 0; }
.board { overflow-y: auto; background: var(--card); border-right: 1px solid var(--line); }
.mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--map-bg); }

/* --- tablica wydarzeń ----------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0 0 40px; }

.day {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: baseline; gap: 10px;
  padding: 16px 20px 8px; background: var(--card); border-bottom: 2px solid var(--ink);
}
.day-num { font-size: 34px; font-weight: 780; letter-spacing: -0.03em; line-height: 0.9; font-variant-numeric: tabular-nums; }
.day-name { font-size: 15px; font-weight: 600; }
.day-rel { font-size: 13px; color: var(--tram); font-weight: 600; }
.day.ongoing .day-num { font-size: 22px; }

.ev {
  position: relative; display: grid; grid-template-columns: 58px 34px 1fr auto; gap: 2px 12px;
  padding: 12px 16px 12px 20px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.ev:hover { background: var(--raise); }
.ev::before {                       /* pasek po lewej: stan wydarzenia */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent;
}
.ev.liked::before { background: var(--fav); }
.ev.selected { background: var(--sun-soft); }
.ev.selected::before { background: var(--sun); }
.ev.disliked .ev-main, .ev.disliked .ev-time { opacity: 0.45; }
.ev.leaving { opacity: 0; transform: translateX(-12px); transition: opacity .25s, transform .25s; }

.ev-time { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; line-height: 1.15; }
.ev-time.range { font-size: 14px; font-weight: 650; line-height: 1.25; }
.ev-time small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.ev-main { min-width: 0; }
.ev-title { font-size: 16px; font-weight: 650; line-height: 1.25; letter-spacing: -0.01em; }
.ev-meta { margin-top: 4px; font-size: 13.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 12px; }
.ev-cat { font-weight: 600; }
[data-theme="dark"] .ev-cat { filter: brightness(1.35); }

/* Odznaka kategorii: kolorowe kółko z białą ikonką */
.cat-badge {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .18);
}
.cat-badge svg {
  width: 19px; height: 19px; fill: none; stroke: #fff; stroke-width: 2.1;
  stroke-linecap: round; stroke-linejoin: round;
}
.ev-price.free { color: var(--like); font-weight: 600; }
.ev-nomap { font-style: italic; }

.ev-more { display: none; margin-top: 8px; font-size: 14px; color: var(--ink-soft); }
.ev.selected .ev-more, .ev.open .ev-more { display: block; }
.ev-desc { margin: 0 0 8px; max-width: 60ch; }
.ev-tags { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.ev-links { display: flex; flex-wrap: wrap; gap: 6px; }
.ev-links a {
  font-size: 13px; text-decoration: none; color: var(--ink); padding: 4px 10px;
  border: 1.5px solid var(--line); border-radius: 999px;
}
.ev-links a:hover { border-color: var(--ink); }
.ev-links a.gmaps { border-color: transparent; background: var(--tram-soft); color: var(--tram); }

.rate { display: flex; gap: 6px; align-self: start; }
.rate button {
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 50%; background: var(--card); color: var(--muted);
}
.rate button svg { width: 17px; height: 17px; }
.rate .like:hover { color: var(--like); border-color: var(--like); }
.rate .dislike:hover { color: var(--tram); border-color: var(--tram); }
.rate .like.on { background: var(--like); border-color: var(--like); color: #0f2a1b; }
.rate .dislike.on { background: var(--tram); border-color: var(--tram); color: #fff; }
.rate button:active { transform: scale(0.92); }

.empty { padding: 48px 24px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* --- mapa ----------------------------------------------------------------- */
.basemap {
  position: absolute; z-index: 500; top: 12px; right: 12px; display: flex; gap: 2px; padding: 3px;
  background: var(--card); border-radius: 999px; box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.basemap button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; color: var(--muted); }
.basemap button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.maplibregl-popup-content {
  background: var(--card); color: var(--ink); border-radius: var(--r-md); padding: 14px 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5); font-family: var(--font); max-height: min(380px, 55vh); overflow-y: auto;
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--card); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--card); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--card); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--card); }
.maplibregl-popup-close-button { color: var(--muted); font-size: 20px; padding: 2px 8px; }
.maplibregl-popup-close-button:hover { background: transparent; color: var(--ink); }
.maplibregl-ctrl-group { background: var(--card); }
.maplibregl-ctrl-group button + button { border-top-color: var(--line); }
[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-attrib { background: var(--card) !important; opacity: .85; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted); }
.maplibregl-popup-content { font-size: 14px; min-width: 250px; }
.pop-venue { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.pop-addr { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pop-gmaps { display: inline-block; margin-top: 6px; font-size: 13px; color: var(--tram); text-decoration: none; font-weight: 600; }
.pop-list { margin: 10px 0 0; padding: 0; list-style: none; }
.pop-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.pop-list .cat-badge { width: 30px; height: 30px; margin-top: 2px; }
.pop-list .cat-badge svg { width: 16px; height: 16px; }
.pop-body { flex: 1; min-width: 0; }
.pop-desc { margin: 4px 0 2px; font-size: 13px; line-height: 1.4; color: var(--ink-soft); }
.pop-when { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pop-title {
  color: var(--ink); font-weight: 650; text-decoration: underline; text-decoration-thickness: 1.5px;
  text-underline-offset: 3px; text-decoration-color: var(--accent-ink);
}
.pop-title:hover { text-decoration-thickness: 2.5px; }
.pop-title span { display: inline-block; margin-left: 2px; color: var(--accent-ink); font-size: 1.3em; font-weight: 800; line-height: 1; }
.pop-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; }
.pop-more {
  display: inline-flex; align-items: center; height: 30px; padding: 0 14px; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 650; text-decoration: none;
}
.pop-more:hover { opacity: .88; }
.pop-more:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.pop-actions .pop-link { display: inline; margin: 0; }
.pop-link { display: block; margin-top: 3px; font-size: 12.5px; color: var(--accent-ink); text-decoration: none; }
.pop-link:hover { text-decoration: underline; }
.pop-list .rate button { width: 30px; height: 30px; }
.pop-list .rate button svg { width: 14px; height: 14px; }

/* --- telefon: lista albo mapa, przełączane zakładkami --------------------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- ulubione ------------------------------------------------------------- */
.rate .fav:hover { color: var(--fav); border-color: var(--fav); }
.rate .fav.on { background: var(--fav); border-color: var(--fav); color: #3a2a00; }
.pill.fav span { display: inline-flex; align-items: center; gap: 6px; }
.pill.fav svg { width: 14px; height: 14px; }
.pill.fav b { font-weight: 700; }
.fav-mode .when, .fav-mode .filters > :is(.catpick, .pill-btn, .price, .pill:not(.fav)) { opacity: .35; pointer-events: none; }

/* trwające wydarzenie */
.ev-time small.live { color: var(--like); font-weight: 700; }
.ev-time small.live::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px;
  background: var(--like); vertical-align: 1px;
}

/* --- przycisk i okno „Ukryj kategorie” ------------------------------------ */
.pill-btn {
  height: 32px; padding: 0 13px; font-size: 13.5px; cursor: pointer; color: var(--muted);
  background: transparent; border: 1.5px solid var(--line); border-radius: 999px;
}
.pill-btn:hover { color: var(--ink); }
.pill-btn.active { border-color: var(--tram); color: var(--tram); }
.pill-btn b { font-weight: 700; }

.catdlg {
  width: min(620px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 16px;
  background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.catdlg::backdrop { background: rgba(10, 14, 19, .6); }
.catdlg form { padding: 18px 20px 16px; }
.catdlg-head { display: flex; align-items: center; justify-content: space-between; }
.catdlg h2 { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -0.01em; }
.catdlg h3 { margin: 22px 0 2px; font-size: 15px; font-weight: 650; }
.catdlg-hint { margin: 4px 0 12px; font-size: 13px; color: var(--muted); }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 50%; }
.icon-btn:hover { background: var(--raise); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--raise); color: var(--ink); font-size: 14px;
}
.chip.plain { padding-left: 12px; }
.catdlg-note { margin: 10px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.dev-box { margin-top: 22px; padding: 12px 14px 14px; border: 1.5px dashed var(--line); border-radius: 12px; }
.dev-box h3 { margin-top: 0; }
.dev-box .link-btn { margin-top: 10px; }
.chip .cat-badge { width: 26px; height: 26px; box-shadow: none; }
.chip .cat-badge svg { width: 14px; height: 14px; }
.chip small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--ink-soft); }
/* ukryte: przekreślone, przygaszone, z ikoną przekreślonego oka */
.chip.off { padding-left: 10px; background: transparent; border-style: dashed; color: var(--muted); }
.chip.off span { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: currentColor; }
.chip .chip-off { width: 18px; height: 18px; flex: none; color: var(--muted); }
.chip:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

.catdlg-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.link-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13.5px; text-decoration: underline; padding: 0; }
.link-btn:hover { color: var(--ink); }
.done-btn {
  border: 0; background: var(--ink); color: var(--paper); font-weight: 650; padding: 9px 18px;
  border-radius: 999px; cursor: pointer; font-size: 14px;
}

.empty.offline { text-align: center; padding: 64px 28px; }
.empty.offline p { max-width: 34ch; margin: 6px auto 18px; line-height: 1.5; }
.empty.offline .done-btn { min-width: 180px; }
.empty .help { margin: 12px 0; padding-left: 20px; line-height: 1.5; }
.empty .help li { margin-bottom: 8px; }
.empty a { color: var(--accent-ink); }
.empty code { background: var(--raise); padding: 1px 6px; border-radius: 4px; font-size: 13px; }


/* --- przełącznik motywu -------------------------------------------------- */
.theme { display: flex; gap: 2px; background: var(--paper); padding: 3px; border-radius: 999px; }
.theme button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  font-size: 13px; color: var(--muted);
}
.theme button:hover { color: var(--ink); }
.theme button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* --- „teraz” i powrót do wcześniejszych ---------------------------------- */
.board { position: relative; }
.now-line {
  display: flex; align-items: center; gap: 10px; padding: 6px 20px; color: var(--tram);
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.now-line::after { content: ""; flex: 1; height: 2px; background: var(--tram); border-radius: 2px; }

/* --- kalendarzyk: konkretny dzień ---------------------------------------- */
.when .day-pick {
  position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--muted);
}
.day-pick svg { width: 16px; height: 16px; flex: none; }
.when .day-pick:hover, .day-pick[aria-expanded="true"] { color: var(--ink); }
.when .day-pick.active { background: var(--ink); color: var(--paper); }
.day-pick:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

.cal {
  position: fixed; z-index: 1200; width: 300px; padding: 12px 12px 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .45);
}
.cal[hidden] { display: none; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-size: 15px; font-weight: 700; }
.cal-nav {
  display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink); cursor: pointer;
}
.cal-nav svg { width: 18px; height: 18px; transform: rotate(90deg); }
.cal-nav.next svg { transform: rotate(-90deg); }
.cal-nav:hover:not(:disabled) { background: var(--raise); }
.cal-nav:disabled { opacity: .25; cursor: default; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-week span { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.cal-grid button {
  height: 38px; border: 0; border-radius: 50%; background: transparent; color: var(--ink);
  font-size: 14px; font-variant-numeric: tabular-nums; cursor: pointer;
}
.cal-grid button.wknd { color: var(--accent-ink); }
.cal-grid button:hover:not(:disabled) { background: var(--raise); }
.cal-grid button.today { box-shadow: inset 0 0 0 1.5px var(--ink-soft); font-weight: 700; }
.cal-grid button.sel { background: var(--sun); color: var(--on-accent); font-weight: 700; box-shadow: none; }
.cal-grid button:disabled { color: var(--muted); opacity: .35; cursor: default; }
.cal-grid button:focus-visible { outline: 3px solid var(--sun); outline-offset: 1px; }
@media (max-width: 820px) {
  .cal { width: min(340px, calc(100vw - 24px)); }
  .cal-grid button { height: 42px; font-size: 15px; }
}

/* link do podstrony wydarzenia */
.ev-links a.details { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* =========================================================================
   Elementy tylko dla telefonu: domyślnie ukryte
   ========================================================================= */
.filters-btn, .view-fab, .sheet-backdrop, .sheet-head, .sheet-label, .sheet-foot, .theme-sheet, .list-meta { display: none; }
.filters-btn .badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--sun); color: var(--on-accent);
  font-size: 12px; font-weight: 750; display: inline-grid; place-items: center;
}
.filters-btn .badge[hidden] { display: none; }

/* =========================================================================
   Telefon: jeden wiersz u góry, filtry w panelu od dołu, przełącznik mapy w rogu
   ========================================================================= */
@media (max-width: 820px) {
  body { font-size: 15px; }

  /* nagłówek: [pasek marki] [szukaj……] [Filtry], pod spodem przewijany pasek dat */
  .top {
    display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
    padding: 10px 12px 8px; padding-top: max(10px, env(safe-area-inset-top));
  }
  .brand { margin: 0; gap: 0; order: 0; }
  .search { order: 1; }
  .filters-btn { order: 2; }
  .when { order: 3; }
  .brand > div { display: none; }
  .brand-logo { width: 36px; height: 36px; }
  .search { width: auto; height: 42px; min-width: 0; }
  .search input { font-size: 16px; }          /* 16 px: iPhone nie przybliża strony przy pisaniu */
  .theme-top { display: none; }

  .filters-btn {
    display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 14px; cursor: pointer;
    border: 1.5px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink);
    font-size: 14.5px; font-weight: 600;
  }
  .filters-btn svg { width: 18px; height: 18px; }
  .filters-btn.active { border-color: var(--sun); }

  .when {
    grid-column: 1 / -1; width: auto; margin: 0 -12px; padding: 2px 12px; gap: 6px;
    background: transparent; border-radius: 0; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .when::-webkit-scrollbar { display: none; }
  .when button, .day-pick {
    flex: none; white-space: nowrap; height: 36px; padding: 0 14px; font-size: 14px;
    border: 1.5px solid var(--line); border-radius: 999px;
  }
  .when button[aria-pressed="true"], .day-pick.active { border-color: var(--ink); }
  /* kolejność na telefonie: Dziś, kalendarz, potem reszta */
  .when > * { order: 2; }
  .when button[data-preset="today"] { order: 0; }
  .when .day-pick { order: 1; }
  /* zanikające krawędzie: widać, że pasek dat da się przesunąć */
  .when.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
                     mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
  .when.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent);
                    mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent); }
  .when.more-left.more-right {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
  }

  .list-meta { display: block; margin: 0; padding: 10px 16px 6px; font-size: 13px; color: var(--muted); }

  /* --- panel filtrów ----------------------------------------------------- */
  .sheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 900; background: rgba(8, 11, 15, .55);
    opacity: 0; transition: opacity .25s ease;
  }
  .sheet-open .sheet-backdrop { opacity: 1; }
  .sheet-backdrop[hidden] { display: none; }

  .filters {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start;
    max-height: 86dvh; overflow-y: auto; overscroll-behavior: contain;
    padding: 0 16px calc(16px + env(safe-area-inset-bottom));
    background: var(--card); border: 0; border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .35);
    transform: translateY(105%); visibility: hidden;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
  }
  .sheet-open .filters { transform: none; visibility: visible; transition: transform .3s cubic-bezier(.2, .8, .2, 1); }
  .filters > * { grid-column: 1 / -1; }

  .sheet-head {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 2;
    margin: 0 -16px; padding: 18px 12px 6px 18px; background: var(--card);
  }
  .sheet-head h2 { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -0.01em; }
  .grabber {
    position: absolute; top: 7px; left: 50%; width: 38px; height: 5px; margin-left: -19px;
    border-radius: 3px; background: var(--line);
  }
  .sheet-label { display: block; margin: 10px 0 -2px; font-size: 14px; font-weight: 650; color: var(--muted); }

  .filters .pill { grid-column: auto; }
  .filters .pill span {
    display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 46px;
    line-height: 1.2; padding: 0 10px; text-align: center; font-size: 14.5px; border-radius: 14px;
  }
  .filters .pill.fav svg { width: 15px; height: 15px; }
  .filters .catpick-btn, .filters .pill-btn {
    width: 100%; height: 46px; border-radius: 14px; font-size: 15px; padding: 0 14px; text-align: left;
  }
  .filters .catpick-btn { justify-content: space-between; }
  /* w panelu na telefonie lista rozwija się pod przyciskiem, zamiast wisieć nad nim */
  .filters .catpick-list { position: static; margin-top: 6px; max-height: 46dvh; box-shadow: none; }
  .filters .catpick-opt { padding: 9px 10px; font-size: 15px; }
  /* kolejność w panelu: wydarzenia, kategorie, cena, wygląd */
  .sheet-head { order: 0; }
  .sheet-label[data-for="events"] { order: 1; }
  .filters .pill.fav { order: 2; }
  .filters .pill:has(#for_me) { order: 3; }
  .filters .pill:has(#free) { order: 4; }
  .sheet-label[data-for="cats"] { order: 6; }
  .filters .catpick { order: 7; }
  .filters .pill-btn { order: 8; }
  .sheet-label[data-for="price"] { order: 9; }
  .filters .price { order: 10; }
  .sheet-label[data-for="theme"] { order: 11; }
  .theme-sheet { order: 12; }
  .filters .count { display: none; }
  .sheet-foot { order: 13; }

  .filters .price {
    height: auto; flex-wrap: wrap; gap: 10px 14px; padding: 14px 16px; border-radius: 14px;
  }
  .filters .price-label { min-width: 0; width: 100%; font-size: 15px; }
  .filters .price-track { flex: 1; width: auto; }
  .filters .price-track input::-webkit-slider-thumb { width: 24px; height: 24px; }
  .filters .price-unknown { font-size: 13.5px; }

  .theme-sheet { display: flex; padding: 4px; border-radius: 14px; }
  .theme-sheet button { flex: 1; height: 40px; font-size: 14.5px; border-radius: 11px; }

  .sheet-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); margin: 8px -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--card);
    border-top: 1px solid var(--line);
  }
  .sheet-foot .link-btn { font-size: 15px; }
  .sheet-foot .done-btn { flex: 1; max-width: 260px; height: 48px; font-size: 15.5px; border-radius: 14px; }

  /* --- lista i mapa: jedno albo drugie, przełączane przyciskiem w rogu ---- */
  /* Przewija się cała strona, nie wewnętrzne okienko: wtedy iPhone przewija listę do góry po stuknięciu
     w pasek z godziną. Górny pasek stoi w miejscu i nie da się go pociągnąć w pionie (tylko daty w bok). */
  html, body { height: auto; min-height: 100%; }
  html { overscroll-behavior-y: none; }
  body { display: block; }
  .top { position: sticky; top: 0; z-index: 700; touch-action: pan-x; }
  .layout { display: block; }
  .board { border-right: 0; overflow: visible; }
  .day { top: var(--top-h, 0px); }
  .layout[data-view="list"] .mapwrap { display: none; }
  .layout[data-view="map"] .board { display: none; }
  .layout[data-view="map"] .mapwrap { position: fixed; top: var(--top-h, 0px); left: 0; right: 0; bottom: 0; }
  .list { padding-bottom: 96px; }

  .view-fab {
    display: inline-flex; align-items: center; gap: 8px; position: fixed; z-index: 800;
    left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom));
    height: 48px; padding: 0 20px; border: 0; border-radius: 999px; cursor: pointer;
    background: var(--ink); color: var(--paper); font-size: 15px; font-weight: 650;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  }
  .view-fab svg { width: 19px; height: 19px; }
  .sheet-open .view-fab { display: none; }

  .day { padding: 14px 16px 8px; }
  .day-num { font-size: 30px; }
  .ev { grid-template-columns: 46px 30px 1fr auto; gap: 2px 10px; padding: 12px 12px 12px 16px; }
  .ev .cat-badge { width: 30px; height: 30px; }
  .ev .cat-badge svg { width: 16px; height: 16px; }
  .ev-time { font-size: 16px; }
  .ev-title { font-size: 15.5px; }
  .ev .rate button { width: 34px; height: 34px; }
  .now-line { padding: 6px 16px; }
}

/* kompas: tylko gdy mapa jest obrócona */
.maplibregl-ctrl-compass { display: none !important; }
.map-rotated .maplibregl-ctrl-compass { display: block !important; }

/* logo: pinezka z Pałacem Kultury */
.brand-logo { display: block; width: 40px; height: 40px; flex: none; color: var(--accent-ink); }
.brand-logo .cut { fill: var(--card); }   /* panorama wycięta w kolorze tła nagłówka */

/* --- lokalizacja użytkownika ---------------------------------------------- */
.user-dot {
  width: 16px; height: 16px; border-radius: 50%; background: #2f7bf6; border: 3px solid #fff;
  box-shadow: 0 0 0 0 rgba(47, 123, 246, .45), 0 1px 4px rgba(0, 0, 0, .4);
  animation: user-pulse 2.4s ease-out infinite;
}
@keyframes user-pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 123, 246, .45), 0 1px 4px rgba(0, 0, 0, .4); }
  70% { box-shadow: 0 0 0 16px rgba(47, 123, 246, 0), 0 1px 4px rgba(0, 0, 0, .4); }
  100% { box-shadow: 0 0 0 0 rgba(47, 123, 246, 0), 0 1px 4px rgba(0, 0, 0, .4); }
}
.locate-btn { display: grid !important; place-items: center; color: var(--ink); }
.locate-btn svg { width: 18px; height: 18px; }
.locate-btn.on { color: #2f7bf6; }
.locate-btn.busy svg { animation: locate-spin 1s linear infinite; }
@keyframes locate-spin { to { transform: rotate(360deg); } }
.map-toast {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 5;
  width: max-content; max-width: min(340px, calc(100% - 32px)); padding: 10px 14px; border-radius: 12px;
  background: var(--ink); color: var(--paper); font-size: 13.5px; line-height: 1.35; text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}

/* zaproszenie do dodania własnego wydarzenia: na końcu listy i pod podstroną wydarzenia */
.add-cta { list-style: none; padding: 26px 20px 34px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.add-cta a { color: var(--accent-ink); font-weight: 600; }
.event-cta { width: min(720px, 100%); margin: 0 auto; box-sizing: border-box; }
.dev-link { display: block; margin: 4px 0 10px; color: var(--accent-ink); font-weight: 600; font-size: 15px; }
