:root {
	--bg: #0a0d14;
	--card: #10151e;
	--line: #1e2633;
	--track: #1a212c;
	--text: #e9ecf2;
	--muted: #8b95a7;
	--faint: #5d6778;
	--moon: #f4ecd8;
	--band: rgba(244, 236, 216, 0.17);
	--out: #f0b45a;
	color-scheme: dark;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
	margin: 0;
	min-height: 100vh;
	background:
		radial-gradient(1200px 600px at 50% -200px, #141b28 0%, transparent 70%),
		var(--bg);
	color: var(--text);
	font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-variant-numeric: tabular-nums;
	-webkit-font-smoothing: antialiased;
	padding: max(16px, env(safe-area-inset-top)) 16px 32px;
}

.card {
	max-width: 440px;
	margin: 0 auto;
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: 20px;
	padding: 18px 18px 14px;
}

h1, h2, p { margin: 0; }

.top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

h1 { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; color: var(--muted); }

.chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	min-width: 0;
	border: 1px solid var(--line);
	background: transparent;
	color: var(--text);
	border-radius: 999px;
	padding: 5px 11px 5px 8px;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}
.chip svg { width: 14px; height: 14px; fill: var(--muted); flex: none; }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip:hover { border-color: #2c3647; }
.chip.unset { border-color: rgba(240, 180, 90, 0.5); }
.chip.unset svg { fill: var(--out); }

.panel {
	margin-top: 12px;
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: 14px;
	display: grid;
	gap: 10px;
}

.btn {
	font: inherit;
	font-weight: 600;
	border: 0;
	border-radius: 10px;
	padding: 9px 14px;
	background: var(--moon);
	color: #14181f;
	cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }

.manual { display: flex; gap: 8px; align-items: end; }
.manual label { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); display: grid; gap: 3px; }
.manual input {
	width: 100%;
	font: inherit;
	color: var(--text);
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 7px 9px;
}

.link {
	justify-self: start;
	background: none;
	border: 0;
	padding: 0;
	color: var(--muted);
	font: inherit;
	font-size: 13px;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.small { font-size: 12px; color: var(--muted); }
code { font-size: 11.5px; color: var(--text); }

.hero {
	display: grid;
	grid-template-columns: 136px 1fr;
	align-items: center;
	gap: 18px;
	margin: 18px 0 14px;
}

.moon { margin: 0; text-align: center; }
.moon svg { width: 136px; height: 136px; display: block; }
.moon figcaption { font-size: 11px; color: var(--faint); margin-top: 2px; }

.phase { display: grid; gap: 3px; min-width: 0; }
.phase-name { font-size: 19px; font-weight: 600; line-height: 1.2; }
.illum { font-size: 34px; font-weight: 300; line-height: 1.1; letter-spacing: -0.01em; }
.illum .unit { font-size: 15px; font-weight: 400; color: var(--muted); margin-left: 3px; }
.muted { color: var(--muted); font-size: 13.5px; }

.events {
	list-style: none;
	margin: 0 0 14px;
	padding: 10px 0 0;
	border-top: 1px solid var(--line);
	display: grid;
	gap: 4px;
	font-size: 13.5px;
}
.events li { display: flex; justify-content: space-between; gap: 10px; }
.events .what { color: var(--text); white-space: nowrap; }
.events .when { color: var(--muted); text-align: right; }

.scale-legend {
	font-size: 11.5px;
	color: var(--faint);
	padding-top: 10px;
	border-top: 1px solid var(--line);
	margin-bottom: 4px;
}

.meter { padding: 10px 0 8px; }
.meter + .meter { border-top: 1px solid var(--line); }

.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
h2 { font-size: 13.5px; font-weight: 500; color: var(--muted); }
.value { font-size: 19px; font-weight: 500; }
.pct {
	font-size: 12.5px;
	font-weight: 600;
	margin-left: 8px;
	padding: 1px 7px;
	border-radius: 999px;
	background: var(--band);
	color: var(--moon);
	vertical-align: 2px;
}
.meter.outside .pct { background: rgba(240, 180, 90, 0.16); color: var(--out); }

.bar {
	position: relative;
	height: 10px;
	margin: 9px 0 5px;
	border-radius: 999px;
	background: var(--track);
}
.bar .band { position: absolute; top: 0; bottom: 0; background: var(--band); border-radius: 2px; }
.bar .tick, .bar .zero { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--faint); }
.bar .zero { background: var(--muted); top: -5px; bottom: -5px; }
.bar .marker {
	position: absolute;
	top: 50%;
	width: 14px;
	height: 14px;
	margin: -7px 0 0 -7px;
	border-radius: 50%;
	background: var(--moon);
	box-shadow: 0 0 0 3px var(--card), 0 0 12px rgba(244, 236, 216, 0.5);
	transition: left 0.6s ease;
}
.bar.pending > * { visibility: hidden; }
.meter.outside .marker { background: var(--out); box-shadow: 0 0 0 3px var(--card), 0 0 12px rgba(240, 180, 90, 0.5); }

.ends { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--faint); }
.ends .rank { color: var(--muted); text-align: center; }

.note { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.note button { font-size: inherit; }

.chart { padding-top: 12px; border-top: 1px solid var(--line); }
.chart svg { display: block; width: 100%; height: auto; margin-top: 6px; overflow: visible; }
.chart .band { fill: var(--band); }
.chart .line { fill: none; stroke: var(--moon); stroke-width: 1.4; stroke-linejoin: round; }
.chart .axis { stroke: var(--line); }
.chart text { font-size: 9px; fill: var(--faint); font-family: inherit; }
.chart .peak { fill: var(--out); }
.chart .peak-label { fill: var(--out); font-weight: 600; }
.chart .now { fill: var(--moon); }
.chart .full { fill: var(--moon); }
.chart .new { fill: var(--card); stroke: var(--muted); stroke-width: 1; }
.chart .apsis { fill: var(--muted); font-size: 8.5px; }

.about { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.about summary { cursor: pointer; color: var(--text); font-size: 13.5px; }
.about p { margin-top: 8px; }
.about b { color: var(--text); font-weight: 500; }

.fixed { margin-top: 10px; text-align: center; color: var(--out); }

@media (max-width: 380px) {
	.hero { grid-template-columns: 112px 1fr; gap: 14px; }
	.moon svg { width: 112px; height: 112px; }
	.illum { font-size: 30px; }
}
