/* ───────── Liquid Glass 设计系统 ───────── */
:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro SC", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  --text: #1d1d1f;
  --text-2: rgba(29, 29, 31, .62);
  --text-3: rgba(29, 29, 31, .4);
  --accent: #007aff;
  --danger: #ff3b30;
  --bg-base: #e8eefa;

  --glass-tint: rgba(255, 255, 255, .24);
  --glass-tint-strong: rgba(255, 255, 255, .62);
  --glass-rim: rgba(255, 255, 255, .9);
  --glass-rim-low: rgba(255, 255, 255, .22);
  --glass-sheen: rgba(255, 255, 255, .45);
  --glass-shadow: 0 18px 50px -14px rgba(28, 40, 90, .28), 0 2px 8px rgba(28, 40, 90, .07);
  --card-tint: rgba(255, 255, 255, .38);
  --thumb: rgba(255, 255, 255, .92);
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .2);
  --sep: rgba(60, 60, 67, .12);

  --blur: 28px;
  --r-xl: 30px;
  --r-lg: 20px;
  --r-md: 14px;
  --ease: cubic-bezier(.32, .72, 0, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #f5f5f7;
    --text-2: rgba(245, 245, 247, .64);
    --text-3: rgba(245, 245, 247, .38);
    --accent: #0a84ff;
    --danger: #ff453a;
    --bg-base: #090b14;

    --glass-tint: rgba(30, 32, 44, .34);
    --glass-tint-strong: rgba(52, 54, 68, .72);
    --glass-rim: rgba(255, 255, 255, .42);
    --glass-rim-low: rgba(255, 255, 255, .06);
    --glass-sheen: rgba(255, 255, 255, .12);
    --glass-shadow: 0 20px 60px -14px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .35);
    --card-tint: rgba(40, 42, 56, .42);
    --thumb: rgba(255, 255, 255, .2);
    --fill: rgba(118, 118, 128, .24);
    --fill-2: rgba(118, 118, 128, .34);
    --sep: rgba(84, 84, 88, .42);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ───────── 动态背景：给玻璃提供可折射的色彩 ───────── */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(155deg, #dce8ff 0%, #f3e6ff 42%, #ffe8dc 100%);
}
.bg::after { /* 细点阵：让折射与模糊更有层次 */
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .55) 1px, transparent 1.4px);
  background-size: 22px 22px;
  opacity: .5;
}
.blob {
  position: absolute;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  opacity: .8;
  will-change: transform;
  animation: drift 28s ease-in-out infinite alternate;
}
.b1 { background: radial-gradient(circle, #4f9dff 0%, rgba(79, 157, 255, 0) 64%); top: -24vmax; left: -18vmax; }
.b2 { background: radial-gradient(circle, #c56bff 0%, rgba(197, 107, 255, 0) 64%); top: -14vmax; right: -24vmax; animation-duration: 34s; }
.b3 { background: radial-gradient(circle, #ff8a5c 0%, rgba(255, 138, 92, 0) 64%); bottom: -30vmax; left: 8vmax; animation-duration: 31s; animation-delay: -8s; }
.b4 { background: radial-gradient(circle, #2ee6b4 0%, rgba(46, 230, 180, 0) 64%); bottom: -26vmax; right: -14vmax; animation-duration: 38s; animation-delay: -14s; }
.b5 { background: radial-gradient(circle, #ffd25e 0%, rgba(255, 210, 94, 0) 62%); width: 38vmax; height: 38vmax; top: 30%; left: 40%; animation-duration: 25s; animation-delay: -4s; }

@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(7vmax, 4vmax, 0) scale(1.12); }
  100% { transform: translate3d(-5vmax, 9vmax, 0) scale(.94); }
}

@media (prefers-color-scheme: dark) {
  .bg { background: linear-gradient(155deg, #0a1030 0%, #170a2a 48%, #24101a 100%); }
  .bg::after { opacity: .08; }
  .blob { opacity: .5; }
}

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ───────── 玻璃材质 ───────── */
.glass {
  position: relative;
  isolation: isolate;
  background: var(--glass-tint);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(190%);
  backdrop-filter: blur(var(--blur)) saturate(190%);
  border-radius: var(--r-xl);
  box-shadow: var(--glass-shadow),
    inset 0 1px 1px var(--glass-rim-low),
    inset 0 -1px 1px var(--glass-rim-low);
}
/* 高光描边：左上与右下的镜面边缘 */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  padding: 1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(140deg, var(--glass-rim) 0%, transparent 26%, transparent 64%, var(--glass-rim) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
/* 表面光泽 */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(130% 80% at 8% -12%, var(--glass-sheen), transparent 46%),
    radial-gradient(90% 60% at 110% 118%, var(--glass-rim-low), transparent 60%);
}
/* Chromium：叠加 SVG 位移滤镜，模拟液态玻璃的边缘折射 */
.refract .glass.lens {
  -webkit-backdrop-filter: url(#lg-refract) blur(var(--blur)) saturate(190%);
  backdrop-filter: url(#lg-refract) blur(var(--blur)) saturate(190%);
}

/* ───────── 按钮 ───────── */
.btn {
  appearance: none;
  border: 0;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: var(--fill);
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--glass-rim-low);
  transition: transform .4s var(--spring), background .2s, box-shadow .2s, opacity .2s;
  white-space: nowrap;
}
.btn:hover { background: var(--fill-2); }
.btn:active { transform: scale(.94); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary {
  color: #fff;
  background: linear-gradient(180deg, #3a95ff 0%, #0a6cff 100%);
  box-shadow: 0 8px 22px -8px rgba(0, 110, 255, .75),
    inset 0 1px 0 rgba(255, 255, 255, .5),
    inset 0 -1px 0 rgba(0, 0, 0, .12);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); background: rgba(255, 59, 48, .12); }
.btn.danger:hover { background: rgba(255, 59, 48, .2); }
.btn.sm { height: 34px; padding: 0 14px; font-size: 14px; }

.icon-btn {
  appearance: none;
  border: 0;
  width: 36px;
  height: 36px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-2);
  background: transparent;
  cursor: pointer;
  transition: transform .4s var(--spring), background .2s, color .2s;
}
.icon-btn:hover { background: var(--fill); color: var(--text); }
.icon-btn:active { transform: scale(.88); }
.icon-btn.sm { width: 28px; height: 28px; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; stroke: none; }
.icon-btn.sm svg { width: 16px; height: 16px; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* ───────── 输入框 ───────── */
.field {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-md);
  font-size: 16px;
  background: var(--fill);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .05);
  transition: box-shadow .25s, background .25s;
}
.field::placeholder { color: var(--text-3); }
.field:focus {
  background: var(--glass-tint-strong);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent);
}
textarea.field { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
select.field { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* ───────── 分段控件（滑动玻璃滑块） ───────── */
.segmented {
  --x: 0px;
  --w: 0px;
  position: relative;
  display: inline-flex;
  flex: none;
  padding: 3px;
  border-radius: 999px;
  background: var(--fill);
}
.segmented .thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: var(--w);
  transform: translateX(var(--x));
  border-radius: 999px;
  background: var(--thumb);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .12), inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 0 0 .5px rgba(255, 255, 255, .5);
  transition: transform .55s var(--spring), width .55s var(--spring);
}
.segmented > button {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 0;
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: color .25s;
}
.segmented > button[aria-pressed="true"] { color: var(--text); }
.segmented.wide { display: flex; }
.segmented.wide > button { flex: 1; }

/* ───────── 提示 ───────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 20px;
  min-height: 48px;
  border-radius: 999px;
  font-weight: 500;
  transform: translate(-50%, 160%);
  transition: transform .55s var(--spring);
  --glass-tint: var(--glass-tint-strong);
}
.toast.show { transform: translate(-50%, 0); }
.toast:not(:has(.btn)) { padding-right: 20px; }

/* ───────── 登录页 ───────── */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow: auto;
}
.login-box { width: min(380px, 100%); }
.login-card {
  width: 100%;
  padding: 38px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  animation: rise .8s var(--spring) both;
}
.app-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 6px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, #64d2ff 0%, #0a7aff 55%, #5e5ce6 100%);
  box-shadow: 0 14px 30px -10px rgba(10, 122, 255, .7), inset 0 1px 0 rgba(255, 255, 255, .65), inset 0 -2px 6px rgba(0, 0, 0, .12);
}
.app-icon svg { width: 40px; height: 40px; stroke-width: 2.4; }
.login-card h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.login-card p { margin: 0 0 8px; color: var(--text-2); }
.code-input { height: 54px; text-align: center; font-size: 20px; letter-spacing: .28em; }
.code-input::placeholder { letter-spacing: normal; font-size: 16px; }
.login-card .btn { height: 50px; font-size: 16px; }
.login-card .login-error { min-height: 20px; margin: 0; font-size: 13px; color: var(--danger); }
.login-foot { margin-top: 18px; font-size: 12px; color: var(--text-3); text-align: center; }

.shake { animation: shake .5s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.96); } }

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