:root {
  --bg: #17141A;
  --surface: rgba(33, 28, 38, 0.55);
  --surface-solid: #211C26;
  --ink: #F3EDF2;
  --ink-soft: #A79DAA;
  --accent: #E8547E;
  --accent-2: #d4436c;
  --accent-glow: rgba(232, 84, 126, 0.35);
  --accent-ink: #1C1017;
  --line: rgba(255, 255, 255, 0.08);
  --thumb-bg: #3A2530;
  --radius: 20px;
  --danger: #F0938E;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(232, 84, 126, 0.10), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(169, 114, 240, 0.08), transparent 35%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 480px) { .wrap { padding: 0 16px; } }

/* ---- Header ---- */
header.site-header {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(23, 20, 26, 0.65);
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand a.logo { font-family: "Space Grotesk", "Inter", sans-serif; font-weight: 700; font-size: 20px; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; position: relative; display: inline-block; }
.brand a.logo::after {
  content: ""; display: block; width: 30px; height: 3px; margin-top: 6px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), #A972F0);
}
.brand .tagline { color: var(--ink-soft); font-size: 13px; }

main { padding: 40px 0 80px; }

/* ---- Feed grid ---- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 18px; } }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; gap: 16px; } }

.card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1), box-shadow 0.35s ease, border-color 0.3s ease;
}
.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 40px -20px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--accent-glow);
  border-color: rgba(232, 84, 126, 0.4);
}

.card a.card-link { text-decoration: none; color: inherit; display: flex; flex-direction: column; }

.card .thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  background: var(--thumb-bg);
}
.card .thumb::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), transparent 45%);
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.35s ease; }
.card:hover .thumb img { transform: scale(1.04); }

.card .date-tag {
  position: absolute;
  top: 10px;
  left: 8px;
  z-index: 1;
  background: rgba(23, 20, 26, 0.7);
  backdrop-filter: blur(4px);
  color: var(--ink);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
}

.card h2 { font-family: "Space Grotesk", "Inter", sans-serif; font-weight: 500; font-size: 18px; line-height: 1.35; margin: 0; letter-spacing: -0.005em; color: var(--ink); }
.card .body { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px 18px; }
.card p.desc { margin: 0; color: var(--ink-soft); font-size: 14.5px; line-height: 1.55; }
.read-more-hint { color: var(--accent); font-weight: 600; white-space: nowrap; }
.empty { color: var(--ink-soft); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  align-self: flex-start;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -8px var(--accent-glow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: default; }

.card .btn { align-self: stretch; justify-content: center; font-size: 14.5px; font-weight: 700; padding: 11px 20px; }

.post-page-inner .btn {
  font-size: 17px;
  font-weight: 700;
  padding: 16px 36px;
  box-shadow: 0 8px 26px -6px var(--accent-glow);
}
.post-page-inner .btn:hover { box-shadow: 0 12px 30px -6px var(--accent-glow); }

/* ---- Post page ---- */
.post-page main { padding-top: 44px; }
.post-page-inner { max-width: 560px; }

.post-media { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin: 0 0 24px; }

.post-hero {
  width: 260px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--thumb-bg);
  margin: 0;
  box-shadow: 0 24px 40px -20px rgba(0, 0, 0, 0.6);
  flex: none;
}
.post-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }

.post-meta { color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.post-title { font-family: "Space Grotesk", "Inter", sans-serif; font-size: clamp(26px, 4vw, 36px); line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 12px; color: var(--ink); }
.post-desc-wrap { max-width: 480px; margin: 0 0 22px; }
.post-desc { font-size: 16.5px; line-height: 1.65; color: var(--ink-soft); margin: 0; }
.post-desc.desc-clamped { max-height: 108px; overflow: hidden; }
.read-more-btn {
  background: none; border: none; color: var(--accent); font-weight: 600; font-size: 13px;
  cursor: pointer; padding: 0; margin-top: 8px; display: none; align-items: center;
}
.read-more-btn:hover { text-decoration: underline; }
.back-link { display: inline-block; margin-bottom: 22px; color: var(--ink-soft); text-decoration: none; font-size: 13px; }
.back-link:hover { color: var(--ink); }

footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--ink-soft); font-size: 12px; }

