/* Simplifying Fractions Calculator — Teal & Navy theme */

.sfr-app {
	--sfr-navy-950: #0a1120;
	--sfr-navy-900: #0f172a;
	--sfr-navy-850: #131f36;
	--sfr-navy-800: #16223b;
	--sfr-navy-700: #1e2c4a;
	--sfr-teal-300: #5eead4;
	--sfr-teal-400: #2dd4bf;
	--sfr-teal-500: #14b8a6;
	--sfr-teal-600: #0d9488;
	--sfr-text-soft: #94a3b8;
	--sfr-text-faint: #4c5c7a;
	--sfr-red-400: #f87171;

	max-width: 1000px;
	margin: 2rem auto;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	box-sizing: border-box;
}

.sfr-app *,
.sfr-app *::before,
.sfr-app *::after {
	box-sizing: border-box;
}

/* ---------- Layout ---------- */

.sfr-columns {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.25rem;
	margin-bottom: 1.25rem;
}

.sfr-panel {
	position: relative;
	padding: 1.75rem;
	border-radius: 20px;
	background: linear-gradient(160deg, var(--sfr-navy-900) 0%, var(--sfr-navy-950) 100%);
	box-shadow:
		0 20px 45px -15px rgba(10, 17, 32, 0.55),
		0 0 0 1px rgba(45, 212, 191, 0.12),
		inset 0 1px 0 rgba(255, 255, 255, 0.04);
	overflow: hidden;
}

.sfr-panel::before {
	content: "";
	position: absolute;
	top: -60%;
	left: 50%;
	width: 140%;
	height: 140%;
	transform: translateX(-50%);
	background: radial-gradient(circle, rgba(45, 212, 191, 0.12) 0%, rgba(45, 212, 191, 0) 60%);
	pointer-events: none;
}

.sfr-panel-eyebrow {
	display: block;
	position: relative;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.18em;
	color: var(--sfr-teal-300);
	text-transform: uppercase;
	margin-bottom: 1.1rem;
}

/* ---------- Tabs ---------- */

.sfr-tabs {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
	padding: 0.3rem;
	margin-bottom: 1.1rem;
	background: rgba(15, 23, 42, 0.55);
	border: 1px solid rgba(94, 234, 212, 0.15);
	border-radius: 14px;
}

.sfr-tab {
	flex: 1;
	min-width: 45%;
	padding: 0.6rem 0.4rem;
	border: none;
	border-radius: 10px;
	background: transparent;
	color: var(--sfr-text-soft);
	font-family: inherit;
	font-size: 0.78rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
}

.sfr-tab:hover {
	color: #e2e8f0;
}

.sfr-tab.is-active {
	background: linear-gradient(135deg, var(--sfr-teal-400), var(--sfr-teal-600));
	color: var(--sfr-navy-950);
	box-shadow: 0 6px 16px -6px rgba(20, 184, 166, 0.6);
}

/* ---------- Fields ---------- */

.sfr-fields {
	position: relative;
	margin-bottom: 1rem;
}

.sfr-fraction-row {
	display: flex;
	align-items: end;
	gap: 0.6rem;
}

.sfr-mixed-row {
	flex-wrap: wrap;
}

.sfr-field {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 70px;
}

.sfr-label {
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--sfr-teal-300);
	margin-bottom: 0.35rem;
}

.sfr-frac-bar {
	padding-bottom: 0.7rem;
	font-size: 1.3rem;
	font-weight: 800;
	color: var(--sfr-teal-400);
}

.sfr-input-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.sfr-suffix {
	font-size: 1rem;
	font-weight: 700;
	color: var(--sfr-teal-400);
}

.sfr-input {
	width: 100%;
	padding: 0.7rem 0.8rem;
	border-radius: 12px;
	border: 1px solid rgba(94, 234, 212, 0.18);
	background: var(--sfr-navy-800);
	color: #f1f5f9;
	font-family: inherit;
	font-size: 1rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	outline: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sfr-input::placeholder {
	color: #506080;
	font-weight: 500;
}

.sfr-input:focus {
	border-color: var(--sfr-teal-400);
	box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}

/* ---------- Error ---------- */

.sfr-error {
	position: relative;
	margin-bottom: 1rem;
	padding: 0.7rem 0.9rem;
	border-radius: 10px;
	background: rgba(220, 38, 38, 0.12);
	border: 1px solid rgba(248, 113, 113, 0.3);
	color: #fca5a5;
	font-size: 0.85rem;
	line-height: 1.5;
}

/* ---------- Calculate button ---------- */

.sfr-calc-btn {
	position: relative;
	display: block;
	width: 100%;
	padding: 0.8rem;
	border: none;
	border-radius: 12px;
	background: linear-gradient(135deg, var(--sfr-teal-400), var(--sfr-teal-600));
	color: var(--sfr-navy-950);
	font-family: inherit;
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 8px 20px -6px rgba(20, 184, 166, 0.55);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	margin-bottom: 1rem;
}

.sfr-calc-btn:hover {
	box-shadow: 0 10px 24px -6px rgba(20, 184, 166, 0.7);
}

.sfr-calc-btn:active {
	transform: scale(0.98);
}

/* ---------- Samples ---------- */

.sfr-samples {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.sfr-chip {
	padding: 0.4rem 0.7rem;
	border-radius: 999px;
	border: 1px solid rgba(94, 234, 212, 0.18);
	background: var(--sfr-navy-800);
	color: var(--sfr-teal-300);
	font-family: inherit;
	font-size: 0.76rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.sfr-chip:hover {
	background: var(--sfr-navy-700);
	border-color: rgba(94, 234, 212, 0.4);
}

/* ---------- Result hero ---------- */

.sfr-result-hero {
	position: relative;
	text-align: center;
	padding: 1.5rem 1rem;
	margin-bottom: 1.1rem;
	border-radius: 16px;
	background: rgba(30, 44, 74, 0.45);
	border: 1px solid rgba(94, 234, 212, 0.15);
}

.sfr-hero-label {
	display: block;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--sfr-text-faint);
	margin-bottom: 0.5rem;
}

.sfr-hero-value {
	display: block;
	font-size: 2.4rem;
	font-weight: 800;
	color: var(--sfr-teal-300);
	text-shadow: 0 0 20px rgba(45, 212, 191, 0.25);
	font-variant-numeric: tabular-nums;
}

.sfr-hero-steps {
	display: block;
	margin-top: 0.6rem;
	font-size: 0.82rem;
	color: var(--sfr-text-soft);
	font-variant-numeric: tabular-nums;
}

/* ---------- Result grid ---------- */

.sfr-result-grid {
	position: relative;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.55rem;
	margin-bottom: 1.1rem;
}

.sfr-result-cell {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.3rem;
	padding: 0.8rem 0.5rem;
	border-radius: 12px;
	background: rgba(15, 23, 42, 0.55);
	border: 1px solid rgba(94, 234, 212, 0.12);
	text-align: center;
}

.sfr-cell-label {
	font-size: 0.64rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--sfr-text-faint);
}

.sfr-cell-value {
	font-size: 0.95rem;
	font-weight: 800;
	color: #e2e8f0;
	font-variant-numeric: tabular-nums;
	word-break: break-word;
}

/* ---------- Result actions ---------- */

.sfr-result-actions {
	position: relative;
	display: flex;
	gap: 0.5rem;
}

.sfr-action-btn {
	flex: 1;
	padding: 0.6rem 0.8rem;
	border-radius: 10px;
	border: 1px solid rgba(94, 234, 212, 0.3);
	background: transparent;
	color: var(--sfr-teal-300);
	font-family: inherit;
	font-size: 0.82rem;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.15s ease;
}

.sfr-action-btn:hover {
	background: rgba(45, 212, 191, 0.1);
}

.sfr-action-btn.is-copied {
	background: rgba(45, 212, 191, 0.18);
}

/* ---------- History panel ---------- */

.sfr-history-panel {
	padding: 1.75rem;
	border-radius: 20px;
	background: linear-gradient(160deg, var(--sfr-navy-900) 0%, var(--sfr-navy-950) 100%);
	box-shadow:
		0 20px 45px -15px rgba(10, 17, 32, 0.55),
		0 0 0 1px rgba(45, 212, 191, 0.12);
}

.sfr-history-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 1.1rem;
}

.sfr-history-head .sfr-panel-eyebrow {
	margin-bottom: 0;
}

.sfr-history-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.sfr-export-btn {
	padding: 0.5rem 0.85rem;
	border-radius: 9px;
	border: 1px solid rgba(94, 234, 212, 0.25);
	background: var(--sfr-navy-800);
	color: var(--sfr-teal-300);
	font-family: inherit;
	font-size: 0.78rem;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.sfr-export-btn:hover {
	background: var(--sfr-navy-700);
	border-color: rgba(94, 234, 212, 0.5);
}

.sfr-clear-btn {
	color: var(--sfr-red-400);
	border-color: rgba(248, 113, 113, 0.3);
}

.sfr-clear-btn:hover {
	background: rgba(220, 38, 38, 0.12);
	border-color: rgba(248, 113, 113, 0.5);
}

/* ---------- History table ---------- */

.sfr-history-table-wrap {
	overflow-x: auto;
}

.sfr-history-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.85rem;
}

.sfr-history-table th {
	text-align: left;
	padding: 0.6rem 0.7rem;
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--sfr-teal-300);
	border-bottom: 1px solid rgba(94, 234, 212, 0.18);
	white-space: nowrap;
}

.sfr-history-table td {
	padding: 0.6rem 0.7rem;
	color: #cbd5e1;
	border-bottom: 1px solid rgba(94, 234, 212, 0.07);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.sfr-history-table tr.is-latest td {
	background: rgba(45, 212, 191, 0.07);
}

.sfr-history-table tr.is-latest td:first-child {
	border-left: 2px solid var(--sfr-teal-400);
}

.sfr-result-cell-strong,
.sfr-history-table td.sfr-result-col {
	color: var(--sfr-teal-300);
	font-weight: 700;
}

.sfr-history-remove {
	width: 26px;
	height: 26px;
	border-radius: 7px;
	border: 1px solid rgba(94, 234, 212, 0.14);
	background: transparent;
	color: var(--sfr-text-faint);
	font-size: 0.9rem;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.sfr-history-remove:hover {
	background: rgba(220, 38, 38, 0.15);
	color: var(--sfr-red-400);
}

.sfr-history-empty-row td {
	text-align: center;
	color: var(--sfr-text-faint);
	font-style: italic;
	padding: 1.2rem;
}

@media (max-width: 800px) {
	.sfr-columns {
		grid-template-columns: 1fr;
	}
	.sfr-result-grid {
		grid-template-columns: 1fr 1fr;
	}
}
