/* ── база ───────────────────────────────────────────────────────────────── */
:root {
  --bg: #0d1117;
  --bg-soft: #12171f;
  --bg-card: #161b22;
  --border: #232a34;
  --border-soft: #1c232c;
  --fg: #e6edf3;
  --fg-dim: #8b949e;
  --fg-faint: #6e7681;
  --accent: #58a6ff;
  --accent-dim: #1f6feb;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

/* ── шапка ──────────────────────────────────────────────────────────────── */
.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 860px; margin: 0 auto; padding: 22px 24px;
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent-dim), #8957e5);
  font-family: var(--mono); font-weight: 700; font-size: 16px; color: #fff;
}
.brand-name { font-family: var(--mono); font-size: 15px; letter-spacing: .5px; }
.top-nav { display: flex; gap: 20px; font-size: 14px; }
.top-nav a { color: var(--fg-dim); }
.top-nav a:hover { color: var(--fg); text-decoration: none; }

main { max-width: 860px; margin: 0 auto; padding: 0 24px 80px; }

/* ── hero ───────────────────────────────────────────────────────────────── */
.hero { padding: 64px 0 40px; }
.hero h1 {
  margin: 0 0 8px; font-family: var(--mono);
  font-size: 40px; font-weight: 700; letter-spacing: -1px;
}
.hero-sub {
  margin: 0 0 20px; color: var(--accent);
  font-family: var(--mono); font-size: 14px; letter-spacing: .3px;
}
.hero-desc { margin: 0; max-width: 620px; color: var(--fg-dim); font-size: 15px; }

