:root {
  --brand: #6b7a3a;
  --brand-dark: #4f5a2a;
  --accent: #c8643b;
  --ink: #26261f;
  --ink-soft: #6a675b;
  --paper: #ffffff;
  --bg: #f7f3ea;
  --paper-2: #f1ece0;
  --line: #e4ddcc;
  --danger: #c62828;
  --tabbar-h: 64px;
  --top-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --shadow: 0 6px 24px rgba(38, 38, 31, .14);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2efe6; --ink-soft: #b5b0a0; --paper: #23231d; --bg: #181814; --paper-2: #2d2d25; --line: #3a3a30;
    --shadow: 0 6px 24px rgba(0, 0, 0, .45); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
body { padding-top: calc(var(--top-h) + var(--safe-t)); padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; z-index: 1100; left: 0; right: 0; top: 0; height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 12px 0 16px; display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.back-btn { width: 40px; height: 40px; margin-left: -8px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; flex: none; }
.back-btn[hidden] { display: none; }
.brand { flex: 1; min-width: 0; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 19px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#langSelect {
  appearance: none; -webkit-appearance: none; border: 1px solid var(--line); background: var(--paper);
  border-radius: 10px; padding: 8px 10px; font-weight: 700; font-size: 14px; color: var(--ink); flex: none;
}

.demo-strip {
  background: #ffcf5c; color: #2b2100; font-size: 12.5px; font-weight: 700; text-align: center; padding: 6px 12px; line-height: 1.3;
}
.demo-strip[hidden] { display: none; }

/* ---------- Views ---------- */
#view { padding: 16px 16px 28px; max-width: 640px; margin: 0 auto; outline: none; }
#view[hidden] { display: none; }
h1 { font-family: var(--serif); font-size: 28px; line-height: 1.15; margin: 4px 0 10px; }
h2 { font-family: var(--serif); font-size: 22px; margin: 22px 0 10px; }
h3 { margin: 22px 0 8px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }
p { font-size: 16px; line-height: 1.5; margin: 8px 0; }
.lead { font-size: 16.5px; line-height: 1.55; }

.hero {
  margin: -16px -16px 16px; height: 220px; position: relative; overflow: hidden;
  background: linear-gradient(170deg, #9fc3c9 0%, #4f8fa0 45%, #6b7a3a 46%, #4f5a2a 100%);
  display: flex; align-items: flex-end;
}
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-ph { position: relative; color: rgba(255, 255, 255, .92); font-size: 13px; padding: 12px 16px; display: flex; gap: 8px; align-items: center; }
.hero-ph svg { width: 18px; height: 18px; }

.host-card { display: flex; gap: 12px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 14px 0; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: 20px; flex: none; }
.host-card .who { flex: 1; min-width: 0; }
.host-card small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.host-card strong { font-size: 16px; }

.times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.time { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.time small { display: block; font-size: 12.5px; color: var(--ink-soft); }
.time strong { font-size: 24px; font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.tile {
  display: flex; flex-direction: column; gap: 10px; padding: 14px; min-height: 104px; text-decoration: none;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; transition: transform .12s ease;
}
.tile:active { transform: scale(.97); }
.tile .ti { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: var(--brand); }
.tile .ti svg { width: 22px; height: 22px; }
.tile strong { font-size: 15.5px; }
.tile small { color: var(--ink-soft); font-size: 12.5px; margin-top: -6px; }
.tile.sos .ti { background: var(--danger); }
.tile.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; min-height: 0; }

/* cards & lists */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin: 10px 0; }
.wifi-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.wifi-row:last-of-type { border-bottom: 0; }
.wifi-row small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.wifi-row code { font-family: ui-monospace, Menlo, monospace; font-size: 17px; font-weight: 600; word-break: break-all; }
.copy-btn { flex: none; border: 0; background: var(--brand); color: #fff; border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.copy-btn.done { background: #2e7d32; }
.wifi-where { font-weight: 700; font-size: 13px; color: var(--brand); text-transform: uppercase; letter-spacing: .05em; }

.rule-list, .step-list { list-style: none; margin: 0; padding: 0; }
.rule-list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 16px; line-height: 1.45; }
.rule-list li:last-child { border-bottom: 0; }
.rule-list .ri { width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--paper-2); color: var(--brand); display: grid; place-items: center; }
.rule-list .ri svg { width: 20px; height: 20px; }
.step-list { counter-reset: s; }
.step-list li { counter-increment: s; display: flex; gap: 12px; padding: 10px 0; font-size: 16px; line-height: 1.45; }
.step-list li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; flex: none; margin-top: 1px; }
.check-list li::before { content: "✓"; background: var(--paper-2); color: var(--brand); }

details.acc { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; margin: 8px 0; }
details.acc summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 12px 14px; font-weight: 700; font-size: 16px; cursor: pointer; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); transform: rotate(45deg); transition: transform .2s; }
details.acc[open] summary::after { transform: rotate(-135deg); }
details.acc .acc-body { padding: 0 16px 14px 60px; font-size: 15.5px; line-height: 1.5; color: var(--ink); }

