:root {
	color-scheme: light dark;
	--bg: #fff;
	--fg: #1a1a1a;
	--muted: #6b6b6b;
	--accent: #b5442e;
	--card-bg: #f7f4f1;
	--border: #e5e0da;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
	background: var(--bg);
	color: var(--fg);
	line-height: 1.6;
}

main {
	max-width: 640px;
	margin: 0 auto;
	padding: 0 1rem 3rem;
}

.site-header {
	max-width: 640px;
	margin: 0 auto;
	padding: 1rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.brand {
	font-weight: 700;
	font-size: 1.25rem;
	color: var(--accent);
	text-decoration: none;
}

.hero h1 { margin-bottom: 0.25rem; }
.hero .sub { color: var(--muted); margin-top: 0; }

.birth-form {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 1.25rem;
}

.birth-form label {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	font-size: 0.9rem;
	color: var(--muted);
}

.birth-form input {
	font-size: 1rem;
	padding: 0.6rem;
	border-radius: 8px;
	border: 1px solid var(--border);
}

.sex-field {
	display: flex;
	gap: 1rem;
	border: none;
	padding: 0;
	margin: 0;
}

.sex-field legend { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.35rem; }
.radio { flex-direction: row !important; align-items: center; gap: 0.4rem !important; }

.btn {
	display: inline-block;
	border: none;
	border-radius: 999px;
	padding: 0.8rem 1.4rem;
	font-size: 1rem;
	cursor: pointer;
	text-align: center;
	text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.btn-secondary { background: var(--border); color: var(--fg); margin-top: 0.75rem; }

.generating-note[hidden] {
	display: none;
}

.generating-note {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
	text-align: center;
	color: var(--muted);
	font-size: 0.9rem;
	line-height: 1.5;
	padding: 0.5rem 0;
}

.spinner {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 3px solid var(--border);
	border-top-color: var(--accent);
	animation: spin 0.8s linear infinite;
}

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

.disclaimer {
	text-align: center;
	color: var(--muted);
	font-size: 0.8rem;
	margin-top: 2rem;
}

.chip-bar {
	position: sticky;
	top: 0;
	display: flex;
	gap: 0.5rem;
	overflow-x: auto;
	padding: 0.75rem 0;
	background: var(--bg);
	border-bottom: 1px solid var(--border);
	margin-bottom: 1.25rem;
}

.toolbar {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	margin-bottom: 0.5rem;
}

.expiry-note {
	color: var(--muted);
	font-size: 0.8rem;
	margin: 0 0 1.25rem;
}

.toolbar .btn, .share-buttons .btn {
	padding: 0.5rem 1rem;
	font-size: 0.85rem;
}

.share-buttons {
	display: flex;
	gap: 0.5rem;
	justify-content: center;
	flex-wrap: wrap;
	margin-top: 0.75rem;
}

.share-prompt {
	text-align: center;
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 1.5rem 1.25rem;
	margin-bottom: 1.25rem;
}

.share-prompt .muted {
	color: var(--muted);
	font-size: 0.9rem;
	margin-top: 0.25rem;
}

.chip {
	flex: 0 0 auto;
	white-space: nowrap;
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.4rem 0.9rem;
	font-size: 0.85rem;
	text-decoration: none;
	color: var(--fg);
}

.chip-locked { color: var(--muted); }

.chart-card, .teaser-card, .unlock-card, .report-section {
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 1.25rem;
	margin-bottom: 1.25rem;
}

.chart-grid, .lucky-grid {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.35rem 1rem;
	margin: 0;
}

.chart-grid dt, .lucky-grid dt { color: var(--muted); }
.chart-grid dd, .lucky-grid dd { margin: 0; }

.teaser-list { padding-left: 1.1rem; margin-top: 0; }

.unlock-cta {
	font-weight: 700;
	font-size: 1.1rem;
	text-align: center;
	margin: 0 0 1rem;
}

.age-affirm {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	font-size: 0.85rem;
	color: var(--muted);
	margin-bottom: 1rem;
	cursor: pointer;
}

.age-affirm input {
	flex: 0 0 auto;
	margin-top: 0.2rem;
}

.unlock-card .btn-primary {
	display: block;
	width: 100%;
}

.qr-box { text-align: center; margin-top: 1rem; }

.qr-image {
	width: 300px;
	height: 300px;
	max-width: 100%;
	margin: 0 auto;
	display: block;
	background: #fff;
	border-radius: 8px;
	padding: 0.5rem;
}

.waiting-note {
	margin-top: 1rem;
	color: var(--muted);
	font-size: 0.9rem;
}

.locked-note { color: var(--muted); font-style: italic; }

.site-footer {
	max-width: 640px;
	margin: 2rem auto 0;
	padding: 1.5rem 1rem;
	border-top: 1px solid var(--border);
	display: flex;
	justify-content: center;
	gap: 1.5rem;
}

.site-footer a {
	color: var(--muted);
	font-size: 0.85rem;
	text-decoration: none;
}

.site-footer a:hover { text-decoration: underline; }

.legal-page h1 { margin-bottom: 0.25rem; }
.legal-page h2 { margin-top: 1.75rem; margin-bottom: 0.5rem; font-size: 1.1rem; }
.legal-page p { margin-top: 0; }
.legal-page a { color: var(--accent); }

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #15130f;
		--fg: #f2ede6;
		--muted: #a89f93;
		--card-bg: #211d17;
		--border: #3a332a;
	}
}

/* Manual theme override (settings panel) takes precedence over system
   preference in either direction. */
:root[data-theme="light"] {
	--bg: #fff;
	--fg: #1a1a1a;
	--muted: #6b6b6b;
	--card-bg: #f7f4f1;
	--border: #e5e0da;
}

:root[data-theme="dark"] {
	--bg: #15130f;
	--fg: #f2ede6;
	--muted: #a89f93;
	--card-bg: #211d17;
	--border: #3a332a;
}

html[data-fontsize="s"] { font-size: 14px; }
html[data-fontsize="l"] { font-size: 19px; }

.settings-panel {
	position: relative;
}

.settings-toggle {
	list-style: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	border-radius: 999px;
	border: 1px solid var(--border);
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--fg);
	user-select: none;
}

.settings-toggle::-webkit-details-marker { display: none; }

.settings-content {
	position: absolute;
	right: 0;
	top: calc(100% + 0.5rem);
	z-index: 10;
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
	min-width: 200px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.settings-group {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.settings-label {
	font-size: 0.8rem;
	color: var(--muted);
}

.settings-options {
	display: flex;
	gap: 0.4rem;
}

.settings-options button {
	flex: 1;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--fg);
	border-radius: 8px;
	padding: 0.4rem 0.5rem;
	font-size: 0.85rem;
	cursor: pointer;
}

.settings-options button.active {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}
