/* ===========================================================
   TeaRPG messenger — theme tokens
   =========================================================== */
:root {
  --bg-0: #0c0c0f;
  --bg-1: #17171b;
  --bg-2: #1f1f24;
  --bg-3: #29292f;
  --bg-4: #34343c;
  --border: #2c2c33;
  --text-0: #f2f2f5;
  --text-1: #c7c7d1;
  --text-2: #8b8b98;
  --text-3: #5f5f6c;
  /* Вся акцентная палитра выводится из одного --accent через color-mix: чтобы добавить
     цвет, достаточно переопределить --accent в блоке [data-accent] ниже. Ссылки на
     переменные подставляются лениво, поэтому производные пересчитываются сами. */
  --accent: #7c5cff;
  --accent-hover: color-mix(in srgb, var(--accent) 82%, white);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --on-accent: #ffffff;
  --danger: #e6485f;
  --danger-soft: rgba(230, 72, 95, 0.14);
  --success: #1ecb8f;
  --success-soft: rgba(30, 203, 143, 0.14);
  --warn: #f0a63a;
  /* Цвет своих сообщений тоже завязан на акцент — смена акцента перекрашивает чат.
     35% чёрного, а не 10% — так белый текст поверх (--on-accent) держит контраст
     не только на тёмных акцентах вроде фиолетового, но и на светлых вроде
     оранжевого: 90/10 давал там 2.8:1 при нужных для белого текста 4.5, а
     65/35 — не ниже 5.2:1 на каждом из семи цветов акцента. */
  --bubble-mine: color-mix(in srgb, var(--accent) 65%, black);
  --bubble-mine-2: color-mix(in srgb, var(--accent) 65%, black);
  --bubble-other: #24242b;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.5);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-0: #eef0f4;
  --bg-1: #ffffff;
  --bg-2: #f4f5f8;
  --bg-3: #e9eaf0;
  --bg-4: #dcdde6;
  --border: #dfe1e8;
  --text-0: #1a1b22;
  --text-1: #43444e;
  --text-2: #7a7b87;
  --text-3: #9c9da8;
  --bubble-other: #eef0f4;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  [data-theme="auto"] {
    --bg-0: #eef0f4;
    --bg-1: #ffffff;
    --bg-2: #f4f5f8;
    --bg-3: #e9eaf0;
    --bg-4: #dcdde6;
    --border: #dfe1e8;
    --text-0: #1a1b22;
    --text-1: #43444e;
    --text-2: #7a7b87;
    --text-3: #9c9da8;
    --bubble-other: #eef0f4;
    color-scheme: light;
  }
}


/* ---- Акцентные цвета. --on-accent — цвет текста поверх акцента: везде белый,
   у белого акцента ниже — единственное исключение. Раньше на светлых акцентах
   (оранжевый и похожие) белый читался плохо (2.4–3.8:1 при нужных 4.5) — но
   вместо того чтобы менять цвет текста по акценту, затемнили саму подложку
   своих сообщений (--bubble-mine ниже, 35% чёрного вместо 10) — так на любом
   акценте держится один и тот же белый текст, с запасом 5.2:1 и выше. */
