:root {
  --sidebar-w: 260px;
  --toc-w: 220px;
  --border: #e3e3e3;
  --text: #1f2328;
  --text-muted: #6b7280;
  --bg: #ffffff;
  --bg-subtle: #f7f7f8;
  --accent: #1a56db;
  --accent-bg: #eaf1fd;
  --code-bg: #f1f1f3;
  --max-width: 760px;
  --max-width-wide: 1120px;
  --free: #15803d;
  --free-bg: #dcfce7;
  --paid: #b45309;
  --paid-bg: #fef3c7;
  --popular: #6d28d9;
  --popular-bg: #ede9fe;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

.layout { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}
.topbar .tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.body {
  display: flex;
  flex: 1;
  align-items: flex-start;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow-y: auto;
  font-size: 0.9rem;
}

.sidebar-theme {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 8px;
}
.sidebar-theme a { color: var(--text); text-decoration: none; }
.sidebar-theme a:hover { color: var(--accent); }

.sidebar h2 {
  font-size: 0.78rem;
  margin: 18px 0 4px;
}
.sidebar h2:first-of-type { margin-top: 10px; }
.sidebar h2 a { color: var(--text); text-decoration: none; }
.sidebar h2 a:hover, .sidebar h2 a.active { color: var(--accent); }

.sidebar ul.article-list {
  list-style: none;
  margin: 0 0 4px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.sidebar ul.article-list li { margin: 1px 0; }
.sidebar ul.article-list a {
  display: block;
  padding: 4px 8px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.87rem;
}
.sidebar ul.article-list a:hover { background: var(--bg-subtle); color: var(--text); }
.sidebar ul.article-list a.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}
.sidebar .planned { color: var(--text-muted); font-style: italic; font-size: 0.85rem; }

.content {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 60px;
  max-width: var(--max-width);
}
.content.content-wide { max-width: var(--max-width-wide); }

.toc {
  width: var(--toc-w);
  flex: 0 0 var(--toc-w);
  padding: 32px 20px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  font-size: 0.85rem;
}
.toc h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 4px 0; }
.toc a { color: var(--text-muted); text-decoration: none; }
.toc a:hover { color: var(--accent); }

.breadcrumb {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }

h1 { font-size: 1.7rem; margin: 0 0 14px; line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 30px 0 10px; }
h3 { font-size: 1.05rem; margin: 20px 0 8px; }

h2 .anchor, h3 .anchor {
  opacity: 0;
  margin-left: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
h2:hover .anchor, h3:hover .anchor, h2:focus-within .anchor, h3:focus-within .anchor { opacity: 1; }
.anchor .anchor-icon { display: block; }
.anchor { position: relative; cursor: pointer; }
.anchor.copied::after {
  content: "Copied!";
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 6px;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

h2 a:not(.anchor), h3 a:not(.anchor) { color: var(--text); text-decoration: none; }
h2 a:not(.anchor):hover, h3 a:not(.anchor):hover { color: var(--accent); }

p { margin: 0 0 14px; }
a { color: var(--accent); }
ol, ul { padding-left: 22px; margin: 0 0 16px; }
li { margin: 6px 0; }
strong { font-weight: 600; }

.page-intro { color: var(--text-muted); margin-bottom: 18px; }

.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 32px;
  font-size: 0.92rem;
}
.article-nav a { color: var(--text); text-decoration: none; }
.article-nav a:hover { color: var(--accent); }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 20px 0;
}
@media (max-width: 860px) {
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .theme-grid { grid-template-columns: 1fr; }
}
.theme-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: block;
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.theme-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.theme-card-image {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-subtle);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.theme-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
  display: block;
}
.theme-card-image .image-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
}
.theme-card-body { padding: 12px 14px 16px; }
.theme-card .name { font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.theme-card .developer { color: var(--text-muted); font-size: 0.82rem; margin-top: 2px; }
.theme-card .blurb { color: var(--text-muted); font-size: 0.85rem; margin-top: 8px; }
.theme-card .count { color: var(--text-muted); font-size: 0.78rem; margin-top: 8px; }

.price-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  font-weight: 400;
  display: inline-block;
}
.price-tag.badge-free { color: var(--free); background: var(--free-bg); border-color: transparent; }
.price-tag.badge-paid { color: var(--paid); background: var(--paid-bg); border-color: transparent; }
.price-tag.badge-popular { color: var(--popular); background: var(--popular-bg); border-color: transparent; }

.topic-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 22px;
}
.topic-pill {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}
.topic-pill:hover { border-color: var(--accent); color: var(--text); }
.topic-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.topic-pill.filter-pill-free.active { background: var(--free); border-color: var(--free); }
.topic-pill.filter-pill-paid.active { background: var(--paid); border-color: var(--paid); }
.topic-pill.filter-pill-popular.active { background: var(--popular); border-color: var(--popular); }

.article-list-full { list-style: none; padding: 0; margin: 16px 0; }
.article-list-full li {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.article-list-full a { text-decoration: none; color: var(--text); font-weight: 600; }
.article-list-full a:hover { color: var(--accent); }
.article-list-full .desc { color: var(--text-muted); font-size: 0.88rem; margin-top: 2px; }
.article-list-full .tag { margin-top: 6px; }

.tag {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 4px;
}
.tag:hover { border-color: var(--accent); color: var(--accent); }

.theme-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.theme-meta .developer { color: var(--text-muted); font-size: 0.9rem; }

.links-rows { margin: 0 0 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.links-row {
  font-size: 0.88rem;
  margin: 0 0 6px;
}
.links-row:last-child { margin-bottom: 0; }
.links-row a { color: var(--accent); text-decoration: none; }
.links-row a:hover { text-decoration: underline; }

.article-tags { margin: -8px 0 18px; }

.prose a { color: var(--text); text-decoration: none; }
.prose a:hover { text-decoration: underline; }

.planned-list { list-style: none; padding: 0; margin: 16px 0; }
.planned-list li {
  color: var(--text-muted);
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 24px;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.site-footer a { color: var(--text-muted); }

@media (max-width: 900px) {
  .toc { display: none; }
}
.layout.no-sidebar .sidebar { display: none; }
.layout.no-sidebar .nav-toggle-label { display: none; }
.layout.no-sidebar .body { justify-content: center; }

.nav-toggle-input { position: absolute; opacity: 0; pointer-events: none; }
.nav-toggle-label { display: none; }

@media (max-width: 700px) {
  .body { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: none;
  }
  .nav-toggle-label {
    display: block;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    cursor: pointer;
  }
  .nav-toggle-input:checked ~ .body .sidebar { display: block; }
  .nav-toggle-input:focus-visible ~ .nav-toggle-label { outline: 2px solid var(--accent); }
  .content { padding: 24px 20px 40px; max-width: 100%; }
}
