:root {
  color-scheme: light;
  --bg: #fff1f7;
  --panel: rgba(255, 255, 255, 0.76);
  --panel-strong: #ffffff;
  --text: #44263a;
  --muted: #8c6379;
  --line: rgba(213, 97, 145, 0.18);
  --accent: #ff6fae;
  --accent-dark: #e9428e;
  --teal: #d94f93;
  --rose: #ff6fae;
  --warning: #b76800;
  --danger: #c93434;
  --shadow: 0 28px 80px rgba(208, 75, 136, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.92), transparent 18%),
    radial-gradient(circle at 78% 20%, rgba(255, 182, 213, 0.62), transparent 25%),
    radial-gradient(circle at 50% 88%, rgba(255, 225, 238, 0.78), transparent 32%),
    linear-gradient(135deg, #fff8fb 0%, #ffe6f0 46%, #ffd8e9 100%);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.kawaii-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.kawaii-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.42;
  background-image:
    radial-gradient(circle, rgba(255, 122, 177, 0.24) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 3px, transparent 4px);
  background-position: 0 0, 28px 28px;
  background-size: 56px 56px;
}

.float-shape {
  position: absolute;
  display: block;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.46);
  box-shadow: inset 0 0 0 1px rgba(255, 145, 192, 0.24), 0 20px 60px rgba(224, 86, 149, 0.16);
  animation: drift 10s ease-in-out infinite;
}

.shape-a {
  width: 190px;
  height: 190px;
  left: 7%;
  top: 13%;
}

.shape-b {
  width: 120px;
  height: 120px;
  right: 13%;
  top: 10%;
  animation-delay: -2s;
}

.shape-c {
  width: 160px;
  height: 160px;
  left: 17%;
  bottom: 9%;
  animation-delay: -4s;
}

.shape-d {
  width: 96px;
  height: 96px;
  right: 25%;
  bottom: 15%;
  animation-delay: -6s;
}

.login-shell {
  min-height: 100vh;
  padding: 28px;
}

.login-panel {
  min-height: calc(100vh - 48px);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: 28px;
  position: relative;
  overflow: hidden;
}

.login-panel::before,
.login-panel::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.login-panel::before {
  width: 320px;
  height: 320px;
  top: -145px;
  left: -90px;
  background: rgba(255, 170, 206, 0.32);
}

.login-panel::after {
  width: 260px;
  height: 260px;
  right: -70px;
  bottom: -110px;
  background: rgba(255, 255, 255, 0.58);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(32px, 6vw, 72px);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 22px;
  background: linear-gradient(135deg, #ff9ac7, #ff5aa4);
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  box-shadow: 0 16px 36px rgba(225, 74, 142, 0.28);
  transform: rotate(-5deg);
}

.login-panel .eyebrow,
.login-panel h1 {
  text-align: center;
}

.eyebrow {
  margin: 28px 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
  color: #3d2034;
  text-shadow: 0 8px 26px rgba(255, 129, 182, 0.2);
}

h2 {
  margin-bottom: 4px;
  font-size: 28px;
}

.intro {
  max-width: 36rem;
  margin-bottom: 34px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
  text-align: center;
}

.login-form {
  display: grid;
  gap: 18px;
  width: min(100%, 380px);
  position: relative;
  z-index: 1;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: #6f3d59;
  font-size: 13px;
  font-weight: 700;
}

.login-form input,
.assistant-form input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(218, 87, 145, 0.18);
  border-radius: 14px;
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
  padding: 0 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input:focus,
.assistant-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 111, 174, 0.18);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 50px;
}

.icon-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 12px;
  background: #fff0f6;
  color: #b84c82;
}

.form-options,
.check-row {
  display: flex;
  align-items: center;
}

.form-options {
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.check-row {
  gap: 8px;
}

.check-row input {
  width: 16px;
  min-height: auto;
  height: 16px;
  accent-color: var(--accent);
}

.primary-btn {
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 18px 38px rgba(229, 65, 141, 0.28);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 46px rgba(229, 65, 141, 0.34);
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: #067647;
}

.sso-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(100%, 380px);
  margin-top: 28px;
  position: relative;
  z-index: 1;
}

