@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&family=Inter:wght@400;500&display=swap');

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --border: #e8e0d4;
  --text: #2a2118;
  --text-muted: #7a6a5a;
  --accent: #7a5c43;
  --accent-hover: #5c4432;
  --tag-bg: #f0e8df;
  --tag-text: #6b5040;
  --shadow: 0 2px 8px rgba(42,33,24,.08);
  --shadow-hover: 0 8px 24px rgba(42,33,24,.14);
  --radius: 4px;
  --max-width: 1200px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 28px 24px;
  text-align: center;
}
.site-logo { display: block; margin: 0 auto 16px; max-height: 90px; width: auto; }
.site-header h1 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 600;
  letter-spacing: .04em;
  color: #ad7135;
}
.site-header h1 a { color: inherit; }
.site-tagline {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  color: #ad7135;
  font-size: 1.05rem;
  margin-top: 4px;
}
.header-admin-link {
  position: absolute;
  top: 18px;
  right: 24px;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── Filter bar (persistent toggle row) ── */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 24px;
  display: flex;
  gap: 8px;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 200;
}
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 14px;
  border-radius: 99px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: .8rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.scroll-top-btn {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 99px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.scroll-top-btn:hover { background: var(--accent); color: #fff; }
.filter-btn:hover,
.filter-btn[aria-expanded="true"] {
  background: var(--accent);
  color: #fff;
}
.filter-active-badge {
  display: inline-block;
  background: rgba(255,255,255,.25);
  border-radius: 99px;
  padding: 0 7px;
  font-size: .72rem;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.filter-btn:not([aria-expanded="true"]) .filter-active-badge {
  background: var(--accent);
  color: #fff;
}

/* ── Collapsible tag panel ── */
.tag-filter {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.tag-filter a {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: .8rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.tag-filter a:hover,
.tag-filter a.active {
  background: var(--accent);
  color: #fff;
}

/* ── Collapsible search panel ── */
.frontend-search-wrap {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
}
.frontend-search-form {
  display: flex;
  gap: 8px;
  max-width: var(--max-width);
  margin: 0 auto;
}
.frontend-search-input {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: .9rem;
  background: var(--bg);
  color: var(--text);
}
.frontend-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Grid ── */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

.entries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
  padding: 36px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.card-image {
  display: block;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--bg);
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .3s;
}
.card:hover .card-image img { transform: scale(1.03); }
.card-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: .85rem;
}
.card-body { padding: 18px 20px 20px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.card-date { font-size: .75rem; color: var(--text-muted); }
.card-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
.card-title a { color: inherit; }
.card-title a:hover { color: var(--accent); }
.card-desc { font-size: .88rem; color: var(--text-muted); flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: .75rem;
  font-weight: 500;
}
a.tag:hover { background: var(--accent); color: #fff; }

/* ── Entry page ── */
.entry-wrap { max-width: 860px; margin: 48px auto; padding: 0 24px 80px; }
.back-link { display: inline-block; margin-bottom: 28px; color: var(--text-muted); font-size: .875rem; }
.back-link:hover { color: var(--accent); }
.entry-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 12px;
}
.entry-meta { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.entry-date { font-size: .8rem; color: var(--text-muted); }

/* Gallery */
.gallery-main {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--border);
  cursor: zoom-in;
  margin-bottom: 12px;
}
.gallery-main img { width: 100%; display: block; max-height: 600px; object-fit: contain; background: var(--bg); }
.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 32px; }
.gallery-thumb {
  width: 72px;
  height: 72px;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s;
  flex-shrink: 0;
}
.gallery-thumb.active { border-color: var(--accent); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: contain; background: var(--bg); }
.entry-description { font-size: 1rem; line-height: 1.75; color: var(--text); white-space: pre-wrap; }

/* ── Lightbox ── */
.lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.9);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 95vw; max-height: 95vh; object-fit: contain; }
.lightbox-close {
  position: absolute;
  top: 20px; right: 24px;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  background: none;
  border: none;
  opacity: .8;
}
.lightbox-close:hover { opacity: 1; }
.lightbox-prev, .lightbox-next {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  background: none;
  border: none;
  opacity: .7;
  padding: 16px;
}
.lightbox-prev:hover, .lightbox-next:hover { opacity: 1; }
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 24px 48px;
}
.pagination a, .pagination span {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text-muted);
  background: var(--surface);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 80px 24px; color: var(--text-muted); }
.empty-state p { font-size: 1.05rem; }

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

/* ── Admin ── */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--text);
  padding: 28px 0;
}
.admin-sidebar .brand {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.2rem;
  color: #fff;
  padding: 0 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: block;
}
.admin-sidebar .brand span { font-style: italic; color: rgba(255,255,255,.6); font-size: .85rem; display: block; }
.admin-nav { list-style: none; padding: 16px 0; }
.admin-nav a {
  display: block;
  padding: 10px 20px;
  color: rgba(255,255,255,.75);
  font-size: .875rem;
  transition: color .15s, background .15s;
}
.admin-nav a:hover, .admin-nav a.active { color: #fff; background: rgba(255,255,255,.08); }
.admin-nav-btn { display: block; width: 100%; padding: 10px 20px; color: rgba(255,255,255,.75); font-size: .875rem; background: none; border: none; cursor: pointer; text-align: left; font-family: inherit; transition: color .15s, background .15s; }
.admin-nav-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.admin-main { flex: 1; padding: 36px 40px; overflow-y: auto; }
.admin-main h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 24px;
}
.admin-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.admin-header-row h2 { margin-bottom: 0; }

