html,
body {
	height: 100%;
}

body {
	margin: 0;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
		Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
	--accent1: rgba(0, 255, 255, 0.14);
	--accent2: rgba(0, 170, 255, 0.12);
	--bg1: #04070f;
	--bg2: #02030a;
	--text: #eaf0ff;
	--panel-bg: rgba(0, 0, 0, 0.62);
	--panel-border: rgba(0, 255, 255, 0.22);
	--panel-inset: rgba(0, 255, 255, 0.12);
	--panel-shadow: rgba(0, 255, 255, 0.16);
	--chip-bg: rgba(255, 255, 255, 0.05);
	--chip-border: rgba(255, 255, 255, 0.10);
	--leaflet-attrib-bg: rgba(0, 0, 0, 0.35);
	--leaflet-attrib-border: rgba(0, 255, 255, 0.16);
	--leaflet-attrib-shadow: rgba(0, 255, 255, 0.10);

	background:
		radial-gradient(900px 500px at 20% 10%, var(--accent1) 0%, rgba(0, 0, 0, 0) 60%),
		radial-gradient(900px 500px at 85% 25%, var(--accent2) 0%, rgba(0, 0, 0, 0) 62%),
		linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%);
	color: var(--text);
}

/* Themes (set by JS) */
body[data-theme="clear-day"] {
	--accent1: rgba(255, 214, 10, 0.38);
	--accent2: rgba(56, 189, 248, 0.22);
	--panel-bg: rgba(19, 14, 0, 0.58);
	--panel-border: rgba(255, 214, 10, 0.42);
	--panel-inset: rgba(255, 214, 10, 0.22);
	--panel-shadow: rgba(255, 214, 10, 0.26);
	--chip-bg: rgba(255, 214, 10, 0.06);
	--chip-border: rgba(255, 214, 10, 0.22);
	--leaflet-attrib-border: rgba(255, 221, 87, 0.18);
}

body[data-theme="clear-day"][data-phase="night"] {
	--accent1: rgba(147, 197, 253, 0.16);
	--accent2: rgba(168, 85, 247, 0.10);
}

body[data-theme="clear-night"] {
	--accent1: rgba(96, 165, 250, 0.26);
	--accent2: rgba(168, 85, 247, 0.24);
	--panel-bg: rgba(6, 10, 24, 0.66);
	--panel-border: rgba(168, 85, 247, 0.34);
	--panel-inset: rgba(96, 165, 250, 0.18);
	--panel-shadow: rgba(168, 85, 247, 0.22);
	--chip-bg: rgba(168, 85, 247, 0.06);
	--chip-border: rgba(168, 85, 247, 0.22);
	--leaflet-attrib-border: rgba(147, 197, 253, 0.16);
}

body[data-theme="clouds"] {
	--accent1: rgba(148, 163, 184, 0.26);
	--accent2: rgba(56, 189, 248, 0.20);
	--panel-bg: rgba(10, 14, 22, 0.64);
	--panel-border: rgba(148, 163, 184, 0.32);
	--panel-inset: rgba(56, 189, 248, 0.16);
	--panel-shadow: rgba(56, 189, 248, 0.16);
	--chip-bg: rgba(148, 163, 184, 0.06);
	--chip-border: rgba(148, 163, 184, 0.18);
	--leaflet-attrib-border: rgba(148, 163, 184, 0.16);
}

body[data-theme="rain"] {
	--accent1: rgba(56, 189, 248, 0.24);
	--accent2: rgba(37, 99, 235, 0.28);
	--panel-bg: rgba(2, 8, 22, 0.70);
	--panel-border: rgba(56, 189, 248, 0.34);
	--panel-inset: rgba(37, 99, 235, 0.18);
	--panel-shadow: rgba(37, 99, 235, 0.22);
	--chip-bg: rgba(37, 99, 235, 0.08);
	--chip-border: rgba(56, 189, 248, 0.22);
	--leaflet-attrib-border: rgba(56, 189, 248, 0.16);
}

