:root {
  color-scheme: dark;
  --ink: #e8efe9;
  --ink-soft: #b7c4bb;
  --muted: #8a9a90;
  --paper: #0f1612;
  --paper-2: #17201a;
  --elevated: #1c2820;
  --sand: #3a3428;
  --bio: #4a6b3a;
  --mow: #2a3830;
  --fruit-bed: #3d4a38;
  --accent: #5fbf84;
  --accent-2: #8fd4a8;
  --line: rgba(200, 220, 208, 0.12);
  --shadow: rgba(0, 0, 0, 0.35);
  --panel: rgba(22, 30, 25, 0.96);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Sora", system-ui, sans-serif;
  --radius: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1000px 520px at 8% -8%, rgba(47, 122, 82, 0.18) 0%, transparent 55%),
    radial-gradient(800px 420px at 100% 0%, rgba(42, 111, 143, 0.12) 0%, transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.app {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100svh;
}

/* ——— Header ——— */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: relative;
  z-index: 2;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand .eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--accent-2);
}

.brand-blurb {
  margin: 0;
  color: var(--ink-soft);
  max-width: 42ch;
  font-size: 0.92rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.control {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.control label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.year-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control input[type="range"] {
  width: 140px;
  accent-color: var(--accent);
}

.year-readout {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-2);
  white-space: nowrap;
  min-width: 2.8em;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--elevated);
}

.seg button {
  border: 0;
  background: transparent;
  padding: 7px 12px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 13px;
}

.seg button[aria-pressed="true"] {
  background: var(--accent);
  color: #0b120e;
}

.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.chk input {
  accent-color: var(--accent);
}

/* ——— Workspace ——— */
.workspace {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 340px);
  gap: 0;
  min-height: 0;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(52vh, 1fr) auto;
  }
}

.map-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
}

.map-toolbar {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - 28px);
}

.map-toolbar button {
  border: 1px solid var(--line);
  background: var(--elevated);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink-soft);
  backdrop-filter: blur(8px);
}

.map-toolbar button[aria-pressed="true"] {
  background: var(--accent);
  color: #0b120e;
  border-color: transparent;
}

.map-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  cursor: grab;
  background:
    linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.2) 100%),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 39px,
      rgba(255, 255, 255, 0.03) 39px,
      rgba(255, 255, 255, 0.03) 40px
    );
}

.map-scroll.is-dragging {
  cursor: grabbing;
}

#orchard-map {
  display: block;
  min-width: 980px;
  width: 100%;
  height: auto;
  touch-action: none;
}

.compass {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink-soft);
  backdrop-filter: blur(8px);
}

.compass strong {
  display: block;
  color: var(--accent-2);
  margin-bottom: 2px;
  font-family: var(--sans);
  font-size: 12px;
}

/* SVG internals */
.strip-bio {
  fill: #6a9a55;
  fill-opacity: 0.28;
}
.strip-fruit {
  fill: #4a5e42;
  fill-opacity: 0.65;
}
.strip-mow {
  fill: #2f3d34;
  fill-opacity: 0.85;
}
.grid-line {
  stroke: rgba(200, 220, 208, 0.1);
  stroke-width: 0.15;
}
.module-line {
  stroke: rgba(200, 220, 208, 0.28);
  stroke-width: 0.25;
  stroke-dasharray: 1.2 1.2;
}
.ft-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 2.4px;
}
.row-label {
  fill: var(--accent-2);
  font-family: var(--sans);
  font-size: 3.2px;
  font-weight: 600;
}
.canopy {
  fill-opacity: 0.28;
  stroke-width: 0.25;
  pointer-events: none;
  transition: r 0.35s ease, fill-opacity 0.25s ease;
}
.stem {
  cursor: pointer;
  stroke: rgba(232, 239, 233, 0.35);
  stroke-width: 0.2;
  transition: transform 0.2s ease, stroke-width 0.15s ease;
  transform-box: fill-box;
  transform-origin: center;
}
.stem:hover,
.stem.is-hover {
  stroke-width: 0.45;
  stroke: #fff;
}
.stem.is-selected {
  stroke: #fff;
  stroke-width: 0.55;
  filter: drop-shadow(0 0 1.2px rgba(143, 212, 168, 0.7));
}
.stem.is-dim {
  opacity: 0.18;
}
.stem-open {
  fill: none !important;
  stroke-dasharray: 0.8 0.6;
}

