:root {
  color-scheme: light;
  --ink: #233932;
  --muted: #60736b;
  --paper: #f5f5ed;
  --panel: #fffef9;
  --border: #dce2d8;
  --teal: #19745f;
  --blue: #517ca9;
  --risk: #b75f3c;
  --shadow: 0 8px 30px #1b3f2410;
  font:
    15px/1.55 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
summary,
textarea {
  outline-offset: 4px;
}
button,
select,
input,
textarea {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
}
button {
  cursor: pointer;
  padding: 0.5rem 0.8rem;
  min-height: 42px;
}
button:hover {
  background: #e8efe5;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
a {
  color: var(--teal);
}
p {
  margin: 0.4rem 0 1rem;
}
h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.03em;
}
h1 {
  font-size: 2.5rem;
  margin: 0.2rem 0 0.5rem;
  font-weight: 650;
}
h2 {
  font-size: 1.25rem;
  margin: 0.2rem 0 0.8rem;
}
h3 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.5rem;
}
.app-shell {
  max-width: 1700px;
  margin: auto;
  padding: 24px 32px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.eyebrow {
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.topbar .actions {
  justify-content: flex-end;
}
.mode-bar {
  margin: 12px 0;
}
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.segmented button {
  border-color: transparent;
  background: transparent;
}
.segmented button[aria-selected="true"] {
  background: var(--teal);
  color: white;
}
.mode-bar .segmented {
  width: fit-content;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
#status {
  color: var(--muted);
  min-height: 1.2em;
  font-size: 0.86rem;
  margin: 0.4rem 0;
}
.workspace {
  display: grid;
  grid-template-columns: 265px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.input-rail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  scroll-margin-top: 15px;
}
.input-rail label {
  display: grid;
  gap: 5px;
  font-size: 0.9rem;
  margin: 12px 0;
}
.input-rail input,
.input-rail select,
.input-rail textarea {
  width: 100%;
  min-width: 0;
  padding: 9px;
}
.input-rail select {
  font-size: 0.84rem;
}
.field-note,
details p {
  font-size: 0.81rem;
  color: var(--muted);
}
details {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
summary {
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 16px 0;
}
legend {
  font-size: 0.9rem;
  font-weight: 600;
}
#conditions label {
  display: flex;
  align-items: start;
  gap: 8px;
  font-size: 0.82rem;
}
#conditions input {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  padding: 0;
  margin: 3px 0;
}
textarea {
  resize: vertical;
}
.results {
  min-width: 0;
}
.notice {
  padding: 12px 16px;
  border-radius: 8px;
  background: #eaf0e4;
  font-size: 0.9rem;
}
.notice.error {
  background: #fae9e0;
  color: #833719;
}
.chart-panel {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel-heading p,
.chart-caption {
  color: var(--muted);
  font-size: 0.84rem;
}
.chart-caption {
  margin: 8px 0 0;
}
.primary-chart {
  width: 100%;
  height: 310px;
  display: block;
}
.chart {
  width: 100%;
  height: 290px;
  display: block;
}
.metrics-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--border);
  margin: 16px 0;
}
.metric {
  background: var(--panel);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.metric span {
  font-size: 0.79rem;
  color: var(--muted);
}
.metric strong {
  font-size: 1.35rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}
.hero strong {
  font-size: 1.9rem;
  color: var(--teal);
}
.view-tabs {
  margin: 18px 0 12px;
}
.chart-label {
  fill: var(--muted);
  font-size: 10px;
}
.chart-bar {
  fill: var(--teal);
  opacity: 0.85;
}
.grid-line {
  stroke: #dce2d8;
  stroke-width: 1;
}
.interval-band {
  fill: #c4dbc9;
  opacity: 0.5;
}
.interval-band.wide {
  fill: #e5ecdf;
  opacity: 0.8;
}
.median-line {
  stroke: #aa663f;
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}
.line-teal,
.line-blue,
.line-risk,
.line-muted,
.calibration-diagonal {
  fill: none;
  stroke-width: 2;
}
.line-teal {
  stroke: var(--teal);
}
.line-blue {
  stroke: var(--blue);
}
.line-risk {
  stroke: var(--risk);
}
.line-muted {
  stroke: var(--muted);
  stroke-dasharray: 4 3;
}
.calibration-diagonal {
  stroke: #9fac9d;
  stroke-dasharray: 4 4;
}
.calibration-point {
  fill: var(--teal);
}
.calibration-whisker {
  stroke: var(--teal);
  opacity: 0.6;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.87rem;
}
th,
td {
  text-align: right;
  border-bottom: 1px solid var(--border);
  padding: 9px 7px;
  font-variant-numeric: tabular-nums;
}
th:first-child,
td:first-child {
  text-align: left;
}
th {
  color: var(--muted);
  font-weight: 500;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  background: var(--paper);
  padding: 12px;
}
.weeks-row {
  display: grid;
  grid-template-columns: 34px repeat(52, minmax(0, 1fr));
  gap: 2px;
  align-items: center;
  margin: 3px 0;
}
.weeks-row span {
  font-size: 9px;
  color: var(--muted);
}
.week {
  height: 7px;
  border-radius: 1px;
}
.weeks-legend {
  font-size: 0.8rem;
}
.lived-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #5c655e;
  margin-right: 4px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
footer {
  border-top: 1px solid var(--border);
  margin-top: 26px;
  padding-top: 16px;
  color: var(--muted);
  font-size: 0.8rem;
  max-width: 100%;
}
@media (min-width: 1450px) {
  .primary-chart {
    height: 380px;
  }
  .metrics-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .app-shell {
    padding: 20px;
  }
  .workspace {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
  }
  .input-rail {
    padding: 15px;
  }
  .topbar {
    align-items: start;
  }
  .topbar .actions {
    max-width: 240px;
  }
  .chart-panel {
    padding: 16px;
  }
  .metrics-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 680px) {
  .app-shell {
    padding: 16px 12px;
  }
  .topbar {
    display: block;
  }
  .topbar .actions {
    max-width: none;
    justify-content: flex-start;
    font-size: 0.8rem;
  }
  .topbar h1 {
    font-size: 2rem;
  }
  .eyebrow {
    font-size: 0.65rem;
  }
  .topbar p {
    font-size: 0.8rem;
  }
  .mode-bar .segmented {
    width: 100%;
  }
  .mode-bar button {
    flex: 1;
    font-size: 0.78rem;
    padding: 7px 5px;
  }
  .workspace {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  .results {
    order: 0;
    width: 100%;
  }
  .input-rail {
    order: 1;
    width: 100%;
  }
  .primary-chart {
    height: 255px;
  }
  .chart {
    height: 250px;
  }
  .metric {
    padding: 11px 12px;
  }
  .metric strong {
    font-size: 1.2rem;
  }
  .view-tabs {
    gap: 2px;
  }
  .view-tabs button {
    font-size: 0.8rem;
    padding: 5px 9px;
  }
  .notice {
    font-size: 0.81rem;
    padding: 10px 12px;
  }
  .weeks-row {
    grid-template-columns: 25px repeat(52, minmax(0, 1fr));
    gap: 1px;
  }
  .week {
    height: 5px;
  }
  .chart-label {
    font-size: 9px;
  }
  .chart-panel {
    padding: 14px;
  }
}

@media (max-width: 900px) {
  .metric.hero {
    grid-column: 1 / -1;
  }
}

.lifetime-results {
  border: 0;
  padding: 0;
  margin: 0;
}
.lifetime-results.optional {
  margin: 18px 0;
}
.risk-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.risk-metrics .metric {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
#riskDifference {
  font-size: 1.1rem;
}
#associationInterpretation {
  font-size: 0.88rem;
  margin-bottom: 0;
}
@media (max-width: 900px) {
  .risk-metrics {
    grid-template-columns: 1fr 1fr;
  }
  .risk-metrics .hero {
    grid-column: 1 / -1;
  }
}
