:root {
  color-scheme: dark;
  --bg: #080b0a;
  --panel: #111614;
  --panel-2: #171d1a;
  --line: #29332e;
  --text: #f2f7f4;
  --muted: #9ca9a2;
  --green: #76b900;
  --green-soft: #b6f24a;
  --blue: #50a9ff;
  --amber: #f2b84b;
  --red: #ff7c6b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: radial-gradient(circle at 85% -10%, #1d3216 0, transparent 30%), var(--bg); color: var(--text); }
a { color: inherit; }
button, input { font: inherit; }

.topbar { max-width: 1440px; margin: 0 auto; padding: 22px clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { text-decoration: none; font-weight: 900; letter-spacing: -.04em; }
.brand span { color: var(--green-soft); font-size: .72em; letter-spacing: .08em; }
nav { display: flex; gap: 24px; }
nav a { color: var(--muted); text-decoration: none; font-size: .88rem; }
nav a:hover { color: var(--green-soft); }

main { max-width: 1440px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 64px) 48px; }
.hero { min-height: 370px; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .6fr); align-items: end; gap: 48px; padding: 72px 0 56px; }
.eyebrow { color: var(--green-soft); font-size: .78rem; font-weight: 800; letter-spacing: .16em; }
h1 { max-width: 880px; margin: 14px 0 22px; font-size: clamp(2.6rem, 6vw, 5.7rem); line-height: .94; letter-spacing: -.065em; }
h1 span { color: var(--green); }
.lede { max-width: 720px; margin: 0; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.22rem); line-height: 1.7; }
.evidence-note { border-top: 2px solid var(--green); padding: 18px 0; color: var(--muted); line-height: 1.6; }
.evidence-note strong { color: var(--green-soft); font-size: .72rem; letter-spacing: .14em; }

.workspace { display: grid; grid-template-columns: minmax(330px, .78fr) minmax(520px, 1.35fr); gap: 18px; align-items: start; }
.panel { background: rgba(17, 22, 20, .94); border: 1px solid var(--line); border-radius: 18px; padding: clamp(22px, 3vw, 34px); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-heading > div { display: flex; align-items: baseline; gap: 12px; }
.section-heading span { color: var(--green); font: 800 .72rem ui-monospace, monospace; }
h2, h3, p { margin-top: 0; }
h2 { margin-bottom: 0; font-size: 1.25rem; }
.text-button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .82rem; }
.text-button:hover { color: var(--green-soft); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 14px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: .78rem; font-weight: 700; }
input[type="number"] { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #090d0b; color: var(--text); padding: 12px; outline: none; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(118, 185, 0, .12); }
input[aria-invalid="true"] { border-color: var(--red); }
label small { min-height: 1em; color: var(--red); font-weight: 500; }
.range-row { display: flex; align-items: center; gap: 10px; }
input[type="range"] { accent-color: var(--green); width: 100%; }
output { min-width: 48px; color: var(--green-soft); font-weight: 800; text-align: right; }
details { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; }
summary { cursor: pointer; color: var(--text); font-size: .88rem; font-weight: 750; }
.advanced-fields { margin-top: 18px; }

.winner { display: flex; justify-content: space-between; gap: 16px; border: 1px solid rgba(118, 185, 0, .55); background: rgba(118, 185, 0, .08); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.winner span { color: var(--muted); font-size: .82rem; }
.winner strong { color: var(--green-soft); }
.cost-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cost-card { min-width: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.cost-card.best { border-color: var(--green); }
.cost-card .name { color: var(--muted); font-size: .77rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.cost-card .price { display: block; margin: 12px 0 6px; font-size: clamp(1.45rem, 3vw, 2.2rem); letter-spacing: -.05em; }
.cost-card p { margin-bottom: 0; color: var(--muted); font-size: .75rem; line-height: 1.6; }
.chart-card { margin-top: 16px; padding: 20px 18px 12px; background: #0b0f0d; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.chart-heading { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.chart-heading h3 { margin-bottom: 5px; font-size: .95rem; }
.chart-heading p { color: var(--muted); font-size: .75rem; }
.legend { display: flex; gap: 12px; font-size: .7rem; font-weight: 800; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.legend .api::before { background: var(--blue); }
.legend .nim::before { background: var(--green); }
.legend .oss::before { background: var(--amber); }
#sensitivity-chart { width: 100%; min-height: 250px; }
.result-footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 18px; }
.result-footer p { margin: 0; color: var(--muted); font-size: .8rem; }
.primary-button { border: 0; border-radius: 8px; background: var(--green); color: #071000; padding: 12px 16px; font-weight: 850; cursor: pointer; white-space: nowrap; }
.primary-button:hover { background: var(--green-soft); }
.validation-summary { border: 1px solid var(--red); color: #ffd1cb; background: rgba(255, 124, 107, .08); border-radius: 10px; padding: 14px; }

.formula-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 18px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.formula-strip div { background: var(--panel); padding: 20px; }
.formula-strip span { display: block; color: var(--green); font: 800 .68rem ui-monospace, monospace; margin-bottom: 8px; }
.formula-strip strong { font-size: .88rem; }

footer { max-width: 1440px; margin: 0 auto; padding: 24px clamp(20px, 4vw, 64px) 46px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: .75rem; }
footer p { margin: 0; }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .workspace { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { align-items: flex-start; }
  nav { flex-direction: column; gap: 8px; text-align: right; }
  .hero { padding: 54px 0 36px; gap: 24px; }
  .field-grid, .cost-cards, .formula-strip { grid-template-columns: 1fr; }
  .chart-heading, .result-footer, footer { flex-direction: column; align-items: flex-start; }
  .winner { flex-direction: column; }
  .primary-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
