/* 青蛙笔记 - 森系自然主题 */
:root {
  --bg: #f7f5ef;
  --bg-card: #ffffff;
  --bg-sidebar: #2f3d2e;
  --fg: #2c2a26;
  --fg-muted: #6b665c;
  --primary: #4a7c59;
  --primary-dark: #3a6347;
  --primary-light: #e8f0e6;
  --accent: #c9a96a;
  --border: #e2ddd0;
  --danger: #b5483d;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(60, 50, 30, 0.08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 14px; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ===== 布局 ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  color: #d8e0d2;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform 0.25s ease;
}
.sidebar-brand {
  padding: 22px 20px 18px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.sidebar-brand .name { font-size: 17px; font-weight: 600; color: #fff; }
.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgba(216,224,210,0.5); padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  font-size: 14px; color: #cdd6c6;
  margin-bottom: 2px; transition: background 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .icon { width: 18px; text-align: center; font-size: 15px; }
.nav-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; font-size: 13px; color: #cdd6c6;
  border-radius: 6px; margin-left: 4px;
}
.nav-tag:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-tag.active { background: var(--primary); color: #fff; }
.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px; color: rgba(216,224,210,0.6);
}
.sidebar-footer .user-name { color: #fff; font-weight: 500; }

.main {
  flex: 1; min-width: 0; margin-left: 240px;
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.hamburger {
  display: none; width: 36px; height: 36px;
  border-radius: 8px; font-size: 18px;
  background: var(--bg); color: var(--fg);
}
.content { flex: 1; padding: 24px; max-width: 1100px; width: 100%; margin: 0 auto; }

/* ===== 通用组件 ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  background: var(--primary); color: #fff;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.97); }
.btn-secondary { background: var(--bg-card); color: var(--fg); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--fg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9c3c33; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.page-title { font-size: 22px; font-weight: 700; color: var(--fg); }
.page-subtitle { font-size: 14px; color: var(--fg-muted); margin-top: 2px; }

.input, .textarea, .select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-card); color: var(--fg);
  transition: border-color 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--primary);
}
.textarea { resize: vertical; min-height: 80px; }

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 12px; background: var(--primary-light); color: var(--primary-dark);
}
.badge-muted { background: var(--bg); color: var(--fg-muted); }

/* ===== Flash 提示 ===== */
.flash {
  padding: 12px 16px; border-radius: 8px;
  margin-bottom: 16px; font-size: 14px;
}
.flash-success { background: var(--primary-light); color: var(--primary-dark); }
.flash-error { background: #fdecea; color: var(--danger); }

/* ===== 登录页 ===== */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #2f3d2e 0%, #3a5a3f 60%, #4a7c59 100%);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg-card); border-radius: 16px;
  padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.auth-card .logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 16px;
}
.auth-card h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--fg-muted); font-size: 14px; margin-bottom: 24px; }
.auth-form .field { margin-bottom: 16px; }
.auth-form label { display: block; font-size: 13px; color: var(--fg-muted); margin-bottom: 6px; }
.auth-form .btn { width: 100%; justify-content: center; padding: 10px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--fg-muted); }
.auth-switch a { color: var(--primary); font-weight: 500; }

/* ===== 文章列表 ===== */
.list-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.search-box {
  flex: 1; min-width: 200px; position: relative;
}
.search-box input { padding-left: 34px; }
.search-box .ico {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--fg-muted); font-size: 14px;
}
.article-list { display: flex; flex-direction: column; gap: 10px; }
.article-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.article-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.article-item .check { margin-top: 2px; }
.article-item .body { flex: 1; min-width: 0; }
.article-item .title {
  font-size: 15px; font-weight: 600; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.article-item .title a:hover { color: var(--primary); }
.article-item .meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: 12px; color: var(--fg-muted); margin-top: 4px;
}
.article-item .actions { display: flex; gap: 4px; flex-shrink: 0; }
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--fg-muted);
}
.empty-state .ico { font-size: 40px; margin-bottom: 12px; }

/* ===== 编辑器 ===== */
.editor-wrap { max-width: 820px; margin: 0 auto; }
.editor-title {
  width: 100%; border: none; background: transparent;
  font-size: 26px; font-weight: 700; color: var(--fg);
  padding: 8px 0; outline: none;
}
.editor-title::placeholder { color: var(--border); }
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px 8px 0 0;
  border-bottom: none;
  position: sticky; top: 56px; z-index: 20;
}
.tb-btn {
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--fg-muted);
  transition: background 0.12s;
}
.tb-btn:hover { background: var(--bg); color: var(--fg); }
.tb-btn.active { background: var(--primary-light); color: var(--primary-dark); }
.tb-sep { width: 1px; background: var(--border); margin: 4px 2px; }
.editor-content {
  min-height: 360px; padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 0 0 8px 8px;
  outline: none; font-size: 16px; line-height: 1.8; color: var(--fg);
}
.editor-content:focus { border-color: var(--primary); }
.editor-content h1 { font-size: 1.8em; margin: 0.6em 0 0.3em; }
.editor-content h2 { font-size: 1.5em; margin: 0.6em 0 0.3em; }
.editor-content h3 { font-size: 1.25em; margin: 0.6em 0 0.3em; }
.editor-content p { margin: 0.4em 0; }
.editor-content ul, .editor-content ol { padding-left: 1.5em; margin: 0.4em 0; }
.editor-content blockquote {
  border-left: 3px solid var(--primary); padding-left: 12px;
  color: var(--fg-muted); margin: 0.6em 0;
}
.editor-content img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.editor-content a { color: var(--primary); text-decoration: underline; }
.editor-footer {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
}
.tag-input-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; background: var(--primary-light);
  color: var(--primary-dark); border-radius: 999px; font-size: 12px;
}
.tag-chip button { font-size: 12px; color: var(--primary-dark); opacity: 0.7; }
.tag-chip button:hover { opacity: 1; }
.read-mode .editor-content { border-radius: 8px; }
.read-mode .editor-toolbar { display: none; }

/* ===== 管理员后台 ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.stat-card .label { font-size: 13px; color: var(--fg-muted); }
.stat-card .value { font-size: 32px; font-weight: 700; color: var(--primary); margin-top: 4px; }
.stat-card .value.accent { color: var(--accent); }
.stat-card .value.danger { color: var(--danger); }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; text-align: left; white-space: nowrap; }
th { color: var(--fg-muted); font-weight: 500; border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid var(--border); }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(40,35,25,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal {
  background: var(--bg-card); border-radius: 14px;
  padding: 24px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h3 { font-size: 17px; margin-bottom: 8px; }
.modal p { color: var(--fg-muted); font-size: 14px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== 移动端 ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; align-items: center; justify-content: center; }
  .content { padding: 16px; }
  .page-title { font-size: 18px; }
  .editor-title { font-size: 20px; }
  .editor-toolbar { top: 52px; }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    z-index: 35; display: none;
  }
  .sidebar-backdrop.open { display: block; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }