.pm-tool {
	--pm-tool-text: #17202a;
	--pm-tool-muted: #52616f;
	--pm-tool-border: #d8e2dc;
	--pm-tool-soft-border: #e4ebf0;
	--pm-tool-surface: #fbfcfd;
	--pm-tool-surface-strong: #f4f8f6;
	--pm-tool-primary: #176b45;
	--pm-tool-primary-dark: #12583a;
	--pm-tool-blue: #235d9f;
	--pm-tool-danger: #b42318;
	--pm-tool-warning: #a15c07;
	box-sizing: border-box;
	max-width: 100%;
	margin: 1.8rem 0 2.1rem;
	color: var(--pm-tool-text);
	font-family: inherit;
}

.pm-tool *,
.pm-tool *::before,
.pm-tool *::after {
	box-sizing: border-box;
}

.pm-tool-card {
	border: 1px solid var(--pm-tool-border);
	border-radius: 8px;
	background: #ffffff;
	box-shadow: 0 14px 34px rgba(15, 23, 42, .07);
	overflow: hidden;
}

.pm-tool-card__header {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 16px;
	align-items: start;
	padding: 18px 20px 16px;
	border-bottom: 1px solid var(--pm-tool-soft-border);
	background: linear-gradient(180deg, #f8fbfa 0%, #ffffff 100%);
}

.pm-tool-card__eyebrow {
	margin: 0 0 5px;
	color: var(--pm-tool-primary);
	font-size: .78rem;
	font-weight: 800;
	letter-spacing: 0;
	line-height: 1.2;
	text-transform: uppercase;
}

.pm-tool-card__header h2 {
	margin: 0;
	color: #102a43;
	font-size: 1.35rem;
	line-height: 1.25;
	letter-spacing: 0;
}

.pm-tool-card__intro {
	margin: 7px 0 0;
	color: var(--pm-tool-muted);
	font-size: .96rem;
	line-height: 1.55;
}

.pm-tool-badge,
.pm-tool-segment {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 32px;
	border: 1px solid #bad8c8;
	border-radius: 999px;
	background: #eff8f3;
	color: #12583a;
	padding: 5px 10px;
	font-size: .78rem;
	font-weight: 800;
	line-height: 1.2;
	white-space: nowrap;
}

.pm-tool-segment {
	gap: 3px;
	padding: 3px;
}

.pm-tool-segment button {
	min-height: 28px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--pm-tool-primary-dark);
	padding: 4px 10px;
	font: inherit;
	font-size: .78rem;
	font-weight: 850;
	line-height: 1.2;
	cursor: pointer;
}

.pm-tool-segment button.is-active {
	background: var(--pm-tool-primary);
	color: #ffffff;
}

.pm-tool-field {
	min-width: 0;
}

.pm-tool-field label {
	display: block;
	margin-bottom: 6px;
	color: #263b53;
	font-size: .86rem;
	font-weight: 800;
	line-height: 1.25;
}

.pm-tool-field input,
.pm-scientific__display input {
	display: block;
	width: 100%;
	min-height: 46px;
	border: 1px solid #cbd7e3;
	border-radius: 7px;
	background: #ffffff;
	color: var(--pm-tool-text);
	padding: 10px 12px;
	font: inherit;
	font-size: 16px;
	line-height: 1.35;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.pm-tool-field input[type="color"] {
	min-width: 64px;
	padding: 4px;
	cursor: pointer;
}

.pm-tool-field input:focus,
.pm-scientific__display input:focus {
	border-color: var(--pm-tool-primary);
	box-shadow: 0 0 0 3px rgba(31, 122, 79, .15);
	outline: 0;
}

.pm-tool-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 116px;
	min-height: 46px;
	border: 1px solid var(--pm-tool-primary);
	border-radius: 7px;
	background: var(--pm-tool-primary);
	color: #ffffff;
	padding: 10px 16px;
	font: inherit;
	font-weight: 850;
	line-height: 1.25;
	cursor: pointer;
	transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}

.pm-tool-button:hover,
.pm-tool-button:focus {
	background: var(--pm-tool-primary-dark);
	border-color: var(--pm-tool-primary-dark);
	outline: 0;
}

.pm-tool-button:active {
	transform: translateY(1px);
}

.pm-tool-examples {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	padding: 0 20px 18px;
	background: #ffffff;
}

.pm-tool-examples > span {
	color: #667085;
	font-size: .82rem;
	font-weight: 800;
	line-height: 1.25;
}

.pm-tool-examples button,
.pm-grapher__options button {
	min-height: 34px;
	border: 1px solid #d5dee8;
	border-radius: 999px;
	background: #fbfcfd;
	color: #263b53;
	padding: 6px 10px;
	font: inherit;
	font-size: .86rem;
	font-weight: 750;
	line-height: 1.25;
	cursor: pointer;
	transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}

.pm-tool-examples button {
	font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.pm-tool-examples button:hover,
.pm-tool-examples button:focus,
.pm-grapher__options button:hover,
.pm-grapher__options button:focus {
	border-color: var(--pm-tool-primary);
	background: #f0f8f4;
	color: var(--pm-tool-primary-dark);
	outline: 0;
}

.pm-tool-result {
	border-top: 1px solid var(--pm-tool-soft-border);
	background: var(--pm-tool-surface);
	padding: 18px 20px 20px;
	line-height: 1.55;
}

.pm-tool-result[hidden] {
	display: none;
}

.pm-tool-result h3 {
	margin: 0 0 10px;
	color: #102a43;
	font-size: 1.05rem;
	line-height: 1.3;
	letter-spacing: 0;
}

.pm-tool-result__formula,
.pm-tool-result__line {
	margin: 10px 0;
	padding: 12px 14px;
	border: 1px solid var(--pm-tool-border);
	border-radius: 7px;
	background: #ffffff;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
}

.pm-tool-result__value {
	color: var(--pm-tool-primary-dark);
	font-weight: 850;
}

.pm-tool-note,
.pm-tool-error,
.pm-tool-loading {
	margin: 0;
	border-left: 4px solid var(--pm-tool-primary);
	background: #f0f8f4;
	color: var(--pm-tool-primary-dark);
	padding: 10px 12px;
	line-height: 1.5;
}

.pm-tool-error {
	border-left-color: var(--pm-tool-danger);
	background: #fff4f2;
	color: #7a271a;
}

.pm-tool-warning {
	border-left-color: var(--pm-tool-warning);
	background: #fff8eb;
	color: #7a3d00;
}

.pm-scientific {
	max-width: 620px;
}

.pm-scientific__display {
	padding: 18px 20px 14px;
	background: #ffffff;
}

.pm-scientific__display label {
	display: block;
	margin-bottom: 6px;
	color: #263b53;
	font-size: .86rem;
	font-weight: 800;
	line-height: 1.25;
}

.pm-scientific__display input {
	font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.pm-scientific__output {
	display: block;
	min-height: 50px;
	margin-top: 10px;
	border: 1px solid #d8e2dc;
	border-radius: 7px;
	background: #102a43;
	color: #ffffff;
	padding: 12px 14px;
	font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	font-size: 1.12rem;
	font-weight: 800;
	line-height: 1.35;
	overflow-x: auto;
	white-space: nowrap;
}

.pm-scientific__output.is-error {
	background: #7a271a;
}

.pm-scientific__keypad {
	display: grid;
	gap: 8px;
	padding: 0 20px 20px;
	background: #ffffff;
}

.pm-scientific__row {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 8px;
}

.pm-scientific__row:last-child {
	grid-template-columns: repeat(2, minmax(0, 1fr)) 2fr;
}

.pm-scientific__key {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	border: 1px solid #cbd7e3;
	border-radius: 7px;
	background: #ffffff;
	color: #17202a;
	padding: 8px 10px;
	font: inherit;
	font-size: .98rem;
	font-weight: 850;
	line-height: 1.25;
	cursor: pointer;
	transition: border-color .15s ease, color .15s ease, background-color .15s ease, transform .15s ease;
}

.pm-scientific__key:hover,
.pm-scientific__key:focus {
	border-color: var(--pm-tool-blue);
	background: #eef5ff;
	color: #173f73;
	outline: 0;
}

.pm-scientific__key:active {
	transform: translateY(1px);
}

.pm-scientific__key[data-pm-scientific-action="calculate"] {
	border-color: var(--pm-tool-primary);
	background: var(--pm-tool-primary);
	color: #ffffff;
}

.pm-power__controls,
.pm-fraction__controls,
.pm-quadratic__controls,
.pm-grapher__controls,
.pm-integral__controls {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
	gap: 12px;
	align-items: end;
	padding: 18px 20px 14px;
	background: #ffffff;
}

.pm-power__controls input,
.pm-fraction__controls input,
.pm-quadratic__controls input,
.pm-grapher__function-field input,
.pm-integral__function-field input {
	font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.pm-fraction,
.pm-quadratic {
	max-width: 840px;
}

.pm-quadratic__controls {
	grid-template-columns: repeat(3, minmax(92px, 1fr)) auto;
}

.pm-fraction__toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	padding: 0 20px 14px;
	background: #ffffff;
}

.pm-fraction__toolbar .pm-tool-segment {
	flex-wrap: wrap;
	justify-content: flex-start;
	border-radius: 8px;
}

.pm-integral {
	max-width: 920px;
}

.pm-integral__controls {
	grid-template-columns: minmax(250px, 1fr) minmax(74px, 100px) minmax(90px, 120px) minmax(90px, 120px) auto;
}

.pm-matrix,
.pm-inverse-matrix {
	max-width: 920px;
}

.pm-matrix__controls {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
	align-items: start;
	padding: 18px 20px 14px;
	background: #ffffff;
}

.pm-inverse-matrix__controls {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 12px;
	align-items: end;
	padding: 18px 20px 14px;
	background: #ffffff;
}

.pm-tool-field textarea {
	display: block;
	width: 100%;
	min-height: 132px;
	resize: vertical;
	border: 1px solid #cbd7e3;
	border-radius: 7px;
	background: #ffffff;
	color: var(--pm-tool-text);
	padding: 10px 12px;
	font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	font-size: 16px;
	line-height: 1.45;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.pm-tool-field textarea:focus {
	border-color: var(--pm-tool-primary);
	box-shadow: 0 0 0 3px rgba(31, 122, 79, .15);
	outline: 0;
}

.pm-matrix__toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	justify-content: space-between;
	padding: 0 20px 14px;
	background: #ffffff;
}

.pm-matrix__toolbar .pm-tool-segment {
	flex-wrap: wrap;
	justify-content: flex-start;
	border-radius: 8px;
}

.pm-matrix .pm-tool-result__formula,
.pm-inverse-matrix .pm-tool-result__formula {
	padding: 14px;
}

.pm-matrix .katex-display,
.pm-inverse-matrix .katex-display,
.pm-integral .katex-display {
	margin: .2rem 0;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
}

.pm-power .pm-tool-result__formula .katex-display,
.pm-power .pm-tool-result__formula .katex {
	font-size: 1.08em;
}

.pm-grapher {
	max-width: 980px;
}

.pm-grapher__controls {
	grid-template-columns: minmax(260px, 1fr) minmax(74px, 96px) auto;
}

.pm-grapher__viewport {
	position: relative;
	margin: 0 20px 14px;
	border: 1px solid #d8e2dc;
	border-radius: 8px;
	background: #ffffff;
	overflow: hidden;
	aspect-ratio: 16 / 10;
	min-height: 280px;
}

.pm-grapher__canvas {
	display: block;
	width: 100%;
	height: 100%;
	background: #ffffff;
	touch-action: none;
	cursor: crosshair;
}

.pm-grapher__coords {
	position: absolute;
	left: 10px;
	top: 10px;
	max-width: calc(100% - 20px);
	border-radius: 6px;
	background: rgba(16, 42, 67, .88);
	color: #ffffff;
	padding: 5px 8px;
	font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	font-size: .78rem;
	line-height: 1.25;
	pointer-events: none;
	opacity: 0;
	transition: opacity .15s ease;
}

.pm-grapher__viewport:hover .pm-grapher__coords {
	opacity: 1;
}

.pm-grapher__options {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	padding: 0 20px 14px;
	color: #263b53;
	font-size: .9rem;
}

.pm-grapher__options label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 34px;
	border: 1px solid #d5dee8;
	border-radius: 999px;
	background: #fbfcfd;
	padding: 6px 10px;
	font-weight: 750;
	line-height: 1.25;
}

.pm-grapher__options input {
	accent-color: var(--pm-tool-primary);
}

.pm-grapher__functions {
	display: grid;
	gap: 8px;
	padding: 0 20px 18px;
}

.pm-grapher__function {
	display: grid;
	grid-template-columns: 18px minmax(0, 1fr) auto;
	gap: 10px;
	align-items: center;
	min-height: 42px;
	border: 1px solid #e4ebf0;
	border-radius: 7px;
	background: #fbfcfd;
	padding: 8px 10px;
	color: #263b53;
	font-size: .9rem;
	line-height: 1.3;
}

.pm-grapher__function-color {
	width: 18px;
	height: 18px;
	border-radius: 4px;
	border: 1px solid rgba(15, 23, 42, .18);
}

.pm-grapher__function-expression {
	min-width: 0;
	font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	overflow-wrap: anywhere;
}

.pm-grapher__function-remove {
	min-width: 34px;
	min-height: 32px;
	border: 1px solid #d5dee8;
	border-radius: 6px;
	background: #ffffff;
	color: #7a271a;
	font: inherit;
	font-weight: 850;
	cursor: pointer;
}

.pm-grapher__message {
	border-top: 1px solid #e4ebf0;
}

@media (max-width: 820px) {
	.pm-tool-card__header,
	.pm-power__controls,
	.pm-fraction__controls,
	.pm-quadratic__controls,
	.pm-grapher__controls,
	.pm-integral__controls,
	.pm-matrix__controls,
	.pm-inverse-matrix__controls {
		grid-template-columns: 1fr;
	}

	.pm-tool-badge,
	.pm-tool-segment {
		justify-self: start;
	}

	.pm-tool-button {
		width: 100%;
	}

	.pm-grapher__viewport {
		aspect-ratio: 4 / 3;
	}
}

@media (max-width: 520px) {
	.pm-tool {
		margin: 1.4rem 0 1.8rem;
	}

	.pm-tool-card__header,
	.pm-scientific__display,
	.pm-scientific__keypad,
	.pm-power__controls,
	.pm-fraction__controls,
	.pm-quadratic__controls,
	.pm-grapher__controls,
	.pm-integral__controls,
	.pm-matrix__controls,
	.pm-inverse-matrix__controls,
	.pm-matrix__toolbar,
	.pm-fraction__toolbar,
	.pm-tool-result {
		padding-left: 14px;
		padding-right: 14px;
	}

	.pm-tool-examples,
	.pm-grapher__options,
	.pm-grapher__functions {
		padding-left: 14px;
		padding-right: 14px;
	}

	.pm-tool-examples {
		flex-wrap: nowrap;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
	}

	.pm-tool-examples > span,
	.pm-tool-examples button {
		flex: 0 0 auto;
	}

	.pm-tool-examples button {
		max-width: 220px;
		white-space: nowrap;
	}

	.pm-scientific__row {
		gap: 6px;
	}

	.pm-scientific__key {
		min-height: 42px;
		padding-left: 6px;
		padding-right: 6px;
	}

	.pm-grapher__viewport {
		margin-left: 14px;
		margin-right: 14px;
		min-height: 250px;
	}

	.pm-grapher__options {
		flex-wrap: nowrap;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
	}

	.pm-grapher__options > * {
		flex: 0 0 auto;
	}
}

@media (prefers-color-scheme: dark) {
	.pm-tool {
		--pm-tool-text: #e2ebf6;
		--pm-tool-muted: #b8c6d8;
		--pm-tool-border: rgba(148, 163, 184, 0.28);
		--pm-tool-soft-border: rgba(148, 163, 184, 0.22);
		--pm-tool-surface: #101b2a;
		--pm-tool-surface-strong: #0d1420;
		--pm-tool-primary: #187046;
		--pm-tool-primary-dark: #9af0b8;
		--pm-tool-blue: #7db4ff;
		--pm-tool-danger: #ff8a8a;
		--pm-tool-warning: #ffd28a;
		color: var(--pm-tool-text);
	}

	.pm-tool-card,
	.pm-tool-card__header,
	.pm-scientific__display,
	.pm-scientific__keypad,
	.pm-power__controls,
	.pm-fraction__controls,
	.pm-quadratic__controls,
	.pm-grapher__controls,
	.pm-integral__controls,
	.pm-matrix__controls,
	.pm-inverse-matrix__controls,
	.pm-tool-examples,
	.pm-fraction__toolbar,
	.pm-matrix__toolbar,
	.pm-grapher__options,
	.pm-grapher__functions,
	.pm-tool-result {
		background: #101b2a;
		border-color: var(--pm-tool-border);
		color: var(--pm-tool-text);
		box-shadow: none;
	}

	.pm-tool-card__header h2,
	.pm-tool-result h3 {
		color: #f3f7fb;
	}

	.pm-tool-card__intro,
	.pm-tool-field label,
	.pm-scientific__display label,
	.pm-tool-examples > span,
	.pm-grapher__options {
		color: var(--pm-tool-muted);
	}

	.pm-tool-badge,
	.pm-tool-segment {
		background: rgba(34, 197, 94, 0.12);
		border-color: rgba(34, 197, 94, 0.32);
		color: #9af0b8;
	}

	.pm-tool-segment button,
	.pm-tool-examples button,
	.pm-grapher__options button,
	.pm-grapher__options label,
	.pm-grapher__function,
	.pm-scientific__key,
	.pm-tool-result__formula,
	.pm-tool-result__line {
		background: #0d1420;
		border-color: var(--pm-tool-border);
		color: #d8e4f2;
	}

	.pm-tool-segment button.is-active,
	.pm-scientific__key[data-pm-scientific-action="calculate"] {
		background: var(--pm-tool-primary);
		color: #ffffff;
	}

	.pm-tool-field input,
	.pm-tool-field textarea,
	.pm-scientific__display input {
		background: #0d1420;
		border-color: rgba(148, 163, 184, 0.36);
		color: #edf5ff;
	}

	.pm-tool-field input:focus,
	.pm-tool-field textarea:focus,
	.pm-scientific__display input:focus {
		border-color: rgba(125, 180, 255, 0.72);
		box-shadow: 0 0 0 3px rgba(125, 180, 255, 0.16);
	}

	.pm-tool-examples button:hover,
	.pm-tool-examples button:focus,
	.pm-grapher__options button:hover,
	.pm-grapher__options button:focus,
	.pm-scientific__key:hover,
	.pm-scientific__key:focus {
		background: rgba(125, 180, 255, 0.12);
		border-color: rgba(125, 180, 255, 0.52);
		color: #cfe4ff;
	}

	.pm-tool-note,
	.pm-tool-loading {
		background: rgba(125, 180, 255, 0.10);
		border-color: rgba(125, 180, 255, 0.28);
		color: #cfe4ff;
	}

	.pm-tool-error {
		background: rgba(239, 68, 68, 0.12);
		border-color: rgba(239, 68, 68, 0.32);
		color: #ffcaca;
	}

	.pm-tool-warning {
		background: rgba(245, 158, 11, 0.12);
		border-color: rgba(245, 158, 11, 0.32);
		color: #ffd28a;
	}

	.pm-grapher__viewport,
	.pm-grapher__canvas {
		background: #0b1220;
		border-color: var(--pm-tool-border);
	}

	.pm-grapher__coords {
		background: rgba(13, 20, 32, .92);
		color: #edf5ff;
	}
}
