:root {
  --canvas-start: #dbe6f1;
  --canvas-mid: #e7eef6;
  --canvas-end: #f4f7fa;
  --canvas-veil-a: rgba(244, 248, 252, 0);
  --canvas-veil-b: rgba(245, 248, 252, .46);
  --canvas-veil-c: rgba(247, 249, 252, .78);
  --panel-halo: rgba(255, 255, 255, .68);
  --ink: #0c1d30;
  --muted: #5d6f84;
  --soft: #8392a5;
  --field-bg: rgba(255, 255, 255, .48);
  --field-hover: rgba(255, 255, 255, .66);
  --field-autofill: #eef3fb;
  --field-border: rgba(91, 119, 150, .25);
  --field-focus: #3f67de;
  --popover-bg: rgba(248, 251, 254, .92);
  --popover-border: rgba(93, 119, 151, .2);
  --control-bg: rgba(255, 255, 255, .4);
  --button-start: #2f6fd2;
  --button-end: #1c9995;
  --button-text: #fff;
  --button-shadow: rgba(37, 104, 158, .27);
  --red: #d34259;
  --grid-line: rgba(41, 83, 116, .055);
  --flow-line: rgba(63, 121, 166, .18);
  --ribbon-cyan: rgba(18, 176, 202, .52);
  --ribbon-blue: rgba(73, 110, 226, .46);
  --ribbon-violet: rgba(132, 91, 220, .27);
  color-scheme: light;
}

html[data-theme="dark"] {
  --canvas-start: #03111e;
  --canvas-mid: #08263b;
  --canvas-end: #0a1b2b;
  --canvas-veil-a: rgba(5, 18, 31, 0);
  --canvas-veil-b: rgba(5, 18, 31, .22);
  --canvas-veil-c: rgba(5, 17, 29, .68);
  --panel-halo: rgba(66, 116, 151, .17);
  --ink: #f1f6fb;
  --muted: #a3b2c2;
  --soft: #74889c;
  --field-bg: rgba(9, 29, 45, .42);
  --field-hover: rgba(13, 38, 57, .56);
  --field-autofill: #102d43;
  --field-border: rgba(153, 187, 212, .22);
  --field-focus: #82a4ff;
  --popover-bg: rgba(10, 29, 44, .94);
  --popover-border: rgba(151, 184, 209, .18);
  --control-bg: rgba(13, 37, 55, .48);
  --button-start: #4777e4;
  --button-end: #20a39e;
  --button-text: #fff;
  --button-shadow: rgba(0, 0, 0, .28);
  --red: #ff7185;
  --grid-line: rgba(137, 192, 218, .045);
  --flow-line: rgba(136, 210, 236, .16);
  --ribbon-cyan: rgba(42, 221, 230, .48);
  --ribbon-blue: rgba(89, 125, 255, .42);
  --ribbon-violet: rgba(162, 106, 255, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas-end);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--canvas-end);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-page {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 100svh;
  overflow: hidden;
  grid-template-columns: minmax(0, 1.82fr) minmax(380px, 1fr);
  background:
    radial-gradient(ellipse 46% 68% at 72% 50%, var(--panel-halo), transparent 72%),
    linear-gradient(116deg, var(--canvas-start) 0%, var(--canvas-mid) 52%, var(--canvas-end) 100%);
}

/* This broad veil is the bridge between the visual field and the form. */
.auth-page::after {
  position: absolute;
  z-index: 1;
  inset: 0 0 0 auto;
  width: min(61vw, 980px);
  background: linear-gradient(90deg, var(--canvas-veil-a) 0%, var(--canvas-veil-b) 46%, var(--canvas-veil-c) 100%);
  content: "";
  pointer-events: none;
}

