:root {
  --ink: #18332e;
  --muted: #63766f;
  --line: #dce5df;
  --paper: #ffffff;
  --canvas: #f2f5ef;
  --brand: #176b59;
  --brand-dark: #0f4d41;
  --brand-soft: #e3f2eb;
  --water: #167ca5;
  --water-soft: #e0f2f7;
  --sun: #e5a832;
  --danger: #b94a48;
  --shadow: 0 16px 48px rgba(25, 55, 47, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(22, 124, 165, 0.35);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* #app-shell wraps the entire authenticated app (header + tab panels) so
   js/auth.js can hide it behind the sign-in gate. Without this rule it's a
   plain block div sitting between <body> (display:flex; flex-direction:
   column) and <header>/<main> — that breaks the flex chain those elements
   rely on to fill the viewport, so <main>'s `flex: 1` becomes a no-op and it
   shrinks to fit its content instead of filling remaining height. The map
   container (#map, absolutely positioned, sized off its ancestors) then
   inherits a collapsed 0px height and never renders, and other controls in
   that squashed strip become unreliable to click. Giving #app-shell the same
   flex-column-fills-height treatment body would have applied directly
   restores the layout. */
#app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.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;
}

.eyebrow {
  display: block;
  color: var(--brand);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.app-header {
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 64px;
  padding: 0.55rem 1rem;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 150px;
  padding: 0;
  color: var(--ink);
  text-align: left;
  background: none;
  border: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  background: linear-gradient(145deg, var(--water), var(--brand));
  border: 3px solid #d8eee8;
  border-radius: 50% 50% 48% 52% / 58% 58% 42% 42%;
  place-items: center;
}

.brand strong {
  font-size: 1.05rem;
  line-height: 1.05;
}

.tabs {
  display: flex;
  gap: 0.25rem;
}

.tab-button {
  min-height: 38px;
  padding: 0.45rem 0.8rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  background: transparent;
  border: 0;
  border-radius: 10px;
}

.tab-button:hover {
  color: var(--ink);
  background: var(--canvas);
}

.tab-button.active {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.tab-button-catch {
  color: #fff;
  background: var(--brand);
}

.tab-button-catch:hover,
.tab-button-catch.active {
  color: #fff;
  background: var(--brand-dark);
}

.profile-summary {
  display: grid;
  grid-template-columns: auto 72px auto;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
  padding: 0.38rem 0.55rem;
  color: var(--ink);
  background: #f7f9f6;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.auth-sign-out {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 170px;
  min-height: 38px;
  padding: 0.4rem 0.7rem;
  overflow: hidden;
  color: var(--brand-dark);
  font-size: 0.68rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--brand-soft);
  border: 1px solid #c8e0d5;
  border-radius: 999px;
}

.auth-sign-out::before {
  content: '⎋';
  font-size: 0.85rem;
}

.auth-sign-out:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

/* Auth gate */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(160deg, var(--water-soft), var(--canvas) 60%);
}

.auth-card {
  width: min(380px, 100%);
  padding: 1.6rem 1.4rem;
  text-align: center;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.auth-card .brand-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.8rem;
  font-size: 1rem;
}

.auth-card h1 {
  margin: 0 0 0.3rem;
  font-size: 1.4rem;
}

.auth-tagline {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-form {
  display: grid;
  gap: 0.7rem;
  text-align: left;
}

.auth-form label {
  display: grid;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.auth-form input {
  min-height: 42px;
  padding: 0.5rem 0.6rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cedbd3;
  border-radius: 9px;
}

.auth-submit {
  width: 100%;
  margin-top: 0.2rem;
}

.auth-error {
  padding: 0.5rem 0.6rem;
  color: var(--danger);
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(185, 74, 72, 0.1);
  border-radius: 9px;
}

.auth-error.auth-status {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.auth-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.auth-link-button {
  padding: 0;
  color: var(--water);
  font-weight: 750;
  background: none;
  border: 0;
}

.auth-link-button:hover {
  text-decoration: underline;
}

#auth-forgot {
  display: block;
  margin: 0.6rem auto 0;
}

#profile-level {
  font-size: 0.7rem;
  font-weight: 800;
}

#profile-xp-text {
  color: var(--muted);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
}

.profile-xp-track {
  width: 72px;
  height: 5px;
  overflow: hidden;
  background: #dfe7e2;
  border-radius: 999px;
}

#profile-xp-fill {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #57b477);
  transition: width 0.3s ease;
}

.status {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 50%;
  place-items: center;
}

.status-dot {
  width: 9px;
  height: 9px;
  background: #e5a832;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(229, 168, 50, 0.14);
}

.status-ready .status-dot {
  background: #2f9e44;
  box-shadow: 0 0 0 3px rgba(47, 158, 68, 0.14);
}

.status-error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(185, 74, 72, 0.14);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

/* Map */

.map-toolbar {
  z-index: 20;
  display: flex;
  align-items: center;
  padding: 0.65rem 0.9rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.water-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  width: min(760px, 100%);
  padding-left: 0.7rem;
  background: #f4f7f4;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.water-search input {
  min-width: 0;
  height: 40px;
  flex: 1;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.water-search > button {
  align-self: stretch;
  padding: 0 0.9rem;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 800;
  background: var(--brand);
  border: 0;
  border-radius: 0 11px 11px 0;
}

.water-search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  left: 0;
  z-index: 80;
  max-height: 300px;
  padding: 0.35rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.7rem;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 9px;
}

.search-result:hover {
  background: var(--canvas);
}

.search-result strong,
.search-result small {
  display: block;
}

.search-result small {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.target-control {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.target-control select,
#sidebar-sort {
  height: 38px;
  padding: 0 0.65rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.map-filters {
  display: flex;
  gap: 0.35rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 34px;
  padding: 0.35rem 0.55rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.filter-chip.active {
  color: var(--ink);
  background: var(--canvas);
  border-color: #baccc2;
}

.filter-dot,
.source-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.filter-dot.trout {
  background: #2f9e44;
}

.filter-dot.access {
  background: #ec8d24;
}

.source-dot.inferred {
  background: var(--water);
}

.objective-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 35px;
  padding: 0.38rem 1rem;
  color: var(--muted);
  font-size: 0.75rem;
  background: #f7faf7;
  border-bottom: 1px solid var(--line);
}

.objective-bar strong {
  color: var(--ink);
}

#objective-progress {
  margin-left: auto;
  color: var(--brand);
  font-weight: 750;
}

.map-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
}

.maplibregl-ctrl-top-right {
  top: 0.55rem;
  right: 0.55rem;
}

.map-overlay-stack {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 12;
  display: grid;
  gap: 0.5rem;
  width: min(292px, calc(100% - 5rem));
  max-height: calc(100% - 1.5rem);
  pointer-events: none;
}

.map-legend,
.nearby-tray {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(207, 220, 213, 0.9);
  box-shadow: 0 8px 30px rgba(23, 55, 48, 0.16);
  backdrop-filter: blur(12px);
}

.map-legend {
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
}

.map-legend strong {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--ink);
  font-size: 0.72rem;
}

