:root {
  --bg: #081017;
  --panel: #101c25;
  --panel-2: #132532;
  --line: rgba(188, 215, 230, 0.14);
  --text: #f2f7f9;
  --soft-text: #d8e5eb;
  --muted: #94a8b4;
  --blue: #62b6ff;
  --green: #58d09f;
  --yellow: #f2c45f;
  --orange: #ee8b52;
  --red: #ff3fb4;
  --marker: #45f2c3;
  --matrix-bg: #0f1820;
  --matrix-line: rgba(180, 205, 220, 0.13);
  --matrix-text: #dce8ed;
  --matrix-muted: #95a8b5;
  --matrix-band: rgba(255, 255, 255, 0.04);
  --matrix-cell-line: rgba(255, 255, 255, 0.08);
  --matrix-metric: #287f8b;
  --spot-overlay: linear-gradient(90deg, rgba(8, 16, 23, 0.9), rgba(8, 16, 23, 0.72));
  --spot-fill: rgba(16, 28, 37, 0.44);
  --radius: 8px;
}

body[data-theme="light"] {
  --bg: #edf3f6;
  --panel: #ffffff;
  --panel-2: #f3f7fa;
  --line: rgba(44, 65, 80, 0.14);
  --text: #10202b;
  --soft-text: #304756;
  --muted: #62727f;
  --matrix-bg: #f9fcfd;
  --matrix-line: rgba(44, 65, 80, 0.14);
  --matrix-text: #132633;
  --matrix-muted: #5f7280;
  --matrix-band: rgba(30, 55, 72, 0.045);
  --matrix-cell-line: rgba(44, 65, 80, 0.1);
  --matrix-metric: #dbeef2;
  --spot-overlay: linear-gradient(90deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.64));
  --spot-fill: rgba(255, 255, 255, 0.48);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(8, 16, 23, 0.18), rgba(8, 16, 23, 0.92) 420px),
    url("assets/images/wave-bg.png") top center / cover no-repeat,
    var(--bg);
  background-attachment: fixed;
}

.app-shell {
  width: min(1900px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.topbar h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  max-width: 760px;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.95;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topbar-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.meta-pill,
.theme-toggle {
  min-width: 150px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  text-align: left;
}

.theme-toggle {
  cursor: pointer;
}

.theme-toggle {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.theme-copy {
  display: block;
}

.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.switch-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--blue);
  transition: transform 0.18s ease;
}

.theme-toggle[aria-pressed="true"] .switch-track i {
  transform: translateX(20px);
}

.theme-toggle:disabled {
  cursor: wait;
  opacity: 0.72;
}

.meta-label,
.meta-pill span,
.theme-toggle span,
.section-head span,
.condition-card span,
.stat-grid span,
.score-panel span,
.score-panel small,
.tab small,
.tab em,
dt,
.window-card span,
.window-card small,
.day-card span,
.signal span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
}

#app {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.panel {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.spot-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 480px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 18px;
  background:
    var(--spot-overlay),
    var(--spot-fill);
  backdrop-filter: blur(5px);
}

.spot-panel-copy {
  display: grid;
  gap: 12px;
}

.weekly-planner {
  padding-top: 4px;
}

.weekly-planner p {
  margin: 0;
  color: var(--soft-text);
  font-size: 0.95rem;
  line-height: 1.5;
}

.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(330px, 360px);
  grid-template-columns: none;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.tab {
  position: relative;
  appearance: none;
  min-height: 136px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(118px, 1fr) auto;
  grid-template-rows: auto minmax(90px, 1fr);
  column-gap: 12px;
  row-gap: 10px;
  align-items: center;
}

.tab:hover,
.tab.active {
  border-color: rgba(98, 182, 255, 0.68);
  background: rgba(98, 182, 255, 0.1);
}

.tab.active {
  box-shadow:
    inset 0 0 0 1px rgba(98, 182, 255, 0.55),
    0 0 0 1px rgba(98, 182, 255, 0.18),
    0 16px 34px rgba(98, 182, 255, 0.12);
}

.tab-identity {
  min-width: 0;
}

.tab-identity b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
  line-height: 1.1;
}

.tab-identity small {
  margin-top: 2px;
}

