:root {
  --bg: #e4eee8;
  --paper: #fbfaf6;
  --ink: #17211e;
  --muted: #5c6b66;
  --line: #d3ddd6;
  --lagoon: #0c6b62;
  --lagoon-deep: #084840;
  --chip: #e7f3ef;
  --shadow: 0 1px 0 rgba(23, 33, 30, 0.04), 0 14px 36px rgba(23, 33, 30, 0.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--lagoon); outline-offset: 2px; }

header {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  padding: 16px 20px 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { border-left: 3px solid var(--lagoon); padding-left: 12px; min-width: 0; }
.kicker {
  margin: 0;
  color: var(--lagoon);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
h1 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.source { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
button.solid, button.ghost {
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
}
button.solid { background: var(--lagoon); border-color: var(--lagoon); color: white; }
button.ghost:hover, button.texty:hover { border-color: var(--lagoon); }
button.solid:hover { background: var(--lagoon-deep); }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 332px minmax(0, 1fr);
}
aside, main { min-height: 0; overflow: auto; }
aside {
  padding: 14px 14px 28px;
  background: #f6faf7;
  border-right: 1px solid var(--line);
}
main {
  padding: 14px 16px 36px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
main > * { flex-shrink: 0; }

.block { margin: 0 0 16px; }
.block h2, .filter-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.help { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }

.preset-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#presets { display: contents; }
.preset-row button, .mini {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  padding: 5px 10px;
  font-size: 13px;
}
.preset-row button:hover, .mini:hover { border-color: var(--lagoon); }

.search, .text-input, select.full {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 8px 10px;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
.toolbar .spacer { margin-left: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
button.linkish {
  border: 0;
  background: transparent;
  color: var(--lagoon-deep);
  padding: 0;
  border-radius: 4px;
}
button.linkish:hover { text-decoration: underline; }

.species-scroll {
  max-height: min(420px, 46vh);
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.family-row, .species-row, .choice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}
.family-row {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e7f0eb;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 700;
}
.species-row { cursor: pointer; font-size: 13.5px; }
.species-row:hover, .choice:hover { background: #eef6f2; }
.species-row em { font-style: italic; flex: 1; min-width: 0; }
.count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--lagoon); flex: none; }

.controls { display: grid; gap: 8px; }
.controls label.stack { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.controls select { width: 100%; border: 1px solid var(--line); background: white; border-radius: 10px; padding: 7px 8px; }
.check { display: flex; align-items: center; gap: 8px; }
.slider-line { display: flex; align-items: center; gap: 8px; }
.slider-line input[type="range"] { flex: 1; accent-color: var(--lagoon); }
.slider-line output { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }

.choice-list { display: grid; gap: 1px; }
.range-block { margin-top: 8px; }
.range-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.range-head strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.range-block label { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: #fff6e8;
  border: 1px solid #efd3a8;
  color: #6a4210;
  border-radius: 12px;
  padding: 8px 12px;
}
.banner.error { background: #fdecea; border-color: #f3c1b8; color: #8a2b1f; }
.banner button { border: 0; background: transparent; color: inherit; text-decoration: underline; padding: 0; }

.summary { display: flex; flex-wrap: wrap; gap: 8px; }
.summary .chip {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 12px;
  min-width: 92px;
}
.summary .chip span {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.summary .chip strong { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.caption { margin: 0; color: var(--muted); }

.stage {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.plot { height: min(72vh, 760px); min-height: 540px; }
.empty {
  min-height: 420px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 32px;
  font-size: 16px;
}
.facets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 4px;
  padding: 8px;
}
.facet { min-width: 0; }
.facet-title { font-family: var(--serif); font-size: 18px; padding: 10px 12px 0; }
.facet-title em { font-style: italic; }
.facet-plot { height: 400px; }

.underplot { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; min-height: 0; }
.symbol-key { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; color: var(--muted); font-size: 13px; }
.key-item { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.key-item em { font-style: italic; }
.brush {
  background: #fff6e8;
  border: 1px solid #efd3a8;
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.tip {
  background: var(--chip);
  border: 1px solid #b7ddd4;
  color: #0d3f3a;
  border-radius: 12px;
  padding: 8px 12px;
}
.tip button { margin-left: 6px; }

.fishcard {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px 16px;
  align-items: end;
}
.fishcard.is-empty { display: block; color: var(--muted); }
.fishcard .who { grid-column: 1 / -1; }
.card-kicker { color: var(--lagoon); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.fishcard em.name { font-family: var(--serif); font-size: 26px; font-style: italic; font-weight: 500; letter-spacing: -0.02em; }
.fishcard .meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 2px; }
.fishcard .metric span { display: block; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.fishcard .metric strong { font-size: 16px; font-weight: 600; }
.fishcard .sentence { grid-column: 1 / -1; margin: 0; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; grid-column: 1 / -1; }

h2.section-title {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
}
h2.section-title em { font-style: italic; }
.tablewrap {
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 7px 9px; text-align: left; vertical-align: baseline; }
th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { border-bottom: 1px solid #e7eeea; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: #f3faf7; }
td em { font-style: italic; }
.sub { color: var(--muted); font-size: 12px; }
button.sort {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  letter-spacing: inherit;
  text-transform: inherit;
  padding: 0;
}
button.texty {
  border: 0;
  background: transparent;
  color: var(--lagoon);
  padding: 0 0 0 8px;
}
button.texty:hover { text-decoration: underline; }

.notes { margin: 4px 0 0; color: var(--muted); font-size: 13px; max-width: 78ch; }
.notes p { margin: 0 0 8px; }
.formula { font-family: var(--serif); color: var(--ink); }

@media (max-width: 980px) {
  body { height: auto; overflow: auto; display: block; }
  .workspace { display: block; }
  aside, main { overflow: visible; height: auto; }
  .plot { height: 70vh; }
  header { align-items: flex-start; flex-direction: column; }
}
