.calculator-page {
	--calc-panel: rgb(255 250 242 / 0.9);
	--calc-panel-solid: #fffaf2;
	--calc-line: #e2d2be;
	--calc-muted: #665f55;
	--calc-accent: #704623;
	--calc-accent-soft: #f3e7d6;
	--calc-blue: #415f73;
	max-width: 1180px;
	margin: 0 auto;
	padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 4rem) clamp(3rem, 6vw, 5rem);
	color: var(--ink);
	font-variant-numeric: tabular-nums;
	-webkit-font-smoothing: antialiased;
}

.calculator-page *,
.calculator-page *::before,
.calculator-page *::after {
	box-sizing: border-box;
}

.calculator-page button,
.calculator-page input,
.calculator-page select {
	font: inherit;
}

.tool-page-header {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: clamp(1rem, 3vw, 2rem);
	align-items: end;
	margin-bottom: clamp(1rem, 3vw, 1.5rem);
	padding-bottom: clamp(1rem, 3vw, 1.5rem);
	border-bottom: 1px solid var(--calc-line);
}

.tool-page-header h1 {
	max-width: 19ch;
	margin: 0;
	font-size: clamp(2.25rem, 4.8vw, 4.3rem);
	line-height: 1;
	letter-spacing: 0;
	text-wrap: nowrap;
}

.tool-page-header p:last-child {
	max-width: 44rem;
	margin: 1rem 0 0;
	color: var(--calc-muted);
	font-size: clamp(1rem, 1.6vw, 1.15rem);
	line-height: 1.65;
	text-wrap: pretty;
}

.tool-parent-link {
	display: inline-block;
	margin-bottom: 1rem;
	padding-bottom: 0.2rem;
	border-bottom: 1px solid currentcolor;
	color: var(--calc-accent);
	font-size: 0.9rem;
	font-weight: 850;
}

.calculator-shell {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem);
	gap: clamp(1rem, 3vw, 1.5rem);
	align-items: start;
}

.workspace,
.results-card {
	border: 1px solid var(--calc-line);
	border-radius: 8px;
	background:
		linear-gradient(180deg, rgb(255 250 242 / 0.94), rgb(255 250 242 / 0.82)),
		var(--calc-panel-solid);
	box-shadow: 0 16px 42px rgb(112 70 35 / 0.08);
}

.workspace {
	min-width: 0;
	overflow: visible;
}

