:root {
  --bg: #f5f1ea;
  --fg: #1d1a17;
  --fg-2: #6b625a;
  --line: #ddd3c6;
  --card: #ffffff;
  --accent: #b5452b;
  --ok: #2a8a5a;
  --warn: #c28a12;
  --bad: #b5452b;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f;
    --fg: #ece6dc;
    --fg-2: #a59a8d;
    --line: #322c25;
    --card: #1f1b16;
    --accent: #e0745a;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #15130f;
  --fg: #ece6dc;
  --fg-2: #a59a8d;
  --line: #322c25;
  --card: #1f1b16;
  --accent: #e0745a;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
.muted { color: var(--fg-2); }
.small { font-size: 13px; }

.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 1250;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; letter-spacing: 0.28em; font-size: 15px; }
.chips { display: flex; gap: 6px; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--card); white-space: nowrap;
}
.chip::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--fg-2); vertical-align: 1px; }
.chip[data-state="on"]::before { background: var(--ok); }
.chip[data-state="wait"]::before { background: var(--warn); animation: pulse 1.2s infinite; }
.chip[data-state="bad"]::before { background: var(--bad); }
@keyframes pulse { 50% { opacity: 0.3; } }

#map { position: fixed; inset: 0; z-index: 1; background: var(--bg); }
.leaflet-container { font: inherit; }
.leaflet-top { top: calc(env(safe-area-inset-top) + 48px); }

.fab {
  position: fixed; right: 16px; z-index: 1001;
  bottom: calc(var(--sheet-h, 150px) + 16px);
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); box-shadow: var(--shadow); display: grid; place-items: center;
  transition: bottom 0.25s;
}
.fab[data-follow="1"] { color: var(--accent); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 1300;
  top: calc(env(safe-area-inset-top) + 56px);
  background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: var(--shadow);
}

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  background: var(--card); border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; flex-direction: column;
  height: var(--sheet-h, 150px); transition: height 0.25s;
  max-width: 720px; margin: 0 auto;
}
.grip { border: 0; background: none; padding: 8px 0 2px; width: 100%; cursor: pointer; }
.grip span { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
.tabs { display: flex; gap: 4px; padding: 4px 12px 8px; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; border: 0; background: none; color: var(--fg-2); font: inherit; font-size: 14px;
  padding: 6px 4px; border-radius: 8px; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--fg); background: var(--bg); font-weight: 600; }
.pane { overflow-y: auto; padding: 8px 12px 16px; flex: 1; -webkit-overflow-scrolling: touch; }
.row { display: block; padding: 8px 4px; }

.item {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 4px; border-bottom: 1px solid var(--line); cursor: pointer; width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0; color: inherit; font: inherit; text-align: left;
}
.item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--line); }
.item .t { font-weight: 600; line-height: 1.25; }
.item .s { font-size: 13px; color: var(--fg-2); }
.item .d { font-size: 13px; color: var(--fg-2); text-align: right; white-space: nowrap; }
.item.inside .d { color: var(--ok); font-weight: 600; }
.item.visited .t::after { content: " ✓"; color: var(--ok); }

.route {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 8px 0; cursor: pointer;
  background: none; color: inherit; font: inherit; text-align: left; width: 100%;
}
.route[aria-pressed="true"] { border-color: var(--rc); box-shadow: inset 4px 0 0 var(--rc); }
.route h3 { margin: 0 0 4px; font-size: 16px; display: flex; justify-content: space-between; gap: 8px; }
.route p { margin: 0 0 6px; font-size: 14px; color: var(--fg-2); }
.route .stats { font-size: 13px; color: var(--fg-2); }
.stops { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: s; }
.stops li { counter-increment: s; padding: 6px 0 6px 34px; position: relative; font-size: 14px; border-top: 1px dashed var(--line); }
.stops li::before {
  content: counter(s); position: absolute; left: 0; top: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--rc); color: #fff; font-size: 12px; display: grid; place-items: center; font-weight: 600;
}
.stops li.done::before { content: "✓"; }
.stops li.next { font-weight: 600; }
.stops li .leg { display: block; font-size: 12px; color: var(--fg-2); font-weight: 400; }

