:root {
  --cream: #FBF9F5;
  --cream2: #F5F1EA;
  --cream3: #F0EBE1;
  --green: #18221D;
  --green2: #1C2822;
  --deep: #1B2E28;
  --gold: #B89047;
  --gold-hover: #9E7A35;
  --gold-dark: #96702E;
  --gold-light: #DFC894;
  --gold-tint: rgba(184, 144, 71, 0.08);
  --sage: #78857E;
  --sage-border: #C8D0C4;
  --ink: #111815;
  --body-text: #49544E;
  --muted: #55615B;
  --dim: #66736C;
  --line: rgba(28, 35, 30, 0.08);
  --line-medium: rgba(28, 35, 30, 0.14);
  --surface: #FFFFFF;
  --surface-soft: #F5F1EA;
  --inverse: #FAF8F5;
  --inverse-muted: #A3B0A9;
  --accent-emerald: #108A56;
  --rose: #8A3A32;
  --font-serif: "Newsreader", Iowan Old Style, Palatino, serif;
  --font-deva: "Tiro Devanagari Hindi", "Noto Serif Devanagari", serif;
  --font-sans: "Sora", Avenir Next, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-press: 140ms;
  --dur-hover: 180ms;
  --dur-ui: 220ms;
  --press: 0.98;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 9999px;
  --shadow-sm: 0 1px 3px rgba(13, 22, 20, 0.04);
  --shadow-md: 0 4px 16px -2px rgba(13, 22, 20, 0.06);
  --shadow-lg: 0 16px 36px -8px rgba(13, 22, 20, 0.08);
  --shadow-elevated: 0 24px 48px -12px rgba(13, 22, 20, 0.12);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scrollbar-color: var(--gold) var(--cream3); }
body {
  font-family: var(--font-sans);
  color: var(--body-text);
  background-color: var(--cream);
  background-image: linear-gradient(180deg, rgba(251, 249, 245, 0.86), rgba(245, 241, 234, 0.9)), url("/static/luxury_ivory_gold.jpg");
  background-size: auto, 560px;
  background-repeat: no-repeat, repeat;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}
::selection { background: rgba(184, 144, 71, 0.28); color: var(--green); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 36px; padding-left: max(36px, env(safe-area-inset-left)); padding-right: max(36px, env(safe-area-inset-right)); }
.tabular-nums { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "zero" 1; font-family: var(--font-mono); }

nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251, 249, 245, 0.88);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.nav-in { display: flex; align-items: center; justify-content: space-between; max-width: 1220px; margin: 0 auto; padding: 14px 36px; padding-left: max(36px, env(safe-area-inset-left)); padding-right: max(36px, env(safe-area-inset-right)); }
.brand { display: flex; align-items: center; gap: 10px; }
.wordmark { font-family: var(--font-serif); font-size: 21px; color: var(--green); font-weight: 500; display: inline-flex; align-items: baseline; }
.wm-sapt { font-family: var(--font-deva); font-size: 1.12em; }
.wm-alpha { font-style: italic; margin-left: 0.16em; }
.brand small { display: block; font-size: 11px; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.nav-links { display: flex; gap: 22px; font-size: 13.5px; font-weight: 500; }
.nav-links a { color: var(--body-text); }
.nav-links a.active { color: var(--gold); font-weight: 600; }
.nav-right { display: flex; align-items: center; gap: 12px; }

.btn {
  cursor: pointer; border: none; font-family: var(--font-sans); font-size: 13.5px;
  border-radius: var(--radius-pill); padding: 11px 24px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-hover) ease, border-color var(--dur-hover) ease, box-shadow var(--dur-hover) ease, color var(--dur-hover) ease;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(var(--press)); }
