/* Godclone: shared look. Dark, gritty Rust-style UI (sister site of the Rust Loot Simulator).
   Dark is the default; theme-init.js sets html[data-theme] to "dark" or "light" before first paint. */
:root {
  --bg: #0d0c0b;
  --glow: #2b211b;              /* warm glow at the top of the page */
  --glow-2: #151311;
  --panel: rgba(29, 27, 24, .95);
  --panel-solid: #1d1b18;       /* dialogs, menus: things that must not show the page through */
  --panel-2: rgba(255, 255, 255, .045);
  --head: rgba(255, 255, 255, .055);
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .17);
  --field: rgba(0, 0, 0, .35);
  --btn: rgba(255, 255, 255, .09);
  --btn-hover: rgba(255, 255, 255, .16);
  --topbar: rgba(9, 8, 7, .92);
  --foot: rgba(0, 0, 0, .35);
  --toast: rgba(18, 17, 15, .97);
  --tip-bg: rgba(22, 21, 18, .97);   /* tooltips stay dark in both themes, like the game's own */
  --tip-line: rgba(255, 255, 255, .17);
  --tip-text: #e3dccf;
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
  --text: #e3dccf;
  --muted: #a39b8d;
  --dim: #968e81;
  --accent: #cd412b;            /* Rust red-orange */
  --accent-2: #e8653d;          /* links, active marks */
  --on-accent: #fff;
  --green: #536f2b;             /* craft-button green (a shade darker than the loot sim so its text passes AA) */
  --green-hi: #5a772e;
  --on-green: #f1f8e4;
  --red: #a4372a;
  --good: #9cc451;
  --bad: #f7806a;
  --warn: #f0b43c;
  --info: #7fb2e5;
  --focus: #f5a742;             /* amber, so the ring still shows around red-orange buttons */
  --radius: 3px;
  --head-font: "Roboto Condensed", "Bahnschrift", "DIN Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  /* Genes look like Rust's own UI: one green for G/Y/H, one red for W/X, flat circles, light grey letters.
     In game: green #60891b and red #aa4734 at 78% over the dark #27241d panel, which gives these solid colours. */
  --gG: #53731c;
  --gY: #53731c;
  --gH: #53731c;
  --gW: #8d3f2f;
  --gX: #8d3f2f;
  --gene-text: #c8c8c8;
  --gX-text: #c8c8c8;
  --gene-edge: rgba(0, 0, 0, .35);
  --gene-link: rgba(200, 200, 200, .45);   /* the little dash that chains the circles */
  --gene-q: #3d3a35;
  color-scheme: dark;
}

