:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e6e8eb;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --brand: #3370ff;
  --brand-dark: #245bdb;
  --brand-bg: #eef3ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.hidden { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }

/* 登录页 */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 56px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(31, 35, 41, 0.06);
}
.logo {
  width: 64px; height: 64px;
  margin: 0 auto 20px;
  border-radius: 16px;
  background: var(--brand);
  color: #fff;
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo.small { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; margin: 0; }
.login-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.login-card p { margin-bottom: 24px; }

.btn-primary {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 28px;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary.disabled,
.btn-primary[aria-disabled="true"] {
  background: #b5cdff;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-ghost {
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 13px;
}
.btn-ghost:hover { background: var(--bg); }

/* 应用布局 */
.app-view { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.user-box { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-bg);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}
.user-name { color: var(--text-2); }

.layout { display: flex; flex: 1; }
.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  flex-shrink: 0;
}
.sidebar-title { font-size: 13px; font-weight: 600; color: var(--text-3); padding: 0 12px 10px; }
.article-list { list-style: none; }
.article-list li {
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.article-list li:hover { background: var(--bg); }
.article-list li.active { background: var(--brand-bg); color: var(--brand); font-weight: 600; }

.content { flex: 1; padding: 32px 48px; overflow-y: auto; }
.article { max-width: 780px; }
.article h1 { font-size: 26px; font-weight: 600; margin-bottom: 20px; }
.article h2 { font-size: 20px; font-weight: 600; margin: 28px 0 12px; }
.article h3 { font-size: 16px; font-weight: 600; margin: 22px 0 10px; }
.article p { margin-bottom: 12px; }
.article ul, .article ol { margin: 0 0 12px 22px; }
.article code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.article pre {
  background: #1f2329;
  color: #e6e8eb;
  border-radius: 10px;
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 12px;
}
.article pre code { background: none; border: none; color: inherit; padding: 0; }
.article blockquote {
  border-left: 3px solid var(--brand);
  background: var(--brand-bg);
  padding: 10px 16px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 12px;
  color: var(--text-2);
}
.article table { border-collapse: collapse; margin-bottom: 12px; width: 100%; }
.article th, .article td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.article th { background: var(--bg); }
.article a { color: var(--brand); }
.empty { color: var(--text-3); padding: 40px 0; text-align: center; }

/* 顶栏搜索与操作 */
.top-actions { display: flex; align-items: center; gap: 14px; }
.search-input {
  width: 220px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: var(--bg);
}
.search-input:focus { border-color: var(--brand); background: var(--surface); }

/* 侧边栏 */
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 10px; }
.btn-mini {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.btn-mini:hover { background: var(--brand-dark); }

/* 搜索结果 */
.r-title { color: var(--text); font-weight: 500; }
.r-snippet { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.article-list li:has(.r-title) { white-space: normal; overflow: hidden; }

/* 工具栏与编辑器 */
.toolbar { display: flex; gap: 8px; margin-bottom: 16px; }
.btn-ghost.danger { color: #d4380d; border-color: #ffccc7; }
.btn-ghost.danger:hover { background: #fff1f0; }

.editor { max-width: 780px; display: flex; flex-direction: column; gap: 12px; }
.slug-input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.slug-input:focus { border-color: var(--brand); }
.slug-input:disabled { background: var(--bg); color: var(--text-3); }
.editor-area {
  min-height: 420px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
}
.editor-area:focus { border-color: var(--brand); }
.editor-actions { display: flex; gap: 10px; }
