/* Farmer Joe. A brand printed on a seed sack.
 * Green and white with red highlights: sack green is the ground of every
 * screen, white tag stock carries the panels, the tags and the map, and tag red
 * is the pin, the stamps and the warnings. Green and red also print Yes and No. */

:root {
  --green-800: #114a2c;
  --green-700: #17603a;   /* the sack */
  --green-600: #1f7446;
  --green-500: #3d8a5f;   /* rules on green */
  --green-300: #5a9c76;   /* chart: without protection */
  --wash: #e8f3eb;        /* pale green: the row being answered, hovers */
  --red: #c6321d;
  --red-deep: #a32715;

  --on-green: #ffffff;
  --on-green-2: #d3e6d8;
  --on-green-3: #b6d6c0;

  --tag: #fbfcf9;
  --tag-2: #eef3ee;
  --rule: #d5ddd6;
  --rule-strong: #9fb0a5;
  --ink: #0d3320;
  --ink-2: #3c5547;
  --ink-3: #5b7164;

  --yes-tint: #dcebdf;
  --no-tint: #f8dfd9;
  --no-ink: #8a2112;

  --display: "Big Shoulders", "Arial Narrow", sans-serif;
  --text: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --pad: 28px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--green-700);
  color: var(--on-green);
  font-family: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--green-500) var(--green-700);
}

::selection { background: var(--red); color: #ffffff; }

h1, h2, p, ul, ol, dl, dd, figure, fieldset { margin: 0; }
ul, ol { padding: 0; list-style: none; }
fieldset { padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible { outline: 2px solid var(--on-green); outline-offset: 2px; }
.tag :focus-visible, .ticket :focus-visible, .sack-panel :focus-visible { outline-color: var(--ink); }
h1:focus { outline: none; }

/* ---------- screens ---------- */

.screen { min-height: 100dvh; }
.screen.is-entering { animation: screen-in 240ms var(--ease-out); }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(18px); }
}

/* ---------- 1. intro: the front of the sack ---------- */

.screen-intro {
  display: grid;
  grid-template-columns: minmax(0, 62fr) minmax(0, 38fr);
}

.sack-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 48px;   /* stepped in the media queries below, not fluid */
  background: var(--tag);
  color: var(--ink);
  container-type: inline-size;
}

.brand {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(72px, min(17.5vw, 38vh), 360px);
  font-size: clamp(72px, min(31cqi, 38vh), 360px);
  line-height: 0.82;
  letter-spacing: -0.005em;
  text-transform: uppercase;
  margin-top: -0.06em;
  color: var(--green-700);
}
.brand span { display: block; }

.promise {
  max-width: 34ch;   /* wide enough to keep the capitals on one line on desktop */
  font-size: clamp(20px, 2.1vw, 30px);
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-wrap: balance;
}

.sack-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  padding: 48px;
}

.how { display: grid; gap: 22px; counter-reset: how; }
.how li {
  counter-increment: how;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: baseline;
  font-size: clamp(17px, 1.5vw, 21px);
  line-height: 1.35;
  max-width: 26ch;
}
.how li::before {
  content: counter(how);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.9em;
  line-height: 0.9;
  color: var(--on-green);
}

.start-wrap { display: grid; gap: 22px; }

/* The Start button is the sack's tag: white, with a plain black arrow. */
.start-tag {
  display: block;
  color: var(--ink);
  text-decoration: none;
  transition: transform 140ms var(--ease-out);
}
/* The cut shape sits on an inner face, so the link's focus ring is not clipped away. */
.start-face {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 132px;
  padding: 18px 30px 18px 26px;
  background: var(--tag);
  clip-path: polygon(26px 0, 100% 0, 100% 100%, 26px 100%, 0 calc(100% - 26px), 0 26px);
  transition: background-color 160ms ease;
}
.start-tag .eyelet { position: static; flex: none; width: 20px; height: 20px; box-shadow: 0 0 0 5px var(--rule); }
.start-word {
  flex: 1;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(64px, 6.4vw, 96px);
  line-height: 0.9;
  text-transform: uppercase;
}
.start-tag .icon { width: 52px; height: 52px; color: #000000; stroke-width: 2.25; transition: transform 180ms var(--ease-out); }
.start-tag:active { transform: scale(0.98); }
.start-tag:focus-visible { outline: 3px solid var(--on-green); outline-offset: 4px; }
/* The colour change is plain :hover so it never depends on how a browser
 * reports its pointer; only the arrow's nudge is kept to real pointers. */
.start-tag:hover .start-face { background: var(--wash); }
@media (hover: hover) and (pointer: fine) {
  .start-tag:hover .icon { transform: translateX(8px); }
}

.eyelet {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green-700);
  box-shadow: 0 0 0 4px var(--rule);
}

