/* ---------- Tokens ---------- */
:root {
  --stone: #E6E8E3;      /* pozadí – vápenná omítka */
  --paper: #F7F8F5;      /* plochy, plánek */
  --ink: #22302F;        /* text */
  --muted: #5A6966;      /* doplňkový text */
  --line: #C6CCC5;       /* linky */
  --patina: var(--brand, #2E7566);          /* akce – hlavní barva z administrace */
  --patina-ink: var(--brand-ink, #FFFFFF);
  --gilt: #A9812A;       /* aktivní bod */
  --danger: #9B3B2E;

  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3125rem;
  --step-2: 1.75rem;
  --step-3: 2.375rem;

  --r: 6px;
  --gap: 1rem;
  --max: 40rem;
  color-scheme: light dark;
}
/* Tmavý režim: podle telefonu (pokud si návštěvník nezvolil jinak) nebo ručně */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --stone: #141B1A;
    --paper: #1D2625;
    --ink: #E3E8E5;
    --muted: #9FAEAA;
    --line: #34403E;
    --patina: color-mix(in srgb, var(--brand, #2E7566) 62%, #ffffff);
    --patina-ink: #0F1716;
    --gilt: #D2A948;
    --danger: #E08A7C;
  }
}
:root[data-theme="dark"] {
    --stone: #141B1A;
    --paper: #1D2625;
    --ink: #E3E8E5;
    --muted: #9FAEAA;
    --line: #34403E;
    --patina: color-mix(in srgb, var(--brand, #2E7566) 62%, #ffffff);
    --patina-ink: #0F1716;
    --gilt: #D2A948;
    --danger: #E08A7C;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* Velikost písma: --font-scale nastavuje aplikace (Zobrazení), všechny velikosti jsou v rem */
html { -webkit-text-size-adjust: 100%; font-size: calc(100% * var(--font-scale, 1)); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--stone);
  color: var(--ink);
  font: var(--step-0)/1.55 var(--sans);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
img { max-width: 100%; display: block; }
a { color: var(--patina); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gilt); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }
main { max-width: var(--max); margin: 0 auto; padding: 0 var(--gap) 3rem; outline: none; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .25rem;
  padding: calc(env(safe-area-inset-top, 0px) + .4rem) calc(var(--gap) - .25rem) .4rem;
  background: color-mix(in srgb, var(--stone) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.bar__back {
  flex: none; display: inline-flex; align-items: center; gap: .1rem;
  text-decoration: none; font-weight: 500; min-height: 44px; padding: 0 .4rem 0 .15rem;
}
.bar__back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.bar__title {
  flex: 1 1 auto; min-width: 0; margin: 0 .25rem; font-family: var(--serif); font-size: var(--step-0);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar__tools { flex: none; display: flex; align-items: center; gap: .3rem; margin-left: auto; }
.bar__btn {
  height: 44px; min-width: 44px; padding: 0 .6rem; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink);
  font-size: .9rem; font-weight: 600; letter-spacing: .02em; cursor: pointer; line-height: 1;
}
.bar__btn--icon { width: 44px; padding: 0; }
.bar__btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.bar__btn .aa { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; letter-spacing: 0; }
.bar__btn .aa small { font-size: .75em; }
/* Na úzkém displeji jen šipka zpět bez textu */
@media (max-width: 400px) {
  .bar__back span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

/* ---------- Notices ---------- */
.notice {
  max-width: var(--max); margin: .75rem auto 0; padding: .75rem var(--gap);
  display: flex; gap: .75rem; align-items: center; justify-content: space-between;
  background: var(--ink); color: var(--stone); font-size: var(--step--1);
}
@media (min-width: 42rem) { .notice { border-radius: var(--r); } }
.notice button { flex: none; border: 0; border-radius: 999px; padding: .45rem .9rem; background: var(--stone); color: var(--ink); font-weight: 600; cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .6rem 1.2rem; border-radius: 999px;
  border: 0; background: var(--patina); color: var(--patina-ink);
  font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn--text { background: none; color: var(--muted); padding: .4rem 0; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
.btn[disabled] { opacity: .55; cursor: default; }

/* ---------- Home ---------- */
.hero { margin: 0 calc(var(--gap) * -1); position: relative; }
.hero img { width: 100%; aspect-ratio: 800 / 420; object-fit: cover; }
.hero__text { padding: 1.5rem var(--gap) .5rem; }
.hero h1 { font-size: var(--step-3); letter-spacing: -.01em; }
.hero p { margin: .35rem 0 0; color: var(--muted); font-size: var(--step-1); font-family: var(--serif); font-style: italic; }
@media (min-width: 42rem) { .hero { margin: 1rem 0 0; } .hero img { border-radius: var(--r); } .hero__text { padding-inline: 0; } }

.section-title { font-size: var(--step-1); margin: 2rem 0 .75rem; }

.routes { display: grid; gap: .75rem; }
.route {
  display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; align-items: center;
  padding: 1.1rem 1.1rem 1.1rem 1.25rem; background: var(--paper);
  border-left: 4px solid var(--patina); border-radius: 0 var(--r) var(--r) 0;
  text-decoration: none; color: inherit;
}
.route h3 { font-size: var(--step-1); }
.route p { margin: 0; grid-column: 1; color: var(--muted); font-size: var(--step--1); }
.route__meta { font-size: var(--step--1); color: var(--ink) !important; font-weight: 500; }
.route svg { grid-column: 2; grid-row: 1 / span 3; width: 22px; height: 22px; fill: none; stroke: var(--patina); stroke-width: 2.2; }

.offline {
  margin-top: 2rem; padding: 1.25rem; border: 1px dashed var(--muted); border-radius: var(--r);
}
.offline h2 { font-size: var(--step-1); }
.offline p { margin: .5rem 0 1rem; }
.offline__actions { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.offline--ready { border-style: solid; border-color: var(--patina); }
.offline--ready h2::after { content: " ✓"; color: var(--patina); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: .25rem 0 .5rem; }
.progress > span { display: block; height: 100%; width: 0; background: var(--patina); transition: width .2s; }
.progress-label { font-size: var(--step--1); color: var(--muted); }
.error { color: var(--danger); font-size: var(--step--1); }

.install {
  margin-top: 1rem; padding: 1rem 1.25rem; background: var(--paper); border-radius: var(--r);
  font-size: var(--step--1);
}
.install p { margin: 0 0 .5rem; }

/* ---------- Plan ---------- */
.plan {
  position: relative; margin: 1rem 0 0; background: #F7F8F5;
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.plan img { width: 100%; height: auto; }
/* Body: velikost a barvy z administrace (Vzhled → Body na plánku) */
.plan { --pin-s: calc(var(--pin, 34px) * var(--pin-scale, 1)); }
.plan--compact { --pin-scale: .82; }
@media (max-width: 360px) { .plan { --pin-scale: .85; } .plan--compact { --pin-scale: .72; } }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  width: var(--pin-s); height: var(--pin-s); border-radius: 50%;
  border: 2px solid #F7F8F5; background: var(--pin-color, #2E7566); color: var(--pin-ink, #fff);
  font: 700 calc(var(--pin-s) * .42) / 1 var(--sans); cursor: pointer; padding: 0;
  display: grid; place-items: center;
  box-shadow: 0 1px 2px rgba(34,48,47,.35);
  transition: transform .15s ease;
}
.pin:hover { transform: translate(-50%, -50%) scale(1.08); }
.pin[aria-current="true"] {
  width: calc(var(--pin-s) * 1.24); height: calc(var(--pin-s) * 1.24); font-size: calc(var(--pin-s) * .52);
  background: var(--pin-active, #A9812A); color: var(--pin-active-ink, #fff); z-index: 1;
  box-shadow: 0 0 0 calc(var(--pin-s) * .15) color-mix(in srgb, var(--pin-active, #A9812A) 30%, transparent);
}

/* ---------- Stop list ---------- */
.route-head { margin-top: 1.5rem; }
.route-head h1 { font-size: var(--step-2); }
.route-head p { color: var(--muted); margin: .4rem 0 0; }
.stops { list-style: none; margin: 1.25rem 0 0; padding: 0; border-top: 1px solid var(--line); }
.stops li { border-bottom: 1px solid var(--line); }
.stop-link {
  display: grid; grid-template-columns: clamp(7rem, 34vw, 9rem) 1fr; gap: .9rem; align-items: center;
  padding: .75rem 0; text-decoration: none; color: inherit;
}
.stop-link__media { position: relative; display: block; }
.stop-link img, .stop-link__noimg {
  display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r); background: var(--line);
}
/* Číslo zastavení jako bod z plánku v rohu fotky */
.stop-link__n {
  position: absolute; top: .35rem; left: .35rem;
  min-width: 1.9rem; height: 1.9rem; padding: 0 .35rem; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--pin-color, #2E7566); color: var(--pin-ink, #fff);
  border: 2px solid #F7F8F5; box-shadow: 0 1px 2px rgba(34,48,47,.35);
  font: 700 .9rem/1 var(--sans);
}
.stop-link__text { min-width: 0; }
.stop-link h2 { font-size: var(--step-0); font-family: var(--sans); font-weight: 600; line-height: 1.3; }
.stop-link p {
  margin: .25rem 0 0; color: var(--muted); font-size: var(--step--1); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- Stop detail ---------- */
.stop-head { display: flex; align-items: baseline; gap: .9rem; margin: 1.5rem 0 1rem; }
.stop-head__n { font-family: var(--serif); font-size: var(--step-3); line-height: 1; color: var(--gilt); font-variant-numeric: oldstyle-nums; }
.stop-head h1 { font-size: var(--step-2); }

.player {
  display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: .5rem .75rem;
  padding: .9rem 1rem; background: var(--paper); border-radius: var(--r);
}
.player__play {
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--patina); color: var(--patina-ink); display: grid; place-items: center;
}
.player__play svg { width: 26px; height: 26px; fill: currentColor; }
.player__rew {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: none; cursor: pointer;
  display: grid; place-items: center; font-size: .62rem; font-weight: 700; color: var(--muted); position: relative;
}
.player__rew svg { position: absolute; inset: 3px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.player__track { display: grid; gap: .2rem; min-width: 0; }
.player__time { display: flex; justify-content: space-between; font-size: var(--step--1); color: var(--muted); font-variant-numeric: tabular-nums; }
.player__msg { grid-column: 1 / -1; margin: .25rem 0 0; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; cursor: pointer;
  --pct: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(to right, var(--patina) var(--pct), var(--line) var(--pct));
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--patina); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6.5px; border-radius: 50%;
  background: var(--patina); border: 3px solid var(--paper);
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--patina); border: 3px solid var(--paper); }

.gallery {
  display: flex; gap: .6rem; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 1.25rem calc(var(--gap) * -1) 0; padding: 0 var(--gap) .25rem;
  scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery button { flex: 0 0 82%; scroll-snap-align: center; border: 0; padding: 0; background: none; cursor: zoom-in; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r); background: var(--line); }
.gallery--single button { flex-basis: 100%; }

.prose { font-family: var(--serif); font-size: 1.125rem; line-height: 1.65; margin-top: 1.25rem; }
.prose p { margin: 0 0 1em; }

.transcript { margin-top: .5rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.transcript summary {
  min-height: 48px; display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 600; list-style: none;
}
.transcript summary::-webkit-details-marker { display: none; }
.transcript summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid; border-bottom: 2px solid; transform: rotate(-45deg); transition: transform .15s; margin-right: .25rem; }
.transcript[open] summary::before { transform: rotate(45deg); }
.transcript p { margin: 0 0 1rem; }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }
.pager a { flex: 1; max-width: 48%; }
.pager a:only-child:last-child { margin-left: auto; }

/* ---------- Dialogs ---------- */
dialog { border: 0; padding: 0; color: var(--ink); }
dialog::backdrop { background: rgba(10, 16, 15, .55); }
.sheet {
  width: min(100%, 26rem); margin: auto auto 0; border-radius: 16px 16px 0 0;
  background: var(--paper); padding: 1.25rem var(--gap) calc(1.25rem + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 42rem) { .sheet { margin: auto; border-radius: 16px; } }
.sheet h2 { font-size: var(--step-1); margin-bottom: .75rem; }
.lang-list { display: grid; gap: .25rem; }
.lang-list button {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 52px; padding: 0 1rem; border: 1px solid transparent; border-radius: var(--r);
  background: none; text-align: left; cursor: pointer; font-size: var(--step-0);
}
.lang-list button[aria-current="true"] { border-color: var(--patina); font-weight: 600; }
.lang-list button[aria-current="true"]::after { content: "✓"; color: var(--patina); }

.lightbox { max-width: 100vw; max-height: 100dvh; width: 100%; height: 100%; background: #000; }
.lightbox img { width: 100%; height: 100%; object-fit: contain; }
.lightbox__close {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + .5rem); right: .75rem; z-index: 1;
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 1.8rem; cursor: pointer;
}

.empty { text-align: center; padding: 3rem 0; }

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

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Formátovaný text z administrace ---------- */
.prose h2 { font-size: var(--step-1); margin: 1.4em 0 .4em; }
.prose h3 { font-size: var(--step-0); font-family: var(--sans); margin: 1.2em 0 .3em; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.4em; }
.prose li { margin: .2em 0; }
.prose blockquote { margin: 0 0 1em; padding: .2em 0 .2em 1em; border-left: 3px solid var(--gilt); color: var(--muted); font-style: italic; }
.prose a { text-underline-offset: 3px; }
.transcript__body p, .transcript__body ul, .transcript__body ol { margin: 0 0 1rem; }

.hero--plain { padding-top: 1rem; }
.route--link { border-left-color: var(--gilt); }
.route--page { border-left-color: var(--muted); }
.route--link svg, .route--page svg { stroke: var(--muted); }
.route svg { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dev-error { margin-top: 1.5rem; padding: 1rem; text-align: left; white-space: pre-wrap; font-size: .75rem; background: var(--paper); border: 1px solid var(--danger); color: var(--danger); overflow-x: auto; }

/* ---------- Zobrazení (režim, písmo) ---------- */
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.sheet__head h2 { margin: 0; }
.sheet__close {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: none; color: var(--ink); cursor: pointer; display: grid; place-items: center;
}
.sheet__close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; fill: none; }
.setting { margin: 0 0 1.25rem; padding: 0; border: 0; }
.setting legend { font-weight: 600; margin-bottom: .5rem; padding: 0; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--stone); border-radius: 12px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: grid; place-items: center; min-height: 48px; padding: .25rem .4rem; border-radius: 9px;
  text-align: center; font-size: .95rem; line-height: 1.2; color: var(--muted);
}
.segmented input:checked + span { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.segmented input:focus-visible + span { outline: 3px solid var(--gilt); outline-offset: 1px; }
.segmented--font span { font-family: var(--serif); font-weight: 600; color: var(--ink); }
.font-preview { margin: .75rem 0 0; color: var(--muted); font-size: var(--step--1); }

/* ---------- O aplikaci ---------- */
.sheet--about { width: min(100%, 36rem); max-height: 90dvh; overflow-y: auto; }
.about { font-family: var(--serif); font-size: 1.0625rem; line-height: 1.6; }
.about h2, .about h3 { font-size: var(--step-1); margin: 1.2em 0 .4em; }
.about p, .about ul { margin: 0 0 1em; }
.about__meta { margin-top: 1.5rem; padding-top: .75rem; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--step--1); }

/* ---------- Přehrávač přilepený dole (když jeho místo odjede z obrazovky) ---------- */
.player__title { display: none; }
.player--docked {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  margin: 0 auto; max-width: var(--max);
  grid-template-columns: auto 1fr auto; gap: .15rem .75rem;
  padding: .55rem var(--gap) calc(.55rem + env(safe-area-inset-bottom, 0px));
  border-radius: 14px 14px 0 0;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 -4px 20px rgba(0,0,0,.18);
  animation: dock-in .2s ease-out;
}
.player--docked .player__title {
  display: block; grid-column: 2 / 4; grid-row: 1; align-self: end;
  margin: 0; font-weight: 600; font-size: var(--step--1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player--docked .player__play { grid-column: 1; grid-row: 1 / span 2; width: 48px; height: 48px; }
.player--docked .player__track { grid-column: 2 / 4; grid-row: 2; }
.player--docked .player__rew { display: none; }
.player--docked input[type="range"] { height: 20px; }
.player--docked .player__msg { grid-row: 3; }
body.player-docked main { padding-bottom: 7.5rem; }
@keyframes dock-in { from { transform: translateY(100%); } to { transform: none; } }
@media (min-width: 42rem) { .player--docked { bottom: .75rem; border-radius: 14px; } }
