/* ── 重置 & 基础 ──────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F7F5F0;
  --text: #2C2C2C;
  --muted: #8A8A7E;
  --accent: #B8860B;
  --line: #E0DCD4;
  --danger: #C0392B;
  --radius: 4px;
  --font-serif: 'Noto Serif SC', 'Source Han Serif CN', Georgia, serif;
  --font-sans: 'Noto Sans SC', 'Source Han Sans CN', -apple-system, sans-serif;
}

html { font-size: 15px; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ── 按钮 ──────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); cursor: pointer;
  font-size: 14px; transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-ghost {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 4px 8px;
}
.btn-ghost:hover { color: var(--text); }
.btn-danger {
  padding: 8px 18px; background: none; color: var(--danger);
  border: 1px solid var(--danger); border-radius: var(--radius);
  cursor: pointer; font-size: 14px; transition: all 0.2s;
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 13px; }

/* ── 屏幕切换 ───────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── 登录 ──────────────────────────── */
.login-card {
  max-width: 360px; margin: 120px auto 0; text-align: center;
  padding: 60px 40px;
}
.login-card h1 {
  font-family: var(--font-serif); font-size: 32px;
  font-weight: 400; letter-spacing: 0.1em;
  color: var(--text);
}
.login-subtitle { color: var(--muted); font-size: 14px; margin-top: 10px; margin-bottom: 30px; }
.login-sep { width: 40px; height: 1px; background: var(--line); margin: 0 auto 30px; }
.login-card input {
  width: 100%; padding: 12px 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff;
  text-align: center; font-size: 15px; outline: none;
  margin-bottom: 16px;
}
.login-card input:focus { border-color: var(--accent); }
.login-card .btn { width: 100%; padding: 12px; justify-content: center; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 20px; }

/* ── 主面板头部 ──────────────────────── */
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.admin-header-left { display: flex; align-items: baseline; gap: 10px; }
.admin-logo {
  font-family: var(--font-serif); font-size: 20px;
  letter-spacing: 0.08em;
}
.admin-ver { color: var(--muted); font-size: 12px; }
.admin-tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 16px; border: none; background: none;
  color: var(--muted); cursor: pointer; font-size: 14px;
  border-radius: var(--radius); transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── 工具栏 ─────────────────────────── */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px; gap: 16px;
}
.filter-group { display: flex; gap: 4px; }
.filter-btn {
  padding: 4px 14px; border: 1px solid var(--line); background: none;
  color: var(--muted); cursor: pointer; font-size: 13px;
  border-radius: var(--radius); transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── 文章列表 ───────────────────────── */
.article-list { padding: 0 32px 60px; }
.article-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.article-item:hover { background: rgba(0,0,0,0.01); }
.article-date {
  font-size: 13px; color: var(--muted); white-space: nowrap;
  min-width: 90px; font-variant-numeric: tabular-nums;
}
.article-cat {
  font-size: 11px; color: var(--accent); border: 1px solid var(--accent);
  padding: 1px 8px; border-radius: 10px; white-space: nowrap;
}
.article-title {
  flex: 1; font-size: 15px; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
}
.article-actions { display: flex; gap: 8px; }
.article-empty {
  text-align: center; padding: 80px 0; color: var(--muted);
  font-size: 15px;
}

/* ── 设置表单 ───────────────────────── */
.settings-form {
  max-width: 600px; padding: 32px;
}
.settings-form label {
  display: block; font-size: 13px; color: var(--muted);
  margin-bottom: 6px; margin-top: 20px;
}
.settings-form label:first-child { margin-top: 0; }
.settings-form input,
.settings-form textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; outline: none;
  line-height: 1.6;
}
.settings-form input:focus,
.settings-form textarea:focus {
  border-color: var(--accent);
}
.settings-form .btn { margin-top: 24px; }

/* ── 编辑器弹窗 ─────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.3); z-index: 100;
  justify-content: center; align-items: flex-start;
  padding: 40px 20px; overflow-y: auto;
}
.overlay.active { display: flex; }

.editor-panel {
  background: var(--bg); width: 100%; max-width: 760px;
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.editor-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--line);
}
.editor-header h2 {
  font-family: var(--font-serif); font-size: 18px; font-weight: 400;
}
.editor-body { padding: 28px; }
.editor-field { margin-bottom: 18px; }
.editor-field label {
  display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px;
}
.editor-field input,
.editor-field select,
.editor-field textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; outline: none;
  line-height: 1.6; font-size: 14px;
}
.editor-field textarea {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  resize: vertical; min-height: 300px;
}
.editor-field input:focus,
.editor-field select:focus,
.editor-field textarea:focus {
  border-color: var(--accent);
}
.editor-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.editor-footer {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 28px; border-top: 1px solid var(--line);
}
#delete-article-btn { margin-left: auto; }
.msg { font-size: 13px; min-height: 20px; padding: 4px 0; }
.msg.success { color: #27AE60; }
.msg.error { color: var(--danger); }

/* ── 上传弹窗 ───────────────────────── */
.upload-panel {
  background: var(--bg); padding: 32px;
  border-radius: 8px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  margin-top: 80px;
}
.upload-panel h2 {
  font-family: var(--font-serif); font-size: 18px; font-weight: 400;
  margin-bottom: 20px;
}
#upload-file { margin-bottom: 16px; }
#upload-preview img { max-width: 300px; max-height: 200px; border-radius: 4px; margin: 10px 0; }

/* ── 响应式 ─────────────────────────── */
@media (max-width: 640px) {
  .admin-header { padding: 12px 16px; }
  .toolbar { padding: 16px; flex-wrap: wrap; gap: 12px; }
  .article-list { padding: 0 16px 40px; }
  .article-item { flex-wrap: wrap; }
  .editor-row { grid-template-columns: 1fr; }
  .editor-panel { border-radius: 0; max-height: 100vh; overflow-y: auto; }
  .login-card { padding: 40px 24px; }
}