.auth-visual {
  position: absolute;
  z-index: 0;
  inset: 0;
  min-height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.auth-wallpaper {
  position: absolute;
  inset: 0 auto 0 0;
  width: 74%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 70%, rgba(0, 0, 0, .78) 82%, rgba(0, 0, 0, .28) 93%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 0%, #000 70%, rgba(0, 0, 0, .78) 82%, rgba(0, 0, 0, .28) 93%, transparent 100%);
}

.auth-visual::before {
  position: absolute;
  inset: 0;
  opacity: .38;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 72px 72px;
  -webkit-mask-image: radial-gradient(ellipse 72% 90% at 26% 50%, #000 8%, transparent 75%);
  mask-image: radial-gradient(ellipse 72% 90% at 26% 50%, #000 8%, transparent 75%);
  content: "";
}

.auth-visual::after {
  position: absolute;
  top: -38%;
  left: 40%;
  width: 18%;
  height: 176%;
  border-radius: 50%;
  background: linear-gradient(180deg, transparent, rgba(155, 219, 244, .11), transparent);
  filter: blur(30px);
  opacity: .62;
  transform: rotate(21deg);
  content: "";
}

.auth-visual::before,
.auth-visual::after { display: none; }

.visual-aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(84px);
  opacity: .27;
  will-change: transform, opacity;
}

.visual-aurora-one {
  bottom: -22vw;
  left: -10vw;
  width: 54vw;
  height: 54vw;
  background: #00b6c8;
  animation: aurora-one 20s ease-in-out infinite alternate;
}

.visual-aurora-two {
  top: -31vw;
  left: 26vw;
  width: 57vw;
  height: 57vw;
  background: #5364e9;
  animation: aurora-two 24s ease-in-out infinite alternate;
}

.visual-aurora-bridge {
  top: 27%;
  left: 48%;
  width: 34vw;
  height: 34vw;
  background: #4d92c2;
  opacity: .15;
  animation: aurora-bridge 22s ease-in-out infinite alternate;
}

.visual-ribbons {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: .9;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 58%, rgba(0, 0, 0, .76) 73%, transparent 96%);
  mask-image: linear-gradient(90deg, #000 0%, #000 58%, rgba(0, 0, 0, .76) 73%, transparent 96%);
  animation: ribbon-float 19s ease-in-out infinite alternate;
}

.ribbon {
  fill: none;
  stroke: url(#auth-ribbon-gradient);
  stroke-linecap: round;
}

.ribbon-wide {
  stroke-width: 106;
  opacity: .19;
  filter: url(#auth-ribbon-blur);
}

.ribbon-soft {
  stroke-width: 44;
  opacity: .15;
  filter: url(#auth-ribbon-blur);
}

.ribbon-line {
  stroke-width: 1.25;
  opacity: .48;
  filter: drop-shadow(0 0 8px rgba(71, 199, 222, .18));
}

.ribbon-stop-cyan { stop-color: var(--ribbon-cyan); }
.ribbon-stop-blue { stop-color: var(--ribbon-blue); }
.ribbon-stop-violet { stop-color: var(--ribbon-violet); }
.ribbon-stop-clear { stop-color: transparent; }

.visual-flow {
  position: absolute;
  top: 17%;
  left: -12%;
  width: min(78vw, 1180px);
  height: 68%;
  opacity: .82;
  transform: rotate(-7deg);
}

.visual-flow i {
  position: absolute;
  left: 7%;
  width: 88%;
  height: 38%;
  border-top: 1px solid var(--flow-line);
  border-radius: 50%;
  filter: drop-shadow(0 0 12px rgba(104, 208, 230, .08));
  transform-origin: center;
  animation: flow-drift 17s ease-in-out infinite alternate;
}

.visual-flow i:nth-child(1) {
  top: 12%;
  transform: rotate(9deg) scaleY(.75);
}

.visual-flow i:nth-child(2) {
  top: 37%;
  left: -2%;
  width: 96%;
  border-color: color-mix(in srgb, var(--flow-line) 68%, transparent);
  transform: rotate(-5deg) scaleY(1.12);
  animation-delay: -6s;
  animation-duration: 21s;
}

.visual-flow i:nth-child(3) {
  top: 59%;
  left: 14%;
  width: 78%;
  border-color: color-mix(in srgb, var(--flow-line) 52%, transparent);
  transform: rotate(4deg) scaleY(.82);
  animation-delay: -11s;
  animation-duration: 25s;
}

.visual-grain {
  position: absolute;
  inset: 0;
  opacity: .08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.auth-panel {
  position: relative;
  z-index: 3;
  display: grid;
  min-width: 0;
  min-height: 100svh;
  align-items: center;
  padding: clamp(82px, 9vh, 116px) clamp(38px, 4.1vw, 70px) clamp(48px, 7vh, 82px);
  grid-column: 2;
  background: transparent;
}

.auth-panel::before {
  position: absolute;
  z-index: -1;
  top: 17%;
  right: -24%;
  width: 146%;
  height: 66%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 62% 50%, var(--panel-halo), transparent 70%);
  filter: blur(30px);
  content: "";
  pointer-events: none;
}

.auth-controls {
  position: absolute;
  z-index: 20;
  top: clamp(22px, 3vw, 38px);
  right: clamp(22px, 3vw, 38px);
  display: flex;
  gap: 9px;
}

.auth-control { position: relative; }

.control-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  cursor: pointer;
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
  transition: color .18s ease, border-color .18s ease, background .25s ease, transform .18s ease, box-shadow .18s ease;
}

.control-button:hover,
.control-button[aria-expanded="true"] {
  border-color: transparent;
  background: transparent;
  color: var(--field-focus);
  box-shadow: none;
  transform: none;
}

.control-button:focus-visible,
.auth-popover button:focus-visible,
.password-field button:focus-visible,
.submit-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--field-focus) 24%, transparent);
  outline-offset: 3px;
}

.control-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon { display: none; }
html[data-theme-preference="system"] .theme-icon-system,
html[data-theme-preference="light"] .theme-icon-light,
html[data-theme-preference="dark"] .theme-icon-dark { display: block; }

.auth-popover {
  position: absolute;
  top: 52px;
  right: 0;
  width: 250px;
  padding: 12px;
  border: 1px solid var(--popover-border);
  border-radius: 18px;
  background: var(--popover-bg);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(5, 20, 36, .22);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
  backdrop-filter: blur(24px) saturate(120%);
  transform-origin: top right;
  animation: popover-in .16s ease-out;
}

.auth-popover[hidden] { display: none; }

.auth-popover strong {
  display: block;
  padding: 4px 8px 10px;
  font-size: 13px;
  font-weight: 780;
}

.language-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.auth-popover button {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 46px;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: background .15s ease, color .15s ease;
}

.language-options button {
  display: grid;
  gap: 2px;
}

.auth-popover button:hover { background: color-mix(in srgb, var(--field-focus) 8%, transparent); }
.auth-popover button[aria-checked="true"] { background: color-mix(in srgb, var(--field-focus) 12%, transparent); color: var(--field-focus); }
.language-options span { font-size: 13px; font-weight: 740; }
.language-options small { color: var(--soft); font-size: 10px; }
.theme-menu { width: 196px; }
.theme-menu button { width: 100%; font-size: 13px; font-weight: 700; }
.theme-choice-icon { display: grid; width: 24px; height: 24px; place-items: center; color: var(--muted); font-size: 16px; }

.auth-card {
  position: relative;
  z-index: 2;
  width: min(100%, 372px);
  min-width: 0;
  margin: 0 auto;
  padding: 10px 0;
}

.auth-card h1 {
  margin: 0 0 36px;
  color: var(--ink);
  font-size: clamp(42px, 3.6vw, 50px);
  font-weight: 760;
  letter-spacing: -.065em;
  line-height: 1.04;
  text-shadow: 0 8px 30px rgba(4, 20, 34, .08);
}

.auth-card form {
  display: grid;
  min-width: 0;
  gap: 0;
}

.auth-card label {
  margin: 18px 2px 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.auth-card form > label:first-child { margin-top: 0; }

.input-shell {
  position: relative;
  display: flex;
  width: 100%;
  height: 55px;
  min-width: 0;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--field-border);
  border-radius: 22px;
  background: var(--field-bg);
  box-shadow: inset 0 1px rgba(255, 255, 255, .12), 0 10px 30px rgba(8, 28, 47, .045);
  -webkit-backdrop-filter: blur(18px) saturate(118%);
  backdrop-filter: blur(18px) saturate(118%);
  transition: border-color .18s ease, background .22s ease, box-shadow .18s ease, transform .18s ease;
}

.input-shell:hover { background: var(--field-hover); }

.input-shell:focus-within {
  border-color: color-mix(in srgb, var(--field-focus) 62%, transparent);
  background: var(--field-hover);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--field-focus) 9%, transparent), 0 14px 34px rgba(8, 29, 49, .08);
  transform: translateY(-1px);
}

