:root { --bg1:#f7f9fb; --bg2:#e7ecf1; --fg:#162c41; --sub:#4a5d6e;
        --line:#cfd8e0; --cell:#ffffff; --btn:#40b4e5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg1:#080b10; --bg2:#101620; --fg:#e8e8fc; --sub:#a3b1bd;
        --line:#222c38; --cell:#121820; --btn:#40b4e5; }
}
:root[data-theme="dark"] { --bg1:#080b10; --bg2:#101620; --fg:#e8e8fc; --sub:#a3b1bd;
        --line:#222c38; --cell:#121820; --btn:#40b4e5; }
* { box-sizing: border-box; }
body { margin:0; min-height:100vh; color:var(--fg); font-family: Liberation Sans, Arial, sans-serif;
       background: linear-gradient(var(--bg1), var(--bg2)); }
.btn { display:inline-block; background:var(--btn); color:#0b2233; font-weight:700; font-size:20px;
       padding:18px 40px; border-radius:16px; text-decoration:none; border:0; cursor:pointer; }

/* login */
.login { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; }
.hero { display:grid; grid-template-columns: 1fr 1fr; gap:24px; align-items:center; width:100%; max-width:1200px; }
.hero h1 { font-size: clamp(64px, 10vw, 150px); margin:0; line-height:1; letter-spacing:-2px; }
.hero .tag { font-size: clamp(18px, 2.2vw, 30px); color:var(--sub); margin:16px 0 28px; }
.hero img { width:100%; max-width:520px; justify-self:center; display:block; }
.logo-toggle { position:relative; isolation:isolate; background:none; border:0; padding:0; margin:0; cursor:pointer; justify-self:center; width:100%; max-width:520px; }
.logo-toggle img { width:100%; display:block; }
@media (max-width: 800px) {
  .hero { grid-template-columns:1fr; text-align:center; }
  .hero img, .logo-toggle { order:-1; max-width:300px; }
}

/* post-login top bar */
.topbar { position:relative; display:grid; grid-template-columns: 1fr auto 1fr; align-items:center; gap:clamp(16px, 2vw, 40px);
          padding: clamp(16px, 1.4vw, 28px) clamp(20px, 3vw, 64px); }
.navgroup { grid-column:2; display:flex; gap:4px; padding:4px; border-radius:999px; background:var(--cell);
            border:1px solid var(--line); font-family: Roboto, Arial, sans-serif; }
.navgroup a { color:var(--sub); text-decoration:none; font-size:clamp(11px, 0.8vw, 15px); font-weight:500;
              padding:0.55em 1.1em; border-radius:999px; transition:background .15s, color .15s; }

.navgroup a:hover { color:#40b4e5; background:rgba(64,180,229,.12); }
.actions { grid-column:3; display:flex; justify-content:flex-end; align-items:center; gap:clamp(2px, 0.25vw, 6px); }
.icon { display:inline-flex; align-items:center; justify-content:center; width:clamp(26px, 1.9vw, 40px); height:clamp(26px, 1.9vw, 40px);
        border:1px solid var(--line); border-radius:999px; background:var(--cell); color:var(--fg); cursor:pointer; }
.icon svg { width:clamp(12px, 0.9vw, 18px); height:clamp(12px, 0.9vw, 18px); }
#theme { color:#40b4e5; }
#theme svg { width:clamp(12px, 0.9vw, 18px); height:clamp(12px, 0.9vw, 18px); }
#theme .sun { display:none; }
#theme .moon { display:block; }
:root[data-theme="dark"] #theme .sun { display:block; }
:root[data-theme="dark"] #theme .moon { display:none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) #theme .sun { display:block; }
  :root:not([data-theme]) #theme .moon { display:none; }
}
@media (max-width: 800px) {
  .topbar { grid-template-columns: 1fr; padding:88px 16px 16px; justify-items:start; }
  .actions { justify-content:flex-start; }
  .navgroup { flex-wrap:wrap; }
}

/* login → sign-in exit animation */
.hero > div { transition: transform .8s cubic-bezier(.2,.7,.2,1); }
.logo-toggle { transition: transform .8s cubic-bezier(.2,.7,.2,1); }
#signin { transition: opacity .25s ease, transform .25s ease; }
body.leaving #signin { opacity:0; transform:translateY(12px); pointer-events:none; }
body.leaving .hero > div { transform: translate(-1vw, calc(40vh - 16px)); }
body.leaving .logo-toggle { transform: translate(9vw, 22vh) rotate(-14deg); }
@media (prefers-reduced-motion: reduce) {
  .hero > div, .logo-toggle, #signin { transition: none; }
}

/* dashboard — the sign-in end position, kept as the resting layout (same size as login) */
.stage-end { position:fixed; inset:0; min-height:0; pointer-events:none; opacity:0; transition:opacity .2s ease; }
.stage-end.ready { opacity:1; }
.stage-end .hero > div:not(.beaker-wrap) { transform: translate(-1vw, calc(40vh - 45px)); }
.stage-end .beaker-wrap { position:relative; isolation:isolate; width:100%; max-width:520px; justify-self:center; margin-top:-23px; transform: translate(9vw, 22vh) rotate(-14deg); }
.stage-end .beaker-wrap img { width:100%; display:block; }

/* smoke rising from the beaker neck */
.smoke { position:absolute; left:0; top:0; width:100%; height:100%; pointer-events:none; z-index:-1; }
.smoke i { position:absolute; left:57.5%; top:15.5%; width:35%; aspect-ratio:1;
           border-radius:44% 56% 52% 48% / 52% 44% 56% 48%;
           background:
             radial-gradient(ellipse 55% 45% at 40% 45%, var(--line) 0%, transparent 70%),
             radial-gradient(ellipse 45% 55% at 62% 60%, var(--line) 0%, transparent 65%);
           filter: blur(2px);
           opacity:0; animation: puff 4s linear infinite; }
.smoke i:nth-child(1) {   animation-duration:4s; animation-delay:0s;  --x1:14px;  --x2:-22px; --x3:26px;  --rise:280px; }
.smoke i:nth-child(2) { border-radius:58% 42% 46% 54% / 44% 58% 42% 56%;  animation-duration:4s; animation-delay:1s; --x1:-20px; --x2:24px;  --x3:-32px; --rise:318px; }
.smoke i:nth-child(3) { border-radius:48% 52% 60% 40% / 56% 42% 58% 44%;   animation-duration:4s; animation-delay:2s;  --x1:18px;  --x2:-28px; --x3:10px;  --rise:262px; }
.smoke i:nth-child(4) { border-radius:52% 48% 42% 58% / 46% 54% 48% 52%;   animation-duration:4s; animation-delay:3s;  --x1:-12px; --x2:16px;  --x3:-20px; --rise:302px; }
/* puffed out of the mouth: starts small, swells, sways, drifts up and fades */
@keyframes puff {
  0%   { opacity:0;   transform: translate(-50%, -50%) scale(.25); }
  12%  { opacity:.7; }
  35%  { opacity:.6;  transform: translate(calc(-50% + var(--x1)), calc(-50% - 90px)) scale(.95); }
  65%  { opacity:.42; transform: translate(calc(-50% + var(--x2)), calc(-50% - 190px)) scale(1.65); }
  85%  { opacity:.18; }
  100% { opacity:0;   transform: translate(calc(-50% + var(--x3)), calc(-50% - var(--rise, 290px))) scale(2.7); }
}
@media (prefers-reduced-motion: reduce) { .smoke i { animation:none; opacity:0; } }
@media (max-width: 800px) {
  .stage-end { display:none; }
}

/* haze filling the flask interior up to the mouth, slowly churned like being mixed */
.haze { position:absolute; inset:0; pointer-events:none; z-index:-1; opacity:.32;
        background:
          radial-gradient(ellipse 60% 40% at 50% 85%, var(--line) 0%, transparent 70%),
          radial-gradient(ellipse 45% 30% at 50% 30%, var(--line) 0%, transparent 70%),
          linear-gradient(to top, var(--line), var(--cell));
        background-size: 260% 260%, 130% 130%, 100% 100%;
        background-repeat: no-repeat;
        -webkit-mask: url(/static/labs-beaker-mask.png) center / 100% 100% no-repeat;
                mask: url(/static/labs-beaker-mask.png) center / 100% 100% no-repeat;
        animation: churn 8s ease-in-out infinite alternate; }
@keyframes churn {
  0%   { background-position: 0% 100%, 50% 50%, 0 0; }
  50%  { background-position: 100% 100%, 50% 50%, 0 0; }
  100% { background-position: 40% 100%, 50% 50%, 0 0; }
}
@media (prefers-reduced-motion: reduce) { .haze { animation:none; } }

/* arriving from sign-in: no fade, the stage is already where the animation left it */
html.arriving .stage-end { opacity:1; transition:none; }

/* login page text sits 2px lower */
.login .hero > div { position:relative; top:11px; }

/* the login page never scrolls; the sign-in beaker overflows, so hide the scrollbar that would shift the layout */
html:has(.login) { overflow:hidden; }

/* search: the nav links and the search field share the same pill and swap in place */
.navgroup { position:relative; }
.navlinks { display:flex; gap:4px; transition: opacity .2s ease, visibility .2s; }
.navsearch { position:absolute; inset:4px; width:calc(100% - 8px); border:0; outline:0; background:transparent;
             font:inherit; font-size:clamp(11px, 0.8vw, 15px); color:var(--fg); padding:0 1em; border-radius:999px;
             opacity:0; pointer-events:none; transition: opacity .2s ease; }
.navsearch::placeholder { color:var(--muted, #71808e); }
.topbar.searching .navlinks { opacity:0; visibility:hidden; }
.topbar.searching .navsearch { opacity:1; pointer-events:auto; }
