/* Login, forgot password and other sign-in pages.
   Each page sets --lg-accent, --lg-accent-2, --lg-accent-3 (Theme, Secondary, Tertiary colours) and --lg-font inline. */
:root {
	--lg-ink: #1d2433;
	--lg-muted: #5b6576;
	--lg-line: color-mix(in srgb, var(--lg-accent) 14%, #e2e5ea);
	--lg-surface: #ffffff;
	--lg-bg: color-mix(in srgb, var(--lg-accent) 6%, #f6f7f9);
	--lg-shadow: color-mix(in srgb, var(--lg-accent) 22%, rgba(16,24,40,0.2));
	--lg-field: #ffffff;
	--lg-ok: #1f8a4c;
	--lg-fail: #c62828;
	--lg-warn: #9a5b00;
}
[data-theme="dark"] {
	--lg-ink: #eef1f6;
	--lg-muted: #a3acba;
	--lg-line: color-mix(in srgb, var(--lg-accent) 18%, rgba(255,255,255,0.1));
	--lg-surface: color-mix(in srgb, var(--lg-accent) 5%, #1c1f26);
	--lg-bg: color-mix(in srgb, var(--lg-accent) 9%, #111317);
	--lg-shadow: rgba(0,0,0,0.5);
	--lg-field: #15171c;
	--lg-ok: #4cc27f;
	--lg-fail: #f0706b;
	--lg-warn: #e6a740;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
	font-family: var(--lg-font, Inter), system-ui, -apple-system, "Segoe UI", sans-serif;
	background: var(--lg-bg);
	color: var(--lg-ink);
	-webkit-font-smoothing: antialiased;
}
input, button { font: inherit; }

.lg-page {
	position: relative; min-height: 100vh; overflow: hidden;
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	padding: 72px 16px 32px;
	background:
		radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--lg-accent) 22%, transparent) 1px, transparent 0) 0 0 / 22px 22px,
		var(--lg-bg);
}
/* Two soft theme-colour glows behind the card */
.lg-page::before, .lg-page::after {
	content: ""; position: absolute; border-radius: 50%; pointer-events: none; filter: blur(70px);
	background: color-mix(in srgb, var(--lg-accent) 28%, transparent);
}
.lg-page::before { width: 520px; height: 520px; top: -180px; left: -160px; animation: lg-drift 18s ease-in-out infinite alternate; }
.lg-page::after { width: 440px; height: 440px; bottom: -200px; right: -140px; background: color-mix(in srgb, var(--lg-accent-2) 22%, transparent); animation: lg-drift 22s ease-in-out infinite alternate-reverse; }

/* Floating circles and dots, as on the original login page */
.lg-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lg-bubble {
	position: absolute; border-radius: 50%;
	background: color-mix(in srgb, var(--lg-accent) 14%, transparent);
	border: 1px solid color-mix(in srgb, var(--lg-accent) 22%, transparent);
	animation: lg-float 7s ease-in-out infinite;
}
.lg-bubble:nth-child(1) { width: 200px; height: 200px; top: 9%;  right: 12%; animation-duration: 6s; }
.lg-bubble:nth-child(2) { width: 150px; height: 150px; bottom: 12%; left: 9%; animation-duration: 8s; animation-delay: -2s; background: color-mix(in srgb, var(--lg-accent-3) 14%, transparent); border-color: color-mix(in srgb, var(--lg-accent-3) 24%, transparent); }
.lg-bubble:nth-child(3) { width: 90px;  height: 90px;  top: 58%; right: 6%;  animation-duration: 9s; animation-delay: -4s; background: color-mix(in srgb, var(--lg-accent-2) 14%, transparent); border-color: color-mix(in srgb, var(--lg-accent-2) 24%, transparent); }
.lg-bubble:nth-child(4) { width: 60px;  height: 60px;  top: 14%; left: 18%; animation-duration: 7s; animation-delay: -1s; }
.lg-bubble:nth-child(5) { width: 120px; height: 120px; bottom: -40px; right: 34%; animation-duration: 10s; animation-delay: -5s; background: color-mix(in srgb, var(--lg-accent-3) 12%, transparent); border-color: color-mix(in srgb, var(--lg-accent-3) 22%, transparent); }
.lg-dot {
	position: absolute; width: 8px; height: 8px; border-radius: 50%;
	background: var(--lg-accent); opacity: 0.55;
	animation: lg-bob 5s ease-in-out infinite, lg-twinkle 3.5s ease-in-out infinite;
}
.lg-dot:nth-of-type(6)  { top: 15%; right: 22%; animation-delay: 0s, -1s; }
.lg-dot:nth-of-type(7)  { top: 26%; right: 9%;  animation-delay: -1.5s, -2s; }
.lg-dot:nth-of-type(8)  { top: 38%; right: 27%; animation-delay: -3s, 0s; width: 6px; height: 6px; }
.lg-dot:nth-of-type(9)  { top: 47%; right: 7%;  animation-delay: -2s, -0.5s; }
.lg-dot:nth-of-type(10) { bottom: 21%; left: 15%; animation-delay: -0.5s, -2.5s; }
.lg-dot:nth-of-type(11) { bottom: 32%; left: 7%; animation-delay: -4s, -1.5s; width: 6px; height: 6px; }
.lg-dot:nth-of-type(12) { bottom: 41%; left: 21%; animation-delay: -2.5s, -3s; }
.lg-dot:nth-of-type(13) { top: 21%; left: 11%; animation-delay: -1s, -0.2s; }
.lg-dot:nth-of-type(14) { top: 52%; left: 4%;  animation-delay: -3.5s, -1.2s; width: 10px; height: 10px; }
.lg-dot:nth-of-type(15) { bottom: 14%; right: 29%; animation-delay: -1.2s, -2.2s; }
.lg-dot:nth-of-type(16) { top: 8%;  left: 42%; animation-delay: -2.2s, -0.8s; width: 6px; height: 6px; }
.lg-dot:nth-of-type(17) { bottom: 7%; left: 38%; animation-delay: -4.2s, -1.8s; }
/* Dots take turns: theme, secondary, tertiary */
.lg-dot:nth-of-type(3n+7) { background: var(--lg-accent-2); }
.lg-dot:nth-of-type(3n+8) { background: var(--lg-accent-3); }
@keyframes lg-float { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-22px) scale(1.04); } }
@keyframes lg-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes lg-twinkle { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.18; } }
@keyframes lg-drift { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(90px, 60px) scale(1.15); } }