body[data-theme="thunder"] {
	--accent1: rgba(168, 85, 247, 0.28);
	--accent2: rgba(99, 102, 241, 0.30);
	--panel-bg: rgba(8, 4, 18, 0.72);
	--panel-border: rgba(168, 85, 247, 0.40);
	--panel-inset: rgba(99, 102, 241, 0.20);
	--panel-shadow: rgba(168, 85, 247, 0.24);
	--chip-bg: rgba(168, 85, 247, 0.08);
	--chip-border: rgba(168, 85, 247, 0.24);
	--leaflet-attrib-border: rgba(168, 85, 247, 0.16);
}

body[data-theme="snow"] {
	--accent1: rgba(226, 232, 240, 0.24);
	--accent2: rgba(125, 211, 252, 0.26);
	--panel-bg: rgba(8, 12, 18, 0.62);
	--panel-border: rgba(226, 232, 240, 0.32);
	--panel-inset: rgba(125, 211, 252, 0.16);
	--panel-shadow: rgba(125, 211, 252, 0.20);
	--chip-bg: rgba(226, 232, 240, 0.06);
	--chip-border: rgba(226, 232, 240, 0.18);
	--leaflet-attrib-border: rgba(226, 232, 240, 0.16);
}

body[data-theme="mist"] {
	--accent1: rgba(20, 184, 166, 0.22);
	--accent2: rgba(148, 163, 184, 0.18);
	--panel-bg: rgba(4, 12, 14, 0.70);
	--panel-border: rgba(20, 184, 166, 0.32);
	--panel-inset: rgba(148, 163, 184, 0.16);
	--panel-shadow: rgba(20, 184, 166, 0.20);
	--chip-bg: rgba(20, 184, 166, 0.06);
	--chip-border: rgba(20, 184, 166, 0.18);
	--leaflet-attrib-border: rgba(20, 184, 166, 0.16);
}

body::before {
	content: '';
	position: fixed;
	inset: 0;
	pointer-events: none;
	background: repeating-linear-gradient(
		180deg,
		rgba(0, 255, 255, 0.07) 0px,
		rgba(0, 255, 255, 0.07) 1px,
		rgba(0, 0, 0, 0) 4px,
		rgba(0, 0, 0, 0) 10px
	);
	opacity: 0.06;
}

main {
	padding: 16px;
}

.app-header {
	margin: 8px 0 14px;
	padding: 14px 16px;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	border: 1px solid var(--panel-border);
	border-radius: 16px;
	background: linear-gradient(135deg, rgba(0, 255, 255, 0.12), rgba(0, 170, 255, 0.06));
	box-shadow:
		0 0 0 1px var(--panel-inset) inset,
		0 0 22px var(--accent1),
		0 10px 30px rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(8px);
}

.header-left {
	display: flex;
	align-items: baseline;
	gap: 12px;
	min-width: 0;
}

.header-logout {
	margin-left: auto;
}

.tagline {
	margin-left: 16px;
}

.app-header h1 {
	margin: 0;
	letter-spacing: 0.4px;
}

.tagline {
	margin: 0;
	color: rgba(160, 240, 255, 0.85);
	text-align: left;
}

#layout {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
	align-items: start;
}

#mapWrap {
	position: relative;
}

.login-screen {
	min-height: calc(100vh - 140px);
	display: grid;
	place-items: center;
	padding: 24px 16px;
	position: relative;
	z-index: 1000;
}

#mapWrap {
	z-index: 1;
}

/* Ensure the HTML hidden attribute always wins */
.login-screen[hidden] {
	display: none !important;
}

.login-card {
	width: min(560px, 100%);
	border: 1px solid var(--panel-border);
	border-radius: 16px;
	background: var(--panel-bg);
	box-shadow:
		0 0 0 1px var(--panel-inset) inset,
		0 0 34px var(--panel-shadow);
	padding: 18px 18px 16px;
}

.login-card h2 {
	margin: 0 0 10px;
	font-size: 1.15rem;
}

