/*
 * berd.space — тёмная минималистичная тема «в духе раннего веба»:
 * системные шрифты, подчёркнутые ссылки (с отдельным цветом для посещённых),
 * списки заголовков без картинок. Никаких веб-шрифтов и JS для оформления.
 */

:root {
  color-scheme: dark;

  --bg: #0d0d0c;
  --text: #d9d6ce;
  --muted: #817d74;
  --faint: #55524c;
  --line: #262523;
  --link: #8fb4ff;
  --visited: #b59ce6;
  --accent: #59b800; /* перекрывается настройкой «акцентный цвет» из админки */
  --danger: #e5786d;

  --field: #151514; /* заливка полей ввода */
  --radius: 4px; /* скругление полей и кнопок */

  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --page: 1180px;
  --column: 680px;
  --gutter: 24px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--line) transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: #000;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:visited {
  color: var(--visited);
}

a:hover {
  background: var(--link);
  color: var(--bg);
  text-decoration: none;
}

a:visited:hover {
  background: var(--visited);
}

a:focus-visible {
  outline: 1px dashed var(--text);
  outline-offset: 3px;
}

hr {
  height: 0;
  margin: 2.2em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
  line-height: 1.25;
}

p {
  margin: 0;
}

img,
video,
iframe {
  max-width: 100%;
}

.mono,
.site-nav,
.site-foot,
.meta,
.post-row-date,
.year,
.note-date,
.section-title,
.site-auth,
.form-field > span,
.form-error,
.composer-foot,
.comments-login {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.01em;
}

/* ---------- каркас ---------- */

