:root {
  --navy: #0d2240;
  --muted: #5d6b80;
  --line: #e2e8f0;
  --teal: #169b8c;
  --purple: #7455d6;
  --blue: #2d7bd0;
  --selected: rgb(22 155 140 / 0.08);
  --bg: #ffffff;
  --card: #ffffff;
  --footer: rgb(255 255 255 / 0.6);
  --tick-bg: rgb(255 255 255 / 0.85);
  --night: rgb(13 34 64 / 0.12);
  --error: #b5472a;
  color-scheme: light;
}

/* Dark theme, chosen on the Account page. The colours here replace the light ones above. */
[data-theme='dark'] {
  --navy: #e6edf5;
  --muted: #93a4b8;
  --line: #2a3b4d;
  --teal: #33c2b0;
  --purple: #a48cf5;
  --blue: #5aa3ec;
  --selected: rgb(51 194 176 / 0.12);
  --bg: #0b1622;
  --card: #13212f;
  --footer: rgb(19 33 47 / 0.7);
  --tick-bg: rgb(19 33 47 / 0.85);
  --night: rgb(0 0 0 / 0.35);
  --error: #f08a6b;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--navy);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* Small header across the top, with the MySurf name and a wave icon */
.app-bar {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.app-bar-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--navy);
}

.app-bar svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--teal);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Pages: only the active one shows. The footer stays put below them. */
.view {
  display: none;
}

.view.active {
  display: block;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 120px;
}

.view-title {
  margin: 0 0 16px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.page-head {
  margin-bottom: 20px;
}

.page-head h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 4px 0 0;
  font-size: 0.9rem;
}