.fine { color: var(--on-green-2); font-size: 13px; max-width: 60ch; }

/* ---------- the bar on screens 2 and 3 ---------- */

.bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 28px;
  padding: 14px var(--pad) 10px;
}

.wordmark {
  font-family: var(--display);
  font-weight: 900;
  font-size: 30px;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
}

.steps { display: flex; gap: 6px; counter-reset: step; font-size: 14px; }
.steps li { counter-increment: step; }
.steps a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 3px;
  color: var(--on-green-2);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}
.steps a::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.steps a:hover { color: var(--on-green); background: var(--green-600); }
.steps a[aria-current="step"] { background: var(--tag); color: var(--ink); }
.steps a[aria-disabled="true"] { color: var(--on-green-3); pointer-events: none; }

.sample-note {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--on-green-2);
  font-size: 13px;
}
.sample-note .icon { width: 16px; height: 16px; }

h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(40px, 4.4vw, 60px);
  line-height: 1.06;
  text-transform: uppercase;
  text-wrap: balance;
}
h2 { font-size: 16px; font-weight: 700; }

/* ---------- tags ---------- */

.tag {
  position: relative;
  background: var(--tag);
  color: var(--ink);
  border-radius: 3px;
}
.tag > .eyelet { top: 12px; left: 50%; margin-left: -7px; }

.tag-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.tag-head h2 { margin-right: auto; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: -4px 0 8px; color: var(--ink-2); font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 7px; }
.sw-base { width: 16px; height: 3px; border-radius: 1px; background: var(--green-300); }
.sw-plan { width: 16px; height: 3px; border-radius: 1px; background: var(--ink); }

.stamped {
  display: inline-block;
  padding: 1px 9px 2px;
  border: 2px solid var(--red);
  border-radius: 2px;
  color: var(--red);
  font-family: var(--display);
  font-weight: 800;
  font-size: 21px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transform: rotate(-2deg);
}
.stamp-small { font-size: 15px; border-width: 1.5px; }
.stamp-on-green { background: var(--tag); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1.5px solid transparent;
  border-radius: 3px;
  background: none;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 120ms var(--ease-out);
}
.btn:active { transform: scale(0.97); }

.btn-quiet { border-color: var(--rule-strong); color: var(--ink); }
.btn-quiet:hover { background: var(--tag-2); border-color: var(--ink-3); }
.btn-quiet[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--tag); }

