:root {
	--surface: #fff6ee;
	--surface-soft: #fffdf8;
	--page-bg: #f3ece3;
	--text: #252424;
	--border: #ead6c2;
	--shadow: 0 20px 50px rgba(66, 40, 12, 0.18);
	--radius-lg: 20px;
	--radius-md: 14px;
	--radius-pill: 999px;
	--accent: #f28c28;
	--accent-strong: #e07712;
	--accent-bg: #ffbe77;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--page-bg);
	color: var(--text);
}

/* Topbar */
.topbar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 64px;
	padding: 0 16px;
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 10px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	box-shadow: 0 10px 24px rgba(66, 40, 12, 0.14);
	z-index: 1000;
}

.topbar-home,
.topbar-spacer {
	min-width: 98px;
}

.topbar-home {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 40px;
	padding: 0 14px;
	border-radius: var(--radius-pill);
	border: 1px solid var(--border);
	background: rgba(0, 0, 0, 0.03);
	color: inherit;
	text-decoration: none;
	font-weight: 700;
}

.topbar-title {
	margin: 0;
	font-size: 1.1rem;
	line-height: 1.2;
	text-align: center;
}

/* Home */
.home {
	width: min(980px, 100%);
	margin: 30px auto;
	padding: 0 16px;
	text-align: center;
}

.home-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 18px;
	margin-top: 18px;
}

.app-tile {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 18px 16px;
	color: inherit;
	text-decoration: none;
	transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.app-tile:hover {
	transform: translateY(-2px);
	box-shadow: 0 24px 55px rgba(66, 40, 12, 0.2);
}

.app-icon {
	font-size: 4rem;
	line-height: 1;
	padding: 30px 25px;
	border-bottom: 7px solid var(--accent);
	border-radius: 500px;
	background: var(--accent-bg);
	box-shadow: 0 18px 40px rgba(255, 167, 0, 0.35);
}

.app-label {
	font-weight: 700;
	letter-spacing: 0.02em;
	color: var(--accent);
}

.home-saves {
	width: min(980px, 100%);
	margin: 22px auto 0;
	padding: 0 16px;
	text-align: left;
}

.save-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
}

.save-tag {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--border);
	border-radius: var(--radius-pill);
	background: var(--surface);
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
	overflow: hidden;
}

.save-tag-link {
	display: inline-flex;
	align-items: center;
	padding: 6px 12px;
	text-decoration: none;
	color: inherit;
	font-weight: 700;
	font-size: 0.9rem;
}

.save-tag-link:hover {
	background: rgba(242, 140, 40, 0.14);
}

.save-tag-remove {
	margin: 0;
	padding: 0;
	width: 28px;
	min-height: 28px;
	border: none;
	border-left: 1px solid var(--border);
	border-radius: 0;
	background: rgba(0, 0, 0, 0.03);
	color: inherit;
	font-size: 1rem;
	line-height: 1;
	box-shadow: none;
}

.save-tag-remove:hover {
	background: rgba(242, 140, 40, 0.24);
	transform: none;
}

/* Generic card blocks */
.percent-card,
.recipe-row,
#calcul {
	width: min(720px, 100%);
	margin: 12px auto;
	padding: 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--surface);
	box-shadow: var(--shadow);
}

#calcul {
	width: min(860px, 100%);
	display: none;
}

#calcul.show {
	display: block;
}

.calc-hint {
	width: min(720px, 100%);
	margin: 8px auto 0;
	padding: 10px 14px;
	border: 1px dashed var(--border);
	border-radius: var(--radius-md);
	background: rgba(0, 0, 0, 0.03);
	text-align: center;
	font-weight: 600;
	letter-spacing: 0.02em;
}

/* Percent/Tabs */
.percent-tabs {
	width: min(740px, 100%);
	margin: 0 auto;
}

