/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --green-900: #1b4332;
  --green-800: #2d6a4f;
  --green-700: #40916c;
  --green-600: #52b788;
  --green-500: #74c69d;
  --green-300: #95d5b2;
  --green-200: #b7e4c7;
  --green-100: #d8f3dc;
  --green-50: #f0faf4;
  --amber-100: #fef3c7;
  --amber-700: #b45309;
  --red-100: #fee2e2;
  --red-700: #b91c1c;
  --grey-900: #1a1a1a;
  --grey-700: #374151;
  --grey-500: #6b7280;
  --grey-300: #d1d5db;
  --grey-100: #f3f4f6;
  --white: #ffffff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --max-width: 1200px;
}
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--grey-900); background: var(--green-50); line-height: 1.6; }
img, svg { display: block; max-width: 100%; }
a { color: var(--green-800); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--green-900); }
ul { list-style: none; }
.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 1.25rem; }
.skip-link { position: absolute; top: -100%; left: 1rem; background: var(--green-800); color: var(--white); padding: .5rem 1rem; border-radius: 0 0 var(--radius) var(--radius); z-index: 100; }
.skip-link:focus { top: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ===== Header ===== */
.site-header { background: var(--green-900); color: var(--white); padding: .75rem 0; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-md); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: .5rem; color: var(--white); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.logo:hover { color: var(--green-200); }
.main-nav ul { display: flex; gap: 1.25rem; }
.main-nav a { color: var(--green-200); text-decoration: none; font-size: .95rem; }
.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--white); text-decoration: underline; }

/* ===== Intro ===== */
.intro { padding: 2.5rem 0 1.5rem; }
.intro h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); color: var(--green-900); line-height: 1.2; margin-bottom: .75rem; }
.lead { font-size: 1.1rem; color: var(--grey-700); max-width: 65ch; margin-bottom: 1.25rem; }
.why-note { background: var(--green-100); border-left: 4px solid var(--green-700); padding: 1rem 1.25rem; border-radius: 0 var(--radius) var(--radius) 0; font-size: .95rem; color: var(--grey-700); }
.why-note strong { color: var(--green-900); }

/* ===== Planner Workspace ===== */
.planner-workspace { padding: 1rem 0 2.5rem; }
.workspace-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 860px) {
  .workspace-grid { grid-template-columns: 1fr 300px; }
}

/* Controls */
.controls-bar { display: flex; flex-wrap: wrap; gap: 1rem; background: var(--white); padding: 1rem; border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 1rem; }
.control-group { display: flex; flex-direction: column; gap: .25rem; }
.control-group label { font-size: .8rem; font-weight: 600; color: var(--grey-700); text-transform: uppercase; letter-spacing: .03em; }
.control-group select, .control-group input { padding: .5rem .75rem; border: 1px solid var(--grey-300); border-radius: var(--radius); font-size: .95rem; background: var(--white); color: var(--grey-900); }
.control-group select:focus, .control-group input:focus { outline: 2px solid var(--green-600); outline-offset: 1px; border-color: var(--green-600); }
.hint { font-size: .75rem; color: var(--grey-500); }

