/* iOS grouped-list look, ported from the Guerin meal planner. Dark mode follows the system. */
:root {
	--bg: #f2f2f7;
	--fg: #000;
	--card: #fff;
	--primary: #007aff;
	--muted: rgba(118, 118, 128, 0.12);
	--muted-fg: rgba(60, 60, 67, 0.6);
	--destructive: #ff3b30;
	--success: #34c759;
	--border: rgba(60, 60, 67, 0.18);
	--bar: rgba(249, 249, 249, 0.82);
	--tabbar-h: calc(49px + env(safe-area-inset-bottom));
	color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #000;
		--fg: #fff;
		--card: #1c1c1e;
		--primary: #0a84ff;
		--muted: rgba(118, 118, 128, 0.24);
		--muted-fg: rgba(235, 235, 245, 0.6);
		--destructive: #ff453a;
		--success: #30d158;
		--border: rgba(84, 84, 88, 0.6);
		--bar: rgba(22, 22, 24, 0.82);
	}
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	letter-spacing: -0.01em;
	-webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { touch-action: manipulation; cursor: pointer; }
h1, h2, p { margin: 0; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--muted-fg); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.bar { background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
header.top { position: sticky; top: 0; z-index: 30; padding-top: env(safe-area-inset-top); box-shadow: inset 0 -0.5px 0 var(--border); }
.top-inner { max-width: 72rem; margin: 0 auto; height: 52px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-weight: 700; font-size: 17px; text-decoration: none; color: var(--fg); display: flex; align-items: center; gap: 8px; }
.brand img { width: 26px; height: 26px; }
.nav-pills { display: none; gap: 4px; }
.nav-pills a { padding: 6px 14px; border-radius: 999px; font-size: 15px; font-weight: 500; text-decoration: none; color: var(--muted-fg); }
.nav-pills a[aria-current="page"] { background: var(--muted); color: var(--fg); }
.link-btn { background: none; border: 0; padding: 6px 0; color: var(--primary); font-size: 15px; }

main { max-width: 72rem; margin: 0 auto; padding: 24px 16px calc(var(--tabbar-h) + 32px); }
.page-head { margin-bottom: 24px; }
.large-title { font-size: 34px; line-height: 1.2; font-weight: 700; letter-spacing: 0.01em; text-wrap: balance; }
.page-head p { margin-top: 4px; color: var(--muted-fg); }

.tabbar { position: fixed; inset: auto 0 0 0; z-index: 30; display: flex; height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom); box-shadow: inset 0 0.5px 0 var(--border); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; font-weight: 500; color: var(--muted-fg); text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tabbar svg { width: 26px; height: 26px; }

@media (min-width: 640px) {
	.top-inner { height: 56px; padding: 0 24px; }
	.nav-pills { display: flex; }
	.tabbar { display: none; }
	main { padding: 40px 24px 48px; }
	.page-head { margin-bottom: 40px; }
}
@media (min-width: 1024px) { main, .top-inner { padding-left: 32px; padding-right: 32px; } }

/* ---------- grouped lists ---------- */
.section-label { padding: 0 16px; margin-bottom: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted-fg); display: flex; align-items: center; gap: 8px; }
.section-label .count { margin-left: auto; text-transform: none; font-variant-numeric: tabular-nums; }
.card { background: var(--card); border-radius: 16px; overflow: hidden; }
.list > * + * { box-shadow: inset 16px 0.5px 0 var(--card), inset 0 0.5px 0 var(--border); }
.list.with-icon > * + * { box-shadow: inset 58px 0.5px 0 var(--card), inset 0 0.5px 0 var(--border); }
.row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 16px; width: 100%; text-align: left; background: none; border: 0; }
button.row:hover:not(:disabled) { background: var(--muted); }
button.row:active:not(:disabled) { opacity: 0.6; }
button.row:disabled { cursor: not-allowed; }
.row .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .aside { color: var(--muted-fg); font-size: 15px; flex-shrink: 0; }
.row:disabled .label, .row:disabled .icon { opacity: 0.4; }
.check { width: 20px; height: 20px; color: var(--primary); flex-shrink: 0; opacity: 0; transition: opacity 0.15s; }
[aria-checked="true"] .check { opacity: 1; }
.empty { padding: 24px 16px; text-align: center; color: var(--muted-fg); font-size: 15px; }
.stack > * + * { margin-top: 32px; }

