:root {
  --ambient-panel: rgba(255, 255, 255, 0.78);
  --ambient-panel-strong: rgba(255, 255, 255, 0.9);
  --ambient-line: rgba(255, 255, 255, 0.38);
  --ambient-ink: #28344a;
  --ambient-muted: #718099;
  --ambient-accent: #5f73e8;
}

body.ambient-ready {
  background: transparent !important;
}

.ambient-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #b8d2db;
  transition: background-color 450ms ease;
}

.ambient-background canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.ambient-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.18));
  pointer-events: none;
}

body.ambient-ready .bg-blob,
body.ambient-ready .blob {
  display: none;
}

body.ambient-ready .top-header,
body.ambient-ready .side-nav {
  background: var(--ambient-panel);
  border-color: var(--ambient-line);
}

body.ambient-ready .side-nav {
  overflow-x: hidden;
}

.sidebar-meteor-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

body:not([data-ambient-effect="meteor"]) .sidebar-meteor-layer {
  display: none;
}

.sidebar-meteor {
  --meteor-start-y: 15%;
  position: absolute;
  top: var(--meteor-start-y);
  left: calc(100% + 24px);
  width: 112px;
  height: 2px;
  border-radius: 999px;
  opacity: 0;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--ambient-accent) 82%, #ffffff) 0,
    color-mix(in srgb, var(--ambient-accent) 52%, #ffffff) 18%,
    rgba(255, 255, 255, 0.58) 48%,
    rgba(255, 255, 255, 0) 100%
  );
  box-shadow: -3px 0 8px color-mix(in srgb, var(--ambient-accent) 58%, rgba(255, 255, 255, 0.76));
  transform: translate3d(0, 0, 0) rotate(-28deg);
  transform-origin: left center;
  animation: sidebar-meteor-flight 10.2s cubic-bezier(0.28, 0.5, 0.36, 1) infinite;
  animation-delay: -5.8s;
}

.sidebar-meteor::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ambient-accent) 72%, #ffffff);
  box-shadow:
    0 0 5px 2px color-mix(in srgb, var(--ambient-accent) 54%, #ffffff),
    0 0 10px 3px rgba(255, 255, 255, 0.76);
  transform: translateY(-50%);
}

.sidebar-meteor:nth-child(2) {
  --meteor-start-y: 42%;
  width: 88px;
  animation-delay: -2.4s;
}

.sidebar-meteor:nth-child(3) {
  --meteor-start-y: 68%;
  width: 72px;
  animation-delay: 1s;
}

.main-container.sidebar-collapsed .sidebar-meteor-layer {
  display: none;
}

body.ambient-ready .side-nav > .nav-header,
body.ambient-ready .side-nav > .nav-menu {
  position: relative;
  z-index: 2;
}

@keyframes sidebar-meteor-flight {
  0%,
  66% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(-28deg);
  }
  67% {
    opacity: 0.18;
  }
  69% {
    opacity: 0.96;
  }
  85% {
    opacity: 0.72;
  }
  88% {
    opacity: 0;
    transform: translate3d(-390px, 205px, 0) rotate(-28deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(-390px, 205px, 0) rotate(-28deg);
  }
}

body.ambient-ready .login-wrapper {
  background: var(--ambient-panel-strong);
  border-color: var(--ambient-line);
  box-shadow: 0 28px 70px rgba(43, 68, 81, 0.16);
}

body.ambient-ready #contentFrame,
body.ambient-ready .content-frame {
  background: transparent;
}

body.ambient-ready .mobile-shell {
  position: relative;
  z-index: 1;
}

body[data-ambient-theme="polar-dawn"] {
  --ambient-panel: rgba(255, 255, 255, 0.7);
  --ambient-panel-strong: rgba(255, 255, 255, 0.88);
  --ambient-line: rgba(255, 255, 255, 0.54);
  --ambient-ink: #233448;
  --ambient-muted: #687b90;
  --ambient-accent: #2d829c;
}

body[data-ambient-theme="misty-lake"] {
  --ambient-panel: rgba(252, 255, 255, 0.76);
  --ambient-panel-strong: rgba(255, 255, 255, 0.91);
  --ambient-line: rgba(255, 255, 255, 0.55);
  --ambient-accent: #4d8c88;
}