.muted {
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.card > h3 {
  margin: 0 0 10px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Overview: all 14 days on one strip; the viewport shows four at a time */
.scroller {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

.track {
  position: relative;
}

.highlight {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 12px;
  background: var(--selected);
}

.separator {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed var(--line);
}

.cols {
  position: relative;
  z-index: 1;
}

.cols {
  display: grid;
}

.col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  min-height: 76px;
  padding: 6px 2px;
  cursor: pointer;
  scroll-snap-align: start;
}

.col .dow {
  font-size: 0.9rem;
  font-weight: 700;
}

.col .col-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.col .col-temps {
  font-size: 0.85rem;
}

.col .col-rain {
  font-size: 0.72rem;
}

.col .col-surf {
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.col .col-wind {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}

.col .date {
  font-size: 0.75rem;
}

/* Period ratings: three segments per day, green, yellow or red */
.period {
  flex: 1;
  height: 8px;
  border-radius: 3px;
  background: var(--line);
}

.period.good {
  background: #2fb35c;
}

.period.fair {
  background: #f2c12e;
}

.period.poor {
  background: #e5484d;
}

.periods {
  display: flex;
  gap: 2px;
  width: 100%;
  margin-top: 6px;
}

.rating-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--muted);
}

.rating-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rating-legend .period {
  flex: none;
  width: 14px;
}

.swell {
  --c: var(--teal);
}

.wind {
  --c: var(--purple);
}

.tide {
  --c: var(--blue);
}

/* Today's detail */
.detail {
  margin-top: 28px;
}

.detail-head h2 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.detail-head p {
  margin: 2px 0 14px;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
}

.sum-hour {
  font-size: 1.6rem;
  font-weight: 800;
}

.stat span {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat b {
  font-size: 1rem;
}

.chart-card {
  margin-top: 12px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
}

.card-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.right {
  font-size: 0.85rem;
  color: var(--muted);
}

.legend {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  display: inline-block;
  width: 18px;
  border-top: 2px solid var(--purple);
}

.legend .gust-key {
  border-top: 2px dashed var(--muted);
}

/* Charts are sized by CSS; the cursor and dot are HTML so they stay round when the SVG stretches */
.chart {
  position: relative;
  margin-top: 8px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

.chart svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.chart .area {
  fill: var(--c);
  opacity: 0.14;
}

.chart .line {
  fill: none;
  stroke: var(--c);
  stroke-width: 2;
  stroke-linejoin: round;
}

.chart .gust {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

.night {
  fill: var(--night);
}

/* Wind direction row, between the legend and the wind chart: the compass point above an arrow */
.top-row {
  position: relative;
  height: 34px;
  margin-top: 6px;
}

.wind-dir {
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 0;
  transform: translateX(-50%);
  font-size: 10px;
  white-space: nowrap;
  color: var(--muted);
}

.wind-dir svg {
  fill: var(--purple);
}

.tick {
  position: absolute;
  left: 2px;
  transform: translateY(-50%);
  padding: 0 3px;
  border-radius: 4px;
  background: var(--tick-bg);
  font-size: 11px;
  color: var(--muted);
}

.cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1.5px dashed rgb(13 34 64 / 0.35);
  transform: translateX(-50%);
  pointer-events: none;
}

.dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--navy);
  box-shadow: 0 0 0 3px var(--card);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.pin {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.pin-label {
  position: absolute;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  transform: translateX(-50%);
  pointer-events: none;
}

.pin-label.high {
  transform: translate(-50%, calc(-100% - 6px));
}

.pin-label.low {
  transform: translate(-50%, 6px);
}

/* Labels near the chart's edges open inward so they stay inside the chart */
.pin-label.high.edge-right {
  transform: translate(-100%, calc(-100% - 6px));
}

.pin-label.low.edge-right {
  transform: translate(-100%, 6px);
}

.pin-label.high.edge-left {
  transform: translate(0, calc(-100% - 6px));
}

.pin-label.low.edge-left {
  transform: translate(0, 6px);
}

.axis {
  position: relative;
  height: 18px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

.axis span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.axis .first {
  transform: none;
}

.empty {
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.note {
  margin: 16px 2px 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.theme-card,
.quiver {
  margin-top: 20px;
}

/* Quiver: each board with Edit and Remove at the top right; the add and edit forms sit below */
.board-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.board-info {
  min-width: 0;
  overflow-wrap: anywhere;
}

.board-actions {
  display: flex;
  flex: none;
  gap: 8px;
}

.board-editor,
.add-board-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.add-board-form h3 {
  margin: 0;
  font-size: 0.85rem;
}

.board-editor-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.add-board {
  justify-self: start;
  margin-top: 10px;
}

/* Secondary details */
.extras {
  margin-top: 20px;
}

.extras summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 52px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.extras summary::-webkit-details-marker {
  display: none;
}

.extras summary::after {
  content: '+';
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--muted);
}

.extras[open] summary::after {
  content: '–';
}

.extra-block {
  padding-bottom: 14px;
}

.extra-block h4 {
  margin: 0 0 8px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.extra-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.extra-grid span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.extra-grid b {
  font-size: 0.95rem;
  font-weight: 600;
}

.moon-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.moon-dark {
  fill: #000;
  stroke: #888;
  stroke-width: 1;
}

.moon-lit {
  fill: #fff;
}

#warnings p {
  color: var(--error);
  font-size: 0.85rem;
}

/* Explore: search, map and station choices */
.search {
  position: relative;
  margin-bottom: 12px;
}

.search input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  font-size: 1rem;
  color: var(--navy);
}

.results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgb(13 34 64 / 0.12);
}

.results button {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--navy);
  cursor: pointer;
}

.results button:hover {
  background: var(--selected);
}

.results .muted {
  padding: 10px;
}

.results .detail {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Map tiles are light by default; in dark mode they're inverted so the map matches the page */
[data-theme='dark'] .leaflet-tile-pane {
  filter: invert(0.9) hue-rotate(180deg) brightness(0.85) contrast(0.9);
}

.map {
  position: relative;
  z-index: 0;
  height: 60vh;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stations {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.stations label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.stations select {
  width: 100%;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  font-size: 0.9rem;
  color: var(--navy);
}

@media (max-width: 520px) {
  .stations {
    grid-template-columns: 1fr;
  }
}

/* Header: spot name and favorite star */
.spot-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--teal);
  cursor: pointer;
}

/* Sticky footer: see-through, with an icon above each label */
.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: flex;
  justify-content: space-around;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--footer);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid rgb(226 232 240 / 0.8);
}

.footer button {
  flex: 1;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 12px;
  background: none;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.footer button[aria-current='page'] {
  color: var(--teal);
}

.footer svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0 16px;
}

.tabs button {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font: inherit;
  color: var(--navy);
  cursor: pointer;
}

.tabs button.active {
  border-color: var(--teal);
  background: var(--selected);
  font-weight: 700;
}

.form {
  display: grid;
  gap: 14px;
}

.form label > span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.form input[type='text'],
.form input:not([type]),
.form input[type='email'],
.form input[type='password'],
.form input[type='date'] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  font-size: 1rem;
  color: var(--navy);
}