.lg-card {
	position: relative; z-index: 1; width: 100%; max-width: 560px;
	padding: 44px 52px 36px;
	animation: lg-rise .5s ease-out both;
	background: var(--lg-surface);
	border: 1px solid var(--lg-line);
	border-radius: 18px;
	box-shadow: 0 1px 2px color-mix(in srgb, var(--lg-shadow) 20%, transparent), 0 18px 48px -12px var(--lg-shadow);
}
.lg-card::before { /* thin accent edge along the top */
	content: ""; position: absolute; left: 24px; right: 24px; top: -1px; height: 3px; border-radius: 0 0 3px 3px;
	background: linear-gradient(90deg, var(--lg-accent), var(--lg-accent-2), var(--lg-accent-3));
}
.lg-top { text-align: center; margin-bottom: 26px; }
.lg-logo { display: block; max-width: 170px; max-height: 64px; width: auto; height: auto; margin: 0 auto 18px; }
.lg-brandline { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.14em; color: var(--lg-accent); }
.lg-version { color: var(--lg-accent-2); padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; font-size: 0.72rem; letter-spacing: 0.02em; font-weight: 700; }
.lg-card h1 { text-align: center; }
.lg-sub { text-align: center; }
.lg-foot { position: relative; z-index: 1; margin-top: 22px; font-size: 0.8rem; color: var(--lg-muted); text-align: center; }
@keyframes lg-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.lg-card h1 { margin: 0 0 6px; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.lg-sub { margin: 0; color: var(--lg-muted); font-size: 0.93rem; }
.lg-field { margin-bottom: 16px; }
.lg-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.lg-input { position: relative; }
.lg-input > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--lg-muted); font-size: 0.9rem; pointer-events: none; }
.lg-input input {
	width: 100%; height: 48px; padding: 0 44px 0 40px;
	border: 1px solid var(--lg-line); border-radius: 10px;
	background: var(--lg-field); color: var(--lg-ink); font-size: 0.95rem;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.lg-input input::placeholder { color: var(--lg-muted); opacity: .8; }
.lg-input input:focus { outline: none; border-color: var(--lg-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lg-accent) 22%, transparent); }
.lg-eye {
	position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
	width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent;
	color: var(--lg-muted); cursor: pointer;
}
.lg-eye:hover { color: var(--lg-accent); background: color-mix(in srgb, var(--lg-accent) 10%, transparent); }
.lg-eye:focus-visible, .lg-btn:focus-visible, .lg-links a:focus-visible, .lg-theme:focus-visible { outline: 3px solid color-mix(in srgb, var(--lg-accent) 45%, transparent); outline-offset: 2px; }
.lg-row { display: flex; justify-content: flex-end; margin: -6px 0 16px; }
.lg-links a, .lg-row a { color: var(--lg-accent); font-size: 0.88rem; font-weight: 700; text-decoration: none; }
.lg-links a:hover, .lg-row a:hover { color: var(--lg-accent-3); text-decoration: underline; }

