:root {
  --paper: #F6F7FB;
  --grid: #DCE4F2;
  --grid-strong: #C9D5EA;
  --margin: #EFA2AE;
  --ink: #1F2A5C;
  --ink-soft: #5B6696;
  --ink-faint: #9AA3C7;
  --land: rgba(255, 255, 255, 0.82);
  --sea-line: #BCD3EC;
  --water: #7FA7D6;
  --park: #CFE6CF;
  --marker: #FFE66D;
  --card: #FFFFFF;
  --shadow: 0 1px 0 rgba(31, 42, 92, .06), 0 10px 30px -12px rgba(31, 42, 92, .28);
  --v1: #E46A8E;
  --v2: #7C6FD6;
  --v3: #2E9E96;
  --v4: #E7A33A;
  --panel-w: 400px;
  --bar-h: 112px;
  --hand: 'Caveat', 'Segoe Print', cursive;
  --ui: 'Lexend', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- scena mapy ---------- */
#stage {
  position: fixed; inset: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 26px 26px;
  cursor: grab;
  touch-action: none;
}
#stage.dragging { cursor: grabbing; }
#stage::before { /* czerwony margines zeszytu */
  content: ''; position: absolute; top: 0; bottom: 0; left: 64px; width: 2px;
  background: var(--margin); opacity: .55; pointer-events: none; z-index: 1;
}
#map, #ink { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ink { pointer-events: none; z-index: 2; }

.halo-1 { fill: none; stroke: var(--sea-line); stroke-width: 22; opacity: .28; }
.halo-2 { fill: none; stroke: var(--sea-line); stroke-width: 10; opacity: .45; }
.land { fill: var(--land); stroke: var(--ink); stroke-width: 1.2; stroke-linejoin: round; }
.borders { fill: none; stroke: var(--ink-faint); stroke-width: .8; stroke-dasharray: 3 4; }
.halo-1, .halo-2, .land, .borders, .city path { vector-effect: non-scaling-stroke; }
#stage.deep .halo-1, #stage.deep .halo-2 { display: none; }