.icon { width: 30px; height: 30px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.icon svg { width: 19px; height: 19px; }
.icon.sm { width: 24px; height: 24px; border-radius: 6px; }
.icon.sm svg { width: 15px; height: 15px; }
.icon.appetizer { background: #ff9500; }
.icon.main { background: #ff3b30; }
.icon.side_dish { background: #34c759; }
.icon.dessert { background: #ff2d55; }
.icon.empty-slot { background: none; border: 1px dashed var(--muted-fg); }

/* ---------- picker layout ---------- */
.picker { padding-bottom: 96px; }
.picker aside > * + * { margin-top: 32px; }
.picker .countries { margin-top: 32px; }
.countries-head { margin-bottom: 8px; }
.search { position: relative; margin-top: 8px; }
.search input { width: 100%; height: 40px; border: 0; border-radius: 12px; background: var(--muted); padding: 0 12px; font-size: 17px; outline: none; }
.search input:focus-visible { box-shadow: 0 0 0 2px var(--primary); }
.saved-note { display: flex; gap: 12px; align-items: center; padding: 14px 16px; font-size: 15px; }
.saved-note .dot { width: 28px; height: 28px; border-radius: 50%; background: var(--success); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.saved-note .dot svg { width: 16px; height: 16px; }
.summary { padding: 16px; }
.summary-section { display: none; }
.summary > * + * { margin-top: 16px; }
.summary .what { display: flex; gap: 12px; align-items: center; }
.summary .what strong { display: block; font-size: 17px; }
.status { font-size: 13px; color: var(--muted-fg); display: flex; align-items: center; gap: 6px; }
.status.ok { color: var(--success); }
.status svg { width: 14px; height: 14px; }
.actions { display: flex; gap: 8px; }
.actions .btn { flex: 1; }

.savebar { position: fixed; left: 0; right: 0; bottom: var(--tabbar-h); z-index: 20; padding: 0 16px 12px; transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.3s; }
.savebar:not(.show) { transform: translateY(16px); opacity: 0; pointer-events: none; }
.savebar-inner { max-width: 36rem; margin: 0 auto; display: flex; align-items: center; gap: 12px; border-radius: 16px; padding: 8px 8px 8px 16px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16), 0 0 0 0.5px var(--border); }
.savebar-inner .txt { flex: 1; min-width: 0; }
.savebar-inner .txt p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.savebar-inner .txt p:first-child { font-weight: 600; font-size: 15px; }
.savebar-inner .txt p:last-child { font-size: 13px; color: var(--muted-fg); }

@media (min-width: 640px) {
	.countries-head { display: flex; align-items: flex-end; justify-content: space-between; height: 40px; }
	.search { margin-top: 0; width: 16rem; }
	.countries-head .section-label { margin-bottom: 0; }
	.savebar { bottom: env(safe-area-inset-bottom); padding-bottom: 24px; }
	.grid-2 { display: grid; grid-template-columns: 1fr 1fr; }
	.grid-2.list > * + * { box-shadow: none; }
	.grid-2.list > * { box-shadow: inset 16px 0.5px 0 var(--card), inset 0 0.5px 0 var(--border); }
	.grid-2.list > :nth-child(-n + 2) { box-shadow: none; }
	.grid-2.list > :nth-child(even) { border-left: 0.5px solid var(--border); }
}
@media (min-width: 1024px) {
	.picker { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 40px; align-items: start; padding-bottom: 0; }
	.picker aside { grid-column: 2; grid-row: 1; position: sticky; top: 96px; }
	.picker .countries { grid-column: 1; grid-row: 1; margin-top: 0; }
	.course-section .section-label { height: 40px; align-items: flex-end; }
	.summary-section { display: block; }
	.picker aside > .course-section { margin-top: 0; }
	.saved-note, .savebar { display: none !important; }
}

/* ---------- buttons & forms ---------- */
.btn { border: 0; border-radius: 12px; padding: 0 20px; height: 44px; font-weight: 600; font-size: 17px; background: var(--primary); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:active:not(:disabled) { opacity: 0.7; }
.btn.secondary { background: var(--muted); color: var(--primary); }
.btn.ghost { background: none; color: var(--primary); padding: 0 12px; }
.btn.destructive { background: var(--destructive); }
.btn.sm { height: 34px; font-size: 15px; padding: 0 14px; border-radius: 10px; }

.auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 24rem; }
.auth-box .large-title { text-align: center; }
.auth-box > p { text-align: center; color: var(--muted-fg); margin: 8px 0 32px; }
.field { display: flex; align-items: center; min-height: 48px; padding: 0 16px; }
.field label { width: 6.5rem; flex-shrink: 0; }
.field input { flex: 1; min-width: 0; border: 0; background: none; height: 48px; font-size: 17px; outline: none; }
.auth-box .btn { width: 100%; margin-top: 24px; }
.auth-box .switch { margin-top: 16px; text-align: center; font-size: 15px; color: var(--muted-fg); }
.error { color: var(--destructive); font-size: 15px; padding: 8px 16px 0; min-height: 1.5em; }

/* ---------- everyone ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); }
.stats > div { display: flex; flex-direction: column-reverse; align-items: center; padding: 12px 8px; text-align: center; }
.stats > div + div { box-shadow: inset 0.5px 0 0 var(--border); }
.stats dt { font-size: 12px; color: var(--muted-fg); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stats dd { margin: 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; display: flex; gap: 12px; align-items: center; }
.stats dd .icon { display: none; }
.groups > * + * { margin-top: 32px; }
@media (min-width: 640px) {
	.stats > div { flex-direction: row-reverse; justify-content: flex-end; gap: 12px; padding: 16px 20px; text-align: left; }
	.stats dt { font-size: 15px; margin: 0; }
	.stats dd .icon { display: inline-flex; }
}
@media (min-width: 1024px) {
	.groups { display: grid; grid-template-columns: 1fr 1fr; gap: 40px 32px; }
	.groups > * + * { margin-top: 0; }
}

/* ---------- admin ---------- */
.segmented { display: flex; background: var(--muted); border-radius: 9px; padding: 2px; margin-bottom: 24px; max-width: 28rem; }
.segmented button { flex: 1; border: 0; background: none; border-radius: 7px; padding: 6px 0; font-size: 13px; font-weight: 500; }
.segmented button[aria-selected="true"] { background: var(--card); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
.row .sub { display: block; font-size: 13px; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; }
.row select, .row input[type="number"] { border: 0; background: var(--muted); border-radius: 8px; height: 34px; padding: 0 8px; font-size: 15px; max-width: 10rem; }
.row input[type="number"] { width: 5.5rem; text-align: right; }
.row .controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.add-row { display: flex; gap: 8px; padding: 8px 8px 8px 16px; }
.add-row input { flex: 1; border: 0; background: none; font-size: 17px; outline: none; min-width: 0; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--muted); color: var(--muted-fg); }
.limits { display: grid; gap: 32px; align-items: start; }
@media (min-width: 1024px) { .limits { grid-template-columns: 1fr 1fr; } }
.pick-row { flex-wrap: wrap; }
.pick-row .controls { width: 100%; justify-content: flex-start; }
@media (min-width: 640px) { .pick-row { flex-wrap: nowrap; } .pick-row .controls { width: auto; } }

/* ---------- toast & dialog ---------- */
#toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translate(-50%, -150%); z-index: 50; background: var(--card); color: var(--fg); padding: 12px 18px; border-radius: 14px; font-size: 15px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 0 0 0.5px var(--border); transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1); max-width: calc(100vw - 32px); }
#toast.show { transform: translate(-50%, 0); }
#toast.err { color: var(--destructive); }
dialog { border: 0; border-radius: 16px; padding: 20px; background: var(--card); color: var(--fg); width: min(20rem, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dialog-title { font-weight: 600; text-align: center; }
.dialog-body { font-size: 13px; text-align: center; margin-top: 4px; color: var(--muted-fg); }
.dialog-actions { display: flex; gap: 8px; margin-top: 20px; }
.dialog-actions .btn { flex: 1; }

footer.foot { margin-top: 64px; text-align: center; font-size: 13px; color: var(--muted-fg); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* helpers (no inline styles: the CSP is style-src 'self') */
.span-all { grid-column: 1 / -1; }
ul.plain { list-style: none; margin: 0; padding: 0; }
.aside.big { font-size: 17px; }
dl.stats { margin: 0; }
.btn.danger { color: var(--destructive); }
.btn.spaced { margin-top: 24px; }