.btn-primary { min-height: 48px; padding: 0 20px; background: var(--green-700); color: #ffffff; font-size: 16px; }
.btn-primary:hover { background: var(--green-800); }
.btn-primary:disabled { background: var(--tag-2); color: var(--ink-3); border-color: var(--rule); cursor: not-allowed; transform: none; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { text-decoration-thickness: 2px; }

/* ---------- 2. the farm form ---------- */

.farm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(400px, 1fr);
  gap: 32px;
  align-items: start;
  padding: 10px var(--pad) 32px;
}

@media (min-width: 901px) {
  .map-side { position: sticky; top: 16px; }
}

.map-hint { margin-top: 8px; color: var(--on-green-2); font-size: 16px; }

.map {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 6px;
  overflow: visible;
}
.state {
  fill: var(--tag);
  stroke: var(--green-700);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  cursor: crosshair;
}
@media (hover: hover) and (pointer: fine) {
  .state:hover { fill: var(--wash); }
}
.station { fill: var(--ink); pointer-events: none; }
.station.is-nearest { stroke: #ffffff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.station-link { stroke: var(--ink); stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
/* Every station city is named. The nearest one to the farm is set heavier. */
.city-label { pointer-events: none; }
.city-label text {
  fill: var(--ink);
  font-family: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--tag);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.city-label.is-nearest text { font-size: 13.5px; font-weight: 800; }
.pin-anchor { pointer-events: none; }
.pin-body { fill: var(--red); stroke: #ffffff; stroke-width: 1.5; }
.pin-eye { fill: #ffffff; }
.pin-ring {
  fill: none;
  stroke: var(--red);
  stroke-width: 2;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

.map-key { display: flex; align-items: center; gap: 9px; margin-top: 4px; color: var(--on-green-2); font-size: 13px; }
.station-list { margin-top: 6px; color: var(--on-green-2); font-size: 13px; max-width: 70ch; }
.station-list summary { width: fit-content; cursor: pointer; color: var(--on-green); font-weight: 650; }
.station-list p { margin-top: 6px; line-height: 1.6; }
.key-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--tag); }

.farm-tag {
  padding: 40px 22px 22px;
  clip-path: polygon(18px 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%, 0 18px);
}

/* One ruled row per question. The row being answered takes a pale green wash
 * and heavier rules, so the state does not rest on a faint tint alone. */
.row {
  display: grid;
  grid-template-columns: minmax(120px, 0.78fr) minmax(0, 1.22fr);
  align-items: center;
  gap: 6px 16px;
  margin: 0 -22px;
  padding: 10px 22px;
  border-top: 1px solid var(--rule);
  transition: background-color 150ms ease;
}
.row-where { border-top: 2px solid var(--ink); }
.row:focus-within { background: var(--wash); box-shadow: inset 0 2px 0 var(--green-700), inset 0 -2px 0 var(--green-700); }
.row > label, .row > legend { font-size: 14.5px; font-weight: 650; line-height: 1.35; }
/* A legend cannot be a grid item, so fieldset rows place it by float. */
fieldset.row { display: block; }
fieldset.row::after { content: ""; display: block; clear: both; }
fieldset.row > legend { float: left; width: 39%; padding: 9px 16px 0 0; }
fieldset.row > .control { margin-left: 39%; }

.control { min-width: 0; }
.pair { display: grid; grid-template-columns: minmax(118px, 0.9fr) minmax(0, 1fr); align-items: center; gap: 12px; }

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 10px;
  border: 1.5px solid var(--rule-strong);
  border-radius: 3px;
  background: #ffffff;
  transition: border-color 150ms ease;
}
.field:focus-within { border-color: var(--ink); outline: 2px solid var(--ink); outline-offset: 1px; }
.field input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 28px;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  font-size: 15.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  caret-color: var(--green-700);
  appearance: textfield;
  -moz-appearance: textfield;
}
.field input::-webkit-outer-spin-button, .field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.unit { flex: none; color: var(--ink-3); font-size: 13.5px; white-space: nowrap; }
.unit-lead { color: var(--ink); font-weight: 600; font-size: 15.5px; }

#where {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1.5px solid var(--rule-strong);
  border-radius: 3px;
  background: #ffffff;
  font-size: 15.5px;
  font-weight: 600;
  caret-color: var(--green-700);
}
#where::placeholder { color: var(--ink-3); font-weight: 400; opacity: 1; }
#where:focus-visible { border-color: var(--ink); outline: 2px solid var(--ink); outline-offset: 1px; }
[aria-invalid="true"], .field:has([aria-invalid="true"]) { border-color: var(--red); }

.where-out, .row > .note, .row > .error { grid-column: 2; }
.where-out { color: var(--ink-2); font-size: 13.5px; }
.where-station { color: var(--ink-2); font-size: 13.5px; }
.note { color: var(--ink-2); font-size: 13.5px; }
.error { display: flex; gap: 6px; color: var(--red-deep); font-size: 13.5px; font-weight: 600; }
.error .icon { width: 16px; height: 16px; margin-top: 1px; }

/* Crop: one of three. */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; border: 1.5px solid var(--ink); border-radius: 3px; background: #ffffff; }
.seg label { position: relative; display: block; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span {
  display: grid;
  place-items: center;
  min-height: 32px;
  padding: 0 8px;
  border-radius: 2px;
  font-size: 14.5px;
  font-weight: 650;
  transition: background-color 150ms ease, color 150ms ease;
}
.seg input:hover + span { background: var(--tag-2); }
.seg input:checked + span { background: var(--ink); color: #ffffff; }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 1px; }
.seg input:checked:focus-visible + span { outline-color: #ffffff; outline-offset: -4px; }

/* Sliders */
input[type="range"] {
  --fill: 0%;
  display: block;
  width: 100%;
  height: 24px;
  margin: 0;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--green-700) var(--fill), var(--rule-strong) var(--fill));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--rule-strong); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--green-700); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: var(--ink);
  box-shadow: 0 1px 4px rgba(13, 51, 32, 0.45);
  transition: transform 120ms var(--ease-out);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: var(--ink);
  box-shadow: 0 1px 4px rgba(13, 51, 32, 0.45);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }
input[type="range"]:focus-visible::-moz-range-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }
input[type="range"]:disabled { cursor: not-allowed; opacity: 0.45; }

.lean { display: grid; gap: 2px; }
.lean-ends { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 12.5px; }
.lean output { font-size: 15.5px; font-weight: 700; }

.tag-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 20px;
  margin: 0 -22px;
  padding: 16px 22px 0;
  border-top: 2px solid var(--ink);
}
.crop-value { display: grid; gap: 2px; color: var(--ink-2); font-size: 13.5px; }
.crop-value strong {
  color: var(--ink);
  font-family: var(--display);
  font-weight: 800;
  font-size: 40px;
  line-height: 0.95;
}

/* ---------- 3. the advice ---------- */

/* Four blocks set as one rectangle: the advice and the hedges heading share a
 * top and a bottom, and the chart and the hedges column share a top and a
 * bottom. Every block starts on its column's left edge. */
.plan-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(400px, 1fr);
  grid-template-areas: "head sidetop" "chart side";
  gap: 16px 28px;
  align-items: stretch;
  padding: 10px var(--pad) 20px;
}
.plan-head { grid-area: head; min-width: 0; }
.side-top {
  grid-area: sidetop;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding-top: 9px;   /* the small line starts level with the title's capitals */
}
.chart-tag { grid-area: chart; display: flex; flex-direction: column; min-width: 0; }
.plan-side { grid-area: side; display: flex; flex-direction: column; min-width: 0; }

