/* ── Tokens ─────────────────────────────────────────── */
:root {
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;
  --bg:  #fff;     --bg2: #f5f5f5;  --bg3: #ebebeb;
  --tx:  #1a1a1a;  --tx2: #555;     --tx3: #999;
  --bd:  #e0e0e0;  --bd2: #eee;
  --acc: #0d9488;  --acc2:#065f46;
  --r:   8px;
  --max: 720px;
}
[data-theme="dark"] {
  --bg:  #111;     --bg2: #1a1a1a;  --bg3: #252525;
  --tx:  #e5e5e5;  --tx2: #aaa;     --tx3: #666;
  --bd:  #333;     --bd2: #2a2a2a;
  --acc: #2dd4bf;  --acc2:#5eead4;
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100% }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--tx);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--acc); text-decoration: none }
a:hover { text-decoration: underline }
img { max-width: 100%; height: auto; border-radius: var(--r) }

/* ── Layout ─────────────────────────────────────────── */
.site {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.main {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── Header ─────────────────────────────────────────── */
.hdr {
  border-bottom: 1px solid var(--bd2);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.hdr-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--tx);
  text-decoration: none;
}
.logo-icon { font-size: 1.1rem }
.nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.nav-link {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--tx2);
  border-radius: 6px;
  text-decoration: none;
}
.nav-link:hover { background: var(--bg2); color: var(--tx); text-decoration: none }
.nav-lang {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--acc);
  border: 1px solid var(--acc);
  border-radius: 10px;
  text-decoration: none;
  margin-left: 0.3rem;
}
.nav-lang:hover { background: var(--acc); color: var(--bg); text-decoration: none }
.nav-theme {
  background: 0;
  border: 1px solid var(--bd);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--tx2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.2rem;
}
.nav-theme:hover { color: var(--tx); border-color: var(--tx2) }

@media (max-width: 600px) {
  .nav-link { padding: 0.25rem 0.35rem; font-size: 0.75rem }
  .logo-text { font-size: 0.85rem }
}

/* ── Article ────────────────────────────────────────── */
.article-title {
  font-size: 1.6rem;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--tx3);
  margin-bottom: 0.8rem;
}
.meta-sep { color: var(--bd) }
.article-desc {
  font-size: 0.95rem;
  color: var(--tx2);
  border-left: 3px solid var(--acc);
  padding-left: 0.8rem;
  margin-bottom: 1.2rem;
}

/* Tags */
.tag-row { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 1rem }
.tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--bd);
  border-radius: 10px;
  color: var(--tx2);
}
.tag:hover { border-color: var(--acc); color: var(--acc); text-decoration: none }

/* Level badges */
.level-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.3rem;
}
.level-beginner   { background: #d1fae5; color: #065f46 }
.level-intermediate { background: #fef3c7; color: #92400e }
.level-advanced   { background: #fee2e2; color: #991b1b }

/* Series nav */
.series-nav {
  margin-top: 2rem;
  padding: 0.8rem;
  background: var(--bg2);
  border-radius: var(--r);
  font-size: 0.85rem;
}
.series-label { font-weight: 600; color: var(--tx2) }

/* ── Prose (markdown body) ──────────────────────────── */
.prose h2 { font-size: 1.3rem; margin: 1.8rem 0 0.6rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--bd2) }
.prose h3 { font-size: 1.1rem; margin: 1.4rem 0 0.5rem }
.prose h4 { font-size: 0.95rem; margin: 1.2rem 0 0.4rem; color: var(--tx2) }
.prose p  { margin-bottom: 0.9rem }
.prose ul, .prose ol { margin: 0.5rem 0 0.9rem 1.5rem }
.prose li { margin-bottom: 0.3rem }
.prose blockquote {
  border-left: 3px solid var(--acc);
  padding: 0.5rem 0.8rem;
  margin: 0.8rem 0;
  color: var(--tx2);
  background: var(--bg2);
  border-radius: 0 var(--r) var(--r) 0;
}
.prose code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.prose pre {
  background: var(--bg2);
  border: 1px solid var(--bd2);
  border-radius: var(--r);
  padding: 0.8rem;
  overflow-x: auto;
  margin: 0.8rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.prose pre code { background: 0; padding: 0 }
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
  font-size: 0.9rem;
}
.prose th, .prose td {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--bd);
  text-align: left;
}
.prose th { background: var(--bg2); font-weight: 600 }
.prose hr { border: none; border-top: 1px solid var(--bd2); margin: 1.5rem 0 }
.prose img { margin: 0.5rem 0 }
.prose a { color: var(--acc); font-weight: 500 }
.prose strong { font-weight: 600 }

/* ── Home ───────────────────────────────────────────── */
.hero-banner {
  text-align: center;
  padding: 2rem 0.5rem;
  margin-bottom: 1.5rem;
}
.hero-title {
  font-size: 1.8rem;
  line-height: 1.2;
  margin-bottom: 0.4rem;
}
.hero-sub {
  font-size: 1rem;
  color: var(--tx2);
}
.home-body { margin-bottom: 2rem }
.home-section { margin-bottom: 2rem }
.section-title {
  font-size: 1.1rem;
  margin-bottom: 0.8rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--bd2);
}
.section-title a { color: var(--tx); text-decoration: none }
.section-title a:hover { color: var(--acc) }

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}
@media (max-width: 500px) { .card-grid { grid-template-columns: 1fr } }
.card {
  display: block;
  padding: 0.8rem;
  background: var(--bg2);
  border: 1px solid var(--bd2);
  border-radius: var(--r);
  text-decoration: none;
  color: var(--tx);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover { border-color: var(--acc); box-shadow: 0 2px 8px rgba(0,0,0,0.06); text-decoration: none }
.card-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.2rem }
.card-desc { font-size: 0.78rem; color: var(--tx2); line-height: 1.4; margin-bottom: 0.3rem }
.card-date { font-size: 0.7rem; color: var(--tx3) }