.map-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem 0.7rem;
}

.map-legend-items > span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
}

.gauge-symbol {
  color: var(--water);
  font-size: 0.85rem;
  font-weight: 900;
  line-height: 0.7;
}

.nearby-tray {
  min-height: 0;
  padding: 0.7rem;
  border-radius: 16px;
  overflow: hidden;
}

.nearby-tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
}

.nearby-tray h2 {
  margin: 0.1rem 0 0;
  font-size: 0.86rem;
}

.nearby-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 34px;
  padding: 0.38rem 0.55rem;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 850;
  background: var(--brand);
  border: 0;
  border-radius: 9px;
}

.nearby-toggle:hover {
  background: var(--brand-dark);
}

.nearby-tray.collapsed {
  width: fit-content;
  justify-self: start;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.nearby-tray.collapsed .nearby-tray-header > div,
.nearby-tray.collapsed .nearby-tray-body {
  display: none;
}

.nearby-tray.collapsed .nearby-tray-header {
  margin: 0;
}

.nearby-tray.collapsed .nearby-toggle {
  min-height: 44px;
  padding: 0.6rem 0.8rem;
  font-size: 0.72rem;
  box-shadow: 0 8px 24px rgba(15, 77, 65, 0.3);
}

.nearby-tray-body {
  display: grid;
  min-height: 0;
  gap: 0.45rem;
}

.nearby-sort {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
}

#sidebar-sort {
  height: 30px;
  font-size: 0.68rem;
}