.ratings {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 8px;
}

.ratings legend {
  margin-bottom: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.rating {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.rating input {
  width: 20px;
  height: 20px;
  margin: 0;
}

.rating:has(input:checked) {
  border-color: var(--teal);
  background: var(--selected);
}

.primary {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--teal);
  font: inherit;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
}

.error {
  min-height: 1.2em;
  margin: 0;
  font-size: 0.9rem;
  color: var(--error);
}

.error.saved {
  color: var(--teal);
}

.list-plain {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.list-plain li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  align-items: baseline;
}

.fav-row {
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}

.fav-row:last-child {
  border-bottom: 0;
}

.fav-open {
  flex: 1;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  color: var(--navy);
  cursor: pointer;
}

.link {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
}

.link.danger {
  color: var(--error);
  font-weight: 400;
}

/* Favorites table: spot cards with the same day columns across the top */
.fav-strip {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 0 16px 8px;
}

.fav-table {
  display: grid;
  gap: 12px;
}

.fav-days,
.fav-cells {
  display: flex;
}

.fav-days > div,
.fav-cell {
  flex: 0 0 84px;
  width: 84px;
}

.fav-days > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.8rem;
}

.fav-card {
  padding: 0;
  overflow: hidden;
}

.fav-head {
  position: sticky;
  left: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--card);
}

.fav-head .fav-open {
  min-width: 0;
  overflow-wrap: anywhere;
}

.fav-cells {
  padding: 0 0 12px;
}

.fav-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  font-size: 0.8rem;
}

.fav-swell {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
}

.fav-cell .periods {
  width: 84%;
}

.fav-error {
  padding: 0 14px 12px;
}

/* A tappable day on a favorite's card */
.fav-link {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.fav-link:hover {
  background: var(--selected);
}

.fav-link:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

/* Sessions: time blocks, and the conditions recorded for each */
.segments {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.segment label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.segment label > span {
  font-size: 0.75rem;
  color: var(--muted);
}

.segment select {
  width: 100%;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  color: var(--navy);
}

.segment .wide {
  grid-column: 1 / -1;
}

.segment .link.danger {
  justify-self: start;
  min-height: 40px;
}

.list-plain li.session {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.session .block {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  margin-top: 6px;
  font-size: 0.9rem;
}

.session .block .muted {
  flex-basis: 100%;
  font-size: 0.8rem;
}

/* Session entry: large touch targets, with the chosen values clearly highlighted */
.session-spot {
  margin: 0 0 12px;
}

.session-when {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px;
}

.session-when label,
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.session-when label > span,
.field > span {
  font-size: 0.8rem;
  color: var(--muted);
}

.field h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stars {
  display: flex;
  gap: 6px;
}

.star {
  flex: 1;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  font-size: 1.7rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.star.selected {
  border-color: #f2b824;
  background: rgb(242 184 36 / 0.14);
  color: #f2b824;
}

.options,
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.option,
.tag {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  font-size: 0.9rem;
  color: var(--navy);
  cursor: pointer;
}

.option.selected,
.tag.selected {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  font-weight: 600;
}

.tag-group {
  display: grid;
  gap: 6px;
}

.tag-title {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.more {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.more summary {
  min-height: 40px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.more summary::-webkit-details-marker {
  display: none;
}

.more[open] {
  display: grid;
  gap: 14px;
  padding-bottom: 6px;
}

.form select,
.form textarea,
.form input[type='number'] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font: inherit;
  color: var(--navy);
}

.form textarea {
  min-height: 100px;
  resize: vertical;
}

.board-measures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.small-line {
  font-size: 0.8rem;
}

.session-head {
  margin-bottom: 4px;
}

.entry {
  padding: 8px 0 4px;
}

.entry-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.stars-text {
  letter-spacing: 0.1em;
  color: #f2b824;
}

.entry-line {
  margin-top: 2px;
  font-size: 0.85rem;
}

.board-row .small-line {
  flex-basis: 100%;
}