.score-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  justify-self: end;
  margin: 0;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--quality) 58%, var(--line));
  border-radius: 999px;
  color: var(--quality);
  background: color-mix(in srgb, var(--quality) 15%, transparent);
  font-size: 1.2rem;
  line-height: 1;
}

.selected-tag {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 2;
  padding: 3px 7px;
  border: 1px solid rgba(69, 242, 195, 0.5);
  border-radius: 999px;
  color: var(--marker);
  background: rgba(69, 242, 195, 0.1);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score-badge b {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.mini-matrix {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  align-items: stretch;
  min-height: 92px;
  padding-top: 0;
  background:
    linear-gradient(to bottom, transparent 34px, var(--line) 35px, transparent 36px),
    rgba(255, 255, 255, 0.02);
}

.mini-col {
  position: relative;
  display: grid;
  grid-template-rows: 28px 18px 32px 14px;
  align-items: end;
  justify-items: center;
  min-width: 0;
  border-left: 1px solid var(--line);
}

.mini-col:first-child {
  border-left: 0;
}

.daily-pill {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  align-self: center;
  width: calc(100% - 8px);
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid color-mix(in srgb, var(--quality) 48%, var(--line));
  border-radius: 999px;
  color: var(--soft-text);
  background: color-mix(in srgb, var(--quality) 12%, rgba(255, 255, 255, 0.025));
  font-size: 0.66rem;
  font-style: normal;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-pill b {
  color: var(--quality);
}

.mini-arrow {
  display: block;
  align-self: center;
  color: #5bd9df;
  font-size: 0.72rem;
  line-height: 1;
}

.mini-swell-track {
  position: relative;
  display: flex;
  align-items: end;
  width: 100%;
  height: 32px;
  padding: 0 4px;
  overflow: hidden;
}

.mini-day-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(216, 229, 235, 0.18);
  font-size: 1.05rem;
  font-weight: 950;
  letter-spacing: 0;
  pointer-events: none;
}

.swell-mini {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-height: 10px;
  background: linear-gradient(180deg, #42c7d0, #238894);
}

.mini-col small {
  width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.58rem;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero {
  display: block;
  padding-top: 4px;
}

.hero-main,
.score-panel,
.panel:not(.spot-panel) {
  padding: 18px;
}

.hero-main {
  display: grid;
  gap: 18px;
  width: 100%;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--panel) 96%, transparent), color-mix(in srgb, var(--blue) 12%, var(--panel))),
    color-mix(in srgb, var(--panel) 92%, transparent);
}

.hero-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: 32px;
  align-items: center;
}

.hero-copy {
  min-width: 0;
}

.hero-kicker,
.section-head,
.hour-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.hero-kicker span,
.hero-kicker a,
a {
  color: var(--muted);
}

.hero h2 {
  margin-top: 18px;
  font-size: clamp(2.4rem, 7vw, 5.6rem);
  line-height: 0.92;
}

.summary {
  max-width: 1120px;
  margin: 18px 0;
  color: var(--soft-text);
  font-size: 1.08rem;
  line-height: 1.55;
}

.extended-summary {
  margin-top: -6px;
  color: color-mix(in srgb, var(--soft-text) 86%, var(--muted));
  font-size: 0.98rem;
}

.stat-grid,
.condition-grid,
.signal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat-grid div,
.condition-card,
.signal {
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.stat-grid strong,
.condition-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.12rem;
}

.excellent {
  --quality: var(--green);
}

.good {
  --quality: var(--blue);
}

.fair {
  --quality: var(--yellow);
}

.poor {
  --quality: var(--orange);
}

.score-panel,
.window-card,
.day-card {
  border-color: color-mix(in srgb, var(--quality) 50%, var(--line));
}

.score-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 240px;
  text-align: center;
}

.embedded-score {
  justify-self: center;
  align-self: center;
  width: 250px;
  height: 250px;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.score-panel canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

.score-panel strong,
.day-card strong,
.hour-top span {
  color: var(--quality);
}

.score-panel strong {
  font-size: 4.2rem;
  line-height: 1;
}

.visual-grid {
  display: grid;
  gap: 16px;
}

.chart-panel {
  min-height: 260px;
}

.chart-panel canvas {
  width: 100% !important;
  height: 190px !important;
}

.today-analysis-panel {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 0.72fr);
  gap: 16px;
  align-items: start;
}

