/* ================================================================
   Frischmarkt · Pokonaj algorytm
   ================================================================ */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --line: #e7e3db;
  --line-2: #d6d1c6;
  --text: #1d2320;
  --muted: #646b67;
  --faint: #9aa19c;
  --brand: #00a88b;
  --brand-ink: #00745f;
  --brand-soft: #e2f5f0;
  --fm: #00c9a7;
  --warn: #e3830b;
  --warn-soft: #fdf0dc;
  --bad: #d63c3c;
  --bad-soft: #fbe5e3;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow: 0 1px 2px rgba(25, 35, 30, 0.06), 0 6px 20px rgba(25, 35, 30, 0.08);
  --gap: 16px;
  --top: 72px;
  --left-w: 340px;
  --right-w: 300px;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 400 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
body.intro-open { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
a { color: var(--brand-ink); }

/* ---------------------------------------------------------------- aplikacja (pełny ekran) */
#app { position: relative; height: 100vh; height: 100dvh; overflow: hidden; }
#map { position: absolute; inset: 0; }

.card {
  position: absolute; z-index: 5;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.label { font-size: 12px; font-weight: 500; color: var(--muted); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hint { color: var(--faint); font-size: 12px; margin-top: 3px; line-height: 1.35; }
.sub { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- górny pasek */
.topbar {
  top: var(--gap); left: var(--gap); right: var(--gap); height: 56px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 10px 0 14px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 32px; height: 32px; color: var(--brand); flex: none; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.1; letter-spacing: -0.01em; }
.brand-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.modes { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: #efece5; }
.modes button {
  border: 0; background: transparent; padding: 7px 16px; border-radius: 8px;
  font-weight: 500; font-size: 13.5px; color: var(--muted); transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.modes button:hover { color: var(--text); }
.modes button[aria-selected='true'] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.btn-method {
  justify-self: end; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px 0 18px;
  border-radius: 10px; background: var(--brand); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
  box-shadow: 0 2px 8px rgba(0, 168, 139, 0.35); transition: background 0.15s, transform 0.15s;
}
.btn-method:hover { background: #00967c; }
.btn-method svg { width: 16px; height: 16px; animation: nudge 1.8s ease-in-out infinite; }
.btn-method .short { display: none; }
@keyframes nudge { 0%, 100% { transform: translateY(-1px); } 50% { transform: translateY(2px); } }

/* ---------------------------------------------------------------- panele */
.panel {
  top: calc(var(--top) + 10px); max-height: calc(100% - var(--top) - 10px - var(--gap));
  overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; display: flex; flex-direction: column;
}
#panel-left { left: var(--gap); width: var(--left-w); }
#panel-right { right: var(--gap); width: var(--right-w); max-height: calc(100% - var(--top) - 10px - 110px); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.coords { font-size: 11.5px; color: var(--faint); white-space: nowrap; background: none; border: 0; padding: 2px 0; font-variant-numeric: tabular-nums; }
.coords:hover { color: var(--brand-ink); text-decoration: underline; }
.sec { padding: 13px 16px; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 7px; }
.seg button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-align: left; transition: border-color 0.15s, background 0.15s;
}
.seg b { font-weight: 600; font-size: 13px; }
.seg span { font-size: 11.5px; color: var(--faint); }
.seg button:hover { border-color: var(--line-2); }
.seg button[aria-checked='true'] { border-color: var(--brand); background: var(--brand-soft); }
.seg button[aria-checked='true'] span { color: var(--brand-ink); }

.big { font-size: 46px; font-weight: 700; line-height: 1.05; letter-spacing: -0.03em; margin-top: 2px; }
.sec-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.stat { min-width: 0; }
.stat .val { font-size: 19px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color 0.2s; }
.stat .sub { line-height: 1.3; margin-top: 1px; overflow-wrap: anywhere; }
.stat.wide { grid-column: 1 / -1; }
#kpi-district { font-size: 16px; }
#kpi-near.too-close { color: var(--bad); }
#kpi-near.close { color: var(--warn); }
.dist-scale { position: relative; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 2px; height: 5px; margin: 6px 0 5px; }
.dist-scale i { display: block; border-radius: 2px; }
.dist-scale .z1 { background: var(--bad); opacity: 0.85; }
.dist-scale .z2 { background: var(--warn); opacity: 0.85; }
.dist-scale .z3 { background: var(--line-2); }
.dist-scale b { position: absolute; top: -3px; width: 3px; height: 11px; margin-left: -1.5px; border-radius: 2px; background: var(--text); left: 0; transition: left 0.3s; }

.bar { position: relative; height: 10px; margin: 9px 0 6px; border-radius: 5px; background: #ece9e2; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 5px; background: var(--brand); transition: width 0.35s cubic-bezier(.2, .8, .2, 1), background 0.2s; }
.bar-mark { position: absolute; left: 80%; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--text); }
.bar-mark span { position: absolute; top: -17px; left: 50%; transform: translateX(-50%); font-size: 10.5px; font-weight: 600; color: var(--muted); }
.sec-versus.warn .bar-fill { background: var(--warn); }
.pct { font-size: 13px; font-weight: 600; }
.verdict { margin: 7px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); min-height: 36px; }
.verdict.win { color: var(--brand-ink); font-weight: 600; }
.verdict.warn { color: #b0620a; }
.verdict.tie { color: var(--text); font-weight: 600; }

.loss-bars { display: flex; flex-direction: column; gap: 5px; margin-top: 9px; }
.lrow { display: grid; grid-template-columns: 62px 1fr 54px; align-items: center; gap: 8px; font-size: 12.5px; transition: opacity 0.3s; }
.lrow .n { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .t { height: 8px; background: #f0ede7; border-radius: 3px; overflow: hidden; }
.lrow .f { display: block; height: 100%; width: 0; border-radius: 3px; transition: width 0.35s cubic-bezier(.2, .8, .2, 1); }
.lrow .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.lrow.zero { opacity: 0.35; }

/* ---------------------------------------------------------------- scenariusze (zwijane) */
#panel-right { overflow: hidden; }
#panel-right.collapsed { width: auto; }
#panel-right.collapsed .pt-title { white-space: nowrap; }
.panel-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 14px 13px 16px; border: 0; background: none; text-align: left;
}
.pt-title { font-weight: 700; font-size: 14.5px; flex: 1; }
.pt-tags { display: flex; gap: 3px; }
.pt-tags i { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 5px; border-radius: 5px; background: #efece5; color: var(--muted); }
.pt-tags i.k1 { background: var(--brand-soft); color: var(--brand-ink); }
.chev { width: 16px; height: 16px; color: var(--muted); transition: transform 0.2s; }
#panel-right:not(.collapsed) .chev { transform: rotate(180deg); }
#panel-right:not(.collapsed) .panel-toggle { border-bottom: 1px solid var(--line); }
.panel-body { overflow-y: auto; scrollbar-width: thin; }
#panel-right.collapsed .panel-body { display: none; }
.pb-intro { margin: 0; padding: 12px 16px 0; font-size: 12.5px; color: var(--muted); }
.cards { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); }
.card-btn {
  display: block; width: 100%; text-align: left; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.card-btn:hover { border-color: var(--line-2); background: var(--surface-2); }
.card-btn.active { border-color: var(--brand); background: var(--brand-soft); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.tag { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: #efece5; }
.rec { font-size: 11px; font-weight: 700; color: #fff; background: var(--brand); padding: 3px 8px; border-radius: 6px; }
.card-name { font-weight: 700; font-size: 15.5px; margin-top: 7px; line-height: 1.15; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-num { font-size: 19px; font-weight: 700; margin-top: 5px; }
.card-num small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.stack { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin: 8px 0 6px; background: #efece5; }
.stack i { display: block; height: 100%; }
.card-losses { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.card-text { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--muted); }

.shares { display: flex; flex-direction: column; gap: 4px; margin-top: 9px; }
.srow { display: grid; grid-template-columns: 58px 1fr 44px; gap: 8px; align-items: center; font-size: 12px; }
.srow .n { color: var(--muted); }
.srow .t { height: 7px; }
.srow .f { display: block; height: 100%; border-radius: 3px; }
.srow .v { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- legenda */
.legend {
  bottom: var(--gap); left: calc(var(--left-w) + 2 * var(--gap)); right: 64px;
  width: max-content; max-width: calc(100% - var(--left-w) - 2 * var(--gap) - 64px); margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 12px; padding: 8px 12px; font-size: 12px;
}
.legend .label { margin-right: 2px; font-weight: 600; color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); white-space: nowrap; }
.chip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chip.fm { color: var(--brand-ink); font-weight: 600; }
.grad-wrap { display: inline-flex; flex-direction: column; gap: 2px; }
.grad { display: block; width: 220px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgba(255, 237, 160, 0.6) 0%, #fed976 45%, #fd8d3c 75%, #f03b20 92%, #bd0026 100%); }
.grad-ticks { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- pinezka i kandydaci */
.maplibregl-marker.pin { z-index: 5; }
.maplibregl-marker.kmark { z-index: 2; }
.pin { width: 40px; height: 54px; position: relative; cursor: grab; touch-action: none; outline: none; }
.pin:active { cursor: grabbing; }
.pin svg { position: absolute; left: 0; top: 0; width: 40px; height: 52px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3)); transition: transform 0.15s; transform-origin: 50% 100%; }
.pin.dragging svg { transform: translateY(-6px) scale(1.06); }
.pin .shadow { position: absolute; left: 50%; bottom: -3px; width: 16px; height: 6px; margin-left: -8px; border-radius: 50%; background: rgba(0, 0, 0, 0.28); filter: blur(1.5px); transition: transform 0.15s, opacity 0.15s; }
.pin.dragging .shadow { transform: scale(1.4); opacity: 0.5; }
.pin .plabel {
  position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 11.5px; font-weight: 700; color: var(--brand-ink); background: #fff; padding: 3px 8px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.pin:focus-visible svg { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 50%; }
.pin.land svg { animation: drop 0.55s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes drop { 0% { transform: translateY(-40px); opacity: 0; } 100% { transform: none; opacity: 1; } }

.kmark { display: flex; align-items: center; gap: 4px; padding: 3px 7px 3px 4px; border: 1px solid var(--line-2); border-radius: 7px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); cursor: pointer; font-size: 11.5px; font-weight: 700; color: var(--text); }
.kmark .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text); }
.kmark.k1 { border-color: var(--brand); color: var(--brand-ink); }
.kmark.k1 .dot { background: var(--brand); }
.kmark:hover { border-color: var(--brand); }

/* ---------------------------------------------------------------- tooltip */
.tip {
  position: fixed; z-index: 20; pointer-events: none; max-width: 260px; padding: 8px 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow);
}
.tip b { font-weight: 700; }
.tip .m { font-variant-numeric: tabular-nums; font-weight: 600; }
.tip .s { color: var(--muted); }
.tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* ---------------------------------------------------------------- intro */
.intro { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; background: rgba(245, 243, 238, 0.97); transition: opacity 0.5s ease, visibility 0.5s; }
.intro.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-inner { position: relative; width: min(740px, 100%); }
.intro-kicker { display: flex; justify-content: space-between; font-size: 13px; font-weight: 500; color: var(--muted); padding-bottom: 14px; border-bottom: 1px solid var(--line-2); }
.intro-cards { position: relative; min-height: 290px; margin-top: 28px; }
.icard { position: absolute; inset: 0; opacity: 0; transform: translateY(10px); transition: opacity 0.45s ease, transform 0.45s ease; pointer-events: none; }
.icard.on { opacity: 1; transform: none; pointer-events: auto; }
.icard h1 { margin: 0; font-size: clamp(30px, 5vw, 52px); line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; text-wrap: balance; }
.icard h1 em { font-style: normal; color: var(--brand-ink); }
.icard p { margin: 18px 0 0; max-width: 560px; font-size: 16.5px; color: var(--muted); line-height: 1.55; }
.intro-nav { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.dots { display: flex; gap: 6px; margin-right: auto; }
.dots i { width: 24px; height: 4px; background: var(--line-2); border-radius: 2px; transition: background 0.3s; }
.dots i.on { background: var(--brand); }
.btn { height: 44px; padding: 0 20px; border-radius: 10px; font-weight: 600; font-size: 14.5px; }
.btn.primary { border: 0; background: var(--brand); color: #fff; }
.btn.primary:hover { background: #00967c; }
.btn.ghost { background: transparent; border: 1px solid var(--line-2); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--text); }
.intro-status { margin-top: 16px; font-size: 12.5px; color: var(--faint); }
.intro-status.ok { color: var(--brand-ink); }
.intro-status.bad { color: var(--bad); }

/* ---------------------------------------------------------------- metoda */
.method { background: var(--bg); border-top: 1px solid var(--line); }
.m-wrap { max-width: 900px; margin: 0 auto; padding: 64px 24px 80px; }
.m-hero { padding-bottom: 28px; border-bottom: 1px solid var(--line-2); }
.m-kicker { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--brand-ink); }
.m-hero h1 { margin: 0; font-size: clamp(30px, 4.4vw, 44px); line-height: 1.1; letter-spacing: -0.025em; text-wrap: balance; }
.m-lead { margin: 16px 0 0; font-size: 17.5px; line-height: 1.6; color: #3c4440; max-width: 760px; }
.m-figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 28px; }
.m-figures div { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.m-figures b { display: block; font-size: 24px; letter-spacing: -0.02em; }
.m-figures span { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: block; margin-top: 2px; }
.m-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 22px; }
.m-toc a { font-size: 13px; text-decoration: none; color: var(--text); padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); }
.m-toc a:hover { border-color: var(--brand); color: var(--brand-ink); }

.m-sec { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 40px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 16px; }
.m-num { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 16px; }
.m-body h2 { margin: 3px 0 14px; font-size: 26px; letter-spacing: -0.02em; line-height: 1.2; }
.m-body h3 { margin: 24px 0 8px; font-size: 17px; }
.m-body p, .m-body li { font-size: 15.5px; line-height: 1.65; color: #343b37; }
.m-body p { margin: 0 0 12px; }
.m-body ul, .m-body ol { margin: 0 0 12px; padding-left: 20px; }
.m-body li { margin-bottom: 8px; }
.m-body code { font-size: 13.5px; background: #ece9e2; padding: 1px 5px; border-radius: 4px; }
.m-note { font-size: 13.5px !important; color: var(--muted) !important; }
.m-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.m-chips span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: 13.5px; }
.m-chips i { width: 9px; height: 9px; border-radius: 3px; }
.m-chips b { font-variant-numeric: tabular-nums; }

.m-table { width: 100%; border-collapse: collapse; margin: 6px 0 14px; font-size: 14.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.m-table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 9px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.m-table td { padding: 8px 14px; border-bottom: 1px solid var(--line); }
.m-table tr:last-child td { border-bottom: 0; }
.m-table .r { text-align: right; }
.m-table .sum td { font-weight: 600; background: var(--surface-2); }
.m-table.compact td, .m-table.compact th { padding: 7px 12px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 0; }

.formula { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 8px 0 16px; padding: 18px 22px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 10px; font-size: 21px; font-family: 'Cambria Math', 'STIX Two Math', Georgia, serif; }
.formula sub, .formula sup { font-size: 0.65em; }
.frac { display: inline-flex; flex-direction: column; align-items: center; text-align: center; }
.frac > span { padding: 3px 8px; }
.frac > span:first-child { border-bottom: 1.5px solid var(--text); }
.f-note { font-size: 15px; color: var(--muted); font-family: var(--sans); }
.m-defs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; font-size: 15px; }
.m-defs dt { font-family: 'Cambria Math', Georgia, serif; font-weight: 700; }
.m-defs dd { margin: 0; color: #343b37; }
.m-example { padding: 16px 18px 6px; background: var(--brand-soft); border-radius: 10px; margin: 6px 0 14px; }
.m-example .m-table { background: #fff; }

.m-steps { counter-reset: s; list-style: none; padding-left: 0 !important; }
.m-steps li { position: relative; padding-left: 40px; margin-bottom: 14px; }
.m-steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 1px; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 13px; display: grid; place-items: center; }

.m-shares { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.m-shares .srow { grid-template-columns: 80px 1fr 56px; font-size: 14px; }
.m-shares .srow .t { height: 12px; }

.m-scen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.m-scen article { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.m-scen article.rec-card { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.m-scen h3 { margin: 6px 0 0; font-size: 17px; }
.m-scen .card-num { font-size: 24px; }
.m-scen table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.m-scen td { padding: 3px 0; border-top: 1px solid var(--line); }
.m-scen td.r { text-align: right; font-variant-numeric: tabular-nums; }
.m-callout { padding: 14px 18px; background: var(--brand-soft); border-left: 4px solid var(--brand); border-radius: 8px; font-size: 15px; line-height: 1.6; }

.m-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding-top: 36px; }
.m-foot h2 { font-size: 15px; margin: 0 0 8px; }
.m-foot ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; line-height: 1.7; }

.back-to-map {
  position: fixed; z-index: 15; right: 20px; bottom: 20px; display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px;
  border-radius: 999px; background: var(--text); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
.back-to-map svg { width: 16px; height: 16px; }
.back-to-map[hidden] { display: none; }

/* ---------------------------------------------------------------- MapLibre */
.maplibregl-ctrl-group { border-radius: 10px !important; box-shadow: var(--shadow) !important; }
.maplibregl-ctrl-attrib { font-size: 10.5px; }

.mobile-tabs { display: none; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 760px) {
  :root { --gap: 10px; --top: 108px; }
  .topbar { height: auto; grid-template-columns: 1fr auto; grid-template-areas: 'brand method' 'modes modes'; row-gap: 8px; padding: 9px 9px 9px 12px; }
  .brand { grid-area: brand; }
  .top-right { grid-area: method; }
  .theme-btn { width: 36px; height: 36px; }
  .btn-method { height: 36px; padding: 0 12px; font-size: 13.5px; }
  .btn-method .long { display: none; }
  .btn-method .short { display: inline; }
  .brand-sub { display: none; }
  .modes { grid-area: modes; }
  .modes button { flex: 1; padding: 7px 6px; }

  .panel {
    position: absolute; left: 0 !important; right: 0 !important; width: auto !important; top: auto; bottom: 0;
    max-height: 70% !important; border-radius: 16px 16px 0 0; border-bottom: 0;
    transform: translateY(calc(100% - var(--peek, 200px))); transition: transform 0.35s cubic-bezier(.2, .8, .2, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.open { transform: none; }
  .panel.away { transform: translateY(105%); }
  .sheet-handle { position: sticky; top: 0; z-index: 2; background: var(--surface); cursor: pointer; padding-top: 20px; }
  .sheet-handle::before { content: ''; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line-2); }
  #panel-left .panel-head { order: 0; }
  #panel-left .sec-kpi { order: 1; display: grid; grid-template-columns: auto 1fr; align-items: end; column-gap: 12px; }
  #panel-left .sec-kpi .label { grid-column: 1 / -1; }
  #panel-left .sec-kpi .big { font-size: 38px; }
  #panel-left .sec-kpi .hint { margin: 0 0 5px; }
  #panel-left .sec-versus { order: 2; }
  #panel-left .sec-format { order: 3; }
  #panel-left .sec-stats { order: 4; }
  #panel-left .sec-losses { order: 5; }
  #panel-right { --peek: 0px; display: flex; flex-direction: column; }
  #panel-right.collapsed .panel-body { display: block; }
  #panel-right .chev { transform: rotate(180deg); }
  .legend { left: var(--gap); right: var(--gap); width: auto; margin: 0; max-width: none; bottom: auto; top: calc(var(--top) + 48px); padding: 6px 10px; gap: 3px 9px; font-size: 11px; }
  .legend .label { display: none; }
  .grad { width: 140px; }
  .mobile-tabs { display: flex; position: absolute; z-index: 6; top: calc(var(--top) + 6px); left: var(--gap); gap: 5px; }
  .mobile-tabs button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }
  .mobile-tabs button.on { color: #fff; background: var(--brand); border-color: var(--brand); }
  .maplibregl-ctrl-bottom-right { bottom: 205px; }
  .intro-cards { min-height: 340px; }
  .icard p { font-size: 15px; }

  .m-wrap { padding: 44px 18px 90px; }
  .m-figures { grid-template-columns: 1fr 1fr; }
  .m-sec { grid-template-columns: 1fr; padding: 30px 0; }
  .m-body h2 { font-size: 22px; }
  .m-scen { grid-template-columns: 1fr; }
  .m-foot { grid-template-columns: 1fr; }
  .formula { font-size: 18px; padding: 14px 16px; }
  .m-table { font-size: 13.5px; }
  .m-table th, .m-table td { padding: 7px 9px; }
  .back-to-map { right: 12px; bottom: 12px; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  :root { --left-w: 300px; --right-w: 270px; }
  .big { font-size: 40px; }
  .brand-sub { display: none; }
  .btn-method .long { display: none; }
  .btn-method .short { display: inline; }
  .legend { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- tooltip: Frischmarkt i reguła 400 m */
.tip .fm-name { color: #00745f; }
.tip .rule-warn { color: #b0620a; }

/* ---------------------------------------------------------------- tryb ciemny (za ustawieniem witryny GeoSifter) */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111416;
  --surface: #1a1e21;
  --surface-2: #20252a;
  --line: #2c3237;
  --line-2: #3a4147;
  --text: #e8ecea;
  --muted: #a3aba7;
  --faint: #7d8682;
  --brand-ink: #4fd8bd;
  --brand-soft: #123a33;
  --warn-soft: #3b2a12;
  --bad-soft: #3d1c1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .modes,
[data-theme="dark"] .pt-tags i,
[data-theme="dark"] .tag,
[data-theme="dark"] .stack { background: #262b30; }
[data-theme="dark"] .bar { background: #262b30; }
[data-theme="dark"] .lrow .t { background: #262b30; }
[data-theme="dark"] .verdict.warn,
[data-theme="dark"] .tip .rule-warn { color: #f0a34a; }
[data-theme="dark"] .tip .fm-name { color: #4fd8bd; }
[data-theme="dark"] .plabel { background: var(--surface); color: var(--brand-ink); }
[data-theme="dark"] .kmark { background: var(--surface); }
[data-theme="dark"] .tip { background: var(--surface); }
[data-theme="dark"] .intro { background: rgba(17, 20, 22, 0.97); }
[data-theme="dark"] .m-lead { color: #c3cbc7; }
[data-theme="dark"] .m-body p,
[data-theme="dark"] .m-body li,
[data-theme="dark"] .m-defs dd { color: #ccd3cf; }
[data-theme="dark"] .m-body code { background: #262b30; }
[data-theme="dark"] .m-example .m-table { background: var(--surface); }
[data-theme="dark"] .back-to-map { background: #e8ecea; color: #111416; }
[data-theme="dark"] .maplibregl-ctrl-group { background: var(--surface); }
[data-theme="dark"] .maplibregl-ctrl-group button + button { border-top-color: var(--line); }
[data-theme="dark"] .maplibregl-ctrl-group .maplibregl-ctrl-icon { filter: invert(1) hue-rotate(180deg); }
[data-theme="dark"] .maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(26, 30, 33, 0.9); }
[data-theme="dark"] .maplibregl-ctrl-attrib a { color: var(--muted); }
/* ---------------------------------------------------------------- przełącznik jasny/ciemny (własny w projekcie) */
.top-right { justify-self: end; display: flex; align-items: center; gap: 8px; }
.theme-btn {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); color: var(--muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.theme-btn:hover { color: var(--brand-ink); border-color: var(--brand); background: var(--brand-soft); }