/* Warm light theme: bleached concrete and parchment, same Rust accents, darker where text sits on them. */
:root[data-theme="light"] {
  --bg: #ddd5c6;
  --glow: #f7f1e5;
  --glow-2: #e9e2d4;
  --panel: rgba(250, 246, 238, .95);
  --panel-solid: #f8f4ec;
  --panel-2: rgba(70, 50, 30, .055);
  --head: rgba(70, 50, 30, .075);
  --line: rgba(70, 50, 30, .16);
  --line-strong: rgba(70, 50, 30, .32);
  --field: rgba(255, 255, 255, .75);
  --btn: rgba(70, 50, 30, .09);
  --btn-hover: rgba(70, 50, 30, .16);
  --topbar: rgba(240, 234, 222, .94);
  --foot: rgba(70, 50, 30, .07);
  --toast: rgba(35, 30, 24, .97);
  --shadow: 0 4px 16px rgba(60, 40, 20, .14);
  --shadow-lg: 0 16px 48px rgba(40, 25, 10, .32);
  --text: #221d17;
  --muted: #524a3e;
  --dim: #5f574a;
  --accent: #b5391f;
  --accent-2: #a3361c;
  --on-accent: #fff;
  --green: #4c6a25;
  --green-hi: #5a7a2d;
  --on-green: #fff;
  --red: #a4372a;
  --good: #325a0e;
  --bad: #8e2513;
  --warn: #6e4600;
  --info: #224e7a;
  --focus: #1f5fbf;             /* blue ring reads clearly on parchment and on every button colour */
  /* Same Rust colours, solid (no dark panel behind them to blend with), with brighter letters. */
  --gG: #60891b;
  --gY: #60891b;
  --gH: #60891b;
  --gW: #aa4734;
  --gX: #aa4734;
  --gene-text: #f2f2f2;
  --gX-text: #f2f2f2;
  --gene-edge: rgba(40, 25, 10, .4);
  --gene-link: rgba(60, 45, 30, .45);
  --gene-q: #cfc6b6;
  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  color: var(--text); overflow-wrap: break-word; overflow-x: clip;   /* clip, not hidden: keeps the sticky top bar working */
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: url(../img/noise.svg), radial-gradient(ellipse 120% 900px at 50% -10%, var(--glow) 0%, var(--glow-2) 45%, var(--bg) 80%) no-repeat;
  background-color: var(--bg);
}
main { flex: 1 0 auto; width: 100%; }
a { color: var(--accent-2); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.15; font-family: var(--head-font); font-stretch: 87.5%; letter-spacing: .02em; }
p { margin: 0 0 .75rem; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ---------- text helpers ---------- */
.head { font-family: var(--head-font); font-stretch: 87.5%; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.push { margin-left: auto; }   /* push the rest of a flex row (panel head tools) to the right */
.skip {
  position: absolute; left: 16px; top: -200px; z-index: 100; padding: .55rem .9rem; border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent); font-weight: 700; text-decoration: none; box-shadow: var(--shadow-lg);
}
.skip:focus, .skip:focus-visible { top: 8px; }

/* ---------- top bar ---------- */
/* Full-width bar whose contents line up with the 1480px page column. */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .5rem 1.2rem; flex-wrap: wrap;
  padding: .5rem max(16px, calc((100% - 1480px) / 2 + 16px));
  background: var(--topbar); border-bottom: 2px solid var(--accent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: .6rem; min-width: 0; color: inherit; text-decoration: none; }
.brand:hover .brand-name { color: var(--text); }
.logo { width: 40px; height: 40px; flex: none; display: block; }
.brand-text { display: grid; min-width: 0; line-height: 1.05; }
.brand-name {
  font-family: var(--head-font); font-stretch: 87.5%; font-weight: 700; font-size: 1.4rem;
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}
.brand-name b { color: var(--accent); font-weight: inherit; }
.badge {
  font-size: .64rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav { display: flex; align-items: stretch; gap: .15rem; flex: 1 1 auto; min-width: 0; }
.nav a {
  display: flex; align-items: center; padding: .5rem .75rem; min-height: 40px; border-radius: var(--radius);
  font-family: var(--head-font); font-stretch: 87.5%; font-weight: 700; font-size: .9rem;
  text-transform: uppercase; letter-spacing: .07em; white-space: nowrap;
  color: var(--muted); text-decoration: none; transition: background .12s, color .12s;
}
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -3px 0 var(--accent); background: var(--head); }
.nav a:focus-visible { outline-offset: -2px; }
.top-right { display: flex; align-items: center; gap: .4rem; margin-left: auto; flex: none; }

/* ---------- footer ---------- */
.site-foot {
  margin-top: 2rem; padding: .75rem max(16px, calc((100% - 1480px) / 2 + 16px));
  background: var(--foot); border-top: 1px solid var(--line);
  color: var(--muted); font-size: .78rem; text-align: center;
}
.site-foot p { margin: .15rem auto; max-width: 70rem; text-wrap: balance; }
.site-foot a { color: var(--accent-2); }
/* Sean's other tools (same markup and look on both loot sims). */
.more-tools { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .4rem; margin: .5rem auto .1rem; }
.more-tools-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; margin-right: .2rem; }
.more-tools .btn { color: var(--text); text-decoration: none; }
.more-tools .tool-soon { opacity: .75; cursor: default; filter: none; }
.more-tools .tool-soon:hover { background: transparent; border-color: var(--line-strong); }
.soon-tag { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: .02rem .3rem;
  border: 1px solid currentColor; border-radius: 3px; }

