:root {
  --bg: #fbfbfd;
  --bg-card: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --divider: #d2d2d7;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.08);
  --radius: 18px;
  --max-width: 780px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 17px;
}

a { color: inherit; text-decoration: none; }

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(251, 251, 253, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--divider);
}
.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.nav-links { display: flex; gap: 24px; font-size: 14px; color: var(--text-secondary); }
.nav-links a { transition: color 0.2s ease; }
.nav-links a:hover, .nav-links a.active { color: var(--text); }

/* ---------- Layout ---------- */
main { max-width: var(--max-width); margin: 0 auto; padding: 48px 20px 96px; min-height: 60vh; }

.footer {
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 32px 20px 48px;
}

/* ---------- Hero ---------- */
.hero { padding: 40px 0 56px; }
.hero h1 {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}
.hero p { font-size: 19px; color: var(--text-secondary); margin: 0; max-width: 520px; }

/* ---------- Section ---------- */
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin: 40px 0 16px;
}

/* ---------- Post card / list ---------- */
.post-list { display: flex; flex-direction: column; gap: 20px; }
.post-card {
  display: block;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--divider);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.post-card:hover { transform: translateY(-2px); box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 12px 28px rgba(0,0,0,0.08); }
.post-card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg);
}
.post-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card-body { padding: 20px; }
.post-card .tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 100px;
  margin-bottom: 10px;
}
.post-card h2 { font-size: 21px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
.post-card p { margin: 0; color: var(--text-secondary); font-size: 15px; }
.post-card time { display: block; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }

.empty {
  color: var(--text-secondary);
  font-size: 15px;
  padding: 40px 0;
  text-align: center;
}

/* ---------- Category chips on homepage ---------- */
.chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
@media (max-width: 560px) { .chip-grid { grid-template-columns: 1fr; } }
.chip-card {
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--bg-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.chip-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
.chip-card h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.chip-card .subs { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-card .subs span {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--divider);
  padding: 3px 10px;
  border-radius: 100px;
}

/* ---------- Single post ---------- */
.post-header { padding: 8px 0 32px; border-bottom: 1px solid var(--divider); margin-bottom: 32px; }
.post-header .tag { font-size: 12px; font-weight: 600; color: var(--accent); }
.post-header h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin: 10px 0; }
.post-header time { color: var(--text-secondary); font-size: 14px; }
.post-body { font-size: 17px; }
.post-body h2 { font-size: 24px; margin-top: 40px; letter-spacing: -0.01em; }
.post-body h3 { font-size: 20px; margin-top: 32px; }
.post-body p { margin: 18px 0; }
.post-body img { max-width: 100%; border-radius: 12px; }
.post-body code { background: var(--accent-soft); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }
.post-body pre { background: #1d1d1f; color: #f5f5f7; padding: 18px; border-radius: 12px; overflow-x: auto; }
.post-body pre code { background: none; padding: 0; color: inherit; }
.post-body blockquote { margin: 20px 0; padding: 4px 20px; border-left: 3px solid var(--accent); color: var(--text-secondary); }
.post-body a { color: var(--accent); }
.post-body ul, .post-body ol { padding-left: 22px; }

/* ---------- Admin ---------- */
.admin-wrap { max-width: 920px; }
.login-box {
  max-width: 360px;
  margin: 15vh auto;
  padding: 36px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--divider);
  text-align: center;
}
.login-box h1 { font-size: 22px; margin-bottom: 6px; }
.login-box p { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }

input, textarea, select {
  font-family: var(--font);
  font-size: 15px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--divider);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

button, .btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 100px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
button:hover, .btn:hover { opacity: 0.85; }
button.secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--divider); }
button.danger { background: #ff3b30; }

.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.admin-header h1 { font-size: 26px; margin: 0; }

.admin-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: start; }
@media (max-width: 800px) { .admin-grid { grid-template-columns: 1fr; } }

.card { background: var(--bg-card); border: 1px solid var(--divider); border-radius: var(--radius); padding: 24px; }
.card + .card { margin-top: 20px; }
.card h2 { font-size: 16px; margin: 0 0 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.admin-post-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
}
.admin-post-item:last-child { border-bottom: none; }
.admin-post-item .meta { color: var(--text-secondary); font-size: 12px; }
.admin-post-item .actions { display: flex; gap: 8px; }
.admin-post-item .actions button { padding: 6px 12px; font-size: 12px; }

.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 100px; background: var(--accent-soft); color: var(--accent); margin-right: 6px; }
.pill.draft { background: #f5f5f7; color: var(--text-secondary); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }
