@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --fg: #1a1a1a;
  --fg-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-light: #eff6ff;
  --nav-bg: #1e293b;
  --nav-fg: #f1f5f9;
  --nav-fg-muted: #94a3b8;
  --nav-hover: #334155;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,.1);
  --tag-bg: #eff6ff;
  --tag-fg: #1d4ed8;
  --code-bg: #f3f4f6;
  --hero-bg: #1e293b;
  --hero-fg: #f1f5f9;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --fg: #e2e8f0;
  --fg-muted: #94a3b8;
  --border: #334155;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-light: #1e3a5f;
  --nav-bg: #020617;
  --nav-fg: #f1f5f9;
  --nav-fg-muted: #94a3b8;
  --nav-hover: #1e293b;
  --card-bg: #1e293b;
  --card-shadow: 0 1px 3px rgba(0,0,0,.3);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,.4);
  --tag-bg: #1e3a5f;
  --tag-fg: #93c5fd;
  --code-bg: #1e293b;
  --hero-bg: #020617;
  --hero-fg: #f1f5f9;
}

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

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  line-height: 1.7;
  transition: background .2s, color .2s;
}

/* ── Nav ── */
.site-nav {
  background: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--nav-fg);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.02em;
}
.nav-logo img { height: 32px; background: #fff; border-radius: 4px; padding: 2px; }
.nav-links {
  display: flex;
  gap: .25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  color: var(--nav-fg-muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  padding: .4rem .8rem;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.nav-links a:hover, .nav-links a.active {
  background: var(--nav-hover);
  color: var(--nav-fg);
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--nav-fg-muted);
  padding: .4rem;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  transition: background .15s, color .15s;
}
.theme-toggle:hover { background: var(--nav-hover); color: var(--nav-fg); }

/* ── Hero ── */
.hero {
  background: var(--hero-bg);
  color: var(--hero-fg);
  padding: 4rem 1.5rem;
  text-align: center;
}
.hero-inner { max-width: 760px; margin: 0 auto; }
.hero img { height: 64px; margin-bottom: 1.5rem; background: #fff; border-radius: 8px; padding: 6px; }
.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 1rem;
  letter-spacing: -.03em;
  line-height: 1.2;
}
.hero p {
  font-size: 1.15rem;
  opacity: .8;
  margin: 0 0 2rem;
  max-width: 580px;
  margin-left: auto;
  margin-right: auto;
}
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .65rem 1.4rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-outline { background: transparent; color: var(--hero-fg); border: 2px solid rgba(255,255,255,.3); }
.btn-outline:hover { border-color: rgba(255,255,255,.7); }

/* ── Layout ── */
.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}
.content-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 2.5rem;
  align-items: start;
}
@media (max-width: 800px) {
  .content-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
.main-content { min-width: 0; }

/* ── Feature cards (home) ── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2.5rem 0;
}
.feature-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: var(--card-shadow);
  transition: box-shadow .2s, transform .2s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.feature-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}
.feature-card-icon {
  font-size: 2rem;
  margin-bottom: .75rem;
}
.feature-card h3 {
  margin: 0 0 .5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}
.feature-card p {
  margin: 0;
  font-size: .9rem;
  color: var(--fg-muted);
  line-height: 1.5;
}

/* ── Section intro ── */
.section-header { margin-bottom: 2rem; }
.section-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 .5rem;
  letter-spacing: -.02em;
}
.section-header p { color: var(--fg-muted); margin: 0; }
.divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ── Post cards ── */
.post-list { display: flex; flex-direction: column; gap: 1.25rem; }
.post-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: box-shadow .2s, transform .2s;
}
.post-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}
.post-card-meta {
  font-size: .8rem;
  color: var(--fg-muted);
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.post-card h2 {
  margin: 0 0 .6rem;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.35;
}
.post-card h2 a {
  color: var(--fg);
  text-decoration: none;
  transition: color .15s;
}
.post-card h2 a:hover { color: var(--accent); }
.post-card p {
  margin: 0 0 .75rem;
  font-size: .9rem;
  color: var(--fg-muted);
  line-height: 1.55;
}
.post-tags { display: flex; gap: .4rem; flex-wrap: wrap; }
.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-fg);
  padding: .15rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 500;
  text-decoration: none;
}
.tag:hover { opacity: .8; }

/* ── Single post / page ── */
.article-header { margin-bottom: 2rem; }
.article-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 .75rem;
  letter-spacing: -.02em;
  line-height: 1.25;
}
.article-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .85rem;
  color: var(--fg-muted);
  flex-wrap: wrap;
}
.article-body { line-height: 1.8; }
.article-body h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 2rem 0 .75rem;
  letter-spacing: -.01em;
}
.article-body h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.5rem 0 .5rem;
}
.article-body p { margin: 0 0 1.2rem; }
.article-body a { color: var(--accent); }
.article-body a:hover { color: var(--accent-hover); }
.article-body ul, .article-body ol { margin: 0 0 1.2rem; padding-left: 1.5rem; }
.article-body li { margin-bottom: .35rem; }
.article-body blockquote {
  border-left: 4px solid var(--accent);
  margin: 1.5rem 0;
  padding: .75rem 1.25rem;
  background: var(--accent-light);
  border-radius: 0 8px 8px 0;
  color: var(--fg-muted);
}
.article-body code {
  background: var(--code-bg);
  padding: .15em .4em;
  border-radius: 4px;
  font-size: .875em;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.article-body pre {
  background: var(--code-bg);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.2rem 0;
}
.article-body pre code { background: none; padding: 0; font-size: .875rem; }
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
  box-shadow: var(--card-shadow);
}
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: .9rem;
}
.article-body th, .article-body td {
  padding: .6rem 1rem;
  border: 1px solid var(--border);
  text-align: left;
}
.article-body th {
  background: var(--bg-secondary);
  font-weight: 600;
}
.article-body tr:hover td { background: var(--bg-secondary); }

/* ── Download cards ── */
.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.download-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--fg);
  box-shadow: var(--card-shadow);
  transition: box-shadow .2s, transform .2s;
}
.download-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-1px);
  color: var(--accent);
}
.download-card .dl-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}
.download-card .dl-info strong { display: block; font-size: .9rem; font-weight: 600; }
.download-card .dl-info span { font-size: .8rem; color: var(--fg-muted); }

/* ── Sidebar ── */
.sidebar-widget {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.5rem;
}
.sidebar-widget h3 {
  margin: 0 0 1rem;
  font-size: .9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--fg-muted);
}
.sidebar-links { list-style: none; margin: 0; padding: 0; }
.sidebar-links li { margin-bottom: .5rem; }
.sidebar-links a {
  color: var(--fg);
  text-decoration: none;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .5rem;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.sidebar-links a:hover { background: var(--bg-secondary); color: var(--accent); }
.sidebar-buy {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.sidebar-buy a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .9rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s;
}
.sidebar-buy a:hover { opacity: .85; }
.buy-amazon { background: #ff9900; color: #111; }
.buy-apple { background: #007aff; color: #fff; }

/* ── Volume cards ── */
.volume-list { display: flex; flex-direction: column; gap: 1rem; margin: 1.5rem 0; }
.volume-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--card-shadow);
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.volume-num {
  background: var(--accent);
  color: #fff;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  flex-shrink: 0;
}
.volume-info h4 { margin: 0 0 .3rem; font-size: 1rem; font-weight: 600; }
.volume-info p { margin: 0 0 .5rem; font-size: .875rem; color: var(--fg-muted); line-height: 1.5; }
.volume-info a { font-size: .85rem; color: var(--accent); text-decoration: none; font-weight: 500; }
.volume-info a:hover { text-decoration: underline; }

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: .5rem;
  justify-content: center;
  margin-top: 2.5rem;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 .75rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: background .15s, color .15s, border-color .15s;
}
.pagination a { color: var(--fg); background: var(--card-bg); }
.pagination a:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination span { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Footer ── */
.site-footer {
  background: var(--nav-bg);
  color: var(--nav-fg-muted);
  padding: 2rem 1.5rem;
  margin-top: 4rem;
  font-size: .875rem;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.footer-links { display: flex; gap: 1.5rem; }
.footer-links a { color: var(--nav-fg-muted); text-decoration: none; transition: color .15s; }
.footer-links a:hover { color: var(--nav-fg); }

/* ── Utility ── */
.text-muted { color: var(--fg-muted); }
.mt-0 { margin-top: 0; }
.home-intro { font-size: 1.05rem; line-height: 1.8; color: var(--fg); margin-bottom: 2rem; }
.home-intro a { color: var(--accent); }

/* ── Mobile nav ── */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--nav-fg);
  font-size: 1.4rem;
  padding: .25rem;
}
@media (max-width: 640px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    padding: .75rem 1rem;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
  }
  .nav-links.open { display: flex; }
  .hero h1 { font-size: 1.75rem; }
}
