:root {
  --sol: #f2a516;
  --sol-deep: #c97c00;
  --sol-soft: #fff1d1;
  --sombra: #1f2a44;
  --sombra-mid: #3d4d72;
  --sombra-soft: #e4e8f2;
  --bg: #fffaf1;
  --card: #ffffff;
  --ink: #1b2133;
  --muted: #6b7286;
  --line: #ebe4d6;
  --shadow: 0 6px 24px rgba(20, 26, 45, .18);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161b29;
    --card: #1e2436;
    --ink: #f1ede4;
    --muted: #a3a9bb;
    --line: #2c3448;
    --sol-soft: #3a2f17;
    --sombra-soft: #27304a;
    --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
#map { position: fixed; inset: 0; }

/* ---------- barra superior ---------- */
.topbar {
  position: fixed; z-index: 5;
  top: calc(10px + var(--safe-t)); left: 10px; right: 10px;
  display: flex; gap: 8px; align-items: center;
}
.brand, .iconbtn {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: var(--card); box-shadow: var(--shadow);
  display: grid; place-items: center; padding: 0;
}
.iconbtn { color: var(--sombra-mid); }
.iconbtn.active { color: var(--sol-deep); }
.search { flex: 1; min-width: 0; }
.search input {
  width: 100%; height: 46px; border-radius: 23px; border: 0;
  padding: 0 18px; font: inherit; font-size: 16px;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow);
  outline: none;
}
.search input:focus { box-shadow: var(--shadow), 0 0 0 3px var(--sol); }

.chips {
  position: fixed; z-index: 4; top: calc(64px + var(--safe-t)); left: 0; right: 0;
  display: flex; gap: 6px; overflow-x: auto; padding: 0 10px 6px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; border-radius: 16px; padding: 6px 12px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  box-shadow: 0 2px 8px rgba(20, 26, 45, .14); font-size: 13px; font-weight: 600;
}

.notice, .weather {
  position: fixed; z-index: 4; left: 50%; transform: translateX(-50%);
  top: calc(104px + var(--safe-t));
  background: var(--sombra); color: #fff; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 16px; box-shadow: var(--shadow);
  white-space: nowrap; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis;
}
.weather { top: auto; left: auto; right: 10px; transform: none; background: var(--card); color: var(--ink); bottom: calc(var(--sheet-h, 210px) + 12px); }
.notice.loading::after {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 8px;
  border: 2px solid var(--sol); border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- panel inferior ---------- */
.sheet {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0;
  background: var(--bg); border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -6px 28px rgba(20, 26, 45, .22);
  padding: 0 14px calc(10px + var(--safe-b));
  display: flex; flex-direction: column;
  max-height: 72vh; transition: max-height .25s ease;
}
.sheet[data-state="peek"] { max-height: calc(212px + var(--safe-b)); overflow: hidden; }
.sheet[data-state="peek"].has-detail { max-height: calc(390px + var(--safe-b)); }
.grabber {
  border: 0; background: none; height: 22px; display: grid; place-items: center; padding: 0; flex: none;
}
.grabber span { width: 42px; height: 5px; border-radius: 3px; background: var(--line); }

.timebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.clock { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sunicon { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--sol); box-shadow: 0 0 0 6px var(--sol-soft); transition: background .2s, box-shadow .2s; }
.sunicon.night { background: var(--sombra-mid); box-shadow: 0 0 0 6px var(--sombra-soft); }
.time { font-size: 26px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; line-height: 1.05; }
.sub { font-size: 12.5px; color: var(--muted); }
.timectl { display: flex; gap: 6px; align-items: center; }
.timectl input[type=date] {
  font: inherit; font-size: 14px; min-width: 0; border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 8px; background: var(--card); color: var(--ink); max-width: 132px;
}
.pill {
  white-space: nowrap; flex: none;
  border: 0; border-radius: 14px; padding: 7px 13px; font-weight: 700; font-size: 14px;
  background: var(--sombra); color: #fff;
}
.pill.live { background: var(--sol); color: var(--sombra); }
.pill.big { padding: 11px 20px; font-size: 15px; margin-top: 6px; }

.slider { flex: none; padding: 8px 2px 2px; }
.slider input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 30px; margin: 0;
  background: transparent;
}
.slider input[type=range]::-webkit-slider-runnable-track {
  height: 10px; border-radius: 5px; background: var(--track, linear-gradient(90deg, var(--sombra-mid), var(--sol), var(--sombra-mid)));
}
.slider input[type=range]::-moz-range-track {
  height: 10px; border-radius: 5px; background: var(--track, linear-gradient(90deg, var(--sombra-mid), var(--sol), var(--sombra-mid)));
}
.slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9px; border-radius: 50%;
  background: #fff; border: 4px solid var(--sombra); box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.slider input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 4px solid var(--sombra);
}
.ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 0 4px; }

