/* Dokąd teraz? Hiszpania – mapy wyjazdu
   Układ: telefon = mapa u góry (lepka), panel z listą pod spodem;
   tablet/komputer = mapa po lewej, panel 430 px po prawej. */

@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("fonts/poppins-regular.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url("fonts/poppins-medium.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-display: swap; src: url("fonts/poppins-bold.woff") format("woff"); }

:root {
  --navy: #151C33;
  --navy-2: #232C4A;
  --bg: #F4F5F9;
  --surface: #FFFFFF;
  --surface-2: #EEF1FA;
  --ink: #1C2238;
  --muted: #646B82;
  --line: #E1E4EE;
  --accent: #6F86E0;
  --accent-ink: #3E56B8;
  --gold: #C9A24A;
  --gold-bg: #F7EFD9;
  --gold-ink: #5B4A22;
  --ok: #2F9468;
  --ok-bg: #E3F4EC;
  --warn-bg: #FDF1DE;
  --warn-ink: #7A4B0B;
  --danger: #C2413B;
  --shadow: 0 6px 24px rgba(21, 28, 51, .14);
  --radius: 16px;
  --font: "Poppins", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --header-h: 56px;
  --daybar-h: 54px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1222; --surface: #161D33; --surface-2: #1F2843; --ink: #E9ECF6; --muted: #9AA2BD;
    --line: #2A3352; --accent: #8EA2EE; --accent-ink: #B4C2F6; --gold-bg: #3A3220; --gold-ink: #EBD49A;
    --ok: #4CC08D; --ok-bg: #173A2C; --warn-bg: #3B2C14; --warn-ink: #F2CD8F; --danger: #EF6C64;
    --shadow: 0 6px 24px rgba(0, 0, 0, .45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1222; --surface: #161D33; --surface-2: #1F2843; --ink: #E9ECF6; --muted: #9AA2BD;
  --line: #2A3352; --accent: #8EA2EE; --accent-ink: #B4C2F6; --gold-bg: #3A3220; --gold-ink: #EBD49A;
  --ok: #4CC08D; --ok-bg: #173A2C; --warn-bg: #3B2C14; --warn-ink: #F2CD8F; --danger: #EF6C64;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Pasek górny ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; flex-shrink: 0; }
.brand-mark { color: var(--gold); display: grid; place-items: center; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-size: 15px; font-weight: 700; }
.brand-text span { font-size: 11px; color: #C9D2F5; letter-spacing: .04em; }
.topbar-title { flex: 1; min-width: 0; text-align: right; font-weight: 500; font-size: 14px; color: #E8C66A; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(255,255,255,.08); color: #fff; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,.16); }

/* ---------- Ekran startowy ---------- */
.home { padding: 32px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
.home-inner { max-width: 760px; margin: 0 auto; }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.home h1 { margin: 0 0 8px; font-size: clamp(30px, 7vw, 44px); line-height: 1.1; text-wrap: balance; }
.home-lead { margin: 0 0 24px; color: var(--muted); max-width: 60ch; }
.city-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.city-card { display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); min-height: 120px; }
.city-card b { font-size: 22px; line-height: 1.15; }
.city-card .meta { color: var(--muted); font-size: 13px; }
.city-card .tag { align-self: flex-start; margin-top: auto; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px; background: var(--gold-bg); color: var(--gold-ink); }
a.city-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.city-card.soon { opacity: .6; }

/* ---------- Pasek dni ---------- */
.daybar { position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top, 0px)); z-index: 900; background: var(--surface); border-bottom: 1px solid var(--line); }
.daybar-inner { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; height: var(--daybar-h); align-items: center; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.daybar-inner::-webkit-scrollbar { display: none; }
.day-tab { flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; }
.day-tab .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--navy)); }
.day-tab .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-tab[aria-selected="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.day-tab[aria-selected="true"] .count { color: #C9D2F5; }
:root[data-theme="dark"] .day-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #0D1222; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .day-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #0D1222; } }
.day-tab.done .dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ok); }

/* ---------- Układ ---------- */
.layout { display: block; }
.map-wrap { position: sticky; top: calc(var(--header-h) + var(--daybar-h) + env(safe-area-inset-top, 0px)); z-index: 1; height: 44vh; height: 44svh; min-height: 260px; background: var(--surface-2); }
#map { position: absolute; inset: 0; background: var(--surface-2); }
.panel { position: relative; z-index: 2; background: var(--bg); border-radius: 20px 20px 0 0; margin-top: -16px; box-shadow: 0 -8px 24px rgba(21,28,51,.10); }
.panel-inner { display: flex; flex-direction: column; gap: 14px; padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(32px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); max-width: 720px; margin: 0 auto; }
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; height: calc(100vh - var(--header-h) - var(--daybar-h) - env(safe-area-inset-top, 0px)); }
  .map-wrap { position: relative; top: 0; height: 100%; }
  .panel { margin: 0; border-radius: 0; box-shadow: none; border-left: 1px solid var(--line); overflow-y: auto; }
}

