/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-900: #1a3a1a;
  --green-800: #2C522B;
  --green-700: #3B6E3A;
  --green-600: #4A8A49;
  --green-500: #5BA35A;
  --green-400: #7CC47B;
  --green-300: #A8D5A2;
  --green-200: #C8E6C7;
  --green-100: #E8F5E8;
  --amber-600: #D4940A;
  --amber-500: #E8A838;
  --amber-400: #F5C563;
  --amber-100: #FEF3D6;
  --red-600: #C0392B;
  --red-100: #FDEDEC;
  --gray-900: #1c1c1c;
  --gray-800: #2d2d2d;
  --gray-700: #444;
  --gray-600: #555;
  --gray-500: #777;
  --gray-400: #999;
  --gray-300: #bbb;
  --gray-200: #ddd;
  --gray-100: #f4f4f4;
  --white: #fff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  --max-width: 1120px;
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--white);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green-700); text-decoration: none; }
a:hover, a:focus { color: var(--green-900); text-decoration: underline; }

img { max-width: 100%; height: auto; }

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--green-700);
  color: var(--white);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus { top: 16px; }

/* ===== Header ===== */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--gray-900);
}
.logo:hover { text-decoration: none; }

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.logo-accent { color: var(--green-600); }

.site-nav {
  display: flex;
  gap: 20px;
  align-items: center;
}
.site-nav a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-600);
  padding: 4px 0;
}
.site-nav a:hover,
.site-nav a:focus {
  color: var(--green-700);
  text-decoration: none;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  font-family: var(--font);
  line-height: 1.4;
}
.btn:focus-visible {
  outline: 3px solid var(--green-400);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--green-700);
  color: var(--white);
  border-color: var(--green-700);
}
.btn-primary:hover {
  background: var(--green-800);
  border-color: var(--green-800);
  color: var(--white);
  text-decoration: none;
}

.btn-outline {
  background: var(--white);
  color: var(--green-700);
  border-color: var(--green-300);
}
.btn-outline:hover {
  background: var(--green-100);
  border-color: var(--green-500);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  border-color: transparent;
  padding: 6px 12px;
}
.btn-ghost:hover {
  color: var(--gray-700);
  background: var(--gray-100);
  text-decoration: none;
}

.btn-sm { padding: 5px 12px; font-size: 0.82rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, var(--green-100) 0%, var(--amber-100) 100%);
  padding: 80px 0 64px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  color: var(--green-900);
  line-height: 1.2;
  max-width: 640px;
  margin: 0 auto 16px;
}
.hero-lead {
  font-size: 1.1rem;
  color: var(--gray-600);
  max-width: 520px;
  margin: 0 auto 28px;
}

/* ===== Sections ===== */
section { padding: 64px 0; }
section h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--green-900);
  margin-bottom: 8px;
}
.section-intro {
  color: var(--gray-600);
  max-width: 600px;
  margin-bottom: 32px;
}

/* ===== Builder ===== */
.builder-section { background: var(--gray-100); }
.builder-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: start;
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
}
.preset-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.form-row input[type="text"] {
  flex: 1 1 180px;
  min-width: 140px;
}
.form-row input[type="number"] {
  width: 90px;
  flex-shrink: 0;
}
.form-row select {
  width: 70px;
  flex-shrink: 0;
}

input[type="text"],
input[type="number"],
select {
  padding: 8px 12px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--white);
  color: var(--gray-800);
  transition: border-color var(--transition);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(91,163,90,0.2);
}

.material-list {
  margin-bottom: 20px;
}

.empty-state {
  color: var(--gray-400);
  font-style: italic;
  padding: 20px;
  text-align: center;
  background: var(--white);
  border-radius: var(--radius);
  border: 2px dashed var(--gray-200);
}

.material-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--white);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border: 1px solid var(--gray-200);
  gap: 8px;
}
.material-item .mat-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.material-item .mat-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.material-item .mat-amount {
  color: var(--gray-500);
  font-size: 0.82rem;
  flex-shrink: 0;
}
.material-item .mat-ratio {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  flex-shrink: 0;
}
.mat-ratio-high { background: var(--green-200); color: var(--green-800); }
.mat-ratio-low { background: var(--amber-100); color: var(--amber-600); }
.mat-ratio-mid { background: var(--gray-100); color: var(--gray-600); }

.material-item .btn-remove {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.material-item .btn-remove:hover { color: var(--red-600); background: var(--red-100); }

.builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ===== Ratio Card ===== */
.ratio-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  position: sticky;
  top: 80px;
}
.ratio-card h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.ratio-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  margin-bottom: 16px;
}
.ratio-number {
  font-size: 3rem;
  font-weight: 800;
  color: var(--green-700);
  line-height: 1;
}
.ratio-colon {
  font-size: 2rem;
  font-weight: 300;
  color: var(--gray-400);
}
.ratio-denominator {
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--gray-400);
}