.filters { display: flex; gap: 6px; margin: 10px 0 8px; flex: none; }
.seg {
  flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 8px 4px; font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.seg b { font-variant-numeric: tabular-nums; margin-left: 2px; opacity: .7; }
.seg[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg.sol[aria-pressed="true"] { background: var(--sol); color: var(--sombra); border-color: var(--sol); }
.seg.sombra[aria-pressed="true"] { background: var(--sombra); color: #fff; border-color: var(--sombra); }

.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.list li {
  display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); cursor: pointer;
}
.list li:first-child { border-top: 0; }
.dot { flex: none; width: 14px; height: 14px; border-radius: 50%; }
.dot.sun { background: var(--sol); box-shadow: 0 0 0 4px var(--sol-soft); }
.dot.shade { background: var(--sombra-mid); box-shadow: 0 0 0 4px var(--sombra-soft); }
.dot.night { background: #555c70; }
.li-main { flex: 1; min-width: 0; }
.li-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-dist { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { padding: 14px 4px; color: var(--muted); font-size: 14px; border: 0 !important; cursor: default !important; }

.toggle { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); padding: 8px 2px 0; flex: none; }
.toggle input { accent-color: var(--sol-deep); width: 18px; height: 18px; }

/* ---------- ficha de una terraza ---------- */
.detail {
  background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; flex: none;
  border: 1px solid var(--line);
}
.d-head { display: flex; align-items: flex-start; gap: 10px; }
.d-head h3 { margin: 0; font-size: 17px; line-height: 1.25; flex: 1; }
.d-close { border: 0; background: var(--line); width: 28px; height: 28px; border-radius: 50%; flex: none; font-size: 16px; line-height: 1; }
.d-kind { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.badge { display: inline-block; font-weight: 800; font-size: 13px; padding: 3px 10px; border-radius: 10px; margin-top: 8px; }
.badge.sun { background: var(--sol); color: var(--sombra); }
.badge.shade { background: var(--sombra); color: #fff; }
.badge.night { background: #555c70; color: #fff; }
.d-text { font-size: 13.5px; margin-top: 6px; }
.tl { position: relative; height: 16px; border-radius: 8px; overflow: hidden; display: flex; margin-top: 10px; background: #555c70; }
.tl i { flex: 1; }
.tl i.sun { background: var(--sol); }
.tl i.shade { background: var(--sombra-mid); }
.tl i.night { background: #3a3f50; }
.tl .now { position: absolute; top: -2px; bottom: -2px; width: 3px; background: #fff; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.tl-ticks { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.d-links { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.d-links a {
  font-size: 13px; font-weight: 700; text-decoration: none; color: var(--sombra);
  background: var(--sol-soft); padding: 6px 11px; border-radius: 10px;
}
@media (prefers-color-scheme: dark) { .d-links a { color: var(--sol); } }

/* ---------- acerca de ---------- */
dialog {
  border: 0; border-radius: 22px; padding: 0; max-width: min(420px, calc(100% - 32px));
  background: var(--bg); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(15, 20, 35, .5); }
.about { padding: 22px 22px 18px; text-align: center; }
.about h2 { margin: 8px 0 2px; font-size: 24px; }
.about .tag { margin: 0 0 12px; color: var(--sol-deep); font-weight: 700; font-style: italic; }
.about p { margin: 0 0 10px; }
.about .fine { font-size: 12.5px; color: var(--muted); }
.about a { color: inherit; }

/* MapLibre */
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: calc(var(--sheet-h, 210px) + 4px); }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* ---------- escritorio: panel lateral ---------- */
@media (min-width: 820px) {
  .topbar { right: auto; width: 400px; }
  .chips { width: 420px; }
  .sheet, .sheet[data-state="peek"], .sheet[data-state="peek"].has-detail {
    top: calc(120px + var(--safe-t)); bottom: 12px; left: 10px; right: auto; width: 400px;
    max-height: none; border-radius: var(--radius); padding-bottom: 12px; overflow: hidden;
  }
  .grabber { display: none; }
  .notice { left: calc(50% + 210px); }
  .weather { bottom: 30px; }
  .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: 0; }
}
