/* Вид площадки: устройство из BH+, цвета клубные. Тёмная тема основная,
   светлая — кнопкой в шапке. */

:root {
    --bg: #131416;
    --surface: #1b1e22;
    --head: #22272d;
    --line: #2e343b;
    --text: #e9edf1;
    --muted: #8d97a1;
    --red: #e11d34;
    --green: #5cc46b;
    --mark: #e11d34;
    --field: #1b1e22;
    --dim: #8d97a1;
    --radius: 9px;
}

/* Тёмная — основная, как в макете. Светлая включается кнопкой и живёт в куке. */
:root[data-theme="light"] {
    --bg: #eef1f4;
    --surface: #ffffff;
    --head: #e3e8ed;
    --line: #ccd4dc;
    --text: #10151a;
    --muted: #5b6975;
    --red: #c1122b;
    --mark: #c1122b;
    --field: #ffffff;
    --dim: #5b6975;
}

/* Тема «БХ»: палитра старой гостевой, снятая из BH+ — пергамент на тёмно-сером.
   Нужна тем, кому привычнее прежний вид; переезжать так легче. */
:root[data-theme="bh"] {
    --bg: #282828;
    --surface: #efd6c0;
    --head: #dfbea3;
    --line: #8c715e;
    --text: #17110e;
    --muted: #6d564a;
    --red: #8d1a24;
    --green: #2f7a3f;
    --mark: #d79b00;
    --field: #f6e6d6;
    --dim: #b09a86;
    --radius: 8px;
}
* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 "Golos Text", "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- шапка ---------- */

.top {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--head);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    text-decoration: none;
}

.nav { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.nav .me { color: var(--muted); }

.nav button,
.composer button,
.auth button {
    font: inherit;
    font-size: 14px;
    color: #fff;
    background: var(--red);
    border: 0;
    border-radius: 5px;
    padding: 7px 14px;
    cursor: pointer;
}

.nav form { margin: 0; }

/* ---------- полотно ---------- */

.wrap {
    max-width: 760px;
    margin: 0 auto;
    padding-inline: 12px;
    padding-block: 16px 40px;
}

/* ---------- окно отправки ---------- */

.composer {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 14px;
}

.composer textarea {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    resize: vertical;
}

.composer-send {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.composer .hint,
.auth .hint { color: var(--muted); font-size: 13px; }

.composer.guest { color: var(--muted); }
.composer.guest p { margin: 0; }
.composer.guest a { color: var(--red); }

/* ---------- лента ---------- */

.feed { display: flex; flex-direction: column; gap: 8px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-head {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 9px;
    padding: 8px 11px;
    background: var(--head);
    border-bottom: 1px solid var(--line);
}

.jersey {
    grid-row: span 2;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 5px;
    background: var(--red);
    color: #fff;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.jersey.plain { background: transparent; border: 1px solid var(--line); color: var(--muted); }

.name { font-weight: 600; }
.sub { grid-column: 2; font-size: 12px; color: var(--muted); }

.rate {
    grid-row: span 2;
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    color: var(--muted);
}

.rate.up { color: var(--green); }
.rate.down { color: var(--red); }

.card-body { padding: 10px 12px; overflow-wrap: anywhere; }
.card-body p { margin: 0 0 8px; }
.card-body p:last-child { margin-bottom: 0; }
.card-body a { color: var(--red); }

.card-tools {
    display: flex;
    gap: 14px;
    padding: 0 12px 10px;
    font-size: 12px;
    color: var(--muted);
}

.card-tools a { text-decoration: none; }

/* ---------- пусто и служебное ---------- */

.empty,
.note,
.auth {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 18px;
}

.empty h2, .note h2, .auth h2 { margin: 0 0 8px; font-size: 19px; }
.empty p, .note p { margin: 0; color: var(--muted); }

.auth { display: flex; flex-direction: column; gap: 26px; }
.auth section { display: flex; flex-direction: column; gap: 10px; }
.auth form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.auth label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; width: 100%; max-width: 320px; }

.auth input {
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
}

.auth .error {
    margin: 0;
    color: #fff;
    background: var(--red);
    border-radius: 6px;
    padding: 9px 12px;
}

/* ---------- страницы ---------- */

.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
    font-size: 14px;
}

.pager a, .pager .here, .pager .gap {
    min-width: 32px;
    text-align: center;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    text-decoration: none;
}

.pager .here { background: var(--red); color: #fff; border-color: var(--red); }
.pager .gap { border-color: transparent; color: var(--muted); }

.foot {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 12px 30px;
    color: var(--dim);
    font-size: 13px;
}

:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }

/* ---------- разметка внутри сообщения ---------- */

.card-body blockquote {
    margin: 8px 0;
    padding: 6px 12px;
    border-left: 3px solid var(--red);
    background: color-mix(in srgb, var(--head) 70%, transparent);
    border-radius: 0 6px 6px 0;
}

.card-body blockquote cite {
    display: block;
    font-style: normal;
    font-weight: 600;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 2px;
}

.card-body hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 10px 0;
}

.card-body .inline-pic {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin-top: 6px;
}

/* ---------- вложения ---------- */

.shots {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.shots.many { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.shot { display: block; }

.shot img {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.shots.one .shot img { object-fit: contain; max-height: 520px; max-width: 640px; }

/* ---------- выбор картинок ---------- */

.composer.over { outline: 2px dashed var(--red); outline-offset: 3px; }

.picked {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.chip {
    font-size: 12px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 3px 10px;
}

.chip-clear {
    font: inherit;
    font-size: 12px;
    color: var(--red);
    background: none;
    border: 0;
    cursor: pointer;
    padding: 3px 6px;
}

.pick { cursor: pointer; }
.pick input { position: absolute; left: -9999px; }

.pick span {
    display: inline-block;
    font-size: 14px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 6px 12px;
}

.pick span:hover { color: var(--text); }

/* ---------- сообщение сверху ---------- */

.notice {
    background: var(--surface);
    border: 1px solid var(--red);
    border-left-width: 3px;
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 12px;
}

/* ---------- оценка кнопками ---------- */

.rate-box {
    grid-row: span 2;
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.vote {
    font: inherit;
    font-size: 12px;
    line-height: 1;
    color: var(--muted);
    background: none;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 4px 6px;
    cursor: pointer;
}

.vote:hover { color: var(--text); }
.vote.up.on { color: #fff; background: var(--green); border-color: var(--green); }
.vote.down.on { color: #fff; background: var(--red); border-color: var(--red); }

/* ---------- ответы ---------- */

.answering, .answering-to {
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 6px;
}

.answering-to {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-bottom: 9px;
}

.answering-to .drop { color: var(--red); }

.card-tools a { text-decoration: none; }
.card-tools a:hover { color: var(--text); }
.card-tools .danger { color: var(--red); }

/* ---------- панели (правка, удаление, настройки, управление) ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 18px 20px;
    margin-bottom: 14px;
}

.panel h2 { margin: 0 0 10px; font-size: 19px; }
.panel .hint { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; }

.panel form { display: flex; flex-direction: column; gap: 10px; }

.panel label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    max-width: 340px;
}

.panel input, .panel textarea, .panel select {
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
}

.panel textarea { width: 100%; resize: vertical; }

.panel .row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.panel button {
    font: inherit;
    font-size: 14px;
    color: #fff;
    background: var(--red);
    border: 0;
    border-radius: 5px;
    padding: 8px 16px;
    cursor: pointer;
}

.panel .quiet { color: var(--muted); font-size: 14px; }

.panel .error {
    margin: 0 0 10px;
    color: #fff;
    background: var(--red);
    border-radius: 6px;
    padding: 9px 12px;
}

.panel .preview {
    border-left: 3px solid var(--line);
    padding: 4px 12px;
    margin-bottom: 12px;
    color: var(--muted);
}

/* ---------- таблица людей ---------- */

.scroll { overflow-x: auto; }

.people { width: 100%; border-collapse: collapse; font-size: 14px; }
.people th, .people td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.people th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.people .num { font-variant-numeric: tabular-nums; }

.people form.inline {
    display: inline-flex;
    flex-direction: row;
    gap: 5px;
    align-items: center;
    margin-right: 8px;
}

.people .tiny { width: 58px; padding: 5px 7px; }
.people button { padding: 5px 10px; font-size: 13px; }
.people select { padding: 5px 7px; }

/* ---------- панель разметки ---------- */

.markup-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.markup-bar .mk-btn {
    font: inherit;
    font-size: 13.5px;
    line-height: 1;
    min-width: 32px;
    color: var(--muted);
    background: none;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 6px 9px;
    cursor: pointer;
}

.markup-bar .mk-btn:hover { color: var(--text); border-color: var(--muted); }
.mk-b { font-weight: 700; }
.mk-i { font-style: italic; }
.mk-u { text-decoration: underline; }
.mk-s { text-decoration: line-through; }

/* ---------- поиск в шапке ---------- */

.find { margin: 0 auto 0 24px; flex: 1; max-width: 280px; }

.find input {
    width: 100%;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 6px 12px;
}

.card.found mark {
    background: color-mix(in srgb, var(--red) 35%, transparent);
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

/* ---------- непрочитанное ---------- */

.card.unread { box-shadow: inset 3px 0 0 var(--mark); }

.card.unread .sub::before {
    content: 'новое · ';
    color: var(--mark);
    font-weight: 600;
}

/* ---------- кнопка «новых N» ---------- */

.fresh {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 18px;
    z-index: 20;
    font: inherit;
    font-size: 14px;
    color: #fff;
    background: var(--red);
    border: 0;
    border-radius: 20px;
    padding: 10px 20px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
    cursor: pointer;
}

/* ---------- страница человека ---------- */

.person-head { display: flex; align-items: center; gap: 14px; }
.person-head h2 { margin: 0 0 2px; }
.person-head .hint { margin: 0; }

.jersey.big {
    width: 54px;
    height: 54px;
    border-radius: 8px;
    font-size: 22px;
}

.panel .about { margin: 12px 0 0; }
.panel.slim { padding: 14px 18px; margin-bottom: 10px; }
.panel.slim h2 { margin: 0 0 2px; font-size: 17px; }

.name a { text-decoration: none; }
.name a:hover { text-decoration: underline; }

@media (max-width: 560px) {
    .find { margin-left: 12px; max-width: 150px; }
}

/* ---------- переключатель темы ---------- */

.nav .theme {
    font-size: 15px;
    line-height: 1;
    color: var(--muted);
    background: none;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 6px 9px;
}

.nav .theme:hover { color: var(--text); }

/* ---------- чат: полоса и панель ---------- */

.chat-strip {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: min(420px, calc(100vw - 28px));
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 8px 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
    font-size: 13px;
    cursor: pointer;
}

.chat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line);
    flex: none;
}

.chat-dot.lit { background: var(--green); }

.chat-last {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-count { color: var(--text); white-space: nowrap; font-weight: 600; }

.chat-panel {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 26;
    display: flex;
    flex-direction: column;
    width: min(360px, calc(100vw - 28px));
    height: min(460px, calc(100vh - 90px));
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    overflow: hidden;
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--head);
    border-bottom: 1px solid var(--line);
}

.chat-online { color: var(--muted); font-size: 12.5px; margin-right: auto; }

.chat-close {
    font: inherit;
    font-size: 20px;
    line-height: 1;
    color: var(--muted);
    background: none;
    border: 0;
    cursor: pointer;
    padding: 0 4px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 13.5px;
}

.chat-line { display: grid; grid-template-columns: 38px auto 1fr; gap: 6px; }
.chat-line time { color: var(--muted); font-size: 11.5px; padding-top: 2px; }
.chat-line b { color: var(--red); font-weight: 600; white-space: nowrap; }
.chat-line span { overflow-wrap: anywhere; }

.chat-form {
    display: flex;
    gap: 6px;
    padding: 9px 10px;
    border-top: 1px solid var(--line);
}

.chat-form input {
    flex: 1;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 7px 12px;
}

.chat-form button {
    font: inherit;
    color: #fff;
    background: var(--red);
    border: 0;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
}

.chat-form button:disabled, .chat-form input:disabled { opacity: .5; }

/* Кнопка «новых» не должна налезать на чат. */
.fresh { bottom: 68px; }

@media (max-width: 560px) {
    .chat-panel { right: 0; bottom: 0; width: 100vw; height: 100vh; border-radius: 0; }
    .chat-strip { right: 8px; left: 8px; max-width: none; }
}

/* `hidden` не побеждает display:flex — прятать надо правилом той же силы.
   Ровно на этом уже обжигались в BH+. */
.chat-panel[hidden], .chat-strip[hidden], .fresh[hidden] { display: none !important; }
