:root {
	color-scheme: dark;
	-webkit-tap-highlight-color: transparent;

	/* ── Typefaces (Material 3) ─────────────── */
	--md-ref-typeface-brand: 'Roboto', system-ui, sans-serif;
	--md-ref-typeface-plain: 'Roboto', system-ui, sans-serif;
	--md-ref-typeface-code: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

	/* ── Color — Beige / Sand dark (fnn-maven) ── */
	--md-sys-color-primary: #d4b89b;
	--md-sys-color-on-primary: #3e2d1a;
	--md-sys-color-primary-container: #5c4328;
	--md-sys-color-on-primary-container: #f0dcc6;
	--md-sys-color-secondary: #c1b5a8;
	--md-sys-color-on-secondary: #2b241d;
	--md-sys-color-secondary-container: #423a32;
	--md-sys-color-on-secondary-container: #ded3c7;
	--md-sys-color-tertiary: #b0c2a5;
	--md-sys-color-on-tertiary: #222b1b;
	--md-sys-color-tertiary-container: #38412f;
	--md-sys-color-on-tertiary-container: #d4e7c7;
	--md-sys-color-error: #f2b8b5;
	--md-sys-color-on-error: #601410;
	--md-sys-color-error-container: #8c1d18;
	--md-sys-color-on-error-container: #f9dedc;
	--md-sys-color-background: #1a1714;
	--md-sys-color-on-background: #e1ddd8;
	--md-sys-color-surface: #1a1714;
	--md-sys-color-on-surface: #e1ddd8;
	--md-sys-color-surface-variant: #4d463f;
	--md-sys-color-on-surface-variant: #ccc5bc;
	--md-sys-color-outline: #958f87;
	--md-sys-color-outline-variant: #4d463f;
	--md-sys-color-surface-bright: #3d3732;
	--md-sys-color-surface-dim: #1a1714;
	--md-sys-color-surface-container: #23201c;
	--md-sys-color-surface-container-low: #1e1b18;
	--md-sys-color-surface-container-lowest: #110f0d;
	--md-sys-color-surface-container-high: #2d2925;
	--md-sys-color-surface-container-highest: #383430;
	--md-sys-color-inverse-surface: #e1ddd8;
	--md-sys-color-inverse-on-surface: #322f2b;
	--md-sys-color-inverse-primary: #7a6044;
	--md-sys-color-scrim: #000;
	--md-sys-color-shadow: #000;

	/* ── Shape (Material 3) ─────────────────── */
	--md-sys-shape-corner-none: 0px;
	--md-sys-shape-corner-extra-small: 4px;
	--md-sys-shape-corner-small: 8px;
	--md-sys-shape-corner-medium: 12px;
	--md-sys-shape-corner-large: 16px;
	--md-sys-shape-corner-extra-large: 28px;
	--md-sys-shape-corner-full: 999px;

	/* ── Elevation (Material 3) ─────────────── */
	--md-sys-elevation-shadow-1: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
	--md-sys-elevation-shadow-2: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
	--md-sys-elevation-shadow-3: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 4px 8px 3px rgba(0, 0, 0, 0.15);

	/* ── Typescale (Material 3) ─────────────── */
	--md-sys-typescale-headline-medium-size: 1.75rem;
	--md-sys-typescale-headline-medium-line-height: 2.25rem;
	--md-sys-typescale-headline-medium-weight: 400;
	--md-sys-typescale-title-large-size: 1.375rem;
	--md-sys-typescale-title-large-line-height: 1.75rem;
	--md-sys-typescale-title-large-weight: 400;
	--md-sys-typescale-title-medium-size: 1rem;
	--md-sys-typescale-title-medium-line-height: 1.5rem;
	--md-sys-typescale-title-medium-weight: 500;
	--md-sys-typescale-title-small-size: 0.875rem;
	--md-sys-typescale-title-small-line-height: 1.25rem;
	--md-sys-typescale-title-small-weight: 500;
	--md-sys-typescale-body-large-size: 1rem;
	--md-sys-typescale-body-large-line-height: 1.5rem;
	--md-sys-typescale-body-large-weight: 400;
	--md-sys-typescale-body-medium-size: 0.875rem;
	--md-sys-typescale-body-medium-line-height: 1.25rem;
	--md-sys-typescale-body-medium-weight: 400;
	--md-sys-typescale-body-small-size: 0.75rem;
	--md-sys-typescale-body-small-line-height: 1rem;
	--md-sys-typescale-body-small-weight: 400;
	--md-sys-typescale-label-large-size: 0.875rem;
	--md-sys-typescale-label-large-line-height: 1.25rem;
	--md-sys-typescale-label-large-weight: 500;
	--md-sys-typescale-label-medium-size: 0.75rem;
	--md-sys-typescale-label-medium-line-height: 1rem;
	--md-sys-typescale-label-medium-weight: 500;
	--md-sys-typescale-label-small-size: 0.6875rem;
	--md-sys-typescale-label-small-line-height: 1rem;
	--md-sys-typescale-label-small-weight: 500;

	/* ── App phase roles ────────────────────── */
	--mca-menstruation: var(--md-sys-color-error);
	--mca-menstruation-bg: color-mix(in srgb, var(--md-sys-color-error) 24%, transparent);
	--mca-fertile: var(--md-sys-color-tertiary);
	--mca-fertile-bg: color-mix(in srgb, var(--md-sys-color-tertiary) 24%, transparent);
	--mca-predicted: var(--md-sys-color-primary);
	--mca-predicted-bg: color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent);
	--mca-luteal: var(--md-sys-color-secondary);
	--mca-luteal-bg: color-mix(in srgb, var(--md-sys-color-secondary) 20%, transparent);
	--mca-follicular: var(--md-sys-color-on-surface-variant);
	--mca-follicular-bg: var(--md-sys-color-surface-container-high);
}

* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

html, body {
	margin: 0;
	padding: 0;
}

body {
	font-family: var(--md-ref-typeface-plain);
	font-size: 16px;
	background: var(--md-sys-color-surface);
	color: var(--md-sys-color-on-surface);
	min-height: 100vh;
	-webkit-text-size-adjust: 100%;
	-webkit-font-smoothing: antialiased;
}

button {
	font-family: inherit;
}

h2 { margin: 0; }

.muted { color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-typescale-body-small-size); }

/* ── Layout (mobile-first) ────────────── */

.app {
	max-width: 42rem;
	margin: 0 auto;
	padding: 0.5rem 0.75rem 8rem;
}

.top-app-bar {
	position: sticky;
	top: 0;
	z-index: 40;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.625rem 0.5rem 0.5rem;
	background: color-mix(in srgb, var(--md-sys-color-surface) 84%, transparent);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--md-sys-color-outline-variant);
	margin-bottom: 0.75rem;
}

.brand {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-width: 0;
}

.brand-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--md-sys-color-primary);
	flex-shrink: 0;
}

.brand h1 {
	margin: 0;
	font-size: var(--md-sys-typescale-title-large-size);
	font-weight: var(--md-sys-typescale-title-large-weight);
	line-height: var(--md-sys-typescale-title-large-line-height);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.today-chip {
	display: inline-flex;
	align-items: center;
	height: 32px;
	padding: 0 12px;
	border-radius: var(--md-sys-shape-corner-full);
	background: var(--md-sys-color-surface-container-high);
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-label-medium-size);
	font-weight: var(--md-sys-typescale-label-medium-weight);
	letter-spacing: 0.1px;
	flex-shrink: 0;
}

.tab-panel { animation: fade 0.2s ease; }

@keyframes fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

/* Desktop top tabs — hidden on mobile */
.top-tabs { display: none; }

/* ── Sphere (Verity) ─────────────────── */

.sphere-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 0.5rem;
}

.sphere-container {
	width: 100%;
	height: 340px;
	border-radius: var(--md-sys-shape-corner-extra-large);
	overflow: hidden;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

.sphere-hint {
	margin: 0.25rem 0 0.25rem;
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-body-small-size);
	text-align: center;
}

/* ── Card ────────────────────────────── */

.card {
	background: var(--md-sys-color-surface-container-lowest);
	border: 1px solid var(--md-sys-color-outline-variant);
	border-radius: var(--md-sys-shape-corner-extra-large);
	padding: 1rem;
	margin-bottom: 0.75rem;
	box-shadow: var(--md-sys-elevation-shadow-1);
	animation: rise 0.3s ease both;
}

@keyframes rise {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

.card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	margin-bottom: 0.875rem;
}