.map-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); z-index: 5; }
.map-controls { position: absolute; z-index: 500; right: max(10px, env(safe-area-inset-right, 0px)); bottom: 28px; display: flex; flex-direction: column; gap: 8px; }
.map-btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); cursor: pointer; font-size: 13px; font-weight: 500; }
.map-btn[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.map-btn span { display: none; }
@media (min-width: 520px) { .map-btn span { display: inline; } }
.geo-status { position: absolute; z-index: 500; left: 10px; right: 64px; top: 10px; padding: 8px 12px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); font-size: 13px; }

/* ---------- Karty w panelu ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.summary h2 { margin: 0; font-size: 20px; line-height: 1.2; text-wrap: balance; }
.summary .sub { margin: 2px 0 10px; color: var(--muted); font-size: 13px; }
.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--c, var(--accent)); transition: width .35s ease; }
.progress-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-row b { color: var(--ink); font-weight: 600; }
.trip-line { margin: 10px 0 0; font-size: 13.5px; }
.mini-days { display: grid; gap: 8px; margin-top: 12px; }
.mini-day { display: grid; grid-template-columns: 70px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.mini-day .progress { height: 7px; }
.mini-day span:last-child { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent; cursor: pointer; font-weight: 500; font-size: 14px; text-decoration: none; text-align: center; line-height: 1.2; }
.btn svg { flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-navy { background: var(--navy); color: #fff; }
:root[data-theme="dark"] .btn-navy { background: #2C3760; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-navy { background: #2C3760; } }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.next .card { display: grid; gap: 10px; }
.next-label { font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.next-name { font-size: 16px; font-weight: 700; line-height: 1.25; }
.next-done { display: flex; gap: 10px; align-items: center; color: var(--ok); font-weight: 500; }

.route h3, .favs h3, .eat h3 { margin: 0 0 6px; font-size: 15px; }
.route-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 10px; font-size: 13.5px; color: var(--muted); }
.route-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.segments { display: grid; gap: 6px; margin-top: 10px; }
.segment { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px; text-decoration: none; color: var(--ink); }
.segment span { min-width: 0; }
.segment em { font-style: normal; color: var(--muted); }
.segment svg { flex-shrink: 0; color: var(--accent-ink); }
.notice { padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }
details.more summary { cursor: pointer; font-size: 13px; color: var(--accent-ink); font-weight: 500; }

.daynote .notice { font-size: 13.5px; }
.intro p { margin: 0; color: var(--muted); font-size: 14px; }
.intro .walk { margin-top: 6px; font-size: 13px; }

/* ---------- Checklista ---------- */
.checklist { display: grid; gap: 0; }
.checklist h3 { margin: 4px 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.checklist h3 .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.item { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 4px 10px; padding: 10px 10px 10px 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.item.is-next { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.item.is-visited { background: var(--ok-bg); border-color: transparent; }
.item.is-skipped { opacity: .62; }
.item.is-skipped .item-name { text-decoration: line-through; }
.check { position: relative; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; }
.check input { position: absolute; opacity: 0; width: 44px; height: 44px; margin: 0; cursor: pointer; }
.check .box { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted); display: grid; place-items: center; background: var(--surface); transition: background .15s, border-color .15s; }
.check .box svg { opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s; }
.check input:checked + .box { background: var(--ok); border-color: var(--ok); }
.check input:checked + .box svg { opacity: 1; transform: none; }
.check input:focus-visible + .box { outline: 3px solid var(--accent); outline-offset: 2px; }
.item-main { min-width: 0; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; display: grid; gap: 1px; }
.item-top { display: flex; align-items: center; gap: 8px; }
.num { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--c); }
.item-name { font-weight: 500; font-size: 14.5px; line-height: 1.25; overflow-wrap: anywhere; }
.item-meta { font-size: 12.5px; color: var(--muted); padding-left: 32px; font-variant-numeric: tabular-nums; }
.item-meta .changed { color: var(--warn-ink); }
.item-side { display: flex; align-items: center; gap: 2px; }
.mini-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--muted); text-decoration: none; }
.mini-btn:hover { background: var(--surface-2); color: var(--ink); }
.mini-btn.fav-on { color: var(--gold); }
.leg { display: flex; align-items: center; gap: 8px; padding: 6px 0 6px 26px; font-size: 12.5px; color: var(--muted); }
.leg::before { content: ""; width: 2px; align-self: stretch; min-height: 18px; background: var(--c); opacity: .5; border-radius: 2px; margin-right: 8px; }
.leg.transit::before { background: repeating-linear-gradient(var(--c) 0 4px, transparent 4px 7px); }
.tag-skip { font-size: 11px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

.eat .card, .favs .card { font-size: 14px; }
.fav-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.fav-list button { width: 100%; display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; border: 0; background: var(--surface-2); cursor: pointer; text-align: left; font-size: 13.5px; }

.panel-foot { display: grid; gap: 10px; font-size: 12.5px; color: var(--muted); }
.panel-foot .btn-row .btn { font-size: 13px; min-height: 40px; }
.panel-foot p { margin: 0; }

/* ---------- Karta atrakcji (arkusz) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 2000; background: rgba(13, 18, 34, .45); }
.sheet {
  position: fixed; z-index: 2001; left: 0; right: 0; bottom: 0; max-height: 86vh; max-height: 86svh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 8px max(18px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  animation: up .22s ease-out;
}
@media (min-width: 900px) { .sheet { left: auto; right: 24px; bottom: 24px; width: 420px; border-radius: 22px; max-height: calc(100vh - 140px); } }
@keyframes up { from { transform: translateY(32px); } to { transform: none; } }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; }
.sheet-head .num { width: 36px; height: 36px; font-size: 15px; }
.sheet-head h2 { margin: 0; font-size: 20px; line-height: 1.2; text-wrap: balance; }
.sheet-head .day-label { font-size: 12px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.close-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--surface-2); display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.fact { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.fact b { font-weight: 600; }
.state-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; font-size: 13px; font-weight: 500; background: var(--ok-bg); color: var(--ok); }
.state-pill.skip { background: var(--surface-2); color: var(--muted); }
.sheet p.desc { margin: 10px 0; font-size: 14.5px; }
.info { padding: 10px 12px; border-radius: 12px; font-size: 13.5px; margin: 8px 0; }
.info b { display: block; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 2px; }
.info.tip { background: var(--surface-2); }
.info.tip b { color: var(--accent-ink); }
.info.ticket { background: var(--gold-bg); color: var(--gold-ink); }
.info.practical { background: var(--surface-2); }
.info.practical b { color: var(--muted); }
.info.changed { background: var(--warn-bg); color: var(--warn-ink); }
.sheet-actions { display: grid; gap: 8px; margin-top: 14px; }
.sheet-actions .btn-row { grid-template-columns: 1fr 1fr; }
.arrive { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
.src { font-size: 11.5px; color: var(--muted); margin-top: 10px; }

/* ---------- Okno potwierdzenia, komunikat ---------- */
.dialog-backdrop { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 16px; background: rgba(13, 18, 34, .55); }
.dialog { width: min(420px, 100%); background: var(--surface); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
.dialog h2 { margin: 0 0 6px; font-size: 18px; }
.dialog p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; z-index: 2500; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); width: max-content; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; background: var(--navy); color: #fff; font-size: 14px; box-shadow: var(--shadow); animation: up .2s ease-out; }
.toast.big { background: var(--ok); }

/* ---------- Znaczniki na mapie ---------- */
.pin-wrap { background: none; border: 0; }
.pin { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; font: 700 13px/1 var(--font); border: 2.5px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); transition: transform .15s; }
.pin.visited { background: #fff; color: var(--c); border-color: var(--c); }
.pin.visited::after { content: ""; position: absolute; right: -4px; top: -4px; width: 14px; height: 14px; border-radius: 50%; background: #2F9468 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.2 4.2L19 7' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/10px no-repeat; border: 1.5px solid #fff; }
.pin { position: relative; }
.pin.skipped { background: #9AA0B4; border-style: dashed; opacity: .8; }
.pin.next { transform: scale(1.18); }
.pin.next::before { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 3px solid var(--c); opacity: .55; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { from { transform: scale(.7); opacity: .7; } to { transform: scale(1.35); opacity: 0; } }
.pin.dim { opacity: .35; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1A73E8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26,115,232,.25); }

.leaflet-container { font-family: var(--font); background: var(--surface-2); }
.leaflet-control-attribution { font-size: 10.5px; }
:root[data-theme="dark"] .tiles-dark-filter { filter: invert(1) hue-rotate(185deg) brightness(.95) contrast(.88) saturate(.7); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tiles-dark-filter { filter: invert(1) hue-rotate(185deg) brightness(.95) contrast(.88) saturate(.7); } }
:root[data-theme="dark"] .leaflet-bar a, :root[data-theme="dark"] .leaflet-control-attribution { background: var(--surface); color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-bar a, :root:not([data-theme="light"]) .leaflet-control-attribution { background: var(--surface); color: var(--ink); } }
.leaflet-control-attribution a { color: var(--accent-ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
