/* ===== RESET & BASE — minimalist theme ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #ffffff;
  --bg-muted:     #fafafa;
  --bg-hover:     #f5f5f5;
  --accent:       #2563eb;
  --accent-hover: #1d4ed8;
  --text-primary: #1a1a1a;
  --text-secondary:#555555;
  --text-muted:   #999999;
  --border:       #e5e5e5;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,0.06);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.08);
  --font-sans:    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                  "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono:    "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== HEADER ===== */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.site-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-decoration: none;
}
.site-title .accent { color: var(--accent); }

/* Nav */
.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.site-nav a {
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.site-nav a:hover {
  color: var(--accent);
  background: var(--bg-hover);
}
.site-nav a.active {
  color: var(--accent);
  background: var(--bg-hover);
  font-weight: 600;
}
.site-nav a .count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 4px;
}
.site-nav a.nav-write {
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.site-nav a.nav-write:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

/* ===== HERO / BRAND STRIP ===== */
.brand-strip {
  margin: 48px 0 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.brand-strip h2 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.6;
  letter-spacing: -0.01em;
}

/* ===== SECTION TITLE ===== */
.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 48px 0 20px;
}
.section-head .hex-marker {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  text-transform: uppercase;
}
.section-head .hex-marker.green { color: var(--accent); }
.section-head .line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== ARTICLE CARDS ===== */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.article-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 20px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--bg);
  transition: all 0.15s ease;
}
a + .article-card { margin-top: 12px; }
.article-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: #ddd;
  transform: translateY(-1px);
}
.article-card:hover .card-title {
  color: var(--accent);
}

.article-card .card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.article-card .card-category {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.article-card .card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  transition: color 0.15s ease;
}

.article-card .card-summary {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card .card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.article-card .card-rating {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  text-align: right;
  flex-shrink: 0;
}

/* Featured */
.article-card.featured {
  border-color: var(--accent);
  background: var(--bg-muted);
}
.article-card.featured .card-title {
  font-size: 1.15rem;
}

/* ===== ARTICLE DETAIL ===== */
.article-detail {
  padding: 48px 0;
}
.article-detail .back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 28px;
}
.article-detail .back-link:hover { color: var(--accent); }

.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.detail-top .back-link { margin-bottom: 28px; }
.detail-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 28px;
}
.btn-detail {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1;
  padding: 8px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease;
}
.btn-edit {
  color: var(--text-secondary);
  background: var(--bg);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
.btn-edit:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-muted);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.15);
}
.btn-delete {
  color: #dc2626;
  background: var(--bg);
  border-color: #fecaca;
}
.btn-delete:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.25);
}

.article-detail .detail-category {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 10px;
}

.article-detail h1 {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

.article-detail .detail-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.article-detail .detail-meta .detail-rating {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}
.article-detail .detail-meta .tag {
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
}

/* Article content (rendered Markdown) */
.article-content {
  font-size: 1rem;
  line-height: 1.85;
}
.article-content h1, .article-content h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.article-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 28px 0 12px;
}
.article-content p { margin-bottom: 1.2em; }
.article-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(37, 99, 235, 0.25);
}
.article-content a:hover { border-bottom-color: var(--accent); }
.article-content ul, .article-content ol { margin: 0 0 1.2em 1.5em; }
.article-content li { margin-bottom: 0.4em; }
.article-content blockquote {
  border-left: 3px solid var(--border);
  margin: 1.2em 0;
  padding: 4px 0 4px 20px;
  color: var(--text-secondary);
}
.article-content code {
  font-family: var(--font-mono);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}
.article-content pre {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  margin: 1.2em 0;
}
.article-content pre code {
  background: none;
  border: none;
  padding: 0;
}
.article-content img { max-width: 100%; border-radius: var(--radius); margin: 1em 0; }
.article-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: 0.92rem;
}
.article-content th, .article-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.article-content th { background: var(--bg-muted); font-weight: 600; }
.article-content hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

/* ===== AUTH NAV (login / logout) ===== */
.site-nav .nav-user {
  font-size: 0.82rem;
  color: var(--text-muted);
  align-self: center;
  padding: 0 6px;
}
.site-nav form.nav-logout {
  display: inline-flex;
  margin: 0;
  padding: 0;
}
.site-nav form.nav-logout button {
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.site-nav form.nav-logout button:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-hover);
}

/* ===== LOGIN PAGE ===== */
.auth-panel {
  max-width: 360px;
  margin: 80px auto;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
}
.auth-panel h1 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 20px;
}
.auth-form label {
  display: block;
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.auth-form input {
  width: 100%;
  padding: 10px 12px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.auth-error {
  color: #dc2626;
  font-size: 0.88rem;
  margin-bottom: 14px;
}
.btn-primary {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-primary:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-muted);
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 32px 0 8px;
}
.pagination .page-link {
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.15s ease;
}
.pagination a.page-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-hover);
}
.pagination .page-link.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pagination .page-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== FOOTER ===== */
.site-footer {
  margin-top: 80px;
  padding: 28px 0;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* ===== CATEGORY MANAGEMENT PAGE (2026-08-16) ===== */
.cat-msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
}
.cat-msg.ok { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.cat-msg.error { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }

.cat-create {
  margin-bottom: 28px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-muted);
}
.cat-create h2 { font-size: 1rem; margin-bottom: 12px; }
.cat-create form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cat-create input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--bg);
  flex: 1 1 180px;
}
.cat-create input[name="slug"] { flex: 1 1 220px; }

.cat-list h2 { font-size: 1rem; margin-bottom: 12px; }
.cat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: var(--bg);
}
.cat-name { font-weight: 600; color: var(--text-primary); }
.cat-meta { font-size: 0.8rem; color: var(--text-muted); }
.cat-inline { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.cat-inline input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  max-width: 160px;
}
.cat-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
}
.cat-btn:hover { border-color: var(--accent); color: var(--accent); }
.cat-delete:hover { border-color: #dc2626; color: #dc2626; }
.cat-empty { color: var(--text-muted); font-size: 0.9rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .site-header .container { flex-direction: column; align-items: flex-start; }
  .article-card { grid-template-columns: 1fr; }
  .article-card .card-rating { text-align: left; }
  .article-detail h1 { font-size: 1.5rem; }
  .detail-top { flex-direction: column; align-items: flex-start; gap: 8px; }
  .detail-actions { margin-bottom: 20px; }
  .btn-detail { padding: 7px 14px; }
}
