:root {
	color-scheme: light dark;
	--bg: #f7f4ee;
	--bg-card: #ffffff;
	--bg-subtle: #f0ece1;
	--fg: #2c2523;
	--fg-muted: #726861;
	--accent: #c46d3b;
	--accent-hover: #b05c2d;
	--accent-subtle: #faefe7;
	--accent-text: #8c4118;
	--cafe-espresso: #3d2a24;
	--cafe-crema: #e8d7c3;
	--cafe-matcha: #43694f;
	--cafe-matcha-bg: #eaf2eb;
	--border: #e3dcce;
	--border-dashed: #d4ccbe;
	--danger: #b42318;
	--radius: 12px;
	--radius-sm: 8px;
	--radius-lg: 18px;
	--space: 1rem;
	--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	--font-serif: "Playfair Display", Georgia, "Times New Roman", serif;
	--shadow-sm: 0 2px 6px rgba(44, 37, 35, 0.04);
	--shadow-md: 0 8px 24px rgba(44, 37, 35, 0.08);
	--shadow-receipt: 0 12px 32px rgba(61, 42, 36, 0.12);
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1c1816;
		--bg-card: #26211e;
		--bg-subtle: #302a27;
		--fg: #f4ede6;
		--fg-muted: #a89b91;
		--accent: #e2854f;
		--accent-hover: #f19763;
		--accent-subtle: #382921;
		--accent-text: #ffb88f;
		--cafe-espresso: #141110;
		--cafe-crema: #423832;
		--cafe-matcha: #689f78;
		--cafe-matcha-bg: #223326;
		--border: #3d3530;
		--border-dashed: #4f453f;
		--shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
		--shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
		--shadow-receipt: 0 12px 32px rgba(0, 0, 0, 0.6);
	}
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font-sans);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	background-image: radial-gradient(var(--border) 1px, transparent 1px);
	background-size: 24px 24px;
	min-height: 100vh;
}

.shell {
	max-width: 68rem;
	margin: 0 auto;
	padding: 1.5rem 1rem 3rem;
}

/* Header */
.cafe-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 1rem;
	padding-bottom: 1.25rem;
	margin-bottom: 1.5rem;
	border-bottom: 2px dashed var(--border);
}

.brand {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.brand-icon {
	width: 2.75rem;
	height: 2.75rem;
	background: var(--accent);
	color: #fff;
	border-radius: var(--radius);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	box-shadow: var(--shadow-sm);
}

.brand-title {
	margin: 0;
	font-size: 1.4rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--fg);
}

.brand-subtitle {
	margin: 0;
	font-size: 0.85rem;
	color: var(--fg-muted);
}

/* Quick Bar (Currency, Reset, Sample Checks) */
.header-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: wrap;
}

/* Layout Grid */
.calc-layout {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1.5rem;
}

@media (min-width: 54rem) {
	.calc-layout {
		grid-template-columns: 1.1fr 0.9fr;
		align-items: start;
	}
}

/* Main Input Column */
.calc-card {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 1.5rem;
	box-shadow: var(--shadow-md);
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

.section-title {
	font-size: 0.825rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--fg-muted);
	margin: 0 0 0.75rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

/* Bill Input Area */
.bill-input-container {
	position: relative;
	display: flex;
	align-items: center;
}

.currency-symbol {
	position: absolute;
	left: 1rem;
	font-size: 1.75rem;
	font-weight: 600;
	color: var(--fg-muted);
	pointer-events: none;
	font-family: var(--font-mono);
}

.bill-input {
	width: 100%;
	padding: 0.85rem 1rem 0.85rem 2.5rem;
	font-size: 2rem;
	font-weight: 700;
	font-family: var(--font-mono);
	color: var(--fg);
	background: var(--bg-subtle);
	border: 2px solid var(--border);
	border-radius: var(--radius);
	transition: all 0.15s ease;
	outline: none;
}

.bill-input:focus {
	border-color: var(--accent);
	background: var(--bg-card);
	box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* Cafe Item Quick-Add Pills */
.quick-orders {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	margin-top: 0.6rem;
}

.order-pill {
	background: var(--bg-subtle);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.35rem 0.75rem;
	font-size: 0.775rem;
	color: var(--fg);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	transition: all 0.15s ease;
}

.order-pill:hover {
	background: var(--accent-subtle);
	border-color: var(--accent);
	color: var(--accent-text);
}

/* Tip Grid */
.tip-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(4.75rem, 1fr));
	gap: 0.5rem;
}

