:root {
  --bg: #ffffff;
  --fg: #222222;
  --muted: #666666;
  --accent: #1a73e8;
  --border: #e0e0e0;
  --card-bg: #f7f7f7;
  --message-bg: #fff3cd;
  --message-border: #ffe08a;
  --message-fg: #5c4300;
  --mark-bg: #fff3b0;
  --mark-fg: #5c4a00;
  --critic-del-bg: #ffd7d5;
  --critic-del-fg: #7c0000;
  --critic-ins-bg: #d4f4d4;
  --critic-ins-fg: #005c00;
}
html[data-theme="dark"] {
  --bg: #1e1e1e;
  --fg: #e8e8e8;
  --muted: #9a9a9a;
  --accent: #8ab4f8;
  --border: #3a3a3a;
  --card-bg: #2a2a2a;
  --message-bg: #3a3220;
  --message-border: #6b5a24;
  --message-fg: #f0d88a;
  --mark-bg: #4a4420;
  --mark-fg: #ffe97a;
  --critic-del-bg: #4a2525;
  --critic-del-fg: #ff8f8f;
  --critic-ins-bg: #1f3d1f;
  --critic-ins-fg: #8fe58f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent); text-decoration: underline; }
.container { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.site-header { border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { font-weight: 700; font-size: 1.3rem; color: var(--fg); text-decoration: none; }
.nav a, .nav button { margin-left: 12px; color: var(--fg); text-decoration: none; background: none; border: none; cursor: pointer; font-size: 1rem; }
.nav a:hover, .nav button:hover { color: var(--accent); }
.nav .inline-form { display: inline; margin: 0; padding: 0; }
.nav .inline-form button { margin-left: 12px; }
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding-top: 16px; padding-bottom: 16px; color: var(--muted); }
.card { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 20px; overflow: hidden; background: var(--card-bg); }
.card-img { width: 100%; display: block; }
.card-body { padding: 16px; }
.card h2 { margin: 0 0 8px; font-size: 1.35rem; }
.card h2 a { color: var(--fg); text-decoration: none; }
.card h2 a:hover { color: var(--accent); }
.meta { color: var(--muted); font-size: 0.9rem; }
.meta a { color: inherit; text-decoration: none; }
.meta a:hover { color: var(--accent); text-decoration: underline; }
.tag { color: var(--accent); text-decoration: none; margin-left: 6px; }
.pagination { display: flex; gap: 12px; margin: 24px 0; align-items: center; }
.pagination a {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9rem;
}
.pagination a:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
}
.pagination span { color: var(--muted); font-size: 0.9rem; }
.messages .message, .message { background: var(--message-bg); border: 1px solid var(--message-border); color: var(--message-fg); padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; }
.post-cover { max-width: 100%; border-radius: 8px; }
.markdown img { max-width: 100%; }
.markdown pre { padding: 12px; border-radius: 8px; overflow-x: auto; }
.markdown code { background: var(--card-bg); padding: 2px 4px; border-radius: 4px; }
.markdown pre code { background: none; padding: 0; }
.codeblock { position: relative; }
.codeblock pre { margin-top: 0; }
.copy-btn {
  position: absolute; top: 6px; right: 6px;
  background: var(--card-bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; cursor: pointer; opacity: 0;
  transition: opacity .15s;
}
.codeblock:hover .copy-btn, .copy-btn:focus { opacity: 1; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
input[type=text], input[type=password], input[type=email], input[type=search], textarea, select {
  width: 100%; padding: 8px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--fg);
}
button, .btn { background: var(--accent); color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; text-decoration: none; font-size: 1rem; }
.MathJax_Preview { display: none; }
.comments { margin-top: 32px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 16px; }
.comment { border-bottom: 1px solid var(--border); padding: 10px 0; }
.comment-text { white-space: pre-line; }

/* Pymdown Extensions: Tabbed */
.tabbed-set { display: flex; flex-wrap: wrap; margin: 24px 0; padding: 0; border: 1px solid var(--border); border-radius: 8px; }
.tabbed-set input { position: absolute; opacity: 0; pointer-events: none; }
.tabbed-set label {
  order: 1; padding: 8px 16px; cursor: pointer;
  font-size: 0.9rem; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: 0;
}
.tabbed-set input:checked + label {
  color: var(--fg); border-color: var(--accent); font-weight: 600;
}
.tabbed-content { order: 2; flex-basis: 100%; display: none; padding: 16px; border-top: 1px solid var(--border); }
.tabbed-set input:checked + label + .tabbed-content { display: block; }
.tabbed-content pre { margin: 0; }

/* Кастомный fence: колонки (```columns, разделитель :::) */
.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.columns > .col {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
}
.columns > .col > :first-child { margin-top: 0; }
.columns > .col > :last-child { margin-bottom: 0; }
.columns > .col pre { margin: 0; }

@media (max-width: 640px) {
  .columns { grid-template-columns: 1fr; }
}

/* Pymdown Extensions: Keys */
.keys { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; }
.keys kbd {
  background: var(--card-bg); color: var(--fg);
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 6px;
  font-family: inherit; font-size: 0.85em; line-height: 1.4;
}

/* Pymdown Extensions: Mark / sup / sub */
mark { background: var(--mark-bg); color: var(--mark-fg); border-radius: 3px; padding: 0 3px; }
sup, sub { line-height: 0; }

/* Pymdown Extensions: Critic */
.critic del { background: var(--critic-del-bg); color: var(--critic-del-fg); text-decoration: line-through; border-radius: 3px; padding: 0 2px; }
.critic ins { background: var(--critic-ins-bg); color: var(--critic-ins-fg); text-decoration: none; border-radius: 3px; padding: 0 2px; }

/* Pymdown Extensions: Task lists */
ul.task-list { list-style: none; padding-left: 4px; }
ul.task-list .task-list-item { display: flex; align-items: center; gap: 8px; }
ul.task-list li.task-list-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  width: 16px;
  height: 16px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  cursor: default;
  position: relative;
}
ul.task-list li.task-list-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
ul.task-list li.task-list-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Lists */
ol { padding-left: 1.4em; }
ul:not(.task-list) { padding-left: 1.4em; list-style: disc; }

/* Pymdown Extensions: Emoji */
img.emojione {
  height: 1.2em;
  width: 1.2em;
  vertical-align: text-bottom;
}

/* Pymdown Extensions: Details */
details { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--card-bg); margin-bottom: 16px; }
summary { cursor: pointer; font-weight: 600; outline: none; }
summary:hover { color: var(--accent); }

/* Quotes */
blockquote {
  margin: 16px 0;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--muted);
  color: var(--muted);
}

/* Admonitions */
.admonition {
  margin: 16px 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--card-bg);
}
.admonition .admonition-title { font-weight: 600; margin-bottom: 8px; }
.admonition.note { border-left-color: #58a6ff; }
.admonition.note .admonition-title { color: #58a6ff; }
.admonition.warning { border-left-color: #d29922; }
.admonition.warning .admonition-title { color: #d29922; }
.admonition.danger { border-left-color: #f85149; }
.admonition.danger .admonition-title { color: #f85149; }
.admonition.tip { border-left-color: #3fb950; }
.admonition.tip .admonition-title { color: #3fb950; }

/* Print: только контент статьи */
@media print {
  .site-header,
  .site-footer,
  .messages,
  .comments,
  #theme-toggle,
  .copy-btn,
  .nav {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }
  .container {
    max-width: none;
    padding: 0;
  }
  .post-cover {
    max-height: 8cm;
    object-fit: cover;
  }
  a {
    color: #000;
    text-decoration: none;
  }
  .markdown pre {
    white-space: pre-wrap;
    word-wrap: break-word;
  }
}