/* Admin search */
.search-form { display: flex; gap: 8px; margin-bottom: 20px; }
.search-input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; font-size: .9rem; background: var(--surface); color: var(--text); }
.search-input:focus { outline: none; border-color: var(--accent); }
.search-hint { font-size: .85rem; color: var(--text-muted); margin-bottom: 12px; }

/* Admin table */
.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.admin-table th { background: #f5f0ea; text-align: left; padding: 12px 16px; font-size: .8rem; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--accent); }
.admin-table td { padding: 12px 16px; border-top: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
.admin-table tr:hover td { background: #fdf9f5; }
.admin-table .thumb { width: 48px; height: 48px; object-fit: contain; background: var(--bg); border-radius: 3px; }
.admin-table .actions { display: flex; gap: 36px; white-space: nowrap; align-items: center; }
.admin-table .actions a { color: var(--text-muted); font-size: .8rem; }
.admin-table .actions a:hover { color: var(--accent); }
.admin-table .actions .del { color: #c0392b; }
.admin-table .actions .del:hover { color: #922b21; }
.admin-table .actions button { background: none; border: none; padding: 0; cursor: pointer; font: inherit; color: var(--text-muted); font-size: .8rem; }
.admin-table .actions button:hover { color: var(--accent); }
.admin-table .actions button.del { color: #c0392b; }
.admin-table .actions button.del:hover { color: #922b21; }
.status-btn { display: inline-block; font-size: .75rem; font-weight: 500; padding: 2px 8px; border-radius: 20px; border: none; cursor: pointer; font-family: inherit; }
.status-published { background: #e6f4ea; color: #1e7e34; }
.status-draft { background: #f0f0f0; color: #777; }
.status-published:hover { background: #d4edda; }
.status-draft:hover { background: #e2e2e2; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d5cab8; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #922b21; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-group input[type=datetime-local] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.date-toggle-label {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
}
.date-toggle-label input[type=checkbox] { width: auto; margin: 0; cursor: pointer; }
.form-group input[type=text],
.form-group input[type=password],
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 120px; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

/* Image upload preview */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s;
  position: relative;
}
.upload-area:hover { border-color: var(--accent); }
.upload-area input[type=file] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-area-text { color: var(--text-muted); font-size: .9rem; pointer-events: none; }
.upload-area-text strong { display: block; color: var(--accent); margin-bottom: 4px; }

.image-previews { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.image-preview-item {
  position: relative;
  width: 90px; height: 90px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.image-preview-item img { width: 100%; height: 100%; object-fit: contain; background: var(--bg); }
.image-preview-item .remove-preview {
  position: absolute; top: 3px; right: 3px;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* Existing images in edit */
.existing-images { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.existing-image-item {
  position: relative;
  width: 90px; height: 90px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.existing-image-item img { width: 100%; height: 100%; object-fit: contain; background: var(--bg); }
.existing-image-item .del-img-btn {
  position: absolute; top: 3px; right: 3px;
  background: rgba(192,57,43,.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Description icon + overlay */
.desc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  background: none;
  cursor: pointer;
  font-style: italic;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: .95rem;
  font-weight: 600;
  line-height: 1;
  flex-shrink: 0;
  transition: background .15s, color .15s;
  vertical-align: middle;
}
.desc-btn:hover { background: var(--accent); color: #fff; }
.desc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(42, 33, 24, .55);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.desc-overlay.open { display: flex; }
.desc-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 36px;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(42,33,24,.25);
  position: relative;
}
.desc-box-text {
  white-space: pre-wrap;
  line-height: 1.75;
  font-size: 1rem;
  color: var(--text);
}
.desc-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.desc-close:hover { color: var(--text); }

/* Tag autocomplete */
.tag-ac-wrap { position: relative; display: block; }
.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  max-height: 180px;
  overflow-y: auto;
}
.tag-suggestion {
  padding: 8px 12px;
  font-size: .9rem;
  cursor: pointer;
  color: var(--text);
}
.tag-suggestion:hover,
.tag-suggestion.active { background: var(--tag-bg); color: var(--tag-text); }

/* Alert */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: .9rem; }
.alert-error { background: #fdf0ef; color: #c0392b; border: 1px solid #f5c6c2; }
.alert-success { background: #edfaf1; color: #1e8449; border: 1px solid #b7e4c7; }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.login-box h1 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.login-box .sub { color: var(--text-muted); font-size: .85rem; margin-bottom: 28px; }

/* Setup page */
.setup-wrap { max-width: 680px; margin: 60px auto; padding: 0 24px; }
.setup-wrap h1 { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 2rem; margin-bottom: 8px; }
.setup-wrap .sub { color: var(--text-muted); margin-bottom: 32px; }
.setup-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); margin-bottom: 24px; }
.setup-card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }
pre.setup-code {
  background: #2a2118;
  color: #f0e8df;
  border-radius: var(--radius);
  padding: 16px;
  font-size: .82rem;
  overflow-x: auto;
  margin: 12px 0;
}

@media (max-width: 768px) {
  .entries-grid { grid-template-columns: 1fr; gap: 20px; padding: 20px 16px; }
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; }
  .admin-main { padding: 24px 16px; }
  .entry-wrap { margin: 24px auto; }
}