.card-head h2 {
	font-size: var(--md-sys-typescale-title-medium-size);
	font-weight: var(--md-sys-typescale-title-medium-weight);
	line-height: var(--md-sys-typescale-title-medium-line-height);
}

/* ── Hero ────────────────────────────── */

.hero {
	background: var(--md-sys-color-primary-container);
	color: var(--md-sys-color-on-primary-container);
	border-radius: var(--md-sys-shape-corner-extra-large);
	padding: 1.25rem;
	margin-bottom: 0.75rem;
	box-shadow: var(--md-sys-elevation-shadow-2);
	animation: rise 0.3s ease both;
}

.hero-main {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
}

.hero-date {
	display: inline-block;
	font-size: var(--md-sys-typescale-label-medium-size);
	letter-spacing: 0.1px;
	text-transform: uppercase;
	opacity: 0.85;
	margin-bottom: 4px;
}

.hero-day {
	margin: 0 0 0.5rem;
	font-size: var(--md-sys-typescale-headline-medium-size);
	font-weight: var(--md-sys-typescale-headline-medium-weight);
	line-height: var(--md-sys-typescale-headline-medium-line-height);
}

.hero-day b {
	font-size: 2.5rem;
	font-weight: 400;
	line-height: 1;
}

.phase-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	background: color-mix(in srgb, var(--md-sys-color-on-primary-container) 14%, transparent);
	padding: 0.375rem 0.875rem;
	border-radius: var(--md-sys-shape-corner-full);
	font-size: var(--md-sys-typescale-label-large-size);
	font-weight: var(--md-sys-typescale-label-large-weight);
	letter-spacing: 0.1px;
}

.phase-chip::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--md-sys-color-on-primary-container);
}

.hero-ring {
	position: relative;
	width: 120px;
	height: 120px;
	flex: 0 0 auto;
}

.hero-ring svg {
	width: 100%;
	height: 100%;
	transform: rotate(-90deg);
}

.ring-bg {
	fill: none;
	stroke: color-mix(in srgb, var(--md-sys-color-on-primary-container) 25%, transparent);
	stroke-width: 10;
}

.ring-fg {
	fill: none;
	stroke: var(--md-sys-color-on-primary-container);
	stroke-width: 10;
	stroke-linecap: round;
	transition: stroke-dashoffset 0.6s ease;
}

.ring-label {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.ring-label b {
	font-size: 2rem;
	line-height: 1;
	font-weight: 400;
}

.ring-label span {
	font-size: var(--md-sys-typescale-label-small-size);
	opacity: 0.85;
	margin-top: 2px;
}

.hero-stats {
	display: flex;
	gap: 0.5rem;
	margin-top: 1rem;
	overflow-x: auto;
	padding-bottom: 2px;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.hero-stats::-webkit-scrollbar { display: none; }

.stat {
	flex: 0 0 auto;
	min-width: 7.25rem;
	background: color-mix(in srgb, var(--md-sys-color-on-primary-container) 10%, transparent);
	border: 1px solid color-mix(in srgb, var(--md-sys-color-on-primary-container) 18%, transparent);
	border-radius: var(--md-sys-shape-corner-medium);
	padding: 0.625rem 0.875rem;
}

.stat-k {
	display: block;
	font-size: var(--md-sys-typescale-label-small-size);
	opacity: 0.85;
	margin-bottom: 2px;
}

.stat-v {
	font-size: var(--md-sys-typescale-title-medium-size);
	font-weight: var(--md-sys-typescale-title-medium-weight);
}

.stat-v.warn { color: var(--md-sys-color-tertiary); }
.stat-v.bad { color: var(--md-sys-color-error); }

.hero-banner {
	margin-top: 0.875rem;
	border-radius: var(--md-sys-shape-corner-medium);
	padding: 0.6875rem 0.875rem;
	font-size: var(--md-sys-typescale-body-small-size);
	font-weight: var(--md-sys-typescale-label-large-weight);
	letter-spacing: 0.1px;
}

.hero-banner.green { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.hero-banner.amber { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }

.hero-banner.pulse { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
	0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-on-primary-container) 40%, transparent); }
	50% { box-shadow: 0 0 0 8px transparent; }
}

.hero-empty { text-align: center; padding: 1.5rem 0.5rem; }

