:root {
  --bg: #0d0e10;
  --ink: #ebe8e2;
  --ink-75: rgba(235, 232, 226, 0.75);
  --ink-55: rgba(235, 232, 226, 0.55);
  --ink-40: rgba(235, 232, 226, 0.4);
  --ink-25: rgba(235, 232, 226, 0.25);
  --hairline: rgba(235, 232, 226, 0.12);
  --fill: rgba(235, 232, 226, 0.05);
  --fill-strong: rgba(235, 232, 226, 0.08);
  --accent: #9ccbd8;
  --accent-fill: rgba(156, 203, 216, 0.1);
  --font-display: "Newsreader", Georgia, serif;
  --font-body: "Hanken Grotesk", "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", monospace;
  --page: 1240px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 300;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 300;
  line-height: 1.04;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(3.1rem, 7.4vw, 6.3rem);
  max-width: 11ch;
}

h2 {
  font-size: clamp(1.9rem, 3.4vw, 2.7rem);
}

h3 {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.mono,
.mono-label,
.step-number,
.pill,
.btn,
.topbar-note,
.wordmark,
.eyebrow,
th,
.legend,
.file-meta,
.header-control,
.field > span,
.field-note,
.big-number,
.summary-sub,
.wf-value,
.mix-number,
.slider-number,
.method-note,
.footer-mono,
.report-meta {
  font-family: var(--font-mono);
}

.mono-label,
.step-number,
.eyebrow {
  font-size: 0.64rem;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-40);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: var(--page);
  margin: 0 auto;
  padding: 26px 32px 22px;
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.wordmark span {
  color: var(--accent);
  padding: 0 2px;
}

.topbar-note {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-40);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.status-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border: 1px solid var(--accent);
  border-radius: 50%;
}

.page {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 32px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.5fr);
  gap: 72px;
  align-items: end;
  padding: 78px 0 64px;
}

.eyebrow {
  margin-bottom: 24px;
}

.lede {
  max-width: 64ch;
  margin-top: 28px;
  color: var(--ink-75);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  line-height: 1.6;
}

.hero-formula {
  border-left: 1px solid var(--hairline);
  padding-left: 26px;
  padding-bottom: 5px;
}

.formula {
  margin-top: 18px;
  color: var(--ink-75);
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.25;
}

.formula span {
  color: var(--accent);
}

.formula-note {
  margin-top: 20px;
  max-width: 31ch;
  color: var(--ink-40);
  font-size: 0.78rem;
  line-height: 1.5;
}

.step {
  padding: 52px 0 58px;
  border-top: 1px solid var(--hairline);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.section-head > div:first-child {
  min-width: 0;
}

.step-number {
  margin-bottom: 13px;
}

.section-intro {
  max-width: 73ch;
  margin-bottom: 30px;
  color: var(--ink-55);
  font-size: 0.98rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--hairline);
  border-radius: 0;
  background: transparent;
  color: var(--ink-75);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.btn:hover,
.btn:focus-visible {
  border-color: var(--ink-55);
  color: var(--ink);
  outline: none;
}

.btn-accent {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
  padding: 14px 21px;
}

.btn-accent:hover,
.btn-accent:focus-visible {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.btn-quiet {
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink-55);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--hairline);
  text-underline-offset: 3px;
}

.text-button:hover,
.text-button:focus-visible {
  color: var(--accent);
  outline: none;
}

