:root {
	color-scheme: light dark;
	--bg: #ffffff;
	--fg: #0b0d12;
	--muted: #5b6472;
	--accent: #2f6df6;
	--border: #e4e7ec;
	--danger: #b42318;
	--radius: 10px;
	--space: 1rem;
	--font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0b0d12;
		--fg: #f4f6fa;
		--muted: #9aa4b2;
		--accent: #6f9bff;
		--border: #232833;
		--danger: #ff9a8f;
	}
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.shell {
	max-width: 42rem;
	margin: 0 auto;
	padding: calc(var(--space) * 3) var(--space);
}

h1 {
	margin: 0 0 0.5rem;
	font-size: clamp(1.6rem, 4vw, 2.25rem);
	letter-spacing: -0.02em;
}

.lede {
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
}

.hint {
	margin: 0;
	color: var(--muted);
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.55rem 0.9rem;
	border: 1px solid transparent;
	border-radius: var(--radius);
	background: var(--accent);
	color: var(--accent-ink);
	font: inherit;
	font-weight: 700;
	min-height: 44px;
	justify-content: center;
	cursor: pointer;
	transition: transform 0.12s ease;
}

.btn:hover {
	filter: brightness(1.07);
}

.btn:active {
	transform: scale(0.97);
}

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

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

.card {
	padding: var(--space);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
}

.input,
.select,
.textarea {
	width: 100%;
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--fg);
	font: inherit;
}

.field {
	display: grid;
	gap: 0.35rem;
	margin-bottom: var(--space);
}

.field > label {
	font-size: 0.875rem;
	color: var(--muted);
}

.stack {
	display: grid;
	gap: var(--space);
}

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

/*
 * 390px-safe. An unclamped minmax track overflows a 390px viewport once the
 * shell padding is subtracted, and nothing in the pipeline ever looked at a
 * phone-width layout, so every generated app inherited the horizontal scroll.
 * min() clamps the track to the container instead.
 */
