/* Будка — «Журнал». Один файл стилей вместо style.css + link.css + login.css + плагинов. */

:root {
  --bg: #efefea;
  --paper: #ffffff;
  --ink: #111111;
  --ink-2: #3d3d38;
  --muted: #55554f;
  --line: #d9d9d2;
  --accent: #ff6a2b;
  --accent-ink: #111111;
  --dark: #111111;
  --dark-2: #222222;
  --dark-text: #f4f4ef;
  --dark-muted: #b9b9b2;
  --pos: #2f7a1f;
  --neg: #c0392b;
  --radius: 22px;
  --radius-sm: 14px;
  --gap: 20px;
  --display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --body: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--ink); text-underline-offset: 3px; }
a:hover { color: var(--ink-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { line-height: 1.2; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; }
.skip:focus { top: 8px; color: #fff; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 24px;
  border: 2px solid transparent; background: none; cursor: pointer;
  font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: transform .12s ease, background-color .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn--ink { background: var(--ink); color: #fff; }
.btn--ink:hover { background: #2a2a2a; color: #fff; }
.btn--line { border-color: var(--ink); color: var(--ink); }
.btn--line:hover { background: var(--paper); }
.btn--ghost { color: var(--ink); }
.btn--ghost:hover { background: rgba(0,0,0,.06); }
.btn--accent { background: var(--accent); color: var(--accent-ink); }
.btn--big { min-height: 56px; padding: 0 36px; border-radius: 28px; border-color: var(--ink); font-family: var(--display); font-weight: 700; font-size: 16px; }
.btn--big:hover { background: var(--ink); color: #fff; }
.btn[aria-busy="true"] { opacity: .6; pointer-events: none; }
.link { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; color: inherit; }
.link--danger { color: var(--neg); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 22px; background: none; cursor: pointer; }
.icon-btn:hover { background: rgba(0,0,0,.06); }

/* ---------------------------------------------------------------- шапка */
.site-head { padding-top: 28px; }
.site-head__top { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.logo {
  font-family: var(--display); font-weight: 900; font-size: 44px; line-height: 1;
  letter-spacing: -0.04em; text-decoration: none; color: var(--ink);
}
.logo span { color: var(--accent); }
.logo--small { font-size: 26px; }
.tagline { margin: 0; max-width: 220px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.site-head__actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.cats {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-top: 28px; padding-bottom: 20px; border-bottom: 2px solid var(--ink);
}
.pill {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px;
  border-radius: 22px; background: var(--paper); color: var(--ink);
  text-decoration: none; font-weight: 600; font-size: 15px; cursor: pointer; list-style: none;
}
.pill::-webkit-details-marker { display: none; }
.pill:hover { background: #fafaf7; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.pill.is-active { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.pill--sm { min-height: 38px; padding: 0 14px; font-size: 14px; }

.more { position: relative; }
.more summary::after { content: ""; width: 7px; height: 7px; margin-left: 8px; border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.more[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.more__menu {
  position: absolute; z-index: 20; top: calc(100% + 8px); left: 0; min-width: 220px;
  display: flex; flex-direction: column; padding: 8px; border-radius: 18px;
  background: var(--paper); box-shadow: 0 12px 40px rgba(0,0,0,.16);
}
.more__menu a { padding: 11px 14px; border-radius: 12px; text-decoration: none; font-weight: 500; }
.more__menu a:hover, .more__menu a.is-active { background: var(--bg); }

/* ---------------------------------------------------------------- лента */
main.wrap { padding-top: 28px; padding-bottom: 64px; }
.feed-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.feed-head h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 32px; letter-spacing: -0.02em; }
.feed-head .btn { margin-left: auto; }

/* Без JS — одна колонка в порядке записей; JS раскладывает «кирпичами» (см. app.js). */
.feed { display: grid; gap: var(--gap); max-width: 720px; margin: 0 auto; }
.feed.is-masonry { display: flex; align-items: flex-start; gap: var(--gap); max-width: none; }
.feed__col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }

.feed-more { display: flex; flex-direction: column; align-items: center; gap: 22px; padding-top: 36px; }
.pager { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; align-items: center; }
.pager__n { min-width: 40px; height: 40px; padding: 0 8px; display: grid; place-items: center; border-radius: 20px; text-decoration: none; font-size: 14px; color: var(--muted); }
.pager__n:hover { background: var(--paper); color: var(--ink); }
.pager__n.is-current { background: var(--ink); color: #fff; font-weight: 600; }
.pager__gap { color: var(--muted); padding: 0 4px; }

/* ---------------------------------------------------------------- карточки */
.card { background: var(--paper); border-radius: var(--radius); overflow: hidden; }
.card__inner { padding: 24px 26px 22px; }
.card__cover { display: block; background: var(--line); }
.card__cover img { display: block; width: 100%; max-height: 520px; object-fit: cover; }

.card__meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.card__cat { font-weight: 600; color: var(--ink); text-decoration: none; }
.card__cat:hover { text-decoration: underline; }
.card__num { color: inherit; text-decoration: none; white-space: nowrap; }
.card__num:hover { color: var(--ink); text-decoration: underline; }

.card__foot { display: flex; align-items: center; gap: 14px; margin-top: 18px; font-size: 14px; flex-wrap: wrap; }
.card__replies { font-weight: 600; }
.card__views { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-left: auto; font-size: 13px; }
.card__more { display: inline-block; margin-top: 10px; font-weight: 600; font-size: 14px; }

.card__thread { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.card__thread-more { font-size: 13px; color: var(--muted); }
.reply-mini { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 16px; }
.reply-mini__meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; }

/* плакат: короткий текст крупно на акцентном фоне */
.card--poster { background: var(--accent); color: var(--accent-ink); }
.card--poster .card__meta, .card--poster .card__cat, .card--poster .card__views { color: var(--accent-ink); }
.card--poster .card__meta { font-weight: 600; }
.card--poster .vote__btn { background: rgba(255,255,255,.35); }
.card--poster .vote__n.is-pos, .card--poster .vote__n.is-neg { color: var(--accent-ink); }

/* тёмная карточка — для ритма ленты */
.card--ink { background: var(--dark); color: var(--dark-text); }
.card--ink a, .card--ink .card__cat { color: var(--dark-text); }
.card--ink .card__meta, .card--ink .card__views, .card--ink .reply-mini__meta, .card--ink .card__thread-more { color: var(--dark-muted); }
.card--ink .reply-mini { background: var(--dark-2); }
.card--ink .vote__btn { background: var(--dark-2); color: var(--dark-text); }
.card--ink .vote__n.is-pos { color: #8fd16f; }
.card--ink .vote__n.is-neg { color: #ff8a7a; }
.card--ink .prose a.reply-ref { color: var(--accent); }

.card--invite { background: transparent; border: 2px dashed var(--ink); }
.invite__title { margin: 0 0 6px; font-family: var(--display); font-size: 20px; font-weight: 700; }
.invite__fake {
  display: block; width: 100%; margin-top: 14px; min-height: 84px; padding: 14px;
  border: 0; border-radius: var(--radius-sm); background: var(--paper); color: var(--muted);
  text-align: left; cursor: text; font-size: 15px;
}

.card--single { border-radius: 26px; }
.card--single .card__inner { padding: 30px 34px 26px; }

/* ---------------------------------------------------------------- текст поста */
.prose { overflow-wrap: anywhere; font-size: 16px; line-height: 1.6; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose details, .prose figure { margin: 0 0 .8em; }
.prose h3, .prose h4 { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; margin: .2em 0 .5em; }
.prose h3 { font-size: 22px; }
.prose h4 { font-size: 18px; }
.prose img { display: block; margin: 12px auto; border-radius: 12px; cursor: zoom-in; }
.prose img[data-nolightbox] { cursor: default; }
.prose blockquote { border-left: 3px solid var(--accent); padding-left: 14px; color: var(--ink-2); }
.prose pre { background: var(--bg); padding: 12px 14px; border-radius: 12px; overflow-x: auto; font-size: 14px; }
.prose .center { text-align: center; }
.prose details { background: var(--bg); border-radius: 12px; padding: 10px 14px; }
.prose summary { cursor: pointer; font-weight: 600; }
.prose details[open] summary { margin-bottom: 6px; }
.prose audio { width: 100%; margin: 6px 0; }
.prose figcaption { font-size: 14px; font-weight: 600; }
.prose .embed { position: relative; aspect-ratio: 16 / 9; margin: 12px 0; border-radius: 12px; overflow: hidden; background: #000; }
.prose .embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.prose .table-wrap { overflow-x: auto; }
.prose table { border-collapse: collapse; }
.prose td, .prose th { border: 1px solid var(--line); padding: 6px 10px; }
.card--ink .prose details, .card--ink .prose pre { background: var(--dark-2); }

.prose--poster { font-family: var(--display); font-weight: 700; font-size: 25px; line-height: 1.22; letter-spacing: -0.02em; }
.card--quote .prose--poster { font-weight: 500; font-size: 21px; line-height: 1.3; }
.prose--large { font-size: 18px; line-height: 1.65; }
.prose--small { font-size: 15px; line-height: 1.5; }
.prose--small img { max-height: 220px; width: auto; margin: 8px 0; }
.prose.is-clamped { max-height: 24em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }

/* ---------------------------------------------------------------- голосование */
.vote { display: inline-flex; align-items: center; gap: 6px; }
.vote__btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: 20px; background: var(--bg); color: var(--ink); cursor: pointer;
}
.vote__btn:hover:not(:disabled) { background: var(--ink); color: #fff; }
.vote__btn:disabled { opacity: .35; cursor: default; }
.vote__n { min-width: 34px; text-align: center; font-weight: 700; }
.vote__n.is-pos { color: var(--pos); }
.vote__n.is-neg { color: var(--neg); }

.own { position: relative; }
.own summary { list-style: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 18px; cursor: pointer; }
.own summary::-webkit-details-marker { display: none; }
.own summary:hover { background: rgba(0,0,0,.07); }
.card--ink .own summary:hover, .card--poster .own summary:hover { background: rgba(255,255,255,.15); }
.own__menu { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 10; display: flex; flex-direction: column; min-width: 170px; padding: 6px; border-radius: 14px; background: var(--paper); box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.own__menu button { text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: none; cursor: pointer; color: var(--ink); }
.own__menu button:hover { background: var(--bg); }
.own__menu button[data-delete] { color: var(--neg); }

/* редактирование на месте */
.inline-edit { display: flex; flex-direction: column; gap: 10px; }
.inline-edit__actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------------------------------------------------------- страница записи */
.single { max-width: 780px; margin: 0 auto; }
.back { display: inline-block; margin-bottom: 16px; font-weight: 600; text-decoration: none; }
.back:hover { text-decoration: underline; }
.replies { margin-top: 34px; }
.replies h2 { font-family: var(--display); font-size: 22px; font-weight: 700; margin: 0 0 16px; }
.reply { background: var(--paper); border-radius: 18px; padding: 18px 22px; margin-bottom: 10px; scroll-margin-top: 20px; }
.reply:target { box-shadow: 0 0 0 3px var(--accent); }
.reply__meta { display: flex; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.reply__num { font-weight: 600; color: var(--ink); text-decoration: none; }
.reply__foot { display: flex; align-items: center; gap: 16px; margin-top: 10px; font-size: 14px; flex-wrap: wrap; }
.reply__foot .vote__btn { width: 34px; height: 34px; }
.reply-form { margin-top: 22px; padding: 22px; border: 2px dashed var(--ink); border-radius: var(--radius); display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.reply-form h3 { margin: 0; font-family: var(--display); font-size: 18px; }
.reply-form .editor { width: 100%; }

/* ---------------------------------------------------------------- редактор */
.editor { border-radius: var(--radius-sm); background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.editor:focus-within { box-shadow: inset 0 0 0 2px var(--ink); }
.editor.is-drop { box-shadow: inset 0 0 0 3px var(--accent); background: #fff7f2; }
.editor textarea[aria-busy="true"] { opacity: .6; }
.editor__bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: #fafaf7; }
.editor__bar button { min-width: 38px; height: 38px; padding: 0 8px; border: 0; border-radius: 10px; background: none; cursor: pointer; font-size: 14px; color: var(--ink); display: grid; place-items: center; }
.editor__bar button:hover { background: var(--bg); }
.editor textarea { display: block; width: 100%; border: 0; padding: 14px; resize: vertical; min-height: 110px; background: transparent; outline: none; font-size: 16px; line-height: 1.55; }

/* ---------------------------------------------------------------- формы, диалоги */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field input, .field select, .field textarea { font-weight: 400; font-size: 16px; min-height: 48px; padding: 10px 14px; border: 0; border-radius: var(--radius-sm); background: var(--bg); }
.field textarea { resize: vertical; }
.modal { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0; border-radius: 26px; background: var(--paper); color: var(--ink); }
.modal::backdrop { background: rgba(17,17,17,.55); }
.modal__body { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; }
.modal__head h2 { margin: 0; font-family: var(--display); font-size: 22px; }
.modal__body > .muted { margin: -6px 0 0; font-size: 14px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; }
.modal .field select { background: var(--bg); }

.lightbox { padding: 0; border: 0; background: transparent; max-width: 100vw; max-height: 100vh; }
.lightbox::backdrop { background: rgba(0,0,0,.88); }
.lightbox img { display: block; max-width: 94vw; max-height: 90vh; border-radius: 10px; cursor: zoom-out; }
.lightbox__close { position: fixed; top: 12px; right: 12px; color: #fff; background: rgba(255,255,255,.12); }

.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 16px; font-size: 15px; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: min(480px, calc(100vw - 32px)); animation: toast-in .2s ease; }
.toast--error { background: var(--neg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.filters__row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 14px; }
.filters__row .muted { margin-right: 4px; }

.empty { text-align: center; padding: 60px 0; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.empty__big { margin: 0; font-family: var(--display); font-weight: 700; font-size: 28px; }
.empty__huge { margin: 0; font-family: var(--display); font-weight: 900; font-size: clamp(64px, 14vw, 140px); line-height: 1; color: var(--accent); }
.empty__text { margin: 0; max-width: 460px; color: var(--ink-2); font-size: 17px; }

.narrow { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.form .card__inner { display: flex; flex-direction: column; gap: 14px; }
.form h1, .form h2, .narrow h1 { margin: 0; font-family: var(--display); font-size: 22px; }
.narrow form { display: flex; gap: 8px; flex-wrap: wrap; }
.alert { margin: 0; padding: 14px 18px; border-radius: var(--radius-sm); background: var(--paper); font-weight: 600; }
.alert--error { background: #ffe1d9; color: #7a1d0b; }

/* ---------------------------------------------------------------- подвал */
.site-foot { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding-top: 28px; padding-bottom: 40px; border-top: 2px solid var(--ink); font-size: 14px; color: var(--muted); }
.site-foot nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-foot p { margin: 0 0 0 auto; }

/* ---------------------------------------------------------------- мобильный */
@media (max-width: 700px) {
  .wrap { padding: 0 12px; }
  .site-head { padding-top: 16px; }
  .logo { font-size: 30px; }
  .tagline { display: none; }
  .site-head__actions .btn--line span { display: none; }
  .site-head__actions .btn--line { width: 44px; min-height: 44px; padding: 0; }
  .site-head__actions .btn--ink { min-height: 44px; padding: 0 16px; }
  .cats { flex-wrap: nowrap; overflow-x: auto; margin: 14px -12px 0; padding: 0 12px 14px; scrollbar-width: none; border-bottom-width: 0; }
  .cats::-webkit-scrollbar { display: none; }
  .pill { flex: 0 0 auto; min-height: 40px; padding: 0 16px; font-size: 14px; }
  .more { position: static; }
  .more__menu { left: 12px; right: 12px; top: auto; }
  main.wrap { padding-top: 8px; padding-bottom: 40px; }
  .site-head__top { flex-wrap: nowrap; gap: 10px; }
  .site-head__actions { flex-wrap: nowrap; gap: 8px; }
  .hide-sm { display: none; }
  .card__inner { padding: 20px; }
  .card--single .card__inner { padding: 22px 20px; }
  .prose--poster { font-size: 21px; }
  .prose--large { font-size: 17px; }
  .feed-head h1 { font-size: 26px; }
  .site-foot { padding-top: 20px; padding-bottom: 28px; gap: 14px; }
  .site-foot p { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