/* Upload */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.upload-card {
  padding: 20px;
  border: 1px solid var(--hairline);
  background: var(--fill);
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 4px 8px;
  border: 1px solid var(--hairline);
  color: var(--ink-55);
  font-size: 0.56rem;
  line-height: 1.3;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill-accent {
  border-color: rgba(156, 203, 216, 0.45);
  color: var(--accent);
}

.pill-warn {
  border-color: rgba(235, 232, 226, 0.28);
  color: var(--ink-75);
}

.dropzone {
  display: flex;
  min-height: 174px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px dashed rgba(235, 232, 226, 0.2);
  color: var(--ink-55);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.dropzone:hover,
.dropzone:focus-within,
.upload-card.drag-over .dropzone {
  border-color: var(--accent);
  background: var(--accent-fill);
  color: var(--ink-75);
}

.drop-arrow {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 1.2rem;
  line-height: 1;
  margin-bottom: 5px;
}

.drop-title {
  font-size: 0.94rem;
}

.drop-sub {
  color: var(--ink-40);
  font-size: 0.75rem;
}

.file-meta {
  min-height: 20px;
  margin-top: 12px;
  color: var(--ink-55);
  font-size: 0.65rem;
  line-height: 1.5;
}

.header-control {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 8px;
  color: var(--ink-40);
  font-size: 0.58rem;
  letter-spacing: 0.04em;
}

.header-control select {
  border: 0;
  border-bottom: 1px solid var(--hairline);
  padding: 4px 0;
  background: transparent;
  color: var(--ink-55);
  font-size: 0.58rem;
  cursor: pointer;
}

.header-detect {
  margin-left: auto;
  color: var(--ink-40);
  font-size: 0.55rem;
  text-align: right;
}

.header-detect.detected {
  color: var(--accent);
}

.inline-status {
  min-height: 20px;
  margin-top: 16px;
  color: var(--ink-40);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.03em;
}

.inline-status.is-error {
  color: var(--accent);
}

/* Setup */
.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.1fr) minmax(0, 0.85fr);
  gap: 18px;
}

.field-card {
  min-width: 0;
  margin: 0;
  padding: 22px;
  border: 1px solid var(--hairline);
  background: var(--fill);
}

.field-card legend {
  padding: 0 6px 0 0;
  color: var(--ink-75);
  font-family: var(--font-mono);
  font-size: 0.63rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.field {
  display: block;
  margin-top: 17px;
}

.field:first-of-type {
  margin-top: 8px;
}

.field > span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-55);
  font-size: 0.58rem;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.field > span em {
  color: var(--ink-40);
  font-style: normal;
  text-transform: none;
}

.field select,
.field input[type="number"] {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 0;
  padding: 10px 11px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.82rem;
  outline: none;
}

.field select:focus,
.field input[type="number"]:focus {
  border-color: var(--accent);
}

