/* ============ 全局主题：深色科技风 ============ */
:root {
  /* 声明深色配色方案：让浏览器原生控件（输入框、下拉、滚动条）走深色渲染，
     避免在浅色系统主题下输入框被渲染成白底 */
  color-scheme: dark;

  --bg: #050a16;
  --bg-2: #071022;
  --panel: rgba(14, 24, 44, 0.72);
  --panel-solid: #0d1729;
  --panel-hover: rgba(24, 40, 70, 0.85);
  --border: rgba(90, 140, 220, 0.18);
  --border-strong: rgba(100, 170, 255, 0.35);

  --text: #e6efff;
  --text-dim: #8ea3c4;
  --text-mute: #5f7595;

  --accent: #22d3ee;
  --accent-2: #8b5cf6;
  --accent-3: #38bdf8;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --purple: #a78bfa;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --glow: 0 0 24px rgba(34, 211, 238, 0.35);
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow-x: hidden;
}

/* 背景层：网格 + 光斑 */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(34, 211, 238, 0.16), transparent 60%),
    radial-gradient(900px 560px at 92% 8%, rgba(139, 92, 246, 0.16), transparent 62%),
    radial-gradient(800px 600px at 50% 110%, rgba(56, 189, 248, 0.10), transparent 60%),
    linear-gradient(180deg, #050a16 0%, #060d1d 55%, #040711 100%);
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(90, 150, 230, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 150, 230, 0.055) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 78%);
}

#bgCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ============ 通用组件 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.16), rgba(56, 189, 248, 0.05));
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn:hover {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.28), rgba(56, 189, 248, 0.10));
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.28);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary {
  border-color: rgba(34, 211, 238, 0.55);
  background: linear-gradient(135deg, #22d3ee 0%, #6366f1 100%);
  color: #04121f;
  font-weight: 600;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #38e0f5 0%, #7c7ff5 100%);
  box-shadow: 0 0 22px rgba(34, 211, 238, 0.45);
}

.btn-danger {
  border-color: rgba(248, 113, 113, 0.45);
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.18), rgba(248, 113, 113, 0.05));
  color: #fecaca;
}
.btn-danger:hover {
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.28), rgba(248, 113, 113, 0.1));
  box-shadow: 0 0 18px rgba(248, 113, 113, 0.3);
}

.btn-ghost {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }

.btn-sm { height: 28px; padding: 0 11px; font-size: 12px; border-radius: 7px; }

.input, .select {
  height: 36px;
  width: 100%;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #0a1526;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: all 0.18s ease;
}
.input::placeholder { color: var(--text-mute); }
.input:focus, .select:focus {
  border-color: rgba(34, 211, 238, 0.6);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
  background: #0d1b30;
}

/* 搜索框：去掉浏览器自带的搜索装饰与清除按钮 */
.input[type="search"]::-webkit-search-decoration,
.input[type="search"]::-webkit-search-cancel-button,
.input[type="search"]::-webkit-search-results-button,
.input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
}

/* 浏览器自动填充会把输入框强制刷成浅色（白底黑字），这里强行压回深色 */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active,
textarea.input:-webkit-autofill {
  -webkit-text-fill-color: #e6efff !important;
  -webkit-box-shadow: 0 0 0 1000px #0a1526 inset !important;
  box-shadow: 0 0 0 1000px #0a1526 inset !important;
  caret-color: #e6efff;
  transition: background-color 999999s ease-in-out 0s;
}
/* 自动填充发生的瞬间会触发这个动画，JS 用它来感知并清掉被误填的内容 */
@keyframes onAutoFillStart { from { opacity: 1; } to { opacity: 1; } }
.input:-webkit-autofill { animation-name: onAutoFillStart; animation-duration: 0.001s; }
.select { cursor: pointer; appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select option { background: #0b1526; color: var(--text); }

textarea.input { height: auto; padding: 8px 12px; resize: vertical; min-height: 62px; line-height: 1.5; }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(90, 140, 220, 0.28); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(90, 140, 220, 0.45); }

/* 徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 18px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.badge-signed   { color: #34d399; background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.32); }
.badge-signing  { color: #fbbf24; background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.32); }
.badge-unsigned { color: #94a3b8; background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.28); }
.badge-ended    { color: #f87171; background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.32); }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulseGlow { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

/* 通用 toast */
.toast-wrap {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 13px;
  background: rgba(13, 23, 41, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: fadeUp 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.ok { border-color: rgba(52, 211, 153, 0.5); color: #a7f3d0; }
.toast.err { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }
