/* ============================================================
   Holiday Mashup — design system
   ============================================================ */

:root {
	--bg: #eef1f8;
	--bg-accent: #e5e9f8;
	--surface: #ffffff;
	--surface-2: #f3f5fb;
	--surface-hover: #eef1f9;
	--border: #e2e6ef;
	--border-strong: #ccd3e2;
	--text: #1a1f2e;
	--text-muted: #5b6478;
	--accent: #4f46e5;
	--accent-strong: #4338ca;
	--accent-soft: #ecebfe;
	--on-accent: #ffffff;
	--focus: #6366f1;
	--today: #4f46e5;
	--danger: #dc2626;
	--danger-soft: #fdecec;
	--shadow-sm: 0 1px 2px rgba(20, 26, 45, .06), 0 1px 3px rgba(20, 26, 45, .08);
	--shadow-md: 0 4px 12px rgba(20, 26, 45, .08), 0 2px 4px rgba(20, 26, 45, .06);
	--shadow-lg: 0 18px 48px rgba(20, 26, 45, .18);
	--radius-sm: 8px;   /* inner elements — concentric with --radius-lg minus 1rem surface padding */
	--radius: 16px;
	--radius-lg: 24px;
	--pill-text: #ffffff;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #0e1117;
		--bg-accent: #141a2b;
		--surface: #171b24;
		--surface-2: #1f2430;
		--surface-hover: #232937;
		--border: #2a303c;
		--border-strong: #3a4252;
		--text: #e6e9f0;
		--text-muted: #9aa3b5;
		--accent: #818cf8;
		--accent-strong: #a5b4fc;
		--accent-soft: #232945;
		--on-accent: #0e1117;
		--focus: #a5b4fc;
		--today: #818cf8;
		--danger: #f87171;
		--danger-soft: #2a1c1e;
		--shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
		--shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
		--shadow-lg: 0 22px 55px rgba(0, 0, 0, .6);
		--pill-text: #ffffff;
		color-scheme: dark;
	}
}

:root[data-theme="dark"] {
	--bg: #0e1117;
	--bg-accent: #141a2b;
	--surface: #171b24;
	--surface-2: #1f2430;
	--surface-hover: #232937;
	--border: #2a303c;
	--border-strong: #3a4252;
	--text: #e6e9f0;
	--text-muted: #9aa3b5;
	--accent: #818cf8;
	--accent-strong: #a5b4fc;
	--accent-soft: #232945;
	--on-accent: #0e1117;
	--focus: #a5b4fc;
	--today: #818cf8;
	--danger: #f87171;
	--danger-soft: #2a1c1e;
	--shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
	--shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
	--shadow-lg: 0 22px 55px rgba(0, 0, 0, .6);
	--pill-text: #ffffff;
	color-scheme: dark;
}

:root[data-theme="light"] {
	color-scheme: light;
}

* { box-sizing: border-box; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

html, body {
	margin: 0;
	padding: 0;
	font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
	background: var(--bg);
	color: var(--text);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

body {
	background: radial-gradient(1200px 600px at 100% -10%, var(--bg-accent), transparent 60%),
				radial-gradient(1000px 500px at -10% 110%, var(--bg-accent), transparent 55%),
				var(--bg);
	min-height: 100vh;
}

a { color: var(--accent-strong); }

:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
	border-radius: 4px;
}

/* --- skip link --- */
.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 100;
	background: var(--accent);
	color: var(--on-accent);
	padding: .65rem 1rem;
	border-radius: 0 0 var(--radius-sm) 0;
	font-weight: 600;
}
.skip-link:focus {
	left: 0;
}

/* ============================================================
   App shell
   ============================================================ */

.app-shell {
	max-width: 1180px;
	margin: 0 auto;
	padding: 1.25rem clamp(.75rem, 3vw, 2rem) 2rem;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.app-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: .5rem 0 1.25rem;
}

.app-header__brand {
	display: flex;
	align-items: center;
	gap: .75rem;
}

