:root {
  --viewer-ink: #342b1d;
  --viewer-link: #8b5e12;
  --viewer-link-hover: #6f4b0e;
  --viewer-border: #cfcfcf;
  --viewer-line: #dedede;
  --viewer-panel: #f8f8f8;
  --viewer-panel-alt: #f1f1f1;
  --viewer-bg: #ffffff;
  --viewer-success: #c49327;
  --viewer-danger: #9d2a2a;
  --viewer-warning: #8b5e12;
  --viewer-accent: #c49327;
  --viewer-accent-deep: #8b5e12;
  --viewer-accent-soft: rgba(196, 147, 39, 0.14);
  --viewer-accent-soft-strong: rgba(196, 147, 39, 0.22);
  --viewer-complement: #46513b;
  --viewer-complement-soft: #edf0e7;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 62.5%;
}

body {
  margin: 0;
  font-size: 1.5em;
  line-height: 1.6;
  font-weight: 400;
  font-family: "Optima", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--viewer-ink);
  background: var(--viewer-bg);
}

button,
input,
textarea {
  font: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: 0;
  font-weight: 500;
  font-family: "Optima", "Segoe UI", sans-serif;
}

h1 {
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.1rem;
  margin-bottom: 1.6rem;
}

h2 {
  font-size: 3rem;
  line-height: 1.25;
  letter-spacing: -0.1rem;
  margin-bottom: 1.4rem;
}

