:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1e2430;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --border: #e5e7eb;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-size: 20px; font-weight: 800; color: var(--accent); text-decoration: none; letter-spacing: .5px; }
.brand span { font-weight: 500; color: var(--text); }
nav a { margin-left: 20px; color: var(--muted); text-decoration: none; font-weight: 500; padding: 6px 4px; }
nav a:hover { color: var(--accent); }
nav a.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

/* Hero */
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: 32px; margin: 0 0 10px; }
.hero p { color: var(--muted); margin: 0; font-size: 16px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 6px 0 24px; }
.cats { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.chip {
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 13px; transition: .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.search {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; font-size: 14px;
  min-width: 220px; background: var(--card); outline: none;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Post cards */
.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card {
  display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: .18s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #c7d2fe; }
.card-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tag { background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.time { color: var(--muted); font-size: 12px; }
.card-title { margin: 0 0 8px; font-size: 18px; line-height: 1.4; }
.card-author { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* Detail */
.detail-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px; margin: 26px 0; }
.detail-card h1 { font-size: 28px; margin: 10px 0 14px; line-height: 1.35; }
.detail-meta { color: var(--muted); font-size: 13px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.prose { padding-top: 8px; font-size: 16px; }
.prose h1, .prose h2, .prose h3 { line-height: 1.35; margin-top: 1.4em; }
.prose pre { background: #111827; color: #e5e7eb; padding: 14px 16px; border-radius: 10px; overflow: auto; font-size: 14px; }
.prose code { background: #f3f4f6; padding: 2px 6px; border-radius: 5px; font-size: .9em; }
.prose pre code { background: none; padding: 0; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose blockquote { border-left: 4px solid var(--accent); margin: 1em 0; padding: 4px 16px; color: var(--muted); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; }
.prose th { background: #f9fafb; }
.err { color: var(--danger); }

/* Admin */
.auth-card, .panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; margin: 30px 0; }
.auth-card { max-width: 400px; margin: 60px auto; }
.auth-card h2 { margin: 0 0 6px; }
.auth-card p { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; font-family: inherit; background: #fff; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 200px; line-height: 1.6; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 180px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; background: var(--accent); color: #fff; transition: .15s;
}
.btn:hover { background: #4338ca; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: #fee2e2; color: var(--danger); }
.btn.danger:hover { background: #fecaca; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab { padding: 10px 18px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabview { display: none; }
.tabview.on { display: block; }

.admin-list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.admin-list-item .info { flex: 1; min-width: 0; }
.admin-list-item .title { font-weight: 600; margin: 0 0 4px; }
.admin-list-item .sub { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.plain-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.msg { padding: 10px 14px; border-radius: 10px; font-size: 14px; margin: 10px 0; display: none; }
.msg.ok { display: block; background: #dcfce7; color: #166534; }
.msg.err { display: block; background: #fee2e2; color: #991b1b; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-backdrop.on { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 26px; max-width: 520px; width: 100%; box-shadow: var(--shadow-lg); }
.modal h3 { margin: 0 0 16px; }
.share-link-box { background: #f3f4f6; border-radius: 8px; padding: 12px; word-break: break-all; font-size: 13px; margin: 10px 0; user-select: all; }

/* Footer */
.site-footer { margin-top: auto; text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; }

@media (max-width: 640px) {
  .hero h1 { font-size: 24px; }
  .detail-card { padding: 20px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { min-width: 0; }
}
