/* ==========================================================================
   Третья версия: чат, вложения, просмотр картинок, быстрый поиск,
   стена, награды, лента, топ, аналитика и личные настройки вида.
   Все цвета — из переменных style.css, поэтому тёмная тема работает сама.
   ========================================================================== */

:root {
  /* Цвета графиков (проверены на различимость, в том числе при дальтонизме) */
  --viz-1: #2a78d6;
  --viz-2: #1baf7a;
  --viz-3: #6250d6;
  --st-0: #2a78d6; --st-1: #eb6834; --st-2: #1baf7a; --st-3: #eda100; --st-4: #e87ba4; --st-5: #008300;
  --bubble-mine: var(--accent);
  --hl: color-mix(in srgb, var(--marker) 55%, transparent);
}
:root[data-theme="dark"] {
  --viz-1: #3987e5; --viz-2: #199e70; --viz-3: #9085e9;
  --st-0: #3987e5; --st-1: #d95926; --st-2: #199e70; --st-3: #c98500; --st-4: #d55181; --st-5: #008300;
  --hl: color-mix(in srgb, var(--marker) 30%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --viz-1: #3987e5; --viz-2: #199e70; --viz-3: #9085e9;
    --st-0: #3987e5; --st-1: #d95926; --st-2: #199e70; --st-3: #c98500; --st-4: #d55181; --st-5: #008300;
    --hl: color-mix(in srgb, var(--marker) 30%, transparent);
  }
}

/* ---------- Личная настройка вида: плотность и размер текста ---------- */
html.ts-s { font-size: 93.75%; }
html.ts-s body { font-size: 15px; }
html.ts-l body { font-size: 17.5px; }
html.ts-l .prose { font-size: 1.08em; }
html.dens-compact .t-row { padding-top: 9px; padding-bottom: 9px; }
html.dens-compact .t-row .av-md { width: 32px; height: 32px; font-size: 12px; }
html.dens-compact .post { margin-bottom: 10px; }
html.dens-compact .post-body { padding-top: 14px; padding-bottom: 14px; }
html.dens-compact .card { padding: 18px; }
html.dens-compact .cat-row { padding-top: 12px; padding-bottom: 12px; }
html.dens-compact .msg-bubble { padding: 7px 11px 5px; }
.field label.choice { display: inline-flex; padding: 9px 14px; }
.field label.choice.rich { display: flex; padding: 13px 15px; }
.field label.accent-opt { display: inline-flex; padding: 8px 14px 8px 9px; }
.field label.status-opt, .field label.role-check, .field label.icon-opt, .field label.swatch { margin-bottom: 0; }
.accent-sw.site { background: conic-gradient(var(--sw, var(--accent)) 0 50%, var(--surface-2) 0); }
.sound-test-row { margin: -4px 0 8px; }

/* ==========================================================================
   Вложения: галерея, карточки файлов, плашки при загрузке
   ========================================================================== */

.atts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 14px; min-width: 0; }
.atts.compact { margin-top: 6px; gap: 6px; }
.att-gallery { display: grid; gap: 4px; border-radius: 14px; overflow: hidden; max-width: 560px; }
.att-gallery.n1 { grid-template-columns: 1fr; max-width: 460px; }
.att-gallery.n2 { grid-template-columns: 1fr 1fr; }
.att-gallery.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.att-gallery.n3 .att-img:first-child { grid-row: span 2; }
.att-gallery.n4 { grid-template-columns: 1fr 1fr; }
.att-img { position: relative; display: block; background: var(--surface-2); overflow: hidden; aspect-ratio: 4 / 3; cursor: zoom-in; }
.att-gallery.n1 .att-img { aspect-ratio: var(--ar, 16 / 10); max-height: 420px; }
.att-gallery.n3 .att-img:first-child { aspect-ratio: auto; }
.att-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.att-img:hover img { transform: scale(1.04); }
.att-img.more { display: none; }
.att-more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(13, 15, 34, .55); color: #fff; font: 600 26px var(--f-display); backdrop-filter: blur(2px); }
.atts.compact .att-gallery { max-width: 320px; border-radius: 12px; }
.atts.compact .att-gallery.n1 .att-img { max-height: 300px; }

.att-files { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; max-width: 520px; min-width: 0; }
.att-file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--ink); text-decoration: none !important; transition: border-color .15s, box-shadow .15s, transform .15s; }
.att-file:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.att-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.att-meta b { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-meta small { color: var(--ink-3); font-size: 12.5px; }
.att-dl { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); flex: none; transition: background .15s, color .15s; }
.att-file:hover .att-dl { background: var(--accent); color: var(--on-accent); }
.msg.mine .att-file { background: color-mix(in srgb, var(--on-accent) 14%, transparent); border-color: color-mix(in srgb, var(--on-accent) 25%, transparent); color: var(--on-accent); }
.msg.mine .att-meta small { color: inherit; opacity: .75; }
.msg.mine .att-dl { background: color-mix(in srgb, var(--on-accent) 22%, transparent); color: var(--on-accent); }

/* Плитка с расширением файла */
.ftile { position: relative; display: inline-grid; place-items: center; width: 40px; height: 46px; flex: none; color: var(--ft, var(--ink-3)); }
.ftile .ic { width: 40px; height: 46px; stroke-width: 1.3; }
.ftile b { position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%); padding: 1px 4px; border-radius: 4px; background: var(--ft, var(--ink-3)); color: #fff; font: 700 8.5px/1.25 var(--f-body); letter-spacing: .03em; }

/* Панель вложений в редакторе и поле ввода */
.att-bar { display: grid; gap: 10px; padding: 12px 14px; border-top: 1px dashed var(--line-2); transition: background .15s; }
.att-bar.drag-on, .composer.drag-on { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -4px; }
.att-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.att-actions .hint { margin: 0; }
.att-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.att-chips:empty { display: none; }
.att-chip { position: relative; display: inline-flex; align-items: center; gap: 9px; max-width: 260px; padding: 6px 34px 6px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .04); overflow: hidden; }
.att-chip.just { animation: chip-in .3s ease-out; }
@keyframes chip-in { from { transform: scale(.92); opacity: .4; } }
.att-chip > img, .att-chip-thumb img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }
.att-chip-thumb { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--surface-2); color: var(--ink-3); flex: none; overflow: hidden; }
.att-chip .ftile { width: 34px; height: 40px; }
.att-chip .ftile .ic { width: 34px; height: 40px; }
.att-chip .ftile b { bottom: 6px; font-size: 7.5px; }
.att-chip-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.att-chip-meta b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-chip-meta small { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.att-chip-x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); cursor: pointer; }
.att-chip-x:hover { background: var(--bad-soft); color: var(--bad); }
.att-chip-x .ic { width: 14px; height: 14px; }
.att-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.att-prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.att-chip.uploading .att-chip-thumb img { opacity: .55; filter: saturate(.6); }
.is-uploading .cmp-send, .is-uploading button[type="submit"].btn-primary { opacity: .6; cursor: progress; }
.post-atts { padding: 4px 22px 10px; max-width: 880px; }
.post-atts .atts { margin-top: 0; }
@media (max-width: 760px) { .post-atts { padding: 4px 16px 8px; } }
.editor.drag-on { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ==========================================================================
   Общий чат
   ========================================================================== */

.chat { display: grid; grid-template-columns: 250px minmax(0, 1fr) 250px; height: calc(100vh - 150px); min-height: 520px; max-height: 900px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.chat-rooms { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface-2); min-height: 0; }
.chat-rooms-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.chat-rooms nav { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 0 8px 12px; overflow-y: auto; overflow-x: hidden; }
.room-link { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 10px; border-radius: 12px; color: var(--ink); text-decoration: none !important; transition: background .15s; }
.room-link:hover { background: var(--surface); }
.room-link.on { background: var(--surface); box-shadow: var(--shadow); }
.room-link.on::before { content: ''; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.room-link.on { margin-left: 0; }
.room-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.room-txt b { font-weight: 600; font-size: 14.5px; }
.room-txt small { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-link.unread b { font-weight: 700; }
.room-flag { margin-left: auto; color: var(--ink-3); display: inline-flex; }
.room-flag .ic { width: 14px; height: 14px; }
.room-dot { margin-left: auto; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.room-flag + .room-dot { margin-left: 6px; }
.room-ic { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; flex: none; background: color-mix(in srgb, var(--rc, var(--accent)) 16%, var(--surface)); color: var(--rc, var(--accent)); }
.room-ic .ic { width: 18px; height: 18px; }
.room-ic.lg { width: 44px; height: 44px; border-radius: 14px; }
.room-ic.lg .ic { width: 22px; height: 22px; }
:root[data-theme="dark"] .room-ic { color: color-mix(in srgb, var(--rc) 55%, #fff); }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .room-ic { color: color-mix(in srgb, var(--rc) 55%, #fff); } }

.chat-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.chat-title { min-width: 0; }
.chat-title h1 { font-size: 18px; line-height: 1.2; }
.chat-title p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-flags { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chat-pinned { display: flex; align-items: center; gap: 10px; padding: 9px 18px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--marker) 16%, var(--surface)); color: var(--ink); text-decoration: none !important; font-size: 13.5px; }
.chat-pinned .ic { color: var(--warn); flex: none; }
.chat-pinned div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.chat-pinned b { font-size: 12.5px; color: var(--warn); }
.chat-pinned span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.chat-pinned.new { animation: toast-in .3s ease-out; }
.chat-side { border-left: 1px solid var(--line); padding: 14px; display: grid; align-content: start; gap: 14px; overflow-y: auto; background: var(--surface-2); }
.chat-side .side-box { padding: 14px 16px; }
.chat-side .people { gap: 9px; }
.presence-count { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.chat-tips ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }

/* ==========================================================================
   Лента сообщений (чат и личные сообщения)
   ========================================================================== */

.thread { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 18px 10px; display: flex; flex-direction: column; gap: 2px; background: var(--surface-2);
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1px); background-size: 18px 18px; scroll-padding-bottom: 20px; }
.thread-earlier { align-self: center; margin-bottom: 10px; }
.thread-empty { margin: auto; display: grid; justify-items: center; gap: 6px; text-align: center; color: var(--ink-3); max-width: 320px; padding: 30px 0; }
.thread-empty .ic { width: 44px; height: 44px; padding: 10px; border-radius: 16px; background: var(--surface); color: var(--accent); box-shadow: var(--shadow); margin-bottom: 6px; }
.thread-empty b { color: var(--ink); font-size: 16px; }
.thread-new { position: sticky; bottom: 4px; align-self: center; z-index: 2; display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 7px 14px; border: 0; border-radius: 99px; background: var(--ink); color: var(--paper); font: 600 13px var(--f-body); box-shadow: var(--shadow-pop); cursor: pointer; animation: toast-in .25s ease-out; }
.thread-new[hidden] { display: none; }
.thread-new .ic { width: 16px; height: 16px; }

.msg { position: relative; display: flex; gap: 8px; align-items: flex-end; max-width: min(78%, 680px); margin-top: 10px; }
.msg.cont { margin-top: 2px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-av { width: 30px; flex: none; }
.msg.mine .msg-av { display: none; }
.msg-col { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
.msg.mine .msg-col { align-items: flex-end; }
.msg-name { display: flex; align-items: center; gap: 6px; margin: 0 0 3px 4px; font-size: 13px; }
.msg-name .nick { font-weight: 600; }
.msg-name .role-badge { transform: scale(.88); transform-origin: left center; }
.msg-name time { font-size: 11.5px; }
.msg-bubble { position: relative; padding: 8px 12px 6px; border-radius: 18px 18px 18px 6px; background: var(--surface); border: 1px solid var(--line); min-width: 0; max-width: 100%; box-shadow: 0 1px 1px rgba(0, 0, 0, .03); }
.msg.cont .msg-bubble { border-top-left-radius: 6px; }
.msg.mine .msg-bubble { border-radius: 18px 18px 6px 18px; background: var(--bubble-mine); border-color: var(--bubble-mine); color: var(--on-accent); }
.msg.mine.cont .msg-bubble { border-top-right-radius: 6px; }
.msg-bubble .prose { font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.msg-bubble .prose > * + * { margin-top: .4em; }
.msg.mine .msg-bubble .prose a { color: inherit; text-decoration: underline; }
.msg.mine .msg-bubble .prose .mention { background: color-mix(in srgb, var(--on-accent) 20%, transparent); color: inherit; text-decoration: none; }
.msg.mine .msg-bubble .prose code { background: rgba(255, 255, 255, .18); border-color: transparent; color: inherit; }
.msg.mine .msg-bubble .prose blockquote { border-color: currentColor; color: inherit; opacity: .9; }
.msg-bubble.deleted { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-style: italic; font-size: 14px; background: transparent; border-style: dashed; }
.msg.mine .msg-bubble.deleted { color: var(--ink-3); background: transparent; border-color: var(--line-2); }
.msg-bubble.deleted .ic { width: 15px; height: 15px; }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: 5px; margin-top: 2px; font-size: 11px; opacity: .7; float: right; margin-left: 10px; position: relative; top: 4px; }
.msg-meta time { font-variant-numeric: tabular-nums; }
.msg-meta .ic { width: 15px; height: 15px; }
.msg-edited { font-style: italic; }
.msg-read { display: inline-flex; }
.msg-read.on { color: inherit; opacity: 1; }
.msg-bubble::after { content: ''; display: table; clear: both; }
.msg-reply { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px; padding: 4px 10px; border-left: 3px solid var(--accent); border-radius: 4px 8px 8px 4px; background: var(--accent-soft); color: var(--ink); font-size: 13px; line-height: 1.35; text-decoration: none !important; max-width: 100%; }
.msg-reply b { color: var(--accent); font-size: 12.5px; }
.msg-reply span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.msg.mine .msg-reply { background: color-mix(in srgb, var(--on-accent) 16%, transparent); border-color: currentColor; color: inherit; }
.msg.mine .msg-reply b, .msg.mine .msg-reply span { color: inherit; }
.msg-tools { position: absolute; top: -14px; display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(4px); transition: opacity .12s, transform .12s; z-index: 3; }
.msg:not(.mine) .msg-tools { left: 46px; }
.msg.mine .msg-tools { right: 6px; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; pointer-events: auto; transform: none; }
.msg-tools .icon-btn { width: 28px; height: 28px; }
.msg-tools .icon-btn .ic { width: 16px; height: 16px; }
.msg-tools .icon-btn.danger:hover { color: var(--bad); background: var(--bad-soft); }
.msg.new { animation: msg-in .28s cubic-bezier(.2, .8, .3, 1.2); }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.msg.flash-hl .msg-bubble, .flash-hl { animation: flash-hl 1.6s ease-out; }
@keyframes flash-hl { 0%, 35% { box-shadow: 0 0 0 4px var(--hl); } }
.msg-ignored { align-self: stretch; margin: 6px 0; font-size: 13px; color: var(--ink-3); }
.msg-ignored > summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--surface); border: 1px dashed var(--line-2); list-style: none; }
.msg-ignored > summary::-webkit-details-marker { display: none; }
.msg-ignored > summary .ic { width: 14px; height: 14px; }
.msg-ignored[open] > summary { margin-bottom: 6px; }
.msg-day { text-align: center; margin: 14px 0 4px; }
.msg-day span { font-size: 12px; color: var(--ink-2); background: var(--surface); padding: 3px 11px; border-radius: 99px; border: 1px solid var(--line); }
.msg .atts.compact .att-gallery { margin-top: 2px; }
.msg-bubble .atts.compact:first-child { margin-top: 0; }

/* Поле ввода */
.composer { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 14px 8px; border-top: 1px solid var(--line); background: var(--surface); }
.composer-off { margin: 12px; }
.cmp-row { display: flex; align-items: flex-end; gap: 6px; }
.cmp-row textarea { flex: 1; min-width: 0; resize: none; min-height: 44px; max-height: 200px; border: 1.5px solid var(--line-2); border-radius: 14px; padding: 10px 14px; background: var(--surface-2); font: inherit; font-size: 15px; line-height: 1.45; color: var(--ink); transition: border-color .15s, background .15s; }
.cmp-row textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.cmp-row .icon-btn { width: 40px; height: 44px; flex: none; }
.cmp-send { height: 44px; padding: 0 16px; border-radius: 14px; flex: none; }
.cmp-send span { margin-left: 2px; }
.cmp-foot { display: flex; justify-content: space-between; gap: 10px; min-height: 16px; font-size: 12px; color: var(--ink-3); }
.cmp-foot [data-typing-label] { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 500; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: typing 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-3px); opacity: 1; } }
.accent-text { color: var(--accent) !important; }
.cmp-context { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 10px; border-radius: 12px; background: var(--accent-soft); border-left: 3px solid var(--accent); }
.cmp-context[hidden] { display: none; }
.cmp-context > div { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.cmp-context b { font-size: 12.5px; color: var(--accent); }
.cmp-context span { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-ic { color: var(--accent); display: inline-flex; }
.composer.is-editing .cmp-context { background: color-mix(in srgb, var(--marker) 22%, var(--surface)); border-color: var(--warn); }
.composer.is-editing .cmp-context b, .composer.is-editing .cmp-ic { color: var(--warn); }
.composer.is-editing .att-bar, .composer.is-editing [data-att-pick] { display: none; }
.composer .att-bar.inline { padding: 0; border: 0; }
.composer .att-bar.inline:not(.has-files) .att-chips:empty { display: none; }
.composer .att-bar.inline:has(.att-chips:empty) { display: none; }
.composer .mention-box { top: auto !important; bottom: calc(100% + 6px); }
.cmp-emoji { position: absolute; right: 70px; bottom: calc(100% - 4px); z-index: 20; display: grid; grid-template-columns: repeat(9, 34px); gap: 2px; padding: 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop); animation: toast-in .15s ease-out; }
.cmp-emoji button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: none; font-size: 20px; cursor: pointer; }
.cmp-emoji button:hover { background: var(--surface-2); transform: scale(1.12); }

/* Личные сообщения в новой разметке */
.pm .thread { padding-bottom: 12px; }
.pm-head-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pm-head-main > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-menu { margin-left: auto; position: relative; }
.pm-menu > summary { list-style: none; cursor: pointer; }
.pm-menu > summary::-webkit-details-marker { display: none; }
.pm-settings { position: absolute; right: 0; top: calc(100% + 8px); width: 320px; padding: 14px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-pop); z-index: 30; }
.pm-set-row { display: flex; align-items: flex-end; gap: 8px; }
.pm-set-row label { flex: 1; display: grid; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.pm-set-row input { width: 100%; height: 36px; padding: 0 10px; border: 1.5px solid var(--line-2); border-radius: 10px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 14px; }
.pm-people { max-height: 220px; overflow-y: auto; }
.pm-people li form { margin-left: auto; }
.av-stack { display: inline-flex; flex: none; }
.av-stack > * { box-shadow: 0 0 0 2px var(--surface); border-radius: 50%; }
.av-stack > * + * { margin-left: -12px; }
.av-more { background: var(--surface-2); color: var(--ink-2); font-size: 11px; }
.conv-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-name .ic { width: 15px; height: 15px; color: var(--ink-3); flex: none; }

/* ==========================================================================
   Просмотр картинок
   ========================================================================== */

html.lb-open, html.pal-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 200; display: none; grid-template-rows: auto minmax(0, 1fr) auto; background: rgba(8, 9, 20, .94); color: #fff; animation: fade-in .18s ease-out; }
.lightbox.open { display: grid; }
@keyframes fade-in { from { opacity: 0; } }
.lb-top { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.lb-count { font: 600 13px var(--f-body); padding: 4px 10px; border-radius: 99px; background: rgba(255, 255, 255, .12); font-variant-numeric: tabular-nums; }
.lb-count:empty { display: none; }
.lb-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.lb-name b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-name small { font-size: 12px; opacity: .65; }
.lb-actions { margin-left: auto; display: flex; gap: 4px; }
.lb-btn { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; transition: background .15s; }
.lb-btn:hover, .lb-btn:focus-visible { background: rgba(255, 255, 255, .2); outline: none; }
.lb-stage { grid-row: 2; display: grid; place-items: center; padding: 0 70px; min-height: 0; overflow: hidden; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); cursor: zoom-in; transition: transform .25s ease, opacity .2s; user-select: none; -webkit-user-drag: none; }
.lb-stage img.loading { opacity: .35; }
.lightbox.zoomed .lb-stage img { transform: scale(2.2); cursor: zoom-out; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 52px; height: 52px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer; transition: background .15s, transform .15s; }
.lb-nav:hover { background: rgba(255, 255, 255, .22); transform: translateY(-50%) scale(1.06); }
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 14px; }
.lightbox.single .lb-nav, .lightbox.single .lb-strip { display: none; }
.lb-strip { grid-row: 3; display: flex; justify-content: center; gap: 6px; padding: 12px 16px 16px; overflow-x: auto; }
.lb-strip:empty { display: none; }
.lb-strip button { flex: none; width: 56px; height: 42px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: none; cursor: pointer; opacity: .5; transition: opacity .15s, border-color .15s; }
.lb-strip button:hover { opacity: .85; }
.lb-strip button.on { opacity: 1; border-color: #fff; }
.lb-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prose img.post-img { cursor: zoom-in; }

/* ==========================================================================
   Быстрый поиск и горячие клавиши
   ========================================================================== */

.palette { position: fixed; inset: 0; z-index: 180; display: none; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: rgba(13, 15, 34, .45); backdrop-filter: blur(3px); animation: fade-in .12s ease-out; }
.palette.open { display: flex; }
.palette-box { width: min(640px, 100%); max-height: 70vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-pop), 0 0 0 6px color-mix(in srgb, var(--surface) 30%, transparent); overflow: hidden; animation: pal-in .16s ease-out; }
@keyframes pal-in { from { transform: translateY(-8px) scale(.985); opacity: 0; } }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-input > .ic { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.palette.busy .palette-input > .ic { color: var(--accent); animation: pulse-ic .8s infinite alternate; }
@keyframes pulse-ic { to { opacity: .35; } }
.palette-input input { flex: 1; height: 58px; border: 0; background: none; font: 500 17px var(--f-body); color: var(--ink); outline: none; }
kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); font: 600 11.5px var(--f-body); color: var(--ink-2); }
.palette-list { overflow-y: auto; padding: 8px; }
.pal-group { display: grid; gap: 1px; }
.pal-group + .pal-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.pal-group > b { padding: 4px 10px 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 11px; color: var(--ink); text-decoration: none !important; }
.pal-item.on { background: var(--accent-soft); }
.pal-item.on .pal-ic { color: var(--accent); }
.pal-ic { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); color: var(--ink-3); flex: none; }
.pal-ic .ic { width: 17px; height: 17px; }
.pal-ic .av { width: 30px; height: 30px; font-size: 11px; }
.pal-main { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.pal-main > span { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-main small { font-size: 12.5px; color: var(--ink-3); }
.pal-main mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }
.pal-item kbd { margin-left: auto; }
.pal-all .pal-ic { background: var(--accent); color: var(--on-accent); }
.pal-empty { padding: 18px 12px; color: var(--ink-3); text-align: center; }
.palette-foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 12px; color: var(--ink-3); }
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }
.palette-foot kbd { min-width: 18px; height: 18px; font-size: 10.5px; }
.head-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }

.hotkeys .palette-box { max-height: 80vh; }
.hk-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.hk-head b { display: inline-flex; align-items: center; gap: 8px; font: 600 16px var(--f-display); }
.hk-list { margin: 0; padding: 8px 16px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.hk-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.hk-list dt { white-space: nowrap; font-size: 12px; color: var(--ink-3); }
.hk-list dd { margin: 0; font-size: 13.5px; text-align: right; }
.hk-note { margin: 0; padding: 10px 16px 14px; font-size: 12.5px; color: var(--ink-3); }
.kb-on { box-shadow: 0 0 0 2px var(--accent), var(--shadow) !important; border-radius: var(--r); }

/* ==========================================================================
   Карточка участника при наведении
   ========================================================================== */

.ucard { position: absolute; z-index: 150; width: 300px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop); overflow: hidden; opacity: 0; pointer-events: none; transform: translateY(6px); transition: opacity .15s, transform .15s; }
.ucard.above { transform: translateY(calc(-100% - 6px)); }
.ucard.open { opacity: 1; pointer-events: auto; transform: none; }
.ucard.above.open { transform: translateY(-100%); }
.ucard-banner { height: 74px; background: linear-gradient(130deg, var(--b1, #3447D6), var(--b2, #C2367A)) center / cover; }
.ucard-banner[style*="background-image"] { background-size: cover; background-position: center; }
.ucard-body { position: relative; padding: 0 16px 14px; display: grid; gap: 6px; }
.ucard-av { margin-top: -30px; justify-self: start; border-radius: 50%; box-shadow: 0 0 0 4px var(--surface); display: inline-flex; }
.ucard-name { font: 600 17px var(--f-display); margin-top: 2px; }
.ucard-status { font-size: 13.5px; color: var(--ink-2); }
.ucard-roles { display: flex; flex-wrap: wrap; gap: 4px; }
.ucard-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0 0; }
.ucard-stats div { padding: 7px 4px; border-radius: 10px; background: var(--surface-2); text-align: center; }
.ucard-stats dt { font-size: 11px; color: var(--ink-3); }
.ucard-stats dd { margin: 0; font: 600 15px var(--f-display); }
.ucard-seen { margin: 0; }
.ucard-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ==========================================================================
   Статус, награды, стена, чёрный список
   ========================================================================== */

.ustatus-dot { display: inline-grid; place-items: center; margin-left: 4px; font-size: 14px; line-height: 1; cursor: default; vertical-align: 1px; }
.ustatus { display: inline-flex; align-items: center; gap: 5px; }
.ustatus-emoji { font-size: 1.1em; }
.status-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.status-opt input { position: absolute; opacity: 0; pointer-events: none; }
.status-opt span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); font-size: 20px; cursor: pointer; transition: transform .12s, border-color .12s, background .12s; }
.status-opt span:hover { transform: translateY(-2px); }
.status-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.status-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.medal { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; flex: none;
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--md, #E3A008) 55%, #fff), var(--md, #E3A008) 62%, color-mix(in srgb, var(--md, #E3A008) 75%, #000));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--md, #E3A008) 30%, var(--surface)), 0 2px 4px rgba(0, 0, 0, .15); }
.medal .ic { width: 60%; height: 60%; stroke-width: 2; }
.medal.lg { width: 44px; height: 44px; }
.medal.xl { width: 60px; height: 60px; }
.medal.more { background: var(--surface-2); color: var(--ink-2); font: 700 10px var(--f-body); box-shadow: 0 0 0 1px var(--line-2); }
.award-row { display: inline-flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.post-author .award-row { justify-content: center; }
.award-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.award-list li { display: flex; align-items: center; gap: 12px; }
.award-list li > div { flex: 1; min-width: 0; line-height: 1.35; }
.award-list p { margin: 1px 0; font-size: 13.5px; color: var(--ink-2); }
.award-list form { margin-left: auto; }

.wall { margin-top: 20px; }
.wall:first-child { margin-top: 0; }
.wall .card-head h2 { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.wall .card-head h2 .ic { width: 20px; height: 20px; color: var(--accent); }
.wall-form { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 16px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.wall-input { flex: 1; display: grid; gap: 8px; justify-items: end; }
.wall-input textarea { width: 100%; resize: vertical; min-height: 64px; padding: 10px 14px; border: 1.5px solid var(--line-2); border-radius: 14px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 15px; }
.wall-input textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.wall-list { display: grid; }
.wall-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.wall-item:last-child { border-bottom: 0; }
.wall-item:target { background: var(--accent-soft); border-radius: 12px; padding-left: 10px; padding-right: 10px; }
.wall-main { flex: 1; min-width: 0; }
.wall-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.wall-head .nick { font-weight: 600; }
.wall-del { margin-left: auto; }
.wall-empty { padding: 10px 0; }
.ignore-add { display: flex; gap: 8px; margin-bottom: 14px; }
.ignore-add input { flex: 1; }
.ignore-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ignore-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; }
.ignore-list li:hover { background: var(--surface-2); }
.ignore-list form { margin-left: auto; }
.post-ignored { margin-bottom: 14px; }
.post-ignored > summary { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); background: var(--surface); color: var(--ink-3); font-size: 14px; cursor: pointer; list-style: none; }
.post-ignored > summary::-webkit-details-marker { display: none; }
.post-ignored > summary .ic { width: 16px; height: 16px; flex: none; }
.pi-show { margin-left: auto; color: var(--accent); font-weight: 600; white-space: nowrap; }
.post-ignored[open] > summary { margin-bottom: 10px; }
.post-ignored[open] .pi-show { display: none; }
.profile-main .award-row { margin-top: 0; }

/* ==========================================================================
   Лента друзей и топ участников
   ========================================================================== */

.feed { position: relative; display: grid; gap: 12px; max-width: 820px; }
.feed::before { content: ''; position: absolute; left: 25px; top: 20px; bottom: 20px; width: 2px; background: var(--line); border-radius: 2px; }
.feed-item { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 6px 0 6px 6px; }
.feed-av { position: relative; display: inline-flex; flex: none; margin-top: 6px; z-index: 1; }
.feed-av > .av, .feed-av > .av-wrap { box-shadow: 0 0 0 4px var(--paper); border-radius: 50%; }
.feed-kind { position: absolute; right: -4px; bottom: -4px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 3px var(--paper); }
.feed-kind .ic { width: 12px; height: 12px; stroke-width: 2.2; }
.feed-award .feed-kind, .feed-badge .feed-kind { background: var(--marker); color: var(--marker-ink); }
.feed-friend .feed-kind { background: var(--ok); color: #fff; }
.feed-wall .feed-kind { background: var(--viz-3); color: #fff; }
.feed-main { flex: 1; min-width: 0; padding: 12px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.feed-main > p { margin: 0 0 4px; }
.feed-main .nick { font-weight: 600; }
.feed-main blockquote { margin: 6px 0 8px; padding: 8px 12px; border-left: 3px solid var(--line-2); border-radius: 0 10px 10px 0; background: var(--surface-2); color: var(--ink-2); font-size: 14.5px; }

.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 14px; max-width: 760px; margin: 10px auto 28px; }
.podium-col { display: grid; justify-items: center; gap: 6px; color: var(--ink); text-decoration: none !important; text-align: center; }
.podium-av { position: relative; transition: transform .2s; }
.podium-col:hover .podium-av { transform: translateY(-4px); }
.podium-av .av { box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px var(--pc, var(--line-2)), var(--shadow-pop); }
.podium-medal { position: absolute; right: -2px; bottom: 0; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--pc); color: #fff; font: 700 15px var(--f-display); box-shadow: 0 0 0 3px var(--surface); }
.podium-name { font: 600 16px var(--f-display); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-score { font-size: 13.5px; color: var(--ink-3); }
.podium-score b { color: var(--ink); font-size: 15px; }
.podium-step { display: grid; place-items: center; width: 100%; margin-top: 8px; border-radius: 16px 16px 6px 6px; background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 30%, var(--surface)), color-mix(in srgb, var(--pc) 10%, var(--surface))); border: 1px solid color-mix(in srgb, var(--pc) 40%, var(--line)); color: var(--pc); }
.podium-step .ic { width: 30px; height: 30px; }
.place-1 { --pc: #D9A200; }
.place-2 { --pc: #8E98AE; }
.place-3 { --pc: #C0703A; }
.place-1 .podium-step { height: 150px; }
.place-2 .podium-step { height: 110px; }
.place-3 .podium-step { height: 82px; }
.place-1 .podium-av .av { width: 110px; height: 110px; font-size: 36px; }
.top-list { list-style: none; margin: 0 auto; padding: 6px; max-width: 760px; }
.top-list li { display: grid; grid-template-columns: 34px auto minmax(0, 1fr) 160px auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; }
.top-list li:hover { background: var(--surface-2); }
.top-place { font: 600 15px var(--f-display); color: var(--ink-3); text-align: center; font-variant-numeric: tabular-nums; }
.top-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.top-name .nick { font-weight: 600; }
.top-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.top-bar span { display: block; height: 100%; width: var(--w); border-radius: 99px; background: var(--viz-1); }
.top-score { font-size: 13px; color: var(--ink-3); white-space: nowrap; text-align: right; min-width: 110px; }
.top-score b { color: var(--ink); font-size: 14.5px; }

/* ==========================================================================
   Рекомендуемые темы, массовые действия, свои страницы, таблицы
   ========================================================================== */

.featured { margin-bottom: 26px; }
.featured-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.featured-head h2 { display: inline-flex; align-items: center; gap: 8px; font-size: 19px; }
.featured-head h2 .ic { color: #D9A200; fill: color-mix(in srgb, #D9A200 35%, transparent); }
.featured-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.fcard { display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); text-decoration: none !important; scroll-snap-align: start; transition: transform .2s, box-shadow .2s; }
.fcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
.fcard-cover { display: grid; place-items: center; height: 120px; background: radial-gradient(circle at 80% 10%, color-mix(in srgb, var(--fc) 55%, #fff), var(--fc) 70%); color: rgba(255, 255, 255, .9); background-size: cover; background-position: center; }
.fcard-cover .ic { width: 42px; height: 42px; stroke-width: 1.4; }
.fcard-cover.has-img { background-color: var(--surface-2); }
.fcard-body { display: grid; gap: 8px; padding: 12px 14px 14px; flex: 1; align-content: start; }
.fcard-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); min-width: 0; }
.fcard-title { font-weight: 600; font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fcard-foot { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); margin-top: auto; }
.fcard-stat { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
.fcard-stat .ic { width: 14px; height: 14px; }
.t-flag.star { color: #D9A200; }
.tag-star { background: color-mix(in srgb, #D9A200 16%, var(--surface)); border-color: transparent; color: color-mix(in srgb, #D9A200 75%, var(--ink)); }

.t-av { position: relative; }
.t-check { position: absolute; left: -6px; top: -6px; z-index: 2; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: var(--surface); box-shadow: 0 0 0 1px var(--line-2), var(--shadow); opacity: 0; transition: opacity .12s; cursor: pointer; }
.t-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.t-row.selectable:hover .t-check, .t-check:focus-within, .t-row.is-picked .t-check { opacity: 1; }
.t-row.is-picked { background: var(--accent-soft); }
@media (hover: none) { .t-check { opacity: 1; } }
.mass-bar { position: sticky; bottom: 16px; z-index: 40; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: fit-content; max-width: calc(100% - 24px); margin: 16px auto 0; padding: 10px 12px 10px 18px; border-radius: 16px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow-pop); animation: toast-in .2s ease-out; }
.mass-bar[hidden] { display: none; }
.mass-count b { font: 600 17px var(--f-display); color: var(--marker); }
.mass-bar select { height: 36px; padding: 0 10px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, .12); color: inherit; font: inherit; font-size: 14px; }
.mass-bar select option { color: var(--ink); background: var(--surface); }
.mass-bar .btn-ghost { background: transparent; color: inherit; border-color: rgba(255, 255, 255, .25); }
.mass-bar .btn-ghost:hover { background: rgba(255, 255, 255, .1); }

.custom-page { max-width: 880px; margin: 0 auto; padding: 32px 36px 40px; }
.cp-head { display: flex; align-items: center; gap: 14px; padding-bottom: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.cp-head h1 { font-size: clamp(24px, 3vw, 32px); line-height: 1.15; }
.cp-head > a { margin-left: auto; }

.table-wrap { overflow-x: auto; margin: 1em 0; border: 1px solid var(--line); border-radius: 12px; }
.md-table { width: 100%; border-collapse: collapse; font-size: .94em; }
.md-table th, .md-table td { padding: 9px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md-table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.md-table tr:last-child td { border-bottom: 0; }
.md-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.md-table td[align="center"], .md-table th[align="center"] { text-align: center; }
.md-table td[align="right"], .md-table th[align="right"] { text-align: right; font-variant-numeric: tabular-nums; }

/* Подсветка кода */
.code-block { position: relative; }
.code-copy { position: absolute; top: 8px; right: 8px; padding: 4px 10px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 8px; background: rgba(255, 255, 255, .06); color: var(--pre-ink); font: 500 12px var(--f-body); cursor: pointer; opacity: 0; transition: opacity .15s, background .15s; }
.code-block:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { background: rgba(255, 255, 255, .14); }
.code-copy.ok { color: #7ee2b0; border-color: rgba(126, 226, 176, .4); opacity: 1; }
@media (hover: none) { .code-copy { opacity: 1; } }
.code-block .code-lang + pre { padding-top: 30px; }
.tk-k { color: #C792EA; font-weight: 500; }
.tk-s { color: #C3E88D; }
.tk-c { color: #7A84B5; font-style: italic; }
.tk-n { color: #F78C6C; }
.tk-f { color: #82AAFF; }

/* Полоска чтения и «наверх» */
.read-progress { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 120; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 50%, var(--marker))); transform-origin: left; transform: scaleX(0); transition: transform .1s linear; }
.to-top { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); cursor: pointer; transition: transform .2s, background .15s; animation: toast-in .2s ease-out; }
.to-top:hover { transform: translateY(-3px); background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.to-top[hidden] { display: none; }
.toast-zone { bottom: 76px; }
.foot-link { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.foot-link:hover { color: var(--ink); text-decoration: underline; }
.foot-link[hidden] { display: none; }
.ed-hint { color: var(--ink-3); }
.search-btn { display: none; }
.main-nav a { white-space: nowrap; padding: 8px 11px; }
.brand { flex: none; }
.head-search { flex: 1 1 200px; min-width: 120px; }
@media (min-width: 1360px) { :root { --wrap: 1260px; } }
@media (max-width: 1300px) and (min-width: 901px) {
  .head-row { gap: 14px; }
  .main-nav a { padding: 8px 9px; }
  .head-search { display: none; }
  .search-btn { display: inline-grid; }
  .head-actions { margin-left: auto; }
}
@media (max-width: 900px) { .search-btn { display: inline-grid; } }

/* ==========================================================================
   Админка: аналитика
   ========================================================================== */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { display: grid; gap: 2px; padding: 18px 20px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.kpi-label { font-size: 13px; color: var(--ink-3); }
.kpi-value { font: 600 30px/1.15 var(--f-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12.5px; color: var(--ink-2); }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.stats-grid > .card { margin: 0; }
.stats-grid > .wide { grid-column: 1 / -1; }
.chart-card .card-head { flex-wrap: wrap; }

.vchart { --bar: var(--viz-1); position: relative; height: 200px; margin: 6px 0 4px 34px; }
.vchart[data-tone="ok"] { --bar: var(--viz-2); }
.vchart[data-tone="violet"] { --bar: var(--viz-3); }
.vchart-grid { position: absolute; inset: 0 0 22px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.vchart-grid span { position: relative; border-top: 1px dashed var(--line); height: 0; }
.vchart-grid span:last-child { border-top: 1px solid var(--line-2); }
.vchart-grid i { position: absolute; right: calc(100% + 8px); top: -8px; font: 500 11px var(--f-body); font-style: normal; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.vchart-bars { position: absolute; inset: 0; display: flex; align-items: stretch; gap: 2px; padding-bottom: 22px; }
.vbar-col { position: relative; flex: 1; display: flex; align-items: flex-end; justify-content: center; border-radius: 4px; cursor: default; outline: none; }
.vbar-col:hover, .vbar-col:focus-visible { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.vbar { display: block; width: min(100%, 22px); height: var(--h); min-height: 0; border-radius: 4px 4px 0 0; background: var(--bar); transition: filter .15s; }
.vbar-col:hover .vbar, .vbar-col:focus-visible .vbar { filter: brightness(1.12) saturate(1.1); }
.vbar-x { position: absolute; top: calc(100% + 5px); left: 50%; transform: translateX(-50%); font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.vbar-col[data-tip]:hover::after, .vbar-col[data-tip]:focus-visible::after { bottom: calc(var(--h, 0%) + 30px); }
.data-table { margin-top: 26px; font-size: 13px; }
.data-table summary { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); cursor: pointer; }
.data-table summary .ic { width: 15px; height: 15px; }
.data-table table { margin-top: 10px; max-height: 260px; }
.data-table[open] table { display: block; max-height: 260px; overflow-y: auto; }

.heat { display: grid; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat-hours, .heat-row { display: grid; grid-template-columns: 30px repeat(24, minmax(14px, 1fr)); gap: 3px; align-items: center; min-width: 520px; }
.heat-hours span { font-size: 10.5px; color: var(--ink-3); text-align: left; }
.heat-day { font-size: 12px; color: var(--ink-2); }
.heat-cell { display: block; height: 22px; border-radius: 4px; background: color-mix(in srgb, var(--viz-1) calc(var(--k) * 100%), var(--surface-2)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 4%, transparent); outline: none; }
.heat-cell[data-tip]:hover, .heat-cell[data-tip]:focus-visible { box-shadow: 0 0 0 2px var(--ink); position: relative; z-index: 2; }
.heat-legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 10px; font-size: 11.5px; color: var(--ink-3); }
.heat-legend .heat-cell { width: 16px; height: 12px; }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hbars li { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13.5px; border-radius: 8px; outline: none; }
.hbars li:hover .hbar span, .hbars li:focus-visible .hbar span { filter: brightness(1.12); }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.hbar { height: 12px; border-radius: 0 4px 4px 0; background: var(--surface-2); overflow: hidden; }
.hbar span { display: block; height: 100%; width: var(--w); border-radius: 0 4px 4px 0; background: var(--viz-1); }
.hbars b { font-variant-numeric: tabular-nums; min-width: 32px; text-align: right; }

/* Файлы */
.storage-bar { display: flex; gap: 2px; height: 14px; border-radius: 99px; overflow: hidden; background: var(--surface-2); margin: 4px 0 12px; }
.storage-bar span { width: var(--w); min-width: 3px; background: var(--c); }
.storage-bar span:first-child { border-radius: 99px 0 0 99px; }
.storage-legend { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--ink-2); }
.storage-legend li { display: inline-flex; align-items: center; gap: 6px; }
.storage-legend b { color: var(--ink); font-weight: 600; margin-left: 2px; }
.storage-legend .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.files-table td { vertical-align: middle; }
.file-cell { display: flex; align-items: center; gap: 10px; color: var(--ink); max-width: 360px; }
.file-cell img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }
.file-cell .ftile { width: 36px; height: 44px; }
.file-cell .ftile .ic { width: 36px; height: 44px; }
.file-cell span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.actions-col { width: 1%; white-space: nowrap; }

/* Награды */
.award-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.award-grid > .card { margin: 0; }
.award-admin { display: flex; gap: 16px; align-items: flex-start; }
.award-admin-main { flex: 1; min-width: 0; }
.award-admin-main p { margin: 2px 0 10px; }
.award-admin { flex-wrap: wrap; }
.award-admin .row-actions { width: 100%; justify-content: flex-end; padding-top: 12px; border-top: 1px solid var(--line); }
.award-preview { display: flex; align-items: center; gap: 16px; padding: 16px; margin-bottom: 18px; border-radius: 16px; background: var(--surface-2); border: 1px dashed var(--line-2); }
.award-preview b { font: 600 17px var(--f-display); }
.award-preview p { margin: 2px 0 0; }
.grant-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.grant-form .btn { justify-self: start; }
.grant-form .field { margin: 0; }

/* ==========================================================================
   Адаптивность
   ========================================================================== */

@media (max-width: 1180px) {
  .chat { grid-template-columns: 220px minmax(0, 1fr); }
  .chat-side { display: none; }
}
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
  .hk-list { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 120px); border-radius: 14px; }
  .chat-rooms { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-rooms-head { display: none; }
  .chat-rooms nav { display: flex; overflow-x: auto; padding: 8px; gap: 6px; scrollbar-width: none; }
  .room-link { flex: none; padding: 6px 12px 6px 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; }
  .room-link.on { border-color: var(--accent); box-shadow: none; }
  .room-link.on::before { display: none; }
  .room-txt small, .room-flag { display: none; }
  .room-ic { width: 28px; height: 28px; border-radius: 50%; }
  .room-ic .ic { width: 15px; height: 15px; }
  .chat-head { padding: 10px 12px; }
  .chat-head .room-ic.lg { display: none; }
  .chat-flags { display: none; }
  .thread { padding: 12px 10px 8px; }
  .msg { max-width: 90%; }
  .msg-tools { top: -30px; }
  .cmp-send span, .cmp-hint { display: none; }
  .cmp-send { width: 44px; padding: 0; justify-content: center; }
  .cmp-emoji { right: 8px; grid-template-columns: repeat(7, 34px); }
  .composer { padding: 8px 8px 6px; }
  .lb-stage { padding: 0 8px; }
  .lb-nav { display: none; }
  .lb-top { padding: 8px 10px; gap: 8px; }
  .lb-btn { width: 38px; height: 38px; }
  .palette { padding-top: 10px; }
  .palette-box { max-height: 86vh; }
  .palette-foot { display: none; }
  .podium { gap: 8px; }
  .place-1 .podium-av .av { width: 84px; height: 84px; font-size: 28px; }
  .podium-av .av-xl { width: 64px; height: 64px; font-size: 22px; }
  .place-1 .podium-step { height: 110px; }
  .place-2 .podium-step { height: 80px; }
  .place-3 .podium-step { height: 60px; }
  .podium-name { font-size: 14px; }
  .top-list li { grid-template-columns: 26px auto minmax(0, 1fr) auto; }
  .top-bar { display: none; }
  .top-score { min-width: 0; }
  .feed::before { left: 25px; }
  .custom-page { padding: 22px 18px 28px; }
  .award-admin { flex-wrap: wrap; }
  .pm-settings { width: min(320px, calc(100vw - 32px)); }
  .head-search kbd { display: none; }
  .wall-form > .av { display: none; }
  .to-top { right: 14px; bottom: 14px; width: 42px; height: 42px; }
  .vchart { margin-left: 28px; height: 170px; }
}
@media (prefers-reduced-motion: reduce) {
  .msg.new, .att-chip.just, .palette-box, .lightbox, .thread-new, .to-top, .mass-bar { animation: none !important; }
  .att-img img, .fcard, .podium-av, .lb-stage img { transition: none !important; }
}
@media (forced-colors: active) {
  .vbar, .hbar span, .top-bar span, .heat-cell, .storage-bar span { forced-color-adjust: none; }
}
.card-head h2 > .ic:first-child { margin-right: 8px; vertical-align: -3px; color: var(--accent); }
.code-block .code-lang ~ .code-copy { right: 52px; }
.head-search input { padding-right: 64px; }