.today-analysis-main {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.analysis-block {
  min-width: 0;
}

.signal-chart-panel {
  display: grid;
  grid-template-rows: auto auto;
  align-self: start;
  height: auto;
  max-height: 360px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.radar-frame {
  width: 100%;
  max-width: 330px;
  height: 260px;
  margin: 10px auto 0;
  overflow: hidden;
}

.radar-frame canvas {
  width: 100% !important;
  height: 260px !important;
  max-height: 260px !important;
}

.map-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.map-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

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

.map-card-head strong {
  font-size: 0.95rem;
}

.map-card-head span {
  color: var(--muted);
  font-size: 0.78rem;
}

.windy-frame,
#windy,
.windy-fallback,
.pressure-map {
  width: 100%;
  height: 390px;
  min-height: 390px;
  border-radius: var(--radius);
}

#windy,
.pressure-map {
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.windy-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

#windy {
  position: absolute;
  inset: 0;
  height: 390px;
  min-height: 390px;
  overflow: hidden;
  z-index: 1;
}

.windy-status {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--panel-2);
  font-weight: 800;
}

.windy-frame.api-loaded .windy-status,
.windy-frame.use-fallback #windy {
  display: none;
}

.windy-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.windy-frame.use-fallback .windy-fallback {
  z-index: 3;
  opacity: 1;
  pointer-events: none;
}

.pressure-map {
  display: block;
  border: 1px solid var(--line);
  background: var(--panel-2);
  pointer-events: none;
}

.pressure-frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  touch-action: pan-y;
}

.pressure-frame .pressure-map {
  border: 1px solid var(--line);
}

.pressure-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  touch-action: pan-y;
  pointer-events: auto;
}

.pressure-pin {
  position: absolute;
  left: var(--pin-x);
  top: var(--pin-y);
  z-index: 5;
  display: grid;
  place-items: center;
  color: var(--marker);
  font-size: 2rem;
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, -100%);
  text-shadow:
    0 2px 0 white,
    0 0 14px rgba(0, 0, 0, 0.62);
}

.vortex-map-marker {
  display: grid;
  place-items: center;
  color: var(--marker);
  font-size: 2rem;
  line-height: 1;
  text-shadow:
    0 2px 0 white,
    0 0 12px rgba(0, 0, 0, 0.45);
}

.window-grid,
.outlook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.window-card,
.day-card,
.hour-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.window-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.2rem;
}

.window-card small {
  color: var(--quality);
  font-weight: 800;
}

.window-card p,
.day-card p,
.signal p {
  margin: 10px 0 0;
  color: var(--soft-text);
  line-height: 1.45;
}

.hourly-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 260px);
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.hour-card dl {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

dd {
  margin: 0;
  color: var(--soft-text);
}

.surf-size {
  margin-top: 10px;
  font-size: 1.8rem;
  font-weight: 900;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--quality);
}

.day-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 2rem;
}

.matrix-panel {
  overflow: hidden;
}

.dashboard-section {
  display: grid;
  gap: 16px;
  padding-top: 8px;
}

.section-divider {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  padding: 8px 2px 0;
  border-top: 1px solid var(--line);
}