.field select:disabled,
.field input:disabled {
  opacity: 0.45;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-note {
  margin-top: 13px;
  color: var(--ink-40);
  font-size: 0.61rem;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

.field-note .mono {
  color: var(--ink-55);
}

.segmented {
  display: flex;
  border: 1px solid var(--hairline);
}

.segmented button {
  flex: 1;
  border: 0;
  border-right: 1px solid var(--hairline);
  padding: 10px 9px;
  background: transparent;
  color: var(--ink-40);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button[aria-pressed="true"] {
  background: var(--accent-fill);
  color: var(--accent);
}

.segmented button:hover,
.segmented button:focus-visible {
  color: var(--ink);
  outline: none;
}

.segmented-small button {
  padding: 8px 10px;
  font-size: 0.55rem;
}

.ordinal-list {
  display: grid;
  gap: 6px;
  margin-top: 7px;
}

.ordinal-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
  align-items: center;
}

.ordinal-row span {
  overflow: hidden;
  color: var(--ink-75);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ordinal-row input {
  width: 72px;
  border: 1px solid var(--hairline);
  border-radius: 0;
  padding: 6px 7px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.identity-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

.identity-note p:last-child {
  margin-top: 7px;
  color: var(--ink-55);
  font-size: 0.74rem;
  line-height: 1.5;
}

.run-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 26px;
}

.run-note {
  color: var(--ink-40);
  font-family: var(--font-mono);
  font-size: 0.59rem;
  line-height: 1.5;
}

.form-error {
  margin-top: 15px;
  padding: 10px 12px;
  border-left: 1px solid var(--accent);
  background: var(--accent-fill);
  color: var(--ink-75);
  font-size: 0.76rem;
}

.form-warning {
  margin-top: 15px;
  padding: 10px 12px;
  border-left: 1px solid var(--hairline);
  background: var(--fill);
  color: var(--ink-55);
  font-size: 0.74rem;
}

/* Validation */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 20px;
  border: 1px solid var(--hairline);
  background: var(--hairline);
}

.stat-cell {
  padding: 17px 18px;
  background: var(--bg);
}

.stat-cell .mono-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.56rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.stat-sub {
  margin-top: 4px;
  color: var(--ink-40);
  font-size: 0.68rem;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
}

.rule-grid p:last-child {
  margin-top: 8px;
  color: var(--ink-55);
  font-size: 0.8rem;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-top: 1px solid var(--hairline);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.data-table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-40);
  font-size: 0.55rem;
  font-weight: 400;
  letter-spacing: 0.07em;
  text-align: right;
  text-transform: uppercase;
}

.data-table th:first-child,
.data-table td:first-child {
  padding-left: 0;
  text-align: left;
}

.data-table th:last-child,
.data-table td:last-child {
  padding-right: 0;
}

.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(235, 232, 226, 0.07);
  color: var(--ink-75);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-align: right;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table td.group-cell {
  max-width: 270px;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-overflow: ellipsis;
}

.data-table td.flag-cell {
  text-align: left;
}

.flag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.flag {
  display: inline-block;
  padding: 2px 5px;
  border: 1px solid rgba(235, 232, 226, 0.18);
  color: var(--ink-55);
  font-family: var(--font-mono);
  font-size: 0.52rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.flag-accent {
  border-color: rgba(156, 203, 216, 0.4);
  color: var(--accent);
}

.data-table .em-dash {
  color: var(--ink-25);
}

.data-table .total-row td {
  border-top: 1px solid var(--hairline);
  color: var(--ink);
}

.mono-neg {
  color: var(--accent);
}

/* Results */
.results-step {
  padding-top: 44px;
}

.report-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding: 18px 0 20px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.report-head h3 {
  margin-top: 7px;
  font-size: 1.55rem;
}

.report-meta {
  margin-top: 7px;
  color: var(--ink-40);
  font-size: 0.58rem;
  letter-spacing: 0.02em;
}

.report-note {
  max-width: 37ch;
  color: var(--ink-40);
  font-size: 0.7rem;
  text-align: right;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--hairline);
  background: var(--hairline);
}

.summary-card {
  min-width: 0;
  padding: 20px 21px 19px;
  background: var(--bg);
}

.summary-card .mono-label {
  display: block;
  margin-bottom: 13px;
  font-size: 0.56rem;
}

.big-number {
  color: var(--ink);
  font-size: clamp(2rem, 3.3vw, 3.1rem);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.055em;
  white-space: nowrap;
}

.summary-change .big-number {
  color: var(--accent);
}

.summary-sub {
  margin-top: 8px;
  color: var(--ink-40);
  font-size: 0.59rem;
  line-height: 1.5;
}

.decomp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.decomp-card {
  min-width: 0;
  padding: 21px;
  border: 1px solid var(--hairline);
  background: var(--fill);
}

.accent-card {
  border-left: 2px solid var(--accent);
  background: var(--accent-fill);
}

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

.decomp-card .big-number {
  font-size: clamp(2.1rem, 4vw, 3.4rem);
}

.decomp-card .summary-sub {
  color: var(--ink-55);
}

.decomp-copy {
  max-width: 46ch;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--hairline);
  color: var(--ink-40);
  font-size: 0.76rem;
}

.bootstrap-status {
  margin-top: 12px;
  color: var(--ink-40);
  font-family: var(--font-mono);
  font-size: 0.57rem;
  letter-spacing: 0.02em;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.lower-grid {
  margin-top: 18px;
}

.panel {
  min-width: 0;
  padding: 21px;
  border: 1px solid var(--hairline);
  background: var(--fill);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.panel-head h3 {
  margin-top: 6px;
  font-size: 1.3rem;
}

.panel-note {
  max-width: 30ch;
  color: var(--ink-40);
  font-size: 0.65rem;
  text-align: right;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--ink-40);
  font-size: 0.53rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 4px;
}

.swatch-composition {
  background: var(--accent);
}

.swatch-within {
  background: var(--ink-55);
}

.swatch-wave1 {
  background: var(--ink-40);
}

.swatch-wave2 {
  background: var(--accent);
}

/* Waterfall */
.waterfall {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.wf-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 64px;
  gap: 11px;
  align-items: center;
  min-height: 43px;
}

.wf-label {
  color: var(--ink-55);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.03em;
  line-height: 1.35;
}

.wf-row.is-endpoint .wf-label {
  color: var(--ink-75);
}

.wf-track {
  position: relative;
  height: 22px;
  border-left: 1px solid var(--hairline);
  background: rgba(235, 232, 226, 0.025);
  overflow: hidden;
}

.wf-track::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: rgba(235, 232, 226, 0.06);
  content: "";
}

