:root {
  --accent: #1473E6;
  --bg: #0B0B0B;
  --panel: #1B1B1B;
  --card: #232323;
  --line: #3A3A3A;
  --text: #F2F2F2;
  --muted: #D0D0D0;
  --sub: #BDBDBD;
  --faint: #9A9A9A;
  --soft: #E0E0E0;
  --edge: #4A4A4A;
  --fill: #2A2A2A;
  --rule: #2E2E2E;
  --btn: #E8E8E8;
  --on-text: #141414;
  --strong: #fff;
  --card2: #141414;
  --link: #7DB4FF;
  --ok: #8CE6B0;
  --err: #FFB199;
  --glass: rgba(35, 35, 35, .82);
  --glow: rgba(255, 255, 255, .06);
  --shadow: rgba(0, 0, 0, .5);
  --icon-filter: invert(1);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
html[data-theme=light] { color-scheme: light; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 14px/1.45 Onest, system-ui, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p, ul { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Верхняя панель */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px;
  padding: 10px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.top-nav { flex-grow: 1; font-weight: 600; }
.top-nav a { display: block; padding: 12px 0; border-bottom: 2px solid var(--text); width: max-content; }
.top-right { display: flex; align-items: center; gap: 16px; max-width: 100%; }
.search-wrap { position: relative; min-width: 0; }
.search {
  display: flex; align-items: center; gap: 10px; width: 360px; max-width: 100%; min-width: 0;
  padding: 10px 16px; border: 1.5px solid var(--edge); border-radius: 999px;
}
.search:focus-within { border-color: var(--text); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; }
.search input::placeholder { color: var(--faint); }
.avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--fill); font-weight: 700; font-size: 13px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; text-transform: uppercase;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 88px; height: 88px; font-size: 34px; }

.rail-count {
  position: absolute; top: -2px; right: -4px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px;
  background: #E5352B; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}

.lang {
  flex: none; min-width: 44px; height: 44px; padding: 0 8px; border: 0; border-radius: 22px; background: none;
  color: var(--soft); font-weight: 700; font-size: 13px;
}
.lang:hover { background: var(--fill); }

/* Уведомления */
.bell-wrap { position: relative; flex: none; }
.bell {
  position: relative; width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: var(--soft);
  display: flex; align-items: center; justify-content: center;
}
.bell:hover, .bell[aria-expanded=true] { background: var(--fill); }
.bell-count {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: #E5352B; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.bell-panel {
  position: absolute; right: 0; top: 48px; width: min(340px, calc(100vw - 32px)); max-height: 420px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 30px var(--shadow);
}
.bell-panel .empty { padding: 16px; }
.note { display: flex; flex-direction: column; gap: 3px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.note:hover { background: var(--fill); }
.note.unread { box-shadow: inset 3px 0 0 var(--accent); }
.note-text { color: var(--muted); overflow-wrap: anywhere; }
.note-time { font-size: 12px; color: var(--sub); }

/* Левая панель и контент */
.shell { flex: 1; display: flex; min-height: 0; }
.rail { flex: 0 0 96px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0; }
.rail a {
  width: 72px; padding: 8px 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; color: var(--soft);
}
.rail-ico { position: relative; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.rail a:hover .rail-ico { background: var(--fill); }
.rail a[aria-current] { color: var(--strong); font-weight: 700; }
.rail a[aria-current] .rail-ico { background: var(--fill); }
.content { flex: 1; min-width: 0; background: var(--panel); border-top-left-radius: 16px; outline: 0; }

/* Вкладки категорий */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 18px 28px; border-bottom: 1px solid var(--rule); }
.tabs button {
  min-height: 40px; padding: 8px 14px; border: 0; border-radius: 6px;
  background: none; color: var(--soft); font-weight: 600;
}
.tabs button:hover { background: var(--fill); }
.tabs button[aria-pressed=true] { background: var(--text); color: var(--on-text); }

/* Сетка приложений */
.section { padding: 28px; display: flex; flex-direction: column; gap: 20px; }
.section h1 { font-size: 19px; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, max(300px, calc((100% - 32px) / 3))), 1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-height: 152px;
}
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head img { width: 30px; height: 30px; border-radius: 7px; flex: none; }
.card h2 { flex: 1; font-size: 16px; font-weight: 700; }
.card h2 a:hover { text-decoration: underline; }
.card p { flex: 1; color: var(--muted); }
.card-foot { display: flex; align-items: center; gap: 14px; }
.card-foot .dl, .card-foot .dl-linux, .card-foot .dl-android, .card-foot .dl-web, .card-foot .open { margin-left: auto; }
.card-act { margin-left: auto; display: flex; align-items: center; gap: 14px; min-width: 0; }
.card-dls { display: inline-flex; align-items: center; gap: 4px; color: var(--sub); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.link { font-weight: 600; color: var(--muted); }
.link:hover { color: var(--strong); text-decoration: underline; }
.btn {
  display: inline-block; padding: 6px 16px; border: 2px solid var(--btn); border-radius: 999px;
  background: none; font-weight: 700; white-space: nowrap;
}
.btn:hover { background: var(--btn); color: var(--on-text); }
.btn.primary { background: #1473E6; border-color: #1473E6; color: #fff; }
.btn.primary:hover { background: #0D66D0; border-color: #0D66D0; color: #fff; }
.btn.danger { border-color: var(--err); color: var(--err); }
.btn.danger:hover { background: var(--err); color: var(--on-text); }
.tabs-add { margin-left: auto; align-self: center; }
.card p.author, .app-head p.author { flex: none; font-size: 13px; color: var(--sub); }
.card.wide { grid-column: 1 / -1; }
.card.wide p { flex: none; }
.player { width: 100%; height: 360px; border: 0; border-radius: 6px; display: block; }
.player.review { height: auto; aspect-ratio: 16 / 9; border-radius: 8px; }
.empty { color: var(--muted); }

/* Промо-плитка */
.promo { position: relative; overflow: hidden; }
.promo .card-head, .promo p, .promo .card-foot { position: relative; }
.promo p { max-width: calc(100% - 120px); }
/* Круги в правом верхнем углу, выше кнопки «Скачать». */
.eggs {
  position: absolute; right: -16px; top: -16px; width: 120px; height: 120px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; transform: rotate(-12deg);
}
.eggs i { border-radius: 50%; }

/* Страница программы */
.app-bar {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 44px; border-bottom: 1px solid var(--rule); font-weight: 700; font-size: 15px;
}
.app-back { position: absolute; left: 8px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.app-page {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px;
  max-width: 1280px; margin: 0 auto; padding: 32px 28px;
}
.app-side {
  flex: 0 1 320px; min-width: 0; position: sticky; top: calc(var(--top-h) + 16px); display: flex; flex-direction: column; gap: 16px;
  padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
}
.app-title { display: flex; align-items: center; gap: 20px; }
.app-title img { width: 56px; height: 56px; border-radius: 10px; }
.app-title h1 { font-size: 24px; font-weight: 700; }
.app-platform {
  width: max-content; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding-bottom: 8px; border-bottom: 2px solid var(--text); font-size: 12px; font-weight: 700;
}
.app-desc { color: var(--muted); }
.app-meta { list-style: none; padding: 0; display: grid; gap: 12px; color: var(--muted); }
.app-meta li { display: flex; align-items: center; gap: 10px; }
.app-meta i {
  flex: none; width: 18px; height: 18px; border: 1.5px solid var(--faint); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 11px; font-weight: 700;
}
.app-meta i svg { width: 12px; height: 12px; }
.app-meta i.ok { border-color: #3DBE6C; color: #3DBE6C; }
.app-side .btn { text-align: center; }
.app-side .btn.primary { padding: 10px 26px; font-size: 15px; }
.report-link { text-align: center; }
.app-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; }
.app-links:empty { display: none; }
.app-main { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.app-main h2 { font-size: 15px; font-weight: 700; color: var(--muted); }
.app-main h2:not(:first-child) { margin-top: 14px; }
.use { display: flex; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
/* Гифка 540×608: держим не больше родного размера, иначе видно низкое разрешение */
.use img, .use video { flex: 0 1 340px; min-width: 0; max-width: 100%; height: auto; display: block; margin-left: auto;
  /* Flex тянет картинку на высоту текста: cover обрезает края вместо того, чтобы сплющить */
  object-fit: cover; }
/* Широкое демо: колонка пошире, а лишнее срезаем справа, слева обычно самое важное */
.use .wide { flex-basis: 50%; object-position: left center; }
.demo-preview { width: 72px; height: 81px; object-fit: cover; }
/* Кадр демо из формы программы: --x --y — видимая точка, --z — увеличение. Обёртка встаёт на место картинки и режет лишнее */
/* Кадр квадратный, как в окне кадрирования: что выбрали, то и видно */
.use .demo-box { flex: 0 1 340px; min-width: 0; max-width: 100%; margin-left: auto; align-self: center; aspect-ratio: 1; display: flex; overflow: hidden; }
.use .demo-box img, .use .demo-box video { flex: 1 1 auto; width: 100%; height: 100%; margin-left: 0; }
.demo-box img, .demo-box video, .demo-crop-stage img, .demo-crop-stage video {
  object-fit: cover; object-position: var(--x) var(--y); transform: scale(var(--z)); transform-origin: var(--x) var(--y); }
.r-crop-stage.demo-crop-stage { aspect-ratio: 1; max-width: 300px; }
.demo-crop-stage img, .demo-crop-stage video { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.r-crop-stage.demo-crop-stage::after { border-radius: 0; box-shadow: none; outline-color: transparent; }
.use-text { flex: 1 1 260px; min-width: 0; padding: 28px; display: flex; flex-direction: column; gap: 16px; justify-content: center; }
.use-lead { padding-left: 14px; border-left: 2px solid var(--text); font-weight: 700; }
.use-text ul { list-style: none; padding: 0; display: grid; gap: 14px; color: var(--muted); }

/* Комментарии */
.comment-form { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.comment-form textarea {
  width: 100%; padding: 10px 14px; background: var(--card); border: 1.5px solid var(--edge); border-radius: 6px;
  resize: vertical; font: inherit;
}
.comment-form textarea:focus { outline: 0; border-color: var(--accent); }
.comment-form .btn { cursor: pointer; }
#comment-list, .replies { display: flex; flex-direction: column; gap: 12px; }
.replies { margin-left: 32px; }
.comment-body .comment-form { margin-top: 6px; }
.comment { display: flex; gap: 12px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.comment.flash { border-color: var(--accent); }
.comment-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.comment-head span { font-size: 12px; color: var(--sub); }
.comment-body p { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
.comment-actions { display: flex; align-items: center; gap: 16px; }
.comment-actions .linkbtn { align-self: center; }
.like {
  display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px 4px 0;
  background: none; border: 0; color: var(--muted); font-weight: 600;
}
.like:hover, .like[aria-pressed=true] { color: #FF6F91; }

/* Панели по центру экрана: вход, профиль, формы, сообщения, статистика. Длинные просто прокручиваются. */
.content:has(> .panel) { display: flex; flex-direction: column; }
.panel { width: 100%; max-width: 640px; margin: auto; }
.panel.stats { max-width: 776px; }

/* Сообщения */
.inbox { max-width: 760px; }
.thread { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; padding-left: 14px; border-left: 2px solid var(--line); }
.message-reply { margin-top: 6px; }
.tag { padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.comment-head span.tag.bug { background: #E5352B; color: #fff; }
.comment-head span.tag.admin { background: #1473E6; color: #fff; }
.comment-head span.tag.idea { background: #1473E6; color: #fff; }
.comment-head span.tag.ok { background: #1E8E4E; color: #fff; }

/* Статистика */
.table-box { overflow-x: auto; max-width: 720px; }
.table-box table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table-box th, .table-box td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.table-box th:first-child { text-align: left; font-weight: 600; }
.table-box thead th { color: var(--muted); font-weight: 600; }
.stats-sub { font-size: 16px; font-weight: 700; }

/* Аккаунт и редактор */
.icon-pick { display: flex; align-items: center; gap: 16px; }
.icon-pick img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--fill); }
.icon-pick .btn { font-weight: 700; cursor: pointer; }
.icon-pick .btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.more { border-top: 1px solid var(--line); padding-top: 10px; }
.more summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.more-body { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.profile-head { display: flex; align-items: center; gap: 18px; }
.profile-photo { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.profile-photo .linkbtn { align-self: center; }
.profile-photo .btn { cursor: pointer; }
.profile-photo .btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.account { max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.account .tabs { padding: 0; border: 0; }
.editor, .editor .account { max-width: 640px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.field input, .field textarea, .field select {
  padding: 10px 14px; background: var(--card); border: 1.5px solid var(--edge); border-radius: 6px; font-weight: 400;
}
.field textarea { resize: vertical; font: inherit; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 0; border-color: var(--accent); }
.account .btn { padding: 10px 20px; text-align: center; cursor: pointer; }
.google { display: flex; align-items: center; justify-content: center; gap: 10px; }
.or { text-align: center; color: var(--faint); }
.msg { color: var(--err); }
.msg.ok { color: var(--ok); }
.linkbtn { background: none; border: 0; padding: 0; align-self: flex-start; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 10; max-width: min(420px, calc(100vw - 32px));
  padding: 14px 18px; background: var(--text); color: var(--on-text); border-radius: 8px; font-weight: 500;
  box-shadow: 0 8px 30px var(--shadow);
}

/* ---------- Соцчасть: лента, посты, ветки, профили, чаты (раскладка как у Reddit, цвета сайта) ---------- */
:root {
  --up: #FF4F7A;    /* розовый из логотипа вместо оранжевого Reddit */
  --down: #7B5CFF;  /* фиолетовый из логотипа вместо синего */
  --hover: #262626;
  --pill: #2A2A2A;
  --pill-hover: #343434;
  --egg: linear-gradient(120deg, #FFC531, #FF4F7A 55%, #6E4BFF);
}
.comment-author { font-weight: 700; }
.comment-author:hover { text-decoration: underline; }
a.avatar { color: #141414; }

.r-page {
  display: grid; grid-template-columns: minmax(0, 756px) 316px; gap: 24px; justify-content: center; align-items: start;
  padding: 20px 24px 48px;
}
.r-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.r-aside { position: sticky; top: calc(var(--top-h) + 16px); display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.r-note { padding: 24px 16px; text-align: center; }
.r-muted { color: var(--faint); }

.r-card { background: var(--card2); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.r-card-title { font-size: 16px; font-weight: 700; margin: 0; }
.r-card-title.small { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--sub); }
.r-card-text { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.r-banner { margin: -16px -16px 0; height: 64px; background: var(--egg); }
.r-banner.big { height: 96px; }

/* Аватар: фото или первая буква на цветном яйце */
.r-ava {
  --s: 32px; flex: none; width: var(--s); height: var(--s); border-radius: 50%; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c, var(--line)); color: #141414; font-weight: 800; font-size: calc(var(--s) * .45); line-height: 1;
}
.r-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.r-ava.ghost { background: var(--fill); }

/* Кнопки-«таблетки» */
.r-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 0; border-radius: 999px; background: var(--pill); color: var(--text); font-weight: 600; font-size: 12px; white-space: nowrap;
}
.r-pill:hover { background: var(--pill-hover); }
.r-pill.primary { background: var(--accent); color: #fff; }
.r-pill.primary:hover { background: #0D66D0; }
.r-pill.ghost { background: none; box-shadow: inset 0 0 0 1px var(--edge); }
.r-pill.ghost:hover { background: var(--pill); }
.r-pill.flat { background: none; color: var(--sub); }
.r-pill.flat:hover { background: var(--pill); color: var(--text); }
.r-pill.wide { width: 100%; height: 40px; font-size: 14px; }
.r-pill.small { height: 28px; padding: 0 10px; }
.r-pill:disabled { opacity: .5; cursor: default; }
.r-iconbtn {
  flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; list-style: none;
}
.r-iconbtn::-webkit-details-marker { display: none; }
.r-iconbtn:hover { background: var(--pill); }
.r-iconbtn.small { width: 28px; height: 28px; color: var(--sub); }
.r-backbtn { background: var(--pill); }

/* Голосование: стрелки вверх и вниз со счётом посередине */
.r-vote { display: inline-flex; align-items: center; height: 32px; border-radius: 999px; background: var(--pill); }
.r-arrow {
  width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}
.r-arrow[data-dir="1"]:hover { color: var(--up); background: rgba(255, 79, 122, .14); }
.r-arrow[data-dir="-1"]:hover { color: var(--down); background: rgba(123, 92, 255, .16); }
.r-score { min-width: 14px; text-align: center; font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; }
.r-vote.up { background: var(--up); }
.r-vote.down { background: var(--down); }
.r-vote.up .r-arrow, .r-vote.down .r-arrow, .r-vote.up .r-score, .r-vote.down .r-score { color: #fff; }
.r-vote.up .r-arrow:hover, .r-vote.down .r-arrow:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.r-vote.up [data-dir="1"] path, .r-vote.down [data-dir="-1"] path { fill: currentColor; }
.r-c-actions .r-vote, .r-c-actions .r-vote.up, .r-c-actions .r-vote.down { background: none; }
.r-c-actions .r-vote .r-arrow { color: var(--sub); }
.r-c-actions .r-vote.up [data-dir="1"], .r-c-actions .r-vote.up .r-score { color: var(--up); }
.r-c-actions .r-vote.down [data-dir="-1"], .r-c-actions .r-vote.down .r-score { color: var(--down); }

/* Строка «кто и когда» */
.r-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; color: var(--sub); min-width: 0; }
.r-who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); }
.r-who span { display: flex; flex-direction: column; min-width: 0; }
.r-who b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-who small { font-size: 12px; color: var(--sub); }
.r-user { font-weight: 600; color: var(--text); }
.r-user.strong { font-weight: 700; }
a.r-user:hover, .r-who:hover .r-user, .r-app:hover, .r-ptitle:hover { text-decoration: underline; }
.r-dot { color: var(--faint); }
.r-app { font-weight: 600; color: var(--text); }
.r-tag { padding: 1px 7px; border-radius: 999px; background: var(--pill); color: var(--muted); font-size: 11px; font-weight: 700; }
.r-tag.mutual { background: rgba(107, 227, 180, .16); color: #6BE3B4; }
.r-tag.op { background: rgba(20, 115, 230, .22); color: var(--link); }
.r-sub { font-size: 12px; color: var(--sub); }
.r-full-who .r-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.field textarea[name=bio] { font-weight: 400; }
.r-link { color: var(--link); }
.r-link:hover { text-decoration: underline; }

/* Лента */
.r-feedbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.r-sorts, .r-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.r-sort, .r-tabs a {
  flex: none; padding: 9px 14px; border-radius: 999px; font-weight: 600; color: var(--soft);
}
button.r-sort { border: 0; background: none; font: inherit; cursor: pointer; }
.cat-pick { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; }
.app-sorts { margin: -6px 0 16px; }
/* Типы слева, сортировка справа — одной строкой */
.app-filters { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: -6px 0 16px; }
.app-filters .app-sorts { margin: 0; }
.r-sort:hover, .r-tabs a:hover { background: var(--hover); color: var(--strong); }
.r-sort[aria-current=page], .r-tabs a[aria-current=page] { background: var(--pill-hover); color: var(--strong); }
.r-list { display: flex; flex-direction: column; }
.r-list.boxed { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 4px 0; }
.r-post { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 10px 16px; border-radius: 16px; cursor: pointer; }
.r-post:hover { background: var(--hover); }
.r-post + .r-post { margin-top: 9px; }
.r-post + .r-post::before { content: ''; position: absolute; left: 16px; right: 16px; top: -5px; border-top: 1px solid var(--rule); }
.r-title { font-size: 18px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.r-preview {
  color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.r-actions, .r-c-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.r-c-actions { gap: 2px; margin-top: 2px; }
.r-people { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.r-people li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.r-people.big { gap: 4px; }
.r-person { padding: 8px 16px; border-radius: 16px; }
.r-person:hover { background: var(--hover); }

/* Страница поста */
.r-full { display: flex; flex-direction: column; gap: 10px; }
.r-full-head { display: flex; align-items: center; gap: 10px; }
.r-full-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.r-h1 { font-size: 24px; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; overflow-wrap: anywhere; margin: 0; }
.r-body { color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: 15px; }
.r-body:empty { display: none; }
/* Списки и черта в тексте поста и комментариев */
.r-list-ul, .r-list-ol { margin: 4px 0; padding-left: 26px; white-space: normal; }
.r-list-ul li, .r-list-ol li { white-space: pre-wrap; padding-left: 2px; }
.r-list-ul li + li, .r-list-ol li + li { margin-top: 3px; }
.r-list-ul li::marker, .r-list-ol li::marker { color: var(--sub); }
.r-hr { height: 1px; margin: 14px 0; border: 0; background: var(--line); }
/* Пост разработчика о своей программе */
.r-devbadge {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--link); font-size: 12px; font-weight: 700;
}
/* Обновление программы: мягкая рамка по всему скруглению, а не полоска слева — та обрезалась на углах */
.r-post.dev, .r-full.dev {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}
.r-post.dev:hover { background: color-mix(in srgb, var(--accent) 11%, transparent); }
.r-full.dev { padding: 14px; border-radius: 16px; }
.r-post.dev + .r-post::before, .r-post + .r-post.dev::before { display: none; }
.r-update-check { font-weight: 500; }
.r-submit-tabs { margin: -4px 0 14px; }
.r-count { margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: var(--pill); font-size: 12px; }
.r-drafts { display: flex; flex-direction: column; gap: 8px; }
.r-draft { display: flex; align-items: flex-start; gap: 8px; padding: 12px 8px 12px 16px; border: 1px solid var(--edge); border-radius: 16px; }
.r-draft:hover { background: var(--hover); }
.r-draft-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.r-draft-open b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-draft-body { color: var(--sub); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.r-draft-open small { color: var(--faint); font-size: 12px; }
.r-composer-bar .r-update-check { margin-right: auto; padding-left: 8px; font-size: 14px; }
.r-composer textarea { scrollbar-width: thin; scrollbar-color: var(--edge) transparent; }
/* «Создать пост» в ленте: на узком экране боковая колонка с этой кнопкой уезжает под все посты */
.r-feed-new { display: none; flex: none; margin-left: auto; }
.r-menu { position: relative; }
.r-menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 6; min-width: 170px; padding: 6px 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px var(--shadow);
}
.r-menu-list button { display: block; width: 100%; padding: 10px 16px; border: 0; background: none; text-align: left; font-weight: 600; }
.r-menu-list button:hover { background: var(--pill); }

.r-composer {
  display: flex; flex-direction: column; border: 1px solid var(--edge); border-radius: 20px; background: var(--bg);
}
.r-composer:focus-within { border-color: var(--text); }
.r-composer textarea {
  width: 100%; min-height: 40px; padding: 10px 16px; border: 0; outline: 0; background: none; resize: none; font: inherit; line-height: 1.45;
}
.r-composer-bar { display: none; justify-content: flex-end; gap: 8px; padding: 6px 8px 8px; }
.r-composer.open .r-composer-bar, .r-composer:focus-within .r-composer-bar,
.r-composer:has(textarea:not(:placeholder-shown)) .r-composer-bar { display: flex; }
.r-composer.reply { margin: 8px 0 4px; }
.r-composer-stub {
  display: block; padding: 10px 16px; border: 1px solid var(--edge); border-radius: 20px; color: var(--sub); background: var(--bg);
}
.r-composer-stub:hover { border-color: var(--text); color: var(--text); }
.r-sortline { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sub); scroll-margin-top: 16px; }
.r-sortline select { margin-left: 6px; padding: 6px 10px; border: 0; border-radius: 999px; background: var(--pill); font-weight: 700; font-size: 12px; color: var(--text); }
.r-single { padding: 10px 14px; border-radius: 10px; background: var(--card); color: var(--muted); }

/* Ветка комментариев: линия слева сворачивает ветку, дети подключаются к ней изогнутым «локтем» */
.r-tree { display: flex; flex-direction: column; gap: 14px; }
.r-c { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 8px; scroll-margin-top: 40vh; }
.r-c-gut { grid-row: 1; grid-column: 1; display: flex; }
.r-c-head { grid-row: 1; grid-column: 2; min-height: 28px; }
.r-c-line { grid-row: 2; grid-column: 1; position: relative; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.r-c-line::before { content: ''; position: absolute; left: 13.5px; top: 4px; bottom: 0; width: 1px; background: var(--line); }
.r-c-line:hover::before { left: 13px; width: 2px; background: var(--text); }
.r-c-content { grid-row: 2; grid-column: 2; min-width: 0; }
.r-c-body { padding: 2px 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.r-c-body p { margin: 0; }
.r-c-kids { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.r-c-kids > .r-c { position: relative; }
.r-c-kids > .r-c::before {
  content: ''; position: absolute; left: -22.5px; top: -10px; width: 18px; height: 24px;
  border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); border-bottom-left-radius: 12px; pointer-events: none;
}
.r-c-plus {
  display: none; width: 28px; height: 28px; border: 1px solid var(--edge); border-radius: 50%; background: none; color: var(--text);
  align-items: center; justify-content: center;
}
.r-c-hidden { display: none; color: var(--faint); }
.r-c.collapsed > .r-c-line, .r-c.collapsed > .r-c-content, .r-c.collapsed > .r-c-gut > a, .r-c.collapsed > .r-c-gut > .r-ava { display: none; }
.r-c.collapsed > .r-c-gut > .r-c-plus, .r-c.collapsed > .r-c-head > .r-c-hidden { display: inline-flex; }
.r-c.flash > .r-c-content > .r-c-body { background: rgba(20, 115, 230, .14); border-radius: 6px; box-shadow: 0 0 0 4px rgba(20, 115, 230, .14); }
.r-more { display: inline-block; margin-top: 8px; font-weight: 700; color: var(--link); }
.r-more:hover { text-decoration: underline; }

/* Карточка автора */
.r-author-head { display: flex; align-items: center; gap: 12px; margin-top: -28px; }
.r-author-head .r-ava { box-shadow: 0 0 0 4px var(--card2); }
.r-author-head > div { padding-top: 26px; min-width: 0; }
.r-author-name { font-weight: 700; font-size: 16px; }
.r-author-name:hover { text-decoration: underline; }
.r-author-actions { display: flex; gap: 8px; }
.r-author-actions > * { flex: 1; }

/* Профиль */
.r-profile { display: flex; flex-direction: column; gap: 14px; }
.r-phead { display: flex; align-items: center; gap: 16px; }
.r-pava { position: relative; flex: none; }
.r-pava .r-ava { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px #FF4F7A; }
.r-phead-text { min-width: 0; }
.r-phead-text h1 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.r-phead-text .r-sub { font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.r-create { align-self: flex-start; }
.r-pcard .r-card-title { margin-top: 4px; }
.r-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; padding-top: 4px; border-top: 1px solid var(--fill); padding-top: 14px; }
.r-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.r-stat b { font-size: 14px; font-weight: 700; }
.r-stat span { font-size: 12px; color: var(--sub); }
a.r-stat:hover b { text-decoration: underline; }
.r-pcomment .r-meta svg { flex: none; color: var(--sub); }
.r-ptitle { font-weight: 700; color: var(--text); font-size: 13px; }

/* Новый пост */
.r-submit { display: flex; flex-direction: column; gap: 14px; }
.r-field { position: relative; display: flex; flex-direction: column; gap: 6px; }
.r-field input, .r-field textarea, .r-field select {
  width: 100%; padding: 14px 16px; border: 1px solid var(--edge); border-radius: 16px; background: var(--bg); font: inherit; outline: 0;
}
.r-field textarea { resize: vertical; min-height: 160px; line-height: 1.5; }
.r-field input:focus, .r-field textarea:focus, .r-field select:focus { border-color: var(--text); }
.r-field.inline { flex-direction: row; align-items: center; gap: 12px; font-weight: 600; }
.r-field.inline select { width: auto; flex: 1; max-width: 320px; padding: 10px 14px; border-radius: 999px; }
.r-counter { align-self: flex-end; font-size: 12px; color: var(--faint); }
.r-submit-bar { display: flex; justify-content: flex-end; gap: 8px; }
.r-submit-bar .r-pill { height: 40px; padding: 0 18px; font-size: 14px; }
.r-rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--muted); }

/* Чаты */
.content:has(> .r-chat) { display: flex; }
.r-chat { flex: 1; display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - var(--top-h)); min-height: 420px; }
.r-chat-list { border-right: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; }
.r-chat-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 10px; }
.r-chat-top h1 { font-size: 19px; font-weight: 800; }
#chat-items { overflow-y: auto; padding: 0 8px 12px; }
.r-chat-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; }
.r-chat-item:hover { background: var(--hover); }
.r-chat-item.active { background: var(--fill); }
.r-chat-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.r-chat-line { display: flex; justify-content: space-between; gap: 8px; }
.r-chat-line b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-chat-line small { flex: none; font-size: 11px; color: var(--faint); }
.r-chat-last { font-size: 13px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-chat-item.unread .r-chat-last { color: var(--text); font-weight: 600; }
.r-chat-item.unread .r-chat-line small::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--up); }
.r-chat-item.muted.unread .r-chat-line small::before { background: var(--faint); }
.r-chat-muted { display: inline-flex; vertical-align: -2px; margin-left: 4px; opacity: .55; }
.r-chat-muted svg { width: 13px; height: 13px; }
.r-mute { margin-left: auto; }
.r-mute.on { opacity: .7; }
.r-room { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.r-room-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.r-room-back { display: none; }
.r-room-status { font-size: 12px; color: var(--sub); }
.r-room-status.online { color: #3DBE6C; }
.r-room-status.typing { color: var(--link); }
.r-msgs { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; }
.r-msg { display: flex; gap: 10px; padding: 3px 8px; margin: 0 -8px; border-radius: 8px; }
.r-msg:not(.grouped) { margin-top: 12px; }
.r-msg:hover { background: var(--fill); }
.r-msg-gap { width: 32px; flex: none; }
.r-msg-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.r-msg-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.r-msg.mine .r-user { color: var(--link); }
.r-day { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; font-size: 12px; color: var(--faint); }
.r-day::before, .r-day::after { content: ''; flex: 1; border-top: 1px solid var(--rule); }
.r-room-hello { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.r-room-empty { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.r-chat-form { display: flex; align-items: flex-end; gap: 8px; margin: 0 16px 16px; padding: 6px 6px 6px 16px; border: 1px solid var(--edge); border-radius: 22px; background: var(--bg); }
.r-chat-staged:not([hidden]) { display: flex; gap: 6px; align-self: center; }
.r-chat-form:focus-within { border-color: var(--text); }
.r-chat-form textarea { flex: 1; min-height: 36px; padding: 7px 0; border: 0; outline: 0; background: none; resize: none; font: inherit; line-height: 1.45; }
/* Всё в строке на одной высоте с кнопкой отправки (36px): значки 32px поднимаем на 2px, поле — тоже 36px. */
.r-chat-form > .emoji, .r-chat-form > .r-iconbtn, .r-chat-form > label.r-iconbtn { margin-bottom: 2px; }
.r-chat-form > .emoji { display: flex; }
.r-send { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.r-send:hover { background: #0D66D0; }
.r-room > .r-composer-stub { margin: 0 16px 16px; }
.inbox-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

/* Профиль в настройках: поле @имени */
.r-at { display: flex; align-items: center; background: var(--card); border: 1.5px solid var(--edge); border-radius: 6px; font-weight: 400; }
.r-at:focus-within { border-color: var(--accent); }
.r-at > span { padding-left: 14px; color: var(--faint); font-weight: 700; }
.field .r-at input { flex: 1; min-width: 0; border: 0; background: none; padding-left: 4px; }
.r-hint { font-weight: 400; font-size: 12px; color: var(--faint); }
.app-threads { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.app-threads .r-list { align-self: stretch; }

/* Кадрирование аватарки */
.r-crop { width: min(400px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); }
.r-crop::backdrop { background: rgba(0, 0, 0, .7); }
.r-crop-box { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.r-crop-box h2 { font-size: 18px; font-weight: 800; }
.r-crop-stage {
  position: relative; width: 100%; max-width: 320px; aspect-ratio: 1; margin: 0 auto; border-radius: 10px; overflow: hidden;
  touch-action: none; cursor: grab; background: var(--panel);
}
.r-crop-stage:active { cursor: grabbing; }
.r-crop-stage canvas { width: 100%; height: 100%; display: block; }
.r-crop-stage::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .6); outline: 2px solid rgba(255, 255, 255, .85); outline-offset: -1px;
}
.r-crop-zoom { display: flex; align-items: center; gap: 10px; color: var(--sub); }
.r-crop-zoom input { flex: 1; accent-color: var(--accent); }
.r-crop-bar { display: flex; justify-content: flex-end; gap: 10px; }
.r-crop-bar .btn { padding: 8px 20px; cursor: pointer; }
.dl-mac { cursor: pointer; }
.mac-steps { display: grid; gap: 6px; padding-left: 20px; color: var(--muted); }
.mac-cmd { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; word-break: break-all; user-select: all; }

@media (max-width: 1100px) {
  .r-page { grid-template-columns: minmax(0, 756px); }
  .r-aside { position: static; }
  .r-feed-new { display: inline-flex; }
  .r-feedbar { flex-wrap: nowrap; }
  .r-feedbar .r-sorts { min-width: 0; }
  .r-profile .r-phead-actions { display: flex; }
}
/* На узком экране карточка профиля уезжает вниз, поэтому подписка и «Написать» дублируются в шапке */
.r-phead-actions { display: none; flex-wrap: wrap; align-items: center; gap: 8px; }
.r-phead-actions b { color: var(--text); }
@media (max-width: 760px) {
  .r-chat { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 150px); }
  .r-chat.has-room .r-chat-list, .r-chat:not(.has-room) .r-room { display: none; }
  .r-room-back { display: inline-flex; }
}

@media (max-width: 640px) {
  .r-page { padding: 14px 8px 32px; }
  .r-post, .r-person { padding: 10px 8px; }
  .r-post + .r-post::before { left: 8px; right: 8px; }
  .r-h1, .r-phead-text h1 { font-size: 20px; }
  .r-c { grid-template-columns: 24px minmax(0, 1fr); column-gap: 6px; }
  .r-c-line::before { left: 11.5px; }
  .r-c-kids > .r-c::before { left: -18.5px; width: 14px; }
  /* Глубже третьего ответа лесенка больше не сдвигается: иначе на телефоне тексту остаётся пара слов в строку. */
  .r-c-kids .r-c-kids .r-c-kids { margin-left: -30px; }
  .r-c-kids .r-c-kids .r-c-kids > .r-c::before { display: none; }
  .r-pill.flat span { display: none; }
  .top { padding: 10px 16px; }
  .top-nav { display: none; }
  .brand { flex: 1; }
  .top-right { width: 100%; }
  .shell { flex-direction: column; }
  .rail { flex: none; flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 4px 0; }
  .content { border-top-right-radius: 16px; }
  .tabs { padding: 14px 16px; }
  .section { padding: 20px 16px; }
  .app-page { padding: 20px 16px; }
  .app-side { position: static; flex-basis: 100%; }
}

/* ---------- Всплывающие панели: меню аватарки, поиск, подсказки ---------- */
.pop {
  position: absolute; z-index: 30; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 16px 48px var(--shadow); overflow: hidden;
}
.me-menu { right: 0; top: 42px; width: 220px; padding: 6px; }
.me-menu a, .me-menu button {
  display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 9px; background: none;
  text-align: left; font-weight: 600;
}
.me-menu a:hover, .me-menu button:hover { background: var(--pill); }
.search-panel { left: 0; top: calc(100% + 8px); width: min(420px, calc(100vw - 32px)); max-height: min(70vh, 520px); overflow-y: auto; padding: 6px; }
.s-title { margin: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--sub); }
.s-empty { padding: 14px; }
.s-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px;
  background: none; text-align: left; color: var(--text);
}
.s-head { padding: 8px 8px 4px; color: var(--sub); font-size: 12px; font-weight: 600; }
.s-head:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--line); }
.s-item:hover, .s-item:focus-visible, .s-item[aria-selected=true] { background: var(--pill); }
.s-item > img { flex: none; width: 28px; height: 28px; border-radius: 7px; object-fit: cover; }
.s-item > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.s-item b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-item small { color: var(--sub); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-ico { flex: none; width: 28px; height: 28px; border-radius: 7px; background: var(--pill); display: flex; align-items: center; justify-content: center; }
.suggest { left: 0; top: calc(100% + 4px); width: min(340px, 100%); max-height: min(320px, 40vh); overflow-y: auto; padding: 6px; font-weight: 400; }
.field { position: relative; }

/* ---------- Шапка и соцсети ---------- */
.r-banner, .r-hero { background-size: cover; background-position: center; }
.r-hero { position: relative; height: clamp(110px, 24vw, 190px); border-radius: 16px; background-color: var(--c); background-image: var(--egg); }
.r-hero-edit { position: absolute; right: 10px; top: 10px; background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.r-hero-edit:hover { background: rgba(0, 0, 0, .75); }
.r-net { width: 34px; height: 34px; border-radius: 50%; background: var(--pill); display: flex; align-items: center; justify-content: center; }
.r-net:hover { background: var(--pill-hover); }
.r-net img, .net-row img { filter: var(--icon-filter); }
.r-crop.wide .r-crop-stage { max-width: 100%; }
.r-crop.tall .r-crop-stage { max-width: 240px; }
.r-crop.wide .r-crop-stage::after, .r-crop.tall .r-crop-stage::after { border-radius: 0; box-shadow: none; }

/* ---------- Картинки в комментариях ---------- */
.c-image { display: block; max-width: min(100%, 420px); max-height: 420px; margin: 6px 0; border-radius: 10px; }
.comment-form-bar { align-self: stretch; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.attach { display: flex; align-items: center; gap: 8px; margin-right: auto; }
form.dropping { outline: 2px dashed var(--accent); outline-offset: 2px; }
.attach label { cursor: pointer; }
.attach label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.attach-preview { position: relative; display: block; line-height: 0; }
.attach-preview img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.attach-preview button {
  position: absolute; right: -6px; top: -6px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: var(--text); color: var(--on-text); font-size: 14px; line-height: 20px;
}
.r-composer:has(.attach-preview:not([hidden])) .r-composer-bar { display: flex; }
.r-composer-bar { align-items: center; }
.r-composer .attach { padding-left: 2px; }
.r-composer textarea { border-radius: 20px; }
.r-all { color: #FFC531; }

/* ---------- Заявки, админка, соглашение ---------- */
.card-head .tag { background: var(--pill); color: var(--muted); }
.card p.author a, .app-meta a { color: inherit; }
.sub { align-items: flex-start; }
.sub-selfie { flex: none; width: 120px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; background: var(--fill); }
.sub-icon { width: 22px; height: 22px; border-radius: 5px; align-self: center; }
.sub ul { padding-left: 18px; color: var(--muted); }
.comment-body p.author { font-size: 13px; color: var(--sub); }
.comment-actions.wrap { flex-wrap: wrap; }
.comment-actions .btn { padding: 6px 16px; cursor: pointer; }
#my-subs { display: flex; flex-direction: column; gap: 12px; }
#my-subs:empty { display: none; }
.panel.admin { max-width: 1200px; margin: 0 auto; padding-top: 32px; gap: 24px; }
.section.admin h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.admin-head p { margin-top: 6px; }
.admin .tabs { padding: 0; border: 0; }
.admin .table-box { max-width: none; }
.admin .table-box th, .admin .table-box td { padding: 10px 12px; }
.tab { min-height: 40px; padding: 8px 14px; border-radius: 6px; font-weight: 600; color: var(--soft); }
.tab:hover { background: var(--fill); }
.tab[aria-current=true] { background: var(--text); color: var(--on-text); }
.terms { max-width: 720px; }
.terms h2 { font-size: 16px; font-weight: 700; margin-top: 6px; }
.terms p { color: var(--muted); }
.cookie {
  position: fixed; left: 50%; bottom: 16px; z-index: 40; width: min(620px, calc(100vw - 32px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--glass); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 16px 48px var(--shadow);
}
.cookie p { flex: 1; }
.cookie .btn { flex: none; cursor: pointer; }
@media (max-width: 640px) {
  /* Значки в строке с логотипом, поиск отдельной строкой: подпись влезает целиком */
  .top { gap: 8px 4px; }
  .top-right { display: contents; }
  .brand { flex: 1 0 auto; font-size: 17px; white-space: nowrap; }
  .bell, .theme, .lang { width: 40px; min-width: 40px; height: 40px; }
  .search-wrap { order: 10; flex: 1 1 100%; }
  .search-wrap .search { width: 100%; }
  .search-panel { position: fixed; left: 16px; right: 16px; top: 116px; width: auto; }
  .sub { flex-direction: column; }
  .cookie { flex-direction: column; align-items: stretch; text-align: left; }
}

/* ---------- Анимация: как в Notion, только цвет и короткий fade, ничего не двигается ---------- */
a, button, summary, input, textarea, select, .card, .comment, .rail-ico, .r-post, .r-pill, .btn, .r-net, .s-item, .search {
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.content.enter > * { animation: fade .12s ease both; }
.pop, .bell-panel, .r-menu-list, .toast, .cookie, .r-crop[open], .r-crop[open]::backdrop, .r-view[open], .r-view[open]::backdrop { animation: fade .12s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.author-selfie { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.author-selfie img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; }
.author-selfie figcaption { font-size: 12px; color: var(--sub); }
#selfie-preview { width: 72px; height: 96px; }
.consent-selfie { width: 150px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; align-self: center; }

/* ---------- Эмодзи ---------- */
.emoji { position: relative; }
.emoji summary { list-style: none; cursor: pointer; color: var(--sub); }
.emoji summary:hover, .emoji[open] summary { color: var(--text); }
.emoji summary::-webkit-details-marker { display: none; }
.emoji-panel { left: 0; top: calc(100% + 6px); width: 276px; max-width: calc(100vw - 48px); padding: 6px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-panel button { aspect-ratio: 1; padding: 0; border: 0; border-radius: 8px; background: none; font-size: 19px; line-height: 1; }
.emoji-panel button:hover { background: var(--pill); }
.r-chat-form .emoji-panel { top: auto; bottom: calc(100% + 6px); }
/* В посте кнопки живут внутри рамки поля, отдельной строкой под текстом: длинный текст под них не заезжает */
.r-field-body { gap: 0; border: 1px solid var(--edge); border-radius: 16px; background: var(--bg); }
.r-field-body:focus-within { border-color: var(--text); }
.r-field-body textarea, .r-field-body textarea:focus { border: 0; border-radius: 16px 16px 0 0; background: none; }
.r-field-body .attach { flex-wrap: wrap; margin: 0; padding: 4px 10px 10px; }

/* ---------- Редактирование профиля ---------- */
.panel.edit { max-width: 920px; margin: 0 auto; padding-top: 32px; padding-bottom: 48px; gap: 24px; }
.edit-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.section.edit h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.edit-profile { background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.r-banner.edit-hero { position: relative; margin: 0; height: clamp(150px, 24vw, 230px); }
.edit-hero-actions { position: absolute; right: 16px; top: 16px; display: flex; gap: 8px; }
.glass {
  padding: 8px 14px; border: 0; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-weight: 600; font-size: 13px;
  cursor: pointer; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.glass:hover { background: rgba(0, 0, 0, .75); }
.glass:focus-within { outline: 2px solid #fff; outline-offset: 2px; }
.edit-id { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; padding: 0 28px 24px; }
.edit-id .avatar.big { width: 124px; height: 124px; margin-top: -48px; font-size: 44px; box-shadow: 0 0 0 5px var(--card); position: relative; }
.edit-who { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 2px; padding-top: 14px; }
.edit-who b { font-size: 22px; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.edit-who small { font-size: 14px; color: var(--sub); overflow-wrap: anywhere; }
.edit-id .profile-photo { padding-top: 14px; }
.edit-form { display: flex; flex-direction: column; gap: 24px; }
.edit-card { display: flex; flex-direction: column; gap: 22px; padding: 28px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; }
.edit-title h2 { font-size: 17px; font-weight: 700; }
.edit-title p { margin-top: 4px; color: var(--sub); overflow-wrap: anywhere; }
.edit-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.edit-fields .wide { grid-column: 1 / -1; }
.edit-fields .field { font-size: 13px; color: var(--sub); }
.edit-fields .field input, .edit-fields .field textarea, .edit-fields .r-at { font-size: 15px; color: var(--text); }
.edit-fields .field > input, .edit-fields .field > textarea, .edit-fields .r-at, .net-row {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.edit-fields .field > input, .edit-fields .field > textarea { padding: 12px 14px; }
.edit-fields .field .r-at input { padding: 12px 14px 12px 4px; }
.edit-fields .field > input:focus, .edit-fields .field > textarea:focus, .edit-fields .r-at:focus-within, .net-row:focus-within { border-color: var(--accent); }
.net-list { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.net-rows { align-self: stretch; display: flex; flex-direction: column; gap: 10px; }
.net-row { display: flex; align-items: center; gap: 12px; padding: 0 6px 0 14px; }
.net-del { flex: none; width: 30px; height: 30px; border: 0; border-radius: 50%; background: none; color: var(--faint); font-size: 18px; line-height: 1; }
.net-del:hover { background: var(--pill); color: var(--text); }
.net-add { height: 36px; }
.net-list .r-hint { color: var(--faint); }
.net-row img { flex: none; opacity: .85; }
.net-row input { flex: 1; min-width: 0; padding: 12px 0; border: 0; outline: 0; background: none; font-size: 14px; }
.net-row input::placeholder { color: var(--faint); }
/* Только кнопка, без панели: она плавает справа и всегда под рукой */
.edit-bar { position: sticky; bottom: 16px; z-index: 5; align-self: flex-end; max-width: 100%; display: flex; align-items: center; gap: 10px; }
.edit-bar .msg { padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 6px 20px var(--shadow); font-size: 13px; }
.edit-bar .msg:empty { display: none; }
.edit-bar .btn { flex: none; padding: 11px 30px; cursor: pointer; box-shadow: 0 6px 20px var(--shadow); }
.edit-account { gap: 16px; }
.edit-account-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.edit-account-actions .btn { padding: 8px 22px; cursor: pointer; }
.root-row { display: flex; gap: 8px; }
.root-row input { flex: 1; min-width: 0; }
.root-row .btn { flex: none; cursor: pointer; }
.root-bar { display: flex; justify-content: flex-end; }
.mic-level { width: 100%; height: 10px; }
.report-bar { display: flex; align-items: center; gap: 10px; }

/* Вкладка «Топ авторов» */
.top-note { margin: -4px 0 16px; }
.top-authors { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.top-authors a { display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; color: inherit; text-decoration: none; transition: background-color .15s; }
.top-authors a:hover { background: var(--fill); }
.top-rank { width: 22px; flex: none; text-align: center; font-weight: 600; color: var(--muted); }
.top-authors li:nth-child(-n+3) .top-rank { color: var(--text); }
.top-who, .top-num { display: flex; flex-direction: column; min-width: 0; }
.top-who { flex: 1; }
.top-num { flex: none; text-align: right; }
.top-who b, .top-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-who small, .top-num small { color: var(--muted); font-size: 12px; }

/* Админка: удалённые программы */
.deleted-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.deleted-list li { display: flex; align-items: center; gap: 12px; }
.deleted-list img { width: 36px; height: 36px; border-radius: 8px; flex: none; }
.deleted-list span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.deleted-list small { color: var(--muted); font-size: 12px; }
.deleted-list .btn { flex: none; cursor: pointer; }

/* Программы автора в профиле */
.author-apps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.author-apps a { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 6px; color: inherit; text-decoration: none; transition: background-color .15s; }
.author-apps a:hover { background: var(--fill); }
.author-apps img { width: 32px; height: 32px; flex: none; border-radius: 8px; }
.author-apps span { display: flex; flex-direction: column; min-width: 0; }
.author-apps small { color: var(--muted); font-size: 12px; }
.root-bar .btn { padding: 10px 26px; cursor: pointer; }
@media (max-width: 640px) {
  .panel.edit { padding-top: 20px; gap: 16px; }
  .edit-profile, .edit-card { border-radius: 16px; }
  .edit-card { padding: 20px; }
  .edit-id { padding: 0 20px 20px; }
  .edit-id .avatar.big { width: 96px; height: 96px; margin-top: -40px; font-size: 34px; }
  .edit-who { flex-basis: 100%; padding-top: 0; }
  .edit-id .profile-photo { padding-top: 0; }
  .edit-fields { grid-template-columns: minmax(0, 1fr); }
  .edit-hero-actions { right: 10px; top: 10px; }
}

/* ---------- Шапка и меню стоят на месте, прокручивается только содержимое ---------- */
:root { --top-h: 66px; }
html { scrollbar-gutter: stable; scroll-padding-top: calc(var(--top-h) + 12px); }
.top { position: sticky; top: 0; z-index: 25; background: var(--bg); }
.rail { position: sticky; top: var(--top-h); align-self: flex-start; height: calc(100vh - var(--top-h)); overflow-y: auto; scrollbar-width: none; }
.rail a { width: 92px; text-align: center; }
/* Надписи не обрываем: длинное название переносится на вторую строку */
.s-item b, .s-item small { white-space: normal; overflow-wrap: anywhere; }
.search-panel { width: min(480px, calc(100vw - 32px)); }
.card h2 { min-width: 0; overflow-wrap: anywhere; }
.card-head .tag { flex: none; white-space: nowrap; }
@media (max-width: 640px) {
  /* На телефоне меню внизу, как в приложениях: так оно не съедает экран */
  .rail {
    position: fixed; left: 0; right: 0; top: auto; bottom: 0; z-index: 25; width: 100%; height: auto;
    flex-direction: row; flex-wrap: nowrap; justify-content: space-around; gap: 0; overflow-x: auto;
    padding: 4px 0 max(4px, env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line);
  }
  .rail a { flex: 1 0 56px; width: auto; padding: 4px 0; font-size: 10px; }
  .shell { padding-bottom: 72px; }
  html { scroll-padding-bottom: 84px; }
  .toast, .cookie { bottom: 84px; }
  .edit-bar { bottom: 80px; }
  .search-panel { top: calc(var(--top-h) + 4px); }
}

/* Админские разделы: внизу меню, за линией и серым цветом */
.rail-bottom { margin-top: auto; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rail-admin { width: 100%; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rail-admin a:not([aria-current]) { color: var(--faint); }
.rail-admin a:not([aria-current]) .rail-ico { opacity: .7; }
@media (max-width: 640px) {
  .rail-bottom { display: contents; }
  .rail-admin { flex: 2 0 112px; width: auto; flex-direction: row; gap: 0; padding: 0; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ---------- Светлая тема в духе Creative Cloud ---------- */
html[data-theme=light] {
  --bg: #F1F1F1;
  --panel: #FAFAFA;
  --card: #FFFFFF;
  --card2: #FFFFFF;
  --line: #E1E1E1;
  --rule: #E1E1E1;
  --text: #2C2C2C;
  --muted: #505050;
  --sub: #6E6E6E;
  --faint: #8E8E8E;
  --soft: #3A3A3A;
  --edge: #B3B3B3;
  --fill: #E8E8E8;
  --hover: #EFEFEF;
  --pill: #EAEAEA;
  --pill-hover: #DEDEDE;
  --btn: #2C2C2C;
  --on-text: #FFFFFF;
  --strong: #000;
  --link: #0D66D0;
  --ok: #107C41;
  --err: #C9252D;
  --glass: rgba(255, 255, 255, .82);
  --glow: rgba(0, 0, 0, .05);
  --shadow: rgba(0, 0, 0, .14);
  --icon-filter: none;
}
html[data-theme=light] .r-all { color: #A86A00; }
html[data-theme=light] .r-tag.mutual { color: #107C41; }
html[data-theme=light] .eggs i { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.search svg, .card-head > svg { stroke: var(--sub); }
.theme { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: var(--soft); display: flex; align-items: center; justify-content: center; }
.theme:hover { background: var(--fill); }
.theme .sun { display: none; }
html[data-theme=dark] .theme .sun, html:not([data-theme]) .theme .sun { display: block; }
html[data-theme=dark] .theme .moon, html:not([data-theme]) .theme .moon { display: none; }
body, .content { transition: background-color .12s ease; }
@media (max-width: 640px) {
  .top-right { gap: 4px; }
}

/* Хэштег программы: отдельное поле в посте и метка под текстом */
.r-tagfield { max-width: 320px; }
.r-tagfield .r-at { position: relative; border-radius: 999px; }
.r-tagfield input { padding: 8px 14px 8px 4px; font-size: 14px; }
.r-tagchip { align-self: flex-start; width: max-content; max-width: 100%; padding: 3px 10px; border-radius: 999px; background: var(--pill); color: var(--link); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.r-tagchip:hover { background: var(--pill-hover); }

/* Картинка поста как на Reddit: целиком, по бокам размытая копия */
.r-media { position: relative; width: 100%; max-height: 540px; margin: 4px 0; border-radius: 16px; overflow: hidden; background: var(--fill); }
.r-media img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.r-media-bg { object-fit: cover; filter: blur(24px) brightness(.7); transform: scale(1.15); }
.r-media-img { object-fit: contain; }
/* Несколько фото в посте: лента со щелчком по кадрам, стрелки и номер поверх. */
.r-gallery { position: relative; margin: 4px 0; border-radius: 16px; overflow: hidden; }
.r-gallery-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.r-gallery-track::-webkit-scrollbar { display: none; }
.r-gallery-track > .r-media { flex: 0 0 100%; margin: 0; border-radius: 0; scroll-snap-align: start; }
.r-gallery-step {
  position: absolute; top: 50%; translate: 0 -50%; width: 36px; height: 36px; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer;
}
.r-gallery-step[hidden] { display: none; }
.r-gallery-step.prev { left: 10px; }
.r-gallery-step.next { right: 10px; }
.r-gallery-step.next svg { rotate: 180deg; }
.r-gallery-step:hover { background: rgba(0, 0, 0, .75); }
.r-gallery-count { position: absolute; top: 10px; right: 10px; padding: 3px 9px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; font-weight: 600; }
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* Просмотр картинки: цвета свои, потому что фон тёмный и в светлой теме */
.c-image, .r-media-img, .attach-preview img { cursor: zoom-in; }
/* Кнопка установки в приложении: ширина не прыгает, пока растут проценты. */
/* В приложении: только полоска прокрутки, без стрелок, в цветах сайта.
   Свойства scrollbar-width/scrollbar-color тут не годятся: с ними Chromium рисует стрелки. */
html.in-app::-webkit-scrollbar, html.in-app *::-webkit-scrollbar { width: 10px; height: 10px; }
html.in-app::-webkit-scrollbar-track, html.in-app *::-webkit-scrollbar-track { background: transparent; }
html.in-app::-webkit-scrollbar-thumb, html.in-app *::-webkit-scrollbar-thumb { background: var(--line) padding-box; border: 3px solid transparent; border-radius: 10px; }
html.in-app::-webkit-scrollbar-thumb:hover, html.in-app *::-webkit-scrollbar-thumb:hover { background-color: var(--sub); }
html.in-app::-webkit-scrollbar-button, html.in-app *::-webkit-scrollbar-button { display: none; }
html.in-app::-webkit-scrollbar-corner, html.in-app *::-webkit-scrollbar-corner { background: transparent; }
.dt { min-width: 168px; font-variant-numeric: tabular-nums; }
.platforms { display: flex; gap: 8px; margin-left: auto; flex: none; color: var(--sub); }
.r-post[data-href] .r-media-img { cursor: pointer; }
.r-view { width: 100vw; height: 100dvh; max-width: none; max-height: none; padding: 0; border: 0; background: none; overflow: hidden; }
.r-view[open] { display: flex; align-items: center; justify-content: center; }
.r-view::backdrop { background: rgba(0, 0, 0, .9); }
:root:has(.r-view[open]) { overflow: hidden; }
.use .zoomable { cursor: zoom-in; }
.r-view > img, .r-view > video { max-width: calc(100vw - 32px); max-height: calc(100dvh - 88px); margin-top: 56px; border-radius: 10px; object-fit: contain; }
.r-view-bar { position: absolute; top: 12px; right: 16px; display: flex; gap: 8px; }
.r-view-bar a, .r-view-bar button { padding: 8px 16px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .14); color: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.r-view-bar a:hover, .r-view-bar button:hover { background: rgba(255, 255, 255, .26); color: #fff; }
.r-view-bar [data-view-close] { width: 38px; padding: 8px 0; }
.r-field-body .attach-preview img { width: 36px; height: 36px; }

/* Стикеры */
.sticker-panel { width: 360px; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sticker-panel button { padding: 4px; }
.sticker-panel img { display: block; width: 100%; height: 100%; }
.c-sticker { display: block; width: 160px; height: 160px; margin: 2px 0; }

/* В сети и галочки */
.r-msg-line { display: flex; align-items: flex-end; gap: 6px; }
.r-msg-body { min-width: 0; }
.r-ticks { flex: none; display: inline-flex; margin-bottom: 2px; color: var(--faint); }
.r-ticks.read { color: var(--accent); }

/* Группы */
.r-chat-top { align-items: center; }
.r-chat-bugs { display: block; padding: 0 16px 10px; font-size: 13px; }
.r-chat-bugs .rail-count:not([hidden]) { position: static; display: inline-block; margin-left: 4px; vertical-align: 1px; }
.r-group-new { width: min(420px, 100%); margin: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.r-group-new h2 { font-size: 18px; font-weight: 800; }
.r-group-new .btn { padding: 10px 20px; cursor: pointer; }
.r-group-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.r-group-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-group-who small { color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Чужие сообщения слева, свои справа */
.r-msg { max-width: 80%; }
.r-msg:hover { background: none; }
.r-msg-text { width: fit-content; padding: 7px 12px; border-radius: 16px; background: var(--pill); }
.r-msg.mine { align-self: flex-end; }
.r-msg.mine > a, .r-msg.mine > .r-msg-gap, .r-msg.mine .r-meta .r-user { display: none; }
.r-msg.mine .r-msg-main { align-items: flex-end; }
.r-msg.mine .r-msg-text { background: var(--accent); color: #fff; }
.r-msg.mine .r-msg-text .r-link { color: #fff; text-decoration: underline; }
.r-chat-search { width: auto; margin: 0 16px 10px; padding: 8px 14px; }
.r-chat-search svg { stroke: var(--sub); }

.r-menu-list label { display: block; padding: 10px 16px; font-weight: 600; cursor: pointer; }
.r-menu-list label:hover { background: var(--pill); }
.r-menu-list label:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Плотный чат: сообщения в одной колонке по центру, свои и чужие рядом */
.r-msgs { padding: 10px max(16px, calc((100% - 600px) / 2)); }
.r-msg { max-width: 85%; margin: 0; padding: 1px 0; gap: 8px; }
.r-msg:not(.grouped) { margin-top: 8px; }
.r-msg-main { gap: 1px; }
.r-msg-text { padding: 5px 11px; line-height: 1.35; }
.r-msg-gap { width: 28px; }
.r-msg .r-ava { --s: 28px !important; }
.r-msg .r-meta { font-size: 12px; }
.r-msg .c-sticker { width: 168px; height: 168px; }
/* Сообщение из 1–3 эмодзи — крупно и без пузыря, как в Телеграме */
.r-bubble.emoji .r-msg-text { display: block; padding: 0; line-height: 1.15; }
.r-bubble.e1 .r-msg-text { font-size: 76px; }
.r-bubble.e2 .r-msg-text { font-size: 56px; }
.r-bubble.e3 .r-msg-text { font-size: 44px; }
.r-room .r-chat-form { width: calc(100% - 32px); max-width: 600px; margin-left: auto; margin-right: auto; }
.r-day { margin: 8px 0 4px; }
.r-chat-item { padding: 7px 10px; gap: 10px; }

.r-names { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.r-names b { color: var(--text); font-size: 14px; font-weight: 700; }
.r-names small { color: var(--sub); font-size: 12px; }

.emoji.up .emoji-panel { top: auto; bottom: calc(100% + 6px); }
.r-c-body:empty { display: none; }

/* Шапка профиля: аватарка заходит на шапку, имя и соцсети стоят с ней в одну линию */
.r-profile .r-phead { align-items: flex-end; gap: 18px; margin-top: -52px; padding: 0 20px 6px; }
.r-pava .r-ava { box-shadow: 0 0 0 5px var(--panel); }
.r-online { position: absolute; right: 8px; bottom: 8px; width: 20px; height: 20px; border-radius: 50%; background: #3DBE6C; box-shadow: 0 0 0 4px var(--panel); }
.r-profile .r-phead-text { flex: 1; padding-bottom: 8px; }
.r-phead-text .r-sub .r-dot { color: var(--faint); }
.r-nets { flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 45%; padding-bottom: 12px; }
@media (max-width: 640px) {
  .r-profile .r-phead { flex-wrap: wrap; gap: 8px 14px; margin-top: -40px; padding: 0 8px; }
  .r-pava .r-ava { --s: 92px !important; font-size: 40px; }
  .r-online { right: 5px; bottom: 5px; width: 16px; height: 16px; }
  .r-profile .r-phead { flex-wrap: nowrap; }
  .r-profile .r-phead-text { min-width: 0; flex: 1 1 0; padding-bottom: 2px; }
  /* Соцсети в строке с аватаркой справа от имени, много значков переносится внутри своего блока */
  .r-nets { max-width: 40%; gap: 4px; padding-bottom: 4px; }
  .r-net { width: 30px; height: 30px; }
  /* Больше трёх значков не влезает рядом с именем: отдельной строкой под именем */
  .r-profile .r-phead:has(.r-nets > :nth-child(4)) { flex-wrap: wrap; }
  .r-nets:has(> :nth-child(4)) { flex-basis: 100%; max-width: none; justify-content: flex-start; padding: 0 0 0 106px; }
}

/* Переписка: список слева, сама переписка отдельным окном */
.r-chat { flex: none; width: calc(100% - 48px); max-width: 1120px; height: calc(100vh - var(--top-h) - 48px); margin: 24px auto; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; }
.r-chat-list { border-right: 0; }
.r-room { background: var(--card2); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
@media (max-width: 760px) {
  /* minmax(0, …): иначе колонка растягивается под самое длинное «последнее сообщение» и страница шире экрана */
  .r-chat { width: 100%; height: calc(100vh - 150px); margin: 0; grid-template-columns: minmax(0, 1fr); gap: 0; }
  .r-room { border: 0; border-radius: 0; }
}

/* Время и галочки внутри сообщения, как в Telegram */
.r-bubble { width: fit-content; max-width: 100%; padding: 5px 10px; border-radius: 16px; background: var(--pill); }
.r-msg.mine .r-bubble { background: var(--accent); color: #fff; }
.r-msg .r-msg-text, .r-msg.mine .r-msg-text { display: inline; width: auto; padding: 0; border-radius: 0; background: none; }
.r-msg-info { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 5px 0 -1px 10px; font-size: 11px; line-height: 1; color: var(--sub); }
.r-msg.mine .r-msg-info, .r-msg.mine .r-ticks { color: rgba(255, 255, 255, .8); }
.r-msg.mine .r-ticks.read { color: #fff; }
.r-ticks, .r-ticks.read { margin: 0; }
.r-ticks svg { width: 15px; height: 12px; }
.r-bubble.sticker { padding: 0; background: none; }
.r-msg.mine .r-bubble.sticker { background: none; }
.r-bubble.sticker .r-msg-info { float: none; display: flex; width: fit-content; margin: 2px 0 0 auto; padding: 2px 6px; border-radius: 8px; background: rgba(0, 0, 0, .5); color: #fff; }

/* Окно вопроса */
.r-ask { overflow: visible; }
.r-ask .field input { padding: 10px 14px; border-radius: 10px; font-weight: 400; }
.r-ask .r-crop-bar .btn { cursor: pointer; }

/* В окне вопроса подсказки раздвигают окно, а не закрывают кнопки */
.r-ask .suggest { position: static; width: 100%; margin-top: 2px; border-radius: 12px; box-shadow: none; }
.r-menu-list .r-menu-danger { color: var(--err); }

/* ---------- Телефон: стоит в конце, чтобы перекрывать правила выше ---------- */
html { -webkit-tap-highlight-color: transparent; }
/* После касания :hover залипает, поэтому на сенсорных экранах отклик даёт только нажатие */
@media (hover: none) {
  .btn:hover { background: none; color: inherit; }
  .btn.primary:hover { background: #1473E6; border-color: #1473E6; color: #fff; }
  .btn.danger:hover { background: none; color: var(--err); }
  a:active, button:active, summary:active { opacity: .7; }
}
@media (max-width: 640px) {
  /* Меньше 16px iPhone приближает страницу при вводе */
  input, textarea, select { font-size: 16px !important; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs button { flex: none; }
  .sticker-panel { width: min(360px, calc(100vw - 104px)); }
  .r-chat { height: calc(100dvh - var(--top-h) - 72px); min-height: 0; }
  /* Открытая переписка на весь экран, как в мессенджерах: шапка и меню не отнимают место у клавиатуры */
  .r-chat.has-room { position: fixed; inset: 0; z-index: 26; height: 100dvh; background: var(--panel); }
  /* На узком экране значкам остаётся ~110px под текст: с текстом поле уходит на всю ширину строкой выше кнопок. */
  .r-chat-form textarea { text-align: left; }
  .r-chat-form:has(textarea:not(:placeholder-shown)) { flex-wrap: wrap; row-gap: 2px; padding-left: 10px; border-radius: 20px; }
  .r-chat-form:has(textarea:not(:placeholder-shown)) textarea { order: -1; flex: 1 0 100%; padding: 6px 4px 2px; }
  .r-chat-form:has(textarea:not(:placeholder-shown)) .r-mic { margin-left: auto; }
  .r-chat-form:has(textarea:not(:placeholder-shown)) .r-chat-staged:not([hidden]) { order: -2; flex-basis: 100%; }
}

/* Фото и голосовые в переписке */
.r-chat-form .r-iconbtn { flex: none; color: var(--sub); cursor: pointer; }
.r-chat-form .r-iconbtn:hover { color: var(--text); }
.r-rec { display: none; flex: 1; align-items: center; gap: 10px; min-height: 32px; }
.r-rec i { width: 10px; height: 10px; border-radius: 50%; background: #E5352B; }
.r-rec b { font-variant-numeric: tabular-nums; font-weight: 600; }
.r-rec .linkbtn { margin-left: auto; align-self: center; }
.r-chat-form.recording .r-rec { display: flex; }
.r-chat-form.recording textarea, .r-chat-form.recording .emoji, .r-chat-form.recording .r-chat-photo, .r-chat-form.recording .r-mic { display: none; }
.r-bubble .r-media { width: 300px; max-width: 100%; margin: 0; }
.r-voice { display: flex; align-items: center; gap: 10px; width: 230px; max-width: 100%; padding: 2px 0; border: 0; background: none; color: inherit; }
.r-voice-btn { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.r-msg.mine .r-voice-btn { background: #fff; color: var(--accent); }
.r-voice-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--edge); overflow: hidden; }
.r-msg.mine .r-voice-bar { background: rgba(255, 255, 255, .35); }
.r-voice-bar i { display: block; width: 0; height: 100%; border-radius: 2px; background: var(--accent); }
.r-msg.mine .r-voice-bar i { background: #fff; }
.r-voice-time { flex: none; font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- Телефон с крупным системным шрифтом: ничего не вылезает за экран ---------- */
.card-foot { flex-wrap: wrap; row-gap: 10px; }
.card-foot .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) {
  /* Уведомления листом под шапкой во всю ширину, как в VK и Instagram */
  .bell-panel {
    position: fixed; left: 8px; right: 8px; top: calc(var(--top-h) - 6px); width: auto;
    max-height: calc(100dvh - var(--top-h) - 96px); border-radius: 14px;
  }
  /* Нижнее меню всегда влезает: подписи в одну строку, лишнее — многоточием */
  .rail { overflow-x: hidden; }
  .rail a { flex: 1 1 0; min-width: 0; }
  .rail a > span:last-child { max-width: 100%; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rail-admin { flex: 2 1 0; min-width: 0; }
  /* Значки шапки всегда в строке с логотипом: сжимается название, а не ряд */
  .brand { flex: 1 1 0; min-width: 0; }
  .brand span { overflow: hidden; text-overflow: ellipsis; }
  /* У админа семь пунктов: только значки, как в Instagram и X; подпись остаётся для экранного диктора */
  .rail:has(.rail-admin:not([hidden])) a > span:last-child { position: absolute; width: 1px; height: 1px; padding: 0; clip-path: inset(50%); }
}

/* Свои сообщения: «Изменить» и «Удалить» появляются при наведении, рядом с пузырём. */
.r-msg-main { position: relative; }
.r-msg-acts { position: absolute; top: 50%; right: calc(100% + 4px); transform: translateY(-50%); display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.r-msg:hover .r-msg-acts, .r-msg-acts:focus-within { opacity: 1; }
.r-msg-acts .r-iconbtn { width: 28px; height: 28px; color: var(--sub); }
.r-msg-acts .r-iconbtn:hover { color: var(--text); }
@media (hover: none) { .r-msg-acts { opacity: 1; position: static; transform: none; align-self: flex-end; } }
.r-edit-bar { display: flex; align-items: center; gap: 8px; width: calc(100% - 32px); max-width: 600px; margin: 0 auto 6px; padding: 6px 6px 6px 14px; border-left: 2px solid var(--accent); color: var(--sub); font-size: 13px; }
.r-edit-bar svg { color: var(--accent); flex: none; }
.r-edit-bar span { flex: 1; }
.r-edit-bar .r-iconbtn { width: 28px; height: 28px; color: var(--sub); font-size: 18px; }
.r-pill.off { opacity: .45; cursor: not-allowed; }
.r-group-who small a { color: inherit; }
.r-group-who small a:hover, .r-meta a.r-user:hover { text-decoration: underline; }

/* Модерация */
.r-tag.mod { background: rgba(20, 115, 230, .22); color: var(--link); vertical-align: middle; }
.r-tag.ban { background: rgba(255, 79, 122, .18); color: #FF4F7A; vertical-align: middle; }
h1 .r-tag { font-size: 12px; margin-left: 6px; }
.ban-bar { padding: 10px 20px; background: rgba(255, 79, 122, .14); color: var(--text); font-size: 14px; text-align: center; }
.move-bar { background: rgba(20, 115, 230, .14); }
.move-bar a { color: var(--link); }
.move-x { margin-left: 8px; border: 0; background: none; color: var(--muted, inherit); font-size: 18px; line-height: 1; cursor: pointer; }
.mod-acts { display: flex; flex-direction: column; gap: 8px; }
.table-box td .r-tag { margin-left: 6px; }
.r-pcard-mod .r-menu, .r-pcard-mod summary { width: 100%; justify-content: center; }
.r-pcard-mod { position: relative; z-index: 10; }
.r-pcard-mod .r-menu-list { left: 0; right: 0; }
summary.r-pill { list-style: none; cursor: pointer; }
summary.r-pill::-webkit-details-marker { display: none; }
.r-tag.admin { background: rgba(255, 197, 49, .18); color: #FFC531; vertical-align: middle; }
html[data-theme=light] .r-tag.admin { color: #A86A00; }
.mod-check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.mod-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.mod-fields { display: flex; flex-direction: column; gap: 12px; }
.mod-term-row { display: flex; gap: 8px; }
.mod-term-row input { width: 90px; flex: none; }
.mod-term-row select { flex: 1; }
.mod-term-row input, .mod-term-row select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