.tab-list {
	width: min(720px, 100%);
	margin: 18px auto 8px;
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.tab-button {
	border: 1px solid var(--border);
	border-radius: var(--radius-pill);
	background: rgba(0, 0, 0, 0.03);
	padding: 10px 14px;
	font-weight: 700;
	cursor: pointer;
}

.tab-button.is-active {
	background: #f5dfc5;
}

.tab-panel {
	display: none;
}

.tab-panel.is-active {
	display: block;
}

/* Standard field component */
.percent-field {
	display: grid;
	grid-template-columns: 1fr auto minmax(24px, auto);
	grid-template-rows: auto auto;
	gap: 6px 12px;
	align-items: center;
	margin-bottom: 12px;
	padding: 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--surface-soft);
}

.percent-field:last-child {
	margin-bottom: 0;
}

.percent-field.compact {
	padding: 12px;
	margin-bottom: 0;
}

.percent-field.big-field-indice {
	grid-template-columns: 1fr auto minmax(52px, auto);
}

.percent-field label {
	font-weight: 700;
	letter-spacing: 0.02em;
	justify-self: start;
}

.percent-field-indice {
	font-weight: 700;
	opacity: 0.8;
	font-size: 1.25rem;
	justify-self: end;
}

.percent-field input[type="number"] {
	width: 100%;
	padding: 0;
	border: none;
	background: transparent;
	font-size: 2rem;
	color: var(--accent);
	text-align: right;
	appearance: textfield;
}

.percent-field.compact input[type="number"] {
	font-size: 1.35rem;
}

.percent-field input[type="number"]:focus {
	outline: none;
}

.percent-field:focus-within {
	border-color: var(--accent);
	box-shadow: 0 0 10px 6px rgba(242, 140, 40, 0.25);
}

.result {
	display: inline-block;
	padding: 6px 12px;
	border-radius: var(--radius-pill);
	background: rgba(0, 0, 0, 0.06);
	font-weight: 700;
	box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.percent-result {
	margin-top: 8px;
	text-align: center;
}

/* Croix */
.calc-rows {
	display: grid;
	gap: 10px;
}

.calc-row {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}

button {
	margin-top: 12px;
	padding: 10px 14px;
	border-radius: 12px;
	background: rgba(0, 0, 0, 0.03);
	color: var(--accent-strong);
	border: 1px solid var(--border);
	font-weight: 700;
	cursor: pointer;
}
button.action {
	border: 1px solid var(--accent-strong);
	color: var(--accent);
}

.import-bar {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
	margin-top: 10px;
}

.import-input {
	flex: 1 1 380px;
	min-width: 240px;
	height: 38px;
	padding: 8px 10px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface-soft);
	color: var(--text);
}

.import-status {
	margin-top: 8px;
	font-size: 0.9rem;
	opacity: 0.85;
}

.import-status.is-error {
	color: #b64026;
}

#import-yahoo:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.calc-add:hover {
	transform: translateY(-1px);
}

.calc-swap {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	width: fit-content;
	margin: -2px auto 8px;
	padding: 6px 12px;
	min-height: 32px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: rgba(0, 0, 0, 0.03);
	font-size: 0.9rem;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
	transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.calc-swap:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
}

/* Controls */
.calc-controls {
	width: min(720px, 100%);
	margin: 8px auto 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 17px;
	flex-wrap: wrap;
	flex-direction: column;
}

.calc-controls label {
	font-weight: 600;
}

/* Recette chips/buttons */
.units,
.actions {
	list-style: none;
	padding: 0;
	margin: 10px auto;
	display: flex;
	justify-content: center;
	gap: 8px;
	flex-wrap: wrap;
}

.units li,
.actions li {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 36px;
	padding: 8px 14px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: rgba(0, 0, 0, 0.03);
	font-weight: 700;
	cursor: pointer;
	user-select: none;
	transition: transform 0.15s ease, box-shadow 0.2s ease;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.units li:hover,
.actions li:hover {
	transform: translateY(-1px);
}

#units li {
	padding: 0 20px;
	border-radius: 25px;
}

#units li.selected {
	background: var(--accent);
	border-color: var(--accent-strong);
	color: #1f1206;
	box-shadow: 0 8px 18px rgba(242, 140, 40, 0.35);
}

