/* ── Variables ───────────────────────────────────────────────────────────────── */
:root {
  --bg:           #f7f4f0;
  --surface:      #ffffff;
  --border:       #e4dbd0;
  --text:         #1c1a18;
  --text-muted:   #6e6259;
  --primary:      #5c7a6b;
  --primary-dark: #496259;
  --primary-fg:   #ffffff;
  --danger:       #b55353;
  --nav-bg:       #1e1c1a;
  --nav-text:     #ede9e3;
  --nav-hover:    #ffffff;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 3px rgba(0,0,0,.07), 0 6px 18px rgba(0,0,0,.06);
  --font-serif:   'Lora', Georgia, 'Times New Roman', serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
a { text-decoration: none; color: inherit; }
textarea { resize: vertical; }

/* ── Typography ──────────────────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; line-height: 1.25; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.25rem;
  font-size: .875rem;
  font-weight: 500;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-fg);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: rgba(0,0,0,.05); color: var(--text); }
.btn-full { width: 100%; }
.btn-sm { padding: .35rem .85rem; font-size: .8125rem; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .35rem; }
label { font-size: .8125rem; font-weight: 500; color: var(--text-muted); }
input[type=text], input[type=password], textarea {
  width: 100%;
  padding: .6rem .8rem;
  font-family: var(--font-sans);
  font-size: .9375rem;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(92, 122, 107, .15);
}

.error-msg {
  font-size: .8125rem;
  color: var(--danger);
  min-height: 1rem;
}

/* ── Navbar ──────────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 56px;
  background: var(--nav-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.nav-brand {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--nav-text);
  letter-spacing: .01em;
}
.nav-brand:hover { color: var(--nav-hover); }
.nav-links { display: flex; align-items: center; gap: .5rem; }
.nav-link {
  padding: .35rem .7rem;
  font-size: .875rem;
  color: rgba(237, 233, 227, .7);
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--nav-text); background: rgba(255,255,255,.08); }
.nav-link.active { color: var(--nav-text); font-weight: 500; }
.navbar .btn-ghost { color: rgba(237, 233, 227, .7); }
.navbar .btn-ghost:hover { color: var(--nav-text); background: rgba(255,255,255,.08); }

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}
.page-title {
  font-size: 1.75rem;
  color: var(--text);
}

/* ── Login Page ──────────────────────────────────────────────────────────────── */
.login-page { background: var(--bg); }
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.brand {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}
.login-tagline {
  text-align: center;
  color: var(--text-muted);
  font-size: .9375rem;
  margin-top: -.75rem;
}
#login-form { display: flex; flex-direction: column; gap: 1rem; }

/* ── Blog Posts ──────────────────────────────────────────────────────────────── */
#posts-list { display: flex; flex-direction: column; gap: 1.25rem; }
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.post-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .35rem;
}
.post-title {
  font-size: 1.2rem;
  color: var(--text);
  flex: 1;
}
.post-meta {
  font-size: .8125rem;
  color: var(--text-muted);
  margin-bottom: .85rem;
}
.post-body {
  font-size: .9375rem;
  line-height: 1.7;
  color: var(--text);
}

/* ── Icon Button ─────────────────────────────────────────────────────────────── */
.icon-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: .75rem;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
}
.post-card:hover .icon-btn { opacity: 1; }
.icon-btn:hover { background: rgba(181,83,83,.12); color: var(--danger); }

/* ── Photos Grid ─────────────────────────────────────────────────────────────── */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
}
.photo-tile {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--border);
  border: 1px solid var(--border);
}
.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .2s, opacity .2s;
}
.photo-tile:hover img { transform: scale(1.04); opacity: .9; }

/* ── Upload Banner ───────────────────────────────────────────────────────────── */
.upload-banner {
  background: var(--primary);
  color: var(--primary-fg);
  text-align: center;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1rem;
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}
.modal-box {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  padding: 2rem;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.modal-title { font-size: 1.25rem; }
#post-form { display: flex; flex-direction: column; gap: 1rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .75rem; margin-top: .25rem; }

/* ── Lightbox ────────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}
.lightbox[hidden] { display: none; }
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.88);
}
#lb-img {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 80vh;
  border-radius: var(--radius-sm);
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }
.lightbox-delete {
  position: relative;
  z-index: 1;
  padding: .45rem 1.1rem;
  border: 1.5px solid rgba(255,255,255,.3);
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255,255,255,.75);
  font-size: .8125rem;
  transition: background .15s, color .15s, border-color .15s;
}
.lightbox-delete:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* ── Empty / Loading States ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  grid-column: 1 / -1;
}
.empty-icon { font-size: 2.5rem; display: block; margin-bottom: .75rem; }
.empty-state p { font-size: .9375rem; line-height: 1.6; }
.loading-text { color: var(--text-muted); padding: 3rem 0; text-align: center; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .navbar { padding: 0 1rem; }
  .container { padding: 1.5rem 1rem 3rem; }
  .photos-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .modal-box { padding: 1.5rem; }
}
