:root {
  --primary: #4f6ef7;
  --primary-dark: #3d5ae0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --border: #e5e7eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ===== 布局 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.topbar .brand .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center; color:#fff; font-size: 18px;
}
.topbar .spacer { flex: 1; }
/* 顶栏右侧菜单（全站统一样式：首页 / 登录 / 注册 / 本地编辑） */
.top-nav { display: flex; align-items: center; gap: 16px; }
.top-nav .link { color: var(--text-2, #777); font-size: 14px; text-decoration: none; }
.top-nav .link:hover { color: var(--primary, #4f6ef2); }
.top-nav .top-uname { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-2, #8a8a8a); }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page { display: none; }
.page.active { display: block; }

/* ===== 卡片/按钮/表单 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px;
  padding: 7px 14px; font-size: 14px; cursor: pointer;
  background: #fff; color: var(--text); transition: all .15s;
  text-decoration: none;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 3px 9px; font-size: 13px; border-radius: 6px; }
.btn-ghost { border-color: var(--border); background: #fff; }

.input, select, textarea.input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 14px; background: #fff; color: var(--text);
  outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus, select:focus, textarea.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,110,247,.12);
}
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-2); font-size: 13px; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl th { color: var(--text-2); font-weight: 500; background: #fafbfc; }
table.tbl tbody tr:hover { background: #f8faff; }
table.tbl td .muted { color: var(--text-2); font-size: 13px; }

/* ===== 徽章 ===== */
.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.badge-admin { background: #ede9fe; color: #7c3aed; }
.badge-user { background: #e0e7ff; color: #4f6ef7; }
.badge-on { background: #dcfce7; color: #16a34a; }
.badge-off { background: #fee2e2; color: #dc2626; }

/* ===== 提示 toast ===== */
#toast-box { position: fixed; top: 74px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 220px; max-width: 360px; padding: 11px 16px; border-radius: 8px;
  color: #fff; font-size: 14px; box-shadow: var(--shadow);
  animation: slideIn .25s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: #2563eb; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0;} to { transform: none; opacity: 1;} }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.5); z-index: 1000;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; max-width: 640px; width: 100%;
  max-height: 88vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background:#fff; z-index: 2;
}
.modal-header h3 { font-size: 16px; }
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-2); background:none; border:none; }
.modal-body { padding: 20px; }
.modal-body:not(:last-child) + .modal-footer { border-top: 1px solid var(--border); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background:#fff;
}

/* ===== 导图卡片 ===== */
.mindmap-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.mindmap-item {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: box-shadow .15s, transform .15s; display: flex; flex-direction: column; gap: 8px;
}
.mindmap-item:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.mindmap-item .title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mindmap-item .root { color: var(--text-2); font-size: 13px; height: 40px; overflow: hidden; }
.mindmap-item .meta { display: flex; gap: 12px; color: var(--text-2); font-size: 12px; }
.mindmap-item .ops { display: flex; gap: 6px; justify-content: flex-end; border-top: 1px dashed var(--border); padding-top: 8px; }

/* ===== 树预览 ===== */
.tree-preview { font-size: 13px; background:#fafbfc; border:1px solid var(--border); border-radius:8px; padding: 12px; max-height: 320px; overflow:auto; }
.tree-preview ul { padding-left: 18px; list-style: none; position: relative; }
.tree-preview ul ul { border-left: 1px dashed #cbd5e1; }
.tree-preview li { padding: 2px 0; }
.tree-preview li .text { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; display:inline-block; max-width: 100%; }

/* ===== 空态 ===== */
.empty { text-align: center; color: var(--text-2); padding: 60px 20px; }
.empty .big { font-size: 46px; margin-bottom: 12px; }
.empty p { margin-bottom: 6px; }
.empty .steps { max-width: 560px; margin: 18px auto 0; text-align: left; background:#fafbfc; border:1px solid var(--border); border-radius: 10px; padding: 16px 22px; }
.empty .steps ol { padding-left: 20px; }
.empty .steps li { padding: 3px 0; }

/* ===== 认证面板 ===== */
.auth-wrap { max-width: 420px; margin: 8vh auto 0; }
.auth-card { padding: 26px; }
.auth-tabs { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; margin-bottom: 20px; }
.auth-tab { flex:1; text-align:center; padding: 9px; cursor:pointer; color: var(--text-2); font-weight:500; }
.auth-tab.on { background: var(--primary); color: #fff; }
.auth-note { text-align:center; margin-top:14px; color: var(--text-2); font-size: 13px; }
.auth-note a { color: var(--primary); cursor: pointer; }

/* ===== 状态统计 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-item { background:#fff; border:1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-item .num { font-size: 26px; font-weight: 700; }
.stat-item .lbl { color: var(--text-2); font-size: 13px; margin-top: 2px; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.pager .info { color: var(--text-2); font-size: 13px; margin-right: auto; }

.auth-user { display: flex; align-items:center; gap: 10px; }
.auth-user .link { color: var(--text-2, #777); font-size: 14px; text-decoration: none; }
.auth-user .link:hover { color: var(--primary, #4f6ef2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #4f6ef7, #8b5cf6); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
}

.alert {
  padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px;
}
.alert-info { background:#eff6ff; color:#1d4ed8; border:1px solid #bfdbfe; }
.alert-danger { background:#fef2f2; color:#b91c1c; border:1px solid #fecaca; }

.drop-zone {
  border: 2px dashed #cbd5e1; border-radius: 10px; padding: 22px; text-align:center;
  color: var(--text-2); cursor: pointer; transition: all .15s; margin-bottom: 12px;
}
.drop-zone.hover, .drop-zone:hover { border-color: var(--primary); background:#f5f7ff; color: var(--primary); }

.flex { display:flex; gap:10px; align-items:center; }
.flex-1 { flex:1; }
.mt { margin-top: 12px; }
.hint { color: var(--text-2); font-size: 12px; margin-top: 8px; }
.right { text-align: right; }
textarea.code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: 12px; min-height: 200px; resize: vertical; line-height: 1.5;
}
