:root {
  color-scheme: dark;
  --ink: #f2fbff;
  --muted: #91aebf;
  --cyan: #4de4ff;
  --cyan-soft: rgba(77, 228, 255, .16);
  --orange: #ff7a2f;
  --panel: rgba(4, 15, 27, .72);
  --line: rgba(165, 226, 255, .18);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background: #020711;
  font-family: "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.scene, .fallback-earth, .scene-shade {
  position: fixed;
  inset: 0;
}
.scene { z-index: 0; }
.scene canvas { display: block; width: 100%; height: 100%; }
.fallback-earth {
  z-index: -1;
  opacity: 0;
  background:
    radial-gradient(circle at 57% 42%, transparent 0 16%, rgba(57, 213, 255, .1) 17%, transparent 30%),
    url("/static/earth_realistic.png") 68% 50% / min(62vw, 760px) auto no-repeat,
    #020711;
  transition: opacity .4s ease;
}
.webgl-failed .fallback-earth { z-index: 0; opacity: .72; }
.scene-shade {
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(1, 5, 12, .96) 0%, rgba(1, 7, 15, .73) 32%, rgba(1, 7, 15, .06) 66%, rgba(1, 5, 12, .46) 100%),
    linear-gradient(180deg, rgba(1, 6, 14, .34), transparent 58%, rgba(1, 6, 14, .78));
}
.scene-shade::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .22;
  background-image:
    linear-gradient(rgba(83, 197, 255, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(83, 197, 255, .07) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: linear-gradient(90deg, black, transparent 72%);
}

.topbar {
  position: fixed;
  z-index: 4;
  inset: 0 0 auto;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(24px, 4vw, 72px);
  border-bottom: 1px solid rgba(141, 217, 255, .12);
}
.top-actions { display: flex; align-items: center; gap: 18px; }
.login-trigger {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 17px;
  border: 1px solid rgba(136, 221, 255, .27);
  border-radius: 4px;
  color: #e9fbff;
  background: rgba(4, 21, 35, .52);
  backdrop-filter: blur(12px);
  cursor: pointer;
  font: 680 12px inherit;
  transition: color .2s, border-color .2s, background .2s;
}
.login-trigger:hover { color: #fff; border-color: var(--cyan); background: rgba(7, 40, 61, .7); }
.login-trigger svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.identity {
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}
.identity img {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  box-shadow: 0 12px 35px rgba(255, 108, 34, .25);
}
.identity strong {
  display: block;
  font-size: 19px;
  font-weight: 780;
}
.identity small {
  display: block;
  margin-top: 3px;
  color: #7d9aab;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
}
.system-state {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #a9c2cf;
  font-size: 12px;
  font-weight: 650;
}
.system-state i, .security i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #49e49b;
  box-shadow: 0 0 12px #49e49b;
}

.login-shell {
  position: relative;
  z-index: 3;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(380px, 680px) 1px;
  align-items: center;
  justify-content: space-between;
  gap: 0;
  width: min(1400px, calc(100vw - 9vw));
  margin: 0 auto;
  padding: 120px 0 82px;
}
.story { align-self: center; max-width: 580px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 26px;
  color: #8ec8d7;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .2em;
}
.eyebrow span {
  width: 32px;
  height: 1px;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}
.story h1 {
  margin: 0;
  max-width: 560px;
  font-size: clamp(52px, 5vw, 82px);
  line-height: 1.04;
  font-weight: 760;
  letter-spacing: 0;
}
.story h1 em {
  color: transparent;
  font-style: normal;
  background: linear-gradient(90deg, #f5fbff 5%, #8eeeff 52%, #d9f9ff);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 22px rgba(61, 218, 255, .2));
}
.story p {
  max-width: 470px;
  margin: 26px 0 0;
  color: #91aab8;
  font-size: 16px;
  line-height: 1.9;
}
.coordinates {
  display: flex;
  gap: 24px;
  margin-top: 42px;
  color: #58788a;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 10px;
  letter-spacing: .12em;
}

.login-panel {
  position: fixed;
  z-index: 7;
  top: 82px;
  right: clamp(20px, 4vw, 70px);
  width: min(410px, calc(100vw - 32px));
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(8, 30, 49, .84), rgba(2, 11, 21, .9)),
    var(--panel);
  box-shadow: 0 32px 100px rgba(0, 0, 0, .5), inset 0 1px rgba(255, 255, 255, .04);
  backdrop-filter: blur(22px) saturate(120%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-14px) scale(.98);
  transform-origin: top right;
  transition: opacity .28s ease, visibility .28s ease, transform .36s cubic-bezier(.2,.8,.2,1);
}
.login-panel.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.login-panel::before, .login-panel::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  pointer-events: none;
}
.login-panel::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
}
.login-panel::after {
  right: -1px;
  bottom: -1px;
  border-right: 2px solid var(--cyan);
  border-bottom: 2px solid var(--cyan);
}
.panel-index {
  position: absolute;
  top: 20px;
  right: 24px;
  color: #537285;
  font: 10px Consolas, monospace;
  letter-spacing: .14em;
}
.panel-close {
  position: absolute;
  z-index: 2;
  top: 15px;
  right: 16px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  color: #7898aa;
  background: rgba(111, 171, 199, .08);
  cursor: pointer;
}
.panel-close:hover { color: #fff; background: rgba(111, 171, 199, .16); }
.panel-close svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.panel-index { right: 62px; }
.panel-heading {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}
.panel-mark {
  width: 3px;
  height: 38px;
  border-radius: 4px;
  background: linear-gradient(var(--cyan), #1179a2);
  box-shadow: 0 0 16px rgba(77, 228, 255, .46);
}
.panel-heading h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 760;
}
.panel-heading p {
  margin: 5px 0 0;
  color: #7290a1;
  font-size: 12px;
}
.login-panel > label {
  display: block;
  margin: 15px 0 8px;
  color: #a8c0cd;
  font-size: 12px;
  font-weight: 680;
}
.field {
  position: relative;
  display: flex;
  align-items: center;
  height: 52px;
  border: 1px solid rgba(145, 211, 244, .17);
  border-radius: 6px;
  background: rgba(1, 9, 18, .68);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field:focus-within {
  border-color: rgba(77, 228, 255, .72);
  background: rgba(2, 16, 29, .86);
  box-shadow: 0 0 0 3px rgba(77, 228, 255, .07), inset 0 0 20px rgba(77, 228, 255, .035);
}
.field > svg, .reveal svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}
.field > svg {
  flex: 0 0 auto;
  margin-left: 15px;
  color: #5d8294;
}
.field input {
  min-width: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  padding: 0 13px;
  color: #effbff;
  background: transparent;
  font: 500 15px inherit;
}
.field input::selection { background: rgba(77, 228, 255, .25); }
.reveal {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 100%;
  border: 0;
  color: #678697;
  background: transparent;
  cursor: pointer;
}
.reveal:hover { color: #c4f6ff; }
.submit {
  position: relative;
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin-top: 22px;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  color: white;
  background: linear-gradient(105deg, #ff6427, #ff8a32);
  box-shadow: 0 14px 36px rgba(255, 104, 39, .22);
  cursor: pointer;
  font: 760 15px inherit;
  transition: transform .2s, box-shadow .2s;
}
.submit::before {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-110%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent);
  transition: transform .55s ease;
}
.submit:hover { transform: translateY(-1px); box-shadow: 0 18px 44px rgba(255, 104, 39, .3); }
.submit:hover::before { transform: translateX(110%); }
.submit svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.submit.loading span { opacity: .65; }
.submit.loading svg { animation: arrowPulse .7s ease-in-out infinite alternate; }
.error {
  min-height: 20px;
  margin-top: 11px;
  color: #ff9a9a;
  font-size: 12px;
  font-weight: 650;
}
.security {
  display: grid;
  grid-template-columns: 8px auto 1fr;
  align-items: center;
  gap: 8px;
  padding-top: 15px;
  border-top: 1px solid rgba(139, 205, 236, .1);
  color: #75acbc;
  font-size: 10px;
}
.security b { justify-self: end; color: #506f80; font-weight: 550; }

footer {
  position: fixed;
  z-index: 4;
  inset: auto clamp(24px, 4vw, 72px) 25px;
  display: flex;
  justify-content: space-between;
  color: #476574;
  font: 9px Consolas, monospace;
  letter-spacing: .15em;
}
.scene-hint {
  position: fixed;
  z-index: 4;
  left: 50%;
  bottom: 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 0;
  color: #557789;
  background: transparent;
  transform: translateX(-50%);
  pointer-events: none;
  font: 8px Consolas, monospace;
  letter-spacing: .18em;
}
.scene-hint span {
  width: 19px;
  height: 30px;
  border: 1px solid rgba(127, 207, 240, .35);
  border-radius: 12px;
}
.scene-hint span::after {
  content: "";
  display: block;
  width: 2px;
  height: 6px;
  margin: 6px auto 0;
  border-radius: 2px;
  background: var(--cyan);
  animation: mouseHint 1.5s ease-in-out infinite;
}
.loader {
  position: fixed;
  z-index: 8;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: #020711;
  transition: opacity .7s ease, visibility .7s;
}
.loader span {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(77, 228, 255, .18);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.loader small { color: #67899a; font: 9px Consolas, monospace; letter-spacing: .2em; }
.loaded .loader { opacity: 0; visibility: hidden; }
.entering .scene canvas {
  transform: scale(1.08);
  filter: brightness(1.28) saturate(1.18);
  transition: transform .8s cubic-bezier(.2,.8,.2,1), filter .8s ease;
}
.entering .story, .entering .topbar, .entering footer {
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity .45s ease, transform .45s ease;
}
.entering .login-panel {
  transform: scale(.98);
  border-color: rgba(77, 228, 255, .62);
  box-shadow: 0 0 80px rgba(77, 228, 255, .16);
  transition: transform .45s ease, border-color .45s ease, box-shadow .45s ease;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes arrowPulse { to { transform: translateX(5px); } }
@keyframes mouseHint {
  0% { transform: translateY(0); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translateY(10px); opacity: 0; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .scene-shade {
    background:
      linear-gradient(180deg, rgba(1, 6, 14, .22), rgba(1, 6, 14, .7) 44%, #020711 78%),
      linear-gradient(90deg, rgba(1, 6, 14, .55), transparent);
  }
  .login-shell {
    width: min(92vw, 620px);
    grid-template-columns: 1fr;
    gap: 34px;
    padding: 120px 0 76px;
  }
  .story { padding-top: 5vh; }
  .story h1 { font-size: clamp(44px, 11vw, 68px); }
  .story p { max-width: 520px; }
  .login-panel { margin-top: 18vh; }
  .login-panel { top: 78px; right: 16px; margin-top: 0; }
}

@media (max-width: 520px) {
  .topbar { height: 76px; padding: 0 18px; }
  .identity img { width: 42px; height: 42px; border-radius: 11px; }
  .identity strong { font-size: 17px; }
  .system-state span { display: none; }
  .system-state { display: none; }
  .login-trigger { height: 38px; padding: 0 13px; }
  .login-shell {
    width: calc(100vw - 32px);
    min-height: 100svh;
    gap: 22px;
    padding: 96px 0 46px;
  }
  .story { padding-top: 1vh; }
  .eyebrow { margin-bottom: 17px; font-size: 9px; }
  .story h1 { max-width: 360px; font-size: 42px; line-height: 1.08; }
  .story p { margin-top: 17px; font-size: 14px; line-height: 1.72; }
  .coordinates { display: none; }
  .login-panel {
    top: 68px;
    margin-top: 0;
    padding: 24px 20px 21px;
    border-radius: 7px;
  }
  .panel-heading h2 { font-size: 24px; }
  .panel-heading p { font-size: 11px; }
  .security { grid-template-columns: 8px auto; }
  .security b { display: none; }
  footer { display: none; }
  .scene-hint { bottom: 18px; }
}

@media (max-height: 720px) and (min-width: 901px) {
  .topbar { height: 76px; }
  .login-shell { padding: 88px 0 58px; }
  .story h1 { font-size: 54px; }
  .story p { margin-top: 18px; }
  .coordinates { margin-top: 24px; }
  .login-panel { padding: 24px; }
  .panel-heading { margin-bottom: 17px; }
  .field { height: 47px; }
  .submit { height: 48px; margin-top: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