.app-header__logo {
	display: grid;
	place-items: center;
	width: 46px;
	height: 46px;
	border-radius: 13px;
	background: linear-gradient(135deg, var(--accent), var(--accent-strong));
	color: var(--on-accent);
	box-shadow: var(--shadow-md);
}

.app-header__titles { display: flex; flex-direction: column; line-height: 1.15; }
.app-header__title { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; }
.app-header__tagline { font-size: .82rem; color: var(--text-muted); }

.app-main { flex: 1; outline: none; }

.app-footer {
	margin-top: 2rem;
	padding-top: 1rem;
	border-top: 1px solid var(--border);
	font-size: .82rem;
	color: var(--text-muted);
	text-align: center;
}

/* --- screen-reader-only text --- */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* ============================================================
   Stats strip — visit counters above the footer

   Deliberately container-less: the numbers sit straight on the page,
   split by a hairline, so the counter doesn't compete with the calendar.
   ============================================================ */

.stats-strip {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	margin-top: 2rem;
}

.stats-strip__stat {
	display: flex;
	flex-direction: column;
	gap: .2rem;
	/* Padding rather than gap, so the hairline sits centred between the two. */
	padding: 0 clamp(1.5rem, 5vw, 3rem);
}
.stats-strip__stat + .stats-strip__stat { border-left: 1px solid var(--border); }
.stats-strip__stat:first-child { padding-left: 0; }
.stats-strip__stat:last-child { padding-right: 0; }

.stats-strip__label {
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: var(--text-muted);
}

.stats-strip__value {
	font-size: clamp(1.9rem, 4vw, 2.3rem);
	font-weight: 600;
	letter-spacing: -.03em;
	line-height: 1.1;
	color: var(--text);
}
/* Equal-width digits only while counting, so the number doesn't jitter.
   At rest it uses the font's proportional figures. */
.stats-strip__value.is-animating { font-variant-numeric: tabular-nums; }

.stats-strip__value--skeleton {
	width: 3.5ch;
	height: 1.1em;
	border-radius: var(--radius-sm);
	background: linear-gradient(90deg, var(--surface-2), var(--surface-hover), var(--surface-2));
	background-size: 200% 100%;
	animation: hm-shimmer 1.4s ease-in-out infinite;
}

/* Stacked on very narrow screens — a vertical hairline reads as a mistake once wrapped. */
@media (max-width: 380px) {
	.stats-strip { flex-direction: column; align-items: center; gap: 1.1rem; }
	.stats-strip__stat { padding: 0; }
	.stats-strip__stat + .stats-strip__stat { border-left: 0; }
}
@keyframes hm-shimmer {
	from { background-position: 200% 0; }
	to   { background-position: -200% 0; }
}

/* ============================================================
   Theme toggle
   ============================================================ */

.theme-toggle {
	display: inline-flex;
	align-items: center;
	gap: .5rem;
	padding: .5rem .85rem;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	border-radius: 999px;
	cursor: pointer;
	font-weight: 600;
	font-size: .85rem;
	box-shadow: var(--shadow-sm);
	transition: background .15s ease, transform .15s ease, border-color .15s ease;
}
.theme-toggle:hover { background: var(--surface-hover); transform: translateY(-1px); }
.theme-toggle__icon { display: inline-flex; color: var(--accent); }

/* ============================================================
   Buttons & shared controls
   ============================================================ */

