:root {
  --bg: #060913;
  --bg-2: #0b1126;
  --surface: rgba(18, 24, 46, 0.55);
  --surface-2: rgba(26, 34, 64, 0.5);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eaf0fc;
  --text-dim: #9aa5c4;
  --teal: #5fd0c0;
  --teal-2: #7fe0ff;
  --violet: #a48bff;
  --pink: #ff8fb1;
  --danger: #ff7b8a;
  --gold: #f6d99b;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 700px at 15% -10%, #1b2a5e 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 15%, #3a1f5e 0%, transparent 50%),
    radial-gradient(900px 600px at 50% 120%, #0f3550 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

/* 星空 + 极光 */
#stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.aurora {
  position: fixed; inset: -20%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 30% at 20% 30%, rgba(95, 208, 192, 0.14), transparent 70%),
    radial-gradient(40% 30% at 80% 20%, rgba(164, 139, 255, 0.14), transparent 70%),
    radial-gradient(45% 35% at 60% 80%, rgba(255, 143, 177, 0.1), transparent 70%);
  filter: blur(30px);
  animation: aurora 18s var(--ease) infinite alternate;
}
@keyframes aurora {
  0% { transform: translate3d(-2%, -1%, 0) rotate(0.001deg); opacity: 0.8; }
  100% { transform: translate3d(2%, 2%, 0) rotate(0.001deg); opacity: 1; }
}