.tip-btn {
	background: var(--bg-subtle);
	border: 2px solid var(--border);
	border-radius: var(--radius);
	padding: 0.75rem 0.4rem;
	text-align: center;
	cursor: pointer;
	transition: all 0.15s ease;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.2rem;
}

.tip-btn:hover {
	border-color: var(--accent);
	background: var(--accent-subtle);
}

.tip-btn.active {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
	box-shadow: 0 4px 12px rgba(196, 109, 59, 0.35);
}

.tip-pct {
	font-size: 1.2rem;
	font-weight: 700;
	font-family: var(--font-mono);
}

.tip-label {
	font-size: 0.7rem;
	opacity: 0.85;
}

.tip-btn.active .tip-label {
	color: #fff;
	opacity: 0.95;
}

.custom-tip-box {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.5rem;
	background: var(--bg-subtle);
	padding: 0.5rem 0.75rem;
	border-radius: var(--radius);
	border: 1px solid var(--border);
}

.custom-tip-input {
	flex: 1;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 0.4rem 0.6rem;
	font-size: 1rem;
	font-family: var(--font-mono);
	background: var(--bg-card);
	color: var(--fg);
}

/* Split Section */
.split-controls {
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: var(--bg-subtle);
	border: 2px solid var(--border);
	border-radius: var(--radius);
	padding: 0.6rem 1rem;
}

.split-count {
	display: flex;
	align-items: baseline;
	gap: 0.4rem;
}

.split-number {
	font-size: 2rem;
	font-weight: 800;
	font-family: var(--font-mono);
	color: var(--fg);
}

.split-label {
	font-size: 0.9rem;
	color: var(--fg-muted);
}

.split-buttons {
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

.stepper-btn {
	width: 2.5rem;
	height: 2.5rem;
	border-radius: 50%;
	border: 1px solid var(--border);
	background: var(--bg-card);
	color: var(--fg);
	font-size: 1.25rem;
	font-weight: 600;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all 0.15s ease;
}

.stepper-btn:hover:not(:disabled) {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent);
}

.stepper-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* Rounding Toggles */
.options-row {
	display: flex;
	gap: 0.6rem;
	flex-wrap: wrap;
}

.option-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	background: var(--bg-subtle);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.4rem 0.85rem;
	font-size: 0.8rem;
	cursor: pointer;
	user-select: none;
	transition: all 0.15s ease;
}

.option-chip.active {
	background: var(--cafe-matcha-bg);
	border-color: var(--cafe-matcha);
	color: var(--cafe-matcha);
	font-weight: 600;
}

/* RECEIPT / BILL RESULT COLUMN */
.receipt-wrapper {
	position: relative;
	perspective: 1000px;
}

.receipt-card {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-receipt);
	overflow: hidden;
	position: relative;
}

/* Perforated top receipt edge */
.receipt-card::before {
	content: "";
	display: block;
	height: 10px;
	background: repeating-linear-gradient(
		-45deg,
		transparent,
		transparent 6px,
		var(--bg) 6px,
		var(--bg) 12px
	);
	border-bottom: 1px dashed var(--border-dashed);
}

.receipt-body {
	padding: 1.5rem;
}

.receipt-header {
	text-align: center;
	border-bottom: 2px dashed var(--border-dashed);
	padding-bottom: 1rem;
	margin-bottom: 1.25rem;
}

.receipt-cafe-name {
	font-size: 1.2rem;
	font-weight: 800;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	margin: 0 0 0.2rem;
}

.receipt-meta {
	font-size: 0.775rem;
	color: var(--fg-muted);
	font-family: var(--font-mono);
	display: flex;
	justify-content: center;
	gap: 0.75rem;
}

/* Big Hero Result Box: Each Person Pays */
.hero-split-box {
	background: var(--accent-subtle);
	border: 2px solid var(--accent);
	border-radius: var(--radius);
	padding: 1.25rem;
	text-align: center;
	margin-bottom: 1.25rem;
	position: relative;
	overflow: hidden;
}

.hero-split-tag {
	display: inline-block;
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--accent-text);
	background: rgba(196, 109, 59, 0.15);
	padding: 0.2rem 0.6rem;
	border-radius: 999px;
	margin-bottom: 0.35rem;
}

.hero-split-amount {
	font-size: 2.75rem;
	font-weight: 900;
	font-family: var(--font-mono);
	color: var(--accent-text);
	line-height: 1.1;
	margin-bottom: 0.25rem;
}

.hero-split-sub {
	font-size: 0.8rem;
	color: var(--fg-muted);
}