.tool-kicker,
.calculator-page .eyebrow {
	margin: 0 0 0.5rem;
	color: var(--calc-accent);
	font-size: 0.78rem;
	font-weight: 850;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.calculator-page h2 {
	margin: 0;
	font-family: Georgia, serif;
	font-size: clamp(1.35rem, 2.2vw, 2rem);
	line-height: 1.08;
	letter-spacing: 0;
	text-wrap: balance;
}

.lede {
	max-width: 42rem;
	margin: 0.75rem 0 0;
	color: var(--calc-muted);
	font-size: 1rem;
	line-height: 1.65;
	text-wrap: pretty;
}

.status-strip {
	display: grid;
	gap: 0.5rem;
	min-width: 11rem;
}

.status-strip span {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.65rem 0.75rem;
	border: 1px solid rgb(112 70 35 / 0.2);
	border-radius: 4px;
	background: rgb(255 250 242 / 0.82);
	color: var(--calc-muted);
	font-size: 0.82rem;
}

.status-strip strong {
	color: var(--calc-accent);
}

.calculator {
	display: grid;
	gap: 0.9rem;
	padding: clamp(1rem, 3vw, 1.25rem);
}

.panel {
	padding: clamp(1rem, 2.4vw, 1.25rem);
	border: 1px solid var(--calc-line);
	border-radius: 6px;
	background: rgb(255 250 242 / 0.74);
}

.calculator-page .section-heading {
	display: flex;
	gap: 0.9rem;
	align-items: flex-start;
	margin: 0 0 1rem;
}

.calculator-page .section-heading > div {
	display: block;
}

.section-toggle {
	width: 100%;
	min-height: 3rem;
	border: 0;
	background: transparent;
	color: inherit;
	padding: 0;
	text-align: left;
	cursor: pointer;
}

.section-toggle:focus-visible {
	outline: 3px solid rgb(112 70 35 / 0.18);
	outline-offset: 6px;
}

.section-copy {
	min-width: 0;
	flex: 1 1 auto;
}

.calculator-page .section-heading p {
	margin: 0.25rem 0 0;
	color: var(--calc-muted);
	font-size: 0.95rem;
	line-height: 1.45;
	text-wrap: pretty;
}

.calculator-page .section-number {
	display: grid;
	place-items: center;
	width: 2.125rem;
	height: 2.125rem;
	flex: 0 0 auto;
	border: 1px solid var(--calc-accent);
	border-radius: 50%;
	background: var(--calc-accent);
	color: white;
	font-weight: 850;
	line-height: 1;
}

.section-total {
	flex: 0 0 auto;
	margin-left: auto;
	color: var(--calc-accent);
	font-size: 0.92rem;
	line-height: 1.35;
	text-align: right;
	white-space: nowrap;
}

.toggle-icon {
	position: relative;
	width: 1.5rem;
	height: 1.5rem;
	flex: 0 0 auto;
	margin-top: 0.3rem;
	border: 1px solid rgb(112 70 35 / 0.3);
	border-radius: 50%;
	background: rgb(255 250 242 / 0.82);
}

.toggle-icon::before,
.toggle-icon::after {
	position: absolute;
	content: "";
	inset: 50% auto auto 50%;
	width: 0.65rem;
	height: 2px;
	background: var(--calc-accent);
	transform: translate(-50%, -50%);
}

.toggle-icon::after {
	transform: translate(-50%, -50%) rotate(90deg);
	transition: opacity 160ms ease;
}

.panel.is-collapsed .panel-content {
	display: none;
}

.panel.is-collapsed .section-heading {
	margin-bottom: 0;
}

.panel:not(.is-collapsed) .toggle-icon::after {
	opacity: 0;
}

.field-grid {
	display: grid;
	gap: 0.75rem;
}

.field-grid.three {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.calculator-page label {
	display: grid;
	gap: 0.45rem;
	min-width: 0;
}

.calculator-page label span {
	color: var(--calc-muted);
	font-size: 0.82rem;
	font-weight: 750;
}

.field-label {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	width: fit-content;
}

.info-dot {
	position: relative;
	display: inline-grid;
	place-items: center;
	width: 1.1rem;
	height: 1.1rem;
	border: 1px solid rgb(112 70 35 / 0.34);
	border-radius: 50%;
	background: rgb(255 250 242 / 0.92);
	color: var(--calc-accent);
	font-size: 0.68rem;
	font-style: normal;
	font-weight: 900;
	line-height: 1;
	cursor: help;
}

.info-dot::after {
	position: absolute;
	left: 50%;
	bottom: calc(100% + 9px);
	z-index: 4;
	width: min(260px, 70vw);
	padding: 0.65rem 0.7rem;
	border: 1px solid rgb(112 70 35 / 0.25);
	border-radius: 4px;
	background: var(--calc-panel-solid);
	box-shadow: 0 12px 30px rgb(112 70 35 / 0.16);
	color: var(--ink);
	content: attr(data-info);
	font-size: 0.78rem;
	font-weight: 700;
	line-height: 1.35;
	opacity: 0;
	pointer-events: none;
	text-transform: none;
	transform: translate(-50%, 4px);
	transition: opacity 140ms ease, transform 140ms ease;
}

.info-dot:hover::after,
.info-dot:focus-visible::after {
	opacity: 1;
	transform: translate(-50%, 0);
}

.info-dot:focus-visible {
	outline: 2px solid rgb(112 70 35 / 0.28);
	outline-offset: 2px;
}

.calculator-page input,
.calculator-page select {
	width: 100%;
	min-height: 2.75rem;
	border: 1px solid #cfbfaa;
	border-radius: 4px;
	background: #fffdf8;
	color: var(--ink);
	padding: 0.65rem 0.75rem;
	outline: none;
	transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.calculator-page input:focus,
.calculator-page select:focus {
	border-color: var(--calc-accent);
	box-shadow: 0 0 0 3px rgb(112 70 35 / 0.14);
	background: white;
}

.input-suffix {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 2.625rem;
	border: 1px solid #cfbfaa;
	border-radius: 4px;
	background: #fffdf8;
	overflow: clip;
}

.input-suffix:focus-within {
	border-color: var(--calc-accent);
	box-shadow: 0 0 0 3px rgb(112 70 35 / 0.14);
	background: white;
}

.input-suffix input {
	min-height: 2.625rem;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
}

.input-suffix span {
	display: grid;
	place-items: center;
	color: var(--calc-accent);
	font-weight: 850;
}

.assumption-row {
	position: relative;
	z-index: 2;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 0.75rem;
	padding: 1rem;
	border: 1px solid var(--calc-line);
	border-radius: 6px;
	background:
		linear-gradient(135deg, rgb(160 106 59 / 0.07), transparent 56%),
		rgb(255 250 242 / 0.82);
}

.results {
	position: sticky;
	top: 6rem;
	align-self: start;
}

.results-card {
	padding: clamp(1rem, 2.6vw, 1.25rem);
}

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

.reset-button {
	min-height: 2.5rem;
	border: 1px solid var(--calc-line);
	border-radius: 999px;
	background: transparent;
	color: var(--calc-accent);
	cursor: pointer;
	padding: 0 0.95rem;
	font-weight: 850;
	transition: background-color 160ms ease, transform 160ms ease;
}

.reset-button:hover {
	background: var(--calc-accent-soft);
}

.reset-button:active {
	transform: scale(0.96);
}

.hero-metric {
	display: grid;
	gap: 0.45rem;
	padding: 1.1rem;
	border-radius: 6px;
	background:
		linear-gradient(135deg, rgb(112 70 35 / 0.96), rgb(65 95 115 / 0.92)),
		var(--calc-accent);
	color: white;
}

.hero-metric span,
.hero-metric small {
	color: rgb(255 255 255 / 0.76);
	font-weight: 750;
}

.hero-metric strong {
	font-family: Georgia, serif;
	font-size: clamp(2.15rem, 5vw, 3.6rem);
	line-height: 0.95;
}

.metric-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.65rem;
	margin-top: 0.8rem;
}

.metric-grid article {
	min-height: 6rem;
	padding: 0.9rem;
	border: 1px solid var(--calc-line);
	border-radius: 6px;
	background: rgb(255 253 248 / 0.82);
}

.metric-grid span,
.model-list dt {
	display: block;
	color: var(--calc-muted);
	font-size: 0.78rem;
	font-weight: 850;
	line-height: 1.35;
}

.metric-grid strong {
	display: block;
	margin-top: 0.5rem;
	color: var(--ink);
	font-size: 1.13rem;
	line-height: 1.2;
}

.chart-wrap {
	margin: 0.9rem 0;
	padding: 0.65rem;
	border: 1px solid var(--calc-line);
	border-radius: 6px;
	background: #fffdf8;
}

.calculator-page canvas {
	display: block;
	width: 100%;
	max-width: 100%;
	aspect-ratio: 2 / 1;
}

.model-list {
	display: grid;
	gap: 0;
	margin: 0;
	border-top: 1px solid var(--calc-line);
}

.model-list div {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.75rem 0;
	border-bottom: 1px solid var(--calc-line);
}

.model-list dd {
	margin: 0;
	font-weight: 850;
	text-align: right;
}

.note {
	margin: 0.9rem 0 0;
	color: var(--calc-muted);
	font-size: 0.82rem;
	line-height: 1.45;
}

.source-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.65rem;
	margin-top: 0.9rem;
}

.source-links a {
	color: var(--calc-accent);
	font-size: 0.82rem;
	font-weight: 850;
	text-decoration-thickness: 2px;
	text-underline-offset: 3px;
}

.tool-detail-nav {
	padding: 1.5rem 0 0;
}

@media (max-width: 1120px) {
	.calculator-shell {
		grid-template-columns: 1fr;
	}

	.results {
		position: static;
	}
}

@media (max-width: 780px) {
	.calculator-page {
		padding-inline: clamp(0.75rem, 4vw, 1rem);
	}

	.tool-page-header {
		grid-template-columns: 1fr;
		align-items: start;
	}

	.field-grid.three,
	.assumption-row,
	.metric-grid {
		grid-template-columns: 1fr;
	}

	.calculator,
	.panel,
	.results-card {
		padding: 0.9rem;
	}

	.status-strip {
		min-width: 0;
	}

	.calculator-page .section-heading {
		display: grid;
		grid-template-columns: auto minmax(0, 1fr) auto;
	}

	.section-total {
		grid-column: 2;
		margin-left: 0;
		text-align: left;
	}

	.toggle-icon {
		grid-column: 3;
		grid-row: 1;
	}
}