.city { opacity: 0; transition: opacity .5s ease; }
#stage.street .city { opacity: 1; }
.city .river { fill: none; stroke: var(--water); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.city .canal { fill: none; stroke: var(--water); stroke-width: 2.5; stroke-dasharray: 7 4; opacity: .9; }
.city .road { fill: none; stroke: var(--ink-soft); stroke-width: 1.3; stroke-linecap: round; opacity: .7; }
.city .road.major { stroke-width: 2.6; opacity: .8; }
.city .rail { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 10 3 2 3; opacity: .55; }
.city .park { fill: var(--park); stroke: #8DBF8D; stroke-width: 1.2; fill-opacity: .7; }
.city .campus { fill: url(#hatch); stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 2 3; }
.city .centre { fill: url(#hatch-soft); stroke: none; }

/* ---------- etykiety i pinezki (warstwa HTML) ---------- */
#pins { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.label {
  position: absolute; left: 0; top: 0;
  font: 600 22px/1 var(--hand); color: var(--ink-soft);
  white-space: nowrap; transform-origin: 0 0;
  opacity: 0; transition: opacity .35s ease;
  text-shadow: 0 0 3px var(--paper), 0 0 6px var(--paper);
}
.label.on { opacity: .9; }
.label.small { font-size: 18px; }
.label.big { font-size: 30px; letter-spacing: .5px; color: var(--ink-faint); }
.label.water { color: var(--water); font-style: normal; }

.pin {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  pointer-events: auto;
}
.pin button {
  position: absolute; left: -22px; top: -22px; width: 44px; height: 44px;
  border: 0; background: none; padding: 0; border-radius: 50%;
}
.pin svg { width: 44px; height: 44px; overflow: visible; display: block; }
.pin .petal { transform-box: fill-box; transform-origin: 50% 100%; }
.pin .bud { transition: transform .25s ease; transform-box: fill-box; transform-origin: center; }
.pin button:hover .bud { transform: scale(1.18); }
.pin .count {
  position: absolute; left: 10px; top: -26px; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--ink); color: #fff;
  font: 600 11px/20px var(--ui); text-align: center; pointer-events: none;
}
.pin .pin-name {
  position: absolute; left: 24px; top: -11px; white-space: nowrap; pointer-events: none;
  font: 700 21px/1 var(--hand); color: var(--ink);
  text-shadow: 0 0 3px var(--paper), 0 0 7px var(--paper), 0 0 10px var(--paper);
}
.pin.left .pin-name { left: auto; right: 24px; }
.pin.left .count { left: auto; right: 10px; }
.pin.dim { opacity: .28; }
.pin.hidden { display: none; }
.pin.current { z-index: 5; }
.pin.current .pin-name { font-size: 25px; }

.who { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 6; pointer-events: none; }
.who .av { pointer-events: auto; }

.av {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  font: 600 12px/1 var(--ui); color: #fff; letter-spacing: .3px;
  border: 2.5px solid #fff; box-shadow: 0 2px 8px -2px rgba(31,42,92,.45);
  background: var(--ink-soft);
}
.who .av { position: absolute; left: -17px; top: -17px; }

/* ---------- górny pasek ---------- */
#top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 20px 14px 84px; pointer-events: none;
}
#top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: baseline; gap: 12px; margin-right: auto;
  padding: 4px 16px 6px 12px; margin-left: -12px; border-radius: 16px;
  background: rgba(246, 247, 251, .86); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.brand h1 { margin: 0; font: 700 44px/0.9 var(--hand); letter-spacing: .5px; }
.brand p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.progress-read {
  display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 14px;
  background: var(--card); border-radius: 999px; box-shadow: var(--shadow);
}
.progress-read span { font-size: 13px; color: var(--ink-soft); margin-right: 4px; }
.vol-toggle {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: none;
  display: grid; place-items: center; position: relative;
}
.vol-toggle svg { width: 30px; height: 30px; transition: transform .3s ease, filter .3s ease; }
.vol-toggle.locked svg { filter: grayscale(1) opacity(.35); transform: scale(.82); }
.vol-toggle b { position: absolute; bottom: -1px; right: 2px; font: 700 11px/1 var(--ui); color: var(--ink); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 999px; border: 0;
  background: var(--card); box-shadow: var(--shadow); font-size: 14px; font-weight: 500;
}
.chip-btn:hover { background: #fff; transform: translateY(-1px); }
.chip-btn svg { width: 18px; height: 18px; }
.found { font-variant-numeric: tabular-nums; }
.found-ring { width: 22px; height: 22px; }
.found-ring circle { fill: none; stroke-width: 3.5; }

/* ---------- przełącznik skali ---------- */
#scale {
  position: fixed; left: 84px; top: 84px; z-index: 9;
  display: flex; flex-direction: column; gap: 6px;
}
#scale button {
  border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 12px;
  padding: 7px 14px; font: 700 21px/1 var(--hand); text-align: left; color: var(--ink-soft);
}
#scale button.active { color: var(--ink); background: linear-gradient(transparent 55%, var(--marker) 55%, var(--marker) 88%, transparent 88%), var(--card); }

/* ---------- oś czasu ---------- */
#bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 0 20px 16px 84px; pointer-events: none;
}
#bar > * { pointer-events: auto; }
.cast { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 12px; scrollbar-width: none; }
.cast::-webkit-scrollbar { display: none; }
.cast-chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 14px 3px 3px; border-radius: 999px; border: 0;
  background: var(--card); box-shadow: var(--shadow); font-size: 13.5px; font-weight: 500;
}
.cast-chip .av { width: 30px; height: 30px; font-size: 11px; border-width: 2px; box-shadow: none; }
.cast-chip.on { background: var(--ink); color: #fff; }
.timeline {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 12px 16px;
}
.play {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--ink); color: #fff; display: grid; place-items: center;
}
.play svg { width: 18px; height: 18px; }
.track { position: relative; flex: 1; height: 50px; display: flex; gap: 6px; }
.seg { position: relative; flex: 1; min-width: 0; }
.seg-head { display: flex; align-items: baseline; gap: 6px; font: 700 20px/1 var(--hand); white-space: nowrap; }
.seg-head small { font: 400 11.5px/1 var(--ui); color: var(--ink-soft); }
.seg-line { position: absolute; left: 0; right: 0; bottom: 9px; height: 4px; border-radius: 2px; opacity: .3; }
.seg.locked .seg-line { opacity: .12; }
.seg.locked .seg-head { color: var(--ink-faint); }
.seg-lock {
  position: absolute; inset: 22px 0 0 0; border: 0; background: none; padding: 0;
  font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; justify-content: center; gap: 6px;
}
.seg-lock svg { width: 13px; height: 13px; }
.tick {
  position: absolute; bottom: 3px; width: 16px; height: 16px; margin-left: -8px;
  border: 0; padding: 0; background: none; display: grid; place-items: center;
}
.tick i { display: block; width: 9px; height: 9px; border-radius: 50%; background: currentColor; transition: transform .2s ease; }
.tick.seen i { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px currentColor; }
.tick:hover i { transform: scale(1.5); }
.tick.current i { transform: scale(1.7); }
.tick-tip {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 12px; white-space: nowrap;
  padding: 4px 9px; border-radius: 7px; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.tick:hover .tick-tip, .tick:focus-visible .tick-tip { opacity: 1; }
.nib {
  position: absolute; bottom: 14px; width: 18px; height: 26px; margin-left: -9px;
  pointer-events: none; opacity: 0;
}

/* ---------- panel boczny ---------- */
#panel {
  position: fixed; z-index: 12; top: 84px; right: 20px; bottom: calc(var(--bar-h) + 70px);
  width: var(--panel-w); display: flex; flex-direction: column;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  visibility: hidden; overflow: hidden;
}
#panel.open { visibility: visible; }
.panel-tape { /* taśma washi przyklejająca kartkę */
  position: absolute; top: -8px; left: 50%; width: 110px; height: 26px; margin-left: -55px;
  transform: rotate(-3deg); opacity: .75; border-radius: 3px; z-index: 2;
}
.panel-close {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--paper);
  display: grid; place-items: center;
}
.panel-close svg { width: 16px; height: 16px; }
.panel-body { overflow-y: auto; padding: 26px 26px 22px; flex: 1; overscroll-behavior: contain; }
.panel-nav { display: flex; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--grid); }
.panel-nav button {
  flex: 1; height: 40px; border-radius: 12px; border: 0; background: var(--paper); font-weight: 500; font-size: 14px;
}
.panel-nav button:disabled { opacity: .35; cursor: default; }

