:root {
  --black:      #000000;
  --white:      #ffffff;
  --off-white:  #f5f5f5;
  --grey-100:   #e8e8e8;
  --grey-200:   #d0d0d0;
  --grey-400:   #888888;
  --grey-600:   #555555;
  --grey-800:   #222222;
  --grey-900:   #111111;
  --accent:     #f0c800;
  --accent-soft: #fff7c2;
  --f-serif:    'Instrument Serif', Georgia, serif;
  --f-sans:     'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --f-mono:     'Space Mono', ui-monospace, monospace;
  --ease:       cubic-bezier(0.16, 1, 0.3, 1);
}
:root, [data-theme="light"] {
  --bg:           var(--off-white);
  --card:         var(--white);
  --card-2:       #ececec;
  --text:         var(--black);
  --text-2:       var(--grey-800);
  --subtext:      var(--grey-400);
  --dim:          var(--grey-600);
  --border:       var(--grey-100);
  --border-strong: var(--grey-200);
  --input-bg:     var(--white);
  --input-border: var(--grey-200);
  --pill-bg:      var(--grey-100);
  --pill-text:    var(--grey-800);
}
[data-theme="dark"] {
  --bg:           var(--black);
  --card:         var(--grey-900);
  --card-2:       #1a1a1a;
  --text:         var(--white);
  --text-2:       var(--grey-200);
  --subtext:      #b0b0b0;
  --dim:          #999999;
  --border:       var(--grey-800);
  --border-strong: #3a3a3a;
  --input-bg:     #0d0d0d;
  --input-border: #2a2a2a;
  --pill-bg:      var(--grey-800);
  --pill-text:    var(--grey-200);
  --accent-soft:  #2a2308;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
html, body {
  min-height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--f-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background .3s var(--ease), color .3s var(--ease);
}
body {
  display: flex; flex-direction: column;
  position: relative; overflow-x: hidden;
}
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 9998;
  pointer-events: none; opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}
::selection { background: var(--text); color: var(--bg); }
a { color: var(--text); }
img { max-width: 100%; height: auto; }