.sso-row button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
  color: #7e4565;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(218, 87, 145, 0.08);
}

.assistant-panel {
  --assistant-width: 300px;
  --assistant-height: 460px;
  --assistant-theme: #d94f93;
  --assistant-theme-soft: rgba(255, 246, 251, 0.94);
  --assistant-theme-border: rgba(255, 142, 190, 0.46);
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 30;
  width: var(--assistant-width);
  height: var(--assistant-height);
  min-width: 180px;
  min-height: 260px;
  background: transparent;
  border: 0;
  box-shadow: none;
  touch-action: none;
  user-select: none;
}

.assistant-panel.theme-berry {
  --assistant-theme: #d94f93;
  --assistant-theme-soft: rgba(255, 246, 251, 0.94);
  --assistant-theme-border: rgba(255, 142, 190, 0.46);
}

.assistant-panel.theme-mint {
  --assistant-theme: #18a999;
  --assistant-theme-soft: rgba(241, 255, 251, 0.94);
  --assistant-theme-border: rgba(76, 201, 176, 0.42);
}

.assistant-panel.theme-night {
  --assistant-theme: #7a4fb0;
  --assistant-theme-soft: rgba(248, 243, 255, 0.94);
  --assistant-theme-border: rgba(143, 104, 203, 0.42);
}

.assistant-panel.dragging,
.assistant-panel.resizing {
  transition: none;
}

.assistant-stage {
  position: absolute;
  inset: 78px 38px 0 0;
  display: grid;
  place-items: end center;
  overflow: visible;
  cursor: grab;
  touch-action: none;
}

.assistant-panel.dragging .assistant-stage {
  cursor: grabbing;
}

#live2dCanvas {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.assistant-costume {
  display: none;
}

.assistant-avatar {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(104px, 74%);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 30%, #fff8d6 0 8%, transparent 9%),
    linear-gradient(150deg, #f7d767 0 34%, #2456c8 35% 66%, #f7f0d0 67%);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.18);
  animation: floatAvatar 4s ease-in-out infinite;
}

.assistant-avatar.hidden {
  display: none;
}

.avatar-face {
  display: grid;
  grid-template-columns: 8px 8px;
  gap: 18px;
  align-items: center;
  justify-content: center;
  width: 66px;
  height: 48px;
  border-radius: 46% 46% 48% 48%;
  background:
    linear-gradient(180deg, rgba(255, 232, 128, 0.95) 0 24%, transparent 25%),
    rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 -10px 0 rgba(36, 86, 200, 0.12);
}

.avatar-face span {
  width: 7px;
  height: 10px;
  border-radius: 50%;
  background: #17202a;
}

.assistant-card {
  position: absolute;
  top: 0;
  left: 0;
  right: 38px;
  z-index: 3;
  display: grid;
  gap: 6px;
  min-height: 80px;
  border: 1px solid var(--assistant-theme-border);
  border-radius: 16px;
  background: var(--assistant-theme-soft);
  padding: 9px 12px;
  box-shadow: 0 12px 28px rgba(218, 87, 145, 0.16);
  user-select: text;
}

.assistant-card::after {
  content: "";
  position: absolute;
  right: 28px;
  bottom: -10px;
  width: 18px;
  height: 18px;
  border-right: 1px solid var(--assistant-theme-border);
  border-bottom: 1px solid var(--assistant-theme-border);
  background: var(--assistant-theme-soft);
  transform: rotate(45deg);
}

.assistant-head {
  position: absolute;
  top: 74px;
  right: -32px;
  display: grid;
  align-items: center;
  gap: 6px;
}

.assistant-actions {
  display: grid;
  align-items: center;
  gap: 4px;
}

.assistant-card h2 {
  display: none;
}

.assistant-actions button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  color: var(--assistant-theme);
  font-size: 17px;
  line-height: 1;
  box-shadow: 0 3px 10px rgba(218, 87, 145, 0.16);
}