body[data-ambient-theme="spring-mist"] {
  --ambient-panel: rgba(250, 255, 252, 0.76);
  --ambient-panel-strong: rgba(255, 255, 255, 0.9);
  --ambient-line: rgba(244, 255, 249, 0.58);
  --ambient-accent: #438c72;
}

body[data-ambient-theme="peach-morning"] {
  --ambient-panel: rgba(255, 252, 250, 0.8);
  --ambient-panel-strong: rgba(255, 255, 255, 0.91);
  --ambient-line: rgba(255, 248, 244, 0.58);
  --ambient-accent: #b66f70;
}

body[data-ambient-theme="sea-salt"] {
  --ambient-panel: rgba(250, 254, 255, 0.76);
  --ambient-panel-strong: rgba(255, 255, 255, 0.9);
  --ambient-line: rgba(249, 254, 255, 0.58);
  --ambient-accent: #3d87a1;
}

body[data-ambient-theme="cloud-gold"] {
  --ambient-panel: rgba(255, 254, 250, 0.78);
  --ambient-panel-strong: rgba(255, 255, 255, 0.91);
  --ambient-line: rgba(255, 253, 244, 0.6);
  --ambient-accent: #9a7b42;
}

body[data-ambient-theme="iris-haze"] {
  --ambient-panel: rgba(253, 253, 255, 0.78);
  --ambient-panel-strong: rgba(255, 255, 255, 0.91);
  --ambient-line: rgba(255, 255, 255, 0.56);
  --ambient-accent: #6f719e;
}

body[data-ambient-theme="snow-light"] {
  --ambient-panel: rgba(252, 255, 255, 0.78);
  --ambient-panel-strong: rgba(255, 255, 255, 0.92);
  --ambient-line: rgba(255, 255, 255, 0.62);
  --ambient-accent: #5b8d9e;
}

body[data-ambient-theme="none"] {
  --ambient-panel: rgba(255, 255, 255, 0.92);
  --ambient-panel-strong: #ffffff;
  --ambient-line: rgba(220, 227, 237, 0.94);
  --ambient-accent: #6273d9;
}

.ambient-picker {
  position: relative;
  z-index: 170;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Segoe UI", sans-serif;
}

.ambient-picker-trigger {
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  color: var(--ambient-muted);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(215, 224, 236, 0.88);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.ambient-picker-trigger:hover,
.ambient-picker.open .ambient-picker-trigger {
  color: var(--ambient-accent);
  background: rgba(255, 255, 255, 0.88);
  border-color: color-mix(in srgb, var(--ambient-accent) 45%, #d9e1ec);
}

.ambient-picker-trigger i:last-child {
  font-size: 9px;
  transition: transform 180ms ease;
}

.ambient-picker.open .ambient-picker-trigger i:last-child {
  transform: rotate(180deg);
}

.ambient-picker-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  width: 360px;
  max-height: min(680px, calc(100vh - 78px));
  padding: 12px;
  overflow-y: auto;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-6px);
  color: var(--ambient-ink);
  background: rgba(250, 252, 255, 0.94);
  border: 1px solid rgba(218, 226, 237, 0.92);
  border-radius: 8px;
  box-shadow: 0 20px 46px rgba(23, 37, 61, 0.2);
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
}