#actions li.reset {
	background: rgba(0, 0, 0, 0.03);
}

#actions li.save {
	background: var(--accent);
	border-color: var(--accent-strong);
	color: #1f1206;
	box-shadow: 0 6px 14px rgba(242, 140, 40, 0.3);
}

#actions li:active {
	transform: translateY(0);
	filter: brightness(0.98);
}

/* Recette layout */
.recipe-row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.recipe-col {
	flex: 1 1 0;
	min-width: 0;
}

.recipe-arrow {
	font-weight: 700;
	opacity: 0.8;
	letter-spacing: 0.06em;
}

.finalresult {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font-size: 1.1rem;
	font-weight: 700;
}

#result:empty::before {
	content: "?";
	opacity: 0.5;
}

.recipe-formule,
#formule {
	width: min(720px, 100%);
	margin: 6px auto 12px;
	text-align: center;
	opacity: 0.7;
}

.autocomplete {
	width: min(720px, 100%);
	margin: 10px auto 16px;
}

.autocomplete ul {
	list-style: none;
	padding: 0;
	margin: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
	gap: 6px;
}

.autocomplete li {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 36px;
	padding: 7px 10px;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: rgba(0, 0, 0, 0.03);
	cursor: pointer;
	transition: transform 0.15s ease, box-shadow 0.2s ease;
	box-shadow: 0 5px 14px rgba(0, 0, 0, 0.07);
}

.autocomplete li:hover {
	transform: translateY(-1px);
	background: rgba(242, 140, 40, 0.24);
	border-color: var(--accent-strong);
	box-shadow: 0 8px 18px rgba(242, 140, 40, 0.28);
}

.autocomplete li:active {
	background: var(--accent);
	border-color: var(--accent-strong);
	color: #1f1206;
}

#calcul-table {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

#calcul .calc-history-row {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 8px;
	align-items: center;
	padding: 8px 10px;
	border-radius: 12px;
}

#calcul .entitle {
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-size: 0.85rem;
	opacity: 0.7;
}

#calcul .calc-history-row[data-id] {
	cursor: pointer;
}

#calcul .calc-history-row[data-id]:hover {
	background: rgba(0, 0, 0, 0.04);
}

.finaltotal {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin: 12px 0;
	font-weight: 700;
}

/* Footer + misc placeholders */
.kalert {
	position: fixed;
	bottom: 12px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 1200;
}

#modale {
	display: none;
}

footer {
	margin: 28px 0 16px;
	text-align: center;
	opacity: 0.6;
	font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 720px) {
	.topbar {
		height: 58px;
		padding: 0 10px;
	}

	.topbar-home,
	.topbar-spacer {
		min-width: 86px;
	}

	.topbar-title {
		font-size: 1rem;
	}

	body {
		padding-top: 76px;
	}

	.calc-row {
		grid-template-columns: 1fr;
	}

	.recipe-row {
		flex-direction: column;
		gap: 10px;
		padding: 10px;
	}

	#calcul .calc-history-row {
		grid-template-columns: 1fr;
		text-align: center;
		gap: 4px;
		padding: 8px 0;
		border-bottom: 1px dashed rgba(80, 60, 20, 0.15);
		border-radius: 0;
	}

	#calcul .entitle {
		display: none;
	}

	.finaltotal {
		flex-direction: column;
		gap: 6px;
	}
}

@media (prefers-color-scheme: dark) {
	:root {
		--surface: #1c1f24;
		--surface-soft: #14171b;
		--page-bg: #0f1216;
		--text: #eef2f6;
		--border: #2e343b;
		--shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
	}

	.calc-hint,
	.units li,
	.actions li,
	.autocomplete li,
	.tab-button,
	.calc-add,
	.result {
		background: rgba(255, 255, 255, 0);
	}

	#units li.selected,
	#actions li.save {
		color: #1a0f06;
	}

	#calcul .calc-history-row[data-id]:hover {
		background: rgba(255, 255, 255, 0.05);
	}
}
