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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #e63946;
  --accent-blue: #388bfd;
  --accent-hover: #ff6b6b;
}

html.light {
  --bg: #ffffff;
  --surface: #f6f8fa;
  --surface-2: #eaeef2;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #636e7b;
  --accent: #0969da;
  --accent-blue: #0550ae;
  --accent-hover: #1a7fd4;
}

/* Light mode element overrides */
html.light .tag {
  background: rgba(9, 105, 218, 0.1);
  color: #0969da;
  border-color: rgba(9, 105, 218, 0.3);
}

html.light .tag--blue {
  background: rgba(5, 80, 174, 0.1);
  color: #0550ae;
  border-color: rgba(5, 80, 174, 0.3);
}

html.light .risk-block {
  background: rgba(9, 105, 218, 0.06);
  border-left-color: #0969da;
}

html.light .risk-block h3 {
  color: #0969da;
}

html.light .brand-svg polygon {
  fill: #0969da;
}

html.light .post-content {
  color: #1f2328;
}

html.light .site-tagline {
  color: #636e7b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main, .post-wrap, .archive-wrap {
  flex: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Header ─────────────────────────────────────────── */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem 1rem;
  background: var(--surface);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-svg {
  height: 2.2rem;
  width: auto;
  border-radius: 4px;
  flex-shrink: 0;
}

.site-brand h1 a {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.site-brand h1 a:hover {
  color: var(--accent);
}

nav {
  display: flex;
  gap: 1.5rem;
}

nav a {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

nav a:hover {
  color: var(--text);
}

.site-tagline {
  max-width: 1100px;
  margin: 0.75rem auto 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Main layout ─────────────────────────────────────── */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

/* ── Cards ───────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* Featured post */
.featured-post {
  margin-bottom: 2rem;
}

.card--featured {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 700px) {
  .card--featured {
    grid-template-columns: 1fr;
  }
}

/* Post grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* Card image */
.card-image {
  position: relative;
  background: #0d1117;
  min-height: 240px;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 240px;
}

.card-image-placeholder svg {
  width: 100%;
  height: 100%;
}

/* Card body */
.card-body {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-body h2 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}

.card-body h2 a:hover {
  color: var(--accent);
}

.card--featured .card-body h2 {
  font-size: 1.35rem;
}

.excerpt {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tags */
.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  background: rgba(230, 57, 70, 0.15);
  color: var(--accent);
  border: 1px solid rgba(230, 57, 70, 0.3);
  width: fit-content;
}

.tag--blue {
  background: rgba(56, 139, 253, 0.15);
  color: var(--accent-blue);
  border-color: rgba(56, 139, 253, 0.3);
}

/* Meta */
.meta {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Read more */
.read-more {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: auto;
  transition: color 0.2s;
}

.read-more:hover {
  color: var(--accent-hover);
}

/* ── Footer ──────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Search & filter ─────────────────────────────────── */

.search-bar {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#search-input {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

#search-input::placeholder {
  color: var(--text-muted);
}

#search-input:focus {
  border-color: var(--accent);
}

.tag-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filter-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.active {
  background: rgba(230, 57, 70, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.no-results {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 2rem 0;
  text-align: center;
}

/* ── Post page ───────────────────────────────────────── */

.post-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

.post-wrap .tag {
  margin-bottom: 0.5rem;
}

.post-wrap h1 {
  font-size: 1.9rem;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.post-wrap .meta {
  margin-bottom: 2rem;
}

.post-hero {
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
}

.post-hero svg,
.post-hero img {
  width: 100%;
  display: block;
}

.post-content {
  font-size: 1rem;
  line-height: 1.8;
  color: #cdd9e5;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content h2 {
  font-size: 1.2rem;
  margin: 2rem 0 0.75rem;
  color: var(--text);
}

.post-content img {
  max-width: 100%;
  border-radius: 6px;
  margin: 1.25rem 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--text);
}

/* ── Archive page ────────────────────────────────────── */

.archive-wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

.archive-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.archive-header h1 {
  font-size: 1.4rem;
}

.archive-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.archive-list {
  list-style: none;
  margin: 1.5rem 0 0;
}

.archive-item {
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--border);
}

.archive-item:last-child {
  border-bottom: none;
}

.archive-item-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.archive-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.archive-tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.archive-item h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.archive-item h2 a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
}

.archive-item h2 a:hover {
  color: var(--accent);
}

.archive-item p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pagination {
  display: flex;
  gap: 0.4rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.page-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.page-btn.active {
  background: rgba(230, 57, 70, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Code blocks ─────────────────────────────────────── */

.post-content pre {
  background: #010409;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  font-size: 0.78rem;
  line-height: 1.65;
}

.post-content code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  color: #cdd9e5;
}

.post-content p code {
  background: #010409;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-size: 0.85em;
  color: var(--accent-blue);
}

.detection {
  margin-bottom: 2.5rem;
}

.detection-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.detection-header h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
  flex: 1;
}

.tag-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.risk-block {
  background: rgba(230, 57, 70, 0.07);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.risk-block h3 {
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.risk-block p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}
