:root {
  --bg: #0d0f12;
  --bg-raised: #14181d;
  --bg-sunken: #090b0e;
  --border: #232a32;
  --border-strong: #303945;
  --text: #e8edf3;
  --text-muted: #94a2b3;
  --accent: #e0662a;
  --accent-soft: rgba(224, 102, 42, 0.14);
  --radius: 12px;
  --wrap: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: inherit; }

img, video { max-width: 100%; height: auto; display: block; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  z-index: 20;
}
.skip:focus { left: 0; }

/* Header ------------------------------------------------------------------ */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(13, 15, 18, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  font-size: 1.05rem;
}
.brand img { border-radius: 8px; }
.site-nav { display: flex; gap: 20px; font-size: 0.92rem; }
.site-nav a { color: var(--text-muted); text-decoration: none; }
.site-nav a:hover { color: var(--text); }

main { flex: 1; padding: 32px 20px 64px; }

/* Hero -------------------------------------------------------------------- */
.hero { padding: 28px 0 32px; }
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.hero p { margin: 0; color: var(--text-muted); }
.hero-compact { padding: 12px 0 24px; }

.search { display: flex; gap: 8px; margin-top: 20px; max-width: 460px; }
.search input {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search button {
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  color: #fff;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.result-count { color: var(--text-muted); margin: 0 0 20px; font-size: 0.92rem; }

/* Grid -------------------------------------------------------------------- */
.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.card-link { text-decoration: none; color: inherit; display: flex; flex-direction: column; flex: 1; }
.card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg-sunken);
  overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media-empty {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #14181d 0%, #1d242c 100%);
}
.badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(9, 11, 14, 0.85);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.75rem;
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 6px;
}
.badge-count { left: auto; right: 10px; }
.card-body { padding: 16px 16px 12px; flex: 1; }
.card-body h2 { margin: 0 0 6px; font-size: 1.05rem; letter-spacing: -0.01em; line-height: 1.35; }
.card-body p { margin: 0 0 12px; color: var(--text-muted); font-size: 0.9rem; }
.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--mono);
}
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 16px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  border: 1px solid rgba(224, 102, 42, 0.28);
  color: #f3a173;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  text-decoration: none;
}
.pill:hover { border-color: var(--accent); }
.pill span { color: var(--text-muted); font-family: var(--mono); }
.pill-draft { background: rgba(148, 162, 179, 0.12); border-color: var(--border-strong); color: var(--text-muted); }

.empty { color: var(--text-muted); padding: 40px 0; text-align: center; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.page-link {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  text-decoration: none;
  background: var(--bg-raised);
}
.page-link:hover { border-color: var(--border-strong); }

.tag-cloud { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }

/* Post -------------------------------------------------------------------- */
.post { max-width: 820px; margin: 0 auto; }
.post-header { margin-bottom: 28px; }
.post-header h1 {
  margin: 0 0 12px;
  font-size: clamp(1.7rem, 3.6vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--mono);
}
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

.gallery { display: flex; flex-direction: column; gap: 24px; margin-bottom: 32px; }
.media { margin: 0; }
.media img, .media video {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
}
.media-image a { display: block; cursor: zoom-in; }
.media audio { width: 100%; }
.media figcaption { color: var(--text-muted); font-size: 0.85rem; margin-top: 8px; }
.file-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
}
.file-link:hover { border-color: var(--border-strong); }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-size { color: var(--text-muted); font-family: var(--mono); font-size: 0.85rem; }

.prose { font-size: 1.02rem; }
.prose h2, .prose h3, .prose h4 { letter-spacing: -0.02em; margin: 32px 0 10px; line-height: 1.25; }
.prose p { margin: 0 0 18px; }
.prose a { color: #f3a173; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 18px; }
.prose li { margin-bottom: 6px; }
.prose blockquote {
  margin: 0 0 18px;
  padding: 4px 18px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}
.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}
.prose pre {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
}
.prose pre code { background: none; border: 0; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.prose img { border-radius: var(--radius); border: 1px solid var(--border); }

/* Lightbox ---------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 8, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  z-index: 50;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}

/* Footer ------------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.footer-inner a { color: var(--text-muted); text-decoration: none; }
.footer-inner a:hover { color: var(--text); }

@media (max-width: 600px) {
  main { padding: 20px 16px 48px; }
  .wrap { padding: 0 16px; }
  .grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
