/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --bg:        #faf9f7;
  --surface:   #ffffff;
  --border:    #e8e4df;
  --text:      #1a1a1a;
  --muted:     #6b7280;
  --primary:   #4f46e5;
  --primary-h: #3730a3;
  --danger:    #dc2626;
  --radius:    12px;
  --shadow:    0 2px 12px rgba(0,0,0,.07);
  --font-body: 'Inter', system-ui, sans-serif;
  --font-head: 'Playfair Display', Georgia, serif;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  flex: 1;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: .9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-title {
  font-family: var(--font-head);
  font-size: 1.4rem;
  color: var(--text);
  font-weight: 700;
}
.site-title:hover { text-decoration: none; color: var(--primary); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .6rem 1.4rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s;
}
.btn-primary:hover { background: var(--primary-h); }

.btn-ghost {
  display: inline-block;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem 1.1rem;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .18s, color .18s;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

.btn-danger {
  display: inline-block;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: .3rem .8rem;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .18s, color .18s;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-edit {
  display: inline-block;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .3rem .8rem;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .18s, color .18s;
}
.btn-edit:hover { border-color: var(--primary); color: var(--primary); }

/* ── Page intro ─────────────────────────────────────────────────────────── */
.page-intro {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.page-intro h1 {
  font-family: var(--font-head);
  font-size: 2rem;
  margin-bottom: .4rem;
}
.page-intro p { color: var(--muted); }

/* ── Loading / empty state ──────────────────────────────────────────────── */
.loading-state, .empty-state {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  font-size: .95rem;
}

/* ── Posts grid ─────────────────────────────────────────────────────────── */
.posts-grid {
  display: grid;
  gap: 1.5rem;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(0,0,0,.1);
}

.post-card-cover {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.post-card-body { padding: 1.4rem; }

.post-card-meta {
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: .5rem;
  display: flex;
  gap: 1rem;
}

.post-card-title {
  font-family: var(--font-head);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: .6rem;
  line-height: 1.3;
}
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--primary); text-decoration: none; }

.post-card-excerpt {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .82rem;
  color: var(--muted);
}
.post-card-footer a { color: var(--primary); font-weight: 500; }

/* ── Full post ──────────────────────────────────────────────────────────── */
.post-full { margin-bottom: 2.5rem; }

.post-full-cover {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.post-full-meta {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: .8rem;
}

.post-full-title {
  font-family: var(--font-head);
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 1.5rem;
}

.post-full-body { font-size: 1.05rem; line-height: 1.8; }
.post-full-body p { margin-bottom: 1.1rem; }

/* ── Reactions ──────────────────────────────────────────────────────────── */
.reactions-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 2rem;
}
.reactions-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-family: var(--font-body);
}

.reaction-bar {
  display: flex;
  gap: .7rem;
  flex-wrap: wrap;
}

.reaction-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 50px;
  padding: .45rem 1rem;
  font-size: 1.15rem;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .12s;
  font-family: inherit;
  line-height: 1;
}
.reaction-btn:hover {
  border-color: var(--primary);
  background: #eef2ff;
  transform: scale(1.08);
}
.reaction-btn.active {
  border-color: var(--primary);
  background: #eef2ff;
  font-weight: 600;
}
.reaction-btn .count {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
}
.reaction-btn.active .count { color: var(--primary); }

/* ── Comments ───────────────────────────────────────────────────────────── */
.comments-section {
  margin-bottom: 3rem;
}
.comments-section h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
}

.comments-list { margin-bottom: 2rem; }

.comment-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: .9rem;
  position: relative;
}
.comment-header {
  display: flex;
  align-items: baseline;
  gap: .7rem;
  margin-bottom: .4rem;
  flex-wrap: wrap;
}
.comment-author { font-weight: 600; font-size: .95rem; }
.comment-date   { font-size: .78rem; color: var(--muted); }
.comment-text   { font-size: .93rem; white-space: pre-wrap; word-break: break-word; }

.comment-delete {
  position: absolute;
  top: .8rem;
  right: .8rem;
  display: none;
}

.comment-form-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
}
.comment-form-wrap h4 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

.comment-form { display: flex; flex-direction: column; gap: .8rem; }
.comment-form input,
.comment-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .9rem;
  font-family: inherit;
  font-size: .95rem;
  background: var(--bg);
  transition: border-color .18s;
  resize: vertical;
}
.comment-form input:focus,
.comment-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-error {
  color: var(--danger);
  font-size: .85rem;
  margin-top: .3rem;
}

/* ── Admin ──────────────────────────────────────────────────────────────── */
.auth-card {
  max-width: 400px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow);
}
.auth-card h2 { font-family: var(--font-head); margin-bottom: .4rem; }
.auth-card p  { color: var(--muted); margin-bottom: 1.5rem; }
.auth-card form { display: flex; flex-direction: column; gap: .8rem; }
.auth-card input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .9rem;
  font-size: .95rem;
  font-family: inherit;
}
.auth-card input:focus { outline: none; border-color: var(--primary); }

.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}
.admin-section h2 {
  font-family: var(--font-head);
  font-size: 1.4rem;
  margin-bottom: 1.4rem;
}

.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.form-group input,
.form-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .9rem;
  font-family: inherit;
  font-size: .95rem;
  background: var(--bg);
  resize: vertical;
}
.form-group input:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-group small { color: var(--muted); font-size: .8rem; }

.form-actions { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }

.admin-posts-list { display: flex; flex-direction: column; gap: .9rem; }

.admin-post-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  flex-wrap: wrap;
}
.admin-post-info { flex: 1; min-width: 0; }
.admin-post-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .2rem;
}
.admin-post-meta { font-size: .78rem; color: var(--muted); }
.admin-post-actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: .85rem;
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--primary); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .post-full-title { font-size: 1.6rem; }
  .reaction-btn { padding: .4rem .75rem; font-size: 1rem; }
}