.ratio-meter { margin-bottom: 12px; }
.ratio-meter-track {
  height: 8px;
  background: linear-gradient(90deg, var(--amber-500) 0%, var(--green-500) 50%, var(--green-300) 100%);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.ratio-meter-fill {
  position: absolute;
  top: 0;
  left: 50%;
  width: 14px;
  height: 14px;
  background: var(--gray-900);
  border-radius: 50%;
  transform: translate(-50%, -3px);
  transition: left 0.3s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.ratio-meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--gray-400);
  margin-top: 4px;
}

.ratio-status {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.status-ok { background: var(--green-100); color: var(--green-800); }
.status-low { background: var(--amber-100); color: var(--amber-600); }
.status-high { background: var(--red-100); color: var(--red-600); }
.status-empty { background: var(--gray-100); color: var(--gray-500); }

.ratio-breakdown {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 0.85rem;
}
.breakdown-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot-carbon { background: var(--green-600); }
.dot-nitrogen { background: var(--amber-500); }

.suggestion-box {
  background: var(--green-100);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.suggestion-box h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--green-700);
  margin-bottom: 4px;
}
.suggestion-box p {
  font-size: 0.85rem;
  color: var(--green-800);
}

/* ===== Layering Guide ===== */
.guide-section { background: var(--white); }
.layer-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 40px;
}
.layer {
  display: flex;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--gray-200);
}
.layer:last-child { border-bottom: none; }
.layer-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green-700);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.layer-repeat .layer-number {
  background: var(--gray-300);
  color: var(--gray-600);
}
.layer-body h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-900);
  margin-bottom: 4px;
}
.layer-body p {
  font-size: 0.9rem;
  color: var(--gray-600);
}

.guide-tips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.tip-card {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 20px;
  border-left: 4px solid var(--green-500);
}
.tip-card h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--green-900);
  margin-bottom: 6px;
}
.tip-card p {
  font-size: 0.88rem;
  color: var(--gray-600);
}

/* ===== Reference ===== */
.reference-section { background: var(--gray-100); }
.table-wrap {
  overflow-x: auto;
  margin-bottom: 40px;
}
.ref-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}
.ref-table th {
  background: var(--green-800);
  color: var(--white);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ref-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-700);
}
.ref-table tr:last-child td { border-bottom: none; }
.ref-table tr:hover td { background: var(--green-100); }

.reference-notes h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-900);
  margin-bottom: 12px;
  margin-top: 32px;
}
.reference-notes h3:first-child { margin-top: 0; }
.reference-notes ul {
  padding-left: 20px;
  margin-bottom: 8px;
}
.reference-notes li {
  font-size: 0.9rem;
  color: var(--gray-700);
  margin-bottom: 8px;
  line-height: 1.5;
}
.reference-notes dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
}
.reference-notes dt {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--green-900);
}
.reference-notes dd {
  font-size: 0.9rem;
  color: var(--gray-700);
}

/* ===== Scenarios ===== */
.scenario-section { background: var(--white); }
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.scenario-card {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 24px;
  border-top: 4px solid var(--green-500);
}
.scenario-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-900);
  margin-bottom: 8px;
}
.scenario-card p {
  font-size: 0.88rem;
  color: var(--gray-600);
  line-height: 1.55;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--green-900);
  color: var(--green-200);
  padding: 48px 0 24px;
}
.footer-top {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 32px;
  margin-bottom: 32px;
}
.footer-brand .logo-text {
  color: var(--white);
  font-size: 1.1rem;
}
.footer-brand p {
  font-size: 0.85rem;
  margin-top: 8px;
  max-width: 280px;
}
.footer-brand a { color: var(--green-300); }
.footer-brand a:hover { color: var(--white); }

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.footer-nav a {
  color: var(--green-300);
  font-size: 0.85rem;
}
.footer-nav a:hover { color: var(--white); text-decoration: none; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 16px;
}
.footer-bottom p {
  font-size: 0.8rem;
  color: var(--green-400);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .builder-grid {
    grid-template-columns: 1fr;
  }
  .ratio-card {
    position: static;
  }
  .hero { padding: 56px 0 40px; }
  section { padding: 48px 0; }
}

@media (max-width: 600px) {
  .site-header .container { height: 52px; }
  .site-nav { gap: 12px; }
  .site-nav a { font-size: 0.82rem; }
  .form-row { flex-direction: column; }
  .form-row input[type="text"],
  .form-row input[type="number"],
  .form-row select { width: 100%; }
  .preset-bar { flex-direction: column; align-items: flex-start; }
  .ratio-breakdown { flex-direction: column; gap: 8px; }
  .footer-top { flex-direction: column; }
  .reference-notes dl { grid-template-columns: 1fr; gap: 2px 0; }
  .reference-notes dt { margin-top: 12px; }
  .reference-notes dt:first-child { margin-top: 0; }
}



/* 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;
}