#assistantCloseChat {
  display: none;
}

.assistant-status {
  margin: 0;
  color: #7a4261;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
}

.chat-log {
  display: none;
  gap: 6px;
  max-height: 120px;
  overflow: auto;
  padding-right: 4px;
}

.assistant-panel.chat-open {
  --assistant-width: max(320px, var(--assistant-current-width, 320px));
  --assistant-height: max(500px, var(--assistant-current-height, 500px));
}

.assistant-panel.chat-open .chat-log {
  display: grid;
}

.assistant-panel.chat-open .assistant-form {
  display: grid;
}

.assistant-panel.chat-open #assistantCloseChat {
  display: grid;
}

.assistant-settings {
  display: none;
  gap: 7px;
  max-height: 245px;
  overflow: auto;
  padding: 2px 2px 4px;
}

.assistant-panel.settings-open {
  --assistant-width: max(340px, var(--assistant-current-width, 340px));
  --assistant-height: max(560px, var(--assistant-current-height, 560px));
}

.assistant-panel.settings-open .assistant-settings {
  display: grid;
}

.assistant-settings label {
  display: grid;
  gap: 3px;
}

.assistant-settings span {
  color: #8f5471;
  font-size: 11px;
}

.assistant-settings input,
.assistant-settings select {
  min-height: 30px;
  width: 100%;
  border: 1px solid rgba(255, 142, 190, 0.36);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #6f3d58;
  font-size: 12px;
}

.assistant-settings input {
  padding: 0 8px;
}

.assistant-settings select {
  padding: 0 6px;
}

.assistant-settings .setting-check {
  grid-template-columns: 16px 1fr;
  align-items: center;
}

.assistant-settings .setting-check input {
  min-height: auto;
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.settings-actions button {
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--assistant-theme);
  font-size: 12px;
  font-weight: 700;
}

.chat-bubble {
  max-width: 100%;
  border-radius: 8px;
  padding: 6px 8px;
  color: #74415e;
  font-size: 12px;
  line-height: 1.45;
}

.chat-bubble.assistant {
  justify-self: start;
  background: rgba(255, 255, 255, 0.58);
}

.chat-bubble.user {
  justify-self: end;
  background: rgba(255, 221, 237, 0.76);
}

.assistant-form {
  display: none;
  grid-template-columns: 1fr 36px;
  gap: 6px;
}

.assistant-form input {
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
}

.assistant-form button {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: var(--assistant-theme);
  color: #fff;
  font-size: 20px;
}

.assistant-tip {
  display: none;
}

.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 6;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background:
    linear-gradient(135deg, transparent 0 45%, var(--assistant-theme) 46% 54%, transparent 55%),
    rgba(255, 255, 255, 0.72);
  box-shadow: 0 3px 10px rgba(218, 87, 145, 0.16);
  cursor: nwse-resize;
  touch-action: none;
}

.cursor-sparkle {
  position: fixed;
  z-index: 9999;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 14px rgba(255, 143, 189, 0.55);
  animation: sparkleTrail 760ms ease-out forwards;
}

@keyframes floatAvatar {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  50% {
    transform: translate3d(18px, -20px, 0) rotate(8deg);
  }
}

@keyframes sparkleTrail {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--spark-x)), calc(-50% + var(--spark-y))) scale(0.25);
  }
}

@media (max-width: 980px) {
  .login-shell {
    padding: 18px;
  }

  .login-panel {
    min-height: auto;
  }

  .assistant-panel {
    top: auto;
    right: 14px;
    bottom: 14px;
    --assistant-width: 260px;
    --assistant-height: 420px;
  }
}

@media (max-width: 560px) {
  .login-shell {
    padding: 0;
  }

  .login-panel {
    border: 0;
    box-shadow: none;
  }

  .login-panel {
    padding: 28px 20px;
  }

  .sso-row {
    grid-template-columns: 1fr;
  }

  .assistant-card {
    padding: 9px 12px;
  }
}