.ambient-picker.open .ambient-picker-menu {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.ambient-picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.ambient-picker-heading strong {
  font-size: 12px;
}

.ambient-picker-heading span {
  color: #8a98ab;
  font-size: 10px;
}

.ambient-template-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.ambient-template {
  min-width: 0;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 8px;
  padding: 7px;
  color: #36445b;
  background: #fff;
  border: 1px solid #e3e8f0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color 150ms ease, background 150ms ease;
}

.ambient-template:hover {
  border-color: #b9c5d7;
  background: #f7f9fc;
}

.ambient-template.active {
  color: var(--ambient-accent);
  border-color: color-mix(in srgb, var(--ambient-accent) 55%, #dce3ed);
  background: color-mix(in srgb, var(--ambient-accent) 7%, #fff);
}

.ambient-template-copy {
  min-width: 0;
}

.ambient-template-copy strong,
.ambient-template-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ambient-template-copy strong {
  font-size: 10px;
}

.ambient-template-copy small {
  margin-top: 2px;
  color: #8a98ab;
  font-size: 8px;
}

.ambient-template > i {
  visibility: hidden;
  color: var(--ambient-accent);
  font-size: 11px;
}

.ambient-template.active > i {
  visibility: visible;
}

.ambient-effect-section {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid #e5eaf1;
}

.ambient-effect-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.ambient-effect-option {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 8px;
  padding: 7px;
  color: #36445b;
  background: #fff;
  border: 1px solid #e3e8f0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color 150ms ease, background 150ms ease;
}

.ambient-effect-option:hover {
  border-color: #b9c5d7;
  background: #f7f9fc;
}

.ambient-effect-option.active {
  color: var(--ambient-accent);
  border-color: color-mix(in srgb, var(--ambient-accent) 55%, #dce3ed);
  background: color-mix(in srgb, var(--ambient-accent) 7%, #fff);
}

.ambient-effect-option > i {
  visibility: hidden;
  color: var(--ambient-accent);
  font-size: 10px;
}

.ambient-effect-option.active > i {
  visibility: visible;
}

.ambient-effect-icon {
  position: relative;
  width: 34px;
  height: 30px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #75849a;
  background: linear-gradient(145deg, #edf2f8, #f9fbfd);
  border: 1px solid #e0e6ee;
  border-radius: 5px;
}

.ambient-effect-icon i {
  position: relative;
  z-index: 2;
  font-size: 13px;
}

.ambient-effect-icon::before,
.ambient-effect-icon::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.ambient-effect-icon[data-effect-preview="meteor"] {
  color: #5384a4;
  background: linear-gradient(145deg, #dcecf2, #f7fbfc);
}

.ambient-effect-icon[data-effect-preview="meteor"]::before {
  width: 25px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(75, 132, 166, 0.8));
  transform: rotate(-28deg);
}

.ambient-effect-icon[data-effect-preview="fireworks"] {
  color: #b96c75;
  background: linear-gradient(145deg, #f7e9ec, #fff7ec);
}

.ambient-effect-icon[data-effect-preview="fireworks"]::before {
  width: 18px;
  height: 18px;
  border: 1px dotted #d9817f;
}

.ambient-effect-icon[data-effect-preview="stardust"] {
  color: #6c78a6;
  background: linear-gradient(145deg, #e7e9f4, #f8f9fd);
}

.ambient-effect-icon[data-effect-preview="stardust"]::before,
.ambient-effect-icon[data-effect-preview="stardust"]::after {
  width: 3px;
  height: 3px;
  background: #8f99bd;
  box-shadow: 9px -5px #c7a96c, -8px 6px #76ada3;
}

.ambient-effect-icon[data-effect-preview="fireflies"] {
  color: #7f8f4e;
  background: linear-gradient(145deg, #eef2df, #fbf8e9);
}

.ambient-effect-icon[data-effect-preview="fireflies"]::before {
  width: 5px;
  height: 5px;
  background: #efd676;
  box-shadow: 0 0 7px #efd676, 9px 5px 0 -1px #9dc68f, -8px -4px 0 -1px #f1dda1;
}

.ambient-swatch {
  position: relative;
  width: 40px;
  height: 30px;
  overflow: hidden;
  border-radius: 4px;
  background: #0b1b32;
}

.ambient-swatch::before,
.ambient-swatch::after {
  content: "";
  position: absolute;
  left: -5px;
  width: 50px;
  height: 10px;
  border-radius: 50%;
  transform: rotate(-10deg);
}

.ambient-swatch::before {
  top: 7px;
  background: rgba(80, 235, 185, 0.72);
}

.ambient-swatch[data-swatch="none"] {
  background: #f4f6fb;
  border: 1px solid #dfe5ee;
}
.ambient-swatch[data-swatch="none"]::before,
.ambient-swatch[data-swatch="none"]::after {
  display: none;
}

.ambient-swatch::after {
  top: 13px;
  background: rgba(86, 151, 255, 0.62);
}

.ambient-swatch[data-swatch="polar-dawn"] {
  background: #b9dce6;
}
.ambient-swatch[data-swatch="polar-dawn"]::before { background: rgba(47, 184, 151, 0.66); }
.ambient-swatch[data-swatch="polar-dawn"]::after { background: rgba(255, 179, 148, 0.58); }

.ambient-swatch[data-swatch="misty-lake"] {
  background: #c5dadd;
}
.ambient-swatch[data-swatch="misty-lake"]::before { background: rgba(103, 169, 158, 0.62); }
.ambient-swatch[data-swatch="misty-lake"]::after { background: rgba(184, 201, 174, 0.64); }

.ambient-swatch[data-swatch="spring-mist"] {
  background: #d4e4dc;
}
.ambient-swatch[data-swatch="spring-mist"]::before { background: rgba(101, 178, 141, 0.62); }
.ambient-swatch[data-swatch="spring-mist"]::after { background: rgba(120, 173, 200, 0.58); }

.ambient-swatch[data-swatch="peach-morning"] {
  background: #ead8d4;
}
.ambient-swatch[data-swatch="peach-morning"]::before { background: rgba(227, 168, 160, 0.64); }
.ambient-swatch[data-swatch="peach-morning"]::after { background: rgba(142, 188, 196, 0.54); }

.ambient-swatch[data-swatch="sea-salt"] {
  background: #cae0e8;
}
.ambient-swatch[data-swatch="sea-salt"]::before { background: rgba(88, 171, 193, 0.62); }
.ambient-swatch[data-swatch="sea-salt"]::after { background: rgba(183, 201, 223, 0.62); }

.ambient-swatch[data-swatch="cloud-gold"] {
  background: #e7e2d7;
}
.ambient-swatch[data-swatch="cloud-gold"]::before { background: rgba(216, 185, 121, 0.62); }
.ambient-swatch[data-swatch="cloud-gold"]::after { background: rgba(145, 188, 169, 0.54); }

.ambient-swatch[data-swatch="iris-haze"] {
  background: #d7d8e2;
}
.ambient-swatch[data-swatch="iris-haze"]::before { background: rgba(153, 159, 200, 0.6); }
.ambient-swatch[data-swatch="iris-haze"]::after { background: rgba(131, 184, 189, 0.54); }

.ambient-swatch[data-swatch="snow-light"] {
  background: #e4edf0;
}
.ambient-swatch[data-swatch="snow-light"]::before { background: rgba(142, 194, 199, 0.58); }
.ambient-swatch[data-swatch="snow-light"]::after { background: rgba(227, 185, 162, 0.5); }

.login-ambient-picker {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 20;
}

.login-ambient-picker .ambient-picker-trigger {
  color: #53677a;
  background: rgba(255, 255, 255, 0.68);
  border-color: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.login-ambient-picker .ambient-picker-trigger:hover,
.login-ambient-picker .ambient-picker.open .ambient-picker-trigger {
  color: var(--ambient-accent);
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.96);
}

@media (max-width: 640px) {
  .ambient-picker-trigger span {
    display: none;
  }

  .ambient-picker-trigger {
    width: 36px;
    padding: 0;
  }

  .ambient-picker-trigger i:last-child {
    display: none;
  }

  .ambient-picker-menu {
    position: fixed;
    top: calc(max(58px, env(safe-area-inset-top) + 48px));
    right: 10px;
    left: 10px;
    width: auto;
  }

  .ambient-template-list {
    grid-template-columns: 1fr 1fr;
  }

  .ambient-effect-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  body.ambient-ready .login-container {
    padding-top: calc(70px + env(safe-area-inset-top));
  }
}

@media (max-width: 390px) {
  .ambient-template-list {
    grid-template-columns: 1fr;
  }

  .ambient-effect-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-picker-menu,
  .ambient-picker-trigger i {
    transition: none;
  }

  .sidebar-meteor-layer {
    display: none;
  }
}