.page {
  width: 100%;
  max-width: calc(var(--column) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.page-main {
  min-height: 60vh;
  padding: 8px 0 56px;
}

/* ---------- шапка и подвал ---------- */

.site-head {
  padding: 40px 0 28px;
}

/* название — часть логотипа, поэтому гротеском, в пару к геометричному знаку */
.site-title {
  font-family: var(--sans);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.site-title a,
.site-title a:visited {
  color: var(--text);
  text-decoration: none;
}

.site-title a {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

/* точка — часть логотипа, а не названия сайта: в подвале, <title> и RSS её нет */
.site-title a span::after {
  content: ".";
}

/* общая подсветка ссылок сюда не доходит: на наведение отвечает сам знак — квадрат становится целым */
.site-title a:hover,
.site-title a:visited:hover {
  background: none;
  color: var(--text);
}

/* динамический логотип: форму внутри двигает скрипт из components/site/logo.tsx */
.site-title a {
  --logo-size: 40px;
  --logo-hover: 0.88; /* во сколько раз сжимается знак при наведении */
}

.site-logo {
  flex: none;
  width: var(--logo-size);
  height: var(--logo-size);
  transform-origin: left center; /* левый край остаётся на линии колонки */
}

.site-logo,
.site-title a span {
  transition: transform 0.9s cubic-bezier(0.3, 0, 0.2, 1);
}

/*
 * При наведении квадрат собирается целиком и чуть сжимается, а название подъезжает ровно
 * на столько, на сколько ушёл правый край знака, — отступ между ними постоянен на всём
 * ходу анимации. Темп — как у формы: туда быстро, обратно неспешно.
 */
.site-title a:hover .site-logo,
.site-title a:focus-visible .site-logo {
  transform: scale(var(--logo-hover));
}

.site-title a:hover span,
.site-title a:focus-visible span {
  transform: translateX(calc(var(--logo-size) * (var(--logo-hover) - 1)));
}

.site-title a:hover .site-logo,
.site-title a:hover span,
.site-title a:focus-visible .site-logo,
.site-title a:focus-visible span {
  transition-duration: 0.45s;
}

@media (prefers-reduced-motion: reduce) {
  .site-logo,
  .site-title a span {
    transition: none;
  }
}

.site-description {
  max-width: 34em;
  margin-top: 6px;
  color: var(--muted);
}

.site-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 24px;
  margin-top: 16px;
}

.site-auth {
  display: flex;
  align-items: baseline;
  color: var(--muted);
}

.site-auth .sep {
  margin: 0 0.7em;
  color: var(--faint);
}

.site-nav ul,
.site-foot ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* разделитель после пункта, а не перед: при переносе строка не начинается с точки */
.site-nav li:not(:last-child)::after,
.site-foot li:not(:last-child)::after {
  content: "·";
  margin: 0 0.7em;
  color: var(--faint);
}

.site-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 20px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

/* ---------- заголовки разделов ---------- */

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 18px;
  color: var(--muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-title a {
  text-transform: none;
  letter-spacing: 0.01em;
}

/* мигающий курсор у микроблога — привет тегу <blink> */
.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 0.35em;
  background: var(--accent);
  vertical-align: -0.12em;
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor {
    animation: none;
  }
}

/* ---------- лента заголовков ---------- */

.year {
  margin: 0 0 8px;
  color: var(--faint);
  font-weight: 400;
}

section + section > .year {
  margin-top: 26px;
}

.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-row {
  display: grid;
  grid-template-columns: 4.2em minmax(0, 1fr);
  align-items: baseline;
  padding: 5px 0;
}

.post-row-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.post-row-title {
  font-size: 19px;
  line-height: 1.35;
}

.pin {
  width: 0.72em;
  height: 0.72em;
  margin-left: 0.4em;
  color: var(--muted);
  transform: rotate(40deg);
}

/* ---------- главная: публикации + микроблог ---------- */

.home {
  max-width: var(--page);
}

@media (min-width: 980px) {
  .home {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
    column-gap: 72px;
  }

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

  .home-main .page-main {
    flex: 1;
  }

  /* колонка микроблога закреплена и прокручивается сама */
  .home-notes {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    margin-right: calc(var(--gutter) * -1);
    padding: 44px var(--gutter) 40px 40px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-left: 1px solid var(--line);
    scrollbar-width: thin;
  }
}

@media (max-width: 979px) {
  /* на телефоне микроблог идёт первым и показывает только свежее */
  .home {
    display: flex;
    flex-direction: column;
  }

  .home-main {
    display: contents;
  }

  .home-main .site-head {
    order: 1;
  }

  .home-notes {
    order: 2;
    padding: 4px 0 30px;
  }

  .home-notes:not(.is-fullscreen) .note:nth-of-type(n + 4) {
    display: none;
  }

  /* «показать ещё» раскрывает микроблог на весь экран; лента листается внутри и подгружается сама */
  html.notes-open {
    overflow: hidden;
  }

  .home-notes.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 20;
    padding: 0 var(--gutter) calc(40px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg);
    animation: notes-in 0.18s ease-out;
  }

  .home-notes.is-fullscreen > .section-title {
    display: none; /* его место занимает закреплённая шапка с «закрыть» */
  }

  .home-notes.is-fullscreen .notes-bar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin: 0 calc(var(--gutter) * -1) 18px;
    padding: calc(14px + env(safe-area-inset-top)) var(--gutter) 12px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .notes-bar .link-button {
    padding: 6px 0 6px 12px; /* область нажатия побольше */
    letter-spacing: 0.01em;
    text-transform: none;
  }

  .home-main .page-main {
    order: 3;
    min-height: 0;
    padding-top: 26px;
    border-top: 1px solid var(--line);
  }

  .home-main .site-foot {
    order: 4;
  }
}

/* ---------- заметки микроблога ---------- */

.note {
  padding: 16px 0;
  border-top: 1px dashed var(--line);
}

.note:first-of-type {
  padding-top: 0;
  border-top: 0;
}

/* в ленте заметка кликабельна целиком: ведёт на свою страницу с комментариями */
.notes-feed .note {
  cursor: pointer;
}

.notes-feed .note:hover .note-text {
  color: #f4f1e8;
}

.notes-feed .note .note-edit,
.notes-feed .note .note-menu {
  cursor: auto;
}

.note-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

/* «три точки» владельца: изменить или удалить заметку */
.note-menu {
  position: relative;
  font-family: var(--mono);
  font-size: 13px;
}

.note-menu-toggle {
  margin: -6px -8px -6px 0; /* область нажатия больше самого знака, строка при этом не растёт */
  padding: 6px 8px;
  border: 0;
  background: none;
  color: var(--faint);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.note-menu-toggle:hover,
.note-menu-toggle[aria-expanded="true"] {
  color: var(--text);
}

.note-menu-toggle:focus-visible {
  outline: 1px dashed var(--text);
  outline-offset: -2px;
}

.note-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  white-space: nowrap;
}

.note-menu-ask {
  color: var(--muted);
}

.note-edit {
  margin-bottom: 0;
}

.note-date a,
.note-date a:visited {
  color: var(--muted);
  text-decoration: none;
}

.note-date a:hover {
  background: var(--muted);
  color: var(--bg);
}

.note-text {
  font-size: 17px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.note-text p + p {
  margin-top: 0.6em;
}

.notes-more,
.notes-empty {
  margin-top: 18px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
}

.notes-bar {
  display: none; /* шапка полноэкранного режима, см. мобильный блок выше */
}

.notes-tail:empty {
  height: 1px; /* пустой хвост остаётся в потоке: за ним следит автоподгрузка */
  margin: 0;
}

/* десктоп и полный экран листаются сами — там кнопки нет; в свёрнутой мобильной ленте нет хвоста */
.home-notes.is-fullscreen .notes-expand {
  display: none;
}

@media (min-width: 980px) {
  .notes-expand {
    display: none;
  }
}

@media (max-width: 979px) {
  .home-notes:not(.is-fullscreen) .notes-tail {
    display: none;
  }
}

@keyframes notes-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-notes.is-fullscreen {
    animation: none;
  }
}

.note-single .note-text {
  font-size: 21px;
  line-height: 1.5;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 32px;
  font-family: var(--mono);
  font-size: 13px;
}

/* ---------- формы: вход, быстрая заметка, комментарий ---------- */

/*
 * Элементы форм — одни на сайт и админку (админка подключает этот файл).
 * Минимум оформления: поле — заливка и тонкая рамка, кнопка — рамка без заливки, главная кнопка —
 * акцентная. Без теней, переходов и анимаций. База написана через :where(), то есть с нулевой
 * специфичностью: панели редактора и прочие кнопки «со своим лицом» перекрывают её обычным
 * правилом, без !important.
 */

:where(button, input, select, textarea) {
  color: inherit;
  font: inherit;
}

:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"], [type="range"], [type="color"]), select, textarea) {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  font-family: var(--serif);
  font-size: 16px; /* меньше 16px — iOS зумит страницу при фокусе */
  line-height: 1.45;
}

:where(textarea) {
  display: block;
  resize: vertical;
}

:where(input, select, textarea)::placeholder {
  color: var(--faint);
  opacity: 1;
}

:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"]), select, textarea):focus {
  border-color: var(--muted);
  outline: 0;
}

:where(input[type="checkbox"], input[type="radio"]) {
  accent-color: var(--accent);
}

input[type="file"] {
  max-width: 100%;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
}

/* кнопка: <button> без своего оформления, а также .btn / .site-btn (в том числе на ссылках) */
:where(button, input[type="submit"], input[type="button"], input[type="reset"]),
.btn,
.site-btn,
input[type="file"]::file-selector-button {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  margin-right: 10px;
}

a.btn,
a.btn:visited,
a.btn:hover {
  background: none;
  color: var(--text);
  text-decoration: none;
}

:where(button, input[type="submit"], input[type="button"], input[type="reset"]):hover,
.btn:hover,
.site-btn:hover,
.btn.active {
  border-color: var(--text);
}

:where(button, input[type="submit"], input[type="button"], input[type="reset"]):focus-visible,
.btn:focus-visible,
.site-btn:focus-visible {
  outline: 1px dashed var(--text);
  outline-offset: 2px;
}

/* главная кнопка формы */
.btn.btn-primary,
a.btn.btn-primary,
a.btn.btn-primary:visited,
.site-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: #000;
}

.btn.btn-danger {
  border-color: transparent;
  color: var(--danger);
}

.btn.btn-danger:hover {
  border-color: var(--danger);
}

.btn.btn-sm {
  padding: 2px 9px;
  font-size: 12.5px;
}

:where(button, input[type="submit"], input[type="button"], input[type="reset"]):disabled,
.btn:disabled,
.site-btn:disabled {
  border-color: var(--line);
  background: none;
  color: var(--faint);
  cursor: default;
}