/* Beds */
.beds-area { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1rem; }
.bed-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1rem; border: 2px solid transparent; transition: border-color .2s; }
.bed-card.nitrogen-positive { border-color: var(--green-600); }
.bed-card.nitrogen-neutral { border-color: var(--grey-300); }
.bed-card.nitrogen-negative { border-color: var(--amber-700); }
.bed-card.pest-warning { border-color: var(--red-700); }
.bed-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.bed-label { font-weight: 700; font-size: 1rem; color: var(--green-900); }
.bed-number { background: var(--green-100); color: var(--green-800); font-size: .8rem; font-weight: 600; padding: .15rem .5rem; border-radius: 99px; }
.bed-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.bed-field { display: flex; flex-direction: column; gap: .2rem; flex: 1; min-width: 140px; }
.bed-field label { font-size: .8rem; color: var(--grey-700); font-weight: 500; }
.bed-field select { padding: .45rem .6rem; border: 1px solid var(--grey-300); border-radius: var(--radius); font-size: .9rem; background: var(--white); }
.bed-field select:focus { outline: 2px solid var(--green-600); outline-offset: 1px; }
.bed-status { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.status-badge { font-size: .75rem; padding: .15rem .5rem; border-radius: 99px; font-weight: 600; }
.status-badge.n-pos { background: #d1fae5; color: #065f46; }
.status-badge.n-neg { background: #fef3c7; color: #92400e; }
.status-badge.n-neu { background: var(--grey-100); color: var(--grey-700); }
.status-badge.pest { background: var(--red-100); color: var(--red-700); }
.family-tag { font-size: .75rem; padding: .15rem .5rem; border-radius: 99px; font-weight: 600; color: var(--white); }

/* Actions */
.actions-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.btn { padding: .6rem 1.25rem; border-radius: var(--radius); font-size: .95rem; font-weight: 600; cursor: pointer; border: 2px solid transparent; transition: background .2s, border-color .2s, color .2s; }
.btn-primary { background: var(--green-800); color: var(--white); border-color: var(--green-800); }
.btn-primary:hover { background: var(--green-900); }
.btn-secondary { background: var(--white); color: var(--green-800); border-color: var(--green-600); }
.btn-secondary:hover { background: var(--green-100); }
.btn-ghost { background: transparent; color: var(--grey-700); border-color: var(--grey-300); }
.btn-ghost:hover { background: var(--grey-100); }
.btn:focus-visible { outline: 3px solid var(--green-600); outline-offset: 2px; }

/* History */
.history-section { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1rem; }
.history-section h3 { font-size: 1rem; margin-bottom: .5rem; color: var(--green-900); }
.history-section ul { display: flex; flex-direction: column; gap: .4rem; }
.history-section li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .9rem; padding: .4rem .5rem; background: var(--grey-100); border-radius: var(--radius); }
.history-section li button { font-size: .8rem; padding: .2rem .6rem; }

/* Reference Panel */
.reference-panel { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.25rem; height: fit-content; }
.reference-panel h2 { font-size: 1.1rem; color: var(--green-900); margin-bottom: .75rem; }
.reference-panel h3 { font-size: .9rem; color: var(--green-800); margin-bottom: .4rem; }
.family-legend { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1.25rem; }
.legend-item { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.nitrogen-key { margin-bottom: 1.25rem; }
.nitrogen-key ul { display: flex; flex-direction: column; gap: .3rem; }
.nitrogen-key li { font-size: .85rem; display: flex; align-items: center; gap: .5rem; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .1rem .4rem; border-radius: 4px; }
.badge-positive { background: #d1fae5; color: #065f46; }
.badge-neutral { background: var(--grey-100); color: var(--grey-700); }
.badge-negative { background: #fef3c7; color: #92400e; }
.pest-notes p, .pest-notes li { font-size: .85rem; color: var(--grey-700); }
.pest-notes ul { display: flex; flex-direction: column; gap: .25rem; padding-left: 1rem; list-style: disc; }

/* ===== Walkthrough ===== */
.walkthrough { padding: 2rem 0; }
.walkthrough h2 { font-size: 1.4rem; color: var(--green-900); margin-bottom: 1rem; }
.steps { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: .75rem; }
.steps li { background: var(--white); padding: 1rem 1rem 1rem 3rem; border-radius: var(--radius-lg); box-shadow: var(--shadow); position: relative; font-size: .95rem; color: var(--grey-700); }
.steps li::before { counter-increment: step; content: counter(step); position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); width: 1.75rem; height: 1.75rem; background: var(--green-800); color: var(--white); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.steps li strong { color: var(--green-900); }

/* ===== Common Mistakes ===== */
.common-mistakes { padding: 2rem 0; }
.common-mistakes h2 { font-size: 1.4rem; color: var(--green-900); margin-bottom: 1rem; }
.mistake-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 600px) {
  .mistake-grid { grid-template-columns: 1fr 1fr; }
}
.mistake-card { background: var(--white); padding: 1.25rem; border-radius: var(--radius-lg); box-shadow: var(--shadow); border-top: 4px solid var(--green-600); }
.mistake-card h3 { font-size: 1rem; color: var(--green-900); margin-bottom: .4rem; }
.mistake-card p { font-size: .9rem; color: var(--grey-700); }

/* ===== FAQ ===== */
.faq { padding: 2rem 0 3rem; }
.faq h2 { font-size: 1.4rem; color: var(--green-900); margin-bottom: 1rem; }
.faq details { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: .5rem; overflow: hidden; }
.faq summary { padding: 1rem 1.25rem; font-weight: 600; color: var(--green-900); cursor: pointer; font-size: .95rem; }
.faq summary:hover { background: var(--green-50); }
.faq details[open] summary { border-bottom: 1px solid var(--grey-300); }
.faq details p { padding: 1rem 1.25rem; font-size: .9rem; color: var(--grey-700); }

/* ===== Footer ===== */
.site-footer { background: var(--green-900); color: var(--green-200); padding: 1.5rem 0; font-size: .85rem; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.footer-inner a { color: var(--green-200); }
.footer-inner a:hover { color: var(--white); }
.footer-inner nav ul { display: flex; gap: 1rem; }
.version { color: var(--green-300); font-size: .8rem; }

/* ===== Print Styles ===== */
@media print {
  .site-header, .site-footer, .controls-bar, .actions-bar, .history-section, .reference-panel, .walkthrough, .common-mistakes, .faq, .why-note { display: none !important; }
  body { background: var(--white); color: #000; }
  .bed-card { break-inside: avoid; border: 1px solid #999; box-shadow: none; }
  .intro h1 { font-size: 1.5rem; }
  .lead { font-size: 1rem; }
}

/* ===== Responsive Tweaks ===== */
@media (max-width: 480px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .main-nav ul { gap: .75rem; }
  .controls-bar { flex-direction: column; }
  .bed-row { flex-direction: column; }
  .actions-bar { flex-direction: column; }
  .btn { width: 100%; text-align: center; }
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
