:root {
  --bg: #f8f9fb;
  --bg2: #ffffff;
  --ink: #1a1d23;
  --muted: #7a808c;
  --rule: rgba(26, 29, 35, 0.08);
  --accent: #4f6df5;
  --accent2: #7c5cff;
  --accent-soft: rgba(79, 109, 245, 0.08);
  --danger: #ef4444;
  --ok: #10b981;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

body::before {
  content: ''; position: fixed; top: -20%; right: -10%;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(79,109,245,.08) 0%, transparent 70%);
  border-radius: 50%; pointer-events: none;
}
body::after {
  content: ''; position: fixed; bottom: -20%; left: -10%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(124,92,255,.06) 0%, transparent 70%);
  border-radius: 50%; pointer-events: none;
}

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

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(79,109,245,.25);
}
.brand-text { font-weight: 700; font-size: 17px; letter-spacing: 1px; margin-left: 10px; white-space: nowrap; }
.brand { display: flex; flex-direction: row; align-items: center; gap: 0; flex: 0 0 auto; }
.topbar nav a { margin-left: 20px; color: var(--muted); font-size: 14px; }
.topbar nav a:hover { color: var(--accent); text-decoration: none; }

/* 容器 */
.container { max-width: 1080px; margin: 0 auto; padding: 40px 24px 80px; position: relative; z-index: 1; }
.container-narrow { max-width: 720px; }

/* 首页 hero */
.hero { text-align: center; margin-bottom: 48px; }
.hero h1 {
  font-size: clamp(28px, 4vw, 40px); font-weight: 700; letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 12px;
}
.hero p { color: var(--muted); font-size: 15px; max-width: 540px; margin: 0 auto; }

/* 卡片网格 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.card {
  background: var(--bg2); border: 1px solid var(--rule); border-radius: 16px;
  padding: 28px 24px; transition: all .25s ease; position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0; transition: opacity .25s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(26,29,35,.08); border-color: transparent; }
.card:hover::before { opacity: 1; }
.card-icon {
  width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; font-size: 26px; margin-bottom: 16px;
}
.card-name { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.card-summary { color: var(--muted); font-size: 14px; flex: 1; margin-bottom: 18px; word-break: break-word; }
.card-actions { display: flex; gap: 10px; align-items: center; }
.card-actions .btn-sm { flex: 1; text-align: center; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--rule);
  background: var(--bg2); color: var(--ink); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .2s; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: none; }
.btn-primary:hover { color: #fff; opacity: .92; }
.btn-danger { color: var(--danger); border-color: rgba(239,68,68,.3); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 表单 */
.form-card { background: var(--bg2); border: 1px solid var(--rule); border-radius: 16px; padding: 28px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.form-group .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=url], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); transition: border .2s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

/* 登录页 */
.login-wrap { max-width: 380px; margin: 80px auto; }
.login-wrap .form-card { padding: 36px 32px; }
.login-wrap h1 { text-align: center; font-size: 22px; margin-bottom: 6px; }
.login-wrap .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* 详情页 */
.detail-head { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--rule); }
.detail-head h1 { font-size: 30px; font-weight: 700; margin-bottom: 10px; }
.detail-head .meta { color: var(--muted); font-size: 13px; }
.detail-body { font-size: 15px; line-height: 1.85; }
.detail-body :is(h1,h2,h3,h4) { margin: 1.4em 0 .6em; line-height: 1.3; }
.detail-body h2 { font-size: 22px; }
.detail-body h3 { font-size: 18px; }
.detail-body p { margin: .8em 0; }
.detail-body ul, .detail-body ol { margin: .8em 0; padding-left: 1.6em; }
.detail-body li { margin: .3em 0; }
.detail-body img { max-width: 100%; border-radius: 10px; margin: 1em 0; }
.detail-body pre { background: #1a1d23; color: #e5e7eb; padding: 16px; border-radius: 10px; overflow-x: auto; margin: 1em 0; font-size: 13px; }
.detail-body code { background: var(--accent-soft); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.detail-body pre code { background: none; padding: 0; }
.detail-body blockquote { border-left: 3px solid var(--accent); padding: 4px 16px; color: var(--muted); margin: 1em 0; background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.detail-body a { color: var(--accent); }
.detail-body table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.detail-body th, .detail-body td { border: 1px solid var(--rule); padding: 8px 12px; text-align: left; }
.detail-body th { background: var(--accent-soft); }

/* HTML 编辑器 */
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border: 1px solid var(--rule);
  border-bottom: none; border-radius: 10px 10px 0 0; background: #fafbfc;
}
.editor-toolbar button {
  padding: 6px 10px; border: 1px solid transparent; border-radius: 6px; background: none;
  cursor: pointer; font-size: 13px; color: var(--ink); transition: all .15s;
}
.editor-toolbar button:hover { background: var(--accent-soft); border-color: var(--rule); }
.editor-toolbar button.active { background: var(--accent); color: #fff; }
.editor-toolbar .sep { width: 1px; background: var(--rule); margin: 4px 2px; }
.editor-area { border: 1px solid var(--rule); border-radius: 0 0 10px 10px; overflow: hidden; }
.editor-visual {
  min-height: 320px; padding: 16px; background: #fff; outline: none; overflow-y: auto;
  font-size: 15px; line-height: 1.7;
}
.editor-visual:empty::before { content: '在此输入内容…'; color: var(--muted); }
.editor-source { width: 100%; min-height: 320px; padding: 16px; border: none; border-radius: 0 0 10px 10px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; outline: none; }

/* 管理后台 */
.admin-layout { display: grid; grid-template-columns: 1fr; gap: 24px; }
.admin-section h2 { font-size: 18px; margin-bottom: 16px; }
.list-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  background: var(--bg2); border: 1px solid var(--rule); border-radius: 12px; margin-bottom: 10px;
}
.list-item .li-icon { font-size: 22px; }
.list-item .li-name { font-weight: 600; }
.list-item .li-summary { color: var(--muted); font-size: 13px; margin-top: 2px; }
.list-item .li-meta { flex: 1; min-width: 0; }
.list-item .li-actions { display: flex; gap: 8px; }

/* 表格（使用情况）*/
.table-wrap { overflow-x: auto; background: var(--bg2); border: 1px solid var(--rule); border-radius: 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--rule); }
table.data th { background: #fafbfc; font-weight: 600; color: var(--muted); white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
table.data td.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* 工具类 */
.row { display: flex; gap: 12px; align-items: center; }
.row > * { flex: 1; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* 空状态 */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .emoji { font-size: 48px; margin-bottom: 12px; }

/* Toast */
.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 18px; border-radius: 10px; color: #fff; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.15); animation: toastIn .25s ease;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* 页脚 */
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 32px 0; border-top: 1px solid var(--rule); margin-top: 40px; }

/* 响应式 */
@media (max-width: 640px) {
  .topbar-inner { padding: 12px 16px; }
  .container { padding: 24px 16px 60px; }
  .cards { grid-template-columns: 1fr; }
  .row { flex-direction: column; align-items: stretch; }
  .row > * { width: 100%; }
}