/* кнопка, которая выглядит как ссылка: «выйти», «ответить», «удалить» */
.textbtn,
.linklike,
.link-button {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0; /* подсветка при наведении — прямоугольная, как у ссылок */
  background: none;
  color: var(--link);
  font: inherit;
  text-align: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  white-space: normal;
  cursor: pointer;
}

.textbtn:hover,
.linklike:hover,
.link-button:hover {
  background: var(--link);
  color: var(--bg);
  text-decoration: none;
}

.textbtn.danger,
.linklike.danger,
.link-button.is-danger {
  color: var(--danger);
}

.textbtn.danger:hover,
.linklike.danger:hover,
.link-button.is-danger:hover {
  background: var(--danger);
}

.textbtn:focus-visible,
.linklike:focus-visible,
.link-button:focus-visible {
  outline: 1px dashed var(--text);
  outline-offset: 3px;
}

.textbtn:disabled,
.linklike:disabled,
.link-button:disabled {
  background: none;
  color: var(--muted);
  text-decoration: none;
  cursor: default;
}

/* подпись над полем */
.field,
.form-field {
  display: block;
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.field > span,
.form-field > span,
.form-field > legend {
  display: block;
  margin-bottom: 5px;
  padding: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
}

.checkbox {
  display: flex;
  align-items: baseline; /* у длинной подписи галочка стоит у первой строки */
  gap: 8px;
  margin-bottom: 14px;
  cursor: pointer;
}

.auth-form {
  max-width: 340px;
}

.auth-hp {
  position: absolute;
  left: -9999px;
}

.form-error,
.login-error,
.editor-warning {
  margin: 8px 0 12px;
  color: var(--danger);
  font-family: var(--mono);
  font-size: 13px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 18px;
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 13px;
}

.composer {
  margin-bottom: 22px;
}

.composer textarea {
  min-height: 3.6em;
  max-height: 60vh;
  resize: none;
}

.composer-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--faint);
}

/* ---------- комментарии ---------- */

.comments {
  margin-top: 40px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.comment {
  padding: 16px 0;
  border-top: 1px dashed var(--line);
}

.comment:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.comment .meta {
  margin-bottom: 6px;
}

/* разделитель после пункта, а не перед: при переносе строка не начинается с точки */
.comment .meta > * + *::before {
  content: none;
}

.comment .meta > *:not(:last-child)::after {
  content: "·";
  margin: 0 0.7em;
  color: var(--faint);
}

.comment .meta a,
.comment .meta a:visited {
  color: var(--muted);
  text-decoration: none;
}

.comment .meta a:hover {
  background: var(--muted);
  color: var(--bg);
}

/* имя стало ссылкой на профиль — перебиваем серый цвет ссылок в мете */
.comment .meta a.comment-owner,
.comment .meta a.comment-owner:visited {
  color: var(--accent);
}

.comment .meta a.comment-owner:hover {
  background: var(--accent);
  color: var(--bg);
}

.comments .composer {
  margin: 22px 0 0;
}

.comments-login {
  margin-top: 18px;
  color: var(--muted);
}

/* ветка: ответы с отступом и линией слева, как цитата в письме */
.thread {
  padding: 16px 0;
  border-top: 1px dashed var(--line);
}

.thread:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.thread .comment {
  padding: 0;
  border: 0;
}

.replies {
  margin: 14px 0 0;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.replies .comment + .comment,
.replies .comment + .composer {
  margin-top: 14px;
}

.comments .replies .composer {
  margin-bottom: 0;
}

.comment-gif,
.composer-gif img {
  display: block;
  width: auto;
  max-width: min(100%, 360px);
  height: auto;
  max-height: 320px;
  margin-top: 8px;
}

.composer-gif {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 14px;
  font-family: var(--mono);
  font-size: 13px;
}

.composer-gif img {
  max-height: 140px;
}

.composer-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
}

.composer-foot {
  flex-wrap: wrap;
}

.emoji-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 8px;
  padding: 6px;
  border: 1px solid var(--line);
}

.emoji-panel button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.gif-panel {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 13px;
}

.gif-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 264px;
  margin-top: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.gif-grid button {
  flex: 1 0 auto;
  height: 84px;
  max-width: 100%;
  padding: 0;
  border: 1px solid transparent;
  background: var(--line);
  cursor: pointer;
}

.gif-grid button:hover,
.gif-grid button:focus-visible {
  border-color: var(--accent);
  outline: 0;
}

.gif-grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gif-note {
  padding: 12px 4px;
  color: var(--muted);
}

.gif-foot {
  margin-top: 8px;
}

.emoji-panel button:hover,
.emoji-panel button:focus-visible {
  background: var(--line);
  outline: 0;
}

/* ---------- заголовок страницы (тег, автор, заметки, 404) ---------- */

.page-title {
  margin-bottom: 8px;
  font-size: 28px;
}

.page-lead {
  margin-bottom: 30px;
  color: var(--muted);
}

.page-title + * {
  margin-top: 30px;
}

/* ---------- пост ---------- */

.single-head {
  margin-bottom: 34px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 14px;
  color: var(--muted);
}

.meta > * + *::before {
  content: "·";
  margin: 0 0.7em;
  color: var(--faint);
}

.single-title {
  font-size: clamp(30px, 5.2vw, 42px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.single-media {
  margin: 30px 0 0;
}

.single-media img {
  display: block;
  width: 100%;
  height: auto;
}

figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
}

.single-foot {
  margin-top: 56px;
}

.prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.prevnext-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
}

.prevnext-next {
  text-align: right;
}

.related {
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

/* ---------- тело поста ---------- */

.content {
  font-size: 19px;
  line-height: 1.65;
  overflow-wrap: break-word;
}

.content > * {
  margin-top: 0;
  margin-bottom: 0;
}

.content > * + * {
  margin-top: 1.15em;
}

.content > h1,
.content > h2,
.content > h3,
.content > h4 {
  margin-top: 1.9em;
}

.content > h1 + *,
.content > h2 + *,
.content > h3 + *,
.content > h4 + * {
  margin-top: 0.6em;
}

.content h1 {
  font-size: 1.55em;
}

.content h2 {
  font-size: 1.4em;
}

.content h3 {
  font-size: 1.18em;
}

.content h4 {
  font-size: 1em;
}

.content ul,
.content ol {
  padding-left: 1.3em;
}

.content li + li {
  margin-top: 0.35em;
}

.content li::marker {
  color: var(--muted);
}

.content blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: 1.1em;
  border-left: 2px solid var(--accent);
  color: var(--text);
  font-style: italic;
}

.content code,
.content pre {
  font-family: var(--mono);
  font-size: 0.82em;
}

.content :not(pre) > code {
  padding: 0.1em 0.35em;
  border: 1px solid var(--line);
}

.content pre {
  padding: 16px 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  line-height: 1.5;
}

.content table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.85em;
}