[data-accent="purple"] { --accent: #7c5cff; }
[data-accent="blue"]   { --accent: #3b82f6; }
[data-accent="cyan"]   { --accent: #06b6d4; }
[data-accent="green"]  { --accent: #10b981; }
[data-accent="orange"] { --accent: #f97316; }
[data-accent="red"]    { --accent: #ef4444; }
[data-accent="pink"]   { --accent: #ec4899; }
[data-accent="white"]  {
  --accent: #e8e8ef;
  --accent-hover: color-mix(in srgb, var(--accent) 88%, black);
  --on-accent: #17171b;
  --bubble-mine: #d9d9e3;
  --bubble-mine-2: #b9b9c6;
}
/* Белый акцент на светлой теме сливается с фоном — уводим его в графитовый.
   Для «системной» темы это верно только когда система реально светлая, иначе
   тёмная системная тема получила бы графит вместо белого. */
[data-theme="light"][data-accent="white"] {
  --accent: #3a3a44;
  --accent-hover: color-mix(in srgb, var(--accent) 82%, white);
  --on-accent: #ffffff;
  --bubble-mine: #3a3a44;
  --bubble-mine-2: #26262e;
}
@media (prefers-color-scheme: light) {
  [data-theme="auto"][data-accent="white"] {
    --accent: #3a3a44;
    --accent-hover: color-mix(in srgb, var(--accent) 82%, white);
    --on-accent: #ffffff;
    --bubble-mine: #3a3a44;
    --bubble-mine-2: #26262e;
  }
  [data-theme="auto"] .accent-swatch[data-accent-id="white"] { background: #3a3a44; --on-swatch: #fff; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  overflow: hidden;
}
/* Выделение текста своим цветом — иначе браузер берёт системный по умолчанию,
   а на части устройств (жалоба игрока: чёрный сплошной блок при выделении
   текста листа персонажа) он рисуется совсем не в тон тёмной теме сайта. */
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.center-pad { text-align: center; padding: 24px 12px; }
.center-col { display: flex; flex-direction: column; align-items: center; text-align: center; }
.accent { color: var(--accent); }
.accent-text { color: var(--accent); font-weight: 600; }
.red-text { color: var(--danger); }
.req { color: var(--danger); }
/* !important здесь по делу: .icon-btn объявлен ниже и с той же специфичностью,
   поэтому его display:flex перебивал это правило — кнопки «только для телефона»
   висели и на ПК, где ничего не делали. */
.only-mobile { display: none !important; }

/* ===================== APP LAYOUT ===================== */
.app {
  display: grid;
  grid-template-columns: 72px 320px 1fr;
  /* 100vh on real mobile browsers is the height with the address bar hidden — the page ends
     up taller than what's actually visible, so the bottom (composer, nav) sits below the
     fold behind browser chrome. 100dvh tracks the real visible viewport; older browsers that
     don't understand it just keep the 100vh above. */
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}
.app:has(#charpanel:not([hidden])) {
  grid-template-columns: 72px 320px 1fr 320px;
}

/* ------ rail ------ */
.rail {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 8px;
}
.rail-logo { width: 40px; height: 40px; color: var(--accent); margin-bottom: 10px; cursor: pointer; }
.rail-logo:hover { filter: brightness(1.08); }
.rail-logo:active { transform: scale(.94); }
.rail-logo svg { width: 100%; height: 100%; }
.rail-btn {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: transparent; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.rail-btn:hover { background: var(--bg-3); color: var(--text-0); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }
.rail-btn-bottom { margin-top: auto; }
.rail-question { font-size: 16px; font-weight: 800; }
.rail-avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid transparent;
  padding: 0; overflow: hidden; margin-top: 8px; background: var(--bg-3);
}
.rail-avatar:hover { border-color: var(--accent); }
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ------ sidebar (chat list) ------ */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-head { padding: 16px 16px 4px; }
.brand { font-weight: 700; font-size: 14px; letter-spacing: .2px; }
.sidebar-search { display: flex; gap: 8px; padding: 10px 16px; }
.search-input {
  /* min-width:0 обязателен: без него flex-элемент не сжимается меньше своего содержимого,
     и соседние кнопки в строке поиска выдавливаются за край панели. */
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 10px; height: 38px;
}
.search-input svg { width: 16px; height: 16px; color: var(--text-2); flex-shrink: 0; }
.search-input input {
  flex: 1; background: transparent; border: none; outline: none; color: var(--text-0); font-size: 14px;
}
.search-input input::placeholder { color: var(--text-3); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text-1); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text-0); }
.icon-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.small { width: 26px; height: 26px; border: none; background: transparent; font-size: 13px; }

.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.chat-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 12px;
  cursor: pointer; position: relative;
}
.chat-item:hover { background: var(--bg-2); }
.chat-item.active { background: var(--accent-soft); }
.chat-item img { width: 46px; height: 46px; border-radius: 14px; object-fit: cover; background: var(--bg-3); flex-shrink: 0; }
.chat-item-body { flex: 1; min-width: 0; padding-right: 28px; }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.chat-item-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-sub { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.chat-item-sub b { color: var(--text-1); font-weight: 600; }
.chat-item-archive-ic { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.chat-item-archive-btn {
  position: absolute; right: 8px; bottom: 8px; width: 26px; height: 26px; border-radius: 8px;
  border: none; background: var(--bg-4); color: var(--text-1); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .12s; flex-shrink: 0;
}
.chat-item-archive-btn svg { width: 14px; height: 14px; }
.chat-item-archive-btn:hover { background: var(--danger); color: white; }
.chat-item:hover .chat-item-archive-btn { opacity: 1; }
.chat-empty-list { text-align: center; color: var(--text-3); padding: 30px 10px; font-size: 13px; }
/* счётчик непрочитанных справа от чата */
.unread-badge {
  align-self: center; flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 11.5px; font-weight: 800; line-height: 20px; text-align: center;
}
.chat-item:hover .chat-item-archive-btn { opacity: 1; }
.chat-item:hover .unread-badge { display: none; }

/* ===================== MAIN ===================== */
.main { position: relative; overflow: hidden; background: var(--bg-0); }
.view { height: 100%; display: flex; flex-direction: column; }

/* ---- home ---- */
/* width:100% здесь обязателен вместе с margin:0 auto. Авто-поля по поперечной оси
   отменяют растягивание flex-элемента (align-items:stretch перестаёт действовать),
   и ширина начинает подбираться по содержимому. А в содержимом — лента карточек:
   две штуки по 236px давали 486px при доступных 348, главная вылезала за экран и
   правую половину срезал overflow:hidden у .main. С одной карточкой всё сходилось,
   поэтому ошибка и не ловилась на тесте. Явная ширина возвращает элементу размер
   родителя, max-width по-прежнему держит колонку узкой на больших экранах, а лента
   карточек прокручивается внутри себя, как и задумано. */
.home-scroll { overflow-y: auto; height: 100%; padding: 40px 48px 60px; width: 100%; max-width: 780px; margin: 0 auto; }
.home-hero { text-align: center; padding: 20px 0 36px; }
.home-hero-icon { width: 64px; height: 64px; margin: 0 auto 18px; color: var(--accent); }
.home-hero h1 { font-size: 26px; margin: 0 0 10px; }
.home-hero p { margin: 0 0 20px; }
.section-title { font-size: 19px; margin: 30px 0 4px; }
.card-row { display: flex; gap: 14px; overflow-x: auto; padding: 14px 2px; }
/* Ширина карточки задана жёстко (flex: 0 0), а не «по содержимому». С auto-шириной
   и запретом сжиматься карточка раздувалась до самой длинной строки описания:
   у ленты обрезка по двум строкам только прячет лишнее, а на внутреннюю ширину
   не влияет — одна кампания с длинным описанием растягивалась во весь экран. */
.mini-campaign-card {
  flex: 0 0 240px; max-width: 240px;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 12px; cursor: pointer;
}
.mini-campaign-card:hover { border-color: var(--accent); }
.mini-campaign-card .mcc-cover {
  height: 90px; border-radius: 10px; margin-bottom: 8px; background-color: var(--bg-3);
  background-size: cover; background-position: center; background-repeat: no-repeat;
  display:flex;align-items:center;justify-content:center;font-size:28px;
}
/* Ленту карточек на главной листают вбок, карточки стоят рядом и одной ширины.
   Длинное название разворачивало одну из них на три строки, и ряд получался
   рваным — держим две, дальше многоточие. */
.mcc-title {
  font-weight: 600; font-size: 14px; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mcc-desc { font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tip-row { display: flex; gap: 14px; flex-wrap: wrap; padding: 10px 0; }
.tip-card {
  flex: 1; min-width: 220px; background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 16px; cursor: pointer;
}
.tip-card:hover { border-color: var(--accent); }
.tip-badge { display: inline-block; background: var(--warn); color: #241a04; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-bottom: 10px; }
.tip-title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.tip-desc { font-size: 13px; color: var(--text-2); }

/* ---- chat header ---- */
.chat-header {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-1); flex-shrink: 0;
}
.chat-header-avatar { width: 38px; height: 38px; border-radius: 12px; object-fit: cover; background: var(--bg-3); }
/* min-width:0 обязателен. Без него флекс-элемент не сжимается меньше самого
   длинного слова в названии, и на узком экране кампания вроде «Альтернативный Я»
   выдавливала кнопки за правый край — карандаш правки обрезался. Заодно название
   держим одной строкой с многоточием: перенос на вторую делал шапку выше и
   съезжал ряд кнопок. */
.chat-header-title {
  font-weight: 700; font-size: 15px; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Кампания, снятую с поиска модератором, в выдаче видит только он сам —
   пометка нужна, чтобы он не принял её за обычное объявление. */
.pcc-badge.blocked { background: var(--danger, #e6485f); color: #fff; }
.chat-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
/* Сколько человек в сети. Приглушённый — это справка, а не действие: рядом
   стоят кнопки, и одинаково заметная подпись спорила бы с ними за внимание.
   Не сжимается и не переносится: место ей нужно постоянное, иначе кнопки
   ездили бы вбок каждый раз, когда кто-то вошёл или вышел. */
.chat-header-online {
  display: flex; align-items: center; gap: 5px; flex-shrink: 0;
  margin-right: 4px; font-size: 12.5px; color: var(--text-2); white-space: nowrap;
  cursor: default;
}
.chat-header-online i {
  width: 7px; height: 7px; border-radius: 50%; background: #2fbf6b;   /* тот же зелёный, что у кружка «в сети» на аватарке */
  flex-shrink: 0;
}
/* На узком экране от названия кампании и так остаются два слова — цифры хватает,
   слово «в сети» там только отнимало бы у него место. */
@media (max-width: 640px) {
  .chat-header-online b { display: none; }
}

.pinned-banner {
  display: flex; align-items: center; gap: 10px; background: linear-gradient(90deg, #e6485f, #ef6a4c);
  color: white; padding: 10px 16px; font-size: 13.5px; flex-shrink: 0;
}
.pinned-banner { cursor: pointer; }
/* аватарки, открывающие профиль по клику */
img.clickable { cursor: pointer; transition: filter .12s, transform .12s; }
img.clickable:hover { filter: brightness(1.12); transform: scale(1.06); }
.pinned-banner .pin-ic { width: 16px; height: 16px; stroke: white; flex-shrink: 0; }
/* подсветка сообщения после перехода по закрепу */
.msg-highlight { animation: msg-flash 1.6s ease-out; border-radius: var(--radius-m); }
@keyframes msg-flash {
  0%   { background: color-mix(in srgb, var(--accent) 45%, transparent); }
  100% { background: transparent; }
}
/* Длинный закреп режем по трём строкам: полоса не должна съедать пол-экрана
   переписки, а целиком его всё равно читают по нажатию — оно уводит к самому
   сообщению. */
.pinned-text {
  flex: 1; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  overflow: hidden; overflow-wrap: anywhere;
}
.pinned-banner .icon-btn { background: rgba(255,255,255,0.18); border: none; color: white; }
.pinned-banner .pin-collapse svg { width: 16px; height: 16px; transition: transform .18s; }
.pinned-banner .pin-collapse.flip svg { transform: rotate(180deg); }

/* Свёрнутый закреп — тонкая полоса с одной булавкой: он никуда не делся и
   разворачивается нажатием, но перестаёт занимать три строки над разговором.
   Скрываем не display:none, а нулевой шириной с прозрачностью: так переход
   между состояниями остаётся плавным, а не рывком. */
.pinned-banner.collapsed { padding: 3px 16px; gap: 0; }
.pinned-banner.collapsed .pinned-text,
.pinned-banner.collapsed #btn-unpin {
  opacity: 0; flex: 0 0 0; width: 0; min-width: 0; height: 0;
  padding: 0; margin: 0; overflow: hidden; pointer-events: none;
}
.pinned-banner.collapsed .pin-ic { width: 13px; height: 13px; }
.pinned-banner.collapsed .pin-collapse { margin-left: auto; padding: 0 4px; }

.left-banner {
  display: flex; align-items: center; gap: 10px; background: var(--bg-2); border-top: 1px solid var(--border);
  color: var(--text-1); padding: 12px 16px; font-size: 13px; flex-shrink: 0;
}
.left-banner span { flex: 1; }
/* Та же полоса, что и «вы покинули кампанию», но это не беда, а предложение —
   красный градиент здесь пугал бы на ровном месте. */
.push-banner { background: var(--bg-2); border-bottom: 1px solid var(--border); color: var(--text-1); }
.push-banner .btn-sm { flex-shrink: 0; }

/* ---- messages ---- */
.messages { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
/* Системная строка («вступил в кампанию» и т.п.) раньше была голым текстом —
   на плашке своего фона это ещё туда-сюда читалось, а на фоне-картинке терялось
   совсем: не за что зацепиться взглядом. Подложка и рамка держат её видимой
   при любых обоях позади. */
.msg-system {
  align-self: center; max-width: 90%; margin: 4px 0; padding: 4px 14px;
  border-radius: 999px; background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-3); font-size: 12px; text-align: center;
  overflow-wrap: anywhere;
}

/* Кружок выбора обоев в профиле: показывает сам узор, а не плашку — выбирают
   ведь рисунок. Узор подставляется из JS вместе с картинкой варианта. */
.chatbg-swatch { background-color: var(--bg-2); background-size: 96px 96px; }
/* «Без узора» — перечёркнутый пустой круг. Линию берём контрастной: бледная
   на тёмной заливке была почти неразличима и кружок читался как просто пустой. */
.chatbg-swatch[data-bg-id="none"] {
  background-image: linear-gradient(to bottom right, transparent calc(50% - 1.5px), var(--text-1) 50%, transparent calc(50% + 1.5px));
  background-size: auto;
}
/* Свой фон — фотографией на весь кружок, а не плиткой 96px. */
.chatbg-swatch[data-bg-id="custom"] { background-size: cover; background-position: center; }
.chatbg-swatch.chatbg-add { font-size: 20px; color: var(--text-2); }
.chatbg-actions { display: flex; gap: 14px; margin-top: 4px; }
.btn-text.danger { color: var(--danger); }

/* Разделитель даты («Сегодня», «Вчера», число) — той же плашкой, что системные
   строки («вступил в кампанию»): голый текст на фоне-картинке терялся, а рамка
   держит его видимым при любых обоях позади. */
.msg-day-sep {
  align-self: center; max-width: 90%; margin: 14px 0; padding: 4px 14px;
  border-radius: 999px; background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  overflow-wrap: anywhere;
}
.msg-system { text-align: center; color: var(--text-3); font-size: 12px; margin: 10px 0; }
.msg-unread-sep {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0; color: var(--accent); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .5px;
}
.msg-unread-sep::before, .msg-unread-sep::after {
  content: ""; flex: 1; height: 1px; background: var(--accent);
}

/* Промежуток между сообщениями плотнее: на телефоне лента из шести реплик
   занимала экран целиком, а половина места уходила на воздух между ними. */
/* touch-action: pan-y — только вертикальная прокрутка своя, браузерный
   двойной тап-зум на самом сообщении не перехватывает двойное нажатие,
   которым тут отвечают (см. wireDoubleTapReply в app.js). */
.msg-row { display: flex; gap: 8px; max-width: 72%; margin: 3px 0; touch-action: pan-y; }
/* Внутри серии сообщения стоят вплотную: широкий отступ разбивал подряд идущие
   реплики одного человека на отдельные блоки. */
.msg-row.run-cont { margin-top: 0; }
.msg-row.run-goes-on { margin-bottom: 0; }
.msg-row.mine { align-self: flex-end; }
/* Имя и аватарка живут внутри облачка. Раньше аватарка стояла отдельной колонкой
   сбоку: она отнимала по сорок с лишним пикселей у каждого края ленты и в серии
   подряд идущих реплик всё равно пустовала у всех, кроме последней. */
/* Шапка — это подпись говорящего, а не часть реплики, поэтому она отделена:
   своя, более тёмная подложка во всю ширину облачка и линия снизу. Без них имя
   с аватаркой читались как первая строка сообщения.

   Отрицательные поля гасят внутренний отступ облачка (9px 12px), чтобы полоса
   дошла до его краёв; скругление сверху повторяет скругление самого облачка. */
.msg-head {
  display: flex; align-items: center; gap: 7px;
  margin: -9px -12px 7px; padding: 5px 12px;
  background: rgba(0, 0, 0, .22);
  border-bottom: 1px solid rgba(255, 255, 255, .13);
  border-radius: var(--radius-m) var(--radius-m) 0 0;
}
.msg-row.mine .msg-head { flex-direction: row-reverse; }
/* На светлой теме чёрная вуаль почти не видна — там затемняем сильнее. */
[data-theme="light"] .msg-row:not(.mine) .msg-head { background: rgba(0, 0, 0, .07); border-bottom-color: rgba(0, 0, 0, .12); }
.msg-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; background: var(--bg-3); flex-shrink: 0; }
/* Время с галочкой стоит СБОКУ от облачка, у внешнего края ленты, а не строкой
   под ним: отдельная строка снизу добавляла каждому сообщению лишнюю высоту и
   разрывала подряд идущие реплики. */
.msg-col { display: flex; align-items: flex-end; gap: 6px; min-width: 0; }
.msg-row.mine .msg-col { flex-direction: row-reverse; }
.msg-col > .msg-bubble { min-width: 0; }
/* Имя внутри облачка стоит на цветной подложке, поэтому берёт цвет от неё, а не
   акцентный: на своём (фиолетовом) и на подкрашенном под персонажа акцент терялся. */
.msg-author { font-size: 12.5px; font-weight: 700; color: inherit; opacity: .82; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-author.clickable { cursor: pointer; }
.msg-row:not(.mine) .msg-bubble:not(.char-tinted) .msg-author { color: var(--accent-hover); opacity: 1; }
/* color: inherit, а не свой приглушённый серый: шапка сидит ВНУТРИ пузыря
   (bubble.insertBefore), а у пузыря свой цвет текста — свой для чужого
   сообщения, var(--on-accent) для своего, посчитанный под конкретный цвет
   для реплики «в роли» (см. textOn() и char-tinted ниже). Зафиксированный
   серый читался жалобой «время не видно»: на цветной подложке (акцент вроде
   оранжевого, где бланое к тому же ещё не годится само по себе — см. правки
   --on-accent выше) он проваливался в фон почти без контраста. */
.msg-author-player { font-weight: 400; color: inherit; opacity: .72; }
/* Время рядом с ником, тем же рядом, что имя и аватарка (обычный gap: 7px
   шапки саму расстановку уже даёт). flex-shrink:0 — не даёт времени сжаться
   раньше имени: обрезаться при нехватке места должно оно, а не часы. */
.msg-name-time { font-size: 10.5px; font-weight: 400; color: inherit; opacity: .72; flex-shrink: 0; }
.msg-bubble {
  background: var(--bubble-other); color: var(--text-0); padding: 9px 12px; border-radius: var(--radius-m);
  font-size: 14.5px; line-height: 1.42; white-space: pre-wrap; word-break: break-word; position: relative;
}
.msg-row.mine .msg-bubble { background: var(--bubble-mine); color: var(--on-accent); }
.msg-time {
  font-size: 10.5px; color: var(--text-3); display: flex; align-items: center; gap: 4px;
  flex-shrink: 0; padding-bottom: 2px; white-space: nowrap;
}
.msg-check { color: var(--accent); }
.msg-edited { font-style: italic; }
/* Тоже inherit, тем же поводом, что и msg-name-time выше: плашка рисуется
   внутри пузыря, и его собственный, уже правильно посчитанный цвет текста
   читается на любой подложке, а не только на обычном фоне чата. */
.msg-deleted { color: inherit; opacity: .72; font-style: italic; }
.msg-deleted svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.fmt-semibold { font-weight: 600; }
.msg-mention {
  background: rgba(255,255,255,0.16); color: inherit; border-radius: 5px; padding: 0 4px;
  font-weight: 700; cursor: pointer;
}
.msg-mention:hover { background: rgba(255,255,255,0.28); }
.msg-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }

/* Плашка стоит в строке, на месте формулы, а не блоком под текстом:
   display:block отрывал её от той фразы, к которой она относится. */
.roll-chip {
  background: rgba(0,0,0,0.22); border-radius: 8px; padding: 1px 7px; margin: 0 2px;
  display: inline-flex; align-items: baseline; vertical-align: baseline;
  font-size: 13.5px;
}
.roll-chip-clickable { cursor: pointer; }
.roll-chip-clickable:hover { background: rgba(0,0,0,0.34); }
.msg-row.mine .roll-chip-clickable:hover { background: rgba(255,255,255,0.24); }
.msg-row.mine .roll-chip { background: rgba(255,255,255,0.14); }
.roll-chip .dice-ic { margin-right: 4px; }
.roll-chip .roll-expr { opacity: .85; }
.roll-chip .roll-arrow { opacity: .6; margin: 0 3px; }
.roll-chip .roll-result { font-weight: 800; }
.roll-chip.roll-error { color: #ffd0d6; }
.msg-image { max-width: 260px; border-radius: 10px; display: block; margin-top: 4px; }
.msg-bubble.pinned-msg { border: 1px solid var(--warn); }

/* ---- composer ---- */
.composer { border-top: 1px solid var(--border); background: var(--bg-1); padding: 8px 14px 12px; flex-shrink: 0; position: relative; }
.composer-toolbar { display: flex; align-items: center; gap: 2px; padding: 2px 0 6px; }
.tbtn {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent; color: var(--text-2);
  font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.tbtn:hover { background: var(--bg-3); color: var(--text-0); }
.tbtn svg { width: 17px; height: 17px; }
.tsep { color: var(--border); margin: 0 4px; }
.tbtn-send { margin-left: auto; background: var(--accent); color: var(--on-accent); }
.tbtn-send:hover { background: var(--accent-hover); }
.formula-preview {
  display: flex; align-items: center; gap: 6px; font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12.5px; color: var(--accent-hover); background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; margin: 0 0 6px 42px;
}
.formula-preview .fp-error { color: var(--danger); }
.composer-input-row { display: flex; align-items: flex-end; gap: 10px; }
.composer-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--bg-3); flex-shrink: 0; border: 2px solid var(--bg-4); box-sizing: border-box; cursor: pointer; }
.composer-field {
  flex: 1; min-height: 22px; max-height: 160px; overflow-y: auto; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 9px 12px; font-size: 14.5px; outline: none; line-height: 1.4;
  /* pre-wrap обязателен. Поле редактируемое, а не textarea: без этого правила
     перевод строки схлопывается в пробел прямо при вводе — и не только на вид.
     innerText читает то, что нарисовано, поэтому абзацы терялись и при отправке.
     Задевало это и вставку из буфера: скопированный в три абзаца текст
     превращался в одну строку. */
  white-space: pre-wrap; word-break: break-word;
}
.composer-field:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.composer-field:focus { border-color: var(--accent); }

.popover {
  /* Выше .modal-host (z-index:100) — попапы вроде меню персонажа или выбора игрока
     часто открываются поверх уже открытой модалки и должны быть видны, а не спрятаны за ней. */
  position: absolute; bottom: 100%; left: 14px; margin-bottom: 6px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-modal); width: 300px; max-height: 260px; overflow-y: auto; z-index: 150;
}
.popover-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.popover-item:last-child { border-bottom: none; }
.popover-item:hover { background: var(--bg-3); }
.popover-item b { color: var(--accent-hover); }
.popover-item .muted { font-size: 12px; }
.popover-empty { padding: 16px; text-align: center; color: var(--text-3); font-size: 13px; }
/* ---- информация о сообщении: реакции и «просмотрено» ------------------- */
.msginfo-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.msginfo-row:last-child { border-bottom: none; }
.msginfo-row svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }
.msginfo-emoji { font-size: 18px; flex-shrink: 0; width: 22px; text-align: center; }
/* ---- поддержать проект --------------------------------------------------- */
.support-perks { list-style: none; margin: 4px 0 16px; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; }
.support-card-row { cursor: default; }
.support-card-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.support-card-number { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .3px; word-break: break-all; }
.support-card-row .icon-btn { margin-left: auto; flex-shrink: 0; }
/* ---- подключённые устройства ---------------------------------------------- */
.session-row { cursor: default; }
.session-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13.5px; }
.session-row .icon-btn.danger { margin-left: auto; flex-shrink: 0; color: var(--danger); }
/* ---- поиск по сообщениям --------------------------------------------------- */
.msgsearch-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msgsearch-snippet { font-size: 13.5px; overflow-wrap: anywhere; }
.msgsearch-snippet mark { background: var(--accent-soft); color: var(--accent-hover); border-radius: 3px; padding: 0 1px; }

.image-preview { display: flex; gap: 8px; padding-top: 8px; }
.image-preview-item { position: relative; }
.image-preview-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.image-preview-item button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: white; border: 2px solid var(--bg-1); font-size: 11px; }

/* ---- search view ---- */
.search-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px 6px; }
.search-header h2 { margin: 0; font-size: 20px; }
.search-bar-row { display: flex; gap: 10px; padding: 12px 24px; }
/* Переключатель вкладок ровно по ширине строки поиска: он стоит прямо под ней, и
   разные края бросаются в глаза сильнее, чем кажется. */
#search-mode { margin: 0 24px 10px; }
.btn-filter { position: relative; padding: 0 14px; height: 40px; }
.filter-badge {
  position: absolute; top: -6px; right: -6px; background: var(--danger); color: white; font-size: 10px;
  min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* Сетка, а не колонка: на широком мониторе карточка во всю ширину растягивала
   обложку в узкую полосу и та превращалась в мазню. Колонок столько, сколько
   влезает по 320px — на ноутбуке две, на большом мониторе три-четыре. */
.public-campaign-list {
  flex: 1; overflow-y: auto; padding: 4px 24px 40px;
  display: grid; gap: 14px; align-content: start;
  /* См. пояснение у .seek-gm-list: без min(...) колонка не сжимается ниже
     320 и карточка вылезает за край узкого экрана. */
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
}
/* Пустое состояние и «ничего не найдено» должны занимать всю ширину сетки,
   иначе они прижимаются в первую колонку. */
.public-campaign-list > .pcc-empty { grid-column: 1 / -1; }
/* Без overflow:hidden. Он обрезал обложку по скруглению карточки, но в сетке
   ломал расчёт высоты ряда: карточка получалась ниже своего содержимого и
   теги обрезались краем. Скругление обложки задано ей самой (.pcc-top). */
.pcc { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 16px; cursor: pointer; }
.pcc:hover { border-color: var(--accent); }
/* Растягиваем фон-обложку (отдельная картинка кампании, см. renderSearchView) до самых
   краёв карточки отрицательными полями — иначе он обрывался бы посередине. Без своей
   обложки строка остаётся пустой (просто фон карточки), как и было изначально. */
.pcc-top {
  display: flex; justify-content: space-between; align-items: flex-start; margin: -16px -16px 10px; padding: 12px;
  min-height: 46px; background-size: cover; background-position: center; background-repeat: no-repeat;
  border-radius: var(--radius-m) var(--radius-m) 0 0;
}
.pcc-top.has-cover { min-height: 130px; }
/* Выравнивать карточки по высоте не нужно: сетка и так растягивает их до высоты
   ряда. Попытка сделать это через flex:1 на описании ломала расчёт — описание с
   нулевой базой не попадало в высоту карточки, и теги обрезались краем. */
.pcc-avatar { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; background: var(--bg-3); border: 2px solid var(--bg-1); }
.pcc-badges { display: flex; gap: 6px; }
.pcc-badge { display: flex; align-items: center; gap: 4px; background: var(--bg-3); border-radius: 8px; padding: 4px 8px; font-size: 12px; font-weight: 700; }
.pcc-badge.type { background: var(--warn); color: #241a04; }
.pcc-badge.slots { background: var(--danger); color: white; }
.pcc-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.pcc-title-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.pcc-type-ic { font-size: 14px; }
.pcc-title { font-weight: 700; font-size: 15.5px; }
.pcc-desc { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pcc-empty { text-align: center; padding: 60px 20px; color: var(--text-3); }

.tag-chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 8px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: color-mix(in srgb, var(--tag-color) 18%, transparent);
  color: var(--tag-color);
  border: 1px solid color-mix(in srgb, var(--tag-color) 45%, transparent);
}
.tag-chip svg { width: 13px; height: 13px; stroke-width: 2; flex-shrink: 0; }
.filter-type-ic svg, .radio-card-ic svg { width: 20px; height: 20px; flex-shrink: 0; }
.filter-type-ic, .radio-card-ic { display: flex; align-items: center; margin-top: 1px; flex-shrink: 0; }
.mini-campaign-card .mcc-cover svg { width: 30px; height: 30px; color: var(--text-2); }
.chip-stat svg { width: 18px; height: 18px; }

.archive-list { flex: 1; overflow-y: auto; padding: 4px 8px; }

/* ===================== FEED ===================== */
.feed-list { flex: 1; overflow-y: auto; padding: 4px 8px 20px; }
.feed-composer {
  display: flex; gap: 10px; padding: 12px; margin: 4px 8px 8px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
}
.feed-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--bg-3); }
.feed-avatar.small { width: 26px; height: 26px; }
.feed-composer-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.feed-composer-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.feed-composer-actions #feed-btn-post { margin-left: auto; }
.feed-bg-row { display: flex; gap: 8px; flex-wrap: wrap; }
.feed-bg-dot {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; font-size: 15px; color: var(--text-2); background: var(--bg-3);
}
.feed-bg-dot.active { border-color: var(--accent); }
/* Фоны-пресеты постов. Тот же закрытый список, что в FEED_BGS на сервере:
   пришлют своё — станет обычным постом без фона. */
.feed-bg-sunset { background: linear-gradient(135deg, #ff9a3c, #ff4e7e); }
.feed-bg-ocean { background: linear-gradient(135deg, #2193b0, #6dd5ed); }
.feed-bg-forest { background: linear-gradient(135deg, #134e5e, #71b280); }
.feed-bg-grape { background: linear-gradient(135deg, #6420aa, #ff3ea5); }
.feed-bg-fire { background: linear-gradient(135deg, #f12711, #f5af19); }
.feed-bg-steel { background: linear-gradient(135deg, #4b6cb7, #182848); }
.feed-post {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; margin: 0 auto 10px; max-width: 640px;
}
.feed-post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.feed-post-meta { flex: 1; min-width: 0; }
/* Метка 18+ — тот же цвет, что у чипа mature в карточках кампаний/приключений
   (см. MATURE_TAG_COLOR), только тут это не чип с иконкой, а короткий значок:
   в узкой шапке поста чипу с подписью не хватило бы места. */
.feed-mature-badge {
  flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: #e07a3a; color: #fff;
}
.feed-post-name { font-weight: 700; }
.feed-post-time { font-size: 12px; color: var(--text-3); }
.feed-text { white-space: pre-line; overflow-wrap: anywhere; margin-bottom: 8px; }
/* Текст на цветном фоне — крупно по центру, как цветные посты в FB. */
.feed-text[class*="feed-bg-"] {
  border-radius: 10px; padding: 26px 16px; text-align: center;
  font-size: 19px; font-weight: 700; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.35);
}
.feed-photo { width: 100%; border-radius: 10px; display: block; margin-bottom: 8px; cursor: zoom-in; }
/* ---- альбом из нескольких фото в одном посте (до 5), как в сообщениях ---- */
.feed-photo-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px;
  width: 100%; border-radius: 10px; overflow: hidden; margin-bottom: 8px;
}
.feed-photo-grid.count-3 .feed-photo-grid-cell:first-child,
.feed-photo-grid.count-5 .feed-photo-grid-cell:last-child {
  grid-column: span 2;
}
.feed-photo-grid-cell { position: relative; aspect-ratio: 1 / 1; overflow: hidden; cursor: zoom-in; }
.feed-photo-grid-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feed-actions { display: flex; align-items: center; gap: 12px; }
.feed-comments-btn {
  background: none; border: none; color: var(--text-2); font-size: 14px;
  cursor: pointer; padding: 4px 2px;
}
/* Реакции поста — те же кружки-пилюли, что под сообщениями в чате (.msg-reaction),
   просто в отдельной строке под кнопками поста, а не внутри пузыря. */
.feed-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.feed-comments { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.feed-comment { display: flex; gap: 8px; margin-bottom: 8px; align-items: flex-start; }
.feed-comment-body { flex: 1; min-width: 0; background: var(--bg-3); border-radius: 10px; padding: 6px 10px; }
.feed-comment-name { font-weight: 700; font-size: 13px; margin-right: 6px; }
.feed-comment-text { overflow-wrap: anywhere; }
.feed-comment-time { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.feed-comment-add { display: flex; gap: 6px; }
.feed-comment-add .text-input { flex: 1; min-width: 0; }

/* ===================== CHARACTER PANEL ===================== */
.charpanel { background: var(--bg-1); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.charpanel-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chip-tab-row { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.chip-tab {
  background: transparent; border: none; color: var(--text-2); font-size: 12px; font-weight: 700; padding: 6px 4px;
  border-bottom: 2px solid transparent; letter-spacing: .3px;
}
.chip-tab.active { color: var(--accent-hover); border-bottom-color: var(--accent); }
.charpanel-tools { display: flex; gap: 6px; }
/* overflow-x: hidden — страховка от того же класса ошибок: содержимое листа
   задаёт сам ведущий шаблоном, и одно неудачное поле не должно уводить всю панель
   вбок. Причину при этом чиним в самой строке, а не прячем обрезкой. */
.charpanel-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 14px 20px; }
.char-search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.btn-sm { height: 38px; padding: 0 14px; font-size: 13px; white-space: nowrap; }
/* Базовое правило для .chip потерялось раньше — оставались только модификаторы
   (.chip.small, .chip.active и т.п.), которые без него ни на что не опирались.
   Из-за этого «голые» .chip (например, кнопки соотношения сторон в обрезке
   фото) рисовались браузерной кнопкой по умолчанию, без стиля сайта вовсе.
   Тот же пилюльный вид, что и у .pill — это один и тот же визуальный паттерн. */
.chip {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 13px; font-size: 12.5px; font-weight: 600; color: var(--text-1); cursor: pointer;
}
.pill-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.pill {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px; padding: 6px 13px; font-size: 12.5px;
  color: var(--text-1);
}
.pill.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }
.char-list { display: flex; flex-direction: column; gap: 2px; }
.char-list-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; cursor: pointer; }
.char-list-item:hover { background: var(--bg-2); }
.char-list-item img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--bg-4); }
.char-list-item-name { font-weight: 600; font-size: 14px; }
.char-list-item-type { font-size: 11.5px; color: var(--accent-hover); }
.char-list-item .star { margin-left: auto; color: var(--text-3); background: none; border: none; font-size: 16px; }
.char-list-item .star.active { color: var(--warn); }

.char-empty { display: none; text-align: center; padding: 30px 10px; }
.char-empty.show { display: block; }
/* overflow:visible — обводка в 1.8 у базового svg (см. правило `svg` в начале файла)
   у этой иконки чуть выходит за верх viewBox (макушка призрака упирается точно в
   y=0), и без этого браузер обрезал бы верхушку по границе. */
.ghost-ic { width: 60px; height: 60px; color: var(--text-3); margin-bottom: 14px; overflow: visible; }
.char-empty-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.char-empty p { font-size: 13px; margin-bottom: 16px; }
.char-empty-hint { background: var(--bg-2); border-radius: var(--radius-m); padding: 14px; margin-top: 20px; font-size: 13px; color: var(--text-2); }
.char-empty-hint .btn { margin-top: 12px; }

.member-list { display: flex; flex-direction: column; gap: 2px; }
.member-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; }
.member-item:hover { background: var(--bg-2); }
.member-item img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.member-role { font-size: 11px; color: var(--text-3); }
.member-role.owner { color: var(--warn); }
.member-role.cogm { color: var(--accent-hover); }

.punish-head { text-align: center; padding: 4px 0 10px; }
.punish-name { font-size: 18px; font-weight: 700; }
.mute-preset-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 8px; }
.mute-preset { padding: 10px 8px; font-size: 13px; }

/* ===================== MODAL SYSTEM ===================== */
.modal-host { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); }
/* Замена системному prompt() — тот же смысл (строка + OK/Отмена), но своим
   окном, а не системным диалогом с адресом сайта в заголовке. Отдельный слой
   поверх .modal-host: может понадобиться, даже когда уже открыто окно листа
   персонажа (переименование зовётся из его меню). */
.prompt-overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); padding: 16px;
}
.prompt-box {
  width: 340px; max-width: 100%; background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-l); box-shadow: var(--shadow-modal); padding: 18px;
  animation: modal-in .16s ease-out;
}
.prompt-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.prompt-text { color: var(--text-1); font-size: 14px; line-height: 1.5; }
.prompt-input { width: 100%; }
.prompt-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.modal-sheet {
  position: relative; width: 480px; max-width: 92vw; max-height: 86vh; background: var(--bg-1);
  border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-modal);
  display: flex; flex-direction: column; overflow: hidden; animation: modal-in .16s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98);} to { opacity:1; transform: none; } }
.modal-topbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-weight: 700; font-size: 16px; flex: 1; }
.modal-subtitle { font-size: 12px; color: var(--text-2); font-weight: 400; }
.modal-topbar .icon-btn { background: transparent; border: none; }
.btn-text { background: transparent; border: none; color: var(--accent-hover); font-weight: 700; font-size: 13.5px; padding: 6px 4px; }
.btn-text:disabled { color: var(--text-3); }
/* overflow-x: hidden — страховка от того же класса ошибок: содержимое окон
   приходит от людей, и одна неудачная строка не должна уводить окно вбок.
   Причину при этом чиним переносом в самом тексте, а не обрезкой. */
.modal-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px; min-width: 0; }
/* Колонка по центру — flex-контейнер, а его дети по умолчанию не сжимаются
   уже своего содержимого: без этого перенос ниже не спасал бы. */
.center-col > * { max-width: 100%; min-width: 0; }
.modal-footer-bar { border-top: 1px solid var(--border); padding: 12px 16px; flex-shrink: 0; }
.footer-btn-row { display: flex; gap: 10px; }
.footer-btn-row .text-input { flex: 1; }

/* ---- shared form bits ---- */
.field-label { display: block; font-size: 13px; font-weight: 700; margin: 14px 0 6px; }
.field-label:first-child { margin-top: 0; }
.text-input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  color: var(--text-0); font-size: 14px; outline: none; resize: vertical;
}
.text-input:focus { border-color: var(--accent); }
.text-input.mono { font-family: "Cascadia Code", Consolas, monospace; }
/* Подсветка :полей: в редакторе макроса. Цвета только через var(--accent):
   акцент оранжевый — рамка оранжевая, сменили тему — перекрасилось само. */
.macro-formula-wrap { position: relative; }
.macro-mirror {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
  background: var(--bg-2); border: 1px solid transparent; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: break-word; color: var(--text-0);
}
.macro-mirror.mono { font-family: "Cascadia Code", Consolas, monospace; }
/* Рамка токена — через inset-тень, а не border/padding: они расширяют строку
   в зеркале, переносы разъезжаются с полем ввода и текст «плывёт». Тень на
   раскладку не влияет, поэтому зеркало и поле идут строка в строку. */
.macro-mirror .macro-tok-ok {
  background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent);
  border-radius: 4px; color: var(--accent-hover);
}
.macro-mirror .macro-tok-bad {
  background: transparent; box-shadow: inset 0 0 0 1px var(--danger);
  border-radius: 4px;
}
.text-input.macro-input {
  position: relative; z-index: 1; background: transparent;
  color: transparent; caret-color: var(--text-0); line-height: 1.45;
  /* Рамка растёт за текстом вместо полосы прокрутки; ручное растягивание
     не нужно — зеркало тянется само за высотой обёртки. */
  resize: none; overflow-y: auto; max-height: 50vh;
}
.text-input.macro-input::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.text-input.macro-input::placeholder { color: var(--text-3); }
.field-hint-chip.lit { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); }
.group-label { font-size: 11.5px; font-weight: 700; color: var(--text-3); letter-spacing: .4px; text-transform: uppercase; margin: 18px 0 8px; }
.group-label.big { font-size: 16px; color: var(--text-0); text-transform: none; font-weight: 700; letter-spacing: 0; }
.group-label-row { display: flex; align-items: center; gap: 8px; margin: 18px 0 4px; }
.group-label-row .group-label { margin: 0; }

.list-card { background: var(--bg-2); border-radius: var(--radius-m); overflow: hidden; border: 1px solid var(--border); }
.list-row {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--border);
  font-size: 14px; cursor: pointer;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-3); }