.section-divider span {
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-divider strong {
  color: var(--muted);
  font-size: 0.92rem;
}

.forecast-matrix {
  display: grid;
  width: 100%;
  max-width: 100%;
  grid-template-columns: 42px repeat(var(--cols), 34px);
  grid-template-rows: 26px 22px 76px 22px 22px 38px 32px 42px;
  overflow-x: auto;
  font-size: 0.72rem;
  border: 1px solid var(--matrix-line);
  border-radius: var(--radius);
  color: var(--matrix-text);
  background: var(--matrix-bg);
}

.matrix-days,
.matrix-times,
.swell-bars,
.metric-row,
.wind-row,
.temp-row,
.matrix-tide-canvas {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: repeat(var(--cols), 34px);
}

.matrix-days {
  grid-row: 1;
  text-align: center;
  font-weight: 900;
  font-size: 0.72rem;
}

.matrix-days div,
.matrix-times div {
  display: grid;
  place-items: center;
}

.matrix-days div:nth-child(odd) {
  background: var(--matrix-band);
}

.matrix-times {
  grid-row: 2;
}

.matrix-corner {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  margin: 6px;
  width: 30px;
  height: 30px;
  font-size: 0.78rem;
  border-radius: 50%;
  color: white;
  background: #666;
  font-weight: 900;
}

.axis,
.row-label {
  grid-column: 1;
  color: var(--matrix-muted);
  border-right: 1px solid var(--matrix-line);
}

.surf-axis {
  grid-row: 3;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  align-items: start;
  padding: 0 6px;
  font-size: 0.72rem;
  text-align: right;
  font-weight: 700;
}

.swell-bars {
  grid-row: 3;
  align-items: end;
  background:
    linear-gradient(to bottom, transparent calc(20% - 1px), var(--matrix-line) 20%, transparent calc(20% + 1px)),
    linear-gradient(to bottom, transparent calc(40% - 1px), var(--matrix-line) 40%, transparent calc(40% + 1px)),
    linear-gradient(to bottom, transparent calc(60% - 1px), var(--matrix-line) 60%, transparent calc(60% + 1px)),
    linear-gradient(to bottom, transparent calc(80% - 1px), var(--matrix-line) 80%, transparent calc(80% + 1px));
  padding-top: 15px;
}

.swell-cell {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  border-left: 1px solid var(--matrix-cell-line);
}

.swell-bar {
  width: calc(100% - 3px);
  min-height: 8px;
  background: #258992;
}

.swell-bar.excellent {
  background: #1d858a;
}

.swell-bar.good {
  background: #2fa4ad;
}

.swell-bar.fair {
  background: #43b4bc;
}

.swell-bar.poor {
  background: #6bbfc5;
}

.swell-arrow {
  position: absolute;
  top: 5px;
  z-index: 1;
  color: #59d7dc;
  font-size: 0.72rem;
}

.row-label {
  display: grid;
  place-items: center end;
  padding-right: 6px;
  font-weight: 700;
  font-size: 0.68rem;
}

.sec-label,
.sec-row {
  grid-row: 4;
}

.energy-label,
.energy-row {
  grid-row: 5;
}

.wind-label,
.wind-row {
  grid-row: 6;
}

.temp-label,
.temp-row {
  grid-row: 7;
}

.tide-label,
.matrix-tide-canvas {
  grid-row: 8;
}

.metric-row {
  color: var(--matrix-text);
  background: var(--matrix-metric);
}

.metric-row div,
.wind-row div,
.temp-row div {
  display: grid;
  place-items: center;
  border-left: 1px solid var(--matrix-cell-line);
}

.wind-row,
.temp-row,
.matrix-tide-canvas {
  border-top: 1px solid var(--matrix-line);
}

.wind-row div {
  align-content: center;
  gap: 1px;
  font-size: 0.58rem;
}

.wind-arrow {
  color: #63a2ff;
  font-size: 0.75rem;
}

.temp-row span {
  color: #aeb9c3;
  font-size: 0.72rem;
}

.metric-row div,
.temp-row strong {
  font-size: 0.68rem;
}

.matrix-tide-canvas {
  display: block;
  position: relative;
}

.matrix-tide-canvas canvas {
  width: 100% !important;
  height: 40px !important;
}

@media (max-width: 980px) {
  .topbar,
  .spot-panel,
  .visual-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero-top {
    grid-template-columns: 1fr;
  }

  .embedded-score {
    width: min(100%, 320px);
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-auto-columns: minmax(280px, 86vw);
  }

  .today-analysis-panel {
    grid-template-columns: 1fr;
  }

  .signal-chart-panel {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 16px;
  }

  .radar-frame {
    max-width: 360px;
  }

  .stat-grid,
  .condition-grid,
  .signal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1380px);
    padding-top: 16px;
  }

  .topbar h1 {
    font-size: 2.3rem;
  }

  .stat-grid,
  .condition-grid,
  .signal-grid {
    grid-template-columns: 1fr;
  }
}