.btn-primary {
	border: none;
	background: linear-gradient(135deg, var(--accent), var(--accent-strong));
	color: var(--on-accent);
	padding: .6rem 1.1rem;
	border-radius: var(--radius-sm);
	font-weight: 600;
	cursor: pointer;
	box-shadow: var(--shadow-sm);
	transition: transform .15s ease, filter .15s ease;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-primary.btn-sm { padding: .4rem .8rem; font-size: .85rem; }

.btn-text {
	border: none;
	background: transparent;
	color: var(--accent-strong);
	font-weight: 600;
	cursor: pointer;
	padding: .4rem .6rem;
	border-radius: var(--radius-sm);
	font-size: .85rem;
}
.btn-text:hover { background: var(--accent-soft); }
.btn-text:disabled { color: var(--text-muted); cursor: not-allowed; background: none; }

/* toolbar action — quieter than btn-primary, more present than btn-text */
.btn-ghost {
	display: inline-flex;
	align-items: center;
	gap: .4rem;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	padding: .45rem .8rem;
	border-radius: var(--radius-sm);
	font-size: .85rem;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: background .15s ease, border-color .15s ease;
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-ghost:disabled { color: var(--text-muted); cursor: not-allowed; }

.stepper-btn {
	width: 34px;
	height: 34px;
	display: grid;
	place-items: center;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	border-radius: var(--radius-sm);
	cursor: pointer;
	font-size: 1.1rem;
	line-height: 1;
	transition: background .15s ease;
}
.stepper-btn:hover { background: var(--surface-hover); }

.field-label {
	display: block;
	font-size: .72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--text-muted);
	margin-bottom: .35rem;
}

/* ============================================================
   Toolbar
   ============================================================ */

.calendar-page { display: flex; flex-direction: column; gap: 1rem; }

/* selection bar: country picker inline to the left of the legend */
.selection-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem 1.5rem;
}
.selection-bar .legend { flex: 1 1 12rem; }
/* the legend grows, so the actions settle against the right edge on their own */
.selection-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.year-stepper, .month-nav {
	display: inline-flex;
	align-items: center;
	gap: .5rem;
}
.year-stepper__value {
	font-size: 1.2rem;
	font-weight: 800;
	min-width: 3.2rem;
	text-align: center;
}
.month-nav__value {
	font-weight: 700;
	min-width: 9rem;
	text-align: center;
}

/* view switch (segmented) */
.view-switch {
	display: inline-flex;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 3px;
}
.view-switch__btn {
	border: none;
	background: transparent;
	color: var(--text-muted);
	padding: .4rem 1rem;
	border-radius: 999px;
	font-weight: 600;
	font-size: .85rem;
	cursor: pointer;
	transition: all .15s ease;
}
.view-switch__btn.is-active {
	background: var(--surface);
	color: var(--accent-strong);
	box-shadow: var(--shadow-sm);
}

/* filters */
.filter-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: .5rem 1.5rem;
	padding: .35rem 0 .1rem;
}
.filter-bar__summary {
	margin: 0;
	font-size: .85rem;
	color: var(--text-muted);
}

.filter-group {
	border: none;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	gap: 1.25rem;
	flex-wrap: wrap;
}
.filter-group__legend {
	float: left;
	font-size: .72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--text-muted);
	margin-right: .5rem;
	padding: 0;
}

/* toggle switch */
.switch {
	display: inline-flex;
	align-items: center;
	gap: .55rem;
	cursor: pointer;
	font-size: .9rem;
	font-weight: 500;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
	position: relative;
	width: 40px;
	height: 22px;
	border-radius: 999px;
	background: var(--border-strong);
	transition: background .18s ease;
	flex: none;
}
.switch__track::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	box-shadow: var(--shadow-sm);
	transition: transform .18s ease;
}
.switch input:checked + .switch__track { background: var(--accent); }
/* The knob sits on --accent once checked, so it has to use the accent's own
   contrast colour rather than staying white — a light accent swallows white. */
