html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #12232e;
  /* Space behind the globe when zoomed out */
  background: radial-gradient(ellipse at center, #0b3a55 0%, #04131d 70%);
}
#map { position: absolute; inset: 0; }
.maplibregl-canvas { outline: none; }

.brand-pill, .pill-btn, .demo-badge, .legend {
  background: rgba(255,255,255,.95);
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  border-radius: 999px;
}
.brand-pill {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  display: flex; align-items: center; gap: .45rem; padding: .45rem .9rem .45rem .55rem;
  text-decoration: none; color: #062a3d; font-weight: 700;
}
.brand-pill b { color: #1583a8; }
.top-right { position: absolute; top: 12px; right: 12px; z-index: 2; display: flex; gap: .5rem; }
.pill-btn { border: 0; padding: .5rem .85rem; font-weight: 700; color: #0b4f6c; cursor: pointer; font-size: .9rem; }

.demo-badge {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 2;
  padding: .35rem .8rem; font-size: .78rem; font-weight: 600; color: #5b6f7a; white-space: nowrap;
}
@media (max-width: 640px) { .demo-badge { top: 108px; left: 12px; transform: none; font-size: .7rem; } .layers-card { top: 140px; } }

.legends { position: absolute; left: 12px; bottom: 28px; z-index: 2; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.legend { border-radius: 12px; padding: .5rem .7rem; font-size: .75rem; max-width: calc(100vw - 90px); }
.legend[hidden] { display: none; }
.legend-title { display: block; font-weight: 700; margin-bottom: .25rem; color: #0b4f6c; }
.legend-row { display: flex; gap: .6rem; flex-wrap: wrap; color: #5b6f7a; }
.legend-row i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

.buoy-dot {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-size: .74rem; font-weight: 700; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.35); cursor: pointer;
  padding: 0; font-family: inherit;
}
.maplibregl-popup-content { border-radius: 12px; padding: .8rem 1rem; min-width: 190px; }
.popup h4 { margin: 0 0 .25rem; font-size: 1rem; }
.popup .big { font-size: 1.8rem; font-weight: 700; color: #0b4f6c; line-height: 1.1; }
.popup table { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: .35rem; }
.popup td { padding: .18rem 0; }
.popup td:last-child { text-align: right; font-weight: 600; }
.popup small { color: #5b6f7a; }

/* ---- Buoy panel ---- */
.panel {
  position: absolute; z-index: 3; top: 64px; right: 12px; width: 380px; max-height: calc(100% - 80px); overflow-y: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.25); padding: 1rem 1.1rem .9rem;
}
@media (max-width: 640px) {
  .panel { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 72%; border-radius: 18px 18px 0 0; }
}
.panel[hidden] { display: none; }
.panel h2 { margin: 0 2rem .5rem 0; font-size: 1.25rem; color: #062a3d; }
.panel-close { position: absolute; top: .55rem; right: .7rem; border: 0; background: #eef3f5; width: 30px; height: 30px; border-radius: 50%; font-size: 1.2rem; line-height: 1; cursor: pointer; color: #0b4f6c; }
.p-now { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: .5rem; align-items: end; margin-bottom: .8rem; }
.p-now > div { display: flex; flex-direction: column; }
.p-big { font-size: 2.1rem; font-weight: 700; color: #0b4f6c; line-height: 1; }
.p-mid { font-size: 1.15rem; font-weight: 700; color: #12232e; }
.p-sub { font-size: .75rem; color: #5b6f7a; margin-top: .2rem; }
.p-tabs { display: inline-flex; background: #eef3f5; border-radius: 999px; padding: 3px; margin-bottom: .55rem; }
.p-tabs button { border: 0; background: transparent; padding: .35rem .85rem; border-radius: 999px; font-weight: 600; font-size: .85rem; color: #5b6f7a; cursor: pointer; }
.p-tabs button[aria-selected="true"] { background: #fff; color: #0b4f6c; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.p-legend { display: flex; gap: 1rem; font-size: .78rem; color: #52514e; margin-bottom: .2rem; }
.p-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: 3px; }
.sw-s { background: #e0671f; } .sw-d { background: #1583a8; }
.p-chart { position: relative; }
.p-chart .grid { stroke: #e8eef0; stroke-width: 1; }
.p-chart .axis { font-size: 10.5px; fill: #7a8a92; }
.p-chart .endlabel { font-size: 11px; font-weight: 700; fill: #12232e; }
.p-chart .cross { stroke: #9aa9b0; stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip {
  position: absolute; top: 4px; transform: translateX(-50%); pointer-events: none;
  background: #12232e; color: #fff; border-radius: 8px; padding: .4rem .55rem; font-size: .75rem; min-width: 150px;
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
}
.chart-tip b { display: block; margin-bottom: .2rem; font-weight: 600; }
.chart-tip div { display: flex; align-items: center; gap: .35rem; }
.chart-tip div span { margin-left: auto; font-weight: 700; }
.chart-tip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.p-stats { display: flex; justify-content: space-between; font-size: .8rem; color: #5b6f7a; border-top: 1px solid #eef3f5; padding-top: .5rem; margin-top: .25rem; }
.p-stats b { color: #12232e; }
.p-demo { margin: .55rem 0 0; font-size: .72rem; color: #8a9aa2; }

/* ---- Layers ---- */
.layers-btn { position: absolute; top: 60px; left: 12px; z-index: 2; border-radius: 999px; display: flex; gap: .35rem; align-items: center; }
.layers-btn[aria-expanded="true"] { background: #0b4f6c; color: #fff; }
.layers-card {
  position: absolute; top: 102px; left: 12px; z-index: 3; width: 250px;
  background: #fff; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.22); padding: .75rem .9rem;
  display: flex; flex-direction: column; gap: .45rem; font-size: .9rem;
}
.layers-card[hidden] { display: none; }
.layers-card label { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.layers-card input[type=radio] { accent-color: #0b4f6c; }
.lc-opacity { flex-direction: column; align-items: stretch !important; gap: .2rem !important; font-size: .78rem; color: #5b6f7a; border-top: 1px solid #eef3f5; padding-top: .5rem; margin-top: .15rem; }
.lc-opacity input { accent-color: #0b4f6c; width: 100%; }
.lc-demo { margin: 0; font-size: .72rem; color: #8a9aa2; }

.timebar {
  position: absolute; z-index: 2; left: 50%; transform: translateX(-50%); top: 48px;
  display: flex; align-items: center; gap: .7rem; background: rgba(255,255,255,.96);
  border-radius: 999px; box-shadow: 0 2px 12px rgba(0,0,0,.2); padding: .4rem .9rem .4rem .45rem; font-size: .82rem;
}
.timebar[hidden] { display: none; }
.timebar button { border: 0; width: 32px; height: 32px; border-radius: 50%; background: #0b4f6c; color: #fff; cursor: pointer; font-size: .8rem; }
.timebar input { width: 180px; accent-color: #0b4f6c; }
.tb-label { min-width: 150px; color: #5b6f7a; white-space: nowrap; }
.tb-label b { color: #12232e; }
@media (max-width: 760px) {
  .timebar { top: auto; bottom: 190px; left: 12px; right: 12px; transform: none; padding-right: .7rem; }
  .timebar input { flex: 1; width: auto; min-width: 0; }
  .tb-label { min-width: 0; font-size: .75rem; }
}

/* ---- Buoy camera photo ---- */
.p-photo { margin: 0 0 .8rem; }
.p-photo-main { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: zoom-in; background: #eef3f5; aspect-ratio: 4 / 3; }
.p-photo-main img { width: 100%; height: 100%; object-fit: cover; display: block; }
.p-stamp { position: absolute; left: 8px; bottom: 8px; background: rgba(6,42,61,.72); color: #fff; font-size: .72rem; padding: .2rem .5rem; border-radius: 6px; font-variant-numeric: tabular-nums; }
.p-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; }
.p-thumbs button { position: relative; padding: 0; border: 2px solid transparent; border-radius: 7px; overflow: hidden; cursor: pointer; background: none; aspect-ratio: 4 / 3; }
.p-thumbs button[aria-pressed="true"] { border-color: #0b4f6c; }
.p-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.p-thumbs span { position: absolute; left: 0; right: 0; bottom: 0; font-size: .62rem; color: #fff; background: rgba(6,42,61,.6); padding: 1px 0; text-align: center; }
.p-photo-cap { font-size: .7rem; color: #8a9aa2; margin-top: .3rem; }
.lightbox { position: fixed; inset: 0; z-index: 20; background: rgba(4,19,29,.88); display: grid; place-items: center; padding: 3vmin; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox .panel-close { position: fixed; top: 14px; right: 14px; background: #fff; }

/* ---- Swimming advice ---- */
.p-advice { background: #f6f9fa; border-radius: 12px; padding: .65rem .75rem .6rem; margin-bottom: .8rem; }
.p-advice h3 { margin: 0 0 .45rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: #5b6f7a; }
.adv-row { display: grid; grid-template-columns: 30px 1fr auto; gap: .55rem; align-items: center; padding: .38rem 0; border-top: 1px solid #e8eef0; }
.adv-row:first-child { border-top: 0; }
.adv-ico { width: 30px; height: 30px; color: #0b4f6c; }
.adv-ico svg { width: 100%; height: 100%; }
.adv-txt b { display: block; font-size: .9rem; color: #12232e; }
.adv-txt span { font-size: .76rem; color: #5b6f7a; line-height: 1.3; display: block; }
.adv-chip { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; padding: .2rem .55rem .2rem .25rem; font-size: .76rem; font-weight: 700; color: #fff; white-space: nowrap; }
.adv-chip i { font-style: normal; width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.25); display: grid; place-items: center; font-size: .72rem; }
.p-cyano { margin-top: .55rem; padding-top: .5rem; border-top: 1px solid #e8eef0; }
.p-cyano-head { display: flex; justify-content: space-between; font-size: .82rem; color: #5b6f7a; }
.p-cyano-head b { color: #12232e; }
.p-scale { position: relative; height: 8px; border-radius: 4px; margin: .4rem 0 .2rem;
  background: linear-gradient(90deg, #1f9d6b 0 43.4%, #fff 43.4% calc(43.4% + 2px), #d9900f calc(43.4% + 2px) 66.7%, #fff 66.7% calc(66.7% + 2px), #c8412f calc(66.7% + 2px)); }
.p-scale i { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; border-radius: 2px; background: #12232e; box-shadow: 0 0 0 2px #fff; }
.p-scale-labels { position: relative; height: 1em; font-size: .64rem; color: #8a9aa2; }
.p-scale-labels span { position: absolute; transform: translateX(-50%); }
.p-scale-labels span:nth-child(1) { left: 0; transform: none; }
.p-scale-labels span:nth-child(2) { left: 43.4%; }
.p-scale-labels span:nth-child(3) { left: 66.7%; }
.p-scale-labels span:nth-child(4) { right: 0; transform: none; }
.p-adv-note { margin: .5rem 0 0; font-size: .68rem; color: #8a9aa2; line-height: 1.35; }

/* Warning badge on map markers */
.buoy-dot { overflow: visible; }  /* the marker is already absolutely positioned by MapLibre */
.buoy-badge { position: absolute; top: -5px; right: -6px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff;
  color: #fff; font-size: .62rem; font-weight: 800; display: grid; place-items: center; line-height: 1; }