.content th,
.content td {
  padding: 6px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

/* чек-лист */
.content ul[data-type="taskList"] {
  padding-left: 0;
  list-style: none;
}

.content ul[data-type="taskList"] li {
  display: flex;
  gap: 0.6em;
}

.content ul[data-type="taskList"] li > label {
  flex: 0 0 auto;
  user-select: none;
}

.content ul[data-type="taskList"] li > div {
  flex: 1;
  min-width: 0;
}

.content ul[data-type="taskList"] input[type="checkbox"] {
  accent-color: var(--accent);
}

.content ul[data-type="taskList"] li[data-checked="true"] > div {
  color: var(--muted);
  text-decoration: line-through;
}

/* сворачиваемый блок — родной <details>, работает без JS */
.content details {
  padding: 0.7em 1em;
  border: 1px solid var(--line);
}

.content details summary {
  font-weight: 700;
  cursor: pointer;
}

.content details summary::marker {
  color: var(--muted);
}

.content details[open] summary {
  margin-bottom: 0.7em;
}

.content details [data-type="detailsContent"] > * + * {
  margin-top: 0.8em;
}

.content th {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.9em;
  font-weight: 400;
}

.content td > p,
.content th > p {
  margin: 0;
}

.content figure {
  margin-left: 0;
  margin-right: 0;
}

.content .kg-card {
  margin-top: 1.7em;
}

.content .kg-card + * {
  margin-top: 1.7em;
}

.content img {
  height: auto;
}

.content .kg-image-card img,
.content .kg-gallery-image img {
  display: block;
  margin: 0 auto;
}

.content .kg-gallery-image img {
  width: 100%;
  height: 100%;
}

/* широкие карточки выходят за колонку текста */
@media (min-width: 760px) {
  .content .kg-width-wide,
  .content .kg-width-full {
    position: relative;
    left: 50%;
    width: min(920px, 100vw - var(--gutter) * 2);
    max-width: none;
    transform: translateX(-50%);
  }

  .content .kg-width-wide img,
  .content .kg-width-full img {
    width: 100%;
  }
}

.content .kg-embed-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.content .kg-embed-card iframe[src*="youtube"],
.content .kg-embed-card iframe[src*="vimeo"],
.content .kg-embed-card iframe[src*="rutube"],
.content .kg-embed-card iframe[src*="vk.com"],
.content .kg-embed-card iframe[src*="vkvideo"] {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

/* закладка — текстом, без превью: только рамка, заголовок и источник */
.content .kg-bookmark-card a.kg-bookmark-container,
.content .kg-bookmark-card a.kg-bookmark-container:hover {
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
}

.content .kg-bookmark-card a.kg-bookmark-container:hover {
  border-color: var(--muted);
}

.content .kg-bookmark-content {
  padding: 16px 18px;
  font-family: var(--serif);
}

.content .kg-bookmark-title {
  color: var(--link);
  font-size: 17px;
  font-weight: 400;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.content .kg-bookmark-description {
  font-size: 15px;
}

.content .kg-bookmark-metadata {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 400;
}

.content .kg-bookmark-thumbnail,
.content .kg-bookmark-icon {
  display: none;
}

.content .kg-callout-card,
.content .kg-cta-card {
  border-radius: 0;
  color: var(--text);
}

.content .kg-callout-card div.kg-callout-text,
.content .kg-cta-text {
  font-size: 0.92em;
}

.content .kg-cta-text p + p {
  margin-top: 0.7em;
}

.content .kg-cta-card a.kg-cta-button,
.content .kg-button-card a.kg-btn {
  border: 1px solid var(--text);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.content .kg-cta-card a.kg-cta-button:hover,
.content .kg-button-card a.kg-btn:hover {
  background: var(--text);
  color: var(--bg);
  opacity: 1;
}

.content .kg-video-card,
.content .kg-video-container {
  border-radius: 0;
}

/* ---------- телефон ---------- */

@media (max-width: 600px) {
  :root {
    --gutter: 18px;
  }

  body {
    font-size: 17px;
  }

  .site-head {
    padding: 26px 0 22px;
  }

  .content {
    font-size: 18px;
  }

  /* колонка рассчитана на полную дату «31.12.25» — она у закрепов и в «По теме» */
  .post-row {
    grid-template-columns: 4.4em minmax(0, 1fr);
  }

  .post-row-title {
    font-size: 18px;
  }

  .prevnext {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .prevnext-next {
    text-align: left;
  }
}

/* ---------- профиль и аватары ---------- */

.avatar {
  display: inline-block;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: -0.3em;
}

/* нет своей картинки — контурная иконка в кружке (components/site/Avatar.tsx) */
.avatar-empty {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--faint);
  color: var(--muted);
}

.avatar-empty svg {
  width: 62%;
  height: 62%;
}

.avatar-lg {
  width: 96px;
  height: 96px;
}

.comment-author {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
}

.comment-title {
  color: var(--faint);
}

.form-hint {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
}

.profile-form {
  max-width: 460px;
}

.profile-avatar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.profile-avatar .form-actions {
  margin: 0 0 4px;
}

.profile-links {
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.profile-links input + input {
  margin-top: 6px;
}

.person {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 26px;
}

.person .page-title,
.person .page-lead {
  margin-bottom: 0;
}

.person .page-title + .page-lead {
  margin-top: 4px;
}

.person-bio {
  margin-bottom: 22px;
}

/* соцсети значками */
.social {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 0 0 26px;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 13px;
}

.social a,
.social a:visited {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  text-decoration: none;
}

/* у значка вместо инверсии, как у текстовых ссылок, просто светлеет цвет */
.social a:hover,
.social a:visited:hover {
  background: none;
  color: var(--text);
}

.social svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.social .social-generic {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}
