:root {
  --sun: #ffb81c;
  --sun-strong: #f59e0b;
  --sun-soft: #ffe08a;
  --shade: #8a94a6;
  --night: #4b5563;
  --bg: #ffffff;
  --bg-2: #f6f5f1;
  --fg: #1c1f26;
  --fg-2: #5c6370;
  --line: #e6e3db;
  --accent: #e8590c;
  --shadow: 0 6px 24px rgba(20, 20, 30, 0.16);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171a21;
    --bg-2: #22262f;
    --fg: #eef0f4;
    --fg-2: #a3aab8;
    --line: #2f3440;
    --shade: #6b7486;
    --night: #3a4150;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* collapsed sheet height; grows by the "sunny near you" strip once we know where you are */
body { --sheet-peek: calc(210px + var(--nearby-h, 0px)); }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
/* iOS app: no text selection or long-press callouts, like a native app */
.native body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

#map { position: fixed; inset: 0; background: var(--bg-2); }
.leaflet-container { font: inherit; }
/* Map credits: required (Stadia Maps, OpenMapTiles, OpenStreetMap), but small and quiet. */
.leaflet-container .leaflet-control-attribution {
  font-size: 9px; line-height: 1.5; padding: 0 6px; border-radius: 6px 0 0 0;
  background: rgba(255, 255, 255, .55); color: #6b7280;
}
.leaflet-container .leaflet-control-attribution a { color: inherit; text-decoration: none; }
@media (prefers-color-scheme: dark) {
  .leaflet-container .leaflet-control-attribution { background: rgba(23, 26, 33, .55); color: #8a919e; }
}
/* calm the basemap down so the sun/shade dots stand out */
.basemap { filter: saturate(0.45) brightness(1.04); }
@media (prefers-color-scheme: dark) {
  .basemap { filter: invert(1) hue-rotate(180deg) saturate(0.35) brightness(0.85) contrast(0.95); }
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: fixed; top: calc(10px + var(--safe-t)); left: 12px; right: 12px; z-index: 500;
  display: flex; gap: 8px; align-items: center; pointer-events: none;
}
.brand, .weather {
  pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border-radius: 999px; box-shadow: var(--shadow);
  padding: 6px 14px 6px 8px; font-weight: 700; letter-spacing: -0.01em;
}
.brand span { font-size: 17px; }
.weather { font-weight: 600; font-size: 14px; padding: 7px 12px; margin-left: auto; white-space: nowrap; }
.weather .t { color: var(--fg-2); font-weight: 500; }

.cloud-note {
  position: fixed; top: calc(62px + var(--safe-t)); left: 12px; right: 12px; margin: 0 auto; width: fit-content; z-index: 500;
  background: var(--bg); color: var(--fg-2); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px 12px; font-size: 13px; max-width: calc(100vw - 24px); text-align: center;
}

.fabs {
  position: fixed; right: 12px; z-index: 500;
  bottom: calc(var(--sheet-peek) + 14px + var(--safe-b));
  display: flex; flex-direction: column; gap: 10px;
  transition: bottom 0.25s ease;
}
.fab {
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--bg); box-shadow: var(--shadow); display: grid; place-items: center;
}
.fab.active { color: var(--accent); }

/* ---------------------------------------------------------------- sheet */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 600;
  height: min(78vh, 680px);
  transform: translateY(calc(100% - var(--sheet-peek) - var(--safe-b)));
  transition: transform 0.28s cubic-bezier(.2, .8, .2, 1);
  background: var(--bg); border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-b);
}
.sheet.open { transform: translateY(0); }
body.sheet-open .fabs { bottom: calc(min(78vh, 680px) + 14px); opacity: 0; pointer-events: none; }
.sheet-handle {
  border: 0; background: none; padding: 8px 0 4px; display: flex; justify-content: center; flex: none;
}
.sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }

.timebar { display: flex; align-items: center; gap: 10px; padding: 6px 14px 4px; flex: none; }
.day-toggle { display: flex; background: var(--bg-2); border-radius: 10px; padding: 2px; flex: none; }
.day-toggle button {
  border: 0; background: none; padding: 5px 9px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--fg-2);
}
.day-toggle button.active { background: var(--bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
#time { flex: 1; min-width: 60px; accent-color: var(--sun-strong); }
#timeLabel { font-variant-numeric: tabular-nums; font-weight: 700; width: 44px; text-align: right; }
.now-btn {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 4px 8px; font-size: 13px; font-weight: 600;
}
.now-btn.live { border-color: transparent; background: var(--sun); color: #3b2500; }

.filters { display: flex; gap: 6px; padding: 8px 14px 4px; overflow-x: auto; flex: none; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 5px 12px;
  font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--fg-2);
}
.chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* "sunny near you": the three closest terraces in the sun */
.nearby { padding: 10px 14px 2px; flex: none; }
.nearby[hidden] { display: none; }
.nearby-title { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-2); margin-bottom: 6px; }
.nearby-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.nearby-list li {
  min-width: 0; padding: 7px 10px 8px; border-radius: 12px; cursor: pointer;
  background: color-mix(in srgb, var(--sun) 22%, var(--bg));
}
.nearby-list li[data-kind="part"] { background: color-mix(in srgb, var(--sun-soft) 30%, var(--bg)); }
.nearby-list li:hover, .nearby-list li:focus-visible { outline: 2px solid var(--sun-strong); outline-offset: -2px; }
.nearby-list .top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.nearby-list .dist { font-weight: 700; font-variant-numeric: tabular-nums; }
.nearby-list .name { font-weight: 650; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nearby-list .sub { color: var(--fg-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nearby-list li.empty { grid-column: 1 / -1; background: none; padding: 2px 0; cursor: default; color: var(--fg-2); font-size: 13px; outline: none; }

.summary { margin: 6px 16px 2px; color: var(--fg-2); font-size: 13px; flex: none; }
.list { list-style: none; margin: 0; padding: 0 6px 12px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.list li {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 10px; border-radius: 12px; cursor: pointer;
}
.list li:hover, .list li:focus-visible { background: var(--bg-2); outline: none; }
.list .ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; }
.list .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { color: var(--fg-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .dist { color: var(--fg-2); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.list .more { text-align: center; color: var(--fg-2); font-size: 13px; display: block; cursor: default; }

/* ---------------------------------------------------------------- detail */
.detail {
  position: fixed; left: 10px; right: 10px; z-index: 700;
  bottom: calc(var(--sheet-peek) + 10px + var(--safe-b));
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px 14px;
}
.detail h2 { margin: 0 28px 2px 0; font-size: 19px; letter-spacing: -0.01em; }
.detail .meta { margin: 0; color: var(--fg-2); font-size: 13px; }
.detail .status { margin: 10px 0 8px; font-weight: 650; font-size: 15px; }
.detail .note { margin: -2px 0 8px; color: var(--fg-2); font-size: 12px; white-space: pre-line; }
.detail .close {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: var(--bg-2); font-size: 20px; line-height: 1;
}
.timeline-wrap { position: relative; }
.timeline { width: 100%; height: 44px; display: block; border-radius: 8px; }
.timeline-labels { display: flex; justify-content: space-between; color: var(--fg-2); font-size: 11px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions a, .actions button {
  flex: 1; text-align: center; text-decoration: none; font: inherit; font-weight: 650; font-size: 14px;
  padding: 9px; border: 0; border-radius: 10px; background: var(--bg-2); color: var(--fg); cursor: pointer;
}
.actions a:first-child { background: var(--sun); color: #3b2500; }
.actions a[hidden] { display: none; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2000;
  padding: 8px 14px; border-radius: 999px; background: var(--fg); color: var(--bg); font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast[hidden] { display: none; }

/* ---------------------------------------------------------------- markers */
.terrace-dot { transition: none; }

/* ---------------------------------------------------------------- about */
.about {
  border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px;
  max-width: min(520px, calc(100vw - 32px)); background: var(--bg); color: var(--fg);
}
.about::backdrop { background: rgba(0, 0, 0, 0.35); }
.about h2 { margin-top: 0; }
.about p, .about li { color: var(--fg-2); font-size: 14px; }
.about a { color: var(--accent); }
.about form { text-align: right; }
.about button { border: 0; background: var(--sun); color: #3b2500; font-weight: 700; padding: 8px 18px; border-radius: 10px; }

/* ---------------------------------------------------------------- loading */
.loading { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; background: var(--bg); transition: opacity .3s; }
.loading.done { opacity: 0; pointer-events: none; }
.sun-spinner {
  width: 54px; height: 54px; border-radius: 50%; background: var(--sun);
  box-shadow: 0 0 0 10px rgba(255, 184, 28, .25), 0 0 0 22px rgba(255, 184, 28, .12);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(.85); } }

/* ---------------------------------------------------------------- desktop */
@media (min-width: 900px) {
  body { --sheet-peek: 0px; }
  .topbar { left: 412px; }
  .cloud-note { left: 412px; }
  .sheet {
    top: 12px; left: 12px; bottom: 12px; right: auto; width: 388px; height: auto;
    transform: none; border-radius: var(--radius);
  }
  .sheet-handle { display: none; }
  .sheet .timebar { padding-top: 14px; }
  .fabs { bottom: 28px; }
  body.sheet-open .fabs { bottom: 28px; opacity: 1; pointer-events: auto; }
  .detail { left: auto; right: 72px; bottom: 20px; width: 380px; }
}
.about .small { font-size: 12px; }