.hero-empty h2 {
	font-size: var(--md-sys-typescale-headline-medium-size);
	margin: 0 0 0.5rem;
}

.hero-empty p {
	margin: 0 auto 1.125rem;
	max-width: 22rem;
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-body-medium-size);
}

.hero-badge {
	display: inline-flex;
	width: 56px;
	height: 56px;
	border-radius: var(--md-sys-shape-corner-extra-large);
	background: var(--mca-predicted-bg);
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	color: var(--md-sys-color-primary);
	margin-bottom: 0.875rem;
	font-weight: 500;
}

/* ── Timeline ────────────────────────── */

.timeline-track {
	position: relative;
	display: flex;
	gap: 2px;
	height: 12px;
	border-radius: var(--md-sys-shape-corner-full);
	margin: 1rem 0 1.25rem;
}

.tl-seg {
	border-radius: var(--md-sys-shape-corner-full);
	height: 100%;
	min-width: 2px;
}

.tl-seg.rose { background: var(--mca-menstruation); }
.tl-seg.lav { background: var(--mca-follicular); opacity: 0.45; }
.tl-seg.green { background: var(--mca-fertile); }
.tl-seg.amber { background: var(--mca-luteal); opacity: 0.7; }

.tl-marker {
	position: absolute;
	top: -6px;
	width: 2px;
	height: 24px;
	background: var(--md-sys-color-on-surface);
	border-radius: 2px;
	transform: translateX(-50%);
	transition: left 0.4s ease;
}

.tl-marker::after {
	content: "";
	position: absolute;
	top: -5px;
	left: 50%;
	transform: translateX(-50%);
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--md-sys-color-on-surface);
}

.tl-phases {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.5rem;
}

.tl-phase {
	border: 1px solid var(--md-sys-color-outline-variant);
	border-radius: var(--md-sys-shape-corner-medium);
	padding: 0.5rem 0.625rem;
}

.tl-phase.active { border-color: transparent; }

.tl-phase.active.rose { background: var(--mca-menstruation-bg); }
.tl-phase.active.green { background: var(--mca-fertile-bg); }
.tl-phase.active.amber { background: var(--mca-luteal-bg); }
.tl-phase.active.lav { background: var(--mca-follicular-bg); }

.tl-phase b {
	display: block;
	font-size: var(--md-sys-typescale-label-large-size);
	font-weight: var(--md-sys-typescale-label-large-weight);
	line-height: var(--md-sys-typescale-label-large-line-height);
}

.tl-phase span {
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-body-small-size);
}

.dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	margin-right: 6px;
	vertical-align: middle;
}
.dot.rose { background: var(--mca-menstruation); }
.dot.green { background: var(--mca-fertile); }
.dot.amber { background: var(--mca-predicted); }

/* ── Calendar ────────────────────────── */

.cal-nav {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	margin-bottom: 0.75rem;
}

.cal-nav strong {
	flex: 1;
	text-align: center;
	font-size: var(--md-sys-typescale-title-small-size);
	font-weight: var(--md-sys-typescale-title-small-weight);
	text-transform: capitalize;
}

.legend {
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
	font-size: var(--md-sys-typescale-label-small-size);
	color: var(--md-sys-color-on-surface-variant);
}

.legend span { display: inline-flex; align-items: center; }

.cal-grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 2px;
}

.dow {
	text-align: center;
	font-size: var(--md-sys-typescale-label-small-size);
	font-weight: 500;
	letter-spacing: 0.1px;
	color: var(--md-sys-color-on-surface-variant);
	padding: 6px 0 2px;
}

.cell {
	position: relative;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--md-sys-shape-corner-full);
	cursor: pointer;
	user-select: none;
	transition: background 0.12s ease;
}

.cell:hover {
	background: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
}

.cell .n {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	font-size: var(--md-sys-typescale-body-medium-size);
	font-weight: 500;
}

.cell.out {
	color: var(--md-sys-color-on-surface);
	opacity: 0.25;
	pointer-events: none;
}

.cell.t .n { box-shadow: 0 0 0 1.5px var(--md-sys-color-primary); }

.cell.p .n { background: var(--mca-menstruation-bg); color: var(--mca-menstruation); font-weight: 600; }
.cell.ov .n { background: var(--md-sys-color-tertiary); color: var(--md-sys-color-on-tertiary); font-weight: 600; }