.hidden, [hidden] { display: none !important; }
.btn { text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.assistant-intro { display: flex; align-items: center; gap: 20px; padding: 12px 0 20px; }
.assistant-intro h2 { margin: 0; font-size: clamp(24px, 4vw, 34px); }
.assistant-intro p { margin: 4px 0; }
.assistant-kicker { color: var(--teal); letter-spacing: .16em; font-size: 11px; }
.assistant-orbit { display: grid; place-items: center; flex: none; width: 78px; height: 78px; border: 1px solid var(--border-strong); border-radius: 50%; font-size: 42px; color: var(--teal); background: radial-gradient(circle, #234c58, #11172d); box-shadow: 0 0 28px #5fd0c01a; }
.assistant-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.assistant-panel { padding: 20px; border: 1px solid var(--border); background: #0a102480; border-radius: 14px; margin-bottom: 18px; min-width: 0; }
.assistant-panel h3 { margin-top: 0; font-size: 16px; }
.assistant-panel .field { margin-bottom: 16px; }
.assistant-search { display: flex; gap: 8px; }
.assistant-search input { min-width: 0; }
.assistant-search .btn { flex: none; white-space: nowrap; }
.assistant-records { max-height: 390px; overflow-y: auto; }
.assistant-record, .assistant-check { display: flex; align-items: start; gap: 12px; padding: 12px 0; cursor: pointer; }
.assistant-record { border-top: 1px solid var(--border); }
.assistant-record input, .assistant-check input { width: auto; flex: none; margin-top: 6px; accent-color: var(--teal); }
.assistant-record strong, .assistant-record small, .assistant-snippet { display: block; }
.assistant-record small, .assistant-snippet { color: var(--text-dim); font-size: 12px; }
.assistant-payload { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 380px; overflow: auto; background: #050914; padding: 14px; border-radius: 10px; font: 13px/1.7 monospace; }
#ai-provider { overflow-wrap: anywhere; }
@media (max-width: 820px) { .assistant-grid { grid-template-columns: 1fr; } .assistant-orbit { width: 52px; height: 52px; font-size: 28px; } }
.muted { color: var(--text-dim); }

/* 通用卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}

/* ---------- 登录 ---------- */
.login-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px; padding: 44px 40px 32px;
  text-align: center;
  animation: rise 0.7s var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.login-mark {
  width: 64px; height: 64px; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #04171a;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--teal-2) 55%, var(--violet));
  box-shadow: 0 0 0 6px rgba(95, 208, 192, 0.12), 0 12px 30px rgba(95, 208, 192, 0.28);
}
.login-title {
  margin: 0; font-size: 30px; letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--teal), var(--teal-2), var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub { margin: 6px 0 26px; color: var(--text-dim); font-size: 14px; }

.password-wrap { position: relative; margin-bottom: 14px; }
.password-wrap input { padding-right: 46px; }
.pwd-toggle {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; border-radius: 10px;
  background: transparent; color: var(--text-dim); cursor: pointer;
}
.pwd-toggle:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.login-hint { margin: 18px 0 0; color: var(--text-dim); font-size: 12.5px; opacity: 0.85; }

/* ---------- 后台布局 ---------- */
.app {
  position: relative; z-index: 1;
  max-width: 1120px; margin: 0 auto; padding: 22px 20px 48px;
  animation: rise 0.5s var(--ease) both;
}
.topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  font-size: 19px; color: #04171a; border-radius: 12px;
  background: linear-gradient(135deg, var(--teal), var(--teal-2) 60%, var(--violet));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 700; letter-spacing: 0.5px; }
.brand-sub { color: var(--text-dim); font-size: 12px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; justify-content: center; }
.tab {
  background: transparent; color: var(--text-dim); border: 1px solid transparent;
  padding: 8px 15px; border-radius: 999px; cursor: pointer; font-size: 14px;
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.2s;
}
.tab:hover { color: var(--text); transform: translateY(-1px); }
.tab.is-active {
  color: #04211d; font-weight: 600;
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
  border-color: transparent; box-shadow: 0 6px 18px rgba(95, 208, 192, 0.25);
}

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin: 14px 0;
}
.stat {
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.stat-num { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--text-dim); font-size: 13px; }
.stat[data-tone="teal"] .stat-num { color: var(--teal); }
.stat[data-tone="pink"] .stat-num { color: var(--pink); }
.stat[data-tone="violet"] .stat-num { color: var(--violet); }
.stat[data-tone="gold"] .stat-num { color: var(--gold); }

/* ---------- 内容区 ---------- */
.content {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; font-size: 19px; letter-spacing: 0.3px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 14px; padding: 13px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: transform 0.2s var(--ease), border-color 0.2s, background 0.2s;
}
.item:hover { transform: translateY(-2px); border-color: var(--border-strong); background: rgba(32, 42, 80, 0.5); }
.item .thumb {
  width: 60px; height: 60px; object-fit: cover; border-radius: 10px;
  background: #0a0f22; flex: none; border: 1px solid var(--border);
}
.item-thumb-fallback {
  width: 60px; height: 60px; flex: none; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); font-size: 20px;
}
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--text-dim); font-size: 13px; }
.item-actions { display: flex; gap: 8px; flex: none; }
.empty {
  color: var(--text-dim); padding: 48px 24px; text-align: center;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--teal); color: #04211d; border: 1px solid transparent; border-radius: 11px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s var(--ease), filter 0.2s, box-shadow 0.2s;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
  box-shadow: 0 8px 22px rgba(95, 208, 192, 0.22);
}
.btn-primary:hover { box-shadow: 0 10px 26px rgba(95, 208, 192, 0.34); }
.btn-block { width: 100%; }
.btn.ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn.ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(255, 123, 138, 0.4); }
.btn.danger:hover { background: rgba(255, 123, 138, 0.1); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 13px; color: var(--text-dim); }
.field-label .req { color: var(--danger); }
input, textarea, select {
  background: rgba(7, 11, 24, 0.7); color: var(--text); border: 1px solid var(--border);
  border-radius: 11px; padding: 11px 13px; font: inherit; width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(95, 208, 192, 0.14); }
.actions { display: flex; gap: 10px; }
.preview { max-width: 180px; max-height: 130px; border-radius: 10px; margin-bottom: 8px; display: block; border: 1px solid var(--border); }
hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }
.msg { color: var(--text-dim); font-size: 13px; min-height: 1.3em; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--teal); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 5, 12, 0.72); backdrop-filter: blur(4px); }
.modal-card {
  position: relative; width: 100%; max-width: 600px; max-height: 90vh; overflow: auto;
  padding: 26px; border-radius: var(--radius);
  animation: rise 0.35s var(--ease) both;
}
.modal-card h2 { margin: 0 0 18px; font-size: 19px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  z-index: 80; padding: 12px 20px; border-radius: 999px;
  background: rgba(20, 28, 52, 0.92); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.3s, transform 0.3s var(--ease);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 抖动（登录失败） */
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}
.shake { animation: shake 0.5s; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .app { padding: 14px 12px 40px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .tabs { justify-content: flex-start; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .item { flex-wrap: wrap; }
  .login-card { padding: 36px 26px 26px; }
}

/* 减少动效 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .login-card, .app { animation: none; }
}