.switch input:checked + .switch__track::after {
	transform: translateX(18px);
	background: var(--on-accent);
}
.switch input:focus-visible + .switch__track {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

/* ============================================================
   Country picker
   ============================================================ */

.country-picker { position: relative; min-width: 220px; }

.country-picker__button {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
	padding: .6rem .85rem;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	border-radius: var(--radius-sm);
	cursor: pointer;
	font-weight: 600;
	box-shadow: var(--shadow-sm);
}
.country-picker__button:hover { background: var(--surface-hover); }
.country-picker__placeholder { color: var(--text-muted); font-weight: 500; }
.country-picker__chevron { color: var(--text-muted); }

.country-picker__backdrop {
	position: fixed;
	inset: 0;
	z-index: 30;
}
.country-picker__panel {
	position: absolute;
	z-index: 31;
	top: calc(100% + .4rem);
	left: 0;
	width: min(340px, 90vw);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-lg);
	padding: .75rem;
	display: flex;
	flex-direction: column;
	gap: .5rem;
}
.country-picker__search-input {
	width: 100%;
	padding: .55rem .7rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	color: var(--text);
	font-size: .9rem;
}
.country-picker__list {
	max-height: 300px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 1px;
}
.country-option {
	display: flex;
	align-items: center;
	gap: .6rem;
	padding: .5rem .55rem;
	border-radius: var(--radius-sm);
	cursor: pointer;
	font-size: .9rem;
}
.country-option:hover { background: var(--surface-hover); }
.country-option--selected { background: var(--accent-soft); }
.country-option input { accent-color: var(--accent); width: 16px; height: 16px; }
.country-option__dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--border-strong); flex: none; }
.country-option__name { flex: 1; }
.country-option__code { color: var(--text-muted); font-size: .75rem; font-weight: 600; }
.country-picker__empty { color: var(--text-muted); font-size: .85rem; padding: .5rem; margin: 0; }
.country-picker__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-top: 1px solid var(--border);
	padding-top: .5rem;
}

/* ============================================================
   Legend
   ============================================================ */

.legend { display: flex; flex-wrap: wrap; }
.legend__items { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin: 0; padding: 0; }
.legend__item { display: inline-flex; align-items: center; gap: .45rem; font-size: .85rem; }
.legend__swatch { width: 14px; height: 14px; border-radius: 4px; }

/* current local time per country — tabular numerals so ticking doesn't shift the row */
.legend__time {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
}
.legend__meta {
	color: var(--text-muted);
	font-size: .78rem;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
}

/* ============================================================
   Status line & states
   ============================================================ */

.status-line {
	font-size: .85rem;
	color: var(--text-muted);
	padding: 0 .25rem;
}
/* stays in the DOM as a live region, but takes no space (and no flex gap) when silent */
.status-line:empty { display: none; }

/* embed: tighter, and the host page supplies the surrounding chrome */
.app-shell--embed { padding: .75rem; gap: .75rem; min-height: 0; }
.app-footer--embed { justify-content: flex-end; padding-top: .5rem; font-size: .78rem; }

/* first-visit guess — stated plainly rather than passed off as the visitor's choice */
.guess-note {
	margin: 0;
	padding: .5rem .8rem;
	border-radius: var(--radius-sm);
	background: var(--accent-soft);
	color: var(--accent-strong);
	font-size: .85rem;
}

.calendar-surface {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm);
	padding: 1rem;
	min-height: 420px;
}

.calendar-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: .75rem 1rem;
	padding-bottom: 1rem;
	margin-bottom: 1rem;
	border-bottom: 1px solid var(--border);
}
.calendar-header__nav {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: .5rem 1.25rem;
}

.empty-state {
	text-align: center;
	padding: 3.5rem 1.5rem;
	color: var(--text-muted);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .5rem;
}
.empty-state__icon { font-size: 3rem; }
.empty-state h2 { margin: .25rem 0; color: var(--text); }
.empty-state p { max-width: 30rem; margin: 0 auto; }
.empty-state--error .empty-state__icon { filter: none; }

.calendar-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	padding: 4rem 1rem;
	color: var(--text-muted);
}