.primary-btn, .ghost-btn, .danger-btn {
  border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 750; font-size: 15px; text-decoration: none; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: 1 1 auto;
}
.primary-btn { background: var(--brand); color: #fff; }
.ghost-btn { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line); }
.danger-btn { background: var(--danger); color: #fff; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.sos-big { display: grid; gap: 10px; margin: 14px 0; }
.sos-big a, .sos-big button { padding: 16px; font-size: 17px; }
.sos-big .danger-btn strong { font-size: 22px; }
.contact { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.contact:last-child { border-bottom: 0; }
.contact small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.contact a { flex: none; text-decoration: none; font-weight: 700; color: var(--brand); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.address { font-size: 15px; line-height: 1.4; }
.pending { display: inline-block; background: #fff1c2; color: #6b4e00; border: 1px dashed #d9b44a; border-radius: 8px; padding: 2px 8px; font-size: 13px; font-weight: 700; font-family: inherit; }
.facts { margin: 4px 0 12px; }
.madeby { text-align: center; margin: 14px 0 0; }
.madeby a { font-size: 12px; font-weight: 500; opacity: .75; text-decoration: none; color: inherit; }
.fine { font-size: 12.5px; color: var(--ink-soft); line-height: 1.45; }

/* ---------- Map screen ---------- */
.map-screen { position: fixed; z-index: 10; left: 0; right: 0; top: calc(var(--top-h) + var(--safe-t)); bottom: calc(var(--tabbar-h) + var(--safe-b)); }
.map-screen[hidden] { display: none; }
#map { position: absolute; inset: 0; background: #cdd; }
.map-filters {
  position: absolute; z-index: 1000; left: 0; right: 0; top: 10px; display: flex; gap: 6px; overflow-x: auto;
  padding: 0 12px; scrollbar-width: none;
}
.map-filters button {
  flex: none; border: 0; background: var(--paper); border-radius: 999px; padding: 8px 13px; font-size: 13.5px; font-weight: 700;
  box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 6px;
}
.map-filters button.on { background: var(--ink); color: var(--bg); }
.map-filters .dot { width: 9px; height: 9px; border-radius: 50%; }
.map-buttons { position: absolute; z-index: 999; right: 12px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.round-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); display: grid; place-items: center; }
.round-btn.on { color: #fff; background: #1d8fe0; }

.sheet {
  position: absolute; z-index: 1001; left: 0; right: 0; bottom: 0;
  max-height: 72%; background: var(--paper); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .22);
  transform: translateY(110%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column;
}
.sheet.open { transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 4px; flex: none; }
.sheet-close { position: absolute; right: 10px; top: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--paper-2); font-size: 22px; line-height: 1; z-index: 2; }
.sheet-body { overflow-y: auto; padding: 4px 16px 18px; -webkit-overflow-scrolling: touch; }
.sheet h2 { margin: 6px 44px 4px 0; font-size: 22px; }
.sheet p { font-size: 15.5px; }

.photo {
  margin: 0 -16px 12px; height: 170px; position: relative; overflow: hidden;
  background: linear-gradient(160deg, #1fa3b0 0%, #0e6f9a 55%, #0b3f5c 100%);
  display: flex; align-items: flex-end; color: rgba(255, 255, 255, .92);
}
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-ph { position: relative; padding: 12px 16px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.photo-ph svg { width: 18px; height: 18px; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.tag { background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.dist-line { font-size: 14px; color: var(--ink-soft); margin: 8px 0 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list button { width: 100%; border: 0; background: none; text-align: left; padding: 12px 2px; display: flex; align-items: center; gap: 12px; }
.list .li-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.list .li-main { flex: 1; min-width: 0; }
.list .li-title { font-weight: 700; font-size: 15px; }
.list .li-sub { font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .li-right { font-size: 13px; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; z-index: 1100; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(4, 1fr); background: var(--paper); border-top: 1px solid var(--line);
}
.tab { text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--brand); }
.tab-sos, .tab-sos.active { color: var(--danger); }

.toast {
  position: fixed; z-index: 2000; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Leaflet markers ---------- */
.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  display: grid; place-items: center; border: 2.5px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}
.pin svg { transform: rotate(45deg); width: 16px; height: 16px; color: #fff; }
.pin.sel { outline: 3px solid #ffb020; outline-offset: 2px; }
.pin.villa { width: 38px; height: 38px; background: var(--accent); }
.pin.villa svg { width: 20px; height: 20px; }
.me-dot { width: 20px; height: 20px; border-radius: 50%; background: #1d8fe0; border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(29, 143, 224, .25), 0 2px 8px rgba(0, 0, 0, .4); }
.leaflet-control-attribution { font-size: 9px; }
.leaflet-control-zoom { display: none; }
