:root {
  --ink: #18211c;
  --muted: #5d6a62;
  --line: #d7ded8;
  --panel: #f7f9f5;
  --paper: #fffef7;
  --yellow: #f1df83;
  --blue: #115ea6;
  --green: #146b3a;
  --focus: #a20f91;
}

* { box-sizing: border-box; }
html {
  overflow-x: clip;
}
body {
  margin: 0;
  color: var(--ink);
  background: #eef4ef;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  overflow-x: clip;
}
a {
  color: #064f86;
  overflow-wrap: anywhere;
}
a:focus-visible, button:focus-visible, input:focus-visible, canvas:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.site-header {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 18px;
  background: #173c46;
  color: white;
}
.brand {
  color: white;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.18rem;
}
.site-footer {
  display: grid;
  gap: 4px;
  padding: 18px;
  color: #314138;
  background: #dde8df;
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.home-shell {
  width: min(1040px, calc(100% - 28px));
  margin: 22px auto 38px;
}
h1 {
  margin: 0 0 14px;
  font-size: clamp(1.65rem, 3vw, 2.4rem);
}
h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}
.search-panel {
  position: relative;
  margin: 0 0 18px;
}
.search-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
}
.search-input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  font-size: 1rem;
  background: white;
}
.icon-button {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: #114b56;
  font-size: 1.45rem;
  cursor: pointer;
}
.results {
  position: absolute;
  z-index: 5;
  top: calc(100% + 5px);
  left: 0;
  right: 56px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 12px 30px rgb(0 0 0 / .12);
  overflow: hidden;
}
.results:empty { display: none; }
.result-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid #edf1ee;
  background: white;
  text-align: left;
  cursor: pointer;
}
.result-item.is-active, .result-item:hover { background: #edf7f4; }
.ports-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.ports-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.ports-grid ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.ports-grid a {
  display: block;
  padding: 4px 0;
  min-height: 30px;
  text-decoration: none;
}
.tide-page {
  width: min(1440px, calc(100% - 20px));
  margin: 10px auto 30px;
  min-width: 0;
}
.tide-band {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  min-height: 52px;
  padding: 9px 14px;
  background: var(--yellow);
  border: 1px solid #d2bc51;
  border-radius: 8px 8px 0 0;
  color: #2b2b16;
  overflow-wrap: anywhere;
}
.tide-band strong { text-align: right; font-size: 1.2rem; }
.notice, .error-notice {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff8d9;
  border: 1px solid #e5cf6e;
}
.error-notice {
  background: #fff0ee;
  border-color: #e6ada4;
}
.tide-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px minmax(330px, 380px);
  gap: 8px;
  align-items: start;
  margin-top: 10px;
}
.chart-panel, .tide-table-panel {
  min-width: 0;
}
.chart-wrap {
  position: relative;
  min-height: 440px;
  background: white;
  border: 1px solid var(--line);
}
#tide-chart {
  display: block;
  width: 100%;
  height: min(62vh, 620px);
  min-height: 440px;
}
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 5px 7px;
  border: 1px solid #cbd5cf;
  border-radius: 4px;
  background: white;
  box-shadow: 0 8px 22px rgb(0 0 0 / .15);
  font-size: .9rem;
}
.day-arrow {
  position: relative;
  align-self: start;
  margin-top: 0;
  color: #1e515d;
  font-size: 1.3rem;
  transition: transform .18s ease;
  will-change: transform;
}
.days-scroll {
  display: grid;
  gap: 5px;
}
.day-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  width: 100%;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 0;
  background: white;
  color: inherit;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
}
.day-card.is-active {
  border-color: #1d5661;
}
.day-date {
  display: grid;
  place-items: center;
  align-content: center;
  border-right: 1px solid #d8ded8;
  background: #f7f9f6;
  min-height: 70px;
}
.day-date strong { font-size: 1.35rem; }
.day-lines {
  display: grid;
  min-height: 70px;
}
.tide-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, .65fr);
  gap: 6px;
  align-items: center;
  padding: 3px 7px;
  min-height: 24px;
  background: var(--coef-bg, transparent);
}
.tide-line > span {
  min-width: 0;
}
.tide-pm { color: var(--blue); font-weight: 700; }
.tide-bm { color: var(--green); font-weight: 650; }
.missing-day { padding: 14px; color: var(--muted); }
.button-link {
  display: inline-block;
  padding: 9px 12px;
  border-radius: 6px;
  background: #174d58;
  color: white;
  text-decoration: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 900px) {
  .tide-band {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .tide-band strong { text-align: left; }
  .tide-layout {
    grid-template-columns: 1fr;
  }
  .day-arrow { display: none; }
  .days-scroll {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    gap: 10px;
    padding-bottom: 8px;
  }
  .day-card {
    flex: 0 0 280px;
    scroll-snap-align: center;
  }
}
@media (max-width: 620px) {
  .ports-grid { grid-template-columns: 1fr; }
  .results { right: 0; }
  #tide-chart, .chart-wrap { min-height: 340px; }
  #tide-chart { height: 380px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