/* shared spinner (also used by index.html loading screen) */
.app-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	min-height: 60vh;
	color: var(--text-muted);
	font-family: "Segoe UI", system-ui, sans-serif;
}
.app-loading__title {
	margin: 0;
	font-size: 1.5rem;
	font-weight: 800;
	letter-spacing: -.02em;
	color: var(--text);
}
.app-loading__blurb {
	margin: 0;
	max-width: 30rem;
	padding: 0 1.25rem;
	text-align: center;
	line-height: 1.6;
}
.app-loading__text { margin: 0; font-size: .88rem; opacity: .75; }
.app-loading__spinner {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: 4px solid var(--border, #e2e6ef);
	border-top-color: var(--accent, #4f46e5);
	animation: hm-spin 0.8s linear infinite;
}
@keyframes hm-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Calendar grid
   ============================================================ */

.calendar-grid { display: flex; flex-direction: column; gap: 6px; }

.calendar-grid__weekdays,
.calendar-grid__week {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 6px;
}
.calendar-grid__weekday {
	text-align: center;
	font-size: .72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .05em;
	color: var(--text-muted);
	padding: .35rem 0;
}

.calendar-cell {
	position: relative;
	min-height: 104px;
	background: var(--surface-2);
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	padding: .4rem;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	gap: .3rem;
	overflow: hidden;
	transition: background .12s ease, border-color .12s ease, transform .12s ease;
}
.calendar-cell:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.calendar-cell--muted { opacity: .45; }
.calendar-cell--has { border-color: var(--border); }
.calendar-cell--today {
	background: var(--accent-soft);
	border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.calendar-cell__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .25rem;
}
.calendar-cell__num {
	font-size: .82rem;
	font-weight: 700;
	color: var(--text-muted);
	align-self: flex-start;
	width: 26px;
	height: 26px;
	display: grid;
	place-items: center;
	border-radius: 50%;
}
.calendar-cell--today .calendar-cell__num {
	background: var(--today);
	color: var(--on-accent);
}
.calendar-cell[aria-selected="true"] {
	background: var(--accent-soft);
	border-color: var(--accent);
	box-shadow: 0 0 0 1px var(--accent) inset;
}

.calendar-cell__events { display: flex; flex-direction: column; gap: 3px; }

.event-pill {
	display: flex;
	align-items: center;
	gap: .35rem;
	padding: 2px 6px;
	border-radius: 6px;
	background: var(--pill-color, var(--accent));
	color: var(--pill-text);
	font-size: .72rem;
	font-weight: 600;
	line-height: 1.3;
	overflow: hidden;
}
.event-pill__text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-more { font-size: .7rem; font-weight: 700; color: var(--text-muted); padding-left: 2px; }

/* ============================================================
   Overlap chip — how many selected countries are off that day
   ============================================================ */

/* Its own surface + border rather than a cell tint, so it stays legible on
   --today and [aria-selected] cells, which already own --accent-soft. */
.overlap-chip {
	flex: none;
	display: inline-flex;
	align-items: center;
	padding: 1px 6px;
	border-radius: 999px;
	border: 1px solid var(--border-strong);
	background: var(--surface);
	color: var(--text-muted);
	font-size: .66rem;
	font-weight: 800;
	line-height: 1.5;
	letter-spacing: .03em;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.overlap-chip--all {
	border-color: transparent;
	background: var(--accent);
	color: var(--on-accent);
}

/* ============================================================
   Year at a glance
   ============================================================ */

/* The grid scrolls inside itself; the page must never scroll sideways. */
.year-grid-scroll { overflow-x: auto; padding-bottom: .35rem; }

.year-grid { display: flex; flex-direction: column; gap: 3px; min-width: 640px; }

/* Every row repeats the template so columns line up across months. */
.year-grid__row {
	display: grid;
	grid-template-columns: 2.6rem repeat(31, minmax(0, 1fr));
	gap: 3px;
	align-items: center;
}

.year-grid__month {
	font-size: .72rem;
	font-weight: 700;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: .04em;
}
.year-grid__daynum {
	font-size: .6rem;
	font-weight: 700;
	color: var(--text-muted);
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.year-grid__cell {
	aspect-ratio: 1;
	min-height: 14px;
	border-radius: 3px;
	cursor: pointer;
	--cell-base: var(--surface-2);
	background: color-mix(in srgb, var(--accent) var(--fill, 0%), var(--cell-base));
	transition: outline-color .12s ease;
	outline: 2px solid transparent;
	outline-offset: 1px;
}
/* Weekends get a different base so long weekends read at a glance. */
.year-grid__cell--weekend { --cell-base: var(--surface-hover); }
.year-grid__cell--void { visibility: hidden; }
.year-grid__cell:hover { outline-color: var(--border-strong); }
.year-grid__cell--today { box-shadow: 0 0 0 2px var(--today); }
.year-grid__cell:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 1px;
}

.year-grid__key {
	display: flex;
	flex-wrap: wrap;
	gap: .35rem 1.25rem;
	margin: .9rem 0 0;
	font-size: .78rem;
	color: var(--text-muted);
}
.year-grid__key-item { display: inline-flex; align-items: center; gap: .4rem; }
.year-grid__swatch {
	width: 12px;
	height: 12px;
	border-radius: 3px;
	border: 1px solid var(--border);
	background: color-mix(in srgb, var(--accent) var(--fill, 0%), var(--surface-2));
}
.year-grid__swatch--all { border-color: transparent; }

/* ============================================================
   Meeting window
   ============================================================ */

.meeting { display: flex; flex-direction: column; gap: .85rem; }

.meeting__controls { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; }
.meeting__hours { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-size: .85rem; }
.meeting__hours label { font-weight: 600; }
.meeting__hours select {
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	border-radius: var(--radius-sm);
	padding: .3rem .45rem;
	font: inherit;
	font-variant-numeric: tabular-nums;
}
.meeting__hours-note { color: var(--text-muted); }

.meeting__scroll { overflow-x: auto; }
.meeting__grid { display: flex; flex-direction: column; gap: 4px; min-width: 560px; }

.meeting__row { display: grid; grid-template-columns: 12rem 1fr; gap: .75rem; align-items: center; }
.meeting__row--shared { margin-top: .35rem; padding-top: .5rem; border-top: 1px solid var(--border); }

.meeting__label { display: flex; align-items: center; gap: .4rem; font-size: .85rem; min-width: 0; }
.meeting__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meeting__swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
/* The bar is the capital's zone; say so when the country spans several. */
.meeting__approx { font-size: .7rem; color: var(--text-muted); white-space: nowrap; }

.meeting__track {
	display: grid;
	grid-template-columns: repeat(var(--slot-count, 24), 1fr);
	gap: 2px;
	min-width: 0;
}
.meeting__cell {
	height: 22px;
	border-radius: 3px;
	background: var(--surface-2);
}
.meeting__cell--on { background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }
.meeting__cell--shared { background: var(--accent); }

.meeting__ticks { height: 1rem; position: relative; }
.meeting__tick {
	grid-column: calc(var(--i) + 1) / span 3;
	font-size: .62rem;
	font-weight: 700;
	color: var(--text-muted);
	font-variant-numeric: tabular-nums;
}

.meeting__verdict {
	margin: 0;
	font-size: .92rem;
	font-weight: 600;
	padding: .55rem .8rem;
	border-radius: var(--radius-sm);
	background: var(--accent-soft);
	color: var(--accent-strong);
}
/* No overlap is a legitimate answer, so it reads as information, not an error. */
.meeting__verdict--none { background: var(--surface-2); color: var(--text-muted); }

.meeting__locals {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: .3rem 1.5rem;
	font-size: .82rem;
	color: var(--text-muted);
	font-variant-numeric: tabular-nums;
}
.meeting__none { color: var(--text-muted); }

/* ============================================================
   Badges
   ============================================================ */

.badge {
	display: inline-flex;
	align-items: center;
	padding: .12rem .5rem;
	border-radius: 999px;
	font-size: .68rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .03em;
}
.badge--public { background: var(--accent-soft); color: var(--accent-strong); }
.badge--school {
	background: var(--surface-2);
	color: var(--text-muted);
	border: 1px dashed var(--border-strong);
}

/* ============================================================
   Agenda
   ============================================================ */

.agenda { display: flex; flex-direction: column; gap: 1.5rem; }
.agenda__empty { color: var(--text-muted); text-align: center; padding: 3rem 1rem; }
.agenda__month-title {
	font-size: .95rem;
	font-weight: 800;
	color: var(--accent-strong);
	margin: 0 0 .5rem;
	padding-bottom: .35rem;
	border-bottom: 1px solid var(--border);
}
.agenda__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.agenda__row {
	width: 100%;
	display: flex;
	align-items: center;
	gap: .85rem;
	padding: .6rem .5rem;
	border: none;
	background: transparent;
	color: var(--text);
	border-radius: var(--radius-sm);
	cursor: pointer;
	text-align: left;
}
.agenda__row:hover { background: var(--surface-hover); }
.agenda__date {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 44px;
	flex: none;
}
.agenda__date-day { font-size: 1.15rem; font-weight: 800; line-height: 1; }
.agenda__date-dow { font-size: .68rem; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.agenda__dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.agenda__details { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.agenda__name { font-weight: 600; }
.agenda__sub { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .8rem; color: var(--text-muted); }
.agenda__range { font-size: .78rem; color: var(--text-muted); }

/* ============================================================
   Day detail popover
   ============================================================ */

.popover-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(10, 14, 25, .5);
	backdrop-filter: blur(2px);
	z-index: 50;
}
.day-popover {
	position: fixed;
	z-index: 51;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: min(460px, 92vw);
	max-height: 82vh;
	overflow-y: auto;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-lg);
	padding: 1.25rem;
}
.day-popover__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1rem;
}
.day-popover__title { font-size: 1.1rem; font-weight: 800; margin: 0; }
.day-popover__close {
	border: none;
	background: var(--surface-2);
	color: var(--text-muted);
	width: 32px;
	height: 32px;
	border-radius: 50%;
	cursor: pointer;
	font-size: 1rem;
	flex: none;
}
.day-popover__close:hover { background: var(--surface-hover); color: var(--text); }
.day-popover__empty { color: var(--text-muted); }
.day-popover__overlap {
	margin: 0 0 .25rem;
	padding: .4rem .7rem;
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	color: var(--text-muted);
	font-size: .85rem;
	font-weight: 600;
}
.day-popover__overlap--all {
	background: var(--accent-soft);
	color: var(--accent-strong);
}
.day-popover__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.day-popover__item { display: flex; gap: .75rem; }
.day-popover__country-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: .35rem; flex: none; }
.day-popover__body { display: flex; flex-direction: column; gap: .25rem; }
.day-popover__name { font-weight: 700; }
.day-popover__meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .82rem; color: var(--text-muted); }
.day-popover__range { font-size: .8rem; color: var(--text-muted); }

