/* ===================================================================
   Theme: editorial paper — warm off-white ground, ink-navy accent,
   serif headlines paired with a plain sans for UI & body copy.
   =================================================================== */

:root {
  --paper: #FAF7F0;
  --ink: #1D1B16;
  --ink-soft: #5B5748;
  --line: #E4DFD1;
  --accent: #2C3E50;
  --accent-soft: #EFE6D8;
  --danger: #B0413E;
  --success: #3B6B4F;
  --sidebar: #1D1B16;
  --sidebar-text: #D9D4C4;
  --radius: 3px;
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', Palatino, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 880px; margin: 0 auto; padding: 0 24px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.text-muted { color: var(--ink-soft); font-size: .92rem; }
.text-danger { color: var(--danger); }
code { background: var(--accent-soft); padding: 1px 5px; border-radius: 2px; font-size: .9em; }

/* ---------- Public header / nav ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--paper); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px; }
.logo { font-family: var(--serif); font-size: 1.5rem; color: var(--ink); letter-spacing: .2px; }
.logo:hover { text-decoration: none; opacity: .8; }
.main-nav a { margin-left: 22px; color: var(--ink-soft); font-size: .95rem; }
.main-nav a:hover { color: var(--accent); text-decoration: none; }

.main-content { padding: 44px 24px 60px; }
.section-title { margin-bottom: 32px; border-bottom: 1px solid var(--line); padding-bottom: 20px; }
.section-title p { color: var(--ink-soft); }

/* ---------- Post grid ---------- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 32px; }
.post-card { border-bottom: 1px solid var(--line); padding-bottom: 24px; }
.post-thumb { width: 100%; height: 170px; object-fit: cover; border-radius: var(--radius); margin-bottom: 14px; display: block; }
.post-card h2 { font-size: 1.25rem; margin-bottom: 4px; }
.post-card h2 a { color: var(--ink); }
.post-meta { color: var(--ink-soft); font-size: .82rem; margin-bottom: 8px; }
.read-more { font-size: .9rem; font-weight: 600; }

.pagination { display: flex; gap: 8px; margin-top: 40px; }
.pagination a { padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink-soft); }
.pagination a.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- Single post / page ---------- */
.single-post h1 { margin-bottom: 6px; }
.featured-image { width: 100%; border-radius: var(--radius); margin: 20px 0; }
.post-content { font-size: 1.05rem; }
.post-content img { max-width: 100%; border-radius: var(--radius); margin: 12px 0; }
.post-content h2 { margin-top: 1.4em; }
.post-content blockquote { border-left: 3px solid var(--accent); margin: 1.2em 0; padding: 4px 0 4px 18px; color: var(--ink-soft); font-style: italic; }

.site-footer { border-top: 1px solid var(--line); padding: 28px 0; margin-top: 40px; color: var(--ink-soft); font-size: .85rem; }

/* ---------- Auth pages (login / signup) ---------- */
.admin-auth-body { background: var(--sidebar); display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; }
.auth-box { background: var(--paper); padding: 40px; border-radius: var(--radius); width: 340px; }
.auth-box h1 { font-size: 1.4rem; margin-bottom: 6px; }
.auth-box label { display: block; margin: 14px 0 6px; font-size: .85rem; color: var(--ink-soft); }
.auth-box input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius); font-size: .95rem; font-family: var(--sans); }
.error { color: var(--danger); font-size: .88rem; }
.success { color: var(--success); font-size: .88rem; }

/* ---------- Buttons ---------- */
.btn { display: inline-block; background: var(--accent); color: #fff; padding: 9px 18px; border: none; border-radius: var(--radius); font-size: .92rem; cursor: pointer; font-family: var(--sans); }
.btn:hover { opacity: .9; text-decoration: none; }
.btn-secondary { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.link-btn { background: none; border: none; padding: 0; color: var(--danger); cursor: pointer; font-size: inherit; font-family: inherit; text-decoration: underline; }
.upload-btn { cursor: pointer; }

/* ---------- Admin shell ---------- */
.admin-body { margin: 0; background: #F4F1E8; }
.admin-wrap { display: flex; min-height: 100vh; }
.admin-sidebar { width: 210px; background: var(--sidebar); color: var(--sidebar-text); padding: 24px 18px; flex-shrink: 0; }
.admin-logo { font-size: 1.1rem; color: #fff; margin-bottom: 26px; font-family: var(--serif); }
.admin-sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.admin-sidebar nav a { color: var(--sidebar-text); padding: 9px 10px; border-radius: var(--radius); font-size: .92rem; }
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar { padding: 14px 32px; border-bottom: 1px solid var(--line); background: #fff; font-size: .88rem; color: var(--ink-soft); }
.admin-content { padding: 28px 32px 60px; max-width: 980px; }

.admin-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin: 20px 0 36px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-align: center; }
.stat-card h3 { font-size: 1.8rem; margin-bottom: 2px; }
.stat-card p { margin: 0; color: var(--ink-soft); font-size: .82rem; }

.admin-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 30px; }
.admin-table th, .admin-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.admin-table th { background: #F4F1E8; font-weight: 600; color: var(--ink-soft); font-size: .8rem; }
.admin-table tr:last-child td { border-bottom: none; }

.badge { padding: 2px 9px; border-radius: 20px; font-size: .75rem; }
.badge-green { background: #E4EFE7; color: var(--success); }
.badge-gray { background: #EDEAE0; color: var(--ink-soft); }

.admin-grid-2 { display: grid; grid-template-columns: 1fr 1.3fr; gap: 30px; align-items: start; }
@media (max-width: 900px) { .admin-grid-2 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
.post-form { max-width: 720px; }
.post-form label { display: block; margin: 16px 0 6px; font-size: .85rem; color: var(--ink-soft); }
.checkbox-label { display: flex; align-items: center; gap: 8px; }
.checkbox-label input { width: auto; }
.post-form input[type=text], .post-form input[type=number], .post-form input[type=email],
.post-form select, .post-form textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: .95rem; font-family: var(--sans); background: #fff;
}
.code-textarea { font-family: 'SFMono-Regular', Consolas, monospace; font-size: .85rem; }

.image-picker { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.image-picker input[type=text] { flex: 1; }
.preview-thumb { max-width: 200px; margin-top: 10px; border-radius: var(--radius); display: block; }

/* ---------- Rich text editor ---------- */
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; border: 1px solid var(--line); border-bottom: none;
  background: #F4F1E8; padding: 6px; border-radius: var(--radius) var(--radius) 0 0; }
.editor-toolbar button { background: #fff; border: 1px solid var(--line); border-radius: 2px; padding: 5px 10px; cursor: pointer; font-size: .85rem; }
.editor-toolbar button:hover { background: var(--accent-soft); }
.rte { min-height: 260px; border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px; background: #fff; font-size: .98rem; }
.rte img { max-width: 100%; border-radius: var(--radius); }
.rte:focus { outline: none; border-color: var(--accent); }

@media (max-width: 720px) {
  .admin-wrap { flex-direction: column; }
  .admin-sidebar { width: 100%; }
  .header-inner { flex-direction: column; gap: 12px; }
  .main-nav a { margin: 0 10px; }
}