.cell.pd::after,
.cell.f::after {
	content: "";
	position: absolute;
	bottom: 3px;
	width: 5px;
	height: 5px;
	border-radius: 50%;
}

.cell.pd::after { background: var(--mca-predicted); }
.cell.f::after { background: var(--mca-fertile); }

/* ── Insights + predictions ──────────── */

.insights {
	display: flex;
	gap: 0.375rem;
	flex-wrap: wrap;
}

.chip {
	display: inline-flex;
	align-items: center;
	height: 32px;
	padding: 0 12px;
	border-radius: var(--md-sys-shape-corner-full);
	background: var(--md-sys-color-surface-container-high);
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-label-medium-size);
	font-weight: var(--md-sys-typescale-label-medium-weight);
	letter-spacing: 0.1px;
}

.chip.green { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.chip.amber { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }

.predictions {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.pred {
	border: 1px solid var(--md-sys-color-outline-variant);
	border-radius: var(--md-sys-shape-corner-large);
	padding: 0.875rem 1rem;
	background: var(--md-sys-color-surface-container-lowest);
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.pred:hover {
	border-color: var(--md-sys-color-primary);
	background: var(--md-sys-color-surface-container-low);
}

.pred.current {
	border-color: var(--md-sys-color-primary);
	background: var(--mca-predicted-bg);
}

.pred-tag {
	font-size: var(--md-sys-typescale-label-small-size);
	text-transform: uppercase;
	letter-spacing: 0.1px;
	color: var(--md-sys-color-on-surface-variant);
	font-weight: 500;
}

.pred-date {
	font-size: var(--md-sys-typescale-title-large-size);
	font-weight: var(--md-sys-typescale-title-large-weight);
	line-height: var(--md-sys-typescale-title-large-line-height);
	margin: 2px 0;
}

.pred-range {
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-body-small-size);
	margin-bottom: 0.625rem;
}

.pred-meta {
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: var(--md-sys-typescale-body-small-size);
	color: var(--md-sys-color-on-surface-variant);
}

.live {
	display: inline-block;
	margin-left: 8px;
	font-size: var(--md-sys-typescale-label-small-size);
	font-weight: 700;
	text-transform: uppercase;
	color: var(--md-sys-color-tertiary);
	animation: blink 1.4s infinite;
}

@keyframes blink { 50% { opacity: 0.35; } }

/* ── Records ─────────────────────────── */

.records { display: flex; flex-direction: column; }

.record {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.75rem 0.25rem;
	min-height: 48px;
	border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.record i {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--mca-menstruation);
	flex: 0 0 auto;
}

.record .r-date {
	flex: 1;
	font-size: var(--md-sys-typescale-body-medium-size);
	font-weight: var(--md-sys-typescale-label-large-weight);
}

.record .r-dur {
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-body-small-size);
}

.empty {
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-body-medium-size);
	text-align: center;
	padding: 1rem;
}

/* ── Buttons (Material 3) ────────────── */

.primary-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	height: 40px;
	padding: 0 1.5rem;
	border: none;
	border-radius: var(--md-sys-shape-corner-full);
	background: var(--md-sys-color-primary);
	color: var(--md-sys-color-on-primary);
	font-size: var(--md-sys-typescale-label-large-size);
	font-weight: var(--md-sys-typescale-label-large-weight);
	letter-spacing: 0.1px;
	line-height: var(--md-sys-typescale-label-large-line-height);
	cursor: pointer;
	box-shadow: var(--md-sys-elevation-shadow-1);
	transition: background 0.15s ease, box-shadow 0.15s ease;
}

.primary-btn:hover {
	background: color-mix(in srgb, var(--md-sys-color-primary) 88%, var(--md-sys-color-on-primary));
	box-shadow: var(--md-sys-elevation-shadow-2);
}

.primary-btn:active { box-shadow: var(--md-sys-elevation-shadow-1); }

.ghost-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 40px;
	padding: 0 1rem;
	border: none;
	border-radius: var(--md-sys-shape-corner-full);
	background: transparent;
	color: var(--md-sys-color-primary);
	font-size: var(--md-sys-typescale-label-large-size);
	font-weight: var(--md-sys-typescale-label-large-weight);
	letter-spacing: 0.1px;
	line-height: var(--md-sys-typescale-label-large-line-height);
	cursor: pointer;
	transition: background 0.15s ease;
}

.ghost-btn:hover { background: var(--mca-predicted-bg); }

.ghost-btn.danger { color: var(--md-sys-color-error); }
.ghost-btn.danger:hover { background: var(--mca-menstruation-bg); }

.icon-btn {
	width: 40px;
	height: 40px;
	border-radius: var(--md-sys-shape-corner-full);
	border: none;
	background: transparent;
	color: var(--md-sys-color-on-surface-variant);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease;
}

.icon-btn:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent); }
.icon-btn:active { background: color-mix(in srgb, var(--md-sys-color-on-surface) 14%, transparent); }

.del-btn {
	border: none;
	background: transparent;
	color: var(--md-sys-color-on-surface-variant);
	font-size: 18px;
	cursor: pointer;
	width: 40px;
	height: 40px;
	border-radius: var(--md-sys-shape-corner-full);
	flex-shrink: 0;
	transition: background 0.15s ease, color 0.15s ease;
}

.del-btn:hover { background: var(--mca-menstruation-bg); color: var(--md-sys-color-error); }

/* ── FAB + bottom navigation ─────────── */

.fab {
	position: fixed;
	right: 1rem;
	bottom: calc(5.5rem + env(safe-area-inset-bottom));
	width: 56px;
	height: 56px;
	border: none;
	border-radius: var(--md-sys-shape-corner-large);
	background: var(--md-sys-color-primary-container);
	color: var(--md-sys-color-on-primary-container);
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	box-shadow: var(--md-sys-elevation-shadow-3);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	z-index: 70;
}

.fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.3), 0 6px 10px 4px rgba(0, 0, 0, 0.15); }
.fab:active { transform: scale(0.96); }

.bottom-nav {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	background: var(--md-sys-color-surface-container);
	border-top: 1px solid var(--md-sys-color-outline-variant);
	padding: 0.375rem 0.25rem calc(0.375rem + env(safe-area-inset-bottom));
	z-index: 60;
}

.nav-item {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.125rem;
	min-height: 56px;
	padding: 0.25rem 0 0.375rem;
	border: none;
	background: transparent;
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-label-small-size);
	font-weight: var(--md-sys-typescale-label-medium-weight);
	letter-spacing: 0.1px;
	cursor: pointer;
	transition: color 0.15s ease;
}

.nav-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 32px;
	border-radius: var(--md-sys-shape-corner-large);
	transition: background 0.15s ease;
}

.nav-icon svg {
	width: 24px;
	height: 24px;
	fill: currentColor;
}

.nav-item:hover { color: var(--md-sys-color-on-surface); }

.nav-item.active { color: var(--md-sys-color-on-surface); }
.nav-item.active .nav-icon {
	background: var(--md-sys-color-secondary-container);
	color: var(--md-sys-color-on-secondary-container);
}

.nav-label { line-height: 1; }

[hidden] {
	display: none !important;
}

.modal {
	position: fixed;
	inset: 0;
	margin: auto;
	width: min(92vw, 400px);
	max-height: 92vh;
	overflow: auto;
	background: var(--md-sys-color-surface-container-high);
	color: var(--md-sys-color-on-surface);
	border: 1px solid var(--md-sys-color-outline-variant);
	border-radius: var(--md-sys-shape-corner-extra-large);
	padding: 1.5rem;
	box-shadow: var(--md-sys-elevation-shadow-3);
	z-index: 200;
	animation: modal-in 0.18s ease both;
}

@keyframes modal-in {
	from { opacity: 0; transform: translateY(12px) scale(0.98); }
	to { opacity: 1; transform: none; }
}

.modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.32);
	backdrop-filter: blur(2px);
	z-index: 199;
}

.modal h2 {
	margin: 0 0 1rem;
	font-size: var(--md-sys-typescale-title-large-size);
	font-weight: var(--md-sys-typescale-title-large-weight);
}

.field {
	display: block;
	margin-bottom: 1rem;
	font-size: var(--md-sys-typescale-label-medium-size);
	font-weight: var(--md-sys-typescale-label-medium-weight);
	letter-spacing: 0.1px;
	color: var(--md-sys-color-on-surface-variant);
}

.field input[type="date"] {
	display: block;
	width: 100%;
	margin-top: 0.375rem;
	padding: 0.75rem 1rem;
	border: 1px solid var(--md-sys-color-outline-variant);
	border-radius: var(--md-sys-shape-corner-extra-small);
	background: var(--md-sys-color-surface-container-highest);
	color: var(--md-sys-color-on-surface);
	font-size: var(--md-sys-typescale-body-large-size);
	font-family: inherit;
}

.field input[type="date"]:focus {
	outline: none;
	border-color: var(--md-sys-color-primary);
	box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}

.field input[type="range"] {
	display: block;
	width: 100%;
	margin-top: 0.625rem;
	accent-color: var(--md-sys-color-primary);
}

.duration-value {
	float: right;
	color: var(--md-sys-color-on-surface);
	font-weight: 500;
}

.error {
	color: var(--md-sys-color-error);
	font-size: var(--md-sys-typescale-body-small-size);
	margin: 0 0 0.75rem;
	min-height: 18px;
}

.dialog-actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.5rem;
	margin-top: 0.25rem;
}

.footer {
	text-align: center;
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-body-small-size);
	margin-top: 0.5rem;
}

/* ── Larger screens ──────────────────── */

@media (min-width: 640px) {
	.app { padding: 1rem 1rem 8rem; }
	.top-app-bar { padding: 0.75rem 0.5rem 0.625rem; margin-bottom: 1rem; }
	.brand h1 { font-size: 1.375rem; }
	.card { padding: 1.25rem; border-radius: 1.75rem; }
	.hero { padding: 1.5rem; }
	.tl-phases { grid-template-columns: repeat(4, 1fr); }
	.predictions { display: grid; grid-template-columns: 1fr 1fr; }
	.record { padding: 0.875rem 0.375rem; }
	.fab { right: 1.5rem; bottom: calc(6rem + env(safe-area-inset-bottom)); }
}

@media (min-width: 960px) {
	.app { max-width: 68rem; padding: 1.5rem 1.5rem 3rem; }
	.top-app-bar { padding: 0.875rem 0.75rem 0.625rem; margin-bottom: 0.5rem; }
	.brand h1 { font-size: 1.5rem; }

	.bottom-nav { display: none; }

	.top-tabs {
		display: flex;
		gap: 0.375rem;
		padding: 0 0.5rem 0.875rem;
	}
	.top-tab {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		height: 40px;
		padding: 0 1.25rem;
		border: none;
		border-radius: var(--md-sys-shape-corner-full);
		background: transparent;
		color: var(--md-sys-color-on-surface-variant);
		font-size: var(--md-sys-typescale-label-large-size);
		font-weight: var(--md-sys-typescale-label-large-weight);
		letter-spacing: 0.1px;
		line-height: var(--md-sys-typescale-label-large-line-height);
		cursor: pointer;
		transition: background 0.15s ease, color 0.15s ease;
	}
	.top-tab:hover {
		background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
		color: var(--md-sys-color-on-surface);
	}
	.top-tab.active {
		background: var(--md-sys-color-secondary-container);
		color: var(--md-sys-color-on-secondary-container);
	}

	.tab-panel[data-panel="today"] {
		display: grid;
		grid-template-columns: 1.5fr 1fr;
		gap: 0.75rem;
		align-items: start;
	}
	.tab-panel[data-panel="today"] > #status { grid-column: 1 / -1; }
	.tab-panel[data-panel="today"] > #timeline { grid-column: 1 / -1; }
	.tab-panel[data-panel="today"] > .sphere-card { grid-column: 1 / -1; }

	.hero { padding: 1.75rem; }
	.hero-main { gap: 2rem; }
	.hero-day b { font-size: 3.5rem; }
	.hero-ring { width: 160px; height: 160px; }
	.ring-label b { font-size: 2.5rem; }

	.sphere-container { height: 440px; }

	.cal-grid { gap: 4px; }
	.dow { padding: 8px 0 4px; }
	.cell { height: 56px; }
	.cell .n { width: 44px; height: 44px; }

	.predictions { grid-template-columns: repeat(3, 1fr); }

	.records {
		display: grid;
		grid-template-columns: 1fr 1fr;
		column-gap: 1rem;
	}

	.fab { right: 1.5rem; bottom: 1.5rem; }
}