.google-btn {
	margin-top: 12px;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 10px 14px;
	border-radius: 12px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	background: #ffffff;
	color: #111827;
	font-weight: 600;
	cursor: pointer;
}

.google-btn:hover {
	filter: brightness(0.97);
}

.g-icon {
	width: 18px;
	height: 18px;
	border-radius: 4px;
	background:
		conic-gradient(from 45deg,
			#4285F4 0 90deg,
			#34A853 90deg 180deg,
			#FBBC05 180deg 270deg,
			#EA4335 270deg 360deg);
}

#map {
	height: calc(100vh - 110px);
	min-height: 420px;
	border: 1px solid var(--panel-border);
	border-radius: 10px;
	background: #0b1326;
	box-shadow:
		0 0 0 1px var(--panel-inset) inset,
		0 0 26px var(--accent1),
		0 18px 40px rgba(0, 0, 0, 0.55);
}

.card {
	border: 1px solid rgba(0, 255, 255, 0.18);
	border-radius: 10px;
	padding: 10px;
	margin-top: 10px;
	background: rgba(0, 0, 0, 0.22);
	box-shadow: 0 0 18px rgba(0, 255, 255, 0.06);
}

.topbar {
	position: absolute;
	left: 50px;
	right: 10px;
	top: 10px;
	z-index: 500; /* above leaflet panes */
	border: 1px solid var(--panel-border);
	border-radius: 12px;
	background: var(--panel-bg);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	box-shadow:
		0 0 0 1px var(--panel-inset) inset,
		0 0 24px var(--panel-shadow);
	padding: 10px;
}

.topbar-head {
	min-width: 0;
}

.topbar-actions {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}

.topbar {
	cursor: pointer;
}

.topbar:hover {
	transform: translateY(-1px);
	transition: transform 120ms ease, box-shadow 120ms ease;
	box-shadow:
		0 0 0 1px var(--panel-inset) inset,
		0 0 28px var(--panel-shadow);
}

.tabs {
	display: flex;
	gap: 6px;
	margin-top: 0;
}

.topbar.collapsed .tabpanels {
	display: none;
}

@keyframes pulseGlow {
	0% { box-shadow: 0 0 0 rgba(255,255,255,0); transform: translateY(0); }
	35% { box-shadow: 0 0 18px var(--accent2); transform: translateY(-1px); }
	100% { box-shadow: 0 0 0 rgba(255,255,255,0); transform: translateY(0); }
}

.tab.pulse {
	animation: pulseGlow 900ms ease-in-out 0s 2;
}



.icon-btn {
	padding: 7px 10px;
	border-radius: 999px;
	border: 1px solid var(--panel-border);
	background: rgba(255, 255, 255, 0.04);
	color: rgba(234, 240, 255, 0.85);
	cursor: pointer;
}

.icon-btn:hover {
	border-color: color-mix(in srgb, var(--panel-border) 70%, white);
}



.topbar-body {
	margin-top: 10px;
	max-height: 35vh;
	overflow: auto;
	padding-right: 4px;
}

.units-menu {
	margin-top: 10px;
}

.topbar-row {
	display: flex;
	gap: 10px;
	justify-content: space-between;
	align-items: center;
}

.topbar-place {
	font-weight: 650;
	color: rgba(234, 240, 255, 0.95);
}

.topbar-asof {
	margin-left: 8px;
	font-weight: 500;
	font-size: 0.9rem;
	opacity: 0.85;
}

.topbar-cache {
	margin-top: 2px;
	font-size: 0.9rem;
	color: rgba(234, 240, 255, 0.75);
}

.topbar-headline {
	margin-top: 2px;
	font-size: 0.95rem;
	color: rgba(234, 240, 255, 0.8);
	display: flex;
	align-items: center;
	gap: 6px;
}

.topbar-headline .wx-icon {
	width: 22px;
	height: 22px;
}

.topbar-units select {
	padding: 8px;
	border-radius: 10px;
	border: 1px solid var(--panel-border);
	background: rgba(0, 0, 0, 0.35);
	color: #eaf0ff;
}

/* tabs definition moved earlier for header placement */

.tab {
	flex: 0 0 auto;
	padding: 6px 10px;
	border-radius: 999px;
	border: 1px solid var(--panel-border);
	background: rgba(255, 255, 255, 0.04);
	color: rgba(234, 240, 255, 0.85);
	cursor: pointer;
}

.tab.active {
	background: var(--accent1);
	color: #eaf0ff;
	border-color: var(--panel-border);
	box-shadow: 0 0 18px var(--accent2);
}

.tabpanels {
	margin-top: 10px;
}


.kv td {
	border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.kv {
	width: 100%;
	border-collapse: collapse;
}

.kv td {
	padding: 6px 4px;
	vertical-align: top;
	border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.kv td:first-child {
	width: 45%;
	color: rgba(234, 240, 255, 0.9);
	font-weight: 600;
}

details > summary {
	cursor: pointer;
}


.muted {
	color: rgba(234, 240, 255, 0.75);
	font-size: 0.95rem;
}


.topbar select:focus {
	outline: none;
	box-shadow:
		0 0 0 2px rgba(0, 255, 255, 0.25),
		0 0 20px rgba(0, 255, 255, 0.18);
}

.forecast h3 {
	margin: 0.75rem 0 0.5rem;
	font-size: 0.95rem;
}

.hourly {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(92px, 1fr);
	gap: 0.5rem;
	overflow-x: auto;
	padding-bottom: 0.25rem;
	scroll-snap-type: x mandatory;
}

.hour-card {
	border: 1px solid var(--chip-border);
	background: var(--chip-bg);
	border-radius: 12px;
	padding: 0.5rem;
	min-height: 92px;
	scroll-snap-align: start;
}

.metric-card {
	border: 1px solid var(--chip-border);
	background: var(--chip-bg);
	border-radius: 12px;
	padding: 0.55rem 0.6rem;
	min-height: 86px;
}

.metric-k {
	font-size: 0.82rem;
	opacity: 0.8;
}

.metric-v {
	margin-top: 0.2rem;
	font-size: 1.05rem;
	font-weight: 520;
	font-variant-numeric: tabular-nums;
}

.hour-time {
	font-size: 0.85rem;
	opacity: 0.8;
}

.hour-temp {
	font-size: 1.1rem;
	margin-top: 0.25rem;
}

.hour-pop {
	font-size: 0.85rem;
	opacity: 0.8;
	margin-top: 0.25rem;
}

.wx-icon {
	width: 34px;
	height: 34px;
	image-rendering: -webkit-optimize-contrast;
}

.daily {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.day-row {
	display: grid;
	grid-template-columns: 70px 36px 1fr auto;
	align-items: center;
	gap: 0.5rem;
	padding: 0.4rem 0.35rem;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(255, 255, 255, 0.02);
}

.day-name {
	font-size: 0.9rem;
	opacity: 0.9;
}

.day-desc {
	font-size: 0.9rem;
	opacity: 0.9;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.day-temps {
	font-variant-numeric: tabular-nums;
	opacity: 0.9;
}

/* Leaflet tweaks for dark UI */
.leaflet-control-attribution {
	background: var(--leaflet-attrib-bg) !important;
	color: rgba(234, 240, 255, 0.7) !important;
	border: 1px solid var(--leaflet-attrib-border) !important;
	border-radius: 10px;
	box-shadow: 0 0 14px var(--leaflet-attrib-shadow);
}

.leaflet-control-attribution a {
	color: rgba(147, 197, 253, 0.95) !important;
}

.code {
	white-space: pre-wrap;
	word-break: break-word;
	font-size: 12px;
	margin: 10px 0 0;
}

@media (max-width: 900px) {
	#layout {
		grid-template-columns: 1fr;
	}
	#map {
		height: 55vh;
	}
	.topbar {
		left: 8px;
		right: 8px;
		top: 8px;
	}
}
