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

:root {
  --bg: #0f1117;
  --bg2: #1a1d2e;
  --bg3: #242840;
  --accent: #5c7cfa;
  --accent2: #748ffc;
  --danger: #ff6b6b;
  --success: #69db7c;
  --warn: #ffd43b;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --border: #2d3250;
  --radius: 10px;
}

body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', sans-serif; min-height: 100vh; }

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ---- 导航栏 ---- */
nav {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}
nav .logo { font-size: 1.2rem; font-weight: 700; color: var(--accent2); letter-spacing: 1px; }
nav .nav-links { display: flex; gap: 16px; flex: 1; }
nav .nav-links a { color: var(--text2); font-size: 0.95rem; padding: 4px 0; border-bottom: 2px solid transparent; transition: all .2s; }
nav .nav-links a.active, nav .nav-links a:hover { color: var(--text); border-bottom-color: var(--accent); }
nav .user-info { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; color: var(--text2); }
nav .user-info .badge { background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 0.8rem; }
nav .user-info .badge.admin { color: var(--warn); border-color: var(--warn); }

/* ---- 布局容器 ---- */
.page { display: none; padding: 32px 24px; max-width: 1100px; margin: 0 auto; }
.page.active { display: block; }

/* ---- 卡片 ---- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 1.1rem; margin-bottom: 16px; color: var(--text); }
.card h3 { font-size: 1rem; margin-bottom: 12px; color: var(--text2); }

/* ---- 登录页 ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #1e2647 0%, var(--bg) 70%);
}
.auth-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 380px;
}
.auth-box .logo { text-align: center; font-size: 1.5rem; font-weight: 700; color: var(--accent2); margin-bottom: 8px; }
.auth-box .subtitle { text-align: center; color: var(--text2); font-size: 0.9rem; margin-bottom: 28px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.auth-tabs button { flex: 1; padding: 10px; background: transparent; border: none; color: var(--text2); cursor: pointer; font-size: 0.95rem; transition: all .2s; }
.auth-tabs button.active { background: var(--accent); color: #fff; }

/* ---- 表单 ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text2); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.form-group select option { background: var(--bg2); }

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-success { background: var(--success); color: #111; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text2); }
.btn-outline:hover { border-color: var(--accent); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-full { width: 100%; }

/* ---- 表格 ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { background: var(--bg3); color: var(--text2); font-weight: 600; padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg3); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.78rem; font-weight: 600; }
.tag-admin { background: #3d2b00; color: var(--warn); }
.tag-sponsor, .badge.sponsor { background: #30204d; color: #e1b4ff; border: 1px solid rgba(225,180,255,.35); box-shadow: 0 0 14px rgba(195,120,255,.2); }
.tag-user { background: #1a2744; color: var(--accent2); }
.tag-banned { background: #3d0000; color: var(--danger); }
.tag-p2p { background: #1a3d2b; color: var(--success); }
.tag-frp { background: #3d1a1a; color: var(--danger); }
.tag-on { background: #1a3d2b; color: var(--success); }
.tag-off { background: #2d2d2d; color: var(--text2); }

/* ---- 统计卡片 ---- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; }
.stat-card .num { font-size: 2rem; font-weight: 700; color: var(--accent2); }
.stat-card .lbl { font-size: 0.85rem; color: var(--text2); margin-top: 4px; }

/* ---- 工具栏 ---- */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; color: var(--text); font-size: 0.9rem; outline: none; min-width: 200px; }
.toolbar input:focus { border-color: var(--accent); }

/* ---- 模态框 ---- */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 440px;
  max-width: 95vw;
}
.modal h3 { font-size: 1.1rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---- 提示 ---- */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.9rem;
  animation: fadein .3s ease;
  min-width: 240px;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.warn { border-color: var(--warn); color: var(--warn); }
@keyframes fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }

/* ---- 分页 ---- */
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.pagination button { background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text2); padding: 6px 14px; cursor: pointer; }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:hover:not(.active) { border-color: var(--accent2); }

@media (max-width: 600px) {
  .auth-box { padding: 24px 16px; width: 95vw; }
  nav { padding: 0 12px; gap: 12px; }
  .page { padding: 16px 12px; }
}

/* ============ 动画 & 玻璃质感美化 ============ */

/* ---- 通用动画关键帧 ---- */
@keyframes floatIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes rippleOut {
  from { transform: scale(0); opacity: .5; }
  to   { transform: scale(2.4); opacity: 0; }
}

/* ---- 液态玻璃质感：导航栏 ---- */
nav {
  background: rgba(26, 29, 46, .72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* ---- 卡片：玻璃质感 + 淡入上浮 + 悬浮提升 ---- */
.card {
  background: rgba(26, 29, 46, .68);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  animation: floatIn .45s ease both;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  border-color: var(--accent);
}

/* ---- 统计卡片：玻璃质感 + 悬浮 ---- */
.stat-card {
  background: rgba(26, 29, 46, .68);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  animation: floatIn .45s ease both;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(92, 124, 250, .18);
  border-color: var(--accent);
}

/* ---- 按钮：悬浮提升 + 点击缩放 + 涟漪 ---- */
.btn {
  position: relative;
  overflow: hidden;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.95); }
/* 涟漪元素（由 JS 动态插入） */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .45);
  pointer-events: none;
  transform: scale(0);
  animation: rippleOut .55s ease-out;
}

