/* Light, map-first layout: sidebar (fish) on the left, tile card floating over the map. */
:root {
  --bg: #ffffff;          /* sidebar, cards */
  --card: #f3f6f8;        /* rows, inputs, stat tiles */
  --card-2: #e9eef2;      /* hover */
  --line: #e1e7ec;
  --ink: #13212b;         /* 16:1 on white */
  --muted: #5b6875;       /* 5.7:1 on white */
  --accent: #0a6e4a;      /* deep sea-green: buttons, links, selection (6.3:1) */
  --accent-soft: #e3f3ec;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --shadow: 0 8px 28px rgba(16, 33, 43, .14), 0 1px 4px rgba(16, 33, 43, .08);
  --sb-w: 372px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); overflow: hidden; }
body { font-size: 14px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }

.map { position: fixed; top: 0; right: 0; bottom: 0; left: var(--sb-w); }
.float { position: fixed; z-index: 5; }

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  position: fixed; z-index: 10; top: 0; left: 0; bottom: 0; width: var(--sb-w);
  display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--line);
  box-shadow: 4px 0 18px rgba(16, 33, 43, .06);
}
.sb-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 10px; }
.grab { display: none; }
.brand { flex: 1; font-weight: 750; font-size: 17px; letter-spacing: -.01em; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); margin-right: 4px; font-size: 15px; }
.iconbtn {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font: italic 700 14px Georgia, serif; cursor: pointer;
}
.iconbtn:hover { color: var(--ink); }

.search { position: relative; margin: 0 16px 12px; }
.search .sicon { position: absolute; left: 12px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; padding: 10px 12px 10px 36px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink); font: inherit;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); }
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none; z-index: 20;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto;
}
.suggest li { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--card-2); }
.suggest img, .suggest .noimg { width: 40px; height: 30px; border-radius: 6px; object-fit: cover; flex: none; background: var(--card-2); }
.suggest .t { display: flex; flex-direction: column; min-width: 0; }
.suggest .t b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sci { font-style: italic; color: var(--muted); font-size: 12.5px; }