/* ---- Search + tags ---- */
.search-form { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.search-form input[type="text"] {
  flex: none; width: 200px; max-width: 100%; padding: 10px 16px; border-radius: 999px;
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); color: var(--ink);
  font-family: inherit; font-size: 14px;
  transition: width 0.3s cubic-bezier(.4,0,.2,1), border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-form input[type="text"]:focus { width: 280px; outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.search-form input[type="text"]::placeholder { color: var(--ink-soft); }
@media (max-width: 480px) {
  .search-form input[type="text"] { width: 130px; }
  .search-form input[type="text"]:focus { width: 190px; }
}
.filter-note { color: var(--ink-soft); font-size: 13px; margin: -10px 0 18px; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pill {
  font-size: 11px; color: var(--ink-soft); background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.tag-pill:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Admin ---- */
body.admin-page { }
.admin-narrow { max-width: 420px; padding-top: 64px; }
.stack-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.stack-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.stack-form input, .stack-form textarea {
  font-family: inherit; font-size: 15px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-solid); color: var(--ink);
}
.stack-form input:focus, .stack-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.error { color: var(--danger); font-size: 14px; }
.form-msg { color: var(--danger); font-size: 13px; min-height: 18px; }
.link-btn { background: none; border: none; color: var(--ink-soft); text-decoration: underline; cursor: pointer; font-size: 14px; padding: 0; }

.new-post-box {
  background: var(--surface); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; max-width: 420px; margin-bottom: 48px;
}
.preview-img { max-width: 160px; aspect-ratio: 1/1; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }

.post-table { width: 100%; border-collapse: collapse; }
.post-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; color: var(--ink); }
.thumb-sm { width: 48px; height: 48px; object-fit: cover; border-radius: 10px; display: block; }
.row-sub { color: var(--ink-soft); font-size: 12px; }
.btn-del { background: none; border: 1px solid var(--line); color: var(--danger); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; transition: background 0.15s ease; }
.btn-del:hover { background: rgba(240, 147, 142, 0.12); }

/* ---- Extra images on a post's own page ---- */
.post-gallery { display: flex; flex-direction: column; gap: 8px; flex: none; }
.gallery-thumb {
  display: block; width: 70px; height: 70px; padding: 0; margin: 0;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--thumb-bg);
  cursor: pointer; transition: transform 0.2s ease, border-color 0.2s ease;
}
.gallery-thumb:hover { transform: scale(1.06); border-color: var(--accent); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 480px) {
  .post-media { flex-direction: column; }
  .post-gallery { flex-direction: row; flex-wrap: wrap; }
}

/* ---- Editing an existing post's extra images ---- */
.gallery-edit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gallery-edit-item { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--ink-soft); cursor: default; }
.gallery-edit-item img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.gallery-edit-item span { display: flex; align-items: center; gap: 5px; }

/* ---- Edit link on the dashboard ---- */
.btn-edit {
  background: none; border: 1px solid var(--line); color: var(--ink-soft); padding: 6px 12px;
  border-radius: 999px; cursor: pointer; font-size: 13px; text-decoration: none; display: inline-block;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-edit:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Lightbox for extra images ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 8, 12, 0.75);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  padding: 24px;
}
.lightbox.open { opacity: 1; visibility: visible; }
.lightbox img {
  max-width: min(90vw, 720px); max-height: 85vh;
  border-radius: 16px; border: 1px solid var(--line);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
  transform: scale(0.94);
  transition: transform 0.25s cubic-bezier(.2,.8,.2,1);
}
.lightbox.open img { transform: scale(1); }
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  width: 40px; height: 40px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); color: var(--ink);
  font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.15); border-color: var(--accent); }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 40px; }
.page-link {
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600;
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); padding: 9px 18px; border-radius: 999px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.page-link:hover { border-color: var(--accent); color: var(--accent); }
.page-status { color: var(--ink-soft); font-size: 13px; }