.input-shell > svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-left: 17px;
  fill: none;
  stroke: var(--soft);
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-card input {
  width: 100%;
  height: 100%;
  min-width: 0;
  padding: 0 16px 0 12px;
  border: 0;
  outline: 0;
  background: transparent;
  border-radius: 0 21px 21px 0;
  color: var(--ink);
  font-size: 15px;
}

.auth-card input::placeholder { color: var(--soft); opacity: .8; }
.password-field input { padding-right: 62px; }

/* Browser autofill otherwise colors only the text area and visually splits
   the icon from the input. Keep both parts on one shared surface. */
.input-shell:has(input:-webkit-autofill),
.input-shell:has(input:autofill) {
  background: var(--field-autofill);
}

.auth-card input:-webkit-autofill,
.auth-card input:-webkit-autofill:hover,
.auth-card input:-webkit-autofill:focus,
.auth-card input:-webkit-autofill:active,
.auth-card input:autofill {
  -webkit-text-fill-color: var(--ink) !important;
  caret-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--field-autofill) inset !important;
  box-shadow: 0 0 0 1000px var(--field-autofill) inset !important;
  transition: background-color 9999s ease-out 0s;
}

.password-field button {
  position: absolute;
  top: 7px;
  right: 7px;
  height: 39px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 740;
  transition: color .15s ease, background .15s ease;
}