.grid {
	display: grid;
	gap: var(--space);
	grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.list {
	display: grid;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.table {
	width: 100%;
	border-collapse: collapse;
}

.table th,
.table td {
	padding: 0.6rem 0.5rem;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

.table th {
	font-size: 0.8125rem;
	color: var(--muted);
	font-weight: 600;
}

.empty {
	padding: calc(var(--space) * 2);
	text-align: center;
	color: var(--muted);
}

.empty-title {
	margin: 0 0 0.25rem;
	color: var(--fg);
	font-weight: 600;
}

/* Loading. Every fetch has one; without a primitive each app invented its own. */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: calc(var(--space) * 1.5);
	color: var(--muted);
}

.spinner {
	flex: none;
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: fab-spin 0.7s linear infinite;
}

@keyframes fab-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Placeholder for content whose shape is known before its data arrives. */
.skeleton {
	display: block;
	height: 1rem;
	border-radius: calc(var(--radius) / 2);
	background: linear-gradient(90deg, var(--border), transparent, var(--border));
	background-size: 200% 100%;
	animation: fab-shimmer 1.2s linear infinite;
}

@keyframes fab-shimmer {
	to {
		background-position: -200% 0;
	}
}

/* Error strip: a failure the user can see and retry, never a silent no-op. */
.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: var(--radius);
}

.alert-error {
	border-left-color: var(--danger);
	color: var(--danger);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	color: var(--muted);
}

/*
 * The scaffold had exactly one @media rule (prefers-color-scheme) and no width
 * breakpoint at all, so the shell was a 42rem column at every size.
 * Mobile-first stays the default; these only widen it.
 */
@media (min-width: 48rem) {
	.shell {
		max-width: 52rem;
		padding: calc(var(--space) * 3) calc(var(--space) * 1.5);
	}
}

@media (min-width: 64rem) {
	.shell {
		max-width: 64rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.spinner,
	.skeleton {
		animation: none;
	}
}

h1, h2, h3, .logo, .order-code { font-family: var(--display); }
a { color: var(--accent); }
.card { background: var(--surface); border-radius: var(--radius-lg); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.btn-block { width: 100%; }
.btn-added { background: var(--ok); }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(14, 16, 34, 0.92); border-bottom: 1px solid var(--border); backdrop-filter: blur(8px); }
.topbar-in { max-width: 64rem; margin: 0 auto; padding: 0.6rem 1rem; display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.logo { font-size: 1.4rem; font-weight: 700; color: var(--fg); text-decoration: none; }
.logo span { color: var(--accent); }
.search { order: 3; flex: 1 1 100%; display: flex; align-items: center; gap: 0.5rem; padding: 0 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted); }
.search input { flex: 1; min-width: 0; min-height: 42px; background: none; border: 0; color: var(--fg); font: inherit; outline: none; }
.cart-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px; padding: 0 0.8rem; background: var(--surface-2); color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius); font: inherit; font-weight: 700; cursor: pointer; }
.cart-count { background: var(--accent); color: var(--accent-ink); border-radius: 4px; padding: 0 0.4rem; font-size: 0.85rem; }
@media (min-width: 48rem) { .search { order: 0; flex: 1 1 auto; max-width: 28rem; } }
.store { display: grid; gap: 1.5rem; padding-top: 1.5rem; }
.hero { display: grid; gap: 1.5rem; }
.hero h1 { font-size: clamp(2.1rem, 7vw, 3.6rem); line-height: 1.05; margin-bottom: 1rem; }
.perks { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; padding: 0; margin: 0; list-style: none; color: var(--muted); font-size: 0.95rem; }
.perks li::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 0.45rem; background: var(--ok); transform: rotate(45deg); }
.hero-deal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.deal-info { padding: 1rem; display: grid; gap: 0.5rem; }
.deal-name { margin: 0; font-weight: 700; font-size: 1.15rem; }
@media (min-width: 48rem) { .hero { grid-template-columns: 1.4fr 1fr; align-items: center; } }
.cover { --h: 220; position: relative; aspect-ratio: 16 / 9; background: hsl(var(--h) 55% 22%); color: hsl(var(--h) 80% 70% / 0.45); overflow: hidden; }
.cover-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover-glyph { position: absolute; left: 1rem; bottom: 0.6rem; font-family: var(--display); font-size: 2.6rem; font-weight: 700; color: hsl(var(--h) 90% 85%); }
.cover-lg .cover-glyph { font-size: 4rem; }
.cover-tag { position: absolute; top: 0.6rem; right: 0.6rem; font-size: 0.75rem; font-weight: 700; padding: 0.15rem 0.45rem; border-radius: 4px; background: rgba(0, 0, 0, 0.35); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { min-height: 40px; padding: 0 0.9rem; background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius); font: inherit; font-weight: 500; cursor: pointer; }
.chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 700; }
.products { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); }
.product { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.off { position: absolute; top: 0.6rem; left: 0.6rem; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.8rem; padding: 0.15rem 0.45rem; border-radius: 4px; }
.product-body { padding: 0.9rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }
.product h3 { margin: 0; font-size: 1.15rem; }
.product-meta { margin: 0; font-size: 0.82rem; color: var(--muted); }
.product-blurb { margin: 0; font-size: 0.92rem; color: var(--muted); flex: 1; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.price-row { margin: 0; display: flex; align-items: baseline; gap: 0.5rem; font-variant-numeric: tabular-nums; }
.price-row strong { font-size: 1.3rem; }
.price-row s { color: var(--muted); font-size: 0.9rem; }
.footer { border-top: 1px solid var(--border); margin-top: 2rem; color: var(--muted); font-size: 0.9rem; }
.footer-in { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 1.25rem; padding-bottom: 1.25rem; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(5, 6, 16, 0.7); display: flex; justify-content: flex-end; }
.drawer { width: min(26rem, 100%); height: 100%; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--border); padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { margin: 0; outline: none; }
.drawer-body { display: flex; flex-direction: column; gap: 0.25rem; }
.drawer-foot { margin-top: auto; display: grid; gap: 0.6rem; padding-top: 1rem; }
.total-row { display: flex; justify-content: space-between; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 1px solid var(--border); border-radius: var(--radius); color: var(--fg); cursor: pointer; }
.cart-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.cart-line { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.75rem; background: var(--surface-2); border-radius: var(--radius); }
.cart-name { margin: 0; font-weight: 700; }
.cart-meta { margin: 0; font-size: 0.85rem; color: var(--muted); }
.qty { display: flex; align-items: center; gap: 0.4rem; }
.qty button { width: 36px; height: 36px; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius); font-size: 1.1rem; cursor: pointer; }
.order-code { font-size: 2rem; color: var(--accent); margin: 0.5rem 0; letter-spacing: 0.05em; }
.owner-login { max-width: 26rem; margin: 2rem auto; }
.owner-top { justify-content: space-between; }
.order-card { display: grid; gap: 0.4rem; }
.order-head { gap: 0.5rem; }
.order-who, .order-note { margin: 0; }
.order-items { margin: 0; padding-left: 1.1rem; }
.order-items span { color: var(--muted); }
.order-foot { justify-content: space-between; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.badge-ok { color: var(--ok); border-color: var(--ok); }
.badge-wait { color: var(--accent); border-color: var(--accent); }

:where(a, button, input, select, textarea):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