/* ── Footer ─────────────────────────────────────────── */
.ftr-site {
  border-top: 1px solid var(--bd2);
  padding: 1rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--tx3);
}
.ftr-inner { max-width: var(--max); margin: 0 auto }
.ftr-site a { color: var(--tx2) }
.ftr-sub { margin-top: 0.2rem; font-size: 0.7rem }

/* ── Search ─────────────────────────────────────────── */
.hdr-search { position: relative; flex: 1; max-width: 260px }
.search-input {
  width: 100%;
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  border: 1px solid var(--bd);
  border-radius: 14px;
  background: var(--bg2);
  color: var(--tx);
}
.search-input:focus { outline: 2px solid var(--acc); outline-offset: 1px; border-color: var(--acc) }
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 200;
  max-height: 360px;
  overflow-y: auto;
}
.sr-item {
  display: block;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--bd2);
  text-decoration: none;
  color: var(--tx);
}
.sr-item:last-child { border-bottom: 0 }
.sr-item:hover { background: var(--bg2) }
.sr-title { font-size: 0.85rem; font-weight: 600; display: block }
.sr-desc  { font-size: 0.75rem; color: var(--tx2); display: block; margin-top: 0.1rem }
.sr-empty { padding: 0.8rem; font-size: 0.82rem; color: var(--tx3); text-align: center }
.sr-item mark { background: #fef08a; color: #1a1a1a; border-radius: 2px; padding: 0 1px }

@media (max-width: 600px) {
  .hdr-search { max-width: 120px }
  .search-input { font-size: 0.75rem; padding: 0.25rem 0.5rem }
}

/* ── Breadcrumb ─────────────────────────────────────── */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem;
  font-size: 0.75rem;
  color: var(--tx3);
  margin-bottom: 1rem;
}
.bc-item { color: var(--tx2); text-decoration: none }
.bc-item:hover { color: var(--acc) }
.bc-current { color: var(--tx3); font-weight: 500 }
.bc-sep { margin: 0 0.15rem; color: var(--bd) }

/* ── TOC ────────────────────────────────────────────── */
.toc {
  background: var(--bg2);
  border: 1px solid var(--bd2);
  border-radius: var(--r);
  padding: 0.8rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.82rem;
}
.toc-label { font-weight: 700; font-size: 0.8rem; color: var(--tx2); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.04em }
.toc-list { list-style: none; padding: 0 }
.toc-item a { color: var(--tx2); text-decoration: none; display: block; padding: 0.15rem 0 }
.toc-item a:hover { color: var(--acc) }
.toc-item a.toc-active { color: var(--acc); font-weight: 600 }
.toc-h3 { padding-left: 1rem }

/* ── Share bar ──────────────────────────────────────── */
.share-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 2rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--bd2);
  font-size: 0.8rem;
}
.share-label { color: var(--tx3); font-size: 0.75rem; margin-right: 0.2rem }
.share-btn {
  padding: 0.25rem 0.65rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--bg);
  border: none;
  cursor: pointer;
}
.share-fb { background: #1877f2 }
.share-tg { background: #2aabee }
.share-tw { background: #000 }
.share-cp { background: var(--bg2); color: var(--tx); border: 1px solid var(--bd) }

/* ── Series nav ─────────────────────────────────────── */
.series-nav {
  margin-top: 1.5rem;
  padding: 0.8rem 1rem;
  background: var(--bg2);
  border: 1px solid var(--bd2);
  border-radius: var(--r);
  font-size: 0.85rem;
}
.series-nav-inner { display: flex; flex-direction: column; gap: 0.5rem }
.series-label { font-size: 0.8rem; color: var(--tx2) }
.series-pn { display: flex; gap: 0.5rem; flex-wrap: wrap }
.series-prev, .series-next {
  padding: 0.3rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  font-size: 0.8rem;
  color: var(--tx);
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.series-next { text-align: right }
.series-prev:hover, .series-next:hover { border-color: var(--acc); color: var(--acc) }

/* ── List page ──────────────────────────────────────── */
.list-page { }
.list-header { margin-bottom: 1.2rem }
.list-title { font-size: 1.4rem; margin-bottom: 0.3rem }
.list-desc { color: var(--tx2); font-size: 0.9rem; margin-bottom: 0.4rem }
.list-count { font-size: 0.78rem; color: var(--tx3) }
.list-group-heading { margin: 1.2rem 0 0.6rem; font-size: 0.9rem }
.list-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}
@media (max-width: 500px) { .list-grid { grid-template-columns: 1fr } }
.list-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.8rem;
  background: var(--bg2);
  border: 1px solid var(--bd2);
  border-radius: var(--r);
  text-decoration: none;
  color: var(--tx);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.list-card:hover { border-color: var(--acc); box-shadow: 0 2px 8px rgba(0,0,0,.06); text-decoration: none }
.list-card-top { display: flex; gap: 0.3rem; flex-wrap: wrap }
.list-card-title { font-size: 0.9rem; font-weight: 600; line-height: 1.3 }
.list-card-desc { font-size: 0.78rem; color: var(--tx2); line-height: 1.4; flex: 1 }
.list-card-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 0.3rem; flex-wrap: wrap; margin-top: auto }
.series-chip { font-size: 0.65rem; padding: 0.1rem 0.4rem; border-radius: 8px; background: var(--bg3); color: var(--tx2); border: 1px solid var(--bd2) }
.empty-state { padding: 2rem; text-align: center; color: var(--tx3); font-size: 0.9rem }