/* ---------- layout & panels ---------- */
.page { width: 100%; max-width: 1480px; margin: 0 auto; padding: 16px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.cols > * { min-width: 0; }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (min-width: 1000px) {
  .cols { grid-template-columns: minmax(340px, 5fr) minmax(0, 7fr); }
  .cols.cols-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.panel {
  --pad: .85rem;
  background: url(../img/noise.svg), var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--pad); min-width: 0; box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; gap: .5rem .75rem; flex-wrap: wrap; min-height: 44px;
  margin: calc(var(--pad) * -1) calc(var(--pad) * -1) var(--pad); padding: .45rem var(--pad);
  background: var(--head); border-bottom: 1px solid var(--line);
  font-family: var(--head-font); font-stretch: 87.5%; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
}
.panel-head > :is(h1, h2, h3, h4, .title) { margin: 0; font-size: 1rem; letter-spacing: .07em; }
/* the little red-orange tick before a panel title, as in the loot sim's windows */
.panel-head > :is(h1, h2, h3, h4, .title):first-child::before {
  content: ""; display: inline-block; width: 3px; height: .9em; margin-right: .55rem; vertical-align: -.08em; background: var(--accent);
}
.panel-head .muted { font-weight: 400; letter-spacing: .04em; font-size: .8rem; }
.panel-body { min-width: 0; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 36px; padding: .5rem .9rem; border: 1px solid transparent; border-radius: var(--radius);
  font-family: var(--head-font); font-stretch: 87.5%; font-weight: 700; font-size: .9rem; line-height: 1.1;
  text-transform: uppercase; letter-spacing: .06em; text-decoration: none; white-space: nowrap;
  background: var(--btn); color: var(--text); cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .05s;
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: translateY(1px); }
.btn svg, .icon-btn svg { width: 1.15em; height: 1.15em; flex: none; }
/* the big green craft button (CALCULATE) */
.btn-primary {
  min-height: 46px; padding: .7rem 1.5rem; font-size: 1.1rem; letter-spacing: .08em;
  background: var(--green); color: var(--on-green);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), inset 0 -3px 0 rgba(0, 0, 0, .25);
}
.btn-primary:hover { background: var(--green-hi); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 84%, #000); }
.btn-danger { background: color-mix(in srgb, var(--red) 30%, transparent); color: var(--bad); border-color: color-mix(in srgb, var(--red) 55%, transparent); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--panel-2); border-color: var(--muted); }
.btn-sm { min-height: 30px; padding: .3rem .6rem; font-size: .78rem; gap: .35rem; }
.icon-btn {
  appearance: none; display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--btn); color: var(--text); cursor: pointer; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--btn-hover); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }
.btn[disabled], .btn[aria-disabled="true"], .icon-btn[disabled], .seg button[disabled], .tabs [role="tab"][disabled] {
  opacity: .45; cursor: not-allowed; transform: none; filter: saturate(.4);
}
.btn[disabled]:hover, .icon-btn[disabled]:hover { background: var(--btn); }
.btn-primary[disabled]:hover { background: var(--green); }
.btn-accent[disabled]:hover { background: var(--accent); }
.btn-ghost[disabled]:hover { background: transparent; border-color: var(--line-strong); }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

