:root {
  --paper: #f3efe6;
  --ink: #1c1916;
  --muted: #6f675f;
  --line: #e3d8cb;
  --card: #fffdf8;
  --rose: #8d2e3c;
  --rose-soft: #f8ece9;
  --pine: #1d5c46;
  --pine-soft: #e6f3ed;
  --shadow: 0 18px 40px rgba(58, 42, 28, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(141, 46, 60, 0.08), transparent 60%),
    var(--paper);
  font-family: Outfit, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.page {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.mast { max-width: 720px; margin-bottom: 28px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--rose);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3 {
  font-family: Fraunces, serif;
  font-weight: 560;
  letter-spacing: -0.03em;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 0.98;
}

h2 { margin: 0; font-size: 1.7rem; }
h3 { margin: 0 0 10px; font-size: 1.15rem; }

.lede, #result-copy { color: var(--muted); }

.lede { margin: 0; font-size: 1.05rem; }

code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92em;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

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

.presets button,
.submit {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.presets button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
}

.presets button:hover { border-color: var(--ink); }

fieldset {
  border: 0;
  margin: 18px 0 0;
  padding: 0;
}

legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.span-2 { grid-column: span 2; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field > span {
  font-size: 0.92rem;
  font-weight: 600;
}

input[type="number"],
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 12px;
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(141, 46, 60, 0.35);
  border-color: var(--rose);
}

.field small { color: var(--muted); font-size: 0.78rem; }

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f6f1e8;
  padding: 4px;
  border-radius: 12px;
}

.segment label {
  text-align: center;
  padding: 9px 8px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 500;
}

.segment input { position: absolute; opacity: 0; pointer-events: none; }

.segment label:has(input:checked) {
  background: white;
  box-shadow: 0 1px 4px rgba(28, 25, 22, 0.08);
}

.form-error {
  margin: 16px 0 0;
  color: var(--rose);
  font-weight: 600;
}

.submit {
  width: 100%;
  margin-top: 16px;
  background: var(--ink);
  color: #f7f2ea;
  border-radius: 14px;
  padding: 14px 16px;
}

.submit:hover { background: #322c27; }
.submit:disabled { opacity: 0.6; cursor: wait; }

.result { position: sticky; top: 18px; }

.result.is-low { background: linear-gradient(180deg, var(--pine-soft), var(--card) 140px); }
.result.is-high { background: linear-gradient(180deg, var(--rose-soft), var(--card) 140px); }

#result-title.is-low { color: var(--pine); }
#result-title.is-high { color: var(--rose); }

.meter-wrap { margin-top: 18px; }

.meter {
  height: 10px;
  border-radius: 999px;
  background: #efe7dc;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  background: var(--rose);
  border-radius: inherit;
}

.result.is-low .meter span { background: var(--pine); }

.meter-label { margin: 8px 0 0; font-weight: 600; }

.neighbors {
  display: flex;
  gap: 8px;
  list-style: none;
  padding: 14px 0 0;
  margin: 0;
}

.neighbors li {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: white;
}

.neighbors li.on {
  background: var(--rose);
  border-color: var(--rose);
}

.result.is-low .neighbors li.on {
  background: var(--pine);
  border-color: var(--pine);
}

#feature-wrap { margin-top: 22px; }

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px 7px 0;
  text-align: left;
  white-space: nowrap;
}

th { color: var(--muted); font-weight: 500; }

@media (max-width: 860px) {
  .layout, .grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .result { position: static; }
  .card-head { flex-direction: column; align-items: flex-start; }
}

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