/* ---- 登录框：玻璃质感 + 淡入 ---- */
.auth-box {
  background: rgba(26, 29, 46, .72);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  animation: scaleIn .4s ease both;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

/* ---- 页面切换淡入 ---- */
.page.active { animation: floatIn .4s ease both; }
/* admin tab 切换淡入 */
#at-overview:not(.hidden),
#at-users:not(.hidden),
#at-nodes:not(.hidden),
#at-rooms:not(.hidden),
#at-settings:not(.hidden) { animation: floatIn .35s ease both; }

/* ---- 模态框：背景淡入 + 弹窗缩放浮现 ---- */
.modal-backdrop.open { animation: fadein .25s ease; }
.modal { animation: scaleIn .3s ease both; }

/* ============ 宣传页 Landing ============ */
.landing {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(92, 124, 250, .22) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(116, 143, 252, .18) 0%, transparent 50%),
    var(--bg);
  overflow-x: hidden;
}
.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  max-width: 1200px;
  margin: 0 auto;
}
.landing-nav .logo { font-size: 1.4rem; font-weight: 800; color: var(--accent2); letter-spacing: 1px; }

.landing-hero {
  max-width: 900px;
  margin: 0 auto;
  padding: 70px 24px 40px;
  text-align: center;
  animation: floatIn .6s ease both;
}
.landing-hero h1 {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 20px;
  background: linear-gradient(120deg, var(--text) 20%, var(--accent2) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.landing-hero .lead {
  font-size: 1.15rem;
  color: var(--text2);
  max-width: 640px;
  margin: 0 auto 32px;
  line-height: 1.8;
}
.landing-hero .hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.btn-lg { padding: 14px 32px; font-size: 1.05rem; border-radius: 10px; }

/* ---- 特性亮点 ---- */
.landing-features {
  max-width: 1000px;
  margin: 20px auto 60px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.feature-card {
  background: rgba(26, 29, 46, .6);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  animation: floatIn .5s ease both;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 34px rgba(92, 124, 250, .2);
  border-color: var(--accent);
}
.feature-card .ico { font-size: 2rem; margin-bottom: 12px; }
.feature-card h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }
.feature-card p { font-size: .92rem; color: var(--text2); line-height: 1.7; }

.landing-footer { text-align: center; color: var(--text2); font-size: .85rem; padding: 30px 24px 40px; }

@media (max-width: 600px) {
  .landing-nav { padding: 14px 16px; }
  .landing-hero { padding: 48px 16px 30px; }
  .landing-hero h1 { font-size: 2.1rem; }
}

/* ============ 尊重系统「减少动画」偏好 ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .btn:hover, .card:hover, .stat-card:hover, .feature-card:hover { transform: none; }
  .btn .ripple { display: none; }
}

/* ============ 浅色主题（[data-theme="light"]，通过设置切换）============ */
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --bg2: #ffffff;
  --bg3: #eef1f8;
  --accent: #4263eb;
  --accent2: #3b5bdb;
  --danger: #e03131;
  --success: #2f9e44;
  --warn: #f08c00;
  --text: #1f2937;
  --text2: #64748b;
  --border: #d8def0;
}
/* 浅色主题下的玻璃质感底色调整（覆盖深色的半透明底） */
:root[data-theme="light"] nav,
:root[data-theme="light"] .card,
:root[data-theme="light"] .stat-card,
:root[data-theme="light"] .auth-box,
:root[data-theme="light"] .feature-card {
  background: rgba(255, 255, 255, .72);
}
:root[data-theme="light"] .btn .ripple { background: rgba(66, 99, 235, .28); }
:root[data-theme="light"] .cursor-trail { background: rgba(66, 99, 235, .55); }

/* ============ 鼠标轨迹拖尾 ============ */
.cursor-trail {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(116, 143, 252, .6);
  box-shadow: 0 0 10px rgba(116, 143, 252, .8);
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 9999;
  animation: trailFade .7s ease-out forwards;
}
@keyframes trailFade {
  from { opacity: .8; transform: translate(-50%, -50%) scale(1); }
  to   { opacity: 0;  transform: translate(-50%, -50%) scale(.2); }
}

/* ============ 动画性能档位（<html> 上的 anim-* class 控制）============ */
/* 关闭档：移除所有动画、过渡、悬浮位移与拖尾 */
:root.anim-off *, :root.anim-off *::before, :root.anim-off *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}
:root.anim-off .btn:hover,
:root.anim-off .card:hover,
:root.anim-off .stat-card:hover,
:root.anim-off .feature-card:hover { transform: none; }
:root.anim-off .btn .ripple,
:root.anim-off .cursor-trail { display: none; }

/* 低档：仅保留基础过渡，去掉玻璃模糊与入场动画、拖尾 */
:root.anim-low nav,
:root.anim-low .card,
:root.anim-low .stat-card,
:root.anim-low .auth-box,
:root.anim-low .feature-card,
:root.anim-low .modal-backdrop {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
:root.anim-low .card,
:root.anim-low .stat-card,
:root.anim-low .feature-card,
:root.anim-low .page.active,
:root.anim-low .auth-box,
:root.anim-low .modal { animation: none !important; }
:root.anim-low .cursor-trail { display: none; }

/* 中档：弱化模糊强度，保留入场过渡；拖尾在 JS 中已限定仅高档 */
:root.anim-medium nav { backdrop-filter: blur(6px) saturate(120%); -webkit-backdrop-filter: blur(6px) saturate(120%); }
:root.anim-medium .card,
:root.anim-medium .stat-card,
:root.anim-medium .auth-box,
:root.anim-medium .feature-card {
  backdrop-filter: blur(5px) saturate(115%);
  -webkit-backdrop-filter: blur(5px) saturate(115%);
}