.btn-dark { background: var(--green); color: var(--inverse); }
.btn-ghost { background: transparent; border: 1px solid var(--line-medium); color: var(--body-text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.hero {
  padding: 56px 0 28px;
  position: relative;
}
.hero h1 {
  font-family: var(--font-serif); font-size: clamp(36px, 5vw, 56px); line-height: 1.1;
  font-weight: 500; color: var(--green); letter-spacing: -0.02em; max-width: 16ch; text-wrap: balance;
}
.hero h1 em { font-style: italic; }
.hero .lead { margin: 16px 0 0; max-width: 48ch; font-size: 16px; color: var(--body-text); }
.studio-switch {
  display: inline-flex; gap: 4px; padding: 4px; background: var(--cream2);
  border: 1px solid var(--line); border-radius: var(--radius-pill); margin-top: 28px;
}
.studio-switch button {
  border: 0; background: transparent; font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  color: var(--muted); padding: 8px 16px; border-radius: var(--radius-pill); cursor: pointer;
  transition: background-color var(--dur-hover) ease, color var(--dur-hover) ease, transform var(--dur-press) var(--ease-out);
}
.studio-switch button.active { background: var(--green); color: var(--inverse); }
.studio-switch button:active { transform: scale(var(--press)); }

.studio { display: none; padding: 8px 0 72px; }
.studio.on { display: block; }
.studio-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(0, 1.18fr);
  gap: 28px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 22px 22px 24px;
}
.panel h2 {
  font-family: var(--font-serif); font-size: 26px; font-weight: 500; color: var(--green);
  letter-spacing: -0.02em; margin-bottom: 6px;
}
.panel .sub { font-size: 13.5px; color: var(--muted); margin-bottom: 20px; max-width: 48ch; }

.ctrl { margin-bottom: 18px; }
.ctrl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.ctrl label { font-size: 12.5px; font-weight: 600; color: var(--green); }
.ctrl .val {
  font-family: var(--font-serif); font-size: 18px; color: var(--green);
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  width: 100%; height: 6px; border-radius: 3px; background: #e2decb;
  accent-color: var(--green); cursor: pointer;
}
.bounds { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--dim); margin-top: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chips button, .ex-chip {
  border: 1px solid var(--line-medium); background: var(--cream3); border-radius: var(--radius-sm);
  padding: 5px 10px; font-size: 11.5px; font-family: var(--font-sans); font-weight: 600;
  cursor: pointer; color: var(--body-text);
  transition: background-color var(--dur-hover) ease, color var(--dur-hover) ease, border-color var(--dur-hover) ease, transform var(--dur-press) var(--ease-out);
}
.chips button.active, .ex-chip.on {
  background: var(--green); color: var(--inverse); border-color: var(--green);
}
.chips button:active, .ex-chip:active { transform: scale(var(--press)); }

.answer {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.answer .kicker { font-size: 12px; letter-spacing: 0.02em; color: var(--muted); font-weight: 700; }
.answer .num {
  font-family: var(--font-serif); font-size: 40px; line-height: 1.1; color: var(--green);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em; margin: 6px 0 8px;
}
.answer .num.up { color: var(--accent-emerald); }
.answer p { font-size: 13.5px; color: var(--body-text); max-width: 54ch; }

.chart-box {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 8px 8px;
  margin-bottom: 16px;
}
.chart-box svg { display: block; width: 100%; height: 220px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); padding: 0 8px 8px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.legend .mf i { background: #8A3A32; }
.legend .di i { background: var(--accent-emerald); }

table.sheet { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 16px; }
table.sheet th {
  text-align: left; font-size: 11.5px; letter-spacing: 0.02em;
  color: var(--muted); font-weight: 700; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line);
}
table.sheet td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--line); color: var(--body-text); }
table.sheet td.num, table.sheet th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 12.5px; }
table.sheet td.up { color: var(--accent-emerald); font-weight: 600; }

.note { font-size: 12px; color: var(--muted); line-height: 1.5; max-width: 62ch; }
.formula {
  font-family: var(--font-mono); font-size: 12px; background: var(--cream2);
  border-radius: 8px; padding: 10px 12px; color: var(--green); margin: 12px 0;
}

.harvest-years { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; align-items: end; height: 120px; margin: 8px 0 16px; }
.harvest-years span {
  display: block; background: var(--gold); border-radius: 3px 3px 0 0; min-height: 8px;
  opacity: 0.35;
}
.harvest-years span.on { opacity: 1; background: var(--accent-emerald); }

.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.drawer {
  position: fixed; inset: 0; z-index: 80; display: none;
}
.drawer.on { display: block; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(13, 22, 20, 0.38); }
.drawer-panel {
  position: absolute; right: 0; top: 0; height: 100%; width: min(440px, 100%);
  background: var(--cream); padding: 28px 24px 32px;
  box-shadow: var(--shadow-elevated);
  transform: translateX(8%);
  opacity: 0;
  transition: transform 380ms var(--ease-drawer), opacity 280ms var(--ease-out);
  overflow: auto;
}
.drawer.on .drawer-panel { transform: translateX(0); opacity: 1; }
.drawer-panel h3 { font-family: var(--font-serif); font-size: 28px; font-weight: 500; color: var(--green); margin: 8px 0 8px; }
.drawer-panel p { font-size: 14px; color: var(--body-text); margin-bottom: 20px; max-width: 40ch; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line-medium); border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 14px; color: var(--green); background: var(--surface); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-tint); }
.field .err { display: none; font-size: 12px; color: var(--rose); margin-top: 4px; }
.field.bad input, .field.bad select { border-color: var(--rose); }
.field.bad .err { display: block; }
.drawer-close {
  position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line-medium); background: var(--surface); cursor: pointer; font-size: 18px; color: var(--green);
}
.ok-state { display: none; }
.ok-state.on { display: block; }
.form-state.hide { display: none; }

footer {
  background: var(--deep); color: var(--inverse-muted); padding: 36px 0 28px; margin-top: 24px;
}
footer .foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12.5px; }
footer a { color: var(--gold-light); }

@media (max-width: 1024px) {
  .studio-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}
@media (max-width: 768px) {
  .wrap, .nav-in { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .hero { padding-top: 36px; }
  .hero h1 { font-size: 32px; }
  .answer .num { font-size: 32px; }
  .harvest-years { grid-template-columns: repeat(5, 1fr); }
}
@media (hover: hover) and (pointer: fine) {
  .btn-dark:hover { background: var(--green2); box-shadow: var(--shadow-md); }
  .btn-ghost:hover { background: var(--surface-soft); border-color: var(--sage-border); }
  .nav-links a:hover { color: var(--green); }
}
@media (prefers-reduced-motion: reduce) {
  .drawer-panel, .btn, .studio-switch button { transition: none; }
}