/* ——— Side panel ——— */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.panel-scroll {
  overflow: auto;
  padding: 18px 18px 28px;
  display: grid;
  gap: 18px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--accent-2);
}

.panel h3 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-family: var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.empty-hint {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: var(--elevated);
}

.station-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--elevated);
  display: grid;
  gap: 10px;
  animation: rise 0.28s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.layer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(95, 191, 132, 0.12);
  width: fit-content;
}

.layer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.station-card .plant-name {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.botanical {
  font-style: italic;
  color: var(--muted);
  font-size: 0.88rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.meta {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.meta .k {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta .v {
  font-size: 0.95rem;
  color: var(--ink);
}

.why {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.cross {
  display: grid;
  gap: 8px;
}

.cross-bar {
  display: flex;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.cross-bar span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  text-align: center;
  line-height: 1.15;
  padding: 2px;
  color: var(--ink);
}

.cross-bar .bio {
  background: rgba(74, 107, 58, 0.55);
}
.cross-bar .fruit {
  background: rgba(47, 122, 82, 0.7);
  color: #e8efe9;
}
.cross-bar .mow {
  background: rgba(60, 75, 65, 0.9);
  color: var(--ink-soft);
}

.legend {
  display: grid;
  gap: 6px;
}

.legend button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 7px 8px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 13px;
}

.legend button[aria-pressed="true"] {
  background: var(--elevated);
  border-color: var(--line);
  color: var(--ink);
}

.legend button.is-off {
  opacity: 0.4;
}

.module-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.module-steps button {
  border: 1px solid var(--line);
  background: var(--elevated);
  border-radius: 10px;
  padding: 8px 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--ink-soft);
}

.module-steps button strong {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-2);
  margin-bottom: 2px;
}

.module-steps button[aria-pressed="true"] {
  background: var(--accent);
  color: #0b120e;
  border-color: transparent;
}

.module-steps button[aria-pressed="true"] strong {
  color: #0b120e;
}

.counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.count {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--elevated);
}

.count .n {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--accent-2);
}

.count .l {
  font-size: 11px;
  color: var(--muted);
}

.footer-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.inventory-table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--elevated);
}

.inventory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.inventory-table th,
.inventory-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(20, 36, 28, 0.08);
}

.inventory-table th {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(20, 36, 28, 0.04);
}

.inventory-table th:first-child,
.inventory-table td:first-child {
  text-align: right;
  width: 3.2em;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.inventory-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.04);
}

.inventory-table tbody tr:last-child td {
  border-bottom: 0;
}

.inventory-where {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 960px) {
  .map-wrap {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    min-height: 42vh;
  }

  .top {
    padding: 8px 12px;
    gap: 8px 10px;
    align-items: center;
  }

  .brand .eyebrow,
  .brand-blurb {
    display: none;
  }

  .brand h1 {
    font-size: 1rem;
    letter-spacing: -0.02em;
  }

  .controls {
    width: 100%;
    gap: 8px;
  }

  .control label {
    display: none;
  }

  .control-year {
    flex: 1;
    min-width: 120px;
  }

  .control input[type="range"] {
    width: 100%;
    max-width: 160px;
  }

  .seg button {
    padding: 6px 10px;
    font-size: 12px;
  }

  .compass {
    display: none;
  }

  .workspace[data-view="list"] {
    grid-template-rows: minmax(48vh, 1fr) auto;
  }

  .workspace[data-view="list"] .panel {
    max-height: 42vh;
  }

  .list-wrap {
    min-height: 48vh;
  }

  .species-row-btn {
    min-height: 48px;
    padding: 10px 12px;
  }
}

