/* ============================================================
   星云盘 · 设计系统（令牌 / 重置 / 通用组件）
   ============================================================ */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --brand: #6d8cff;
  --brand-2: #22d3ee;
  --brand-3: #a78bfa;
  --grad: linear-gradient(135deg, #6d8cff 0%, #22d3ee 100%);
  --grad-soft: linear-gradient(135deg, rgba(109,140,255,.16), rgba(34,211,238,.16));
  --danger: #ff6b81;
  --warn: #ffb454;
  --success: #3ddc97;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.18);
  --shadow-md: 0 12px 32px rgba(0,0,0,.28);
  --shadow-lg: 0 28px 70px rgba(0,0,0,.42);
  --ease: cubic-bezier(.22,.61,.36,1);
  --header-h: 62px;
}

html[data-theme="dark"] {
  --bg: #070b18;
  --bg-grad: radial-gradient(1100px 620px at 78% -10%, rgba(109,140,255,.20), transparent 62%),
             radial-gradient(900px 520px at 6% 4%, rgba(34,211,238,.13), transparent 58%);
  --surface: rgba(255,255,255,.045);
  --surface-2: rgba(255,255,255,.075);
  --surface-3: rgba(255,255,255,.11);
  --solid: #0d1426;
  --solid-2: #121a30;
  --border: rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.17);
  --text: #e9edf9;
  --text-2: #b9c2d8;
  --muted: #808da8;
  --hover: rgba(255,255,255,.055);
  --active: rgba(109,140,255,.16);
  --scrollbar: rgba(255,255,255,.14);
}

html[data-theme="light"] {
  --bg: #f4f6fc;
  --bg-grad: radial-gradient(1100px 620px at 80% -12%, rgba(109,140,255,.22), transparent 60%),
             radial-gradient(900px 520px at 2% 2%, rgba(34,211,238,.16), transparent 56%);
  --surface: #ffffff;
  --surface-2: #f7f9fe;
  --surface-3: #eef2fb;
  --solid: #ffffff;
  --solid-2: #f7f9fe;
  --border: rgba(16,21,39,.10);
  --border-strong: rgba(16,21,39,.20);
  --text: #0f1425;
  --text-2: #3d4761;
  --muted: #6b7794;
  --hover: rgba(16,21,39,.045);
  --active: rgba(109,140,255,.12);
  --scrollbar: rgba(16,21,39,.18);
  --shadow-sm: 0 2px 8px rgba(20,30,60,.08);
  --shadow-md: 0 12px 32px rgba(20,30,60,.10);
  --shadow-lg: 0 28px 70px rgba(20,30,60,.16);
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.app-root { min-height: 100%; display: flex; flex-direction: column; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; }

::selection { background: rgba(109,140,255,.35); }

/* ── 通用工具类 ─────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.center { display: flex; align-items: center; justify-content: center; }

/* ── 按钮 ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease), opacity .18s;
  user-select: none;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled], .btn.is-loading { opacity: .55; pointer-events: none; }
.btn-primary {
  background: var(--grad); border-color: transparent; color: #fff;
  box-shadow: 0 8px 22px -8px rgba(109,140,255,.85);
}
.btn-primary:hover { background: var(--grad); filter: brightness(1.07); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(255,107,129,.12); border-color: rgba(255,107,129,.4); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 15px; border-radius: 13px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }

.btn .spin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 表单 ───────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color .18s, box-shadow .18s, background .18s;
  font-size: 14px;
}
.textarea { height: auto; padding: 10px 13px; resize: vertical; min-height: 90px; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3.5px rgba(109,140,255,.18);
  background: var(--solid-2);
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 42px; }
.input-wrap .suffix {
  position: absolute; right: 6px;
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; color: var(--muted);
}
.input-wrap .suffix:hover { color: var(--text); background: var(--hover); }
.input-error { border-color: var(--danger) !important; }
.field-msg { font-size: 12px; color: var(--danger); min-height: 16px; }
.hint { font-size: 12px; color: var(--muted); }

.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.checkbox input { appearance: none; width: 17px; height: 17px; border-radius: 5px; border: 1.5px solid var(--border-strong); background: var(--surface-2); display: grid; place-items: center; transition: .15s; flex: none; }
.checkbox input:checked { background: var(--grad); border-color: transparent; }
.checkbox input:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translateY(-1px); }

/* ── 卡片 / 面板 ────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.panel { background: var(--solid); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-md); }

/* ── 徽标 / 标签 ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  white-space: nowrap;      /* 固定高度容器内折行会被裁切 */
  max-width: 100%;
}
.badge-brand { background: var(--grad-soft); border-color: rgba(109,140,255,.35); color: var(--brand); }
.badge-success { color: var(--success); border-color: rgba(61,220,151,.35); background: rgba(61,220,151,.1); }
.badge-danger { color: var(--danger); border-color: rgba(255,107,129,.35); background: rgba(255,107,129,.1); }
.badge-warn { color: var(--warn); border-color: rgba(255,180,84,.35); background: rgba(255,180,84,.1); }

/* ── 弹窗 ───────────────────────────────────────────────── */
.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(4,7,16,.62);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .18s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 460px; max-height: 88vh;
  background: var(--solid); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop .24s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.modal-lg { max-width: 640px; }
.modal-xl { max-width: 1040px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--border); }
.modal-close { margin-left: auto; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); }
.modal-close:hover { background: var(--hover); color: var(--text); }

/* ── Toast ──────────────────────────────────────────────── */
.toasts {
  position: fixed; z-index: 400; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  pointer-events: none; width: min(92vw, 420px);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: 13px;
  background: var(--solid); border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 13.5px; font-weight: 500;
  animation: toastIn .28s var(--ease);
  max-width: 100%;
}
.toast.out { animation: toastOut .24s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(.96); } }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; }
.toast.success .dot { background: var(--success); }
.toast.error .dot { background: var(--danger); }
.toast.warn .dot { background: var(--warn); }

/* ── 空状态 / 加载 ──────────────────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 70px 20px; text-align: center; color: var(--muted);
}
.empty .ico { width: 74px; height: 74px; border-radius: 24px; background: var(--grad-soft); display: grid; place-items: center; color: var(--brand); }
.empty h4 { color: var(--text); font-size: 15px; }
.empty p { font-size: 13px; max-width: 320px; }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--border-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; }

/* ── 进度条 ─────────────────────────────────────────────── */
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--grad); transition: width .25s var(--ease); }

/* ── 下拉菜单 ───────────────────────────────────────────── */
.menu {
  position: fixed; z-index: 300; min-width: 186px;
  background: var(--solid); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 6px; animation: pop .16s var(--ease);
  max-height: 70vh; overflow: auto;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 11px; border-radius: 9px;
  font-size: 13.5px; text-align: left; color: var(--text);
  transition: background .14s;
}
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: rgba(255,107,129,.12); }
.menu-item[disabled] { opacity: .45; pointer-events: none; }
.menu-sep { height: 1px; margin: 5px 8px; background: var(--border); }
.menu-label { padding: 8px 11px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ── 图标 ───────────────────────────────────────────────── */
.ico { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ico svg { width: 1em; height: 1em; display: block; }

/* ── 滚动区 ─────────────────────────────────────────────── */
.scroll-y { overflow-y: auto; overscroll-behavior: contain; }

/* ── 移动端 ─────────────────────────────────────────────── */
@media (max-width: 720px) {
  .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: 92vh; }
  .modal-mask { place-items: end center; padding: 0; }
  .toasts { top: 10px; }
}