.kicker { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); margin: 0 40px 6px 0; }
.kicker svg { width: 20px; height: 20px; flex: none; }
.card-title { margin: 4px 0 14px; font: 700 36px/1.02 var(--hand); }
.card-title .hl {
  background-image: linear-gradient(transparent 58%, var(--hl, var(--marker)) 58%, var(--hl, var(--marker)) 92%, transparent 92%);
  background-repeat: no-repeat; background-size: 0% 100%;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.place-link {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0;
  font-weight: 500; color: var(--ink); text-decoration: underline; text-decoration-color: var(--grid-strong);
  text-underline-offset: 4px; text-decoration-thickness: 2px;
}
.place-link svg { width: 16px; height: 16px; }
.card-text { margin: 14px 0 18px; font-size: 15.5px; max-width: 62ch; }
.card-h { margin: 20px 0 8px; font: 700 22px/1.1 var(--hand); color: var(--ink-soft); }
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person {
  display: inline-flex; align-items: center; gap: 8px; border: 0; padding: 3px 12px 3px 3px;
  border-radius: 999px; background: var(--paper); font-size: 13.5px; font-weight: 500;
}
.person .av { width: 28px; height: 28px; font-size: 10.5px; border-width: 2px; box-shadow: none; }
.source { font-size: 12.5px; color: var(--ink-soft); margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--grid-strong); }
.source a { color: var(--ink-soft); }
.source p { margin: 0 0 4px; }
.sure { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: var(--paper); }
.sure i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--grid); }
.list button {
  width: 100%; text-align: left; border: 0; background: none; padding: 11px 4px;
  display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start;
}
.list button:hover { background: var(--paper); }
.list svg { width: 22px; height: 22px; margin-top: 1px; }
.list b { display: block; font-weight: 500; }
.list small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.teaser { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--paper); font-size: 13px; color: var(--ink-soft); display: flex; gap: 8px; align-items: center; }
.teaser svg { width: 15px; height: 15px; flex: none; }
.ghost-btn {
  margin-top: 16px; height: 42px; padding: 0 18px; border-radius: 12px; border: 2px solid var(--ink);
  background: none; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px;
}
.ghost-btn svg { width: 16px; height: 16px; }

