:root {
  --bg: #f4f7f9;
  --card-bg: #ffffff;
  --ink: #14232e;
  --muted: #5c7080;
  --river: #1c6e8c;
  --river-dark: #124a5c;
  --high: #1c6e8c;
  --low: #d98c3a;
  --border: #e1e8ec;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 3rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--river-dark);
  color: white;
  padding: calc(0.9rem + env(safe-area-inset-top)) 1rem 0.9rem;
}
.topbar h1 { font-size: 1.1rem; margin: 0; font-weight: 600; }
.back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.4rem;
  padding: 0 0.4rem;
  cursor: pointer;
}

.day-tabs {
  display: flex;
  overflow-x: auto;
  gap: 0.4rem;
  padding: 0.7rem 0.8rem;
  background: var(--river);
  -webkit-overflow-scrolling: touch;
}
.day-tab {
  flex: 0 0 auto;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: none;
  background: rgba(255,255,255,0.18);
  color: white;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.day-tab.active {
  background: white;
  color: var(--river-dark);
  font-weight: 600;
}

.screen { padding: 0.9rem; }

.location-cards {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.location-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 0.9rem 1rem 0.5rem;
  box-shadow: 0 1px 3px rgba(20,35,46,0.08);
}
.location-card h2 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}
.sun-line {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.tide-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.3rem;
  border-top: 1px solid var(--border);
  width: 100%;
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.tide-row:first-of-type { border-top: none; }

.tide-badge {
  flex: 0 0 3.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0;
  border-radius: 8px;
  text-align: center;
  color: white;
}
.tide-badge.high { background: var(--high); }
.tide-badge.low { background: var(--low); }

.tide-time {
  flex: 0 0 3.6rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.tide-wind {
  flex: 1;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.wind-arrow {
  display: inline-block;
  font-size: 1rem;
}

.chevron { color: var(--border); font-size: 1.1rem; }

/* Detail screen */
.detail-header {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.9rem;
  box-shadow: 0 1px 3px rgba(20,35,46,0.08);
}
.detail-header .big-time { font-size: 2rem; font-weight: 700; }
.detail-header .big-sub { color: var(--muted); font-size: 0.9rem; }

.compare-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
  box-shadow: 0 1px 3px rgba(20,35,46,0.08);
}
.compare-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.compare-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
}
.compare-row:first-of-type { border-top: none; }
.compare-name { flex: 1; font-size: 0.92rem; }
.compare-badge {
  flex: 0 0 3rem;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0;
  border-radius: 7px;
  text-align: center;
  color: white;
}
.compare-badge.high { background: var(--high); }
.compare-badge.low { background: var(--low); }
.compare-time { flex: 0 0 3.2rem; font-weight: 600; text-align: right; }

.hour-strip {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(20,35,46,0.08);
}
.hour-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
}
.hour-row:first-child { border-top: none; }
.hour-row.tide-moment { background: #eaf3f6; }
.hour-time { flex: 0 0 3.4rem; font-weight: 600; }
.hour-wind { flex: 1; color: var(--muted); font-size: 0.9rem; display: flex; align-items: center; gap: 0.4rem; }
.hour-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--river-dark);
  background: #d7e8ee;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
}
.hour-dark { opacity: 0.55; }
.sun-icon { font-size: 0.85rem; }

.loading, .error-box {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
}
.error-box { color: #b3401d; display: none; }

.footer {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  padding: 1rem 1.2rem 0;
  line-height: 1.4;
}
.footer a { color: var(--river); }

@media (min-width: 640px) {
  .screen { max-width: 480px; margin: 0 auto; }
  .day-tabs, .topbar { max-width: 480px; margin: 0 auto; }
}