.sb-body { flex: 1; min-height: 0; overflow: auto; padding: 0 16px 16px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.sb-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 4px 0 10px; }
.sb-title h2 { font-size: 15px; margin: 0; }
.sb-title .muted { font-size: 12.5px; }
.sb-title { align-items: center; }
.sb-actions { display: flex; align-items: center; gap: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.note { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }

.empty { margin-top: 28px; text-align: center; color: var(--muted); padding: 0 10px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* filter chips */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.fchip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px;
  padding: 5px 11px; font-size: 12.5px; cursor: pointer;
}
.fchip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.fchip .n { opacity: .7; margin-left: 3px; }

/* fish list */
.fishlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.fishrow {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line);
  background: var(--bg); text-align: left; cursor: pointer; border-radius: 12px;
}
.fishrow:hover { background: var(--card); }
.fishrow:focus-visible { outline: none; border-color: var(--accent); }
.thumb {
  position: relative; flex: none; width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, #e3edf2, #d3e2ea);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; opacity: .6; }
.fishrow .nm { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fishrow .nm b { font-size: 14px; font-weight: 600; line-height: 1.25; }
.fishrow .nm .sci { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fishrow .tags { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tag { font-size: 11px; font-weight: 650; padding: 1px 8px; border-radius: 999px; }
.t-prot { background: #fdecea; color: var(--danger); }
.seen { font-size: 11px; color: var(--muted); white-space: nowrap; }
.seen::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); margin-right: 5px; vertical-align: 1px; }

/* fish page (in the sidebar) */
.fishnav { display: flex; justify-content: space-between; align-items: center; margin: 2px 0 10px; }
.navbtn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 5px 12px 5px 10px; cursor: pointer; color: var(--muted); font-size: 13px;
}
.navbtn:hover { color: var(--ink); }
.closebtn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.closebtn:hover { color: var(--ink); }
.hero { position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 3; background: linear-gradient(135deg, #e3edf2, #d3e2ea); }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero .ph { font-size: 44px; }
.hero .credit {
  position: absolute; right: 0; bottom: 0; max-width: 100%; padding: 3px 8px; font-size: 10.5px;
  background: rgba(0, 0, 0, .55); border-top-left-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero .credit a { color: #fff; text-decoration: none; }
.hero .credit { color: #fff; }
.fishname { margin: 14px 0 0; font-size: 21px; line-height: 1.2; letter-spacing: -.01em; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.badge { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.badge.danger { color: var(--danger); border-color: #f4c7c1; background: #fdf3f2; }
.links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.links a {
  flex: 1 1 auto; text-align: center; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 13px;
}
.links a:hover { border-color: var(--accent); }
.loading { padding: 14px 0; color: var(--muted); }

/* ---------------------------------------------------------------- tile card (MapLibre popup) */
.tilepop .maplibregl-popup-content {
  background: #ffffff; color: var(--ink); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 14px 12px; box-shadow: var(--shadow); width: 290px;
}
.tilepop .maplibregl-popup-tip { display: none; }
.tilepop .tp-head { display: flex; align-items: center; gap: 10px; }
.tilepop .tp-title { flex: 1; min-width: 0; }
.tilepop .code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.codebtn { border: 0; background: none; padding: 0; font: inherit; cursor: copy; }
.codebtn:hover { color: var(--accent); }
.tilepop .stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 8px; min-width: 0; }
.tilepop .stat .k { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tilepop .stat .v { display: block; font-weight: 650; font-size: 13.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- map keys, hints */
.keys { left: calc(var(--sb-w) + 14px); bottom: 30px; }
.pill { background: #ffffff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 12px; font-size: 12.5px; }
#speciesKey { display: flex; align-items: center; gap: 10px; }
#speciesKey .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
#speciesKey button { border: 0; background: var(--card-2); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; color: var(--muted); }
.hint, .toast {
  left: calc(50% + var(--sb-w) / 2); transform: translateX(-50%); padding: 9px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 550;
  background: #ffffff; border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow); white-space: nowrap; pointer-events: none;
}
.hint { bottom: 40px; }
.toast { top: 20px; }

.btn { border: 0; background: var(--accent); color: var(--accent-ink); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 650; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent-ink); }

.maplibregl-ctrl-group { box-shadow: var(--shadow) !important; }
.maplibregl-ctrl-attrib { font-size: 10.5px; }

/* ---------------------------------------------------------------- about + lab */
dialog { max-width: min(760px, 92vw); border: 1px solid var(--line); border-radius: 16px; padding: 22px; background: var(--bg); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(16, 33, 43, .35); }
dialog .close { position: absolute; top: 10px; right: 14px; border: 0; background: none; font-size: 24px; color: var(--muted); cursor: pointer; }
dialog h2 { margin-top: 0; }
dialog h3 { font-size: 15px; margin: 18px 0 6px; }
dialog table { border-collapse: collapse; width: 100%; font-size: 12px; }
dialog td, dialog th { border-top: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
dialog li { margin-bottom: 3px; font-size: 13.5px; }

.lab-wrap { max-height: 45%; overflow: auto; border-top: 1px solid var(--line); padding: 12px 16px; }
.lab { font-size: 13px; }
.lab h2 { font-size: 16px; margin: 0 0 6px; }
.lab h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 6px; }
.lab .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lab .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.lab label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.lab .checks { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }
.lab .checks label { flex-direction: row; align-items: center; color: var(--ink); gap: 4px; }
.lab input, .lab select, .lab textarea {
  width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit;
}
.lab textarea { font-family: ui-monospace, Consolas, monospace; font-size: 11px; height: 90px; }

/* ---------------------------------------------------------------- phones: sidebar becomes a bottom sheet */
@media (max-width: 760px) {
  :root { --sb-w: 0px; }
  .map { left: 0; }
  .sidebar {
    top: auto; width: auto; right: 0; height: 132px; border-right: 0; border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0; box-shadow: 0 -8px 24px rgba(16, 33, 43, .12); transition: height .25s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.sheet-open .sidebar { height: 50vh; height: 50dvh; }
  .grab { display: block; position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
  .sb-head { padding-top: 18px; }
  .keys { left: 12px; bottom: calc(132px + 12px); }
  body.sheet-open .keys { bottom: calc(50vh + 12px); bottom: calc(50dvh + 12px); }
  .hint { bottom: calc(132px + 14px); left: 50%; }
  .toast { left: 50%; }
  .tilepop .maplibregl-popup-content { width: min(290px, calc(100vw - 32px)); }
  .lab-wrap { max-height: 50%; }
}

/* ---------------------------------------------------------------- charts (js/charts.js) */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.logo svg { width: 18px; height: 9px; }
.ph .fishsil { width: 60%; color: #9fb6c3; }
.hero .ph .fishsil { width: 30%; }
.empty-ic { width: 56px; height: 56px; color: var(--muted); margin-bottom: 10px; }


/* tile card sections */
.tilepop .sec { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.tilepop .sec-h { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }

/* fish page: KPI row + chart blocks */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.kpi { background: var(--card); border-radius: 12px; padding: 9px 10px; min-width: 0; }
.kpi .k, .leanrow .k { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .v { display: block; font-size: 19px; font-weight: 650; margin-top: 2px; white-space: nowrap; }
.cblock { background: var(--card); border-radius: 12px; padding: 10px 12px 6px; margin-top: 8px; }
.cb-h { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.cb-t { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cb-v { font-weight: 600; margin: 2px 0 2px; }
.leanrow { background: var(--card); border-radius: 12px; padding: 9px 12px; margin-top: 8px; font-weight: 600; }

/* ---------------------------------------------------------------- tile card: live conditions */
.tilepop .maplibregl-popup-content { max-height: calc(100vh - 80px); overflow: auto; scrollbar-width: thin; }
.tilepop .tp-head + .sec { border-top: 0; padding-top: 0; }
.now { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.now .stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; min-width: 0; }
.now .k { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.now .v { display: flex; align-items: center; gap: 4px; font-weight: 650; font-size: 17px; margin-top: 1px; white-space: nowrap; }
.now .v small { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.now .sub { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arrow { width: 13px; height: 13px; color: var(--muted); flex: none; }
.depthrow b { display: block; font-size: 15px; margin-bottom: 2px; }
.tilepop .src { margin-top: 10px; font-size: 10.5px; color: var(--muted); }
.tilepop .src a { color: var(--muted); }
.tilepop .note { margin-top: 10px; }
@media (max-width: 760px) {
  /* the card lives in the half of the screen above the sheet and leaves room for the tapped tile */
  .tilepop .maplibregl-popup-content { max-height: calc(50vh - 90px); max-height: calc(50dvh - 90px); padding: 10px 12px; }
  /* fingers, not cursors: 40 px targets */
  .closebtn, .iconbtn { width: 40px; height: 40px; }
  .fchip { padding: 9px 14px; font-size: 13.5px; }
  .navbtn { padding: 9px 14px 9px 12px; }
  .maplibregl-ctrl-group button { width: 40px; height: 40px; }
  #speciesKey button { width: 32px; height: 32px; }
  .suggest li { padding: 9px 8px; }
}
.tp-line { margin-top: 6px; font-size: 13.5px; }
.linkbtn { border: 0; background: none; padding: 6px 0 0; color: var(--accent); font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: underline; }
.tilepop .src .linkbtn { float: right; padding: 0; font-size: 12px; }
.kpi .v.range { font-size: 15px; line-height: 23px; }
.onthis .small { display: block; margin-top: 2px; }
.empty .navbtn { margin-top: 10px; }
.like .lab { max-width: 120px; }
.tilepop .sec-h { gap: 10px; white-space: nowrap; }
.tilepop .sec-h span:last-child { overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- likelihood meter (list rows, fish page) */
.like { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 64px; }
.like .lab { font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.like .meterbar { display: block; width: 64px; height: 6px; border-radius: 3px; background: #dcefe6; overflow: hidden; }
.like .meterbar i { display: block; height: 100%; border-radius: 3px; }
.onthis { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; }
.onthis .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: block; }
.onthis b { font-size: 15px; }
.onthis .like { min-width: 120px; }
.onthis .like .meterbar { width: 120px; height: 8px; border-radius: 4px; }
.onthis .like .meterbar i { border-radius: 4px; }
.seen::before { background: var(--accent) !important; }
.tilepop .stat, .now .stat { background: var(--card); border-color: transparent; }
