/* =========================================================================
   液态玻璃设计系统 · Liquid Glass Design System
   参考 Apple 的 Liquid Glass 视觉语言：半透明介质 + 背景模糊折射 +
   边缘高光 + 柔和内阴影 + 弹性动效。
   ========================================================================= */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --accent: #0a84ff;
  --accent-600: #0071e3;
  --accent-soft: rgba(10, 132, 255, 0.14);
  --violet: #5e5ce6;
  --pink: #ff375f;
  --success: #30d158;
  --warning: #ff9f0a;
  --danger: #ff453a;

  --text-1: #101114;
  --text-2: #4a4a52;
  --text-3: #83838d;

  --glass-bg: linear-gradient(150deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.34));
  --glass-bg-strong: linear-gradient(150deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.5));
  --glass-bg-subtle: rgba(255, 255, 255, 0.34);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-ring: rgba(255, 255, 255, 0.85);
  --glass-inset: rgba(255, 255, 255, 0.6);
  --glass-stroke: rgba(16, 17, 20, 0.08);

  --shadow-sm: 0 2px 10px rgba(20, 30, 60, 0.06);
  --shadow-md: 0 12px 32px rgba(20, 30, 60, 0.1);
  --shadow-lg: 0 24px 60px rgba(20, 30, 60, 0.16);

  --blur: 28px;
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 26px;
  --radius-xl: 34px;

  --ease-spring: cubic-bezier(0.34, 1.4, 0.42, 1);
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);

  --page-bg: #eaf0fa;
  --blob-1: rgba(120, 176, 255, 0.55);
  --blob-2: rgba(214, 168, 255, 0.5);
  --blob-3: rgba(255, 176, 214, 0.42);
  --blob-4: rgba(140, 240, 220, 0.4);
}

[data-theme="dark"] {
  --text-1: #f5f5f7;
  --text-2: #c4c4cc;
  --text-3: #8e8e98;

  --glass-bg: linear-gradient(150deg, rgba(56, 58, 70, 0.6), rgba(28, 29, 38, 0.42));
  --glass-bg-strong: linear-gradient(150deg, rgba(66, 68, 82, 0.78), rgba(32, 33, 44, 0.6));
  --glass-bg-subtle: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-ring: rgba(255, 255, 255, 0.3);
  --glass-inset: rgba(255, 255, 255, 0.14);
  --glass-stroke: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.55);

  --page-bg: #0b0c10;
  --blob-1: rgba(48, 108, 255, 0.5);
  --blob-2: rgba(122, 74, 226, 0.45);
  --blob-3: rgba(214, 62, 130, 0.36);
  --blob-4: rgba(28, 168, 152, 0.32);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  color: var(--text-1);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background 0.5s var(--ease-out), color 0.3s var(--ease-out);
}

a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(10, 132, 255, 0.25); }

/* ------------------------------ 极光背景层 ------------------------------ */

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

.aurora span {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.9;
  will-change: transform;
}

.aurora .b1 { width: 46vw; height: 46vw; background: radial-gradient(circle, var(--blob-1), transparent 68%); top: -12vw; left: -8vw; animation: drift1 22s ease-in-out infinite alternate; }
.aurora .b2 { width: 40vw; height: 40vw; background: radial-gradient(circle, var(--blob-2), transparent 68%); top: -6vw; right: -10vw; animation: drift2 26s ease-in-out infinite alternate; }
.aurora .b3 { width: 44vw; height: 44vw; background: radial-gradient(circle, var(--blob-3), transparent 70%); bottom: -16vw; left: 12vw; animation: drift3 30s ease-in-out infinite alternate; }
.aurora .b4 { width: 34vw; height: 34vw; background: radial-gradient(circle, var(--blob-4), transparent 70%); bottom: -10vw; right: 4vw; animation: drift4 24s ease-in-out infinite alternate; }

/* 细微噪点，避免大面积纯色渐变出现色带 */
.aurora::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.35;
  mix-blend-mode: overlay;
}

@keyframes drift1 { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(6vw, 5vh, 0) scale(1.12); } }
@keyframes drift2 { from { transform: translate3d(0,0,0) scale(1.06); } to { transform: translate3d(-5vw, 8vh, 0) scale(0.96); } }
@keyframes drift3 { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(7vw, -6vh, 0) scale(1.14); } }
@keyframes drift4 { from { transform: translate3d(0,0,0) scale(1.1); } to { transform: translate3d(-6vw, -4vh, 0) scale(1); } }

/* ------------------------------- 玻璃基元 ------------------------------- */

.glass {
  position: relative;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow:
    var(--shadow-md),
    inset 0 1px 1px var(--glass-ring),
    inset 0 -14px 30px -20px rgba(255, 255, 255, 0.5);
  overflow: hidden;
  isolation: isolate;
}

/* 顶部高光：模拟光线在玻璃上表面的镜面反射 */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 70% at 12% -10%, rgba(255, 255, 255, 0.65), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 34%);
  opacity: 0.9;
  pointer-events: none;
  z-index: 0;
}

/* 边缘描边：外描边亮、内倒角暗，形成"厚度感" */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.34),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
  pointer-events: none;
  z-index: 0;
}

.glass > * { position: relative; z-index: 1; }

.glass-strong {
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(36px) saturate(190%);
  backdrop-filter: blur(36px) saturate(190%);
}

.glass-subtle {
  background: var(--glass-bg-subtle);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

/* 可交互玻璃：悬浮抬升 + 光束扫过 */
.glass-interactive { transition: transform 0.4s var(--ease-spring), box-shadow 0.4s var(--ease-out); }
.glass-interactive:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg), inset 0 1px 1px var(--glass-ring); }
.glass-interactive:active { transform: translateY(-1px) scale(0.995); }

.sheen { position: relative; overflow: hidden; }
.sheen > .sheen-beam {
  position: absolute;
  top: -60%;
  left: -30%;
  width: 40%;
  height: 220%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: rotate(14deg) translateX(-140%);
  transition: transform 0.9s var(--ease-out);
  pointer-events: none;
  z-index: 2;
}
.sheen:hover > .sheen-beam { transform: rotate(14deg) translateX(420%); }

/* -------------------------------- 文字 --------------------------------- */

.h1 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 650; letter-spacing: -0.02em; }
.h2 { font-size: 20px; font-weight: 620; letter-spacing: -0.01em; }
.h3 { font-size: 16px; font-weight: 600; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.tiny { font-size: 12px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.text-gradient {
  background: linear-gradient(100deg, var(--accent), var(--violet) 55%, var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* -------------------------------- 按钮 --------------------------------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xs);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  backdrop-filter: blur(16px) saturate(170%);
  color: var(--text-1);
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.28s var(--ease-spring), box-shadow 0.3s var(--ease-out), filter 0.2s;
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-inset);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md), inset 0 1px 0 var(--glass-inset); }
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: grayscale(0.2); }

.btn-primary {
  border-color: rgba(255, 255, 255, 0.42);
  background: linear-gradient(180deg, #3d9dff, var(--accent-600));
  color: #fff;
  box-shadow: 0 10px 26px rgba(10, 132, 255, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.btn-primary:hover { box-shadow: 0 16px 34px rgba(10, 132, 255, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.6); }

.btn-ghost { background: var(--glass-bg-subtle); box-shadow: none; }
.btn-danger { border-color: rgba(255, 69, 58, 0.4); color: var(--danger); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13.5px; border-radius: 9px; }
.btn-icon { width: 42px; height: 42px; padding: 0; border-radius: 50%; }
.btn-block { width: 100%; }

.btn .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn.loading .btn-label { opacity: 0.85; }
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------- 表单 --------------------------------- */

.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 13.5px; font-weight: 550; color: var(--text-2); margin-bottom: 8px; }

.input-wrap { position: relative; display: flex; align-items: center; }

.input, input[type="text"].input, input[type="password"].input, input[type="email"].input, select.input, textarea.input {
  width: 100%;
  height: 50px;
  padding: 0 44px 0 44px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow: inset 0 1px 2px rgba(20, 30, 60, 0.06), inset 0 1px 0 var(--glass-inset);
  outline: none;
  font-size: 15.5px;
  transition: box-shadow 0.25s var(--ease-out), border-color 0.25s, background 0.25s;
}
.input::placeholder { color: var(--text-3); }
.input:focus {
  border-color: rgba(10, 132, 255, 0.55);
  box-shadow: 0 0 0 4px var(--accent-soft), inset 0 1px 2px rgba(20, 30, 60, 0.05);
}
.input.no-icon { padding-left: 16px; }
.input:disabled { opacity: 0.6; }

.input-icon {
  position: absolute; left: 15px; display: grid; place-items: center;
  width: 20px; height: 20px; color: var(--text-3); pointer-events: none;
}
.input-icon svg { width: 19px; height: 19px; }
.input-action {
  position: absolute; right: 8px; display: grid; place-items: center;
  width: 34px; height: 34px; border: none; border-radius: 9px;
  background: transparent; color: var(--text-3); cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.input-action:hover { background: var(--glass-bg-subtle); color: var(--text-1); }

.field-hint { font-size: 12.5px; color: var(--text-3); margin-top: 7px; min-height: 16px; }
.field-hint.error { color: var(--danger); }
.field-hint.success { color: var(--success); }

/* iOS 风格开关 */
.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(120, 120, 130, 0.32);
  border: 1px solid var(--glass-border);
  transition: background 0.3s var(--ease-out);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
}
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  transition: transform 0.32s var(--ease-spring);
}
.switch input:checked ~ .track { background: linear-gradient(180deg, #4fa3ff, var(--accent-600)); }
.switch input:checked ~ .knob { transform: translateX(20px); }

/* 复选 */
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { appearance: none; width: 20px; height: 20px; border-radius: 7px; border: 1px solid var(--glass-border); background: var(--glass-bg-strong); cursor: pointer; position: relative; transition: background 0.2s, box-shadow 0.2s; box-shadow: inset 0 1px 0 var(--glass-inset); }
.check input:checked { background: linear-gradient(180deg, #4fa3ff, var(--accent-600)); border-color: transparent; }
.check input:checked::after { content: ""; position: absolute; left: 6px; top: 2.5px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(42deg); }

/* -------------------------------- 徽标 --------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 550;
  background: var(--glass-bg-subtle);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--text-2);
}
.badge.ok { color: #14713a; background: rgba(48, 209, 88, 0.16); border-color: rgba(48, 209, 88, 0.3); }
.badge.warn { color: #8a5400; background: rgba(255, 159, 10, 0.16); border-color: rgba(255, 159, 10, 0.32); }
.badge.danger { color: #9b2018; background: rgba(255, 69, 58, 0.15); border-color: rgba(255, 69, 58, 0.3); }
.badge.info { color: #0b4f9e; background: var(--accent-soft); border-color: rgba(10, 132, 255, 0.28); }
[data-theme="dark"] .badge.ok { color: #7ff0a4; }
[data-theme="dark"] .badge.warn { color: #ffce7a; }
[data-theme="dark"] .badge.danger { color: #ff9d95; }
[data-theme="dark"] .badge.info { color: #8ec5ff; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.22); }

/* -------------------------------- 提示 --------------------------------- */

.toast-host {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  z-index: 999; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 20px; border-radius: 999px;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  backdrop-filter: blur(24px) saturate(190%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg), inset 0 1px 0 var(--glass-inset);
  font-size: 14.5px; font-weight: 500; max-width: min(88vw, 460px);
  animation: toastIn 0.45s var(--ease-spring);
}
.toast.out { animation: toastOut 0.3s var(--ease-out) forwards; }
.toast .ico { width: 20px; height: 20px; flex: none; display: grid; place-items: center; }
.toast.ok .ico { color: var(--success); }
.toast.err .ico { color: var(--danger); }
.toast.info .ico { color: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(22px) scale(0.94); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(14px) scale(0.96); } }

/* ------------------------------ 提示条 --------------------------------- */

/* 通用说明条（登录页演示账号、离线引导等共用） */
.demo-hint {
  margin-top: 18px; padding: 13px 16px; border-radius: var(--radius-xs);
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; color: var(--text-2); line-height: 1.6;
  background: var(--glass-bg-subtle);
  border: 1px dashed var(--glass-border);
}
.demo-hint b { color: var(--text-1); font-family: var(--font-mono); font-size: 12.5px; }
.demo-hint .ico { color: var(--accent); flex: none; margin-top: 1px; }
.demo-hint a { font-weight: 600; }

/* 服务未启动 / 打开方式不对时的醒目提示 */
.service-warn {
  display: block;
  border: 1px solid rgba(255, 69, 58, 0.45);
  background: rgba(255, 69, 58, 0.09);
  color: #a3241c;
}
.service-warn .ico { color: var(--danger); }
.service-warn b { color: inherit; font-family: var(--font-sans); font-size: 13px; }
.service-warn a { color: inherit; text-decoration: underline; }
[data-theme="dark"] .service-warn { color: #ff9d95; }

/* ------------------------------- 加载态 -------------------------------- */

.skeleton {
  position: relative; overflow: hidden; border-radius: 10px;
  background: rgba(140, 150, 175, 0.16); color: transparent;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  transform: translateX(-100%); animation: shimmer 1.5s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.spinner-lg {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(140, 150, 175, 0.28); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.empty {
  display: grid; place-items: center; gap: 10px;
  padding: 46px 20px; text-align: center; color: var(--text-3);
}
.empty .emoji { font-size: 34px; filter: saturate(0.9); }

/* -------------------------------- 表格 --------------------------------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.glass-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.glass-table th {
  text-align: left; font-weight: 600; font-size: 12.5px; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--text-3);
  padding: 12px 16px; background: var(--glass-bg-subtle);
  border-bottom: 1px solid var(--glass-stroke);
  position: sticky; top: 0; backdrop-filter: blur(12px);
}
table.glass-table td { padding: 14px 16px; border-bottom: 1px solid var(--glass-stroke); color: var(--text-2); }
table.glass-table tbody tr { transition: background 0.22s var(--ease-out); }
table.glass-table tbody tr:hover { background: var(--glass-bg-subtle); }
table.glass-table tbody tr:last-child td { border-bottom: none; }
table.glass-table td:first-child, table.glass-table th:first-child { padding-left: 20px; }
table.glass-table td:last-child, table.glass-table th:last-child { padding-right: 20px; }

/* ------------------------------- 头像 ---------------------------------- */

.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 620; color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--violet));
  box-shadow: 0 6px 16px rgba(10, 132, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  letter-spacing: 0.02em;
}
.avatar.lg { width: 54px; height: 54px; font-size: 19px; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }

/* ------------------------------- 工具类 -------------------------------- */

.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1 1 auto; min-width: 0; }
.wrap { flex-wrap: wrap; }
.gap-6 { gap: 6px; } .gap-10 { gap: 10px; } .gap-14 { gap: 14px; } .gap-20 { gap: 20px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.center { text-align: center; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(130, 140, 165, 0.34); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(130, 140, 165, 0.55); background-clip: content-box; }

/* 无障碍与偏好 */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 640px) {
  :root { --radius-lg: 22px; --radius-xl: 26px; }
  .toast-host { bottom: 20px; }
}
