:root {
  --bg: #dce5e8;
  --panel: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(248, 252, 252, 0.18));
  --panel-strong: linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(248, 252, 252, 0.24));
  --line: rgba(255, 255, 255, 0.34);
  --line-strong: rgba(106, 130, 148, 0.24);
  --text: #102230;
  --muted: #5d6e79;
  --accent: #0f7d80;
  --accent-soft: rgba(15, 125, 128, 0.16);
  --gold: #c08a39;
  --danger: #b42318;
  --highlight: rgba(255, 255, 255, 0.58);
  --shadow: 0 30px 80px rgba(20, 38, 52, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at 16% 18%, rgba(15, 125, 128, 0.26), transparent 24%),
    radial-gradient(circle at 82% 10%, rgba(192, 138, 57, 0.2), transparent 20%),
    radial-gradient(circle at 76% 74%, rgba(136, 185, 215, 0.24), transparent 25%),
    linear-gradient(180deg, #edf4f5 0%, var(--bg) 48%, #d7e0e4 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.8;
  background:
    radial-gradient(circle at 22% 24%, rgba(255, 255, 255, 0.75), transparent 18%),
    radial-gradient(circle at 75% 18%, rgba(255, 255, 255, 0.42), transparent 16%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.22), transparent 36%, rgba(255, 255, 255, 0.16) 60%, transparent 80%);
}

body::after {
  content: "";
  position: fixed;
  inset: auto auto 4% 8%;
  width: 42vw;
  height: 42vw;
  max-width: 560px;
  max-height: 560px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.35;
  background: radial-gradient(circle, rgba(116, 194, 198, 0.4), transparent 68%);
  filter: blur(36px);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 56px;
}

.panel {
  position: relative;
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.14) 28%, transparent 56%),
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.32), transparent 42%);
}

.hero,
.controls-panel,
.table-panel,
.footer-panel,
.chart-panel,
.map-panel,
.summary-card {
  padding: 24px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(220px, 0.72fr);
  gap: 22px;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 125, 128, 0.24), transparent 68%);
  pointer-events: none;
}

.panel-kicker,
.status-label,
.summary-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 16px 0 12px;
  max-width: 760px;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(3rem, 6vw, 5.4rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
}

.hero-text {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.72;
}

.hero-credit {
  margin: 14px 0 0;
  color: var(--accent);
  font-size: 0.96rem;
  font-weight: 700;
}

.hero-actions,
.control-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-actions {
  margin-top: 22px;
}

.hero-monitor-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.sound-toggle[aria-pressed="true"] {
  color: var(--accent);
  border-color: rgba(15, 125, 128, 0.28);
  background: linear-gradient(180deg, rgba(15, 125, 128, 0.2), rgba(255, 255, 255, 0.26));
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 12px 26px rgba(20, 38, 52, 0.1);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 16px 30px rgba(20, 38, 52, 0.14);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, rgba(14, 138, 121, 0.95), rgba(8, 95, 85, 0.84));
}

.btn-secondary {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.36);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.22));
}

.hero-status {
  display: grid;
  justify-self: end;
  max-width: 330px;
  align-content: start;
  gap: 18px;
  padding-top: 10px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
}

.status-note strong,
.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.3rem;
  line-height: 1.2;
}

.status-note p,
.summary-card p,
.muted-text {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.status-note {
  padding-left: 14px;
  border-left: 2px solid rgba(15, 125, 128, 0.24);
}

.status-note code {
  font-size: 0.92em;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.summary-card strong {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.controls-panel {
  margin-top: 22px;
}

.panel-head,
.mini-series-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.panel-head.compact {
  margin-bottom: 14px;
}

.panel-head h2,
.mini-series-head h3 {
  margin: 4px 0 0;
  font-family: "Cormorant Garamond", serif;
  line-height: 1;
  letter-spacing: -0.03em;
}

.panel-head h2 {
  font-size: 2rem;
}

.mini-series-head h3 {
  font-size: 1.5rem;
}

.quick-range-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.chip {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.18));
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.chip:hover {
  transform: translateY(-1px);
}

.chip.active {
  border-color: rgba(15, 125, 128, 0.32);
  background: linear-gradient(180deg, rgba(15, 125, 128, 0.18), rgba(255, 255, 255, 0.24));
  color: var(--accent);
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.94rem;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.2));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.control-actions {
  margin-top: 18px;
}

.insight-grid,
.geo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.dual-series-grid {
  display: grid;
  gap: 16px;
}

.mini-series {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.14));
}

.tight-series {
  padding: 14px 14px 12px;
}

.tight-series .mini-series-head {
  gap: 12px;
}

.tight-series .mini-series-head h3 {
  font-size: 1.36rem;
}

.tight-series .mini-series-head p {
  margin: 0;
  max-width: 320px;
  line-height: 1.4;
}

.svg-wrap {
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.24));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
}

.svg-wrap.compact {
  margin-top: 12px;
}

.tight-series .svg-wrap.compact {
  margin-top: 8px;
}

.bubble-wrap {
  min-height: 430px;
}

.chart-svg {
  display: block;
  width: 100%;
  height: 320px;
}