.password-field button:hover {
  background: color-mix(in srgb, var(--field-focus) 7%, transparent);
  color: var(--field-focus);
}

.submit-button {
  position: relative;
  display: flex;
  width: 100%;
  height: 55px;
  margin-top: 28px;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 22px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(118deg, var(--button-start), var(--button-end));
  color: var(--button-text);
  box-shadow: 0 15px 34px var(--button-shadow), inset 0 1px rgba(255, 255, 255, .22);
  cursor: pointer;
  font-size: 14px;
  font-weight: 760;
  transition: filter .2s ease, transform .18s ease, box-shadow .18s ease;
}

.submit-button::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 20%, rgba(255, 255, 255, .16) 49%, transparent 77%);
  opacity: 0;
  transform: translateX(-45%);
  transition: opacity .22s ease, transform .42s cubic-bezier(.16, 1, .3, 1);
  content: "";
}

.submit-button span { position: relative; z-index: 1; }

.submit-button:hover {
  box-shadow: 0 18px 39px var(--button-shadow), inset 0 1px rgba(255, 255, 255, .24);
  filter: brightness(1.04);
  transform: translateY(-2px);
}

.submit-button:hover::before { opacity: 1; transform: translateX(42%); }
.submit-button:disabled { opacity: .68; cursor: wait; filter: saturate(.65); transform: none; }

.form-status {
  min-height: 23px;
  margin: 4px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.form-status.error { color: var(--red); }

.auth-card h1,
.auth-card form > label,
.auth-card form > .input-shell,
.auth-card .submit-button,
.auth-card .form-status {
  animation: fade-slide-up .72s cubic-bezier(.16, 1, .3, 1) both;
}

.auth-card h1 { animation-delay: .04s; }
.auth-card form > label[for="login-username"] { animation-delay: .11s; }
.auth-card form > .input-shell:first-of-type { animation-delay: .16s; }
.auth-card form > label[for="login-password"] { animation-delay: .22s; }
.auth-card form > .password-field { animation-delay: .27s; }
.auth-card .submit-button { animation-delay: .33s; }
.auth-card .form-status { animation-delay: .38s; }

@keyframes aurora-one {
  from { opacity: .15; transform: translate3d(-4%, 2%, 0) scale(.94); }
  to { opacity: .28; transform: translate3d(11%, -8%, 0) scale(1.08); }
}

@keyframes aurora-two {
  from { opacity: .13; transform: translate3d(-3%, -4%, 0) scale(.92); }
  to { opacity: .25; transform: translate3d(10%, 12%, 0) scale(1.09); }
}

@keyframes aurora-bridge {
  from { opacity: .07; transform: translate3d(-7%, 8%, 0) scale(.9); }
  to { opacity: .16; transform: translate3d(13%, -9%, 0) scale(1.13); }
}

@keyframes flow-drift {
  from { opacity: .42; translate: -1.5% 1%; }
  to { opacity: .9; translate: 2.5% -2%; }
}

@keyframes ribbon-float {
  from { opacity: .72; transform: translate3d(-1.5%, 1.4%, 0) scale(1.015); }
  to { opacity: 1; transform: translate3d(1.8%, -1.2%, 0) scale(1.035); }
}

@keyframes popover-in {
  from { opacity: 0; transform: translateY(-5px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fade-slide-up {
  from { opacity: 0; transform: translate3d(0, 15px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@media (max-width: 1120px) {
  .auth-page { grid-template-columns: minmax(0, 1.28fr) minmax(380px, 1fr); }
  .auth-panel { padding-right: 42px; padding-left: 42px; }
  .visual-flow { width: 82vw; }
}

@media (max-width: 820px) {
  .auth-page {
    min-height: 100svh;
    overflow: visible;
    grid-template-columns: 1fr;
    background:
      radial-gradient(ellipse 90% 48% at 50% 19%, var(--panel-halo), transparent 72%),
      linear-gradient(155deg, var(--canvas-start) 0%, var(--canvas-mid) 52%, var(--canvas-end) 100%);
  }

  .auth-page::after {
    position: fixed;
    top: auto;
    width: 100%;
    height: 78%;
    background: linear-gradient(180deg, var(--canvas-veil-a) 0%, var(--canvas-veil-b) 42%, var(--canvas-veil-c) 100%);
  }

  .auth-visual { position: fixed; }
  .auth-wallpaper {
    width: 100%;
    object-position: 42% center;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 38%, rgba(0, 0, 0, .7) 62%, transparent 94%);
    mask-image: linear-gradient(180deg, #000 0%, #000 38%, rgba(0, 0, 0, .7) 62%, transparent 94%);
  }
  .visual-aurora-one { width: 96vw; height: 96vw; bottom: -38vw; left: -45vw; }
  .visual-aurora-two { width: 110vw; height: 110vw; top: -70vw; left: 18vw; }
  .visual-aurora-bridge { top: 24%; left: 22%; width: 80vw; height: 80vw; }
  .visual-flow { top: 2%; left: -48%; width: 160vw; height: 55%; opacity: .48; }
  .visual-ribbons {
    width: 160%;
    height: 78%;
    transform-origin: 20% 25%;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .7) 66%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .7) 66%, transparent 100%);
  }

  .auth-panel {
    min-height: 100svh;
    padding: 94px 28px 44px;
    grid-column: 1;
  }

  .auth-panel::before { top: 25%; right: -28%; width: 156%; height: 58%; }
  .auth-card { width: min(100%, 400px); }
  .auth-controls { top: 24px; right: 24px; }
}

@media (max-width: 520px) {
  .auth-panel { padding: 86px 22px 28px; }
  .auth-card { width: min(100%, 380px); }
  .auth-card h1 { margin-bottom: 32px; font-size: 42px; }
  .input-shell,
  .submit-button { height: 54px; }
  .language-menu { position: fixed; top: 76px; right: 16px; width: min(280px, calc(100vw - 32px)); }
  .theme-menu { position: fixed; top: 76px; right: 16px; }
}

@media (max-height: 680px) and (min-width: 821px) {
  .auth-panel {
    align-items: start;
    overflow-y: auto;
    padding-top: 70px;
    padding-bottom: 24px;
  }

  .auth-card h1 { margin-bottom: 26px; font-size: 40px; }
  .auth-card label { margin-top: 13px; }
  .input-shell,
  .submit-button { height: 50px; }
  .submit-button { margin-top: 22px; }
}

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