.nearby-content {
  max-height: min(42vh, 420px);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

.spots-row {
  display: grid;
  gap: 0.45rem;
}

.spot-card {
  position: relative;
  width: 100%;
  padding: 0.55rem 0.6rem;
  color: var(--ink);
  text-align: left;
  background: #f7f9f6;
  border: 1px solid #e4ebe6;
  border-radius: 10px;
}

.spot-card:hover {
  background: var(--brand-soft);
  border-color: #bedbce;
}

.spot-card-name {
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spot-card-meta {
  margin-top: 0.15rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.65rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spot-card-dot {
  position: absolute;
  top: 0.65rem;
  right: 0.6rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.sidebar-empty {
  padding: 0.65rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.water-detail-panel {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 30;
  width: min(390px, calc(100% - 1.5rem));
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: sheet-in 0.22s ease-out;
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
}

#water-detail-content {
  height: 100%;
  overflow-y: auto;
}

.water-hero {
  position: relative;
  min-height: 126px;
  padding: 1.15rem 3rem 1rem 1rem;
  color: #fff;
  background:
    radial-gradient(circle at 82% 20%, rgba(255,255,255,0.18) 0 4px, transparent 5px),
    linear-gradient(145deg, #11668a, #125a56 72%);
}

.water-hero::after {
  position: absolute;
  right: -22px;
  bottom: -32px;
  width: 150px;
  height: 78px;
  content: "";
  border: 2px solid rgba(255,255,255,0.14);
  border-radius: 50%;
}

.water-hero .eyebrow {
  color: #bde8df;
}

.water-hero h2 {
  margin: 0.2rem 0 0.3rem;
  font-size: 1.35rem;
  line-height: 1.15;
}

.water-hero p {
  margin: 0;
  color: rgba(255,255,255,0.78);
  font-size: 0.75rem;
}

.sheet-close {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  z-index: 2;
  display: grid;
  width: 32px;
  height: 32px;
  color: #fff;
  font-size: 1.15rem;
  background: rgba(0,0,0,0.18);
  border: 0;
  border-radius: 50%;
  place-items: center;
}

.water-detail-body {
  display: grid;
  gap: 0.8rem;
  padding: 0.9rem;
}

.water-data-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.water-stat {
  min-width: 0;
  padding: 0.6rem;
  background: var(--canvas);
  border-radius: 10px;
}

.water-stat span,
.water-stat strong {
  display: block;
}

.water-stat span {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.water-stat strong {
  margin-top: 0.18rem;
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bite-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--water-soft);
  border: 1px solid #c8e7ef;
  border-radius: 13px;
}

.bite-score {
  display: grid;
  width: 58px;
  height: 58px;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
  background: var(--water);
  border-radius: 50%;
  place-items: center;
}

.bite-card h3,
.detail-section h3 {
  margin: 0;
  font-size: 0.84rem;
}

.bite-card p {
  margin: 0.15rem 0 0;
  color: #4b6870;
  font-size: 0.68rem;
  line-height: 1.4;
}

.confidence {
  display: inline-block;
  margin-top: 0.28rem;
  color: #477981;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-section {
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
}

.source-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.6rem;
}

.species-target-list {
  display: grid;
  gap: 0.4rem;
}

.species-target {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.45rem;
  color: var(--ink);
  text-align: left;
  background: #f8faf8;
  border: 1px solid #e8eee9;
  border-radius: 10px;
}

.species-target.selected {
  background: var(--brand-soft);
  border-color: #bddbce;
}

.species-target-icon {
  display: grid;
  width: 34px;
  height: 34px;
  color: var(--brand);
  place-items: center;
}

.species-target-icon svg {
  width: 100%;
  height: 100%;
}

.species-target strong,
.species-target small {
  display: block;
}

.species-target strong {
  font-size: 0.72rem;
}

.species-target small {
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.62rem;
}

.species-target em {
  color: var(--water);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 850;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.detail-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.28rem 0.5rem;
  color: #42645b;
  font-size: 0.64rem;
  background: var(--brand-soft);
  border-radius: 999px;
}

.detail-tag.warning {
  color: #8b5f16;
  background: #fff1d8;
}

.detail-tag.closed {
  color: #983a39;
  background: #fde4e2;
}

.water-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr;
  gap: 0.4rem;
  padding-top: 0.2rem;
  background: #fff;
}

.water-actions button,
.water-actions a,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.55rem 0.7rem;
  color: var(--brand-dark);
  font-size: 0.7rem;
  font-weight: 800;
  text-decoration: none;
  background: var(--brand-soft);
  border: 0;
  border-radius: 10px;
}

.water-actions .primary-action,
.primary-button {
  color: #fff;
  background: var(--brand);
}

.water-actions .primary-action:hover,
.primary-button:hover {
  background: var(--brand-dark);
}

.water-tooltip {
  position: absolute;
  z-index: 10;
  max-width: 210px;
  padding: 0.55rem 0.65rem;
  color: var(--ink);
  font-size: 0.72rem;
  pointer-events: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 5px 18px rgba(23,55,48,0.2);
}

.water-tooltip-badge {
  margin-bottom: 0.25rem;
  color: var(--brand);
  font-size: 0.64rem;
  font-weight: 800;
}

.water-tooltip-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.tooltip-species {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.tooltip-species-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: currentColor;
}

.tooltip-species-icon svg {
  width: 100%;
  height: 100%;
}

.tooltip-caught {
  color: #b87712;
  font-weight: 750;
}

.tooltip-caught-star {
  color: var(--sun);
}

.closure-badge-closed {
  color: var(--danger);
}

.closure-badge-seasonal {
  color: #966b1e;
}

.app-footer {
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  min-height: 46px;
  padding: 0.45rem 1rem;
  color: var(--muted);
  font-size: 0.7rem;
  background: #fff;
  border-top: 4px solid var(--canvas);
  box-shadow: inset 0 1px var(--line);
}

.footer-section {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.footer-bite {
  min-width: 240px;
}

.bite-meter {
  width: 110px;
  height: 6px;
  overflow: hidden;
  background: #e4eae6;
  border-radius: 999px;
}

.bite-meter-fill {
  width: 0;
  height: 100%;
  background: var(--brand);
  transition: width 0.3s ease;
}

.footer-clock {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.footer-legend {
  gap: 0.8rem;
}

/* Collection and guide */

.collection-panel,
.guide-panel,
.record-panel {
  overflow-y: auto;
  background:
    radial-gradient(circle at 8% 5%, rgba(32, 130, 100, 0.08), transparent 28%),
    var(--canvas);
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  width: min(1180px, calc(100% - 2rem));
  padding: 1.6rem 0 1rem;
  margin: 0 auto;
}

.collection-header {
  align-items: center;
  padding: 1rem 0 0.8rem;
}

.collection-tools {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: auto;
}

.collection-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
}

.fishdex-settings summary {
  min-height: 38px;
  padding: 0.45rem 0.7rem;
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 800;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.fishdex-settings {
  position: relative;
}

.fishdex-settings summary {
  display: flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.fishdex-settings summary::-webkit-details-marker {
  display: none;
}

.fishdex-settings summary::after {
  margin-left: 0.45rem;
  content: "⌄";
}

.fishdex-settings[open] summary::after {
  transform: rotate(180deg);
}

.fishdex-settings-panel {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(180px, 1fr);
  gap: 0.8rem;
  width: min(620px, calc(100vw - 2rem));
  max-height: min(68vh, 620px);
  padding: 0.8rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.fishdex-settings fieldset {
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.fishdex-settings legend {
  padding: 0 0.25rem;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 850;
}

.fishdex-settings fieldset > p {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.63rem;
  line-height: 1.4;
}

.fishdex-settings fieldset > label,
.settings-check-list label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 30px;
  color: var(--ink);
  font-size: 0.68rem;
}

.distance-settings .distance-setting {
  justify-content: space-between;
  gap: 0.75rem;
}

.distance-setting > span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.distance-setting input {
  width: 62px !important;
  min-height: 32px;
  padding: 0.3rem 0.4rem;
  color: var(--ink);
  text-align: right;
  background: #fff;
  border: 1px solid #cedbd3;
  border-radius: 8px;
}

.distance-key {
  display: inline-block;
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(24, 51, 46, 0.16);
}

.distance-far-note {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.45rem !important;
}

.settings-check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.1rem 0.6rem;
}

.settings-check-list input,
.fishdex-settings fieldset > label input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.section-header h1 {
  margin: 0.2rem 0 0.25rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  font-weight: 500;
  letter-spacing: -0.04em;
}

.section-header p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.fishdex-summary {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 260px;
  padding: 0.7rem 0.9rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.summary-ring {
  position: relative;
  display: grid;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  color: var(--brand-dark);
  font-size: 0.75rem;
  font-weight: 900;
  background: conic-gradient(var(--brand) var(--progress), #dfe9e3 0);
  border-radius: 50%;
  place-items: center;
}

.summary-ring::before {
  position: absolute;
  width: 39px;
  height: 39px;
  content: "";
  background: #fff;
  border-radius: 50%;
}

.summary-ring span {
  z-index: 1;
}

.summary-copy strong,
.summary-copy small {
  display: block;
}

.summary-copy strong {
  font-size: 0.8rem;
}

.summary-copy small {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.fishdex-grid,
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.8rem;
  width: min(1180px, calc(100% - 2rem));
  padding-bottom: 2rem;
  margin: 0 auto;
}

.fishdex-empty {
  grid-column: 1 / -1;
  padding: 1.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.badge-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  width: min(1180px, calc(100% - 2rem));
  flex: 0 0 auto;
  margin: 0 auto 0.9rem;
}

.badge-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  padding: 0.65rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.badge-emblem {
  display: grid;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  color: #7c8b84;
  background: #edf1ee;
  border-radius: 50%;
  place-items: center;
}

.badge-card.bronze .badge-emblem {
  color: #8b542f;
  background: #f1dfd0;
}

.badge-card.silver .badge-emblem {
  color: #647079;
  background: #e6ebee;
}

.badge-card.gold .badge-emblem,
.badge-card.platinum .badge-emblem {
  color: #90640e;
  background: #fff0c6;
}

.badge-card strong,
.badge-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-card strong {
  font-size: 0.7rem;
}

.badge-card small {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.61rem;
}

.fishdex-card,
.guide-card {
  position: relative;
  min-height: 190px;
  padding: 1rem;
  overflow: hidden;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.fishdex-card:hover,
.guide-card:hover {
  border-color: #b8d4c7;
  box-shadow: 0 8px 26px rgba(24, 51, 46, 0.09);
  transform: translateY(-1px);
}

.fishdex-card-icon,
.guide-card-icon {
  width: 88px;
  height: 74px;
  margin: 0 auto 0.55rem;
  color: var(--brand);
}

.fishdex-card-icon {
  position: relative;
}

.fishdex-card-icon svg,
.guide-card-icon svg {
  width: 100%;
  height: 100%;
}

.fishdex-card.unknown {
  color: #6f7c76;
  background: #eef1ed;
}

.fishdex-card.unknown .fishdex-card-icon {
  color: #a8b0aa;
  filter: brightness(0.75);
}

.fishdex-card.mastered {
  border-color: #e5bc63;
  box-shadow: inset 0 0 0 2px #f6dfaa;
}

.dex-catch-count {
  position: absolute;
  top: 0.75rem;
  left: 0.8rem;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 850;
}

.dex-distance {
  position: absolute;
  top: 0.72rem;
  right: 0.78rem;
  width: 13px;
  height: 13px;
  background: #aeb9b4;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(24, 51, 46, 0.14);
}

.distance-near {
  background: #2f9e44;
}

.distance-medium {
  background: #e5a832;
}

.distance-far {
  background: #b94a48;
}

.unknown-mark {
  position: absolute;
  inset: 0;
  display: grid;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 5px rgba(24, 51, 46, 0.38);
  place-items: center;
}

.fishdex-card-name,
.guide-card-name {
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.fishdex-card-meta,
.guide-card-meta {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.35;
  text-align: center;
}

.guide-card {
  min-height: 210px;
}

.guide-search input {
  width: min(340px, 38vw);
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
}

/* Catch flow */

.record-layout {
  display: grid;
  grid-template-columns: minmax(0, 760px) minmax(260px, 340px);
  align-items: start;
  gap: 1rem;
  width: min(1120px, calc(100% - 2rem));
  padding-bottom: 2rem;
  margin: 0 auto;
}

.record-form {
  display: grid;
  gap: 0.8rem;
}

.form-card,
.reward-card,
.catch-success {
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.form-step {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

.form-step > span {
  display: grid;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 850;
  background: var(--brand);
  border-radius: 50%;
  place-items: center;
}

.form-step strong,
.form-step small {
  display: block;
}

.form-step strong {
  font-size: 0.84rem;
}

.form-step small {
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.66rem;
}

.photo-drop {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  color: var(--ink);
  background: var(--water-soft);
  border: 1px dashed #8dc3d2;
  border-radius: 12px;
  cursor: pointer;
}

.photo-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.photo-preview {
  display: grid;
  width: 56px;
  height: 56px;
  overflow: hidden;
  color: var(--water);
  font-size: 1.4rem;
  background: #fff;
  border-radius: 10px;
  place-items: center;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-drop strong,
.photo-drop small {
  display: block;
}

.photo-drop strong {
  font-size: 0.76rem;
}

.photo-drop small,
.form-note {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.64rem;
}

.form-note {
  margin: 0.45rem 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.form-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-two {
  grid-column: span 2;
}

.form-grid label {
  display: grid;
  align-content: start;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-height: 40px;
  padding: 0.5rem 0.6rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cedbd3;
  border-radius: 9px;
}

.form-grid textarea {
  resize: vertical;
}

.form-grid .confirm-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding-top: 1.2rem;
  color: var(--ink);
}

.confirm-field input {
  width: 18px;
  min-height: 18px;
}

.selected-water {
  margin-bottom: 0.65rem;
  padding: 0.65rem;
  color: var(--brand-dark);
  font-size: 0.72rem;
  background: var(--brand-soft);
  border-radius: 10px;
}

.secondary-button {
  width: fit-content;
  min-height: 36px;
  margin-top: 0.65rem;
}

.save-catch-button {
  min-height: 50px;
  font-size: 0.8rem;
}

.record-aside {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 0.8rem;
}

.reward-card h2 {
  margin: 0.35rem 0 0.7rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 500;
}

.reward-card ul {
  display: grid;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  list-style: none;
}

.reward-card li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}

.reward-card li span {
  color: var(--brand);
  font-weight: 850;
}

.catch-success {
  color: #fff;
  background: linear-gradient(145deg, var(--brand), #0e4d62);
  border: 0;
}

.catch-success .eyebrow {
  color: #bde8df;
}

.catch-success h2 {
  margin: 0.35rem 0;
}

.reward-total {
  margin: 0.55rem 0;
  font-size: 1.5rem;
  font-weight: 900;
}

.reward-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.reward-tags span {
  padding: 0.25rem 0.42rem;
  font-size: 0.62rem;
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
}

/* Modals */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(13, 35, 30, 0.58);
}

.modal {
  position: relative;
  width: min(520px, 100%);
  max-height: min(86vh, 760px);
  padding: 1.2rem;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.7rem;
  z-index: 2;
  display: grid;
  width: 34px;
  height: 34px;
  color: var(--muted);
  font-size: 1.25rem;
  background: var(--canvas);
  border: 0;
  border-radius: 50%;
  place-items: center;
}

.species-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding-right: 2rem;
}

.species-icon {
  display: grid;
  width: 72px;
  height: 64px;
  flex-shrink: 0;
  color: var(--brand);
  place-items: center;
}

.species-icon svg {
  width: 100%;
  height: 100%;
}

.species-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.species-sci {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: italic;
}

.species-desc {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.modal-section-title {
  margin: 1rem 0 0.45rem;
  font-size: 0.8rem;
}

.catch-list {
  display: grid;
  gap: 0.45rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.catch-entry {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem;
  background: var(--canvas);
  border-radius: 10px;
}

.catch-photo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

.catch-entry-info {
  font-size: 0.7rem;
}

.catch-entry-loc,
.catch-entry-notes {
  margin-top: 0.1rem;
  color: var(--muted);
}

.catch-delete {
  display: grid;
  width: 30px;
  height: 30px;
  color: var(--danger);
  background: transparent;
  border: 0;
  border-radius: 50%;
  place-items: center;
}

.catch-empty {
  color: var(--muted);
  font-size: 0.72rem;
}

.appraisal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem;
  background: #fff5db;
  border-radius: 10px;
}

.appraisal-stars {
  color: #c88619;
  letter-spacing: 0.08em;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.modal-actions button {
  flex: 1;
}

.guide-facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.guide-fact {
  padding: 0.6rem;
  background: var(--canvas);
  border-radius: 10px;
}

.guide-fact span,
.guide-fact strong {
  display: block;
}

.guide-fact span {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
}

.guide-fact strong {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  line-height: 1.35;
}

@media (max-width: 900px) {
  .app-header {
    gap: 0.55rem;
  }

  .brand {
    min-width: auto;
  }

  #profile-xp-text {
    display: none;
  }

  .profile-summary {
    grid-template-columns: auto 48px;
  }

  .auth-sign-out {
    max-width: 40px;
    padding: 0.4rem;
  }

  .auth-sign-out::before {
    font-size: 1rem;
  }

  .profile-xp-track {
    width: 48px;
  }

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

  .record-aside {
    position: static;
    grid-row: 1;
  }

  .reward-card {
    display: none;
  }
}

@media (max-width: 680px) {
  body {
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
  }

  .app-header {
    min-height: 54px;
    padding: 0.4rem 0.7rem;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 0.95rem;
  }

  .tabs {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 90;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    height: calc(60px + env(safe-area-inset-bottom));
    padding: 0.3rem 0.35rem env(safe-area-inset-bottom);
    background: rgba(255,255,255,0.98);
    border-top: 1px solid var(--line);
  }

  .tab-button {
    padding: 0.3rem;
    font-size: 0.7rem;
    border-radius: 8px;
  }

  .tab-button-catch {
    margin: 0.15rem 0.2rem;
  }

  .profile-summary {
    margin-left: auto;
  }

  .auth-sign-out {
    min-height: 36px;
  }

  .map-toolbar {
    padding: 0.45rem 0.55rem;
  }

  .water-search {
    max-width: none;
  }

  .map-overlay-stack {
    top: 0.55rem;
    left: 0.55rem;
    width: min(248px, calc(100% - 4.6rem));
    max-height: calc(100% - 1.1rem);
  }

  .map-legend {
    padding: 0.5rem 0.6rem;
  }

  .map-legend strong {
    margin-bottom: 0.3rem;
    font-size: 0.66rem;
  }

  .map-legend-items {
    gap: 0.3rem 0.55rem;
  }

  .map-legend-items > span {
    font-size: 0.59rem;
  }

  .nearby-tray {
    padding: 0.55rem;
    border-radius: 14px;
  }

  .nearby-tray-header {
    margin-bottom: 0.35rem;
  }

  .nearby-tray .eyebrow {
    display: none;
  }

  .spot-card {
    width: 100%;
    min-width: 0;
  }

  .water-detail-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(72vh, 640px);
    border-radius: 22px 22px 0 0;
    animation: sheet-up 0.22s ease-out;
  }

  .map-canvas-wrap.detail-open .nearby-tray {
    display: none;
  }

  @keyframes sheet-up {
    from {
      opacity: 0;
      transform: translateY(30px);
    }
  }

  .water-hero {
    min-height: 108px;
  }

  .app-footer {
    min-height: 38px;
    padding: 0.35rem 0.6rem;
  }

  .footer-bite,
  .footer-clock,
  .footer-legend {
    display: none;
  }

  .section-header {
    display: block;
    width: calc(100% - 1.2rem);
    padding: 1rem 0 0.75rem;
  }

  .collection-header {
    display: grid;
    gap: 0.65rem;
  }

  .collection-tools {
    margin-left: 0;
  }

  .section-header h1 {
    font-size: 2rem;
  }

  .fishdex-summary {
    min-width: 0;
    margin-top: 0;
  }

  .fishdex-settings-panel {
    position: fixed;
    top: 116px;
    right: 0.6rem;
    left: 0.6rem;
    grid-template-columns: 1fr;
    width: auto;
    max-height: calc(100dvh - 190px);
  }

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

  .fishdex-grid,
  .guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    width: calc(100% - 1.2rem);
  }

  .badge-strip {
    display: flex;
    width: calc(100% - 1.2rem);
    overflow-x: auto;
  }

  .badge-card {
    min-width: 160px;
  }

  .fishdex-card,
  .guide-card {
    min-height: 168px;
    padding: 0.75rem;
  }

  .fishdex-card-icon,
  .guide-card-icon {
    width: 72px;
    height: 62px;
  }

  .guide-search input {
    width: 100%;
    margin-top: 0.75rem;
  }

  .record-layout {
    width: calc(100% - 1rem);
    gap: 0.55rem;
  }

  .form-card {
    padding: 0.8rem;
    border-radius: 13px;
  }

  .form-grid,
  .form-grid-three {
    grid-template-columns: 1fr;
  }

  .span-two {
    grid-column: auto;
  }

  .form-grid .confirm-field {
    padding-top: 0.2rem;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