/* ── список статей ──────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.card-link { display: block; padding: 22px 24px; color: inherit; }
.card-link:hover { text-decoration: none; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-head h2 { margin: 0; font-size: 19px; font-weight: 600; line-height: 1.35; }
.card-arrow { color: var(--fg-faint); font-size: 18px; transition: transform .15s, color .15s; }
.card:hover .card-arrow { transform: translateX(4px); color: var(--accent); }
.card-sub { margin: 8px 0 14px; color: var(--fg-dim); font-size: 14px; }
.card-meta { color: var(--fg-faint); font-family: var(--mono); font-size: 12px; }
.dot { margin: 0 7px; }
.card-tags { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  padding: 2px 9px; border-radius: 20px;
  background: rgba(88,166,255,.1); border: 1px solid rgba(88,166,255,.2);
  color: var(--accent); font-family: var(--mono); font-size: 11px;
}

/* ── об авторе ──────────────────────────────────────────────────────────── */
.about { margin-top: 64px; padding-top: 36px; border-top: 1px solid var(--border-soft); }
.about h2 { margin: 0 0 14px; font-family: var(--mono); font-size: 15px; color: var(--fg-dim); font-weight: 500; }
.about p { color: var(--fg-dim); font-size: 15px; }
.about-links { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.chip {
  padding: 3px 11px; border-radius: 6px; background: var(--bg-card);
  border: 1px solid var(--border); color: var(--fg-dim);
  font-family: var(--mono); font-size: 12px;
}

/* ── страница статьи ────────────────────────────────────────────────────── */
.post { padding-top: 40px; }
.post-head { padding-bottom: 28px; border-bottom: 1px solid var(--border-soft); }
.back { display: inline-block; margin-bottom: 22px; color: var(--fg-faint); font-size: 13px; font-family: var(--mono); }
.back:hover { color: var(--accent); text-decoration: none; }
.post-head h1 { margin: 0 0 10px; font-size: 31px; font-weight: 700; line-height: 1.25; letter-spacing: -.4px; }
.post-sub { margin: 0 0 16px; color: var(--fg-dim); font-size: 16px; }
.post-meta { color: var(--fg-faint); font-family: var(--mono); font-size: 12px; }
.post-tags { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.post-actions { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-block; padding: 8px 16px; border-radius: 7px;
  background: var(--accent-dim); border: 1px solid var(--accent-dim);
  color: #fff; font-size: 13px; font-family: var(--mono); cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--accent); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--fg-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-card); color: var(--fg); border-color: var(--fg-faint); }
.btn.done { background: var(--green); border-color: var(--green); }

/* ── тело статьи ────────────────────────────────────────────────────────── */
.post-body { padding-top: 32px; font-size: 16px; }
.post-body p { margin: 0 0 16px; }
.post-body strong { color: #fff; font-weight: 600; }
.post-body hr { border: 0; border-top: 1px solid var(--border-soft); margin: 32px 0; }

.bb-center { text-align: center; margin: 18px 0; }
.bb-right { text-align: right; color: var(--fg-faint); font-size: 13px; margin: 12px 0; }
.bb-left { text-align: left; }

.bb-size-1 { font-size: .78em; }
.bb-size-2 { font-size: .88em; color: var(--fg-dim); }
.bb-size-3 { font-size: .96em; }
.bb-size-4 { font-size: 1em; }
.bb-size-5 { font-size: 1.3em; font-weight: 600; }
.bb-size-6 { font-size: 1.6em; font-weight: 700; }
.bb-size-7 { font-size: 2em; font-weight: 700; }

/* ── картинки ───────────────────────────────────────────────────────────── */
/* Скриншоты выводим ШИРЕ текстовой колонки — иначе на них ничего не видно.
   Клик открывает полноразмерный просмотр. */
.post-body { position: relative; }

.bb-figure { margin: 30px 0; text-align: center; }

.bb-img {
  display: block; position: relative; cursor: zoom-in;
  margin: 30px 0; line-height: 0;
  /* выходим за пределы текстовой колонки */
  width: calc(100% + 200px);
  margin-left: -100px;
}
.bb-img img {
  display: block; width: 100%; height: auto;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-soft);
}
/* очень маленькие скрины не растягиваем выше оригинала */
.bb-img.small { width: 100%; margin-left: 0; }
.bb-img.small img { width: auto; max-width: 100%; margin: 0 auto; }

.bb-img::after {
  content: "⤢";
  position: absolute; right: 10px; top: 10px;
  width: 30px; height: 30px; border-radius: 7px;
  display: grid; place-items: center;
  background: rgba(13,17,23,.85); color: var(--fg-dim);
  font-size: 15px; line-height: 1;
  opacity: 0; transition: opacity .15s;
}
.bb-img:hover::after { opacity: 1; }

/* на узких экранах — обычная ширина */
@media (max-width: 1100px) {
  .bb-img { width: 100%; margin-left: 0; }
}

/* ── лайтбокс ───────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(5,7,10,.96);
  display: none; overflow: auto;
  padding: 28px; cursor: zoom-out;
}
.lightbox.open { display: block; }
.lightbox img {
  display: block; margin: 0 auto;
  max-width: min(1600px, 100%);
  width: auto; height: auto;
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0,0,0,.7);
}
.lightbox .lb-close {
  position: fixed; top: 18px; right: 22px; z-index: 2;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.1); border: 1px solid var(--border);
  color: var(--fg); font-size: 22px; line-height: 1; cursor: pointer;
}
.lightbox .lb-close:hover { background: rgba(255,255,255,.2); }
.lightbox .lb-hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: var(--fg-faint); font-family: var(--mono); font-size: 12px;
  background: rgba(13,17,23,.85); padding: 5px 14px; border-radius: 20px;
  pointer-events: none; white-space: nowrap;
}
body.lb-lock { overflow: hidden; }

.bb-spoiler {
  margin: 18px 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-soft); overflow: hidden;
}
.bb-spoiler > summary {
  padding: 13px 18px; cursor: pointer; user-select: none;
  font-size: 14px; font-weight: 600; color: var(--fg);
  background: var(--bg-card); list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.bb-spoiler > summary::-webkit-details-marker { display: none; }
.bb-spoiler > summary::before {
  content: "▸"; color: var(--accent); font-size: 12px;
  transition: transform .15s; display: inline-block;
}
.bb-spoiler[open] > summary::before { transform: rotate(90deg); }
.bb-spoiler > summary:hover { background: #1b2129; }
.bb-spoiler-body { padding: 18px; border-top: 1px solid var(--border); }
.bb-spoiler-body > *:last-child { margin-bottom: 0; }
/* вложенные спойлеры — чуть темнее */
.bb-spoiler .bb-spoiler { background: #0f141b; }
.bb-spoiler .bb-spoiler > summary { background: #131920; font-size: 13px; }

.bb-code {
  margin: 18px 0; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; background: #0a0e14;
}
.bb-code-head {
  padding: 7px 14px; background: var(--bg-card); border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 11px; color: var(--fg-faint);
  text-transform: uppercase; letter-spacing: .5px;
}
.bb-code pre { margin: 0; padding: 15px 16px; overflow-x: auto; }
.bb-code code {
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
  color: #c9d1d9; white-space: pre;
}

.bb-quote {
  margin: 18px 0; padding: 12px 18px;
  border-left: 3px solid var(--accent-dim); background: var(--bg-soft);
  color: var(--fg-dim); border-radius: 0 var(--radius) var(--radius) 0;
}
.bb-quote cite { display: block; font-size: 13px; color: var(--accent); font-style: normal; margin-bottom: 6px; }

.bb-list { margin: 16px 0; padding-left: 24px; }
.bb-list li { margin-bottom: 7px; }

.bb-term {
  border-bottom: 1px dotted var(--fg-faint); cursor: help;
  text-decoration: none;
}

.smilie { font-style: normal; }

.bb-attach { color: var(--fg-faint); font-family: var(--mono); font-size: 13px; }

/* ── подвал ─────────────────────────────────────────────────────────────── */
.foot {
  max-width: 860px; margin: 0 auto; padding: 28px 24px 48px;
  border-top: 1px solid var(--border-soft);
  color: var(--fg-faint); font-family: var(--mono); font-size: 12px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.foot-dim { color: #4a5158; }

/* ── мобильные ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hero { padding: 40px 0 28px; }
  .hero h1 { font-size: 30px; }
  .post-head h1 { font-size: 24px; }
  .top { padding: 16px 18px; }
  main { padding: 0 18px 60px; }
  .card-link { padding: 18px; }
  .post-body { font-size: 15px; }
  .bb-code code { font-size: 12px; }
}
