:root {
  --navy: #0b2e4f;
  --sea: #1c7c9c;
  --sand: #f6efe1;
  --ink: #1b2733;
  --muted: #5b6875;
  --card: #ffffff;
  --line: #e4dccb;
  --bg: var(--sand);
  --accent: #d9603b;
  --great: #1f9d63;
  --good: #7bb03a;
  --fair: #e0a526;
  --poor: #c9483b;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(11 46 79 / 8%), 0 4px 14px rgb(11 46 79 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8edf2;
    --muted: #9aa8b5;
    --card: #14263a;
    --line: #22384f;
    --bg: #0a1826;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; margin-top: 1.1rem; }
p { margin: .5rem 0; }
a { color: var(--sea); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 1100;
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
  padding: calc(.75rem + env(safe-area-inset-top, 0px)) 1rem .75rem;
  background: var(--navy); color: #fff;
}
.topbar .muted { color: #b7c7d6; }
.brand { display: flex; gap: .6rem; align-items: center; }
.brand-mark { font-size: 1.8rem; }
.brand h1 { font-size: 1.15rem; letter-spacing: .01em; }
.controls { display: flex; gap: .5rem; flex-wrap: wrap; }
select {
  font: inherit; padding: .4rem .6rem; border-radius: 10px; border: 1px solid #2e5578;
  background: #123d63; color: #fff;
}
.seg { display: inline-flex; border: 1px solid #2e5578; border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: #cfe0ee; padding: .4rem .75rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--sea); color: #fff; }
.linkish { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; }
.topbar .linkish { color: #fff; }

main { max-width: 860px; margin: 0 auto; padding: 1rem; }

/* ---- cards ---- */
.card {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; margin: 0 0 .75rem;
}
button.card { cursor: pointer; }
button.card:hover, .row:hover { border-color: var(--sea); }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cards > li > .card, .cards > li.card { margin: 0; height: 100%; }
.section-title { margin: 1.4rem 0 .7rem; display: flex; gap: .5rem; align-items: baseline; }
.error { border-color: var(--poor); }
.skeleton { color: var(--muted); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.hero { background: linear-gradient(135deg, var(--navy), var(--sea)); color: #fff; border: 0; }
.hero .muted { color: #cfe3ef; }
.hero-main { display: flex; gap: 1rem; align-items: center; }
.hero-icon { font-size: 3rem; line-height: 1; }
.hero-temp { font-size: 2rem; font-weight: 700; margin: 0; }
.hero-temp .muted { font-size: 1rem; font-weight: 500; }
.hero-sun { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .9rem; }
.hero-sun > div { background: rgb(255 255 255 / 12%); border-radius: 10px; padding: .5rem .6rem; display: flex; flex-direction: column; }
.hero-tides { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .8rem; }
.hero-tides > .muted { width: 100%; }
.tide { font-size: .85rem; padding: .15rem .5rem; border-radius: 999px; background: rgb(28 124 156 / 15%); }
.hero .tide { background: rgb(255 255 255 / 16%); }
.tip { margin: .8rem 0 0; padding: .55rem .7rem; border-radius: 10px; background: rgb(255 255 255 / 12%); font-size: .9rem; }

/* ---- activity grid ---- */
.acts { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 640px) { .acts { grid-template-columns: repeat(3, 1fr); } }
.act {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "icon name pill" "where where where" "why why why";
  gap: .15rem .5rem; align-items: center; text-align: left; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: .7rem;
}
.act.on { border-color: var(--sea); }
.act-icon { grid-area: icon; font-size: 1.3rem; }
.act-name { grid-area: name; font-weight: 600; font-size: .9rem; }
.act .pill { grid-area: pill; }
.act-where { grid-area: where; font-size: .85rem; margin-top: .3rem; }
.act-why { grid-area: why; font-size: .78rem; }

.pill {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 2.8rem; padding: .15rem .4rem; border-radius: 10px; color: #fff; font-weight: 700; line-height: 1.1;
}
.pill small { font-size: .62rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pill.great { background: var(--great); }
.pill.good { background: var(--good); }
.pill.fair { background: var(--fair); color: #3a2a00; }
.pill.poor { background: var(--poor); }

.rank { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.row {
  display: flex; gap: .75rem; align-items: center; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .8rem;
}
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rank-n { font-weight: 700; color: var(--sea); width: 1.2rem; }

/* ---- chips & tags ---- */
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .6rem; margin-bottom: .4rem; scrollbar-width: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: .35rem .8rem; cursor: pointer; font-size: .85rem; white-space: nowrap;
}
.chip.on { background: var(--sea); border-color: var(--sea); color: #fff; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }
.tag { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; background: rgb(28 124 156 / 12%); color: var(--sea); white-space: nowrap; }
.warn { color: var(--poor); display: block; }

.beach-card, .route-card, .lh-card { display: flex; flex-direction: column; gap: .15rem; }
.beach-head { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.route-card { border-left: 5px solid var(--route); }
.lh-card.visited { border-color: var(--great); }
.stamp { color: var(--great); font-weight: 700; font-size: .85rem; }
.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin-bottom: .8rem; }
.progress span { display: block; height: 100%; background: var(--great); transition: width .3s; }

.tips { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tips .card { margin: 0; }
summary { cursor: pointer; font-weight: 600; }
.footer-note { margin-top: 1.5rem; text-align: center; }

/* ---- map ---- */
#map { height: calc(100vh - 230px); min-height: 360px; border-radius: var(--radius); border: 1px solid var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; align-items: center; }
.dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; background: var(--c); margin-right: .25rem; vertical-align: -1px; }
.dot.lh { background: none; }
.dot.lh::before { content: "🗼"; font-size: .8rem; }
.beach-marker {
  display: flex !important; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font: 700 12px/1 system-ui, sans-serif; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
}
.beach-marker.great { background: var(--great); }
.beach-marker.good { background: var(--good); }
.beach-marker.fair { background: var(--fair); }
.beach-marker.poor { background: var(--poor); }
.beach-marker.unknown { background: var(--sea); }
.lh-marker { font-size: 20px; line-height: 24px; text-align: center; filter: drop-shadow(0 1px 1px rgb(0 0 0 / 40%)); }

/* ---- bottom tabs ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar button {
  flex: 1; max-width: 140px; border: 0; background: none; cursor: pointer;
  padding: .45rem 0 .5rem; display: flex; flex-direction: column; align-items: center; gap: .1rem;
  font-size: .72rem; color: var(--muted);
}
.tabbar button span { font-size: 1.25rem; filter: grayscale(.7); }
.tabbar button[aria-current="page"] { color: var(--sea); font-weight: 600; }
.tabbar button[aria-current="page"] span { filter: none; }

/* ---- sheet ---- */
dialog {
  width: min(560px, 100vw); max-height: 88vh; margin: auto auto 0; padding: 1.25rem 1.1rem 2rem;
  border: 0; border-radius: 18px 18px 0 0; background: var(--card); color: var(--ink); overflow-y: auto;
}
@media (min-width: 700px) { dialog { margin: auto; border-radius: 18px; } }
dialog::backdrop { background: rgb(5 20 35 / 55%); }
.sheet-close { position: sticky; top: 0; float: right; border: 0; background: var(--line); border-radius: 50%; width: 2rem; height: 2rem; cursor: pointer; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: .9rem 0; }
.stats > div { background: var(--bg); border-radius: 10px; padding: .5rem; display: flex; flex-direction: column; }
.score-list { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .45rem; }
.score-list li { display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; align-items: center; }
.score-list li .muted { grid-column: 1 / -1; }
.stops { padding-left: 1.2rem; }
.actions { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--sea);
  background: var(--sea); color: #fff; text-decoration: none; cursor: pointer; font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--sea); }

@media (max-width: 480px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding-inline: .75rem; }
  main { padding: .75rem; }
}

.geo-banner {
  margin: 0 0 .75rem; padding: .55rem .8rem; border-radius: 10px;
  background: rgb(42 125 225 / 10%); border: 1px solid rgb(42 125 225 / 25%);
}

/* ---- Today: landing picker & results bar ---- */
.place-btn {
  border: 1px solid #2e5578; background: #123d63; color: #fff; border-radius: 10px;
  padding: .4rem .7rem; cursor: pointer; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.place-main { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.place-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.region { margin: 1rem 0 .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.place {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  text-align: left; cursor: pointer; font-weight: 600;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: .6rem .75rem;
}
.place:hover { border-color: var(--sea); }
.place.on { border-color: var(--sea); }
.place > small { display: block; width: 100%; font-weight: 400; color: var(--muted); font-size: .78rem; }
.place-main .place { background: var(--sea); border-color: var(--sea); color: #fff; padding: .8rem; }
.place-main .place > small { color: #d8eef5; }
.place-main .place + .place { background: var(--card); color: var(--ink); border-color: var(--line); }
.place-main .place + .place > small { color: var(--muted); }
.place .pill { min-width: 2.4rem; flex: none; }
.place-grid .place { flex-wrap: nowrap; font-size: .9rem; padding: .55rem .6rem; overflow-wrap: anywhere; }

.results-head {
  display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem;
}
.results-head > div { display: flex; flex-direction: column; }
.back {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: .45rem .8rem; cursor: pointer; font-weight: 600; color: var(--sea);
}
.back:hover { border-color: var(--sea); }

.beach-marker.small { border-width: 1.5px; }
.search {
  width: 100%; font: inherit; padding: .6rem .8rem; margin-bottom: .6rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
}

.access { list-style: none; padding: 0; margin: .4rem 0; display: grid; gap: .35rem; }
.access li { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.access-marker {
  display: flex !important; align-items: center; justify-content: center;
  border-radius: 4px; font: 700 11px/1 system-ui, sans-serif; color: #fff; background: #2a5db0;
  border: 1.5px solid #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 35%);
}
.access-marker.trailhead { background: #fff; font-size: 12px; }