p {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.page {
  padding: 2.2rem 0 3rem;
}

.container {
  position: relative;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header a {
  color: var(--viewer-link);
  word-break: break-all;
}

.page-header a:hover,
.page-header a:focus {
  color: var(--viewer-link-hover);
}

.card {
  border: 1px solid var(--viewer-line);
  border-radius: 8px;
  padding: 1.4rem;
  background-color: var(--viewer-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.card--soft {
  background-color: var(--viewer-panel-alt);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.muted {
  color: #6f6554;
}

.meta-line {
  font-size: 1.3rem;
  color: #645a49;
}

input,
textarea {
  width: 100%;
  min-height: 4rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--viewer-border);
  border-radius: 6px;
  background: #fff;
  color: var(--viewer-ink);
}

textarea {
  resize: vertical;
  min-height: 16rem;
}

input:focus,
textarea:focus,
button:focus-visible,
.growth-grid__cell:focus-visible {
  outline: 2px solid rgba(196, 147, 39, 0.34);
  outline-offset: 1px;
}

.field-label {
  display: inline-block;
  margin-bottom: 0.4rem;
  color: #5a4c35;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
}

button {
  appearance: none;
  border: 1px solid var(--viewer-border);
  border-radius: 6px;
  padding: 0.8rem 1.2rem;
  background: #fffdf8;
  color: var(--viewer-ink);
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

button:hover,
button:focus {
  border-color: rgba(139, 94, 18, 0.42);
  background: #f7efdb;
}

.button-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
}

.button-primary {
  background: var(--viewer-accent);
  border-color: var(--viewer-accent);
  color: #221a0c;
}

.button-primary:hover,
.button-primary:focus {
  background: #ae7f1e;
  border-color: #ae7f1e;
}

.button-soft-success {
  background: var(--viewer-accent-soft);
  border-color: rgba(196, 147, 39, 0.32);
  color: var(--viewer-accent-deep);
}

.button-soft-success:hover,
.button-soft-success:focus {
  background: var(--viewer-accent-soft-strong);
  border-color: rgba(196, 147, 39, 0.42);
}

.tool-page-stack {
  display: grid;
  gap: 1.6rem;
}

.tool-workspace-grid {
  display: grid;
  gap: 1.6rem;
  align-items: stretch;
}

.tool-setup-card,
.tool-estimate-card,
.likelihood-card {
  height: 100%;
}

.tool-setup-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.calculator-grid-card {
  overflow: hidden;
}

.tool-grid-help {
  display: grid;
  gap: 0.3rem;
  justify-items: end;
  text-align: right;
}

.tool-setup-fields {
  display: grid;
  gap: 0.9rem;
}

.tool-input-field {
  display: block;
}

.hint {
  margin-top: 0.2rem;
  color: #70654a;
  font-size: 1.35rem;
}

.tool-status:empty {
  display: none;
}

.tool-selection {
  min-height: 2.4rem;
}

.metric-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 1rem 0 1.4rem;
}

.metric-card {
  padding: 1rem 1.1rem;
  border: 1px solid #dedede;
  border-radius: 8px;
  background: #fff;
}

.metric-card__label {
  display: block;
  margin-bottom: 0.35rem;
  color: #786e5d;
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.08rem;
}

.metric-card__value {
  font-size: 2rem;
  line-height: 1.2;
}

.summary-export {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.summary-export__header {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.summary-export__actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
}

.summary-export__table-shell {
  overflow-x: auto;
  border: 1px solid #dedede;
  border-radius: 10px;
  background: #f3f3f3;
}

.summary-export__table {
  width: 100%;
  min-width: 540px;
  border-collapse: separate;
  border-spacing: 0;
}

.summary-export__table th,
.summary-export__table td {
  padding: 0.7rem;
  border-bottom: 0;
  background: transparent;
}

.summary-export__table thead th {
  color: #675637;
  font-size: 1.15rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06rem;
}

.summary-export__table td span {
  display: block;
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid #dedede;
  border-radius: 8px;
  background: #fff;
  color: #3a3020;
  font-size: 1.35rem;
  font-weight: 600;
}

.results-export {
  display: grid;
  gap: 0.55rem;
}

.results-export__header {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.likelihood-plot {
  margin-top: 0.2rem;
  padding: 0.8rem;
  border: 1px solid #dedede;
  border-radius: 10px;
  background: transparent;
}

.likelihood-notes {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.2rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid #dedede;
  border-radius: 10px;
  background: #f3f3f3;
}

.likelihood-notes p {
  margin-bottom: 0;
  color: #5f5138;
}

.likelihood-plot svg {
  display: block;
  width: 100%;
  height: auto;
}

.plot-frame {
  fill: #fff;
  stroke: none;
}

.plot-axis {
  stroke: rgba(52, 43, 29, 0.38);
  stroke-width: 1.25;
}

.plot-axis-line {
  stroke: rgba(52, 43, 29, 0.38);
  stroke-width: 1.25;
}

.plot-guide {
  stroke: rgba(139, 94, 18, 0.12);
  stroke-width: 1;
  stroke-dasharray: 4 5;
}

.plot-curve {
  fill: none;
  stroke: var(--viewer-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.plot-mle {
  stroke: var(--viewer-accent-deep);
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

.plot-dot {
  fill: var(--viewer-accent-deep);
  stroke: #fff;
  stroke-width: 1.5;
}

.plot-label,
.plot-axis-title {
  fill: #5c513f;
  font-size: 12px;
}

.plot-axis-title {
  font-size: 12.5px;
  font-weight: 600;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 16rem;
  padding: 2rem;
  color: #756a57;
  text-align: center;
  border: 1px dashed var(--viewer-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
}

.growth-grid-shell {
  overflow-x: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  padding: 0.4rem 0.1rem 0.1rem;
  border-radius: 12px;
  background: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.growth-grid-layout {
  --growth-grid-axis-gap: 20px;
  --growth-grid-count-title-width: 1.3rem;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--growth-grid-axis-gap);
  align-items: center;
  padding-right: calc(var(--growth-grid-axis-gap) + var(--growth-grid-count-title-width));
}

.growth-grid-layout__y-title {
  align-self: center;
  display: grid;
  place-items: center;
  min-width: 3.2rem;
  color: #5f5138;
  font-size: 1.72rem;
  font-weight: 600;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.growth-grid-shell.empty-state {
  display: grid;
  place-items: center;
}

.growth-grid {
  position: relative;
  width: max-content;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0.14rem 0.16rem;
  background: transparent;
}

.growth-grid thead,
.growth-grid tbody,
.growth-grid tr {
  background: transparent;
}

.growth-grid th,
.growth-grid td {
  padding: 0;
  border-bottom: 0;
  background: transparent;
  vertical-align: middle;
  white-space: nowrap;
}

.growth-grid__corner {
  width: 3.2rem;
}

.growth-grid__axis-title {
  padding: 0 0.28rem 20px;
  text-align: center;
  color: #675637;
  font-size: 1.18rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
}

.growth-grid__replicate-label {
  padding: 0 0.28rem 0.8rem;
  text-align: center;
  color: #675637;
  font-size: 1.45rem;
  font-weight: 600;
}

.growth-grid__row-label {
  width: 3.2rem;
  padding: 0 1rem 0 0;
  text-align: right;
  color: #54462f;
  font-size: 1.5rem;
  font-weight: 600;
}

.growth-grid__count-title {
  width: 4.8rem;
  padding-left: 0.55rem;
  text-align: left;
  vertical-align: middle;
}

.growth-grid__count-title span {
  position: absolute;
  top: 50%;
  right: calc(-1 * (var(--growth-grid-axis-gap) + var(--growth-grid-count-title-width)));
  color: #675637;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: translateY(-50%);
}

.growth-grid__cell {
  width: 4.4rem;
  height: 4.4rem;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  background: #fff;
  color: #342b1d;
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1;
  text-transform: none;
  touch-action: none;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.growth-grid td .growth-grid__cell {
  display: block;
}

.growth-grid__cell:hover,
.growth-grid__cell:focus {
  border-color: rgba(196, 147, 39, 0.5);
}

.growth-grid__cell--positive {
  color: #241b0d;
  border-color: var(--viewer-accent);
  background: var(--viewer-accent);
}

.growth-grid__summary {
  display: inline-block;
  min-width: 4.2rem;
  padding-left: 0.55rem;
  color: #6a5f4d;
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
}

.noscript-banner {
  margin: 2rem auto;
  width: min(680px, calc(100vw - 40px));
  padding: 1.2rem 1.6rem;
  border: 1px solid rgba(157, 42, 42, 0.18);
  border-radius: 8px;
  background: rgba(157, 42, 42, 0.06);
  color: var(--viewer-danger);
  font-size: 1.4rem;
  text-align: center;
}

@media (min-width: 900px) {
  .tool-workspace-grid {
    grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .tool-grid-help {
    justify-items: start;
    text-align: left;
  }

  .summary-export__actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .summary-export__table {
    min-width: 0;
  }
}