/* ============================================================
   Not found
   ============================================================ */

.not-found { text-align: center; padding: 4rem 1rem; }
.not-found h1 { margin-bottom: .5rem; }

/* ============================================================
   Blazor error UI
   ============================================================ */

#blazor-error-ui {
	display: none;
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 1000;
	padding: .9rem 1.25rem;
	background: var(--danger);
	color: #fff;
	box-shadow: 0 -2px 10px rgba(0, 0, 0, .2);
	align-items: center;
	gap: 1rem;
}
#blazor-error-ui .reload { color: #fff; font-weight: 700; }
#blazor-error-ui .dismiss { margin-left: auto; background: none; border: none; color: #fff; cursor: pointer; font-size: 1rem; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 720px) {
	.selection-bar { flex-direction: column; align-items: stretch; }
	.country-picker { min-width: 0; }
	/* stacked bar: flex-basis would size the legend's height, padding it out to 12rem */
	.selection-bar .legend { flex: 0 0 auto; }
	/* one country per line — wrapping horizontally leaves ragged dead space here */
	.legend__items {
		flex-direction: column;
		align-items: flex-start;
		gap: .5rem;
	}
	.filter-bar { flex-direction: column; align-items: flex-start; gap: .5rem; }
	/* stack the country label above its bar rather than squeezing both onto one line */
	.meeting__row { grid-template-columns: 1fr; gap: .2rem; }
	.meeting__row--head { display: none; }
	.calendar-cell { min-height: 72px; }
	.calendar-cell__events { display: none; }
	/* pills are gone here, so the chip carries the overlap on its own — keep it, just tighter */
	.overlap-chip { padding: 0 4px; font-size: .6rem; }
	.calendar-cell--has::after {
		content: "";
		position: absolute;
		bottom: 6px;
		left: 50%;
		transform: translateX(-50%);
		width: 6px;
		height: 6px;
		border-radius: 50%;
		background: var(--accent);
	}
}

