:root {
  color-scheme: light;
  --ink: #17211e;
  --muted: #64736d;
  --paper: #f4f0e7;
  --panel: #fffaf0;
  --line: #d7c9b2;
  --deep: #10464d;
  --teal: #0a7b83;
  --coral: #d85d45;
  --gold: #c69735;
  --green: #3d7256;
  --shadow: 0 18px 45px rgba(32, 43, 39, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Charter, "Times New Roman", serif;
  background:
    linear-gradient(115deg, rgba(10, 123, 131, 0.12), transparent 36%),
    linear-gradient(245deg, rgba(216, 93, 69, 0.10), transparent 34%),
    repeating-linear-gradient(0deg, rgba(23, 33, 30, 0.025) 0 1px, transparent 1px 7px),
    var(--paper);
}

button, input { font: inherit; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.hero {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(360px, 0.95fr);
  gap: 18px;
  align-items: center;
  padding: 12px 0 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow, .panelKicker {
  margin: 0 0 10px;
  color: var(--teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 700;
}

h1, h2 {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  max-width: 520px;
  font-size: clamp(28px, 4.6vw, 56px);
  line-height: 0.96;
}

h2 {
  font-size: 24px;
  line-height: 1.1;
}

.lede {
  max-width: 520px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.search {
  background: rgba(255, 250, 240, 0.82);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(32, 43, 39, 0.09);
  padding: 14px;
}

.search label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.searchRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

input {
  min-width: 0;
  height: 46px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(10, 123, 131, 0.14); }

button {
  height: 46px;
  border: 1px solid var(--deep);
  background: var(--deep);
  color: #fffaf0;
  padding: 0 16px;
  cursor: pointer;
}

button[type="button"] {
  background: transparent;
  color: var(--deep);
}

.tabBar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 5;
  margin-inline: -4px;
  padding: 10px 4px 8px;
  background: rgba(244, 240, 231, 0.94);
  backdrop-filter: blur(10px);
  scrollbar-width: none;
}

.tabBar::-webkit-scrollbar { display: none; }

.tabButton {
  min-width: 90px;
  height: 38px;
  border-color: var(--line);
  background: rgba(255, 250, 240, 0.74);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 800;
}

.tabButton.active {
  border-color: var(--deep);
  background: var(--deep);
  color: #fffaf0;
}

button:disabled { opacity: 0.55; cursor: wait; }

.statusText {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dashboard {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 16px;
  padding-top: 10px;
}

.panel {
  background: rgba(255, 250, 240, 0.88);
  border: 1px solid var(--line);
  padding: 18px;
  min-height: 210px;
}

.tabPanel { display: none; }
.tabPanel.active { display: block; }

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

.panelHead {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.badge {
  border: 1px solid rgba(10, 123, 131, 0.28);
  color: var(--teal);
  background: rgba(10, 123, 131, 0.08);
  padding: 7px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: nowrap;
}

.badgeStack {
  display: grid;
  gap: 6px;
  justify-items: end;
}

canvas {
  display: block;
  width: 100%;
  height: 280px;
  margin-top: 14px;
  background: linear-gradient(180deg, rgba(10, 123, 131, 0.08), rgba(216, 93, 69, 0.06));
  border: 1px solid rgba(215, 201, 178, 0.8);
  cursor: crosshair;
  touch-action: none;
}

.readout {
  color: var(--deep);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  text-align: left;
  margin-top: 10px;
  min-height: 20px;
}

.stats, .summaryGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.tidePanel .stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.tideExtremes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.extremeItem {
  width: 100%;
  height: auto;
  min-height: 48px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(215, 201, 178, 0.92);
  background: rgba(255, 253, 247, 0.72);
  color: var(--ink);
  text-align: left;
}

.extremeItem:hover {
  border-color: rgba(10, 123, 131, 0.4);
  background: #fffdf7;
}

.extremeArrow {
  font-size: 13px;
  line-height: 1;
}

.extremeItem.high .extremeArrow { color: var(--coral); }
.extremeItem.low .extremeArrow { color: #74a956; }

.extremeItem time,
.extremeItem strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.extremeItem time {
  color: var(--muted);
  font-size: 13px;
}

.extremeItem strong {
  color: var(--deep);
  font-size: 15px;
  white-space: nowrap;
}

.summaryGrid { grid-template-columns: 1fr 1fr; }

.sunGrid {
  margin-top: 18px;
  padding-top: 4px;
}

.nearbyBox {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.nearbyHead {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  color: var(--teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.nearbyHead small {
  color: var(--muted);
  font-weight: 700;
  text-transform: none;
}

.nearbyGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.nearbyItem {
  width: 100%;
  height: auto;
  min-height: 56px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 8px 10px;
  border-color: rgba(215, 201, 178, 0.92);
  background: rgba(255, 253, 247, 0.72);
  color: var(--ink);
  text-align: left;
}

.nearbyItem:hover {
  border-color: rgba(10, 123, 131, 0.45);
  background: #fffdf7;
}

.nearbyItem strong,
.nearbyItem span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.nearbyItem strong {
  color: var(--deep);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.nearbyItem span {
  color: var(--muted);
  font-size: 11px;
}

.nearbyItem.active {
  border-color: var(--deep);
  background: var(--deep);
  color: #fffaf0;
}

.nearbyItem.active strong,
.nearbyItem.active span {
  color: #fffaf0;
}

.weatherList {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.tableScroller {
  width: 100%;
  overflow-x: hidden;
  border-top: 1px solid var(--line);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tableScroller::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.marineTable {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
}

.marineTable th,
.marineTable td {
  padding: 12px 14px;
  text-align: center;
  border-bottom: 1px solid rgba(215, 201, 178, 0.56);
  white-space: nowrap;
}

.marineTable th {
  color: var(--muted);
  font-weight: 800;
}

.marineTable th small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.marineTable td {
  color: var(--ink);
  font-size: 16px;
}

.marineTable tr:nth-child(odd):not(.dateRow):not(.tableHead) {
  background: rgba(255, 253, 247, 0.56);
}

.dateRow th {
  padding: 14px 0 8px;
  color: var(--ink);
  font-family: Charter, "Times New Roman", serif;
  font-size: 22px;
  text-align: left;
  border-bottom: 0;
}

.tableHead th {
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 8px 14px rgba(32, 43, 39, 0.08);
}

.compactTable { min-width: 0; }

.timeCell {
  color: var(--muted);
  font-size: 15px;
}

.tempPill {
  display: inline-block;
  min-width: 96px;
  padding: 8px 10px;
  color: #2d91dc;
  background: rgba(45, 145, 220, 0.12);
  font-size: 22px;
  font-weight: 800;
}

.salinityText {
  color: #e7a50d;
  font-size: 18px;
}

.heightText,
.depthText {
  color: #1aaebe;
  font-size: 18px;
  font-weight: 800;
}

.depthText { color: #2d91dc; }

.dirText {
  color: #8a8f8b;
  font-size: 13px;
}

.currentArrow {
  display: inline-block;
  color: #8a8f8b;
  transform: rotate(var(--angle));
  transform-origin: center;
}

.fishingSummary {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.fishingHero {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.scoreNumber {
  color: #f0b414;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 56px;
  font-weight: 900;
  line-height: 0.9;
}

.scoreLevel {
  margin-top: 8px;
  color: #f0b414;
  font-size: 20px;
}

.speciesButton {
  justify-self: end;
  border: 1px solid #2d9bf0;
  color: #2d9bf0;
  background: rgba(45, 155, 240, 0.08);
  padding: 10px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  white-space: nowrap;
}

.scoreTrack {
  position: relative;
  height: 16px;
  background: linear-gradient(90deg, #ff3f4c 0 30%, #ff7b2b 30% 50%, #f6bd16 50% 75%, #2d9bf0 75% 90%, #19d3a8 90% 100%);
}

.scoreTrack span {
  position: absolute;
  top: -12px;
  width: 4px;
  height: 40px;
  background: var(--deep);
  transform: translateX(-2px);
}

.scoreTrack span::after {
  content: "";
  position: absolute;
  left: -7px;
  bottom: -8px;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 12px solid var(--deep);
}

.fishingMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.fishingMeta span {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.fishingMatrix {
  display: grid;
  grid-template-columns: 112px repeat(10, minmax(64px, 1fr));
  overflow-x: auto;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.fishingMatrix > div {
  min-width: 64px;
  padding: 12px 10px;
  text-align: center;
  border-bottom: 1px solid rgba(215, 201, 178, 0.52);
}

.fishingMatrix .matrixLabel {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 112px;
  color: var(--deep);
  background: #eef7fb;
  font-weight: 800;
}

.activeColumn {
  background: rgba(23, 33, 30, 0.08);
}

.fishingCurveBlock {
  display: grid;
  grid-template-columns: 112px minmax(720px, 1fr);
  overflow-x: auto;
  align-items: stretch;
  border-bottom: 1px solid rgba(215, 201, 178, 0.52);
}

.fishingCurveBlock .matrixLabel {
  position: sticky;
  left: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  color: var(--deep);
  background: #eef7fb;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
}

.fishingTideSvg {
  width: 100%;
  min-width: 720px;
  height: 150px;
}

.fishingTideSvg .tideArea {
  fill: rgba(26, 174, 190, 0.16);
}

.fishingTideSvg .tideLine {
  fill: none;
  stroke: #20bfd8;
  stroke-width: 4;
}

.fishingTideSvg .dashLine {
  stroke: rgba(23, 33, 30, 0.22);
  stroke-dasharray: 7 7;
}

.fishingTideSvg circle {
  fill: #fffaf0;
  stroke: #20bfd8;
  stroke-width: 4;
}

.fishingTideSvg text {
  fill: var(--deep);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
}

.rowItem {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.rowItem time {
  color: var(--teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.rowItem div {
  color: var(--ink);
  line-height: 1.45;
}

.alarmBox {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.alarm {
  border-left: 4px solid var(--coral);
  padding: 10px 12px;
  background: rgba(216, 93, 69, 0.08);
}

.empty {
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }
  .hero, .dashboard { grid-template-columns: 1fr; }
  .hero {
    min-height: auto;
    align-items: start;
    gap: 12px;
    padding: 8px 0 10px;
  }
  .eyebrow { margin-bottom: 6px; }
  h1 {
    font-size: clamp(24px, 8vw, 34px);
    line-height: 1;
  }
  .lede {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.42;
  }
  .search {
    padding: 10px;
    box-shadow: none;
  }
  .search label { margin-bottom: 7px; }
  .searchRow {
    grid-template-columns: minmax(0, 1fr) 74px 74px;
    gap: 6px;
  }
  input, button { height: 42px; }
  button {
    width: auto;
    padding: 0 10px;
  }
  .tabButton { width: auto; }
  .stats, .summaryGrid, .tidePanel .stats { grid-template-columns: 1fr 1fr; }
  .tideExtremes { grid-template-columns: 1fr 1fr; }
  .tidePanel, .nowPanel { grid-column: auto; }
  .panelHead { align-items: stretch; }
  .badgeStack { justify-items: start; }
  canvas { height: 240px; }
  .tableHead th { top: 0; }
  .tableScroller { overflow-x: auto; }
  .marineTable { min-width: 720px; }
  .compactTable { min-width: 760px; }
}

@media (max-width: 520px) {
  body { padding-bottom: 82px; }
  .shell { width: min(100% - 14px, 1180px); }
  .hero { border-bottom: 0; }
  .searchRow {
    grid-template-columns: minmax(0, 1fr) 58px 58px;
  }
  input, button { height: 40px; }
  input { padding: 0 9px; }
  button {
    padding: 0 6px;
    font-size: 13px;
  }
  .statusText {
    margin-top: 8px;
    min-height: 18px;
    font-size: 12px;
  }
  .tabBar {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: max(10px, env(safe-area-inset-bottom));
    justify-content: flex-start;
    padding: 8px;
    gap: 6px;
    border: 1px solid rgba(45, 145, 220, 0.22);
    background: rgba(209, 234, 252, 0.92);
    box-shadow: 0 12px 30px rgba(32, 43, 39, 0.16);
  }
  .tabButton {
    min-width: 78px;
    height: 34px;
    font-size: 11px;
  }
  .tabButton.active {
    border-color: #2d9bf0;
    background: #2d9bf0;
  }
  .dashboard { gap: 10px; }
  .panel {
    padding: 12px;
    min-height: auto;
  }
  .panelHead {
    display: grid;
    gap: 10px;
  }
  h2 { font-size: 20px; }
  .nearbyGrid { grid-template-columns: 1fr 1fr; }
  canvas {
    height: 210px;
    margin-top: 10px;
  }
  .stats, .summaryGrid, .tidePanel .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tideExtremes { grid-template-columns: 1fr; }
  .metric strong { font-size: 14px; }
  .rowItem { grid-template-columns: 1fr; gap: 4px; }
  .dateRow th { font-size: 19px; }
  .marineTable td { font-size: 15px; }
  .tempPill {
    min-width: 86px;
    font-size: 19px;
  }
  .fishingHero {
    align-items: start;
  }
  .scoreNumber { font-size: 48px; }
  .speciesButton {
    max-width: 180px;
    white-space: normal;
    text-align: center;
  }
  .fishingMatrix {
    grid-template-columns: 98px repeat(10, 58px);
  }
  .fishingMatrix .matrixLabel,
  .fishingCurveBlock .matrixLabel {
    min-width: 98px;
  }
  .fishingCurveBlock {
    grid-template-columns: 98px minmax(620px, 1fr);
  }
  .fishingTideSvg {
    min-width: 620px;
  }
}