.lede { margin-top: 12px; max-width: 62ch; color: var(--on-green); font-size: 18px; line-height: 1.4; }
.plan-effect { margin-top: 6px; max-width: 62ch; color: var(--on-green); font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.farm-line { color: var(--on-green-2); font-size: 14px; }
.farm-line a { color: var(--on-green); font-weight: 650; text-underline-offset: 3px; }

.chart-tag, .order-tag { padding: 16px 20px 18px; }

.plot { position: relative; flex: 1 1 300px; min-height: 300px; outline-offset: 3px; }
.plot svg { display: block; position: absolute; inset: 0; }

.rule-h { stroke: var(--rule); stroke-width: 1; }
.baseline { stroke: var(--ink); stroke-width: 1; }
.axis text { fill: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.axis .axis-title { fill: var(--ink-2); font-size: 12.5px; font-weight: 600; }
/* Two lines by harvest: the farm without a hedge in light green, the farm
 * with the plan in ink, heavier and drawn on top. */
.floor { stroke-width: 1; pointer-events: none; }
.floor-base { stroke: var(--green-300); }
.floor-plan { stroke: var(--ink); }
.floor-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--tag);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
}
.line { fill: none; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.line-base { stroke: var(--green-300); stroke-width: 2; }
.line-plan { stroke: var(--ink); stroke-width: 2.5; }
.line-under { stroke: var(--tag); stroke-width: 6; }
.dots circle { stroke: var(--tag); stroke-width: 2; pointer-events: none; transition: r 120ms var(--ease-out); }
.dots-base circle { fill: var(--green-300); }
.dots-plan circle { fill: var(--ink); }
.dots circle.is-hover { r: 5.5px; }
.cross { stroke: var(--ink-2); stroke-width: 1; pointer-events: none; }

.tip {
  position: absolute;
  z-index: 2;
  min-width: 180px;
  padding: 8px 11px 9px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: var(--tag);
  color: var(--ink);
  font-size: 12.5px;
  box-shadow: 0 8px 18px rgba(9, 36, 22, 0.28);
  pointer-events: none;
}
.tip-title { color: var(--ink-2); font-variant-numeric: tabular-nums; margin-bottom: 3px; }
.tip-row { display: flex; align-items: center; gap: 7px; color: var(--ink-2); white-space: nowrap; }
.tip-row strong { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.tip-key { width: 12px; height: 3px; flex: none; border-radius: 1px; }
.tip-key-base { background: var(--green-300); }
.tip-key-plan { background: var(--ink); }

.bins { flex: 1 1 300px; min-height: 300px; max-height: 520px; overflow: auto; border: 1px solid var(--rule); border-radius: 3px; scrollbar-color: var(--rule-strong) transparent; }
.bins table { width: 100%; }
.bins thead th { position: sticky; top: 0; background: var(--tag-2); }

table { border-collapse: collapse; font-size: 14px; }
th, td { padding: 7px 12px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child { text-align: left; }
thead th { color: var(--ink-3); font-size: 12.5px; font-weight: 600; }
tbody th { font-weight: 500; color: var(--ink-2); }
tbody td { font-weight: 650; }
tbody tr { border-top: 1px solid var(--rule); }

.ruled { width: 100%; margin-top: 10px; }
.ruled th:first-child, .ruled td:first-child { padding-left: 0; }
.ruled th:last-child, .ruled td:last-child { padding-right: 0; }
.ruled tbody tr:first-child { border-top: 2px solid var(--ink); }

.price-yes, .price-no { display: inline-block; min-width: 52px; padding: 2px 8px; border-radius: 3px; text-align: center; font-weight: 700; }
.price-yes { background: var(--yes-tint); color: var(--ink); }
.price-no { background: var(--no-tint); color: var(--no-ink); }

/* Hedges */
.side-head { display: flex; align-items: baseline; gap: 12px; }
.side-head h2 { font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1; text-transform: uppercase; }
.plan-state { margin-left: auto; color: var(--on-green-2); font-size: 13.5px; text-align: right; }
.plan-result { display: none; }
.plan-state .link { color: var(--on-green); }

.side-hint { margin-top: 6px; color: var(--on-green-2); font-size: 14px; }

.tickets { display: grid; gap: 12px; }

.ticket {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  background: var(--tag);
  color: var(--ink);
  border-radius: 3px;
  overflow: hidden;
}

/* The pick box is the whole left edge of the ticket: deep green when it is in the plan. */
.pick { position: relative; display: block; border-right: 1px solid var(--rule); background: var(--tag-2); transition: background-color 150ms ease; }
.pick input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.pick .box {
  position: absolute;
  top: 16px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: #ffffff;
  transition: background-color 150ms ease;
}
.pick .box .icon { width: 18px; height: 18px; stroke-width: 2.75; opacity: 0; color: var(--green-700); transition: opacity 120ms ease; }
.pick input:checked ~ .box { background: #ffffff; border-color: #ffffff; }
.pick input:checked ~ .box .icon { opacity: 1; }
.pick input:focus-visible ~ .box { outline: 2px solid var(--ink); outline-offset: 3px; }
.ticket.is-on .pick { background: var(--green-800); border-right-color: var(--green-800); }
.ticket.is-on .pick input:focus-visible ~ .box { outline-color: #ffffff; }

.ticket-body { display: grid; gap: 8px; padding: 12px 16px 14px; min-width: 0; }
.ticket-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ticket-name { font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 0.95; text-transform: uppercase; }
.ticket-meta { color: var(--ink-3); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ticket-q { color: var(--ink-2); font-size: 14px; line-height: 1.35; text-wrap: pretty; }
.ticket-why { color: var(--ink-2); font-size: 13.5px; line-height: 1.35; }
.ticket-why strong { color: var(--ink); font-weight: 650; }

.verdict {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px 1px 6px;
  border-radius: 3px;
  background: var(--tag-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.verdict .icon { width: 14px; height: 14px; stroke-width: 2.25; }

.ticket-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px 14px; }
.sides { display: grid; grid-template-columns: repeat(2, 68px); gap: 6px; }
.side {
  display: grid;
  justify-items: center;
  gap: 0;
  min-height: 50px;
  padding: 5px 4px;
  border: 0;
  border-radius: 3px;
  transition: background-color 150ms ease, color 150ms ease, transform 120ms var(--ease-out);
}
.side:active { transform: scale(0.97); }
.side-word { font-size: 12px; font-weight: 650; }
.side-price { font-size: 18px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.side-yes { background: var(--yes-tint); color: var(--ink); }
.side-yes:hover { background: #c9e0cf; }
.side-yes[aria-pressed="true"] { background: var(--green-700); color: #ffffff; }
.side-no { background: var(--no-tint); color: var(--no-ink); }
.side-no:hover { background: #f3cdc5; }
.side-no[aria-pressed="true"] { background: var(--red); color: #ffffff; }
.side:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.ticket-prices { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ticket-prices .price-yes, .ticket-prices .price-no { padding: 5px 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.ticket-prices .btn { margin-left: auto; }

.qty { display: grid; grid-template-columns: minmax(104px, 0.8fr) minmax(0, 1fr); align-items: center; gap: 10px; }
.qty .field { min-height: 38px; }
.ticket:not(.is-on) .ticket-name { color: var(--ink-3); }
.ticket-flag { display: flex; gap: 6px; color: var(--ink); font-size: 13.5px; }
.ticket-flag .icon { width: 16px; height: 16px; margin-top: 1px; }

/* Order */
.order-tag { margin-top: 12px; flex: 1 0 auto; display: grid; gap: 10px; align-content: start; }
.order-tag .tag-head { margin-bottom: 0; }
.meter { height: 10px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.meter span {
  display: block;
  height: 100%;
  background: var(--green-700);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 200ms var(--ease-out), background-color 150ms ease;
}
.meter.is-over span { background: var(--red); }
.budget-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.budget-line .icon { width: 16px; height: 16px; color: var(--red); }
.budget-line strong { font-weight: 700; }
.order-lines { display: grid; }
.order-lines li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0;
  border-top: 1px solid var(--rule);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.order-lines li span:last-child { font-weight: 650; white-space: nowrap; }
.order-empty { color: var(--ink-2); }
.order-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 8px;
  border-top: 2px solid var(--ink);
  font-weight: 650;
}
.order-total strong { font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1; }
.order-tag .btn-primary { width: 100%; }

.plan-fine { padding: 0 var(--pad) 22px; }

/* ---------- narrower screens ---------- */

@media (max-width: 1100px) {
  .farm-grid { grid-template-columns: minmax(0, 1fr) minmax(380px, 0.9fr); gap: 24px; }
  .plan-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "chart" "sidetop" "side"; gap: 18px; }
  .side-top { padding-top: 0; }
  /* The graph is above the fold here, so its result rides along with the tickets. */
  .plan-result {
    display: block;
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0 calc(var(--pad) * -1) 12px;
    padding: 9px var(--pad);
    background: var(--green-800);
    color: var(--on-green);
    font-size: 14.5px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
  }
}

@media (max-width: 900px) {
  .farm-grid { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .map { max-height: 42dvh; }
}

@media (max-width: 760px) {
  .sample-note { margin-left: 0; flex-basis: 100%; }
}

@media (max-width: 820px) {
  .screen-intro { grid-template-columns: minmax(0, 1fr); }
  .sack-panel { gap: 20px; }
  .how li { max-width: none; }
  .start-wrap { display: contents; }
  .start-tag { order: -1; }
  .fine { order: 1; }
  .sack-panel, .sack-side { padding: 28px; }
  .start-face { min-height: 104px; }
}

@media (max-width: 560px) {
  :root { --pad: 14px; }
  .bar { gap: 8px 14px; }
  .sack-panel, .sack-side { padding: 22px; }
  .steps { gap: 2px; font-size: 13px; }
  .side-head { flex-wrap: wrap; }
  .plan-state { flex-basis: 100%; margin-left: 0; text-align: left; }
  .steps a { padding: 5px 8px 5px 5px; gap: 6px; }
  .row, fieldset.row { display: block; margin: 0 -14px; padding: 10px 14px; }
  .row > label { display: block; padding: 0 0 6px; }
  /* A floated legend lays out as a normal block; an unfloated one sits on the fieldset's border. */
  fieldset.row > legend { float: left; width: 100%; padding: 0 0 6px; }
  fieldset.row > .control { clear: both; }
  fieldset.row > .control { margin-left: 0; }
  .farm-tag { padding: 38px 14px 18px; }
  .tag-foot { margin: 0 -14px; padding: 14px 14px 0; }
  .where-out, .row > .note, .row > .error { padding-top: 6px; }
  .chart-tag, .order-tag { padding: 14px 14px 16px; }
  th, td { padding-left: 6px; padding-right: 6px; }
  .ruled { font-size: 13px; }
  .ruled thead th, .ruled tbody th { white-space: normal; }
  .ticket { grid-template-columns: 44px minmax(0, 1fr); }
  .ticket-body { padding: 12px 12px 14px; }
  .ticket-controls { grid-template-columns: minmax(0, 1fr); }
  .sides { grid-template-columns: 1fr 1fr; }
  .start-word { font-size: 60px; }
  .start-tag .icon { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .screen.is-entering { animation: screen-fade 160ms ease; }
  @keyframes screen-fade { from { opacity: 0; } }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* Real model output vs sample data (server.py). body.real-data is set when the API answers. */
body.real-data .sample-only { display: none; }
body:not(.real-data) .real-only { display: none; }
.plan-verdict { margin: 0 0 0.35rem; font-weight: 700; letter-spacing: 0.01em; }
.plan-verdict[data-decision="none"] { font-weight: 600; }
.plan-status { margin: 0 0 1rem; padding: 0.9rem 1rem; border: 1px solid currentColor; border-radius: 6px; }
.plan-status[hidden] { display: none; }
.plan-status-title { margin: 0; font-weight: 700; }
.plan-status-text { margin: 0.35rem 0 0; }
.plan-status .btn { margin-top: 0.75rem; }
.plan-status[data-kind="loading"] .plan-status-title::after { content: ""; display: inline-block; width: 0.8em; height: 0.8em;
  margin-left: 0.5em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  vertical-align: -0.1em; animation: fj-spin 0.9s linear infinite; }
@keyframes fj-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .plan-status[data-kind="loading"] .plan-status-title::after { animation: none; } }
/* With a long menu of hedges, keep the chart at a readable size and in view while scrolling. */
.chart-tag { align-self: start; position: sticky; top: 1rem; }
.chart-tag .plot { flex: none; height: min(60vh, 520px); }

/* Advice screen: recommendation first, the rest collapsed; illustration mode label. */
.plan-topline { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.illus-toggle { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; line-height: 1; cursor: pointer; }
.illus-toggle input { width: 1rem; height: 1rem; margin: 0; vertical-align: middle; flex: none; }
.illus-label { margin: 0 0 0.5rem; display: inline-block; padding: 0.2rem 0.55rem; border-radius: 4px;
  background: #f2c94c; color: #1c1c1c; font-weight: 700; font-size: 0.8125rem; letter-spacing: 0.01em; }
.illus-label[hidden] { display: none; }
.illus-chip { margin: 0 0.5rem; }
.ticket-group { list-style: none; margin: 0.75rem 0 0.4rem; font-weight: 700; font-size: 0.8125rem;
  text-transform: uppercase; letter-spacing: 0.06em; }
.ticket-group-note { list-style: none; margin: -0.2rem 0 0.5rem; font-size: 0.8125rem; }
.ticket-more { list-style: none; margin-top: 0.75rem; }
.ticket-more > details > summary { cursor: pointer; font-weight: 700; font-size: 0.8125rem; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 0.4rem 0; }
.ticket-more .tickets { padding: 0; margin: 0.4rem 0 0; }
.plot-note { margin: 0.4rem 0 0.75rem; font-size: 0.8125rem; opacity: 0.85; }

/* Bad years on the chart: red, larger, ringed dots (shape cue too, not colour alone). */
.dots-base circle.is-bad { fill: #c0392b; r: 5.5px; }
.bad-ring { fill: none; stroke: #c0392b; stroke-width: 1.5; pointer-events: none; }
.bad-tag { font-size: 11px; font-weight: 600; fill: #8e1f14; paint-order: stroke; stroke: #fff; stroke-width: 3.5px;
  stroke-linejoin: round; pointer-events: none; }
.sw-bad { width: 9px; height: 9px; border-radius: 50%; background: #c0392b; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #c0392b; margin: 0 3px; }

/* Empty farm form: what is still needed before "See My Plan". */
.form-missing { margin: 0.5rem 0 0; font-size: 0.8125rem; text-align: right; color: var(--ink-2); }
.form-missing[hidden] { display: none; }
#see-plan:disabled { opacity: 0.45; cursor: not-allowed; }
