:root {
  --wine: #3b0d1c;
  --wine-2: #8c1d40;
  --wine-soft: #f3e3e6;
  --paper: #f7f1e7;
  --paper-2: #fffaf2;
  --clay-line: #b89a6e;
  --ink: #2a1d18;
  --muted: #7a6a5f;
  --line: #e6dccb;
  --ok: #4f6f2f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --top-h: 52px;
  --rail-h: 112px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; height: 100dvh; margin: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Header: jeden řádek i na 320 px */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 12px 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--wine); color: var(--paper-2);
}
.brand-mark { width: 32px; height: 32px; border-radius: 8px; flex: none; box-shadow: 0 0 0 1px rgba(255, 250, 242, .25); }
.brand { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.brand strong { font-family: var(--serif); font-size: 18px; line-height: 1.1; }
.brand span { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.net {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px;
  border-radius: 99px; background: rgba(255, 250, 242, .14); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.net svg { width: 14px; height: 14px; display: none; }
.net.is-ready svg { display: block; }
.net.is-offline { background: #f2c14e; color: var(--wine); }

main { position: fixed; inset: calc(var(--top-h) + var(--safe-t)) 0 0 0; }
#map { position: absolute; inset: 0; background: var(--paper); }
.leaflet-container { font-family: var(--sans); background: var(--paper); }
.leaflet-control-attribution { font-size: 10px; background: rgba(255, 250, 242, .85) !important; }
.leaflet-bottom.leaflet-right { bottom: calc(var(--rail-h) + var(--safe-b)); }
.leaflet-marker-icon:focus { outline: none; }
.leaflet-marker-icon:focus-visible .pin { box-shadow: 0 0 0 3px var(--paper-2), 0 0 0 6px var(--wine-2); }

/* Piny: velké na prst, se jménem od přiblížení 17 */
.pin-wrap { display: flex; align-items: center; gap: 6px; width: max-content; }
.pin {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--wine-2); color: #fff; border: 3px solid var(--paper-2);
  font-family: var(--serif); font-weight: 700; font-size: 16px;
  box-shadow: 0 3px 10px rgba(59, 13, 28, .35); transition: transform .15s ease, background .15s ease;
}
.pin-name {
  display: none; padding: 4px 8px; border-radius: 8px; background: rgba(255, 250, 242, .94);
  font-size: 12.5px; font-weight: 700; color: var(--wine); white-space: nowrap; box-shadow: 0 2px 6px rgba(59, 13, 28, .15);
}
.show-names .pin-name { display: block; }
.is-selected .pin { transform: scale(1.18); background: var(--wine); }
.is-selected .pin-name { display: block; background: var(--wine); color: var(--paper-2); }
.me { width: 18px; height: 18px; border-radius: 50%; background: #2a7ae2; border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(42, 122, 226, .2); }

/* Plovoucí tlačítka vpravo nad kartami */
.fabs { position: absolute; z-index: 500; right: 12px; bottom: calc(var(--rail-h) + var(--safe-b) + 28px); display: grid; gap: 10px; }
.fab {
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink);
  box-shadow: 0 4px 14px rgba(59, 13, 28, .16);
}
.fab[aria-pressed="true"] { color: var(--wine-2); border-color: var(--wine-2); }
.fab-accent { background: var(--wine); border-color: var(--wine); color: var(--paper-2); }
.fab.is-busy { opacity: .6; }

.toast {
  position: absolute; z-index: 600; left: 12px; right: 12px; top: 12px;
  padding: 12px 14px; border-radius: 14px; background: var(--ink); color: var(--paper-2);
  font-size: 14px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
}
.toast button { flex: none; border: 0; border-radius: 99px; padding: 8px 12px; background: var(--paper-2); color: var(--wine); font-weight: 700; font-size: 13px; }

/* Karty vinařství: vodorovně, se snapem */
.rail { position: absolute; z-index: 500; left: 0; right: 0; bottom: 0; padding-bottom: calc(10px + var(--safe-b)); }
.cards {
  list-style: none; margin: 0; padding: 0 12px; display: flex; gap: 10px;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 12px; scrollbar-width: none;
}
.cards::-webkit-scrollbar { display: none; }
.cards li { flex: 0 0 min(82%, 320px); scroll-snap-align: start; }
.card {
  width: 100%; height: calc(var(--rail-h) - 10px); display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 16px; background: var(--paper-2);
  box-shadow: 0 6px 18px rgba(59, 13, 28, .14);
}
.card.is-active { border-color: var(--wine-2); }
.card .pin { width: 40px; height: 40px; border-width: 0; box-shadow: none; }
.card-copy { min-width: 0; flex: 1; }
.card-copy strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-family: var(--serif); font-size: 17px; line-height: 1.2; }
.card-copy span { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-go { color: var(--wine-2); }

/* Detail: bottom sheet */
.sheet {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; max-height: 62vh; max-height: min(62dvh, calc(100dvh - var(--top-h) - var(--safe-t) - 140px)); overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain;
  background: var(--paper-2); border-radius: 20px 20px 0 0; padding-bottom: var(--safe-b);
  box-shadow: 0 -10px 30px rgba(59, 13, 28, .2); animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { position: sticky; top: 0; z-index: 1; height: 44px; background: var(--paper-2); }
.sheet-handle { position: absolute; left: 50%; top: 8px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line); }
.sheet-close { position: absolute; right: 8px; top: 4px; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--paper); }
.sheet-body { padding: 0 18px 22px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--wine-2); }
.sheet h2 { margin: 4px 0 4px; font-family: var(--serif); font-size: 24px; line-height: 1.15; color: var(--wine); }
.meta { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.story { line-height: 1.55; margin: 14px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.chips li { font-size: 13px; padding: 6px 10px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); }
.chips.varieties li { background: var(--wine-soft); border-color: transparent; color: var(--wine); font-weight: 600; }
.label { margin: 18px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.web {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; margin-top: 18px;
  border-radius: 14px; background: var(--wine); color: var(--paper-2); font-weight: 700; text-decoration: none;
}
.source { margin: 12px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.source a { color: inherit; }

@media (min-width: 760px) {
  :root { --rail-h: 0px; }
  .rail { left: auto; top: 0; right: 0; bottom: 0; width: 340px; padding: 12px; overflow-y: auto; background: var(--paper); border-left: 1px solid var(--line); }
  .cards { flex-direction: column; overflow: visible; padding: 0; }
  .cards li { flex: none; }
  .card { height: auto; min-height: 84px; }
  #map { right: 340px; }
  .fabs { right: 356px; bottom: 28px; }
  .leaflet-bottom.leaflet-right { bottom: 0; }
  .sheet { left: auto; right: 352px; bottom: 16px; width: 400px; border-radius: 20px; max-height: calc(100vh - 100px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 359px) {
  .net.is-ready { padding: 0 8px; }
  .net.is-ready #net-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