.list-row.accent-row { color: var(--accent-hover); background: var(--accent-soft); font-weight: 700; border-radius: var(--radius-m); border: none; margin-bottom: 4px; }
.list-row .row-ic { width: 20px; text-align: center; }
.list-row .row-ic.red { color: var(--danger); }
.list-row .chev { margin-left: auto; color: var(--text-3); }
.list-row .ok-check { margin-left: auto; color: var(--success); font-weight: 700; }
.list-row .ext-ic { margin-left: auto; color: var(--text-3); }
.list-row.toggle-row { cursor: default; align-items: flex-start; }
.list-row.toggle-row:hover { background: transparent; }
.list-row.toggle-row > div:first-child { flex: 1; }
.list-row.toggle-row p { margin: 3px 0 0; }

.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--bg-4); border-radius: 999px; transition: .15s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.segmented { display: flex; background: var(--bg-2); border-radius: 10px; padding: 3px; border: 1px solid var(--border); }
.seg-btn { flex: 1; background: transparent; border: none; padding: 9px 8px; border-radius: 8px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.seg-btn.active { background: var(--accent); color: var(--on-accent); }
.segmented-3 .seg-btn { font-size: 17px; }

/* Выбор акцента: кружки цветов, у выбранного — галочка внутри, чтобы выбор был виден
   и тем, кто не различает эти цвета между собой. */
.accent-row { display: flex; flex-wrap: wrap; gap: 12px; padding: 6px 0 2px; }
.accent-swatch {
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid transparent; padding: 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 17px; font-weight: 700; line-height: 1;
  transition: transform .12s, border-color .12s;
}
.accent-swatch:hover { transform: scale(1.08); }
.accent-swatch.active { border-color: var(--text-0); }
.accent-swatch.active::after { content: "✓"; color: var(--on-swatch, #fff); font-size: 17px; font-weight: 700; }
/* Кружки повторяют палитру акцентов ниже; светлые получают тонкую обводку,
   иначе на светлой теме они сливаются с фоном модалки. */
.accent-swatch[data-accent-id="purple"] { background: #7c5cff; }
.accent-swatch[data-accent-id="blue"]   { background: #3b82f6; }
.accent-swatch[data-accent-id="cyan"]   { background: #06b6d4; }
.accent-swatch[data-accent-id="green"]  { background: #10b981; }
.accent-swatch[data-accent-id="orange"] { background: #f97316; }
.accent-swatch[data-accent-id="red"]    { background: #ef4444; }
.accent-swatch[data-accent-id="pink"]   { background: #ec4899; }
.accent-swatch[data-accent-id="white"]  { background: #e8e8ef; --on-swatch: #17171b; box-shadow: inset 0 0 0 1px rgba(120,120,140,.45); }
[data-theme="light"] .accent-swatch[data-accent-id="white"] { background: #3a3a44; --on-swatch: #fff; }
.theme-preview-dark { background: linear-gradient(135deg, #17171b 50%, #5b4fe5 50%); }
.theme-preview-light { background: linear-gradient(135deg, #ffffff 50%, #5b4fe5 50%); border: 1px solid #dfe1e8; }
.theme-preview-auto { background: linear-gradient(135deg, #17171b 50%, #ffffff 50%); }
.theme-preview-midnight { background: linear-gradient(135deg, #0c0e1c 50%, #3aa0e6 50%); }
.theme-preview-sunset { background: linear-gradient(135deg, #1c1210 50%, #e07a3a 50%); }
.theme-preview-forest { background: linear-gradient(135deg, #0e1913 50%, #1ecb8f 50%); }

.profile-mini { display: flex; align-items: center; gap: 12px; padding: 10px 4px 18px; cursor: pointer; }
.profile-mini img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: var(--bg-3); }
.profile-mini-name { font-weight: 700; font-size: 16px; }
.chev { color: var(--text-3); margin-left: auto; }

.profile-avatar-btn { position: relative; border: none; background: none; padding: 0; cursor: pointer; border-radius: 50%; transition: opacity .15s; }
.profile-avatar-btn:hover { opacity: .85; }
.profile-name-input {
  text-align: center; font-size: 18px; font-weight: 700; max-width: 280px; margin-bottom: 6px;
}

.social-row { display: flex; gap: 10px; padding: 4px 0 20px; }
.social-btn { width: 46px; height: 46px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); font-size: 20px; }

.btn { border: none; border-radius: 10px; padding: 11px 18px; font-size: 14px; font-weight: 700; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline-primary { background: transparent; color: var(--accent-hover); border: 2px solid var(--accent); }
.btn-secondary { background: var(--bg-3); color: var(--text-0); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-4); }
.btn-success { background: var(--success); color: #04231a; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #d43952; }
.btn-block { width: 100%; }
[hidden] { display: none !important; }

/* profile modal */
.profile-big-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; margin: 8px 0 12px; background: var(--bg-3); }
.profile-big-name { font-size: 20px; font-weight: 800; }
.profile-id-row { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 10px; }
.profile-field { width: 100%; margin-bottom: 6px; }
.profile-value { font-weight: 600; padding: 0; }
/* Заголовки разделов внутри профиля стоят плотнее, чем в общих списках: там между
   ними лежат карточки, а здесь — короткие строки, и воздух только рвал их связь
   с собственным значением. */
.center-col .group-label { margin: 12px 0 3px; }
.center-col .profile-field:first-of-type { margin-top: 4px; }

.avatar-edit-row { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar-edit-preview { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; background: var(--bg-3); }
.campaign-avatar-pick {
  width: 84px; height: 84px; border-radius: var(--radius-m); background: var(--bg-3); border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--text-2); cursor: pointer;
  background-size: cover; background-position: center;
}
.avatar-edit-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.campaign-cover-pick {
  width: 100%; height: 90px; border-radius: var(--radius-m); background: var(--bg-3); border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer;
  background-size: cover; background-position: center; margin-bottom: 8px;
}
.campaign-cover-pick.has-image { border-style: solid; color: transparent; }

/* ===================== AUTH SCREEN ===================== */
/* Colors here are hardcoded to match the rollpg.dreamcrie.workers.dev reference exactly
   (zinc-800 panels, violet-500 accent) rather than the app's own theme tokens — this
   screen keeps one fixed look regardless of which of the 6 in-app themes is selected,
   since nobody is logged in yet to have a theme preference. */
.auth-screen {
  position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: #0b0b0c; padding: 16px;
}
.auth-card {
  width: 100%; max-width: 400px; background: #27272a; border: 1px solid #323235; border-radius: 16px;
  padding: 24px; animation: modal-in .16s ease-out;
}
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head h1 { margin: 0; font-size: 18px; font-weight: 700; color: #fff; }
.auth-head p { margin: 2px 0 0; font-size: 12px; color: #a1a1aa; }

.auth-avatar-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 20px; }
.auth-avatar-btn {
  width: 80px; height: 80px; border-radius: 50%; border: none; background: #8b5cf6; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 600;
  background-size: cover; background-position: center; transition: transform .15s;
}
.auth-avatar-btn:hover { transform: scale(1.05); }
.auth-avatar-btn:active { transform: scale(.95); }
.auth-avatar-hint { font-size: 11px; color: #a1a1aa; }

.auth-field { display: block; margin-bottom: 12px; }
.auth-field span { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 500; color: #a1a1aa; }
.auth-field input {
  width: 100%; border-radius: 8px; border: 1px solid #3f3f46; background: #27272a; color: #fff;
  padding: 10px 14px; font-size: 14px; outline: none; transition: border-color .15s, background-color .15s;
}
.auth-field input::placeholder { color: #71717a; }
.auth-field input:focus { border-color: #8b5cf6a0; background: #3f3f46b3; }

.auth-error { color: #f87171; font-size: 12.5px; margin: 2px 0 10px; }
.auth-submit {
  margin-top: 8px; width: 100%; border: none; border-radius: 8px; background: #8b5cf6; color: #fff;
  padding: 10px 16px; font-size: 14px; font-weight: 600; transition: background-color .15s, transform .15s;
}
.auth-submit:hover { background: #a78bfa; transform: scale(1.01); }
.auth-submit:active { transform: scale(.98); }
.auth-link {
  display: block; width: 100%; margin-top: 14px; background: none; border: none; text-align: center;
  font-size: 12px; color: #a1a1aa; transition: color .15s;
}
.auth-link:hover { color: #e4e4e7; }
.auth-note { max-width: 400px; text-align: center; line-height: 1.4; font-size: 12px; color: #71717a; }
.auth-divider {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 10px;
  color: #71717a; font-size: 12px; text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: #2a2a38; }
#login-google-btn, #register-google-btn { display: flex; justify-content: center; }
.auth-lang-switch { position: absolute; top: 18px; right: 18px; display: flex; gap: 4px; background: #18181b; border: 1px solid #323235; border-radius: 8px; padding: 3px; }
.auth-lang-btn { background: transparent; border: none; color: #a1a1aa; font-size: 11.5px; font-weight: 700; padding: 5px 9px; border-radius: 6px; }
.auth-lang-btn.active { background: #8b5cf6; color: white; }

/* filters / tri toggle */
/* Сетка, а не колонка flex: grid-auto-rows:1fr выравнивает все строки по самой
   высокой. Раньше строка с описанием в две строки была заметно выше соседних, и
   список видов кампаний выглядел лесенкой. */
.filter-type-list { display: grid; grid-auto-rows: 1fr; gap: 8px; }
.filter-type-row { display: flex; align-items: flex-start; gap: 10px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 12px; }
/* flex:0 0 18px, а не просто width: без запрета на сжатие флексбокс отбирал у
   галочки ширину в пользу длинного описания, и в каждой строке она получалась
   своего размера. */
.filter-type-row input { flex: 0 0 18px; margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.filter-type-row b { display: block; margin-bottom: 2px; }
.tri-toggle { display: flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.tri-btn { flex: 1; background: transparent; border: none; padding: 10px; border-radius: 8px; font-size: 16px; color: var(--text-2); }
.tri-btn.active { background: var(--bg-4); color: var(--text-0); }
/* Своя подпись вместо .center-pad: у того 24px полей сверху и снизу, из-за чего
   между «Темы не для всех» и «Рады новичкам» зияла дыра почти в 70 пикселей. */
.tri-hint { text-align: center; margin: 6px 0 0; }
.range-input { width: 100%; accent-color: var(--accent); margin: 6px 0 16px; }

.radio-card-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.radio-card { display: flex; gap: 10px; background: var(--bg-2); border: 2px solid var(--border); border-radius: var(--radius-m); padding: 12px; cursor: pointer; align-items: flex-start; }
.radio-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { margin-top: 3px; accent-color: var(--accent); }
.radio-card b { display: block; }
.radio-card .muted { font-size: 12.5px; }

.tag-toggle-row { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.tag-toggle, .tag-toggle.full { display: flex; gap: 10px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 12px; align-items: flex-start; cursor: pointer; margin-bottom: 10px; }
.tag-toggle input { margin-top: 3px; accent-color: var(--accent); }
.tag-ic { font-size: 18px; }

/* campaign detail modal */
.campaign-cover { height: 130px; border-radius: var(--radius-m); background: linear-gradient(135deg, var(--accent), #2a2470); margin-bottom: 12px; }
/* Строка ведущего нажимается: она открывает его профиль, откуда можно написать
   в личные. Раньше это был просто текст, и написать ведущему из поиска было
   попросту нечем. */
.campaign-owner-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; cursor: pointer; }
.cd-owner-go { margin-left: auto; font-size: 12px; color: var(--text-3); }
.campaign-owner-row:hover .cd-owner-go { color: var(--accent); }
.campaign-owner-row img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.campaign-title-big { font-size: 21px; font-weight: 800; margin-bottom: 12px; }
.chip-stat-row { display: flex; gap: 10px; margin-bottom: 16px; }
.chip-stat { flex: 1; background: var(--bg-2); border-radius: var(--radius-m); padding: 10px; text-align: center; font-size: 12px; font-weight: 700; }
.chip-stat-label { font-size: 9.5px; color: var(--text-3); font-weight: 700; text-transform: uppercase; margin-top: 2px; }
/* overflow-wrap: anywhere — сплошная строка без пробелов («ааааа…», ссылка,
   набор символов) иначе не переносится вовсе: она распирает окно и оставляет ему
   горизонтальную прокрутку, а фон профиля обрывается на полуслове. */
.campaign-desc { font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-1); }
.apply-msg-row { margin-top: 10px; }

/* character detail — обложка персонажа уходит фоном за всю модалку, а шапка и вкладки
   лежат поверх неё; книзу картинка растворяется в фоне листа, чтобы поля читались. */
/* Карточка персонажа: круглый аватар по центру над листом, а фон карточки — сплошной
   цвет (у каждого персонажа свой, --char-bg). Раньше аватар растягивался подложкой на
   всю карточку и текст читался поверх картинки — отсюда и «выглядит ужасно». */
.char-detail-sheet {
  position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden;
  /* Цвет персонажа взят в полную силу там, где он мелкий (пузырь реплики, кружок
     выбора), а здесь он заливает целую панель — на полной насыщенности это давит
     и мешает читать лист. Приглушаем подмешиванием фона: оттенок узнаётся, но
     карточка остаётся спокойной. */
  background: color-mix(in srgb, var(--char-bg, var(--bg-1)) 42%, var(--bg-1));
}
/* Шапка листа — обычной полосой над кадром: имя, кнопки и вкладки вне прокрутки,
   никуда не уезжают и ничего не перекрывают — фото видно целиком. */
/* Шапка — прозрачная, поверх кадра: никакой полосы над фото. */
/* backdrop-filter — не ради тона (цвета нет, только blur): полоса всегда лежит
   на одном месте, а под ней то кадр, то — после прокрутки мимо кадра — обычный
   текст листа. Без размытия он проступал бы под именем нечитаемым дублем. */
.char-detail-bar { background: transparent; border-bottom: none; padding: 14px 10px; transition: background-color .15s, backdrop-filter .15s; }
/* Класс ставит app.js по скроллу: пока виден кадр персонажа, шапка остаётся
   прозрачной — размытие на живом фото было бы лишним. Как только кадр
   прокручен выше и под шапкой обычный текст листа, включаем размытие и
   лёгкую подложку. */
.char-detail-bar.scrolled {
  /* Размытие сильнее прежнего: на 6px буквы текста под низом ещё узнавались
     смазанным силуэтом и выглядели неряшливо, а не ровной подложкой. */
  background: color-mix(in srgb, var(--bg-1) 65%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.char-detail-sheet .modal-topbar { color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.85); }
.char-detail-sheet .char-bar-sub { color: rgba(255,255,255,.78); }
.char-detail-scroll { position: relative; scrollbar-width: none; }
.char-detail-scroll::-webkit-scrollbar { display: none; }
/* Кадр персонажа. Круглая аватарка в 128px показывала лицо размером с ноготь
   и съедала верх экрана рамкой и тенью — при том, что картинку человек выбирает
   сам и обычно она стоит того, чтобы её видеть. Теперь это широкий кадр во всю
   ширину окна, книзу растворяющийся в фоне листа: смотрится как задник, а не
   как вставленная картинка, и переход к полям не читается как обрыв.
   Кадр вытянут по вертикали (3:4): аватарки почти всегда портретные, при
   широком кадре от них осталась бы полоса поперёк лица. */
.char-hero { margin: -16px -16px 0; position: relative; }
.char-cover {
  display: block; width: 100%; aspect-ratio: 3 / 4; max-height: 52vh;
  object-fit: cover; object-position: center top;
  background: var(--bg-3); cursor: pointer;
  /* Растворение книзу — маской, а не плашкой поверх: плашка закрасила бы низ
     кадра одним цветом, а маска убирает сами пиксели, и что бы ни стояло за
     листом (в том числе выбранный цвет персонажа), переход выходит чистым. */
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
}
/* Имя и подпись «НИП / игрок» — в углу верхней полосы, над кадром. Длинное
   имя разрешаем рвать по буквам: одно слово в двадцать знаков иначе не находит,
   где перенестись, и уезжает за край. */
/* Раздел без названия — поля вне разделов. Заголовка нет, поэтому и отступа
   под него не нужно; полосой сверху отделяем от того, что стоит выше. */
.sheet-section.untitled { margin-top: 4px; }
/* В редакторе шаблона у такого раздела в заголовке стоит приглушённая подпись:
   пустая строка не читалась бы как строка, и по ней некуда было бы нажать. */
.sec-untitled { color: var(--text-3); font-weight: 500; }
.char-bar-id { flex: 1; min-width: 0; }
.char-bar-name {
  font-weight: 800; font-size: 17px; line-height: 1.15; overflow-wrap: anywhere;
}
.char-bar-sub { font-size: 12px; color: var(--text-2); line-height: 1.2; }
/* Полоса вкладок — между кадром и разделами листа. При прокрутке прилипает
   к верху впритык (top и бока в минус паддинга скролла).
   -webkit-sticky — для старых вебвью. Все три вкладки всегда в один ряд. */
.modal-sheet .char-detail-sheet .char-tabs {
  /* top не -12px (как в общем случае, компенсируя паддинг скролла): здесь скролл
     получает padding-top: 54px под шапку-«.over-bg» (см. правило ниже в файле),
     и без поправки вкладки прилипали ВЫШЕ, чем кончается шапка, наезжая на неё
     при скролле. +12px — расчёт от фактической высоты шапки с именем и
     подписью (~66px), а не от паддинга под неё (54px). */
  position: -webkit-sticky; position: sticky; top: 12px; z-index: 5;
  margin: 0 -10px 10px; padding: 8px 10px;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color .15s, backdrop-filter .15s, border-color .15s;
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 4px;
}
/* Класс ставит app.js по скроллу — тем же моментом, что и .char-detail-bar.scrolled
   рядом: кадр персонажа скрылся из-под шапки — оба перестают быть прозрачными. */
.modal-sheet .char-detail-sheet .char-tabs.scrolled {
  background: color-mix(in srgb, var(--char-bg, var(--bg-1)) 55%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom-color: var(--border);
}
.modal-sheet .char-detail-sheet .char-tabs::-webkit-scrollbar { display: none; }
.modal-sheet .char-detail-sheet .char-tabs .chip-tab {
  white-space: nowrap; flex-shrink: 0;
  font-size: 11px; letter-spacing: 0; padding: 6px 2px;
}
/* Лист уже, поля шире: боковые отступы скролла 16px -> 10px. Кадр разъезжается
   на всю ширину обратно отрицательными полями. Верхний отступ меньше — вкладки
   и так отделены своей полосой. */
.modal-sheet .char-detail-sheet .char-detail-scroll { padding: 12px 10px 24px; }
/* Кадр уходит под шапку до самого верха окна и во всю ширину — одним правилом,
   иначе сокращённая запись margin сбросит подтяжку в 0 и вернётся «рамка». */
.modal-sheet .char-detail-sheet .char-hero { margin: -54px -10px 0; }
@media (max-width: 640px) {
  /* Кадр выше, чтобы лицо влезало целиком: ничего поверх фото больше нет. */
  .char-cover { max-height: 50vh; }
}
/* палитра выбора цвета фона персонажа */
.bg-color-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0 2px; }
.bg-color-dot {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.bg-color-dot.active { border-color: var(--text-0); }
.char-name-row { margin-bottom: 12px; }
.char-name-big { font-size: 22px; font-weight: 800; }

/* items tab */
.item-row {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.item-row:hover { border-color: var(--accent); }
.item-head { display: flex; align-items: baseline; gap: 10px; }
.item-name { font-weight: 700; font-size: 15px; flex: 1; }
.item-qty { font-weight: 700; color: var(--accent-hover); font-size: 14px; flex-shrink: 0; }
/* overflow-wrap обязателен: без него длинная строка без пробелов не переносится и
   растягивает карточку вбок вместо того, чтобы развернуться в несколько строк. */
.item-desc {
  font-size: 12.5px; color: var(--text-2); margin-top: 4px;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.item-desc.clamped { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-name { overflow-wrap: anywhere; }
.item-row { overflow: hidden; }
.item-more { padding: 2px 0; font-size: 12px; }

/* history tab */
.history-row { padding: 10px 2px; border-bottom: 1px solid var(--border); }
.history-text { font-size: 13.5px; }
.history-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* reorder controls in the sheet template builder */
/* Ручка переноса макроса — только подсказка глазу, тянуть можно за всю
   строку: сама зона нажатия не сужена до этих точек. */
.drag-handle { display: inline-flex; align-items: center; flex-shrink: 0; color: var(--text-3); touch-action: none; }
.drag-handle svg { width: 18px; height: 18px; }
.macro-row-dragging { box-shadow: var(--shadow-modal); background: var(--bg-3); border-radius: var(--radius-m); opacity: .96; }
/* Полоска — куда встанет строка при отпускании. */
.macro-drop-indicator { height: 3px; margin: 3px 14px; border-radius: 2px; background: var(--accent); }
/* Режим порядка в конструкторе шаблона: ручки видны только в нём, шевроны
   открытия редактора — наоборот, только вне его. */
#sheet-template-body .drag-handle { display: none; cursor: grab; }
#sheet-template-body.reorder-mode .drag-handle { display: inline-flex; }
#sheet-template-body.reorder-mode .field-row { cursor: default; }
#sheet-template-body.reorder-mode .field-row .chev { display: none; }
/* Пустая секция в режиме порядка — видимая зона сброса. */
#sheet-template-body.reorder-mode .template-fields:empty {
  min-height: 46px; border: 2px dashed var(--border); border-radius: 10px; margin-bottom: 8px;
}
.template-dragging {
  position: fixed; z-index: 500; pointer-events: none; opacity: .96;
  box-shadow: var(--shadow-modal); background: var(--bg-2); border-radius: 10px; margin: 0 !important;
}
.template-drop-indicator { height: 4px; border-radius: 2px; background: var(--accent); margin: 0 0 8px; }
#btn-template-reorder.active { color: var(--accent); }
.btn-text.dirty { color: var(--accent); font-weight: 800; }
.btn-text.dirty::after { content: " •"; }
.template-empty-ic { display: flex; justify-content: center; margin-bottom: 10px; color: var(--text-3); }
.template-empty-ic svg { width: 44px; height: 44px; }
.template-section-head h3 svg { width: 15px; height: 15px; margin-left: 6px; vertical-align: -2px; color: var(--text-3); }
.field-row-flags svg { width: 15px; height: 15px; }
.chip-tab-ic { display: inline-flex; align-items: center; margin-right: 6px; }
.chip-tab-ic svg { width: 15px; height: 15px; }
.chip-tab { display: inline-flex; align-items: center; }
.pcc-badge svg { width: 13px; height: 13px; stroke-width: 2; }
.star svg { width: 18px; height: 18px; }
.tri-btn svg { width: 19px; height: 19px; }
.sheet-section { margin: 18px 0 6px; }
.sheet-section-title {
  font-size: 18px; font-weight: 800; color: var(--accent-hover); margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
}
.sheet-section-title > span:first-child { flex: 1; }
.sheet-section-chev { display: inline-flex; transition: transform .15s; }
.sheet-section-chev svg { width: 18px; height: 18px; }
.sheet-section.collapsed .sheet-section-chev { transform: rotate(-90deg); }
.sheet-section.collapsed .sheet-field-row { display: none; }
/* Строка листа: название слева, значение справа. Обе половины обязаны уметь
   сжиматься и переноситься. Без этого «вторичные значения» (компактные модификаторы,
   которые крепятся справа к основному полю) распирали строку: основное поле 100px
   плюс каждый значок ~66px — пять штук давали больше 400px, сжиматься flex-элементам
   по умолчанию нечем, и вся панель персонажа уезжала в горизонтальную прокрутку,
   а названия полей срезало слева. */
.sheet-field-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  flex-wrap: wrap; padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.sheet-field-name { font-weight: 700; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.sheet-field-val { color: var(--text-1); }
.sheet-field-val input { background: transparent; border: none; color: var(--text-1); text-align: right; outline: none; width: 100px; max-width: 100%; font-size: 14px; }
.sheet-field-val.dash { color: var(--text-3); }
.sheet-field-val {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  flex-wrap: wrap; min-width: 0; flex: 1 1 auto;
}
.sheet-field-secondary { display: inline-flex; align-items: center; background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; padding: 1px 6px; font-size: 12.5px; font-weight: 700; color: var(--accent-hover); }
.sheet-field-secondary.dash { color: var(--text-3); font-weight: 400; }
.sheet-field-secondary input { width: 44px; font-size: 12.5px; font-weight: 700; color: inherit; }

.field-hint-chip { display: inline-flex; align-items: center; background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; padding: 2px 7px; margin: 2px 4px 2px 0; font-family: monospace; font-size: 12px; color: var(--accent-hover); cursor: pointer; }
.field-hint-chip:hover { background: var(--bg-4); }

/* macros list */
.macro-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.macro-row:last-child { border-bottom: none; }
.macro-row:hover { background: var(--bg-3); }
.macro-name { font-weight: 700; }
.macro-trigger { color: var(--danger); font-size: 12.5px; margin-left: 6px; }
.macro-body { font-size: 12.5px; color: var(--text-2); font-family: monospace; }

/* template body */
.template-section-block { margin-bottom: 20px; }
.template-section-head { display: flex; align-items: center; margin-bottom: 8px; }
.template-section-head h3 { flex: 1; margin: 0; font-size: 18px; }
.field-row {
  display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 12px; margin-bottom: 8px; cursor: pointer;
}
.field-row:hover { border-color: var(--accent); }
.field-type-ic { color: var(--danger); font-weight: 800; width: 18px; text-align:center; }
.field-row-name { font-weight: 600; flex: 1; }
.field-row-flags { display: flex; gap: 4px; color: var(--text-3); font-size: 13px; }
.template-empty { text-align: center; padding: 40px 10px; }

/* dice dictionary */
.dict-section-title { color: var(--success); font-size: 19px; font-weight: 800; margin: 22px 0 8px; }
.dict-section-title:first-child { margin-top: 0; }
#dice-dict-body p { line-height: 1.55; font-size: 14px; color: var(--text-1); }
#dice-dict-body code { background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.dict-try {
  display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px 4px 4px 12px; margin: 8px 0 18px;
}
.dict-try input { flex: 1; background: transparent; border: none; color: var(--text-0); font-family: monospace; font-size: 14px; outline: none; }
.dict-try button { width: 36px; height: 36px; border-radius: 8px; background: var(--bg-3); border: none; font-size: 16px; }
.dict-try-result { font-size: 12.5px; color: var(--accent-hover); padding: 0 10px 10px; margin-top: -14px; margin-bottom: 14px; }
.dict-fn-list { margin: 4px 0 16px; padding-left: 4px; list-style: none; }
.dict-fn-list li { margin-bottom: 8px; font-size: 14px; }

.changelog-entry { padding: 14px 0; border-bottom: 1px solid var(--border); }
.changelog-date { color: var(--accent-hover); font-weight: 700; font-size: 12.5px; margin-bottom: 4px; }

/* ---- chat hints panel ---- */
.hint-panel .group-label.big { margin-bottom: 10px; }
.hint-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13.5px; color: var(--text-1); flex-wrap: wrap; }
.hint-chip {
  background: var(--accent-soft); color: var(--accent-hover); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 6px; padding: 2px 8px; font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px; white-space: nowrap;
}
.hint-pattern {
  display: block; background: var(--bg-2); border: 1px dashed var(--border); border-radius: 8px; padding: 6px 10px;
  font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; color: var(--text-2); margin: 6px 0 10px;
}
.hint-subhead { font-size: 15px; font-weight: 700; margin: 18px 0 2px; color: var(--text-0); }

/* toasts */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text-0); padding: 12px 16px; border-radius: 10px;
  font-size: 13.5px; box-shadow: var(--shadow-modal); animation: toast-in .18s ease-out; max-width: 300px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes toast-in { from { opacity:0; transform: translateX(20px);} to { opacity:1; transform:none;} }

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 980px) {
  .app { grid-template-columns: 64px 1fr; }
  .app:has(#charpanel:not([hidden])) { grid-template-columns: 64px 1fr; }
  /* Список кампаний и панель персонажей — на телефоне на весь экран (100vw), не 80-88vw:
     более узкая ширина оставляла зазор сбоку, через который проглядывал слой позади (сетка
     .app, всё ещё резервирующая колонку под скрытый рейл, см. .app:has(#charpanel...) ниже) —
     выглядело как «сломанная пустота», хотя контент за ней на самом деле был на месте,
     просто перекрыт наполовину. На весь экран — зазору просто неоткуда взяться. */
  /* Начинается сразу за рейлом и занимает всю оставшуюся ширину: на весь экран нельзя —
     тогда список кампаний накрывает сам рейл, и «Поиск»/«Архив»/настройки становятся
     недоступны; уже рейла тоже нельзя — сбоку остаётся полоса чужого слоя. */
  .sidebar { position: fixed; left: 64px; top: 0; bottom: 0; width: calc(100vw - 64px); z-index: 40; transform: translateX(0); transition: transform .2s; }
  /* Панель стоит на left:64px, поэтому сдвига на собственную ширину (100%) не хватает —
     её правый край останавливается ровно на 64px и остаётся видимой полосой. Уезжать
     нужно на ширину ПЛЮС этот отступ; запас в несколько пикселей прячет и рамку справа. */
  .sidebar.hide-mobile { transform: translateX(calc(-100% - 70px)); pointer-events: none; }
  .main { grid-column: 2; }
  .charpanel { position: fixed; left: 0; right: 0; top: 0; bottom: 0; width: 100vw; z-index: 41; }
  .only-mobile { display: flex !important; }

  /* Открытый чат на телефоне занимает весь экран: рейл с иконками (как и список
     кампаний выше) на это время скрывается — иначе на узком экране под сам разговор
     остаётся едва половина ширины. Возврат — кнопкой "назад" в шапке чата. */
  .rail.hide-mobile { display: none; }
  .app:has(.rail.hide-mobile) { grid-template-columns: 1fr; }
  .app:has(.rail.hide-mobile) .main { grid-column: 1; }
  /* .app:has(#charpanel:not([hidden])) выше содержит #id-селектор — по специфичности он
     побеждает предыдущее правило даже при более позднем порядке в файле, поэтому для
     случая "рейл скрыт И панель персонажей открыта" нужно отдельное, ещё более специфичное
     правило — иначе сетка молча возвращалась к "64px 1fr" и .main проваливался в колонку
     под уже невидимый рейл. Впрочем, раз и sidebar, и charpanel теперь position:fixed на
     весь экран независимо от сетки, эта колонка уже ни на что не влияет визуально — этот
     блок только ради аккуратности состояния .main под ними. */
  .app:has(.rail.hide-mobile):has(#charpanel:not([hidden])) { grid-template-columns: 1fr; }
  .app:has(.rail.hide-mobile):has(#charpanel:not([hidden])) .main { grid-column: 1; }

  /* Крупная надпись "TeaRPG" над списком кампаний — на телефоне лишняя трата и без
     того тесной высоты экрана: логотип на рейле уже показывает, что это за приложение. */
  .sidebar-head { display: none; }
  /* iOS приближает страницу при фокусе на поле ввода с кеглем меньше 16px.
     Выйти из приближения можно только жестом, а свайп заодно закрывает окно
     вместе с ненабранным текстом — жалоба была именно на эту связку. На
     телефоне все поля ввода идут кеглем 16. Зеркало формулы макроса — тем же
     кеглем и интерлиньяжем, что само поле, иначе подсветка разъедется. */
  .text-input, textarea, input, select, .composer-field { font-size: 16px; }
  .macro-mirror, #macro-formula { font-size: 16px; line-height: 1.45; }
}
@media (max-width: 640px) {
  .modal-sheet {
    width: 100vw; max-width: 100vw; border-radius: 0;
    max-height: 100vh; height: 100vh; /* dvh fallback chain, see .app comment above */
    max-height: 100dvh; height: 100dvh;
  }
  /* Окно персонажа — шторкой, а не во весь экран: сверху и по бокам видно
     затемнение, лист читается как карточка поверх чата. Ширина уже не 100vw
     (тот же .modal-sheet на других окнах) — иначе бока сливались бы с краем
     экрана и комментарий выше был бы неправдой. */
  .modal-host:has(.char-detail-sheet) { align-items: flex-end; }
  .modal-sheet:has(.char-detail-sheet) {
    width: calc(100vw - 16px); max-width: calc(100vw - 16px);
    height: 92vh; max-height: 92vh;
    height: 92dvh; max-height: 92dvh;
    border: none; border-radius: 18px 18px 0 0;
  }
  .msg-row { max-width: 86%; }
}

/* ---- присутствие: точка поверх аватарки -------------------------------- */
.avatar-wrap { position: relative; display: inline-block; flex-shrink: 0; line-height: 0; }
.presence-dot {
  position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px;
  border-radius: 50%; border: 2px solid var(--bg-1); box-sizing: content-box;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; line-height: 1; color: #1a1b22;
}
.presence-online { background: #2fbf6b; }
/* «Отошёл» — полумесяц: вырезаем из кружка второй кружок цветом фона. Одним лишь
   цветом онлайн и отошёл не различить, а глиф на 12 пикселях нечитаем. */
.presence-away { background: #f0a63a; }
.presence-away::after {
  content: ""; position: absolute; left: -3px; top: -3px;
  width: 11px; height: 11px; border-radius: 50%; background: var(--bg-1);
}
/* Офлайн — пустой кружок, а не залитый серым: так он не спорит с активными статусами. */
.presence-offline { background: transparent; box-shadow: inset 0 0 0 3px var(--text-3); }
/* Скрытность: снаружи такой пользователь офлайн, но себе показываем перечёркнутый
   кружок — иначе не отличить «включил режим» от «отвалилась связь». */
.presence-invisible { background: transparent; border-color: var(--text-2); }
.presence-invisible::after {
  content: ""; position: absolute; left: 50%; top: -2px; width: 2px; height: 16px;
  background: var(--text-2); transform: translateX(-50%) rotate(45deg); border-radius: 1px;
}
/* Заявки на вступление — счётчиком поверх аватарки кампании в списке чатов,
   сверху справа (снизу справа у DM уже стоит presence-dot, кампаниям он не
   нужен, но угол лучше не делить). Виден только ведущему/со-ГМ — заявок в
   объекте кампании у остальных попросту нет (см. materializeCampaign). */
.applicants-badge {
  position: absolute; right: -4px; top: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--warn); color: #241a04;
  font-size: 10px; font-weight: 800; line-height: 16px; text-align: center;
  border: 2px solid var(--bg-1); box-sizing: content-box; cursor: pointer;
}
.member-item .avatar-wrap img { display: block; }

/* ---- закрепление и ручной порядок чатов -------------------------------- */
.chat-item-tools {
  position: absolute; right: 6px; bottom: 6px; display: flex; gap: 4px;
  opacity: 0; transition: opacity .12s;
}
.chat-item:hover .chat-item-tools, .chat-item-tools:focus-within { opacity: 1; }
.chat-item-tool {
  width: 24px; height: 24px; border-radius: 7px; border: none; cursor: pointer;
  background: var(--bg-4); color: var(--text-1);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.chat-item-tool svg { width: 13px; height: 13px; }
.chat-item-tool:hover { background: var(--accent); color: var(--on-accent); }
.chat-item-tool.active { background: var(--accent); color: var(--on-accent); }
.chat-item-tool.danger:hover { background: var(--danger); color: white; }
/* Метка «закреплён» у названия — видна и без наведения, иначе непонятно,
   почему чат стоит первым. */
.chat-pin-mark { display: inline-flex; vertical-align: -2px; margin-right: 4px; color: var(--accent); }
.chat-pin-mark svg { width: 13px; height: 13px; }
.chat-item .avatar-wrap { flex-shrink: 0; }

/* ---- догрузка истории вверх -------------------------------------------- */
.history-more-btn {
  display: block; margin: 8px auto 14px; padding: 7px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text-2);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.history-more-btn:hover { background: var(--bg-3); color: var(--text-0); }
.history-spinner { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 10px 0; }

/* ---- опасное действие как строка списка -------------------------------- */
/* Раньше «Закрыть кампанию» была отдельной кнопкой под карточкой и висела в воздухе,
   оторванная от раздела, к которому относится. Теперь это последняя строка той же
   карточки — выглядит как продолжение списка, а не как случайно уехавший элемент. */
.list-row.danger-row {
  width: 100%; border: none; border-bottom: none; background: transparent;
  color: var(--danger); font-weight: 700; font-family: inherit; font-size: 14px;
  justify-content: center; text-align: center;
}
.list-row.danger-row:hover { background: var(--danger-soft); }
.list-card .list-row:last-child { border-bottom: none; }

/* Раньше здесь время и служебные подписи насильно поднимались до
   полупрозрачного белого — на тёмных цветах персонажа выглядело верно, а на
   светлых (light-tinted, см. app.js/textOn()) читалось так же плохо, как и
   хардкод в .msg-name-time/.msg-deleted, который эта же правка убрала выше.
   color: inherit там уже подхватывает то же самое значение, которое
   bubble.style.color посчитал под конкретный цвет (textOn), — отдельная
   правка для .char-tinted ему больше не нужна. */

/* ---- меню чата в списке слева ------------------------------------------ */
/* Пункты меню с иконками: иконка не должна сжиматься, а текст — переноситься. */
.popover-item { display: flex; align-items: center; gap: 9px; }
.popover-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.popover-item.danger { color: var(--danger); }
.popover-item.danger:hover { background: var(--danger-soft); }

/* На тач-экранах наведения нет, а значит и инструменты строки чата никогда бы не
   появились — там показываем их всегда. Троеточие вместо четырёх кнопок как раз и
   позволяет это себе позволить, не загромождая строку. */
@media (max-width: 980px), (hover: none) {
  .chat-item-tools { opacity: 1; }
  .chat-item:hover .unread-badge { display: inline-block; }
  /* Кнопки лежат поверх строки, поэтому освобождаем под них место в превью.
     Именно margin, а не padding: overflow:hidden обрезает по границе padding-box,
     то есть текст спокойно заезжает в отступ, и padding-right ничего не решал. */
  .chat-item-sub { margin-right: 84px; }
}

/* Пункты меню чата не переносим: «Отметить прочитанным» вставало в две строки и
   ломало ровный ритм списка. */
/* Названия пунктов меню не переносим: короткая подпись, разорванная надвое,
   читается хуже, чем чуть более широкое меню. Но правило било по всем span'ам
   внутри — в том числе по пояснению под заголовком в выборе цвета фона: строка
   не переносилась, вылезала за края и оставляла попапу горизонтальную прокрутку.
   Пояснения (.muted) переносим как обычный текст. */
.popover-item span { white-space: nowrap; }
.popover-item span.muted { white-space: normal; display: block; line-height: 1.4; }
/* Ширину задаёт positionPopoverNear, но горизонтально попап уезжать не должен
   ни при каком содержимом — это страховка от того же класса ошибок. */
.popover { overflow-x: hidden; }
.popover-item { overflow-wrap: anywhere; }

/* ---- игральная кость на главной ---------------------------------------- */
.die-svg { width: 100%; height: 100%; display: block; }
/* perspective — на родителе, а не на кубе: сам куб (.die-cube) просто
   поворачивается в этом объёме, глубину задаёт она. */
.home-hero-icon { cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; perspective: 260px; }
.home-hero-icon:hover { filter: brightness(1.08); }
.home-hero-icon:active { transform: scale(.94); }
/* Настоящий куб из шести граней в 3D, а не одна плоская картинка на
   rotateX/rotateY: у плоскости на развороте видно ребро, а не соседнюю
   грань, и кубик «плющится» вместо того, чтобы катиться. Здесь же каждая
   грань — свой элемент, отодвинутый от центра на половину стороны (64px
   куба — сторона 32px до центра) и развёрнутый в свою сторону; JS
   (rollHomeDie в app.js) крутит .die-cube целиком через Web Animations API,
   приземляя его точно на выпавшую грань. */
.die-cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.die-face { position: absolute; inset: 0; backface-visibility: hidden; }
.die-face-1 { transform: translateZ(32px); }
.die-face-6 { transform: rotateY(180deg) translateZ(32px); }
.die-face-2 { transform: rotateY(90deg) translateZ(32px); }
.die-face-5 { transform: rotateY(-90deg) translateZ(32px); }
.die-face-3 { transform: rotateX(90deg) translateZ(32px); }
.die-face-4 { transform: rotateX(-90deg) translateZ(32px); }
/* Подскок — на самой иконке, отдельно от вращения куба внутри неё: так
   прыжок не мешает развороту, и наоборот. */
@keyframes die-bounce {
  0%   { transform: translateY(0) scale(1); }
  22%  { transform: translateY(-30px) scale(1.08); }
  45%  { transform: translateY(-6px) scale(.96); }
  62%  { transform: translateY(-14px) scale(1.03); }
  80%  { transform: translateY(-2px) scale(.99); }
  100% { transform: translateY(0) scale(1); }
}
.home-hero-icon.rolling { animation: die-bounce .78s cubic-bezier(.34, .8, .38, 1); }
@media (prefers-reduced-motion: reduce) {
  .home-hero-icon.rolling { animation: none; }
}

/* ---- карта игры (Owlbear Rodeo) ---------------------------------------- */
.map-empty { text-align: center; padding: 26px 12px 18px; }
.map-empty-ic { width: 54px; height: 54px; margin: 0 auto 12px; color: var(--text-3); }
.map-empty-ic svg { width: 100%; height: 100%; }
.map-actions { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 10px; }
.map-actions .footer-btn-row { display: flex; gap: 8px; }
.map-actions .footer-btn-row .btn { flex: 1; }
/* Ссылку показываем целиком и даём выделить: её нередко надо перекинуть
   в другой мессенджер, а длинный адрес не должен ломать вёрстку. */
.map-link-box {
  margin-top: 10px; padding: 9px 12px; border-radius: var(--radius-s);
  background: var(--bg-2); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-2); user-select: all;
  overflow-wrap: anywhere; word-break: break-word;
}

/* ---- награды поддержавшим: фон профиля --------------------------------- */
/* Шапка профиля лежит ПОВЕРХ фона, а не отдельной полосой над ним: подпись
   «Профиль» и разделительная линия отрезали картинку от верха окна и смотрелись
   рамкой. Кнопки остаются, но на прозрачном — им хватает собственной подложки. */
.modal-topbar.over-bg {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  background: transparent; border-bottom: none;
}
/* Кнопкам поверх картинки нужна своя подложка: на светлом кадре белый значок
   иначе теряется. */
.modal-topbar.over-bg .icon-btn {
  background: rgba(0,0,0,.35); color: #fff; border-radius: 50%;
  backdrop-filter: blur(2px);
}
.modal-topbar.over-bg .icon-btn:hover { background: rgba(0,0,0,.55); }
/* Шапка ушла из потока — оставляем содержимому место под ней, иначе аватарка
   упёрлась бы прямо в кнопки. */
.modal-sheet:has(.modal-topbar.over-bg) .modal-scroll { padding-top: 54px; }

/* Фон уходит под шапку карточки и растворяется книзу, чтобы текст поверх него
   оставался читаемым при любой картинке — включая яркую анимацию. */
.modal-scroll.has-profile-bg { position: relative; }
.modal-scroll.has-profile-bg::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 260px;
  background-image: var(--profile-bg); background-size: cover; background-position: center;
  z-index: 0; pointer-events: none;
}
.modal-scroll.has-profile-bg::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 260px;
  background: linear-gradient(to bottom, rgba(0,0,0,.35) 0%, rgba(0,0,0,.15) 45%, var(--bg-1) 100%);
  z-index: 0; pointer-events: none;
}
.modal-scroll.has-profile-bg > * { position: relative; z-index: 1; }

/* Замок у недоступной награды: строку показываем всем, чтобы про возможность
   узнали, но сразу видно, что она заперта. */
.supporter-lock { margin-left: auto; opacity: .55; font-size: 13px; }
.list-row .supporter-lock + .chev { margin-left: 6px; }

/* ---- поиск кампаний на телефоне -------------------------------------- */
@media (max-width: 700px) {
  /* Одна колонка и поля поуже — на узком экране сетка не нужна. */
  .public-campaign-list,
  .seek-gm-list { grid-template-columns: 1fr; padding: 4px 12px 32px; gap: 10px; }
  .pcc, .seek-gm { padding: 12px; }
  .pcc-top { margin: -12px -12px 8px; }
  /* Помельче: на телефоне карточка и так читается, а крупный шрифт съедал экран. */
  .pcc-title { font-size: 14px; }
  .pcc-desc, .seek-gm-about { font-size: 12px; -webkit-line-clamp: 2; }
  .pcc-meta { font-size: 11px; margin-bottom: 6px; }
  /* Теги — только значки. Что именно за система и метки, видно уже в карточке
     кампании; в списке от подписей больше шума, чем пользы. */
  .pcc .tag-chip, .seek-gm .tag-chip { font-size: 0; padding: 4px 7px; gap: 0; }
  .pcc .tag-chip svg, .seek-gm .tag-chip svg { width: 14px; height: 14px; }
}

/* ---- свёрнутый список чатов на ПК -------------------------------------- */
/* Колонку списка убираем из сетки целиком, а не прячем содержимое: иначе от неё
   осталась бы пустая полоса в 320px. */
.app.list-collapsed { grid-template-columns: 72px 1fr; }
.app.list-collapsed > .sidebar { display: none; }
@media (max-width: 980px) {
  /* На телефоне список и так уезжает наложением, отдельная кнопка не нужна:
     вернуть его можно повторным нажатием «Главная». */
  .app.list-collapsed { grid-template-columns: 64px 1fr; }
  .app.list-collapsed > .sidebar { display: flex; }
}

/* ---- просмотр картинки во весь экран ----------------------------------- */
/* В ленте фото ограничено по высоте: без этого одно изображение занимало
   пол-экрана и разговор приходилось пролистывать мимо него. */
.msg-image { max-height: 200px; max-width: 100%; width: auto; object-fit: cover; cursor: zoom-in; }

/* ---- альбом из нескольких фото в одном сообщении (до 5), как в Telegram --- */
.msg-image-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px;
  max-width: 320px; border-radius: 10px; overflow: hidden; margin-top: 4px;
}
/* Три фото — одно крупное сверху, два помельче под ним; пять — то же самое,
   а лишние два занимают отдельную полную строку внизу. Ровный 2×2 незачем
   ломать только у четвёрки — она и так укладывается без остатка. */
.msg-image-grid.count-3 .msg-image-grid-cell:first-child,
.msg-image-grid.count-5 .msg-image-grid-cell:last-child {
  grid-column: span 2;
}
.msg-image-grid-cell { position: relative; aspect-ratio: 1 / 1; overflow: hidden; cursor: zoom-in; }
.msg-image-grid-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }

.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: lightbox-in .12s ease-out;
}
@keyframes lightbox-in { from { opacity: 0; } to { opacity: 1; } }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; object-fit: contain; }
.lightbox-close {
  position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.14); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-close svg { width: 18px; height: 18px; }
.lightbox-close:hover { background: rgba(255,255,255,.24); }
/* Стрелки и счётчик — только когда фото в альбоме больше одного (см.
   openImageLightbox: multi). Свайп работает и без них, но на десктопе мышью
   удобнее ткнуть в стрелку, чем изображать перетаскивание. */
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px;
  border-radius: 50%; border: none; background: rgba(255,255,255,.14); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.lightbox-nav svg { width: 22px; height: 22px; }
.lightbox-nav:hover { background: rgba(255,255,255,.24); }
.lightbox-nav:disabled { opacity: .3; cursor: default; pointer-events: none; }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-count {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.5); color: #fff; font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
}

/* ---- главная на телефоне ------------------------------------------------ */
/* min-width:0 обязателен: .home-scroll — flex-элемент, а такой по умолчанию не
   сжимается уже своего содержимого, из-за чего главная вылезала за экран и
   правая половина оказывалась срезанной. */
.home-scroll { min-width: 0; }
@media (max-width: 700px) {
  /* На телефоне облачку отдаём почти всю ширину. При 72% справа оставалась широкая
     пустая полоса, а длинный текст при этом жался в узкий столбик и растягивался
     вниз на пол-экрана. На большом мониторе 72% по-прежнему уместны: там строка
     во всю ширину читалась бы тяжело. */
  .msg-row { max-width: 92%; }
  /* На телефоне 240px местами шире доступной колонки — берём долю экрана,
     чтобы край следующей карточки оставался видимым и было понятно, что лента
     листается вбок. */
  .mini-campaign-card { flex-basis: min(240px, 72vw); max-width: min(240px, 72vw); }
  .home-scroll { padding: 20px 14px 40px; }
  .home-hero { padding: 8px 0 22px; }
  .home-hero h1 { font-size: 21px; }
  .home-hero p { font-size: 13.5px; }
  .section-title { font-size: 16px; margin: 22px 0 4px; }
}

/* ---- фильтры: плотнее -------------------------------------------------- */
/* Заголовок в этих карточках уже блочный, а раньше после него стоял ещё и <br> —
   получался двойной перенос и полоса пустоты под каждым названием. */
.filter-type-row { padding: 10px; }
.filter-type-row b, .radio-card b { margin-bottom: 0; line-height: 1.3; }
.filter-type-row .muted, .radio-card .muted { display: block; line-height: 1.35; margin-top: 2px; }
.filter-type-list { gap: 6px; }

/* ---- ссылка-приглашение ------------------------------------------------ */
/* Ссылку показываем целиком и с переносом: обрезанная многоточием, она выглядит
   так, будто скопируется тоже обрезанной, и человек лезет выделять руками. */
.invite-box {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 12px 14px; margin: 10px 0 14px;
}
.invite-box code { font-family: monospace; font-size: 13px; color: var(--text-1); word-break: break-all; }
#invite-has .footer-btn-row { margin-top: 14px; }

/* ---- счётчик остатка символов ------------------------------------------ */
/* Стоит сбоку от поля и не занимает места в потоке: строка листа и без того
   тесная, а в чате счётчик появляется лишь под конец — от него не должно
   дёргаться всё поле ввода. */
.char-left {
  position: absolute; right: 8px; bottom: 4px;
  font-size: 11px; color: var(--text-3); pointer-events: none;
  background: var(--bg-1); border-radius: 6px; padding: 0 4px;
}
.char-left.low { color: var(--danger, #ef4444); font-weight: 700; }
.sheet-field-val, .composer-input-row { position: relative; }
/* У однострочных полей листа счётчик прижат к правому краю строки и
   поднят на уровень текста. */
.sheet-field-row:not(.wide) .char-left { bottom: 50%; transform: translateY(50%); right: 0; background: transparent; }

/* Строка с текстовым полем: название сверху, описание во всю ширину под ним.
   В узкой правой колонке от него оставался обрубок в одну строку без шанса
   дочитать, а на две тысячи знаков там места нет в принципе. */
.sheet-field-row.wide { flex-direction: column; align-items: stretch; gap: 6px; }
.sheet-field-row.wide .sheet-field-name {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  cursor: pointer; user-select: none;
}
.sheet-field-chev { display: inline-flex; color: var(--text-2); transition: transform .15s; }
.sheet-field-chev svg { width: 16px; height: 16px; }
.sheet-field-row.wide.collapsed .sheet-field-chev { transform: rotate(-90deg); }

.sheet-field-row.wide .sheet-field-val { justify-content: flex-start; text-align: left; }
/* pre-wrap — чтобы переносы строк, которые человек поставил в описании, остались
   переносами, а не схлопнулись в сплошной абзац. */
.sheet-field-row.wide .sheet-field-val > span {
  width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45;
}
/* Свёрнуто — две строки с многоточием: видно, что поле заполнено, но лист
   не разъезжается. Развёрнуто — весь текст. */
.sheet-field-row.wide.collapsed .sheet-field-val > span {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sheet-field-row.wide textarea {
  width: 100%; resize: vertical;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-s, 8px);
  color: var(--text-1); padding: 8px 10px 18px; font: inherit; font-size: 14px; outline: none;
  transition: height .15s;
}
/* У поля для ввода сворачивание меняет высоту, а не прячет содержимое: печатать
   в обрезанное overflow:hidden поле нельзя — курсор уезжал бы из виду. */
.sheet-field-row.wide.collapsed textarea { height: 56px; }
.sheet-field-row.wide:not(.collapsed) textarea { height: 150px; }
.sheet-field-row.wide textarea:focus { border-color: var(--accent); }

/* ---- обрезка изображения ----------------------------------------------- */
/* Рамка задана снаружи через --crop-ratio: под аватарку она квадратная, под фон
   вытянутая. Картинка внутри двигается transform'ом, а не изменением размеров, —
   так перетаскивание не вызывает пересчёт разметки на каждый кадр. */
.crop-stage {
  /* Высоту ограничиваем через max-width, а не max-height: max-height спорит с
     aspect-ratio и молча растягивает кадр — квадратная рамка под аватарку
     превращалась в овал, и обрезка врала о том, что попадёт в результат. */
  position: relative; width: 100%; aspect-ratio: var(--crop-ratio, 1);
  max-width: calc(52vh * var(--crop-ratio, 1)); margin: 4px auto 10px; overflow: hidden;
  background: #000; border-radius: var(--radius-m); touch-action: none; cursor: grab;
  user-select: none;
}
.crop-stage.dragging { cursor: grabbing; }
.crop-stage img {
  position: absolute; top: 0; left: 0; transform-origin: 0 0;
  max-width: none; max-height: none; will-change: transform; pointer-events: none;
}
/* Сетка третей поверх кадра — привычная подсказка при кадрировании. */
.crop-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent 33.33%, rgba(255,255,255,.22) 33.33%, rgba(255,255,255,.22) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
    linear-gradient(to right, transparent 66.66%, rgba(255,255,255,.22) 66.66%, rgba(255,255,255,.22) calc(66.66% + 1px), transparent calc(66.66% + 1px)),
    linear-gradient(to bottom, transparent 33.33%, rgba(255,255,255,.22) 33.33%, rgba(255,255,255,.22) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
    linear-gradient(to bottom, transparent 66.66%, rgba(255,255,255,.22) 66.66%, rgba(255,255,255,.22) calc(66.66% + 1px), transparent calc(66.66% + 1px));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
  border-radius: var(--radius-m);
}
.crop-stage.round .crop-shade { border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35), 0 0 0 999px rgba(0,0,0,.55); }
.crop-zoom-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px 12px; }
.crop-zoom-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.crop-zoom-ic { color: var(--text-2); font-size: 16px; width: 14px; text-align: center; }
.crop-ratio-row { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 6px; }
.crop-ratio-row .chip.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ---- модификатор поля --------------------------------------------------- */
/* Строка формулы прижата к своей галочке: визуально это её продолжение, а не
   отдельная настройка, поэтому убираем скругление сверху и зазор между ними. */
.tag-toggle.has-sub { border-bottom-left-radius: 0; border-bottom-right-radius: 0; margin-bottom: 0; }
.tag-toggle-sub {
  background: var(--bg-2); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-m) var(--radius-m); padding: 10px 12px 12px; margin-bottom: 10px;
}
.tag-toggle-sub p { margin: 6px 0 0; }
.tag-toggle-sub code { background: var(--bg-3); border-radius: 5px; padding: 1px 5px; font-size: 12px; }

/* Значение и модификатор — две колонки, чтобы в блоке характеристик числа
   стояли ровно друг под другом, а не разъезжались по длине значения. */
.sheet-field-base { width: 84px; display: flex; justify-content: flex-end; }
.sheet-field-base input { width: 100%; }
/* Модификатор обведён кружком: в настолках это привычный вид «16 (+3)», и по
   кружку сразу видно, где производное значение, а где то, что вводят руками. */
/* Модификатор — просто второе число рядом с основным. Кружок вокруг него
   съедал по сорок точек высоты в каждой строке листа и выглядел кнопкой,
   которой не был; цвета и насыщенности хватает, чтобы отличить производное
   значение от введённого. */
.sheet-field-mod {
  display: inline-flex; align-items: center; justify-content: flex-end;
  min-width: 26px; color: var(--accent-hover);
  font-weight: 700; font-size: 14px; line-height: 1.2; white-space: nowrap;
}
.sheet-field-mod.dash { color: var(--text-3); font-weight: 400; }
.sheet-field-mod.text { min-width: 0; }

/* ---- правка значения поля ---------------------------------------------- */
/* Стрелки «больше-меньше» у числовых полей убираем везде: попасть по ним
   пальцем трудно, а промах меняет значение. Числа вводят с клавиатуры. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Строка листа, которую можно править, отзывается на наведение — иначе не
   догадаться, что по ней вообще нажимают. Только на устройствах с настоящей
   мышью (hover: hover): на тачскрине браузер применяет :hover по тапу и не
   снимает его до следующего касания в другое место — подсветка «залипала» на
   поле, и сплошной --bg-2 поверх цветного фона персонажа читался как чёрный
   блок на весь текст. Жалоба игрока была именно про это. */
.sheet-field-row.editable .sheet-field-val { cursor: pointer; border-radius: 8px; }
@media (hover: hover) {
  .sheet-field-row.editable .sheet-field-val:hover { background: var(--bg-2); }
}
.sheet-field-row.editable .sheet-field-val:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Поле в окне правки: счётчик остатка стоит в его правом нижнем углу, поэтому
   контейнеру нужна точка отсчёта, а самому полю — место под счётчик. */
.efv-field { position: relative; margin-bottom: 4px; }
.efv-field .text-input { width: 100%; padding-bottom: 20px; }
.efv-field textarea.text-input { min-height: 130px; resize: vertical; line-height: 1.45; }
#efv-mod-computed { margin-top: 6px; }

/* Кружок модификатора со сломанной формулой. Раньше в него подставлялся сам
   текст формулы — человек видел «(:оп:)×2^…» вместо числа и не понимал, что
   формула вообще не принята. Теперь это знак «!», а причина — в подсказке. */
.sheet-field-mod.err { color: var(--danger); font-weight: 700; cursor: help; }
#efv-mod-computed.err { color: var(--danger); }

/* Предпросмотр формулы под полем ввода и пунктир под значением-формулой в
   листе: по нему видно, что число не введено руками, а посчитано. */
.efv-preview { margin: 2px 0 10px; }
.efv-preview.err { color: var(--danger); }
.sheet-field-val .has-formula { border-bottom: 1px dashed var(--text-3); cursor: help; }

/* ---- каналы кампании ---------------------------------------------------- */
/* Список лент под кампанией. Отступ слева выравнивает его под аватаркой
   кампании — так видно, что это её содержимое, а не отдельные чаты. */
.channel-toggle {
  background: none; border: none; padding: 0 2px; margin-left: -4px; cursor: pointer;
  color: var(--text-3); display: flex; align-items: center; flex-shrink: 0;
  transition: transform .15s;
}
.channel-toggle svg { width: 14px; height: 14px; }
.channel-toggle:not(.open) { transform: rotate(-90deg); }
.channel-toggle:hover { color: var(--text-1); }

.channel-list { padding: 2px 0 6px; }
.channel-item {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px 14px 5px 40px; color: var(--text-2); font-size: 13.5px;
  border-radius: 8px; margin: 0 6px;
}
.channel-item:hover { background: var(--bg-2); color: var(--text-1); }
.channel-item.active { background: var(--bg-3); color: var(--text-0); font-weight: 600; }
/* Линия вместо "#": идёт от первой ленты списка до открытой сейчас — видно,
   в каком канале сейчас читаешь, не разглядывая подсветку каждой строки. */
.channel-line-mark { width: 2px; align-self: stretch; flex-shrink: 0; border-radius: 1px; }
.channel-item.channel-line .channel-line-mark { background: var(--accent); }
.channel-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.channel-lock { display: inline-flex; flex-shrink: 0; margin-right: 4px; color: var(--text-3); }
.channel-lock svg { width: 12px; height: 12px; }
.channel-mute-btn {
  background: none; border: none; padding: 2px; margin-left: auto; flex-shrink: 0;
  color: var(--text-3); cursor: pointer; opacity: 0; display: flex; align-items: center;
}
.channel-mute-btn svg { width: 14px; height: 14px; }
.channel-item:hover .channel-mute-btn, .channel-item.muted-channel .channel-mute-btn { opacity: 1; }
.channel-mute-btn:hover { color: var(--text-0); }

/* Окно настройки каналов — тут решётка перед именем осталась: это просто
   список для редактирования, без «текущего канала» и линии к нему. */
.channel-hash { color: var(--text-3); font-weight: 700; }
.channel-edit-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; flex-wrap: wrap; }
.channel-edit-row .channel-name-input { flex: 1; min-width: 120px; }
.channel-edit-row .icon-btn.small { flex-shrink: 0; }
.channel-edit-row .icon-btn.small.active { color: var(--accent); border-color: var(--accent); }
.channel-edit-row .icon-btn.danger { color: var(--danger); }
.channel-add-row { display: flex; gap: 8px; margin-top: 12px; }
.channel-add-row .text-input { flex: 1; min-width: 0; }

/* ---- справочник кампании ------------------------------------------------ */
.lore-section { border-bottom: 1px solid var(--border); }
.lore-section:last-of-type { border-bottom: none; }
.lore-section-title {
  display: flex; align-items: center; gap: 8px; padding: 11px 2px;
  cursor: pointer; user-select: none; font-weight: 700;
}
.lore-section-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lore-chev { display: inline-flex; color: var(--text-2); transition: transform .15s; }
.lore-chev svg { width: 16px; height: 16px; }
.lore-section.collapsed .lore-chev { transform: rotate(-90deg); }
.lore-section.collapsed .lore-items,
.lore-section.collapsed .chest-cards { display: none; }
.lore-items { padding: 0 0 10px 24px; }
.lore-item { padding: 8px 0; }
.lore-item-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.lore-item-title .icon-btn.small { margin-left: auto; }
.lore-item-title .icon-btn.danger { color: var(--danger); margin-left: 0; }
/* pre-wrap — записи ведущего пишутся абзацами, и переносы должны остаться. */
.lore-item-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-1); font-size: 13.5px; line-height: 1.5; margin-top: 3px; }
.lore-add-item { padding: 6px 0; color: var(--accent-hover); }

/* ---- своя карта на сетке ------------------------------------------------ */
/* Клетки рисуем повторяющимся градиентом, а не элементами: поле 40×40 — это
   1600 узлов, и каждая перерисовка ощутимо тормозила бы на телефоне. */
/* Окно, в котором лежит поле. Высоту ограничиваем, чтобы увеличенная карта
   прокручивалась внутри окна, а не растягивала всё окно карты до бесконечности. */
.grid-map-wrap {
  width: 100%; overflow: auto; margin-bottom: 8px;
  max-height: min(78vh, 720px); overscroll-behavior: contain;
}
.grid-map {
  position: relative; width: 100%;
  /* У гексов ряд ниже, чем клетка широка (--map-row-ratio = √3/2), иначе
     шестиугольники вышли бы растянутыми по вертикали. У квадратов множитель 1,
     и формула сводится к прежней. */
  aspect-ratio: var(--map-cols, 12) / calc(var(--map-rows, 12) * var(--map-row-ratio, 1));
  background-size: cover; background-position: center; background-repeat: no-repeat;
  background-color: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius-m);
  touch-action: none; user-select: none;
}
/* Клетки — отдельным слоем поверх фона, а не ещё одним слоем background у того
   же элемента: смешивать картинку и линии в одном свойстве нельзя — у слоёв
   разные размеры и повторение, и сетка разъезжалась относительно фигур.
   Здесь размер клетки задан прямо в процентах от стороны, поэтому линии всегда
   совпадают с расчётом положения фигур. */
/* На гексах линии рисует отдельный слой (см. hexGridLayer) — квадратную сетку
   при этом надо убрать, иначе они наложатся друг на друга. */
.grid-map.hex::after { display: none; }
.map-hex-layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; border-radius: inherit;
}
.grid-map::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.14) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.14) 1px, transparent 1px);
  background-size:
    calc(100% / var(--map-cols, 12)) 100%,
    100% calc(100% / var(--map-rows, 12));
}
.map-token {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 2px; cursor: default;
}
.map-token.movable { cursor: grab; }
.map-token.dragging { cursor: grabbing; z-index: 5; }
.map-token img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--bg-3); box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
/* Подпись под фигурой прячем на мелкой сетке: при сорока клетках в ряд она всё
   равно нечитаема и превращается в кашу. */
.map-token-name {
  position: absolute; bottom: -13px; font-size: 9px; color: var(--text-1);
  background: rgba(0,0,0,.6); border-radius: 4px; padding: 0 3px;
  max-width: 200%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none;
}
.grid-map[style*="--map-cols: 2"] .map-token-name,
.grid-map[style*="--map-cols: 3"] .map-token-name { display: none; }

.map-size-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.map-size-row .text-input { width: 64px; text-align: center; }
.map-token-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.map-token-row > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.map-token-row .icon-btn.danger { color: var(--danger); }

/* Выбор размера фигуры в списке — узкий, чтобы не отжимать имя. */
.map-token-size { width: 74px; padding: 4px 6px; font-size: 12.5px; flex-shrink: 0; }
/* У крупной фигуры подпись не должна вылезать за её пределы. */
.map-token-name { max-width: 130%; }

/* Заглушённый чат: значок рядом с названием и приглушённая строка канала. */
.chat-mute-mark { display: inline-flex; margin-left: 5px; color: var(--text-3); vertical-align: -2px; }
.chat-mute-mark svg { width: 13px; height: 13px; }
.channel-item.muted-channel { opacity: .55; }

/* ---- инструменты карты --------------------------------------------------- */
/* Панель инструментов карты. Отделяем от сегментов сверху отступом и рамкой:
   раньше четыре серые таблетки шли впритык под ними и читались как их
   продолжение. */
.map-tools {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  margin: 10px 0 8px; padding: 4px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
}
.map-tool {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 11px; border-radius: 9px;
  background: transparent; border: none; color: var(--text-2);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.map-tool svg { width: 16px; height: 16px; flex-shrink: 0; }
.map-tool:hover { background: var(--bg-3); color: var(--text-0); }
.map-tool.active { background: var(--accent); color: var(--on-accent); }
/* На узком экране подписи прячем: четыре слова в ряд не помещаются, и панель
   переносилась на две строки, съедая высоту у самой карты. Название остаётся
   во всплывающей подсказке и на долгом нажатии. */
@media (max-width: 460px) {
  .map-tool span { display: none; }
  .map-tool { padding: 8px 12px; }
}
.map-measure { margin-left: auto; font-size: 12.5px; color: var(--accent-hover); font-weight: 700; }
.map-paint-colors { display: flex; align-items: center; gap: 5px; margin-left: auto; flex-wrap: wrap; row-gap: 6px; justify-content: flex-end; }
.map-paint-swatch {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent;
  padding: 0; cursor: pointer; flex-shrink: 0;
}
.map-paint-swatch.active { border-color: var(--text-0); }
.map-paint-swatch.eraser {
  background: var(--bg-3); border-color: var(--border); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.map-paint-swatch.eraser svg { width: 12px; height: 12px; }
.map-paint-custom {
  width: 84px; height: 22px; border-radius: 6px; border: 2px solid var(--border);
  background: var(--bg-2); color: var(--text-0); font-family: inherit; font-size: 11px;
  padding: 0 7px; flex-shrink: 0;
}
.map-paint-custom::placeholder { color: var(--text-3); }
.map-paint-custom.active { color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.5); }
/* Пипетка — та же круглая кнопка, что ластик. */
.map-paint-swatch.picker {
  background: var(--bg-3); border-color: var(--border); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.map-paint-swatch.picker svg { width: 12px; height: 12px; }
/* Нативный выбор цвета притворяется таким же кружком. */
.map-paint-swatch.native { padding: 0; overflow: hidden; background: var(--bg-3); border-color: var(--border); }
.map-paint-swatch.native::-webkit-color-swatch-wrapper { padding: 0; }
.map-paint-swatch.native::-webkit-color-swatch { border: none; border-radius: 50%; }
.map-paint-swatch.native::-moz-color-swatch { border: none; border-radius: 50%; }

/* Рамка вокруг поля нужна, чтобы подписям клеток было где стоять: сами они
   вне поля, иначе закрывали бы первый ряд карты. */
/* Увеличение — это ширина рамки сверх ширины окна: всё внутри поля задано в
   процентах от его стороны, поэтому сетка, фигуры, туман и подписи клеток
   пересчитываются сами, и отдельный слой масштабирования не нужен. */
.grid-map-frame { position: relative; width: calc(100% * var(--map-zoom, 1)); }
.grid-map-frame.with-coords { padding: 16px 0 0 18px; }
/* Подписи клеток не перехватывают жесты: на увеличенной карте они наезжают на
   поле, и тянуть карту за них должно быть можно. */
.map-coords { position: absolute; display: flex; color: var(--text-3); font-size: 9px; line-height: 1; pointer-events: none; }
/* Сдвиг на величину прокрутки держит подписи у видимого края окна. */
.map-coords-top { top: 3px; left: 18px; right: 0; transform: translateY(var(--map-scroll-y, 0px)); }
.map-coords-side { top: 16px; bottom: 0; left: 0; width: 16px; flex-direction: column; transform: translateX(var(--map-scroll-x, 0px)); }
/* Прижатые подписи лежат уже поверх карты — им нужна подложка, иначе они
   теряются на картинке фона. */
.grid-map-wrap.zoomed .map-coords span { background: rgba(0,0,0,.62); border-radius: 3px; }
.map-coords span { display: flex; align-items: center; justify-content: center; overflow: hidden; }

.grid-map.tool-ruler, .grid-map.tool-ping { cursor: crosshair; }
.grid-map.tool-fog { cursor: cell; }
/* Увеличенную карту можно тянуть за пустое место — курсор должен об этом
   говорить. У линейки, метки и тумана жест занят, там курсор свой. */
.grid-map-wrap.zoomed .grid-map:not(.tool-ruler):not(.tool-ping):not(.tool-fog) { cursor: grab; }
.grid-map-wrap.panning .grid-map { cursor: grabbing; }

/* Линейка: тонкая нить от клетки к клетке. Поворачиваем вокруг левого края,
   чтобы начало оставалось ровно в исходной клетке. */
.map-ruler {
  position: absolute; height: 3px; background: var(--accent);
  transform-origin: 0 50%; pointer-events: none;
  /* Тёмная обводка поверх свечения: на светлом фоне карты одно свечение
     сливалось с картинкой и нить было не видно. */
  box-shadow: 0 0 0 1px rgba(0,0,0,.75), 0 0 8px var(--accent);
}
/* Точки на концах: без них не понять, от какой клетки до какой меряем. */
.map-ruler::before, .map-ruler::after {
  content: ""; position: absolute; top: 50%; width: 9px; height: 9px;
  margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px rgba(0,0,0,.75);
}
.map-ruler::before { left: 0; }
.map-ruler::after { left: 100%; }
/* Число рядом с концом линейки: значение в углу панели приходится искать
   глазами, а считают его, глядя на саму карту. */
.map-ruler-label {
  position: absolute; transform: translate(10px, -50%); pointer-events: none;
  background: rgba(0,0,0,.78); color: var(--text-0); border: 1px solid var(--accent);
  border-radius: 6px; padding: 1px 6px; font-size: 12px; font-weight: 700; white-space: nowrap;
}

/* Показатель увеличения. Виден только когда карта увеличена — на обычном
   масштабе сообщать нечего. Нажатие возвращает карту в окно целиком. */
.map-zoom { font-variant-numeric: tabular-nums; }

/* Метка внимания: восклицательный знак в круге, от которого без остановки
   расходятся волны. Знак стоит, пока метку не снимут, — вспышку на две секунды
   не видел тот, кто отвлёкся или открыл карту позже. */
.map-ping { position: absolute; pointer-events: none; }
/* Две волны с разбегом в секунду: одна выглядела бы вздрагиванием, а не
   расхождением кругов. Рисуем их на пустых слоях поверх знака. */
.map-ping::before, .map-ping::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--accent); animation: map-ping 2s ease-out infinite;
}
.map-ping::after { animation-delay: 1s; }
@keyframes map-ping {
  0%   { transform: scale(.7); opacity: .9; }
  100% { transform: scale(2.1); opacity: 0; }
}
/* Знак — фигуры в системе координат картинки, а не буква: так он тянется вместе
   с клеткой и читается и на мелкой сетке, и при увеличении. */
.map-ping-mark { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.map-ping-mark circle { fill: var(--accent); }
.map-ping-mark rect, .map-ping-mark .dot { fill: var(--on-accent, #fff); }
@media (prefers-reduced-motion: reduce) {
  /* Знак остаётся, волны — нет: постоянное движение на карте мешает читать её. */
  .map-ping::before, .map-ping::after { animation: none; opacity: .5; }
}

/* Туман: игроку сплошной, ведущему полупрозрачный — ему нужно видеть и карту
   под ним, и то, что именно закрыто. */
.map-fog { position: absolute; inset: 0; pointer-events: none; }
.map-fog-cell { position: absolute; background: #0b0b0e; }
/* Ведущему туман показываем штриховкой, а не просто затемнением: на тёмной
   пустой карте разница между 31 и 19 по яркости неразличима, и было непонятно,
   что именно закрыто. Полосы читаются при любом фоне — и на картинке, и без. */
.map-fog.gm .map-fog-cell {
  background:
    repeating-linear-gradient(45deg,
      rgba(120, 140, 255, .20) 0 4px,
      rgba(0, 0, 0, .55) 4px 8px);
  outline: 1px solid rgba(140, 160, 255, .22); outline-offset: -1px;
}
/* Выключенный туман виден только ведущему и еле-еле: он никуда не делся и
   включится тем же переключателем, но сейчас никого не закрывает — и путать
   его с работающим нельзя. */
.map-fog.off .map-fog-cell { opacity: .3; }

/* На гексах клетка тумана должна быть шестиугольником, иначе она залезает на
   соседние клетки углами и оставляет непрокрашенные щели.
   scaleY: коробка клетки по высоте — шаг ряда (√3/2 ширины), а сам
   шестиугольник выше в 4/3 раза. Масштаб идёт от центра, поэтому фигура
   вырастает симметрично и садится ровно на своё место.
   Точки обрезки — вершины «остроконечного» шестиугольника: плечи у него на
   четверти и трёх четвертях высоты. */
.grid-map.hex .map-fog-cell {
  transform: scaleY(1.33333);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  outline: none;
}

/* Цвет клетки — полупрозрачная заливка поверх карты (зона, укрытие, ловушка):
   видна всем, не только ведущему, поэтому не такая плотная, как туман. */
.map-colors { position: absolute; inset: 0; pointer-events: none; }
.map-color-cell { position: absolute; opacity: .45; }
.grid-map.hex .map-color-cell {
  transform: scaleY(1.33333);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

/* Скрытая фигура видна только ведущему — помечаем её штриховкой, иначе он
   забудет, что игроки её не видят. */
.map-token.hidden-token img { opacity: .55; border-style: dashed; }

/* ---- ответ, шёпот, «вне игры», поиск ------------------------------------ */

/* Цитата над текстом. Полоска слева — привычный знак «это чужие слова»,
   и она же отделяет цитату от самого сообщения, которое идёт следом. */
.msg-quote {
  display: block; border-left: 3px solid currentColor; padding: 2px 0 2px 7px;
  margin-bottom: 5px; font-size: 12.5px; line-height: 1.35; opacity: .78; cursor: pointer;
  max-width: 100%; overflow: hidden;
}
.msg-quote b { display: block; font-weight: 700; }
.msg-quote span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-quote:hover { opacity: 1; }

/* Кому шепнули. Мелкой строкой сверху: важно знать до того, как прочитал —
   иначе легко ответить вслух на то, что сказали на ухо. */
.msg-whisper-tag { font-size: 11.5px; font-weight: 700; opacity: .75; margin-bottom: 3px; letter-spacing: .02em; }
.whisper-msg .msg-bubble {
  border: 1px dashed var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-2));
}
/* Реплика вне игры — приглушённая и без цвета персонажа: она не часть сцены,
   и в ленте не должна спорить с ней за внимание. */
.ooc-msg .msg-bubble {
  background: transparent; border: 1px dashed var(--border);
  color: var(--text-2); font-style: italic;
}
.ooc-msg .msg-author { opacity: .7; }

/* Светлый цвет персонажа: тёмный текст уже выставлен разметкой, здесь нужна
   только окантовка, иначе белая реплика на светлой теме теряет границы. */
.msg-bubble.light-tinted { box-shadow: inset 0 0 0 1px rgba(0,0,0,.14); }

.composer-strip {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px;
  border-left: 3px solid var(--accent); background: var(--bg-2);
  border-radius: var(--radius-s); margin: 0 8px 6px;
  font-size: 12.5px; color: var(--text-1);
}
.composer-strip.whisper { border-left-color: var(--warning, #f0a63a); }
.composer-strip-body { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-strip b { color: var(--text-0); }
.tbtn.active { background: var(--accent); color: var(--on-accent); }
.composer-field.ooc-draft { font-style: italic; opacity: .85; }
.popover-note { padding: 7px 10px; font-size: 12px; color: var(--text-2); line-height: 1.35; }
.popover-item.active { color: var(--accent-hover); }

.icon-btn.active { color: var(--accent-hover); }

/* ---- полоса, инвентарь, бросок из листа --------------------------------- */

/* Полоса занимает всю ширину строки: два числа и заполнение в узкую колонку
   справа не помещаются, а смысл полосы именно в том, чтобы видеть остаток
   не читая цифр. */
.sheet-field-row.bar-row { flex-wrap: wrap; }
.sheet-field-row.bar-row .sheet-field-val { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.sheet-bar {
  flex: 1; height: 8px; border-radius: 999px; overflow: hidden;
  background: var(--bg-3); box-shadow: inset 0 0 0 1px var(--border);
}
.sheet-bar i { display: block; height: 100%; background: var(--accent); transition: width .18s ease; }
.sheet-bar-nums { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-1); white-space: nowrap; }
/* Модификатор полосы — число сразу за «текущее / максимум». Не растягиваем его
   и не даём отдельной колонки: полосе нужна вся оставшаяся ширина. */
.sheet-field-row.bar-row .sheet-field-mod { flex: 0 0 auto; min-width: 0; }

.sheet-inv { margin: 2px 0 0; padding-left: 18px; }
.sheet-inv li { font-size: 13.5px; line-height: 1.45; color: var(--text-1); overflow-wrap: anywhere; }

/* Кубик у названия поля, а не у значения: значение — это кнопка правки, и два
   действия на одной зоне перехватывали бы друг друга. */
.sheet-roll-btn {
  border: none; background: none; color: var(--accent-hover); cursor: pointer;
  padding: 0 4px; margin-left: 4px; vertical-align: -3px; line-height: 1;
}
.sheet-roll-btn svg { width: 15px; height: 15px; }
.sheet-roll-btn:hover { color: var(--accent); }

/* ---- общая библиотека --------------------------------------------------- */
.library-search-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.library-search-row .text-input { flex: 1; }
.library-card {
  border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 10px 12px; margin-bottom: 10px; background: var(--bg-2);
}
.library-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.library-card-head b { font-size: 14.5px; }
.library-card-desc { font-size: 13px; color: var(--text-1); margin: 6px 0; overflow-wrap: anywhere; }
.library-card .footer-btn-row { margin-top: 8px; }
.chip.small { font-size: 11.5px; padding: 1px 7px; }

/* Непрочитанные на строке канала: цифра справа и заметнее сам заголовок. */
.channel-item.has-unread .channel-name { color: var(--text-0); font-weight: 700; }
.channel-unread {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 700; line-height: 1;
}
/* Заглушённый канал не кричит цифрой: она остаётся, но приглушённой — иначе
   глушение теряет смысл. */
.channel-item.muted-channel .channel-unread { background: var(--bg-3); color: var(--text-2); }

/* ---- связи между записями книги ----------------------------------------- */
/* Связь выглядит ссылкой, но остаётся внутри страницы: она ведёт к другой
   записи книги, а не наружу, поэтому без подчёркивания и без синевы браузера. */
.lore-link { color: var(--accent-hover); cursor: pointer; border-bottom: 1px dashed currentColor; }
.lore-link:hover { color: var(--accent); }
/* Ссылка на несуществующую запись: видна, но приглушена — молча превратить её
   в обычный текст значило бы скрыть опечатку от автора. */
.lore-link.missing { color: var(--text-3); border-bottom-style: dotted; cursor: help; }
.lore-backlinks { margin-top: 5px; font-size: 12.5px; line-height: 1.5; }
.lore-link-bar { margin: 6px 0 12px; }
.lore-link-bar .btn { margin-bottom: 4px; }
/* Подсветка записи, к которой перешли по связи: без неё в длинном разделе
   непонятно, куда именно попал. */
@keyframes lore-flash { from { background: color-mix(in srgb, var(--accent) 35%, transparent); } to { background: transparent; } }
.lore-item.lore-highlight { animation: lore-flash 1.6s ease-out; border-radius: 8px; }

/* ---- сундучок: карточки предметов ----------------------------------------- */
/* Карточка целиком кликабельна для правки (внутри самого сундучка) — большая
   цель нажатия важнее на телефоне, чем на десктопе, где промахнуться мимо
   мелкой кнопки проще, чем кажется. */
.chest-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px;
  border-radius: var(--radius-m); border: 1px solid var(--border); margin-bottom: 8px;
}
.chest-item.editable { cursor: pointer; }
.chest-item.editable:hover { border-color: var(--accent); }
.chest-item-img {
  width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
  background: var(--bg-3);
}
/* Заглушка для предмета без картинки — та же коробка, что и на вкладке
   «Предметы» персонажа: один и тот же смысл, один и тот же знак. */
.chest-item-img-empty { display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.chest-item-img-empty svg { width: 22px; height: 22px; }
.chest-item-body { flex: 1; min-width: 0; }
.chest-item-title { font-weight: 700; font-size: 14.5px; overflow-wrap: anywhere; }
.chest-item-desc {
  font-size: 12.5px; color: var(--text-2); margin-top: 3px; white-space: pre-wrap;
  overflow-wrap: anywhere; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chest-item [data-chest-visible] { margin-left: auto; flex-shrink: 0; }
/* Скрытый от участников предмет — приглушённый значок: то же самое различие,
   что у «глаза» в поле листа персонажа, тем же самым цветом. */
.chest-item [data-chest-visible] svg { color: var(--text-3); }
.chest-item [data-chest-visible].chest-visible-on svg { color: var(--accent-hover); }

/* Витрина открытых предметов внутри «Справочника»: та же карточка, но без
   кнопки-глаза. Тап раскрывает полное описание (в карточке оно ужато до двух
   строк), тап по картинке — во весь экран. */
.chest-cards { padding: 4px 0 10px 24px; }
.chest-cards .chest-item { cursor: pointer; }
.chest-cards .chest-item.open .chest-item-desc {
  display: block; -webkit-line-clamp: unset; overflow: visible;
}

/* Фишка из своей картинки — со скруглённым квадратом, а не кружком: круг
   читается как «лицо», а сюда ставят дверь, сундук или стаю волков. */
.map-token.img-token img { border-radius: 6px; border-color: var(--text-3); }

/* Заголовок сворачиваемого поля на пальцевом вводе. Строка имени высотой в
   девятнадцать точек — это меньше половины подушечки пальца: промах попадал
   либо мимо, либо в значение, и вместо сворачивания открывалось окно правки.
   Только для сенсорного ввода: мышью и так попадают, а на ПК лишние отступы
   растягивали бы лист. */
@media (pointer: coarse) {
  .sheet-field-row.wide .sheet-field-name { padding: 10px 0; margin: -6px 0; }
  .sheet-field-chev svg { width: 20px; height: 20px; }
  .sheet-section-title { padding-top: 6px; padding-bottom: 6px; }
}

/* Отметка «ведёт регулярно» на карточке в поиске. Зелёная и рядом с местами —
   игрок выбирает кампанию по двум вопросам: «есть ли место» и «не умрёт ли
   она через неделю», и ответы должны стоять рядом. */
.pcc-badge.regular {
  background: color-mix(in srgb, var(--success, #1ecb8f) 22%, var(--bg-2));
  color: var(--success, #1ecb8f);
  border: 1px solid color-mix(in srgb, var(--success, #1ecb8f) 45%, transparent);
  gap: 3px;
}
.pcc-badge.regular svg { width: 12px; height: 12px; }

/* ---- соло-приключения ---------------------------------------------------- */
.view-solo { display: flex; flex-direction: column; overflow: auto; }
.solo-hint { padding: 0 14px 6px; }
.solo-list { padding: 0 14px 20px; }
.solo-card {
  border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 12px 14px; margin-bottom: 10px; background: var(--bg-2);
}
.solo-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.solo-card-head b { font-size: 15px; }
.solo-card-desc { font-size: 13px; color: var(--text-1); margin: 6px 0; overflow-wrap: anywhere; }
.solo-card .footer-btn-row { margin-top: 10px; }
/* Без flex:1 «Редактировать» не сжимался — по умолчанию флекс-элемент не уже
   ширины своего текста, и вторая кнопка вылезала за карточку. min-width:0
   снимает этот пол, раз кнопки и так делят строку поровну. */
.solo-card .footer-btn-row .btn { flex: 1; min-width: 0; }

/* Сам текст шага — крупнее обычного: читают его как книгу, а не проглядывают. */
.solo-scene {
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 15.5px; line-height: 1.6; color: var(--text-0); margin-bottom: 16px;
}
/* Варианты — именно карточками в ряд: по ним видно, что история разветвляется,
   а список ссылок этого не сообщает. На узком экране становятся друг под другом. */
.solo-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .solo-choices { grid-template-columns: 1fr; } }
.solo-choice {
  border: 1px solid var(--accent); border-radius: var(--radius-m);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-2));
  color: var(--text-0); padding: 14px; font-size: 14px; line-height: 1.45;
  text-align: left; cursor: pointer; min-height: 76px;
  transition: background .15s, transform .08s;
}
.solo-choice:hover { background: color-mix(in srgb, var(--accent) 26%, var(--bg-2)); }
.solo-choice:active { transform: scale(.985); }

.solo-node { border: 1px solid var(--border); border-radius: var(--radius-m); padding: 10px; margin: 10px 0; }
.solo-node.start { border-color: var(--accent); }
.solo-node-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.solo-node-head b { flex: 1; font-size: 13.5px; }
.solo-choice-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.solo-choice-row .text-input { flex: 1; min-width: 0; }
.solo-choice-row select { flex: 0 0 130px; }

/* ---- советы и помощь ----------------------------------------------------- */
.tips-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.tips-item:hover { background: var(--bg-2); }
.tips-item-ic {
  flex: 0 0 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-3); color: var(--accent-hover);
}
.tips-item-ic svg { width: 21px; height: 21px; }
.tips-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tips-item-text b { font-size: 14.5px; }
.tips-item-text .muted { line-height: 1.4; }

/* Страница урока: одна мысль на экран, поэтому текст крупнее обычного —
   его читают, а не проглядывают. */
.tip-page-title { font-size: 22px; line-height: 1.25; margin: 6px 0 0; }
.tip-page-rule { width: 96px; height: 5px; border-radius: 999px; background: var(--accent); margin: 12px 0 16px; }
.tip-page-text { font-size: 15.5px; line-height: 1.65; color: var(--text-1); white-space: pre-wrap; overflow-wrap: anywhere; }
/* Полоски внизу: по ним видно, сколько осталось, и урок не кажется бесконечным. */
.tip-dots { display: flex; gap: 6px; margin-top: 10px; }
.tip-dot { flex: 1; height: 4px; border-radius: 999px; background: var(--bg-3); }
.tip-dot.active { background: var(--accent); }

/* ---- объявления игроков --------------------------------------------------- */
/* Вкладка «Ищут ведущего» — та же сетка карточек, что и «Кампании»: это две
   стороны одного поиска, и выглядеть они должны одинаково. Всё, что здесь
   задаётся, повторяет .public-campaign-list и .pcc.

   flex:1 и min-height:0 на самой колонке обязательны: без них список рос вниз
   за край окна вместо того, чтобы прокручиваться внутри — вкладка не листалась
   вовсе. */
#seek-gm-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.seek-gm-list {
  flex: 1; min-height: 0; overflow-y: auto; padding: 4px 24px 40px;
  display: grid; gap: 14px; align-content: start;
  /* min(320px, 100%) обязателен: голый minmax(320px,1fr) на экране уже 320
     оставляет колонку в 320, и карточки вылезают за край вместе с текстом. */
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
}
/* Телефонные поправки держим здесь, а не в общем блоке «поиск на телефоне»
   выше по файлу: медиазапрос не добавляет веса правилу, решает порядок строк,
   и тот блок это правило перебить не мог. */
@media (max-width: 700px) {
  .seek-gm-list { padding: 4px 12px 32px; gap: 10px; }
  .seek-gm { padding: 12px; }
  .seek-gm-about { font-size: 12px; -webkit-line-clamp: 2; }
}
.seek-gm-list > .pcc-empty { grid-column: 1 / -1; }
.seek-gm {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 16px; cursor: pointer;
}
.seek-gm:hover { border-color: var(--accent); }
/* Своё объявление помечаем рамкой: в общем списке иначе не отличить, а править
   человек идёт именно к нему. */
.seek-gm.mine { border-color: var(--accent); }
.seek-gm-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.seek-gm-avatar { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; flex-shrink: 0; background: var(--bg-3); }
.seek-gm-name { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.seek-gm-name b, .seek-gm-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Пометка «ваше» не должна ужиматься и вылезать за край: место ей уступает имя,
   оно и так обрезается многоточием. */
.seek-gm-head > .chip { flex-shrink: 0; }
.seek-gm-name b { font-size: 14.5px; }
/* Текст обрезаем по трём строкам — как описание кампании в соседней вкладке.
   Раньше объявление на десять абзацев занимало весь экран, и до второго уже
   надо было листать. Целиком открывается по нажатию на карточку. */
.seek-gm-about {
  font-size: 13px; line-height: 1.5; color: var(--text-2);
  white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 8px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
}
/* Полный текст в окне объявления — там обрезать нечего. */
.seek-gm-full {
  font-size: 14.5px; line-height: 1.6; color: var(--text-1);
  white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 12px;
}
.seek-gm-detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.seek-gm-detail-head img { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; background: var(--bg-3); }
.seek-gm-detail-name { font-size: 19px; font-weight: 700; }
.seek-gm-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.seek-gm-tags .chip.tag { background: var(--bg-3); color: var(--text-1); }
.seek-gm .footer-btn-row { margin-top: 10px; }

/* Отметка «играет регулярно» рядом с именем в объявлении. */
.regular-mark {
  display: inline-flex; align-items: center; gap: 3px; margin-left: 6px;
  font-size: 11px; font-weight: 700; color: var(--success, #1ecb8f);
  vertical-align: 1px;
}
.regular-mark svg { width: 12px; height: 12px; }
/* Плашка удалённого аккаунта в чужом профиле: серым, не красным — это не
   нарушение и не бан, человек просто ушёл (и может вернуться). */
.deleted-mark {
  display: inline-flex; align-items: center; margin-left: 6px;
  font-size: 11px; font-weight: 700; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
  vertical-align: 1px;
}

/* Две кнопки на главной рядом, а на узком экране — друг под другом: «Создать
   кампанию» и «Стартовое приключение» равнозначны, и вторая не должна выглядеть
   приложением к первой. */
.home-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
/* Поля по бокам обязательно автоматические: при одной только max-width блок
   прижимается к левому краю, а текст центрируется уже внутри него — подпись
   выглядела сдвинутой и рвалась посреди фразы. */
#home-tutorial-hint { max-width: 460px; margin: 12px auto 0; line-height: 1.5; }

/* ---- новости на главной --------------------------------------------------- */
/* Две колонки на широком экране, одна на узком: заметка без картинки читается
   быстро, и растягивать её на всю ширину незачем. */
.news-list {
  display: grid; gap: 14px; margin-top: 6px;
  /* min(320px, 100%) — не украшение: голый minmax(320px,1fr) на экране уже 320
     пикселей всё равно оставляет колонку в 320, и карточки вылезали за край, а
     текст в них обрезался по правой стороне. */
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
}
/* Карточки тянутся до высоты самой высокой в ряду (align-items по умолчанию —
   stretch), а текст внутри обрезается по строкам: иначе заметка на два абзаца
   вытягивала свою карточку, соседние оставались короткими, и ряд выглядел
   рваным. Полный текст открывается по нажатию — см. openNewsModal. */
.news-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius-m);
  background: var(--bg-2); padding: 14px 16px 16px; overflow: hidden;
  cursor: pointer; transition: border-color .15s, transform .15s;
}
.news-card:hover { border-color: var(--accent); }
.news-card:active { transform: scale(.995); }
/* Схема или снимок во всю ширину карточки и без полей: она объясняет, о чём
   речь, быстрее первого абзаца. */
.news-art {
  display: block; margin: -14px -16px 12px; width: calc(100% + 32px);
  background: var(--bg-3); border-bottom: 1px solid var(--border);
}
.news-art svg, .news-art img { display: block; width: 100%; height: auto; }
.news-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.news-date { font-size: 12px; color: var(--text-3); }
.news-fresh {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--on-accent); background: var(--accent); border-radius: 999px; padding: 2px 7px;
}
.news-title { font-size: 16px; margin: 0 0 6px; }
.news-text {
  margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-1);
  white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4;
  overflow: hidden;
}
/* «Подробнее» прижимаем к низу карточки (margin-top:auto), чтобы у соседних
   карточек с разным текстом эта строка стояла на одной линии. */
.news-open { margin-top: auto; padding-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--accent); }
#btn-news-more { margin-top: 12px; }

/* Полная заметка в окне: картинка во всю ширину, текст без обрезки. */
.news-modal-art { display: block; margin: 0 0 14px; background: var(--bg-3); border-radius: var(--radius-m); overflow: hidden; }
.news-modal-art svg, .news-modal-art img { display: block; width: 100%; height: auto; }
.news-modal-title { font-size: 20px; font-weight: 700; margin: 6px 0 10px; line-height: 1.3; }
.news-modal-text { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--text-1); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Подпись включённого фильтра «только повествование». Нужна, чтобы включённый
   фильтр никогда не выглядел сломанным: видно, что лента короче не сама по
   себе, а потому что часть реплик спрятана. */
.story-filter-note {
  align-self: center; margin: 4px 0 10px; padding: 4px 12px;
  font-size: 12px; color: var(--text-3);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px;
}

/* ---- появление нового сообщения ------------------------------------------- */
/* Играет только на том, что пришло сейчас (см. shouldAnimateMessage): лента
   перерисовывается целиком, и без такой проверки вся переписка «появлялась» бы
   заново при каждом чужом сообщении.
   both — чтобы первый кадр (прозрачность 0) применился ещё до старта: иначе
   сообщение успевает моргнуть на месте и только потом уезжает вниз. */
@keyframes msg-in {
  from { opacity: 0; transform: translateY(9px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.msg-in { animation: msg-in .24s cubic-bezier(.22,.7,.3,1) both; }
@media (prefers-reduced-motion: reduce) {
  .msg-in { animation: none; }
}

/* ---- «кто-то печатает» ---------------------------------------------------- */
/* Строка живёт над полем ввода и занимает высоту всегда — даже пустая. Иначе её
   появление подбрасывало бы поле ввода и кнопки вверх ровно в тот момент, когда
   человек в них целится. */
/* Строка «печатает» ВИСИТ над полем ввода, а не стоит в колонке.
   Раньше она держала свою высоту всегда, и над клавиатурой постоянно темнела
   пустая полоса — даже когда никто ничего не печатает. Теперь она вынесена из
   потока: молчат — её нет совсем, появилась — легла поверх низа переписки, и
   ничего при этом не подпрыгивает.

   Сверху 14 пикселей — место под прыжок: кубик подскакивает на 7 (см.
   @keyframes die-hop) и в прыжке поворачивается, а повёрнутый квадрат занимает
   по высоте примерно в полтора раза больше своей стороны.

   Подложки нет вовсе — ни заливки, ни градиента. Любая из них рисует над лентой
   лишнюю черту: сплошная обрывает переписку резко, растворяющаяся оставляет
   мутную полосу. Над сообщениями висят только кубик и подпись, а читаемость
   поверх светлого пузыря держит тень под текстом — она не даёт никакой линии.

   Класс, а не атрибут hidden: у того в этом файле стоит display:none !important,
   и перебить его можно было бы только вторым !important. */
.typing-row {
  position: absolute; left: 0; right: 0; bottom: 100%;
  display: flex; align-items: center; gap: 7px;
  padding: 14px 16px 4px;
  font-size: 12.5px; color: var(--text-2);
  text-shadow: 0 1px 3px var(--bg-0), 0 0 6px var(--bg-0);
  /* Под строкой живая переписка — нажатия должны проходить сквозь. */
  pointer-events: none;
  visibility: hidden;
}
.typing-row.on { visibility: visible; }
.typing-die { display: block; width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; }
.typing-die svg { display: block; width: 15px; height: 15px; transform-origin: 50% 92%; }
/* Точки на грани — цветом фона, как у логотипа: заливка кубика идёт currentColor,
   и без этого грань была бы просто закрашенным квадратом. */
.typing-die circle { fill: var(--bg-1); }

/* Кубик подпрыгивает и заваливается на следующую грань. Поворот ровно на 90° —
   не произвольная цифра: грань «пять» под этим углом совпадает сама с собой,
   поэтому на повторе цикла картинка не дёргается назад, а кажется, что кубик
   катится дальше. Приземление сплющивает его по вертикали — без этого прыжок
   выглядит как равномерное скольжение вверх-вниз. */
@keyframes die-hop {
  0%   { transform: translateY(0) rotate(0deg) scale(1, 1); }
  18%  { transform: translateY(-7px) rotate(38deg) scale(.94, 1.07); }
  40%  { transform: translateY(0) rotate(78deg) scale(1, 1); }
  48%  { transform: translateY(0) rotate(90deg) scale(1.14, .86); }
  62%  { transform: translateY(0) rotate(90deg) scale(1, 1); }
  100% { transform: translateY(0) rotate(90deg) scale(1, 1); }
}
.typing-row.on .typing-die svg { animation: die-hop 1.15s cubic-bezier(.32,.68,.4,1) infinite; }
/* Кому движение мешает — тому оно и здесь не нужно: строка остаётся, прыжок нет. */
@media (prefers-reduced-motion: reduce) {
  .typing-row.on .typing-die svg { animation: none; }
}

/* ---- разбор жалоб --------------------------------------------------------- */
.mod-report { border: 1px solid var(--border); border-radius: var(--radius-m); padding: 10px 12px; margin-bottom: 10px; }
/* Разобранные приглушаем, но оставляем: по ним видно, что уже смотрели. */
.mod-report.done { opacity: .55; }
.mod-report-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.mod-report-text { margin: 6px 0 8px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.btn.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.mod-report-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mod-about { font-size: 13px; margin: 2px 0; }
/* Снимок того, на что жалуются: сообщение могли удалить или переписать сразу
   после жалобы, поэтому в очереди лежит копия на момент подачи. Отбиваем её
   рамкой — это чужие слова, а не текст жалобы. */
.mod-quote {
  margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--accent);
  background: var(--bg-2); border-radius: 0 8px 8px 0;
  font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.mod-quote-label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin-bottom: 2px; }

/* ---- просмотр места жалобы ---- */
.mod-ctx-head { margin-bottom: 6px; }
.mod-ctx-title { font-size: 18px; font-weight: 700; }
.mod-msg { padding: 6px 10px; border-radius: 8px; margin-bottom: 4px; }
.mod-msg-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.mod-msg-text { font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.mod-msg-img { max-width: 100%; max-height: 200px; border-radius: 8px; margin-top: 4px; }
.mod-msg.system { opacity: .6; font-size: 12px; }
/* Спорную реплику подсвечиваем: ради неё сюда и пришли, а в тридцати строках
   вокруг её пришлось бы искать глазами. */
.mod-msg.flagged { background: color-mix(in srgb, var(--accent) 22%, transparent); outline: 1px solid var(--accent); }
/* «Удалить учётную запись» — не кнопка первого ряда: она стоит под выходом,
   выглядит ссылкой и требует пароля. */
#btn-delete-account { color: var(--danger); margin-top: 10px; }

/* ---- окошко с формулой броска -------------------------------------------- */
/* Плашка в ленте показывает только итог, формула открывается здесь. Ширину не
   задаём жёстко, как у обычного .popover: формулы бывают и в два символа, и в
   полторы строки — фиксированные 300px растянули бы «4» на всю ширину. */
.roll-popover {
  width: auto; max-width: min(360px, calc(100vw - 24px));
  padding: 10px 12px; font-size: 13px; line-height: 1.45;
  max-height: none; overflow: visible;
}
.roll-pop-formula { color: var(--text-1); word-break: break-word; }
.roll-pop-log { color: var(--text-3); margin-top: 4px; }
.roll-pop-result { margin-top: 6px; color: var(--text-2); }
.roll-pop-result b { color: var(--accent-hover); }

/* ---- неотправленное ------------------------------------------------------- */
/* Сообщение, которое ждёт возвращения связи. Показываем его в ленте на своём
   месте, но приглушённым и с часами — чтобы было видно: написано, но ещё не
   ушло. Без этого человек не понимает, отправилось ли, и пишет второй раз. */
.msg-row.msg-pending { opacity: .55; }
.msg-row.msg-pending .msg-bubble { border: 1px dashed var(--border); }
.msg-row.msg-pending .msg-time::after { content: " ⏳"; }

/* ---- множественный выбор сообщений ---------------------------------------- */
/* Чекбокс перед строкой — как в телеграме. Скрыт, пока выбор не идёт; в
   .selecting строка целиком кликабельна (см. renderMessageEl), поэтому курсор
   меняем на весь ряд, а не только на кружок. */
.msg-select-check {
  display: none; width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border); background: var(--bg-1); align-self: center;
  align-items: center; justify-content: center; color: transparent;
}
.msg-select-check svg { width: 13px; height: 13px; }
.msg-row.selecting { cursor: pointer; }
.msg-row.selecting .msg-select-check { display: flex; }
.msg-row.selected .msg-select-check { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.msg-row.selected { background: var(--accent-soft); border-radius: 12px; }

/* Панель выбора — тот же .chat-header, только с другим набором кнопок. */
.select-toolbar .icon-btn.danger { color: var(--danger); }
.select-toolbar .icon-btn:disabled { opacity: .4; pointer-events: none; }
#select-count { font-weight: 700; }

/* Список чатов в окне пересылки — своя маленькая аватарка поверх общего .list-row. */
.fwd-row-avatar { width: 32px; height: 32px; border-radius: 10px; object-fit: cover; background: var(--bg-3); flex-shrink: 0; }

/* ---- главная на очень широком мониторе ------------------------------------ */
/* Колонка главной центрируется в свободной области — и пока область соразмерна
   колонке, это правильно. Но на мониторе шириной 2500px под неё отдаётся 2160px,
   и 780px посередине оставляют по 690px пустоты с каждой стороны: главная
   выглядит уехавшей неизвестно куда, тем более что чат, поиск и архив
   начинаются сразу за списком кампаний.
   Ограничиваем не саму колонку, а область, внутри которой она центруется.
   Порог в 1500px по окну наступает, когда области достаётся около 1100px, то
   есть на обычных мониторах не меняется ничего; дальше колонка просто перестаёт
   уезжать вправо и держится там же, где на экране 1900px. */
@media (min-width: 1500px) {
  .view-home { max-width: 1500px; }
}

/* ---- боковые панели: ход за пальцем -------------------------------------- */
@media (max-width: 980px) {
  /* Панель персонажей раньше просто возникала: hidden убирал её мгновенно, без
     всякого движения — рядом с едущим списком это и выглядело кривым. Теперь
     она никуда не девается, а закрытое состояние — сдвиг за правый край экрана.
     Без !important не обойтись: выше стоит общее [hidden] { display: none
     !important }, а нам нужно оставить панель на месте, лишь отодвинув её.
     Запас в 8px прячет тень и рамку; ровно на столько же её отодвигает жест —
     числа в CSS и в setupPanelSwipes обязаны совпадать, иначе на отпускании
     панель дёрнется. */
  .charpanel { transform: translateX(0); }
  .charpanel[hidden] {
    display: flex !important;
    transform: translateX(calc(100% + 8px));
    pointer-events: none;
  }

  /* Один разгон на обе панели. 0.26s с сильным замедлением к концу: движение
     успевает показать, откуда панель приехала, и не заставляет ждать. Прежние
     0.2s линейного хода у списка обрывались резко — от этого и ощущение рывка.
     will-change отдаёт панель отдельному слою: иначе телефон перерисовывает на
     каждом кадре весь список кампаний с аватарками, и ход выходит рваным. */
  .sidebar, .charpanel {
    transition: transform .26s cubic-bezier(.32, .72, 0, 1);
    will-change: transform;
  }

  /* Пока панель под пальцем, переход только мешает: положение задаёт жест, а
     сглаживание превращает его в отставание — панель тянется следом за пальцем
     вместо того, чтобы стоять под ним. */
  .app.panels-dragging .sidebar,
  .app.panels-dragging .charpanel { transition: none; }
}

/* Кому движение мешает — тому и здесь: панели просто переключаются. Жест при
   этом работает как прежде, он не украшение, а способ их открыть. */
@media (prefers-reduced-motion: reduce) {
  .sidebar, .charpanel { transition: none; }
}

/* Уведомление закрывается нажатием — курсор об этом и говорит. */
.toast { cursor: pointer; }

/* ---- реакции на сообщения ------------------------------------------------- */
/* Полоска под облачком. Ставится в один тон с ним и не занимает высоты, пока
   реакций нет: ряд пустых кружков под каждой репликой засорял бы ленту сильнее,
   чем помогал. */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.msg-reaction {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; cursor: pointer;
  font-size: 13px; line-height: 1.5;
  background: color-mix(in srgb, var(--text-0) 8%, transparent);
  border: 1px solid transparent; color: var(--text-1);
}
/* Своя реакция обведена, а не залита: заливка спорила бы с цветом облачка,
   который у каждого персонажа свой. */
.msg-reaction.mine { border-color: var(--accent); color: var(--text-0); }
.msg-reaction span { font-size: 12px; font-variant-numeric: tabular-nums; }
/* Пометка «изменено» — в той же строке, что и реакции (см. renderReactions в
   app.js). color: inherit — та же причина, что у msg-deleted: строка рисуется
   внутри пузыря, и его уже посчитанный цвет текста читается что на обычном
   фоне, что на акцентном «своём», что на подложке цвета персонажа. */
.msg-edited { align-self: center; font-style: italic; font-size: 11px; color: inherit; opacity: .6; }

/* Выбор смайлика — одна строка кнопок: весь набор виден сразу, без прокрутки
   и вложенных списков. */
.reaction-picker { display: flex; gap: 2px; padding: 6px; }
.reaction-pick {
  background: transparent; border: none; cursor: pointer;
  font-size: 20px; line-height: 1; padding: 6px; border-radius: 8px;
}
.reaction-pick:hover { background: color-mix(in srgb, var(--text-0) 10%, transparent); }

/* ---- Экран загрузки (см. #boot-screen в index.html и boot.js) ----
   Виден с первого байта разметки, пока app.js не показал вход/приложение.
   Инлайн-стиль в разметке уже задаёт раскладку (на случай, если не доехал даже
   сам CSS), здесь — только страховка скрытия и лёгкая пульсация статуса. */
.boot-screen[hidden] { display: none !important; }
.boot-screen .boot-box { max-width: 340px; }
.boot-screen .boot-status::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px; margin-left: 6px; border-radius: 50%;
  background: currentColor; opacity: .5;
  animation: boot-blink 1.2s ease-in-out infinite;
}
@keyframes boot-blink { 50% { opacity: .15; } }