/* ---------- TOPP-META ---------- */
.top-meta {
  display: flex; gap: 14px; align-items: center;
  flex-wrap: wrap;
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.04em;
  color: var(--dim);
  padding: 24px 32px 0;
  max-width: 1100px; width: 100%; margin: 0 auto;
}
@media (max-width: 720px) { .top-meta { padding: 16px 16px 0; } }
.top-meta a {
  color: var(--dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.top-meta a:hover { color: var(--text); border-color: var(--text); }
.top-meta .sep { opacity: .5; }
.top-meta .spacer { flex: 1; }

button.theme-btn {
  background: transparent; color: var(--text);
  border: 1px solid var(--text); border-radius: 0;
  padding: 8px 14px; cursor: pointer;
  font-family: var(--f-sans); font-size: 11px;
  font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background .2s var(--ease), color .2s var(--ease);
}
button.theme-btn:hover { background: var(--text); color: var(--bg); }

/* ---------- HERO (index) ---------- */
.hero {
  padding: 80px 32px 40px;
  max-width: 1100px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px;
}
@media (max-width: 720px) { .hero { padding: 48px 16px 32px; gap: 16px; } }
.hero h1 {
  font-family: var(--f-serif);
  font-size: clamp(56px, 9vw, 110px);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 0.95;
}
.hero .lede {
  font-family: var(--f-serif);
  font-style: italic;
  font-size: clamp(20px, 2.4vw, 26px);
  line-height: 1.4;
  color: var(--text-2);
  max-width: 720px;
}

/* ---------- POSTLISTA ---------- */
.post-list {
  max-width: 1100px; width: 100%; margin: 0 auto;
  padding: 24px 32px 64px;
}
@media (max-width: 720px) { .post-list { padding: 16px 16px 40px; } }

.tag-filter {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.tag-pill {
  display: inline-block;
  padding: 4px 10px;
  font-family: var(--f-mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  text-decoration: none;
  transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.tag-pill:hover { color: var(--text); border-color: var(--text); }
.tag-pill.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.post-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  align-items: start;
  transition: opacity .15s var(--ease);
}
.post-card.no-cover { grid-template-columns: 1fr; }
.post-card:hover { opacity: .75; }
@media (max-width: 600px) {
  .post-card { grid-template-columns: 1fr; gap: 14px; }
}

.post-cover {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--card-2);
}

.post-meta-row {
  font-family: var(--f-mono);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 8px;
}
.post-meta-row .sep { opacity: .4; }

.post-card h2 {
  font-family: var(--f-serif);
  font-size: clamp(28px, 3.4vw, 38px);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.05;
  margin-bottom: 10px;
}

.post-card .excerpt {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-2);
  max-width: 620px;
}

.post-card .read-more {
  display: inline-block;
  margin-top: 12px;
  font-family: var(--f-mono);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
  border-bottom: 1px solid var(--text);
  padding-bottom: 1px;
}

.empty-state {
  padding: 80px 0;
  text-align: center;
  font-family: var(--f-serif);
  font-style: italic;
  font-size: 22px;
  color: var(--dim);
}

/* ---------- ENSKILT INLÄGG ---------- */
article.post-view {
  max-width: 760px; width: 100%; margin: 0 auto;
  padding: 56px 32px 64px;
}
@media (max-width: 720px) { article.post-view { padding: 32px 16px 48px; } }

.post-view .back-link {
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 32px;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.post-view .back-link:hover { color: var(--text); border-color: var(--text); }

.post-view header.post-header {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.post-view header.post-header h1 {
  font-family: var(--f-serif);
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin-bottom: 14px;
}

.post-view .post-cover-large {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--border);
  margin-bottom: 32px;
  background: var(--card-2);
}

.post-body {
  font-family: var(--f-serif);
  font-size: 19px;
  line-height: 1.65;
  color: var(--text);
}
.post-body p { margin-bottom: 22px; }
.post-body h2 {
  font-family: var(--f-serif);
  font-size: 32px; font-weight: 400;
  letter-spacing: -0.015em;
  margin-top: 40px; margin-bottom: 14px;
  line-height: 1.15;
}
.post-body h3 {
  font-family: var(--f-serif);
  font-size: 24px; font-weight: 400;
  letter-spacing: -0.01em;
  margin-top: 32px; margin-bottom: 10px;
  line-height: 1.2;
}
.post-body h4 {
  font-family: var(--f-mono);
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  margin-top: 28px; margin-bottom: 8px;
}
.post-body a {
  color: var(--text);
  border-bottom: 1px solid var(--text);
  text-decoration: none;
  padding-bottom: 1px;
}
.post-body ul, .post-body ol {
  margin: 0 0 22px 24px;
}
.post-body li { margin-bottom: 6px; }
.post-body blockquote {
  border-left: 3px solid var(--text);
  padding: 4px 0 4px 18px;
  margin: 0 0 22px 0;
  font-style: italic;
  color: var(--text-2);
}
.post-body img {
  display: block;
  width: 100%;
  height: auto;
  margin: 28px 0;
  border: 1px solid var(--border);
}
.post-body figure {
  margin: 28px 0;
}
.post-body figure img { margin: 0; }
.post-body figcaption {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--dim);
  margin-top: 8px;
  text-align: center;
}
.post-body code {
  font-family: var(--f-mono);
  font-size: 14px;
  background: var(--card-2);
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
}
.post-body pre {
  font-family: var(--f-mono);
  font-size: 13px;
  background: var(--card-2);
  border: 1px solid var(--border-strong);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 22px 0;
  line-height: 1.5;
}
.post-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
}
.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.post-view footer.post-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 8px;
}

.draft-banner {
  background: var(--accent);
  color: #000;
  padding: 8px 14px;
  font-family: var(--f-mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 24px;
  text-align: center;
}

/* ---------- FOOTER ---------- */
footer.page-footer {
  border-top: 1px solid var(--border);
  padding: 28px 32px;
  max-width: 1100px; width: 100%; margin: 0 auto;
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--dim);
  letter-spacing: 0.02em;
  line-height: 1.7;
  text-align: center;
}
footer.page-footer a {
  color: var(--text);
  border-bottom: 1px solid var(--text);
  text-decoration: none;
  padding-bottom: 1px;
}
@media (max-width: 720px) { footer.page-footer { padding: 22px 16px; } }

/* ---------- 404 ---------- */
.nf-wrap {
  min-height: 80vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 24px;
  gap: 18px;
  text-align: center;
}
.nf-wrap .nf-num {
  font-family: var(--f-serif);
  font-size: clamp(80px, 14vw, 160px);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
}
.nf-wrap .nf-text {
  font-family: var(--f-serif);
  font-style: italic;
  font-size: 22px;
  color: var(--text-2);
  max-width: 480px;
}
.nf-wrap .nf-link {
  margin-top: 8px;
  padding: 12px 22px;
  background: var(--text); color: var(--bg);
  border: 1px solid var(--text);
  font-family: var(--f-sans); font-size: 11px;
  font-weight: 500; letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nf-wrap .nf-link:hover { background: transparent; color: var(--text); }

/* ---------- LOADING SKELETON ---------- */
.loading {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  text-align: center;
  padding: 40px 0;
}