.lg-alert { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px; padding: 11px 14px; border-radius: 10px; border: 1px solid currentColor; font-size: 0.88rem; line-height: 1.45; background: transparent; }
.lg-alert i { margin-top: 3px; }
.lg-alert--fail { color: var(--lg-fail); background: color-mix(in srgb, var(--lg-fail) 8%, transparent); }
.lg-alert--ok { color: var(--lg-ok); background: color-mix(in srgb, var(--lg-ok) 8%, transparent); }
.lg-alert--warn { color: var(--lg-warn); background: color-mix(in srgb, var(--lg-warn) 9%, transparent); }
.lg-alert small { display: block; margin-top: 2px; opacity: .9; }

altcha-widget {
	display: block; margin-bottom: 16px;
	--altcha-max-width: 100%;
	--altcha-border-radius: 10px;
	--altcha-border-width: 1px;
	--altcha-color-base: var(--lg-field);
	--altcha-color-border: var(--lg-line);
	--altcha-color-border-focus: var(--lg-accent);
	--altcha-color-active: var(--lg-accent);
	--altcha-color-text: var(--lg-ink);
	--altcha-color-error-text: var(--lg-fail);
	--altcha-color-footer-bg: var(--lg-bg);
}
/* ALTCHA states: "altcha-widget .altcha" outranks the widget's own .altcha rules */
altcha-widget .altcha { overflow: hidden; transition: border-color .2s ease, box-shadow .2s ease; }
altcha-widget .altcha[data-state="unverified"]:hover { border-color: var(--lg-accent); }
altcha-widget .altcha-spinner { color: var(--lg-accent); animation-duration: .6s; }
altcha-widget .altcha-checkbox { border-radius: 50%; }
/* Verifying: a light sweep across the box and a pulsing ring around the spinner */
altcha-widget .altcha[data-state="verifying"] { border-color: var(--lg-accent); }
altcha-widget .altcha[data-state="verifying"]::before {
	content: ""; position: absolute; inset: 0; pointer-events: none;
	background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--lg-accent-3) 16%, transparent) 50%, transparent 80%);
	transform: translateX(-100%);
	animation: lg-sweep 1.3s ease-in-out infinite;
}
altcha-widget .altcha[data-state="verifying"] .altcha-checkbox::after {
	content: ""; position: absolute; inset: -4px; border-radius: 50%;
	border: 2px solid var(--lg-accent-2);
	animation: lg-ring 1.1s ease-out infinite;
}
/* Verified: tick pops in and the box glows green once */
altcha-widget .altcha[data-state="verified"] { border-color: var(--lg-ok); animation: lg-glow-ok .9s ease-out 1; }
altcha-widget .altcha[data-state="verified"] .altcha-checkbox { animation: lg-pop .45s cubic-bezier(.3, 1.6, .5, 1) 1; }
altcha-widget .altcha[data-state="verified"] .altcha-checkbox input { accent-color: var(--lg-ok); }
/* Error: a short shake */
altcha-widget .altcha[data-state="error"] { border-color: var(--lg-fail); animation: lg-shake .4s ease-in-out 1; }
altcha-widget .altcha[data-state="expired"] { border-color: var(--lg-warn); }
@keyframes lg-sweep { to { transform: translateX(100%); } }
@keyframes lg-ring { 0% { transform: scale(.7); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes lg-pop { 0% { transform: scale(.4); } 70% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes lg-glow-ok { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--lg-ok) 45%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes lg-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.lg-btn {
	width: 100%; height: 48px; border: 0; border-radius: 10px;
	background: var(--lg-accent); color: #fff; font-size: 1rem; font-weight: 700; cursor: pointer;
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	transition: background-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.lg-btn:hover:not(:disabled) { background: var(--lg-accent-3); box-shadow: 0 6px 16px -6px var(--lg-accent-3); }
.lg-btn:active:not(:disabled) { transform: translateY(1px); }
.lg-btn:disabled { opacity: .55; cursor: not-allowed; }
/* Busy state after submit: <button class="lg-btn is-loading" disabled><span class="lg-spinner"></span> Logging In</button> */
.lg-btn.is-loading:disabled { opacity: .85; cursor: progress; }
.lg-spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: lg-spin .7s linear infinite; flex: 0 0 auto; }
@keyframes lg-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .lg-spinner { animation-duration: 1.6s; } }
.lg-links { margin-top: 22px; text-align: center; font-size: 0.9rem; color: var(--lg-muted); }

.lg-theme {
	position: fixed; top: 18px; right: 18px; z-index: 10;
	display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
	border: 1px solid var(--lg-line); border-radius: 999px;
	background: var(--lg-surface); color: var(--lg-ink); font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.lg-theme:hover { border-color: var(--lg-accent); }

@media (max-width: 640px) {
	.lg-page { padding: 64px 12px 24px; justify-content: flex-start; }
	.lg-card { padding: 30px 22px 26px; border-radius: 16px; }
	.lg-theme { top: 12px; right: 12px; padding: 6px 12px; }
	.lg-bubble:nth-child(1) { width: 130px; height: 130px; }
	.lg-bubble:nth-child(3), .lg-bubble:nth-child(5) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- Shared by the password and registration pages ---- */
.lg-icon {
	width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px;
	display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
	color: var(--lg-accent); background: color-mix(in srgb, var(--lg-accent) 12%, transparent);
}
.lg-icon--ok { color: var(--lg-ok); background: color-mix(in srgb, var(--lg-ok) 12%, transparent); }
.lg-icon--fail { color: var(--lg-fail); background: color-mix(in srgb, var(--lg-fail) 12%, transparent); }
.lg-icon--warn { color: var(--lg-warn); background: color-mix(in srgb, var(--lg-warn) 12%, transparent); }
.lg-back { display: inline-flex; align-items: center; gap: 6px; }
a.lg-btn { text-decoration: none; }
a.lg-btn:hover { color: #fff; }
.lg-divider { height: 1px; margin: 4px 0 18px; background: var(--lg-line); }
.lg-note { margin: 14px 0 0; font-size: 0.8rem; color: var(--lg-muted); text-align: center; }
/* "Generate" button inside a password field */
.lg-input--gen input { padding-right: 132px; }
.lg-gen {
	position: absolute; right: 44px; top: 50%; transform: translateY(-50%);
	height: 32px; padding: 0 10px; border: 1px solid var(--lg-line); border-radius: 8px;
	background: var(--lg-surface); color: var(--lg-accent); font-size: 0.8rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.lg-gen:hover { border-color: var(--lg-accent); }
.lg-gen.is-done { color: var(--lg-ok); border-color: var(--lg-ok); }
/* Password rules, ticked off as you type */
.lg-rules { list-style: none; margin: -4px 0 16px; padding: 12px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px;
	border: 1px solid var(--lg-line); border-radius: 10px; background: color-mix(in srgb, var(--lg-accent) 4%, transparent); font-size: 0.82rem; color: var(--lg-muted); }
.lg-rules li { display: flex; align-items: center; gap: 7px; transition: color .15s ease; }
.lg-rules li i { width: 14px; text-align: center; font-size: 0.8rem; }
.lg-rules li.is-ok { color: var(--lg-ok); }
.lg-meter { height: 5px; margin: -6px 0 14px; border-radius: 3px; background: var(--lg-line); overflow: hidden; }
.lg-meter span { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--lg-fail); transition: width .25s ease, background-color .25s ease; }
.lg-match { min-height: 18px; margin: -8px 0 14px; font-size: 0.82rem; }
.lg-match.is-ok { color: var(--lg-ok); } .lg-match.is-fail { color: var(--lg-fail); }
@media (max-width: 400px) { .lg-rules { grid-template-columns: 1fr; } }

/* ---- One-time code (login_otp) ---- */
.lg-to { display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; padding: 5px 12px; border-radius: 999px;
	background: color-mix(in srgb, var(--lg-accent) 9%, transparent); color: var(--lg-ink); font-size: 0.88rem; font-weight: 700; }
.lg-to i { color: var(--lg-accent); }
.lg-otp { display: flex; justify-content: center; gap: 10px; margin: 0 0 14px; }
.lg-otp input {
	width: 52px; height: 58px; padding: 0; text-align: center;
	border: 1px solid var(--lg-line); border-radius: 12px;
	background: var(--lg-field); color: var(--lg-ink); font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums;
	transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.lg-otp input:focus { outline: none; border-color: var(--lg-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lg-accent) 22%, transparent); }
.lg-otp input.is-filled { border-color: var(--lg-accent); background: color-mix(in srgb, var(--lg-accent) 6%, var(--lg-field)); }
.lg-otp.is-wrong input { border-color: var(--lg-fail); animation: lg-shake .4s ease-in-out 1; }
.lg-otp-gap { width: 6px; }
.lg-timer { margin: 0 0 16px; text-align: center; font-size: 0.85rem; color: var(--lg-muted); }
.lg-timer b { color: var(--lg-ink); font-variant-numeric: tabular-nums; }
.lg-timer.is-low b { color: var(--lg-warn); }
.lg-timer.is-out { color: var(--lg-fail); font-weight: 600; }
.lg-links--split { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
@media (max-width: 420px) {
	.lg-otp { gap: 6px; }
	.lg-otp input { width: 42px; height: 50px; font-size: 1.25rem; border-radius: 10px; }
	.lg-otp-gap { width: 2px; }
}
