:root {
  --paper: #f6f4ee;
  --card: #fffdf8;
  --ink: #1c2321;
  --muted: #535d58;
  --rule: #d8d2c4;
  --rule-strong: #b9b1a0;
  --accent: #1d5a4c;
  --accent-soft: #e3ece8;
  --ok: #1d6640;
  --ok-bg: #e5f0e7;
  --risky: #7f4c00;
  --risky-bg: #f8ecd6;
  --bad: #9f2b22;
  --bad-bg: #f7e2de;
  --wait: #3b4757;
  --wait-bg: #e6e9ee;
  --focus: #b8860b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 6px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.55 var(--sans); font-variant-numeric: tabular-nums;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: #123d33; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: 0.005em; }
h1 { font-size: 1.85rem; margin: 28px 0 8px; }
h2 { font-size: 1.35rem; margin: 32px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.1rem; margin: 22px 0 8px; }
p { margin: 0 0 12px; }
.lede { font-size: 1.08rem; color: var(--muted); margin-bottom: 20px; max-width: 46em; }
.small { font-size: 0.88rem; color: var(--muted); }
.sci { font-style: italic; color: var(--muted); }

/* Masthead and footer */
.masthead { background: var(--card); border-bottom: 1px solid var(--rule); }
.masthead-inner { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 22px; padding-top: 12px; padding-bottom: 10px; }
.brand { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 2px 4px; margin-left: -8px; }
.nav a { color: var(--ink); text-decoration: none; padding: 6px 8px; border-radius: 4px; font-size: 0.95rem; }
.nav a:hover { background: var(--accent-soft); }
.nav a[aria-current="page"] { color: var(--accent); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.footer { border-top: 1px solid var(--rule); margin-top: 24px; background: var(--card); }
.footer-inner { padding-top: 18px; padding-bottom: 26px; }
.footer-line { margin-bottom: 8px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.footer-small { font-size: 0.85rem; color: var(--muted); margin: 0; }

/* Reserved spaces for a later ad unit and gear recommendations: fixed size, intentionally empty. */
.reserved-row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-top: 28px; }
.reserved { flex: none; }
.reserved-ad { width: 300px; height: 250px; }
.reserved-gear { width: 300px; height: 250px; }

/* Panels and controls */
.panel { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-title { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; margin: 0 0 12px; border: 0; padding: 0; }
.field { margin-bottom: 14px; }
.field-label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; }
.field-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.input {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  padding: 9px 11px; min-height: 44px; width: 100%; appearance: none; -webkit-appearance: none;
}
.input:focus { border-color: var(--accent); }
.input-num { width: 7.5em; text-align: right; }
.field-row .input:not(.input-num) { flex: 1; width: auto; min-width: 10em; }
.unit-after { color: var(--muted); font-size: 0.95rem; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 6px 0 0; }

.btn {
  font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer; border-radius: var(--radius);
  min-height: 44px; padding: 8px 14px; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  appearance: none; -webkit-appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: #164a3e; }
.btn-quiet { background: transparent; color: var(--accent); border-color: var(--rule-strong); }
.btn-quiet:hover { background: var(--accent-soft); }
.btn-small { min-height: 36px; padding: 4px 10px; font-size: 0.9rem; }
.btn-icon { min-width: 44px; padding: 0; font-size: 1.2rem; line-height: 1; }
.btn[disabled] { opacity: 0.45; cursor: default; }

.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; background: #fff; }
.seg button {
  font: inherit; font-size: 0.95rem; border: 0; background: transparent; color: var(--ink); padding: 8px 14px;
  min-height: 42px; cursor: pointer; appearance: none; -webkit-appearance: none;
}
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font: inherit; font-size: 0.88rem; border: 1px solid var(--rule-strong); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 4px 12px; min-height: 34px; cursor: pointer; appearance: none; -webkit-appearance: none;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Species picker (combobox) */
.picker { position: relative; }
.picker-list {
  list-style: none; margin: 4px 0 0; padding: 4px; background: #fff; border: 1px solid var(--rule-strong);
  border-radius: var(--radius); max-height: 320px; overflow-y: auto; position: absolute; left: 0; right: 0; z-index: 5;
  box-shadow: 0 6px 18px rgba(28, 35, 33, 0.12);
}
.picker-list[hidden] { display: none; }
.picker-option { padding: 8px 10px; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.picker-option[aria-selected="true"], .picker-option:hover { background: var(--accent-soft); }
.picker-option .meta { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.picker-group { padding: 8px 10px 2px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.picker-empty { padding: 10px; color: var(--muted); }

/* Stock list */
.stock { list-style: none; margin: 12px 0 0; padding: 0; }
.stock-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--rule); }
.stock-row:last-child { border-bottom: 1px solid var(--rule); }
.stock-name { flex: 1; min-width: 0; }
.stock-name a { font-weight: 600; color: var(--ink); }
.stock-name .small { display: block; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: #fff; }
.stepper button { font: inherit; border: 0; background: transparent; width: 40px; height: 40px; cursor: pointer; color: var(--accent); font-size: 1.25rem; appearance: none; -webkit-appearance: none; }
.stepper input { width: 3.2em; border: 0; text-align: center; font: inherit; font-weight: 600; height: 40px; background: transparent; color: var(--ink); appearance: textfield; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.remove { font: inherit; border: 0; background: transparent; color: var(--muted); width: 40px; height: 40px; cursor: pointer; font-size: 1.3rem; border-radius: 4px; appearance: none; -webkit-appearance: none; }
.remove:hover { color: var(--bad); background: var(--bad-bg); }
.empty-note { color: var(--muted); margin: 10px 0 0; }

/* Verdict */
.verdict { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; border: 1px solid; }
.verdict-word { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; line-height: 1.15; margin: 0; }
.verdict-sub { margin: 4px 0 0; font-size: 0.95rem; }
.v-suitable { background: var(--ok-bg); border-color: #b9d6c0; color: var(--ok); }
.v-risky { background: var(--risky-bg); border-color: #e6cc9c; color: var(--risky); }
.v-not-suitable { background: var(--bad-bg); border-color: #e6b8b1; color: var(--bad); }
.v-not-ready { background: var(--wait-bg); border-color: #c4cbd5; color: var(--wait); }
.verdict-sub, .verdict-sub a { color: var(--ink); }
.guide { font-size: 0.92rem; color: var(--muted); margin: 12px 0 0; }
.guide strong { color: var(--ink); font-weight: 600; }

.findings { list-style: none; padding: 0; margin: 0; }
.finding { display: grid; grid-template-columns: 22px 1fr; gap: 0 8px; padding: 9px 0; border-top: 1px solid var(--rule); }
.finding:first-child { border-top: 0; }
.mark { width: 14px; height: 14px; border-radius: 50%; margin-top: 5px; border: 2px solid; }
.s-ok .mark { border-color: var(--ok); background: var(--ok); }
.s-risky .mark { border-color: var(--risky); background: transparent; border-width: 3px; }
.s-not-suitable .mark { border-color: var(--bad); background: var(--bad); border-radius: 2px; transform: rotate(45deg) scale(0.85); }
.s-not-ready .mark { border-color: var(--wait); background: var(--wait); border-radius: 2px; }
.rule { display: block; font-size: 0.76rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.s-risky .rule { color: var(--risky); }
.s-not-suitable .rule { color: var(--bad); }

.meter { margin: 6px 0 14px; }
.meter-head { display: flex; justify-content: space-between; font-size: 0.92rem; }
.meter-track { height: 10px; background: #e9e5da; border-radius: 999px; overflow: hidden; margin-top: 4px; position: relative; }
.meter-fill { height: 100%; width: 0; background: var(--ok); border-radius: 999px; }
.meter-fill.risky { background: #c08a1e; }
.meter-fill.over { background: var(--bad); }
.water { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.water div { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 8px 10px; }
.water dt { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.water dd { margin: 2px 0 0; font-weight: 600; }

.status { min-height: 1.4em; font-size: 0.92rem; margin: 8px 0 0; }
.status.error { color: var(--bad); font-weight: 600; }
.status.saved { color: var(--ok); }
.saved-list { list-style: none; padding: 0; margin: 10px 0 0; }
.saved-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.saved-list .saved-name { flex: 1; min-width: 8em; font-weight: 600; }
.saved-list .saved-meta { color: var(--muted); font-size: 0.85rem; }

/* Planner layout */
.planner-grid { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .planner-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "input result" "saved result"; align-items: start; }
  .input-col { grid-area: input; }
  .saved-col { grid-area: saved; }
  .result-col { grid-area: result; position: sticky; top: 12px; }
}
.pair-grid { display: grid; gap: 12px; align-items: end; }
@media (min-width: 700px) { .pair-grid { grid-template-columns: 1fr auto 1fr; } }
.swap { justify-self: center; }

/* Reference pages */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; padding: 0; }
.facts div { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 12px; }
.facts dt { font-size: 0.76rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 3px 0 0; font-weight: 600; }
.answer { background: var(--card); border-left: 4px solid var(--accent); padding: 12px 16px; margin: 12px 0 16px; border-radius: 0 var(--radius) var(--radius) 0; font-size: 1.05rem; }
.mates { list-style: none; padding: 0; margin: 0; }
.mates li { padding: 7px 0; border-top: 1px solid var(--rule); }
.mates li:first-child { border-top: 0; }
.mates .why { display: block; font-size: 0.92rem; color: var(--muted); }
.mates-cols { columns: 2 220px; column-gap: 24px; list-style: none; padding: 0; margin: 0; }
.mates-cols li { break-inside: avoid; padding: 3px 0; }
.mate-head { display: flex; align-items: center; gap: 8px; }
.tag { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; border-radius: 3px; padding: 2px 7px; }
.tag-suitable { background: var(--ok-bg); color: var(--ok); }
.tag-risky { background: var(--risky-bg); color: var(--risky); }
.tag-not-suitable { background: var(--bad-bg); color: var(--bad); }

.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); background: var(--paper); }
tr:last-child td { border-bottom: 0; }
tr.shown td { font-weight: 600; background: var(--accent-soft); }

.index-group { margin-bottom: 8px; }
.species-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0 24px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.species-list li { padding: 8px 0; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 10px; }
.species-list .meta { color: var(--muted); font-size: 0.88rem; text-align: right; white-space: nowrap; }
.prose { max-width: 44em; }
.prose li { margin-bottom: 6px; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; margin-bottom: 14px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin: 16px 0; }
.card { display: block; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px; color: var(--ink); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card strong { display: block; font-family: var(--serif); font-size: 1.1rem; color: var(--accent); margin-bottom: 4px; }
.crumbs { font-size: 0.9rem; color: var(--muted); margin-top: 18px; }
.crumbs a { color: var(--muted); }
.def { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.def dt { font-weight: 600; }
.def dd { margin: 0; }

@media (max-width: 420px) {
  body { font-size: 16px; }
  h1 { font-size: 1.55rem; }
  .verdict-word { font-size: 1.5rem; }
  .water { grid-template-columns: 1fr; }
  .stock-row { flex-wrap: wrap; }
  .stock-name { flex-basis: 100%; }
  .reserved-ad, .reserved-gear { width: 100%; max-width: 300px; }
}