/* ——— Species list ——— */
.list-wrap {
  display: none;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.workspace[data-view="list"] .map-wrap,
.workspace[data-view="guide"] .map-wrap {
  display: none;
}

.workspace[data-view="list"] .list-wrap {
  display: flex;
}

.workspace[data-view="map"] .list-wrap,
.workspace[data-view="guide"] .list-wrap {
  display: none;
}

.workspace[data-view="guide"] .guide-wrap {
  display: flex;
}

.workspace[data-view="map"] .guide-wrap,
.workspace[data-view="list"] .guide-wrap {
  display: none;
}

/* ——— Guide (canvas content) ——— */
.guide-wrap {
  display: none;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.guide-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 32px;
  display: grid;
  gap: 18px;
  width: 100%;
  margin: 0 auto;
}

.guide-scroll h2 {
  margin: 8px 0 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--accent-2);
}

.callout {
  border: 1px solid rgba(95, 191, 132, 0.35);
  background: rgba(95, 191, 132, 0.1);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.callout strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-2);
}

.callout p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.module-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

@media (max-width: 720px) {
  .module-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.module-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  background: var(--elevated);
}

.module-card .ft {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-2);
  margin-bottom: 2px;
}

.module-card .role {
  font-size: 11px;
  color: var(--muted);
}

.module-card .plant {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.plan-strips {
  display: grid;
  gap: 14px;
}

.plan-view-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 18px 16px;
  background: #0a0e0c;
  width: 100%;
}

.plan-view-card h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: #f2f7f3;
}

.plan-view-blurb {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 72ch;
  line-height: 1.45;
}

.plan-strip-label {
  font-size: 13px;
  font-weight: 600;
  color: #e8efe9;
  margin-bottom: 6px;
}

.plan-strip-bar {
  display: flex;
  width: 100%;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(200, 220, 208, 0.14);
  background: #121816;
}

.plan-seg {
  min-width: 2px;
  height: 100%;
  border: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.35);
  padding: 0;
  margin: 0;
  cursor: pointer;
  border-radius: 0;
  transition: filter 0.12s ease, outline-color 0.12s ease;
}

.plan-seg:last-child {
  border-right: 0;
}

.plan-seg:hover,
.plan-seg:focus-visible {
  filter: brightness(1.35);
  outline: 2px solid rgba(94, 200, 255, 0.7);
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}

.plan-seg.is-selected {
  outline: 2px solid #5ec8ff;
  outline-offset: -2px;
  filter: brightness(1.25);
  z-index: 1;
  position: relative;
}

.plan-layer-legend {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.why-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .why-grid {
    grid-template-columns: 1fr;
  }
}

.why-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--elevated);
}

.why-card h3 {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--accent-2);
  text-transform: none;
  letter-spacing: -0.01em;
  font-family: var(--sans);
  font-weight: 600;
}

.why-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

@media (max-width: 960px) {
  .workspace[data-view="guide"] {
    grid-template-rows: minmax(48vh, 1fr) auto;
  }
  .workspace[data-view="guide"] .panel {
    max-height: 42vh;
  }
  .guide-wrap {
    min-height: 48vh;
  }
}

@media (min-width: 961px) {
  .workspace[data-view="guide"] {
    grid-template-columns: 1fr;
  }
  .workspace[data-view="guide"] .panel {
    display: none;
  }
  .guide-scroll {
    padding: 22px 28px 40px;
  }
  .plan-strip-bar {
    height: 42px;
  }
}

.list-toolbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
}

.species-list {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 24px;
  flex: 1;
}

.species-group {
  border-bottom: 1px solid var(--line);
}

.species-group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 14px 8px;
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
  border-bottom: 1px solid var(--line);
}

.species-row-btn {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 11px 14px;
  cursor: pointer;
  color: var(--ink);
}

.species-row-btn:active,
.species-row-btn.is-selected {
  background: rgba(95, 191, 132, 0.16);
}

.species-ft {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.species-plant {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
}

.species-layer {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--ink-soft);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

@media (min-width: 961px) {
  .workspace[data-view="list"] {
    grid-template-columns: 1fr minmax(280px, 340px);
  }
}
