/* ------------------------------------------------------------
   Нейтральная тема. Все цвета/шрифты вынесены в переменные —
   для редизайна обычно достаточно поменять :root.
   ------------------------------------------------------------ */

:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #656d76;
  --border: #d0d7de;
  --surface: #f6f8fa;
  --accent: #0969da;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --max-width: 760px;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --fg: #e6edf3;
    --muted: #8d96a0;
    --border: #30363d;
    --surface: #161b22;
    --accent: #4493f8;
  }
}

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

html { font-size: 17px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

main.container { padding-top: 2rem; padding-bottom: 3rem; min-height: 70vh; }

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

h1, h2, h3, h4 { line-height: 1.3; margin: 2rem 0 0.75rem; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

img { max-width: 100%; height: auto; }

hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ---------- Header / footer ---------- */

.site-header { border-bottom: 1px solid var(--border); }
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.site-title { font-weight: 700; font-size: 1.1rem; color: var(--fg); }
.site-nav { display: flex; gap: 1.25rem; }
.site-nav a { color: var(--muted); }
.site-nav a:hover { color: var(--fg); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Home ---------- */

.intro h1 { margin-top: 0; }
.intro p { color: var(--muted); margin-top: 0; }

.post-list { list-style: none; padding: 0; margin: 2rem 0 0; }
.post-item {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--border);
}
.post-list.compact .post-item { padding: 0.5rem 0; border-top: 0; }
.post-date { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; padding-top: 0.1rem; }
.post-link { font-weight: 600; font-size: 1.05rem; }
.post-venue { color: var(--muted); font-size: 0.9rem; font-style: italic; }
.post-tldr { margin: 0.35rem 0 0.5rem; }

@media (max-width: 560px) {
  .post-item { grid-template-columns: 1fr; gap: 0.2rem; }
}

/* ---------- Tags ---------- */

.tag-list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}
.tag:hover { color: var(--fg); border-color: var(--muted); text-decoration: none; }
.tag-count { opacity: 0.7; margin-left: 0.2rem; }
.tag-index { margin-bottom: 1.5rem; }
.tag-section { scroll-margin-top: 1rem; }

/* ---------- Post ---------- */

.post-title { margin-top: 0; }
.post-meta { color: var(--muted); font-size: 0.9rem; }

.paper-card {
  margin: 1.75rem 0;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.paper-card-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.paper-card-title { font-weight: 600; margin: 0.2rem 0; }
.paper-card-authors { color: var(--muted); font-size: 0.92rem; }
.paper-card-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.88rem; margin-top: 0.4rem; color: var(--muted); }

.tldr {
  border-left: 3px solid var(--accent);
  padding: 0.25rem 0 0.25rem 1rem;
  margin: 1.5rem 0;
}

.post-content blockquote {
  margin: 1.25rem 0;
  padding: 0 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.post-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.25rem 0;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}
.post-content th, .post-content td { border: 1px solid var(--border); padding: 0.4rem 0.7rem; text-align: left; }
.post-content th { background: var(--surface); }

.post-content figure { margin: 1.5rem 0; }
.post-content figcaption { color: var(--muted); font-size: 0.88rem; margin-top: 0.4rem; }

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
}
.post-nav .next { text-align: right; margin-left: auto; }

/* ---------- Code ---------- */

code, pre { font-family: var(--font-mono); font-size: 0.88em; }
:not(pre) > code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05em 0.3em;
}
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  overflow-x: auto;
  line-height: 1.5;
}
.highlight { margin: 1.25rem 0; }
.highlight pre { margin: 0; }

/* Минимальная подсветка синтаксиса (rouge) */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs { color: var(--muted); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .ow { color: #cf222e; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sd, .highlight .si { color: #0a3069; }
.highlight .m, .highlight .mi, .highlight .mf { color: #0550ae; }
.highlight .nf, .highlight .fm { color: #8250df; }
.highlight .nb, .highlight .bp { color: #953800; }
@media (prefers-color-scheme: dark) {
  .highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .ow { color: #ff7b72; }
  .highlight .s, .highlight .s1, .highlight .s2, .highlight .sd, .highlight .si { color: #a5d6ff; }
  .highlight .m, .highlight .mi, .highlight .mf { color: #79c0ff; }
  .highlight .nf, .highlight .fm { color: #d2a8ff; }
  .highlight .nb, .highlight .bp { color: #ffa657; }
}

/* MathJax: длинные формулы скроллятся, а не ломают вёрстку */
mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; }

/* ---------- Images ---------- */

.figure { margin: 1.5rem 0; }
.figure a { display: block; }
.figure img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.figure figcaption { color: var(--muted); font-size: 0.88rem; margin-top: 0.4rem; text-align: center; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.gallery.single { grid-template-columns: 1fr; }
.gallery .figure { margin: 0; }
.gallery:not(.single) .figure img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }

/* ---------- Build log ---------- */

.build-feed { margin-top: 2rem; }
.build-item { padding: 1.5rem 0; border-top: 1px solid var(--border); }
.build-item .post-meta a { color: var(--muted); }
.build-item-title { font-size: 1.2rem; margin: 0.25rem 0 0.5rem; }
.build-item .post-content > :first-child { margin-top: 0; }
.build-links { padding-left: 1.2rem; font-size: 0.92rem; }