/* ---------- ekran startowy ---------- */
#intro {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px;
  background: rgba(246, 247, 251, .72); backdrop-filter: blur(3px);
}
#intro[hidden] { display: none; }
.intro-card {
  position: relative; width: min(560px, 100%); background: var(--card); border-radius: 24px;
  box-shadow: var(--shadow); padding: 44px 40px 34px; text-align: center;
}
.intro-card h2 { margin: 0; font: 700 84px/0.9 var(--hand); }
.intro-card h2 span { display: inline-block; }
.intro-sub { margin: 10px 0 26px; color: var(--ink-soft); font-size: 15px; }
.intro-q { margin: 0 0 14px; font: 700 26px/1.1 var(--hand); }
.intro-vols { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.intro-vol {
  width: 108px; padding: 12px 6px 10px; border-radius: 16px; border: 2px solid var(--grid);
  background: #fff; display: grid; justify-items: center; gap: 4px;
}
.intro-vol:hover, .intro-vol.pick { border-color: var(--ink); }
.intro-vol svg { width: 44px; height: 44px; }
.intro-vol b { font: 700 22px/1 var(--hand); }
.intro-vol small { font-size: 11.5px; color: var(--ink-soft); }
.intro-note { margin: 22px 0 0; font-size: 12px; color: var(--ink-soft); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; top: 84px; z-index: 40; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 14px; padding: 10px 16px; border-radius: 12px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
}

/* ---------- mniejsze ekrany ---------- */
@media (max-width: 900px) {
  :root { --panel-w: auto; }
  #stage::before { left: 18px; }
  #top { padding: 10px 10px 8px 26px; gap: 6px; flex-wrap: wrap; }
  .brand { padding: 2px 10px 4px 10px; margin-left: -10px; }
  .brand h1 { font-size: 32px; }
  .brand p { display: none; }
  .chip-btn .lbl, .found { display: none; }
  .chip-btn { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .progress-read { order: 5; width: 100%; justify-content: space-between; padding: 3px 6px 3px 14px; }
  .vol-toggle { width: 44px; height: 34px; }
  .vol-toggle svg { width: 26px; height: 26px; }
  #scale { left: 26px; top: auto; bottom: 92px; flex-direction: row; gap: 4px; }
  #scale button { font-size: 17px; padding: 5px 9px; border-radius: 10px; }
  #bar { padding: 0 10px 10px; }
  .cast { display: none; }
  .timeline { padding: 8px 10px; gap: 10px; border-radius: 14px; }
  .play { width: 40px; height: 40px; }
  .track { height: 44px; gap: 4px; }
  .seg-head small { display: none; }
  .seg-head { font-size: 16px; }
  .seg-lock span { display: none; }
  #panel { left: 10px; right: 10px; top: auto; bottom: 84px; max-height: 44vh; width: auto; border-radius: 18px; }
  .panel-body { padding: 22px 20px 16px; }
  .panel-nav { padding: 8px 12px 10px; }
  .card-title { font-size: 30px; }
  .card-text { font-size: 15px; margin: 10px 0 12px; }
  .intro-card { padding: 30px 18px 24px; }
  .intro-card h2 { font-size: 64px; }
  .intro-vols { gap: 8px; }
  .intro-vol { width: 74px; }
  .intro-vol small { display: none; }
  .pin .pin-name { font-size: 17px; left: 20px; top: -9px; }
  .pin.left .pin-name { right: 20px; }
  .pin.current .pin-name { font-size: 20px; }
  .label { font-size: 17px; }
  .label.small { font-size: 14px; }
  .label.big { font-size: 22px; }
  #toast { top: auto; bottom: 50vh; max-width: calc(100vw - 40px); }
}

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