/* ---------- forms ---------- */
.field { display: grid; gap: .3rem; min-width: 0; }
.field > label, .field > .label, .field > legend {
  padding: 0; font-family: var(--head-font); font-stretch: 87.5%; font-weight: 700; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.field .hint { font-size: .8rem; color: var(--muted); }
fieldset.field { margin: 0; padding: 0; border: 0; }
.input, .select, .textarea {
  display: block; width: 100%; min-height: 38px; padding: .45rem .6rem; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background-color: var(--field); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus);
}
.input::placeholder, .textarea::placeholder { color: var(--dim); opacity: 1; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); }
.input[type="number"] { font-variant-numeric: tabular-nums; }
.textarea { min-height: 8rem; resize: vertical; line-height: 1.5; }
/* native select, own chevron drawn with two gradients (no image, follows the theme) */
.select {
  appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select option, .select optgroup { background: var(--panel-solid); color: var(--text); }
.input[disabled], .select[disabled], .textarea[disabled] { opacity: .55; cursor: not-allowed; }
.check { display: inline-flex; align-items: center; gap: .5rem; min-height: 32px; cursor: pointer; color: var(--text); }
.check input { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--green-hi); cursor: pointer; }
.check.muted { color: var(--muted); }
.range-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .4rem .7rem; min-width: 0; }
.range-row input[type="range"] { width: 100%; min-width: 0; margin: 0; height: 28px; accent-color: var(--accent); cursor: pointer; }
.range-row output, .range-row .val {
  min-width: 3ch; text-align: right; font: 700 .95rem/1 var(--head-font); font-stretch: 87.5%; font-variant-numeric: tabular-nums;
}
/* segmented control: .seg > button[aria-pressed] */
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--field); }
.seg > button {
  appearance: none; position: relative; margin: 0; padding: .4rem .75rem; min-height: 34px; border: 0; background: transparent;
  color: var(--muted); font-family: var(--head-font); font-stretch: 87.5%; font-weight: 700; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .05em; cursor: pointer; transition: background .12s, color .12s;
}
.seg > button + button { box-shadow: inset 1px 0 0 var(--line); }
.seg > button:hover { color: var(--text); background: var(--btn); }
.seg > button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.seg > button:focus-visible { z-index: 1; }
.seg > button:first-child { border-radius: 2px 0 0 2px; }
.seg > button:last-child { border-radius: 0 2px 2px 0; }

/* ---------- gene chips ---------- */
/* .genes.genes-md > .gene.g-G ... Size comes from --chip (set by the container, md by default).
   Drawn like the game: flat circles, green for G/Y/H and red for W/X, with a short dash chaining each circle to the
   next. The letter is the only thing telling G, Y and H apart, exactly as in Rust. */
.genes { display: inline-flex; flex-wrap: nowrap; align-items: center; gap: var(--gap); vertical-align: middle; --chip: 24px; --gap: 5px; }
.genes-sm { --chip: 18px; --gap: 4px; }
.genes-md { --chip: 24px; --gap: 5px; }
.genes-lg { --chip: 34px; --gap: 7px; }
.gene {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--chip, 24px); height: var(--chip, 24px); border-radius: 50%;
  font-family: var(--head-font); font-stretch: 87.5%; font-weight: 700; font-size: calc(var(--chip, 24px) * .6); line-height: 1;
  text-transform: uppercase; font-variant-numeric: tabular-nums;
  color: var(--gene-text); background: var(--gene-q);
  text-shadow: 1px 1px 0 rgba(44, 39, 35, .35);
}
.gene + .gene::before {
  content: ""; position: absolute; top: 50%; right: 100%; width: var(--gap, 5px); height: max(1px, calc(var(--chip, 24px) * .07));
  transform: translateY(-50%); background: var(--gene-link); pointer-events: none;
}
.g-G { background: var(--gG); }
.g-Y { background: var(--gY); }
.g-H { background: var(--gH); }
.g-W { background: var(--gW); }
.g-X { background: var(--gX); color: var(--gX-text); }
/* faded: a slot that doesn't matter here (kept center gene, not the target...) */
.gene.dim { opacity: .38; filter: saturate(.55); }
/* unknown gene */
.gene.q { background: var(--gene-q); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); text-shadow: none; }
/* ---------- official item icons + plant pictures ---------- */
.item-ic { display: inline-block; object-fit: contain; vertical-align: middle; user-select: none; -webkit-user-drag: none; }
.item-ic.is-broken { visibility: hidden; }
/* Clone sprite with the harvest item tucked into the bottom-right corner on a small dark disc. */
.plant-ic { position: relative; display: inline-grid; place-items: center; flex: none; width: var(--pi, 32px); height: var(--pi, 32px); vertical-align: middle; }
.plant-ic > .item-ic { width: 100%; height: 100%; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5)); }