/* ============================================================
   Print — year wall planner
   ============================================================ */

.print-only { display: none; }

@media print {
	@page { size: A4 landscape; margin: 10mm; }

	/* Force the light palette. Printing the dark theme would put a near-black
	   rectangle on the page, and browsers drop backgrounds by default anyway —
	   so the sheet is defined in ink, not in fills. */
	:root, :root[data-theme="dark"], :root[data-theme="light"] {
		--bg: #ffffff;
		--bg-accent: #ffffff;
		--surface: #ffffff;
		--surface-2: #ffffff;
		--surface-hover: #ffffff;
		--border: #999999;
		--border-strong: #555555;
		--text: #000000;
		--text-muted: #333333;
		--accent: #000000;
		--accent-strong: #000000;
		--accent-soft: #ffffff;
		--on-accent: #ffffff;
		--today: #000000;
		--shadow-sm: none;
		--shadow-md: none;
		--shadow-lg: none;
		color-scheme: light;
	}

	body { background: #fff; color: #000; }

	.print-only { display: block; }

	/* Everything that isn't the planner */
	.app-header,
	.app-footer,
	.stats-strip,
	.selection-bar,
	.status-line,
	.calendar-header,
	.filter-bar,
	.skip-link,
	.year-grid__key,
	#blazor-error-ui { display: none !important; }

	.app-shell, .app-main, .calendar-surface {
		display: block;
		padding: 0;
		margin: 0;
		border: none;
		box-shadow: none;
		background: none;
		max-width: none;
	}

	.print-title h1 { font-size: 16pt; margin: 0 0 2mm; }
	.print-title p { font-size: 9pt; margin: 0 0 4mm; color: #333; }

	/* The grid must fit the page, so it stops being a scroller. */
	.year-grid-scroll { overflow: visible; }
	.year-grid { min-width: 0; gap: 1.2pt; }
	.year-grid__row { gap: 1.2pt; }
	.year-grid__month, .year-grid__daynum { font-size: 6.5pt; color: #000; }

	/* A colour ramp collapses in black and white, so intensity is carried by a
	   border weight that survives, with the fill as a bonus where it prints. */
	.year-grid__cell {
		aspect-ratio: auto;
		height: 4.6mm;
		min-height: 0;
		border: 0.4pt solid #bbb;
		border-radius: 0;
		background: #fff;
		outline: none;
		box-shadow: none;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}
	.year-grid__cell--weekend { background: #f0f0f0; }
	.year-grid__cell[style*="--fill:0%"] { background: #fff; }
	/* Shared days: hatched grey. Everyone-off: solid, plus a heavy border so it
	   still reads if the printer drops backgrounds entirely. */
	.year-grid__cell:not([style*="--fill:0%"]) { background: #c9c9c9; border-color: #666; }
	.year-grid__cell--all { background: #444; border: 1pt solid #000; }

	.print-dates { margin-top: 5mm; break-inside: avoid; }
	.print-dates h2 { font-size: 10pt; margin: 0 0 2mm; }
	.print-dates ul {
		list-style: none;
		margin: 0;
		padding: 0;
		columns: 3;
		column-gap: 8mm;
		font-size: 8pt;
		line-height: 1.5;
	}
	.print-dates li { break-inside: avoid; }

	a[href]::after { content: none; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: .001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .001ms !important;
	}
}