.btn {
  display: inline-block; border: 0; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; text-align: center;
}
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); font-weight: 500; }
.btn.big { padding: 14px 22px; font-size: 17px; width: 100%; }

.card {
  position: fixed; inset: 0; z-index: 1200; padding-top: calc(env(safe-area-inset-top) + 45px); background: var(--card); overflow-y: auto;
  max-width: 720px; margin: 0 auto; -webkit-overflow-scrolling: touch;
}
.card .close {
  position: fixed; z-index: 1260; top: calc(env(safe-area-inset-top) + 58px); right: max(12px, calc(50% - 348px));
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer;
}
.photo { margin: 0; position: relative; background: var(--line); }
.photo img { display: block; width: 100%; height: min(46vh, 380px); object-fit: cover; }
.photo figcaption {
  position: absolute; right: 0; bottom: 0; font-size: 11px; color: #fff; background: rgba(0, 0, 0, 0.5);
  padding: 2px 8px; border-top-left-radius: 6px; max-width: 100%;
}
.photo figcaption a { color: #fff; }
.card-body { padding: 16px 16px calc(env(safe-area-inset-bottom) + 24px); }
.kind { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.card h2 { margin: 2px 0 4px; font-size: 26px; line-height: 1.2; }
.meta { font-size: 14px; color: var(--fg-2); margin-bottom: 12px; }
.text p { margin: 0 0 12px; font-size: 17px; line-height: 1.6; }
.tip { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 15px; }
.tip:empty { display: none; }
.tip::before { content: "Consejo · "; font-weight: 600; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.player { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }
.play {
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.track { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; cursor: pointer; }
#audio-bar { height: 100%; width: 0; background: var(--accent); }

.start {
  position: fixed; inset: 0; z-index: 1400; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(rgba(20, 16, 12, 0.55), rgba(20, 16, 12, 0.8)), url("/img/amfiteatre.jpg") center / cover;
  color: #fff;
}
.start-box { max-width: 420px; width: 100%; display: grid; gap: 12px; text-align: center; }
.start h1 { margin: 0; font-weight: 300; letter-spacing: 0.3em; font-size: 40px; }
.start p { margin: 0 0 8px; }
.start .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, 0.5); }
.start .muted { color: rgba(255, 255, 255, 0.75); }

.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--pc, #b5452b); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); color: #fff; font-size: 12px; font-weight: 700; }
.pin.visited { opacity: 0.6; }
.pin.inside { outline: 3px solid #fff; animation: pulse 1.4s infinite; }
.me { width: 18px; height: 18px; border-radius: 50%; background: #2a6fdb; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(42, 111, 219, 0.4); }
.me.stale { background: #8a8a8a; }

.facts, .links { margin-top: 20px; }
.facts h3, .links h3, .guide h3 { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-2); margin: 0 0 8px; }
.facts dl { margin: 0; display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: 6px 14px; font-size: 15px; }
.facts dt { color: var(--fg-2); }
.facts dd { margin: 0; }
.links ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.links a { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; text-decoration: none; font-size: 14px; }
.guide details { border-bottom: 1px solid var(--line); }
.guide summary { cursor: pointer; padding: 12px 4px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after { content: "+"; color: var(--fg-2); font-weight: 400; }
.guide details[open] summary::after { content: "−"; }
.guide .gbody { padding: 0 4px 14px; font-size: 15px; line-height: 1.6; }
.guide .gbody p { margin: 0 0 10px; }
.guide .gbody ul { margin: 0 0 10px; padding-left: 20px; }
.guide .gbody li { margin-bottom: 6px; }
.guide .tl { margin: 0; padding: 0; list-style: none; border-left: 2px solid var(--accent); }
.guide .tl li { padding: 0 0 12px 14px; position: relative; }
.guide .tl li::before { content: ""; position: absolute; left: -6px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.guide .tl b { display: block; font-size: 13px; color: var(--accent); }
.guide dl { margin: 0; }
.guide dt { font-weight: 600; margin-top: 8px; }
.guide dd { margin: 0; color: var(--fg-2); }
.tabs button { font-size: 13px; padding: 6px 2px; }