@media (forced-colors: active) {
  .gene { border: 1px solid CanvasText; }
}

/* ---------- tags & keys ---------- */
.tag {
  display: inline-flex; align-items: center; gap: .3em; padding: .14rem .5rem; border-radius: 999px; white-space: nowrap;
  font-family: var(--head-font); font-stretch: 87.5%; font-weight: 700; font-size: .72rem; line-height: 1.25;
  text-transform: uppercase; letter-spacing: .06em; vertical-align: middle;
  color: var(--muted); background: var(--panel-2); border: 1px solid var(--line);
}
.tag-good { color: var(--good); background: color-mix(in srgb, var(--good) 13%, transparent); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.tag-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.tag-bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 13%, transparent); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.tag-info { color: var(--info); background: color-mix(in srgb, var(--info) 13%, transparent); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.kbd {
  display: inline-block; min-width: 1.6em; padding: .1em .4em; border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 3px; background: var(--panel-2); color: var(--text); text-align: center;
  font: 600 .8em/1.3 var(--mono); white-space: nowrap;
}

/* ---------- dialogs: <dialog class="dlg"> > .dlg-head / .dlg-body / .dlg-foot ---------- */
.dlg {
  width: min(560px, calc(100vw - 32px)); max-width: none; max-height: min(88vh, calc(100dvh - 32px));
  padding: 0; border: 1px solid var(--line-strong); border-top: 2px solid var(--accent); border-radius: var(--radius);
  background: url(../img/noise.svg), var(--panel-solid); color: var(--text); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dlg[open] { display: flex; flex-direction: column; animation: dlg-in .16s ease-out; }
.dlg.dlg-wide { width: min(860px, calc(100vw - 32px)); }
/* ::backdrop doesn't reliably inherit custom properties, so plain colours here */
.dlg::backdrop { background: rgba(0, 0, 0, .62); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.dlg-head {
  display: flex; align-items: center; gap: .6rem; flex: none; padding: .55rem .6rem .55rem 1rem;
  background: var(--head); border-bottom: 1px solid var(--line);
}
.dlg-head > :is(h1, h2, h3, .title) {
  flex: 1 1 auto; margin: 0; min-width: 0; font-family: var(--head-font); font-stretch: 87.5%; font-weight: 700;
  font-size: 1.1rem; text-transform: uppercase; letter-spacing: .05em;
}
.dlg-head > :is(h1, h2, h3, .title):focus { outline: none; }
.dlg-head .icon-btn { margin-left: auto; }
.dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem; overscroll-behavior: contain; }
.dlg-body > :last-child { margin-bottom: 0; }
.dlg-foot {
  display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .5rem; flex: none;
  padding: .7rem 1rem; border-top: 1px solid var(--line); background: var(--panel-2);
}
.dlg-foot .push { margin-right: auto; margin-left: 0; }   /* e.g. Reset on the left, Cancel/Save on the right */

/* ---------- tabs: .tabs[role=tablist] > button[role=tab][aria-selected] + .tabpanel ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line-strong); margin-bottom: .9rem; }
.tabs > button, .tabs > [role="tab"] {
  appearance: none; margin: 0 0 -1px; padding: .55rem .9rem; min-height: 40px; border: 0; border-radius: var(--radius) var(--radius) 0 0;
  background: transparent; color: var(--muted); cursor: pointer;
  font-family: var(--head-font); font-stretch: 87.5%; font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .07em;
  transition: background .12s, color .12s;
}
.tabs > button:hover, .tabs > [role="tab"]:hover { color: var(--text); background: var(--panel-2); }
.tabs > [aria-selected="true"] { color: var(--text); background: var(--head); box-shadow: inset 0 -3px 0 var(--accent); }
.tabs > :focus-visible { outline-offset: -2px; }
.tabpanel { min-width: 0; }
.tabpanel:focus-visible { outline-offset: 4px; }

/* ---------- toasts ---------- */
.toast-host {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 60; transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: .5rem;
  width: max-content; max-width: calc(100vw - 32px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; pointer-events: auto;
  max-width: min(100%, 460px); padding: .6rem .8rem .6rem .95rem; border-left: 3px solid var(--good); border-radius: var(--radius);
  background: var(--toast); color: #eee8dc; font-size: .9rem; box-shadow: var(--shadow-lg);
  animation: toast-in .22s ease-out;
}
.toast.bad, .toast.error { border-left-color: #ee6a53; }
.toast.warn { border-left-color: #f0b43c; }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast button {
  appearance: none; margin-left: auto; padding: .3rem .55rem; min-height: 30px; border: 1px solid rgba(255, 255, 255, .22); border-radius: var(--radius);
  background: transparent; color: #f4a07e; cursor: pointer;
  font-family: var(--head-font); font-stretch: 87.5%; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
}
.toast button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.toast button:focus-visible { outline-color: #f5a742; }

/* ---------- empty states ---------- */
.empty {
  display: grid; justify-items: center; gap: .5rem; padding: 1.6rem 1rem; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--panel-2); color: var(--muted);
}
.empty > :is(h2, h3, h4, .head) { margin: 0; color: var(--text); font-size: 1rem; }
.empty p { margin: 0; max-width: 34rem; }
.empty .btn-row { justify-content: center; margin-top: .3rem; }
.empty svg { width: 40px; height: 40px; color: var(--dim); }

/* ---------- progress bar: .progress > span, width from --p (set on either element) ---------- */
.progress {
  position: relative; height: 10px; overflow: hidden; border-radius: var(--radius);
  background: var(--field); box-shadow: inset 0 0 0 1px var(--line-strong);
}
.progress > span {
  display: block; height: 100%; width: var(--p, 0%); max-width: 100%;
  background-image: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .12) 0 8px, transparent 8px 16px), linear-gradient(to bottom, var(--green-hi), var(--green));
  background-size: 22.6px 22.6px, auto;
  transition: width .25s ease-out;
  animation: progress-move .9s linear infinite;
}
.progress.done > span, .progress.idle > span { animation: none; }

/* ---------- tooltips (ui.js tip(el, text)) ----------
   A small dark panel above the element after a short hover delay, or at once on keyboard focus. Below instead with
   data-tip-pos="below", or when ui.js finds no room above (data-tip-flip); ui.js also sets --tip-dx so the panel
   stays on screen. */
:where([data-tip]) { position: relative; }   /* zero specificity: a component's own position rule still wins */
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; z-index: 80; left: 50%; bottom: calc(100% + 7px);
  width: max-content; max-width: min(260px, calc(100vw - 16px));
  padding: .36rem .55rem .4rem;
  border: 1px solid var(--tip-line); border-radius: var(--radius);
  background: var(--tip-bg); color: var(--tip-text); box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
  font: 500 .8rem/1.35 var(--head-font); font-stretch: 87.5%; letter-spacing: .015em;
  text-align: left; text-transform: none; text-shadow: none; white-space: normal; overflow-wrap: break-word;
  pointer-events: none; opacity: 0; visibility: hidden;
  transform: translate(calc(-50% + var(--tip-dx, 0px)), 3px);
  /* hidden, the panel folds to a point at its anchor (scale: 0, switched, never animated, so the text stays sharp);
     otherwise a hidden panel near the side of a scrolling box (the clone panel on wide screens) adds a sideways scrollbar */
  scale: 0; transform-origin: 0 100%;
  transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s, scale 0s linear .12s;
}
[data-tip-pos="below"]::after, [data-tip-flip]::after {
  bottom: auto; top: calc(100% + 7px); transform: translate(calc(-50% + var(--tip-dx, 0px)), -3px); transform-origin: 0 0;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  opacity: 1; visibility: visible; transform: translate(calc(-50% + var(--tip-dx, 0px)), 0); scale: 1;
  transition: opacity .14s ease .45s, transform .14s ease .45s, visibility 0s linear .45s, scale 0s linear .45s;
}
[data-tip]:focus-visible::after { transition-delay: .1s; }
/* an inner tip (a mark inside a tipped plant) wins over its container's */
[data-tip]:has([data-tip]:hover)::after { opacity: 0; visibility: hidden; scale: 0; transition: none; }
/* reduced motion: no slide, but keep the hover delay so tips don't flash while the mouse passes over */
@media (prefers-reduced-motion: reduce) {
  [data-tip]::after { transform: translate(calc(-50% + var(--tip-dx, 0px)), 0) !important; }
  [data-tip]:hover::after { transition: visibility 0s .45s, opacity 0s .45s !important; }
}
:root[data-motion="reduce"] [data-tip]::after { transform: translate(calc(-50% + var(--tip-dx, 0px)), 0) !important; }
:root[data-motion="reduce"] [data-tip]:hover::after { transition: visibility 0s .45s, opacity 0s .45s !important; }

/* ---------- motion ---------- */
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes progress-move { to { background-position: 22.6px 0, 0 0; } }
/* OS setting, or the Options "reduce motion" switch (ui.js sets html[data-motion="reduce"]) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}

/* ---------- small screens ---------- */
/* Tablets and phones: the nav drops to its own full-width row and scrolls sideways if it has to
   (the only thing on the page allowed to scroll horizontally). */
@media (max-width: 820px) {
  .topbar { padding-block: .45rem 0; row-gap: .3rem; }
  .brand { flex: 1 1 auto; }
  .nav {
    order: 3; flex: 1 0 100%; gap: 0; margin-inline: -16px; padding-inline: 12px;
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: none; min-height: 42px; padding: .45rem .7rem; border-radius: 0; font-size: .85rem; }
  .nav a[aria-current="page"] { background: transparent; }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .brand-name { font-size: 1.15rem; }
  .logo { width: 32px; height: 32px; }
  .badge { font-size: .58rem; letter-spacing: .08em; }
  .top-right { gap: .3rem; }
  .panel { --pad: .7rem; }
  .btn-primary { padding-inline: 1.1rem; }
  .dlg { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .dlg-body { padding: .85rem; }
  .dlg-foot { padding: .6rem .85rem; }
  .toast-host { left: 16px; right: 16px; width: auto; max-width: none; transform: none; }
  .toast { max-width: 100%; }
  .site-foot { font-size: .74rem; }
}
/* Narrow phones: the top row has no room for the tagline; the footer still says what the site is. */
@media (max-width: 440px) {
  .badge { display: none; }
  .brand { gap: .45rem; }
  .icon-btn { width: 34px; height: 34px; }
  .top-right .btn-sm { padding-inline: .5rem; }
  /* all four tabs, "Clone guide" last, fit a 360px phone without scrolling (about 335 of its 348px) */
  .nav { padding-inline: 6px; }
  .nav a { padding-inline: .45rem; letter-spacing: .04em; }
}

@media print {
  body { background: #fff; color: #000; }
  .topbar, .site-foot, .skip, .toast-host, .btn, .icon-btn { display: none !important; }
  .panel { box-shadow: none; background: #fff; border-color: #999; }
  .gene { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