#occurrence-chart,
#rolling-chart,
#scatter-chart,
#depth-heatmap-chart {
  height: 280px;
}

#month-chart,
#year-chart {
  height: 250px;
}

#bubble-chart {
  height: 430px;
}

.band-chart {
  display: grid;
  gap: 14px;
}

.band-row {
  display: grid;
  gap: 8px;
}

.band-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.band-name-wrap,
.band-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.band-swatch,
.band-inline-dot,
.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.band-name {
  font-weight: 700;
}

.rag-chip,
.legend-rag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.32);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.band-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.34);
}

.band-track > span {
  display: block;
  height: 100%;
  width: calc(var(--size) * 100%);
  border-radius: inherit;
  background: var(--fill);
}

.band-foot {
  color: var(--muted);
  font-size: 0.84rem;
}

.scatter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.2));
  font-size: 0.86rem;
}

.map-panel {
  padding: 20px;
}

#map {
  width: 100%;
  height: 520px;
  margin-top: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  overflow: hidden;
  background: #d5e2e8;
}

.table-panel {
  margin-top: 22px;
}

.table-wrap {
  margin-top: 16px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.16));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

thead {
  background: rgba(255, 255, 255, 0.28);
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(22, 40, 48, 0.08);
  vertical-align: top;
}

th {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.38);
}

.code-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(15, 125, 128, 0.12);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

.footer-panel {
  margin-top: 22px;
  padding: 18px 24px;
}

.footer-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.error-banner {
  margin-top: 10px !important;
  color: var(--danger);
  font-weight: 600;
}

.grid-line {
  stroke: rgba(22, 40, 48, 0.12);
  stroke-width: 1;
}

.axis-text {
  fill: var(--muted);
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
}

.heatmap-axis-label {
  font-size: 10.5px;
}

.axis-title {
  fill: var(--muted);
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
  font-weight: 700;
}

.chart-hit-area,
.scatter-point,
.bubble-node {
  cursor: pointer;
}

.bubble-label {
  fill: #1a2430;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  pointer-events: none;
}

.bubble-count {
  fill: rgba(22, 40, 48, 0.72);
  font-size: 0.76em;
}

.chart-empty,
.chart-empty-text {
  fill: var(--muted);
  color: var(--muted);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.94rem;
}

.chart-empty {
  padding: 24px 0;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: rgba(255, 255, 255, 0.88);
}

.map-popup {
  line-height: 1.5;
}

.map-popup strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.map-popup .meta-line {
  color: var(--muted);
  font-size: 0.84rem;
}

.chart-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000;
  max-width: 260px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 20px 45px rgba(22, 40, 48, 0.16);
  color: var(--text);
  line-height: 1.45;
  pointer-events: none;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.toast-host {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 3000;
  display: grid;
  gap: 12px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.live-toast {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 16px 16px 14px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.44)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
  box-shadow:
    0 22px 60px rgba(17, 35, 47, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  overflow: hidden;
  pointer-events: auto;
  animation: toast-in 240ms ease-out;
}

.live-toast::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--toast-accent, rgba(15, 125, 128, 0.72));
}

.live-toast::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.42), transparent 32%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.2), transparent 38%);
  pointer-events: none;
}

.live-toast.toast-green {
  --toast-accent: #3aa76d;
}

.live-toast.toast-amber {
  --toast-accent: #e7a72f;
}

.live-toast.toast-red {
  --toast-accent: #d54233;
}

.live-toast.toast-unknown {
  --toast-accent: #6f8391;
}

.toast-head,
.toast-meta-line {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.toast-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.toast-title {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
}

.toast-rag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--toast-accent, rgba(15, 125, 128, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.toast-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.44);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.toast-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.64);
}

.toast-meta {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  padding-right: 20px;
}

.toast-primary {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.45;
}

.toast-secondary,
.toast-reference {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.toast-reference {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.toast-sound {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.live-toast.is-hiding {
  animation: toast-out 180ms ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 4px;
}

.chart-tooltip .tooltip-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.34);
  font-size: 0.88em;
}

@media (max-width: 1200px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .insight-grid,
  .geo-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .hero,
  .filter-grid {
    grid-template-columns: 1fr;
  }

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

  .hero-status {
    justify-self: start;
    max-width: none;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 18px, 1440px);
    padding-top: 10px;
  }

  .hero,
  .controls-panel,
  .table-panel,
  .footer-panel,
  .chart-panel,
  .map-panel,
  .summary-card {
    padding: 18px;
    border-radius: 20px;
  }

  .hero h1 {
    font-size: clamp(2.5rem, 11vw, 4rem);
  }

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

  .panel-head,
  .mini-series-head {
    flex-direction: column;
  }

  .chart-svg,
  #occurrence-chart,
  #rolling-chart,
  #scatter-chart,
  #depth-heatmap-chart,
  #month-chart,
  #year-chart {
    height: 260px;
  }

  #bubble-chart {
    height: 380px;
  }

  #map {
    height: 420px;
  }

  .toast-host {
    top: 12px;
    right: 10px;
    left: 10px;
    width: auto;
  }

  .live-toast {
    padding: 14px 14px 12px;
    border-radius: 18px;
  }
}