.wf-bar {
  position: absolute;
  top: 3px;
  bottom: 3px;
  min-width: 2px;
  background: var(--ink-40);
}

.wf-bar.composition {
  background: var(--accent);
}

.wf-bar.within {
  background: var(--ink-55);
}

.wf-bar.absolute {
  background: rgba(235, 232, 226, 0.3);
}

.wf-value {
  color: var(--ink-75);
  font-size: 0.62rem;
  text-align: right;
}

.wf-value.strong {
  color: var(--ink);
}

.chart-note {
  margin-top: 16px;
  color: var(--ink-40);
  font-size: 0.65rem;
  line-height: 1.55;
}

/* Mix bars */
.mix-bars {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.mix-row {
  display: grid;
  grid-template-columns: minmax(76px, 0.9fr) minmax(0, 2.2fr) 52px;
  gap: 11px;
  align-items: center;
}

.mix-label {
  overflow: hidden;
  color: var(--ink-75);
  font-size: 0.73rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mix-label small {
  display: block;
  overflow: hidden;
  color: var(--ink-40);
  font-family: var(--font-mono);
  font-size: 0.51rem;
  text-overflow: ellipsis;
}

.mix-tracks {
  display: grid;
  gap: 4px;
}

.mix-track {
  position: relative;
  height: 7px;
  background: rgba(235, 232, 226, 0.04);
}

.mix-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 1px;
}

.mix-bar.w1 {
  background: var(--ink-40);
}

.mix-bar.w2 {
  background: var(--accent);
}

.mix-number {
  color: var(--ink-55);
  font-size: 0.55rem;
  line-height: 1.45;
  text-align: right;
  white-space: nowrap;
}

.mix-number strong {
  color: var(--ink-75);
  font-weight: 400;
}

/* Counterfactual */
.cf-readout {
  display: flex;
  align-items: baseline;
  gap: 13px;
  min-height: 73px;
  padding: 15px 0 13px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.cf-number {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: clamp(1.9rem, 3.2vw, 2.8rem);
  letter-spacing: -0.05em;
  line-height: 1;
  white-space: nowrap;
}

.cf-delta {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.45;
}

.cf-caption {
  margin-top: 9px;
  color: var(--ink-55);
  font-size: 0.72rem;
  line-height: 1.5;
}

.cf-readout-compact {
  min-height: 61px;
  margin-top: 16px;
  padding: 12px 0;
}

.cf-readout-compact .cf-number {
  font-size: 2rem;
}

.mix-actions {
  display: flex;
  gap: 11px;
  padding-top: 3px;
}

.sliders {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-row {
  display: grid;
  grid-template-columns: minmax(74px, 0.9fr) minmax(0, 2fr) 43px;
  gap: 10px;
  align-items: center;
}

.slider-label {
  overflow: hidden;
  color: var(--ink-55);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slider-row input[type="range"] {
  width: 100%;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.slider-number {
  color: var(--ink-40);
  font-size: 0.55rem;
  text-align: right;
  white-space: nowrap;
}

/* Explanation */
.explanation-panel {
  margin-top: 18px;
  padding-bottom: 23px;
}

.explanation p {
  max-width: 87ch;
  margin-top: 12px;
  color: var(--ink-75);
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  line-height: 1.42;
  letter-spacing: -0.01em;
}

.explanation p:first-child {
  margin-top: 0;
}

.caveats {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

.caveats p {
  position: relative;
  max-width: 98ch;
  padding-left: 13px;
  color: var(--ink-40);
  font-size: 0.7rem;
  line-height: 1.55;
}

.caveats p::before {
  position: absolute;
  top: 0.66em;
  left: 0;
  width: 4px;
  height: 1px;
  background: var(--ink-40);
  content: "";
}

.caveats p + p {
  margin-top: 6px;
}

.table-panel {
  margin-top: 18px;
}

.method-note {
  margin: 20px 0 0;
  color: var(--ink-40);
  font-size: 0.55rem;
  line-height: 1.6;
}

/* Footer */
.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  max-width: var(--page);
  margin: 40px auto 0;
  padding: 20px 32px 32px;
  border-top: 1px solid var(--hairline);
  color: var(--ink-40);
  font-size: 0.68rem;
}

.footer-mono {
  font-size: 0.54rem;
  letter-spacing: 0.08em;
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.65fr);
    gap: 40px;
    padding-top: 58px;
  }

  .setup-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-card:last-child {
    grid-column: 1 / -1;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .topbar {
    padding: 20px 19px 17px;
  }

  .topbar-note {
    display: none;
  }

  .page {
    padding: 0 19px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 34px;
    padding: 50px 0 44px;
  }

  h1 {
    font-size: clamp(2.85rem, 15vw, 4.6rem);
  }

  .hero-formula {
    border-top: 1px solid var(--hairline);
    border-left: 0;
    padding-top: 22px;
    padding-left: 0;
  }

  .formula {
    font-size: 1.3rem;
  }

  .formula-note {
    max-width: 44ch;
  }

  .step {
    padding: 38px 0 42px;
  }

  .section-head {
    flex-direction: column;
    gap: 15px;
  }

  .section-head .btn {
    align-self: flex-start;
  }

  .upload-grid,
  .setup-grid,
  .decomp-grid,
  .rule-grid,
  .summary-grid,
  .stat-strip {
    grid-template-columns: 1fr;
  }

  .field-card:last-child {
    grid-column: auto;
  }

  .upload-card,
  .field-card {
    padding: 17px;
  }

  .dropzone {
    min-height: 140px;
  }

  .header-control {
    flex-wrap: wrap;
  }

  .header-detect {
    flex-basis: 100%;
    margin-left: 0;
    text-align: left;
  }

  .run-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .run-row .btn {
    width: 100%;
  }

  .summary-grid {
    gap: 1px;
  }

  .summary-card {
    padding: 17px;
  }

  .summary-card .big-number {
    font-size: 2.3rem;
  }

  .report-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
  }

  .report-note {
    max-width: none;
    text-align: left;
  }

  .export-actions {
    width: 100%;
  }

  .export-actions .btn {
    flex: 1;
  }

  .panel,
  .decomp-card {
    padding: 17px;
  }

  .panel-head {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
  }

  .panel-note {
    max-width: none;
    text-align: left;
  }

  .legend {
    gap: 9px;
  }

  .wf-row {
    grid-template-columns: 78px minmax(0, 1fr) 54px;
    gap: 7px;
  }

  .wf-label {
    font-size: 0.52rem;
  }

  .wf-value {
    font-size: 0.55rem;
  }

  .mix-row {
    grid-template-columns: 80px minmax(0, 1fr) 44px;
    gap: 7px;
  }

  .mix-label {
    font-size: 0.67rem;
  }

  .mix-number {
    font-size: 0.5rem;
  }

  .slider-row {
    grid-template-columns: 76px minmax(0, 1fr) 38px;
    gap: 7px;
  }

  .cf-readout {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .cf-number {
    font-size: 2.1rem;
  }

  .explanation p {
    font-size: 1.18rem;
  }

  .data-table th,
  .data-table td {
    padding-right: 9px;
    padding-left: 9px;
  }

  .data-table th:first-child,
  .data-table td:first-child {
    padding-left: 0;
  }

  .data-table td.group-cell {
    max-width: 150px;
  }

  .site-footer {
    flex-direction: column;
    gap: 8px;
    padding: 18px 19px 28px;
  }

  .footer-mono {
    line-height: 1.5;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

/* Print: a clean, light report */
@media print {
  @page {
    size: A4;
    margin: 15mm 15mm 16mm;
  }

  :root {
    --bg: #ffffff;
    --ink: #17191b;
    --ink-75: #35393c;
    --ink-55: #575c60;
    --ink-40: #74797d;
    --ink-25: #aeb2b5;
    --hairline: #cfd2d4;
    --fill: #f7f7f6;
    --fill-strong: #eeeeec;
    --accent: #9ccbd8;
    --accent-fill: #eef5f6;
  }

  html,
  body {
    background: #fff !important;
    color: #17191b;
    font-size: 10pt;
  }

  body {
    overflow: visible;
  }

  .topbar,
  .hero,
  .no-print,
  .site-footer,
  .bootstrap-status,
  .export-actions {
    display: none !important;
  }

  .page {
    max-width: none;
    padding: 0;
  }

  .results-step {
    display: block !important;
    padding: 0;
    border: 0;
  }

  .results-step .section-head {
    display: none;
  }

  .report-head {
    margin-bottom: 14pt;
    padding: 0 0 10pt;
    border-top: 0;
    border-bottom: 1pt solid #cfd2d4;
  }

  .report-head h3 {
    font-size: 21pt;
  }

  .report-note {
    color: #575c60;
    font-size: 8pt;
  }

  .summary-grid {
    border-color: #cfd2d4;
    background: #cfd2d4;
  }

  .summary-card {
    padding: 9pt 10pt;
    background: #fff;
  }

  .summary-card .big-number {
    font-size: 21pt;
    color: #17191b !important;
  }

  .summary-card .mono-label,
  .decomp-card .mono-label,
  .panel .mono-label {
    color: #74797d;
  }

  .summary-change .big-number {
    color: #17191b !important;
  }

  .summary-sub {
    color: #74797d;
  }

  .decomp-grid,
  .chart-grid,
  .lower-grid,
  .panel,
  .table-panel,
  .explanation-panel {
    break-inside: avoid;
  }

  .decomp-grid,
  .chart-grid,
  .lower-grid,
  .explanation-panel,
  .table-panel {
    margin-top: 9pt;
  }

  .decomp-card,
  .panel {
    padding: 9pt 10pt;
    border-color: #cfd2d4 !important;
    background: #fff !important;
  }

  .accent-card {
    border-left: 2pt solid #9ccbd8 !important;
    background: #eef5f6 !important;
  }

  .decomp-card .big-number {
    font-size: 20pt;
  }

  .decomp-copy,
  .chart-note,
  .caveats p,
  .method-note {
    color: #575c60;
  }

  .explanation p {
    color: #35393c;
    font-size: 12.5pt;
  }

  .bootstrap-status {
    display: none;
  }

  .chart-grid {
    grid-template-columns: 1fr 1fr;
    gap: 9pt;
  }

  .lower-grid {
    grid-template-columns: 1fr;
  }

  .lower-grid .panel.no-print {
    display: none !important;
  }

  .panel-head {
    margin-bottom: 9pt;
  }

  .panel-head h3 {
    font-size: 12pt;
  }

  .legend {
    color: #74797d;
  }

  .wf-row {
    min-height: 17pt;
    grid-template-columns: 72pt minmax(0, 1fr) 48pt;
  }

  .wf-label {
    font-size: 7pt;
    color: #575c60;
  }

  .wf-value {
    font-size: 7pt;
    color: #35393c;
  }

  .wf-track {
    height: 12pt;
    border-color: #cfd2d4;
    background: #f2f2f0;
  }

  .wf-bar {
    top: 2pt;
    bottom: 2pt;
  }

  .wf-bar.composition {
    background: #9ccbd8;
  }

  .wf-bar.within {
    background: #777d80;
  }

  .wf-bar.absolute {
    background: #aeb2b5;
  }

  .mix-label {
    color: #35393c;
    font-size: 8pt;
  }

  .mix-label small,
  .mix-number,
  .chart-note,
  .method-note {
    color: #74797d;
    font-size: 6.5pt;
  }

  .mix-number strong {
    color: #35393c;
  }

  .mix-bar.w1 {
    background: #aeb2b5;
  }

  .mix-bar.w2 {
    background: #9ccbd8;
  }

  .cf-readout {
    min-height: 0;
    border-color: #cfd2d4;
  }

  .cf-number {
    font-size: 18pt;
  }

  .cf-delta {
    color: #575c60;
  }

  .explanation-panel {
    padding-bottom: 10pt;
  }

  .caveats {
    border-color: #cfd2d4;
  }

  .caveats p {
    font-size: 7.5pt;
  }

  .table-wrap {
    overflow: visible;
  }

  .data-table th {
    color: #74797d;
    font-size: 6.5pt;
  }

  .data-table td {
    padding-top: 5pt;
    padding-bottom: 5pt;
    color: #35393c;
    font-size: 7.5pt;
  }

  .data-table td.group-cell {
    color: #17191b;
    font-size: 8pt;
  }

  .flag {
    border-color: #cfd2d4;
    color: #575c60;
  }

  .table-panel {
    page-break-inside: avoid;
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