/* Itemized Lines */
.receipt-table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 1.25rem;
	font-size: 0.9rem;
}

.receipt-table tr td {
	padding: 0.45rem 0;
	border-bottom: 1px dotted var(--border);
}

.receipt-table tr td:last-child {
	text-align: right;
	font-family: var(--font-mono);
	font-weight: 600;
}

.receipt-table tr.highlight td {
	font-size: 1.05rem;
	font-weight: 800;
	border-top: 2px solid var(--fg);
	border-bottom: 2px solid var(--fg);
	padding: 0.6rem 0;
}

/* Per-person visual avatars / badges */
.people-breakdown {
	background: var(--bg-subtle);
	border-radius: var(--radius);
	padding: 1rem;
	margin-bottom: 1.25rem;
}

.people-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
	gap: 0.5rem;
	margin-top: 0.75rem;
	max-height: 14rem;
	overflow-y: auto;
	padding-right: 0.25rem;
}

.person-card {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 0.5rem 0.6rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 0.2rem;
}

.person-avatar {
	font-size: 1.2rem;
}

.person-name {
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--fg-muted);
}

.person-pay {
	font-size: 0.95rem;
	font-weight: 700;
	font-family: var(--font-mono);
	color: var(--fg);
}

.person-tip-share {
	font-size: 0.675rem;
	color: var(--fg-muted);
}

/* Receipt Actions */
.receipt-actions {
	display: flex;
	gap: 0.5rem;
}

.btn-cafe {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.7rem 1rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--cafe-espresso);
	color: #fff;
	font-weight: 600;
	font-size: 0.9rem;
	cursor: pointer;
	transition: all 0.15s ease;
}

.btn-cafe:hover {
	opacity: 0.9;
	transform: translateY(-1px);
}

.btn-cafe-outline {
	background: transparent;
	color: var(--fg);
	border-color: var(--border);
}

.btn-cafe-outline:hover {
	background: var(--bg-subtle);
	color: var(--fg);
}

/* Notification toast */
.toast {
	position: fixed;
	bottom: 1.5rem;
	left: 50%;
	transform: translateX(-50%);
	background: var(--cafe-espresso);
	color: #fff;
	padding: 0.6rem 1.25rem;
	border-radius: 999px;
	box-shadow: var(--shadow-md);
	font-size: 0.875rem;
	font-weight: 500;
	z-index: 100;
	animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
	from {
		opacity: 0;
		transform: translate(-50%, 10px);
	}
	to {
		opacity: 1;
		transform: translate(-50%, 0);
	}
}

/* Custom Itemized Bill Split Mode (Tab) */
.calc-tabs {
	display: flex;
	gap: 0.25rem;
	background: var(--bg-subtle);
	padding: 0.25rem;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	margin-bottom: 1rem;
}

.calc-tab {
	flex: 1;
	padding: 0.5rem 0.75rem;
	text-align: center;
	border: none;
	background: transparent;
	border-radius: var(--radius-sm);
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--fg-muted);
	cursor: pointer;
	transition: all 0.15s ease;
}

.calc-tab.active {
	background: var(--bg-card);
	color: var(--fg);
	box-shadow: var(--shadow-sm);
}

/* Itemized list */
.item-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.4rem 0;
	border-bottom: 1px solid var(--border);
}

.item-name-input {
	flex: 1.5;
	padding: 0.4rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg-subtle);
	color: var(--fg);
	font-size: 0.85rem;
}

.item-price-input {
	flex: 1;
	padding: 0.4rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg-subtle);
	color: var(--fg);
	font-size: 0.85rem;
	font-family: var(--font-mono);
}

.item-person-select {
	flex: 1;
	padding: 0.4rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg-subtle);
	color: var(--fg);
	font-size: 0.8rem;
}

.btn-icon {
	background: transparent;
	border: none;
	color: var(--fg-muted);
	cursor: pointer;
	padding: 0.25rem 0.5rem;
	border-radius: var(--radius-sm);
	font-size: 1.1rem;
	line-height: 1;
}

.btn-icon:hover {
	color: var(--danger);
	background: var(--bg-subtle);
}

/* Cafe tips guide banner */
.cafe-guide {
	margin-top: 1.5rem;
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1rem 1.25rem;
	display: flex;
	align-items: center;
	gap: 1rem;
	font-size: 0.85rem;
	color: var(--fg-muted);
}

.cafe-guide-icon {
	font-size: 1.75rem;
	flex-shrink: 0;
}
