/* ==================================================================
   КАРТОЧКИ ДОКУМЕНТОВ И ТЕЛЕФОННАЯ РАСКЛАДКА — 24.09.2026
   Подключается последним (после style.css и practice.css).

   Первая часть — для всех экранов: скорость и плавность карточек дела и
   закона. Вторая — телефон: раздел практики и карточки переделаны под
   палец и узкий экран, а не просто сжаты.
   ================================================================== */

/* ── Скорость: длинный текст решения ────────────────────────────
   При открытии карточки браузер раскладывал весь текст решения сразу —
   на слабом ноутбуке это до секунды, отсюда «зависание» при переходах по
   сноскам. Теперь раскладываются только абзацы на экране, остальные — по
   мере прокрутки. Поиск и переход к фрагменту работают как прежде. */
.pr-case-modal .pr-text > p,
.pr-case-modal .pr-text > h4,
.pr-case-modal .pr-text > h5 {
  content-visibility: auto;
  contain-intrinsic-size: auto 96px;
}
/* Переход к дальнему месту текста (practice.js, scrollToInText) идёт скачком — его прикрывает
   короткое затухание: текст гаснет, место встаёт по центру, текст проявляется. */
.pr-case-modal .pr-text { transition: opacity .24s ease; }
.pr-case-modal .pr-text.is-jumping { opacity: .12; transition-duration: .14s; }

/* ── Карточка закона: появление и закрытие, как у карточки дела ─── */
.norm-modal .case-viewer-overlay { animation: dcFadeIn .28s ease-out both; }
.norm-modal .case-viewer-content { animation: dcRise .38s cubic-bezier(0.22, 1, 0.36, 1) both; }
.norm-modal.is-closing .case-viewer-overlay { animation: dcFadeOut .2s ease-in both; }
.norm-modal.is-closing .case-viewer-content { animation: dcSink .2s ease-in both; }
.norm-modal .case-viewer-main.is-fresh,
.norm-modal .case-viewer-sidebar.is-fresh { animation: dcFadeIn .3s ease-out both; }
/* Пока текст статьи грузится — три-четыре тихие полосы вместо надписи. */
.cv-skel { display: flex; flex-direction: column; gap: 12px; padding: 18px 0; }
.cv-skel span {
  display: block; height: 11px; border-radius: 6px;
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
  animation: cvSkel 1.2s ease-in-out infinite;
}
@keyframes cvSkel { 50% { opacity: .45; } }

/* Смахнутая жестом карточка уже уехала вниз — анимация закрытия не нужна. */
.case-viewer-modal.is-dragged-out.is-closing .case-viewer-content,
.case-viewer-modal.is-dragged-out.is-closing .case-viewer-overlay { animation: none !important; }

/* Только для телефона: на компьютере не показываются. */
.dc-facts-toggle, .dc-bottom { display: none; }

/* Размышление: блок появляется мягко, а не возникает целиком за кадр. */
.thinking-row { animation: thRowIn .36s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes thRowIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Превью навигации по чату — ниже карточек документов (их слой 9999):
   раньше оно могло повиснуть поверх открытой карточки. */
.chat-nav-preview { z-index: 9990; }

@media (prefers-reduced-motion: reduce) {
  .norm-modal .case-viewer-content,
  .norm-modal.is-closing .case-viewer-content { animation: dcFadeIn .15s linear both; }
  .norm-modal.is-closing .case-viewer-content { animation-name: dcFadeOut; }
  .thinking-row { animation: dcFadeIn .2s linear both; }
  .cv-skel span { animation: none; }
}


/* ==================================================================
   ТЕЛЕФОН
   Условие то же, что у остальной телефонной раскладки (main.js читает
   его из style.css): палец и узкий экран или просто очень узкое окно.
   ================================================================== */
@media (pointer: coarse) and (max-width: 768px), (pointer: coarse) and (max-height: 480px), (max-width: 560px) {

  /* ── Навигация по чату: полоса меток под палец ───────────────────
     Касание — переход к сообщению, ведение пальцем — превью (main.js,
     initChatNavTouchScrub). Страницу при этом не прокручиваем. */
  .chat-nav-track { touch-action: none; }
  .chat-nav-mark { position: relative; }
  .chat-nav-mark::after { content: ''; position: absolute; inset: -3px -8px; }
  .chat-nav-mark.is-scrub::before { width: 21px !important; opacity: 1; background: var(--accent); }
  .chat-nav-preview { max-width: min(260px, calc(100vw - 72px)); min-width: 0; }

  /* ── Раздел практики: список карточек вместо таблицы ─────────────
     Таблица в четыре колонки на 390px превращалась в кашу, сколько её ни
     сжимай. На телефоне каждое дело — отдельная карточка: сверху исход и
     дата, крупно предмет спора, ниже суд и номер. Шапка раздела (поиск и
     фильтры) стоит на месте, список прокручивается под ней, месяцы
     прилипают к верху, пока листаешь их дела. */
  #practiceView .pr-head { padding: 54px 14px 10px; }
  #practiceView .pr-body { padding: 0 14px calc(28px + env(safe-area-inset-bottom)); }
  #practiceView .pr-head-in {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px; align-items: center;
  }
  #practiceView .pr-find { grid-column: 1; grid-row: 1; }
  #practiceView .pr-filters-wrap { display: contents; }
  /* Кнопка фильтров — круглая, в строке поиска: подпись заменил значок,
     число выбранных фильтров — точкой-счётчиком в углу. */
  #practiceView .pr-filter-toggle {
    grid-column: 2; grid-row: 1; position: relative;
    width: 46px; height: 46px; padding: 0; justify-content: center; gap: 0;
  }
  #practiceView .pr-filter-toggle .pr-filter-label { display: none; }
  #practiceView .pr-filter-toggle svg { width: 18px; height: 18px; }
  #practiceView .pr-filter-count {
    position: absolute; top: 3px; right: 3px; margin: 0;
    min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px;
  }
  #practiceView .pr-filters { grid-column: 1 / -1; grid-row: 2; }
  #practiceView .pr-hints { grid-column: 1 / -1; }
  /* Фильтры — всегда одна и та же сетка, что бы ни было выбрано:
     «Предмет | Инстанция», «Исход | Сортировка», «С текстом | Просмотренные»
     и справа тонкой строкой «Сбросить» (она на месте всегда, неактивна,
     пока сбрасывать нечего). Пункт занимает всю свою ячейку: выбранное
     значение пишется с начала и обрезается многоточием, стрелка — у края. */
  .pr-filters-inner > .pr-chip[data-kind="leaf"],
  .pr-filters-inner > .pr-chip[data-kind="stage"],
  .pr-filters-inner > .pr-chip[data-kind="outcome"],
  .pr-filters-inner > .pr-chip[data-kind="sort"] { grid-column: span 6; }
  .pr-filters-inner > .pr-chip { width: 100%; justify-content: flex-start; }
  .pr-filters-inner .pr-chip .pr-chip-body { flex: 1 1 auto; min-width: 0; }
  .pr-filters-inner > .pr-check:not(.pr-check-seen) { grid-column: span 6; order: 0; }
  .pr-filters-inner > .pr-check-seen { grid-column: span 6; }
  .pr-filters-inner > .pr-reset { grid-column: 1 / -1; justify-self: end; order: 0; }
  #practiceView .pr-filters-inner .pr-reset { height: 28px; margin: 0; padding: 0 4px; font-size: 12.5px; }

  /* Панель без рамки: карточки дел сами по себе рамка. */
  #practiceView .pr-panel { border: 0; background: none; border-radius: 0; overflow: visible; }
  #practiceView .pr-panel-head {
    position: static; background: none; border: 0; border-radius: 0;
  }
  #practiceView .pr-stats {
    margin: 2px 0 4px; padding: 12px 14px;
    border: 0; border-radius: 14px;
    background: var(--bg-elevated);
    box-shadow: inset 0 0 0 1px var(--pr-hair);
  }
  #practiceView .pr-cols { display: none !important; }
  #practiceView .pr-list { padding: 0; }

  #practiceView .pr-month {
    position: sticky; top: 0; z-index: 3;
    margin: 0 -14px; padding: 12px 18px 8px;
    font-size: 11px; letter-spacing: .12em;
    background: var(--bg-page); /* без размытия: прилипший заголовок пересчитывался при каждой прокрутке */
  }

  #practiceView .pr-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "out date" "subj subj" "court court";
    align-items: center;
    gap: 6px 12px;
    min-height: 0; margin: 0 0 8px; padding: 12px 14px 13px;
    border-radius: 14px;
    background: var(--bg-elevated);
    box-shadow: inset 0 0 0 1px var(--pr-hair);
    transition: background-color .16s var(--pr-ease), transform .16s var(--pr-ease);
  }
  #practiceView .pr-row + .pr-row { box-shadow: inset 0 0 0 1px var(--pr-hair); }
  #practiceView .pr-row:hover { background: var(--bg-elevated); box-shadow: inset 0 0 0 1px var(--pr-hair); }
  #practiceView .pr-row:active { transform: scale(.985); background: color-mix(in srgb, var(--text-primary) 6%, var(--bg-elevated)); }
  #practiceView .pr-row.is-last { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent); }

  #practiceView .pr-row .pr-outcome {
    grid-area: out; justify-self: start; align-self: center;
    height: 22px; padding: 0 9px; font-size: 11.5px;
  }
  #practiceView .pr-row .pr-date {
    grid-area: date; justify-self: end;
    font-size: 12px; color: var(--text-muted); white-space: nowrap;
  }
  #practiceView .pr-row .pr-subject {
    grid-area: subj; min-width: 0;
    font-size: 15.5px; font-weight: 600; line-height: 1.3; letter-spacing: -.005em;
    color: var(--text-primary); white-space: normal;
  }
  #practiceView .pr-row.is-seen .pr-subject { color: var(--text-secondary); }
  #practiceView .pr-row .pr-court {
    grid-area: court; justify-self: stretch; display: block; min-width: 0;
    font-size: 12.5px; line-height: 1.35; color: var(--text-muted);
    white-space: normal; overflow: visible; text-align: left;
  }
  #practiceView .pr-row .pr-court::before { content: none; }
  #practiceView .pr-row .pr-court .pr-num {
    display: inline; margin: 0; font-size: 12px; color: var(--text-faint); white-space: nowrap;
  }
  #practiceView .pr-row .pr-court .pr-num::before { content: " · "; }

  /* ── Карточка документа — шторка снизу ───────────────────────────
     На всю высоту экрана (кроме полоски сверху — видно, что это слой над
     страницей), выезжает снизу и уезжает вниз; закрыть — крестиком,
     фоном или смахнуть шапку вниз. Шапка неподвижна, прокручивается
     всё под ней одной лентой: сведения, поиск, текст. */
  .case-viewer-modal.pr-case-modal,
  .case-viewer-modal.norm-modal { align-items: flex-end; }
  .case-viewer-modal.pr-case-modal .case-viewer-content,
  .case-viewer-modal.pr-case-modal .case-viewer-content:not(.is-textless),
  .case-viewer-modal.norm-modal .case-viewer-content {
    width: 100%; max-width: 100%;
    height: calc(100dvh - 12px - env(safe-area-inset-top)); max-height: none;
    border: 0; border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .35);
    animation: sheetUp .42s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  /* Без текста — только сведения: шторка по содержимому, не на весь экран. */
  .case-viewer-modal.pr-case-modal .case-viewer-content.is-textless {
    width: 100%; max-width: 100%;
    height: auto; max-height: calc(100dvh - 12px - env(safe-area-inset-top));
    border: 0; border-radius: 18px 18px 0 0;
    animation: sheetUp .42s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  .case-viewer-modal.pr-case-modal.is-closing .case-viewer-content,
  .case-viewer-modal.norm-modal.is-closing .case-viewer-content {
    animation: sheetDown .24s cubic-bezier(0.4, 0, 1, 1) both;
  }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
  @keyframes sheetDown { from { transform: none; } to { transform: translateY(100%); } }

  /* Шапка: ручка-полоска сверху, заголовок до двух строк, масштаб и
     крестик справа. Листание подборки уехало в нижнюю панель. */
  .case-viewer-modal .case-viewer-header {
    position: relative; flex: none;
    flex-wrap: nowrap; align-items: center; gap: 8px;
    padding: 20px 54px 12px 18px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--pr-hair, var(--border));
    touch-action: none;
  }
  .case-viewer-modal .case-viewer-header::before {
    content: ''; position: absolute; top: 7px; left: 50%;
    width: 36px; height: 4px; margin-left: -18px; border-radius: 2px;
    background: color-mix(in srgb, var(--text-primary) 22%, transparent);
  }
  .case-viewer-modal .case-viewer-header .close-btn {
    position: absolute; right: 10px; top: 14px;
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; padding: 0;
    font-size: 22px; line-height: 1;
    background: color-mix(in srgb, var(--text-primary) 7%, transparent);
  }
  .pr-case-modal .dc-head-text,
  .norm-modal .cv-norm-head { flex: 1 1 auto; min-width: 0; }
  .pr-case-modal .dc-kicker,
  .norm-modal .cv-norm-kicker { font-size: 10.5px; letter-spacing: .08em; margin-bottom: 3px; }
  .pr-case-modal .dc-head-text h3,
  .case-viewer-content.is-norm-card .case-viewer-header h3 {
    font-size: 16px; line-height: 1.3; font-weight: 600;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .pr-case-modal .dc-sub { font-size: 12px; -webkit-line-clamp: 1; }
  .pr-case-modal .case-viewer-header .pr-card-nav { display: none; }
  .pr-case-modal .dc-zoom-slot { flex: none; align-self: center; }
  .case-viewer-modal .case-viewer-header .text-zoom { height: 32px; margin: 0; }
  .case-viewer-modal .case-viewer-header .text-zoom-btn { width: 28px; height: 28px; }

  /* Одна лента прокрутки под шапкой. */
  .case-viewer-modal .case-viewer-body {
    display: block; flex: 1 1 auto; min-height: 0;
    overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .case-viewer-modal .case-viewer-main,
  .case-viewer-modal .case-viewer-sidebar { overflow: visible; }

  /* Сведения о деле: над текстом свёрнуты в одну строку «Сведения ·
     суд · дата · исход» — текст решения начинается сразу под шапкой. */
  .pr-case-modal .case-viewer-sidebar {
    width: 100%; padding: 6px 18px; background: none;
    border: 0; border-bottom: 1px solid var(--pr-hair);
  }
  .pr-case-modal .case-viewer-content.is-textless .case-viewer-sidebar {
    border-bottom: 0; padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
  }
  .pr-case-modal .case-viewer-content.has-bottom.is-textless .case-viewer-sidebar {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }
  .pr-case-modal .dc-facts-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%;
    min-height: 40px; padding: 4px 0; margin: 0;
    border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
  }
  .dc-facts-toggle-k { flex: none; font-size: 13px; font-weight: 600; color: var(--text-primary); }
  .dc-facts-toggle-v {
    flex: 1 1 auto; min-width: 0; font-size: 12.5px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .dc-facts-toggle svg {
    flex: none; width: 14px; height: 14px; color: var(--text-muted);
    transition: transform .28s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .pr-case-modal .case-viewer-sidebar.is-open .dc-facts-toggle svg { transform: rotate(180deg); }
  .pr-case-modal .case-viewer-content:not(.is-textless) .case-viewer-sidebar:not(.is-open) > .sidebar-block { display: none; }
  .pr-case-modal .case-viewer-sidebar.is-open > .sidebar-block { animation: dcFadeIn .26s ease-out both; }
  .pr-case-modal .case-viewer-sidebar .sidebar-block { margin: 4px 0 12px; }
  .pr-case-modal .case-viewer-sidebar .sidebar-block:first-of-type { display: block; }
  /* «Резюме / Сравнить» — в нижней панели. */
  .pr-case-modal .case-viewer-sidebar .dc-chat { display: none !important; }
  .pr-case-modal .pr-facts {
    display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 0 12px;
  }
  .pr-case-modal .pr-facts dt { font-size: 12.5px; padding: 6px 0; color: var(--text-faint); }
  .pr-case-modal .pr-facts dd { font-size: 13.5px; padding: 6px 0; color: var(--text-primary); overflow-wrap: anywhere; }

  /* Текст решения: крупнее и спокойнее, поля по краям — как в читалке. */
  .pr-case-modal .case-viewer-main { padding: 0 18px 28px; min-height: 0; }
  .pr-case-modal .case-viewer-content.has-bottom .case-viewer-main {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }
  .pr-case-modal .pr-text {
    max-width: none;
    font-size: calc(16px * var(--text-zoom, 1)); line-height: 1.62;
    color: var(--text-primary);
  }
  .pr-case-modal .pr-text p { margin: 0 0 12px; }
  .pr-case-modal .pr-text .pr-text-h { margin-top: 20px; }

  /* Поиск по документу: поле — во всю строку, режим и отметка о
     фрагменте — под ним. При чтении панель уезжает вместе с текстом и не
     отнимает экран; когда ищешь (поле в фокусе или в нём есть запрос) —
     прилипает к шапке, чтобы листать совпадения. */
  .pr-case-modal .dc-bar {
    position: static; top: 0; margin: 0 -18px 12px; padding: 10px 18px 0;
    background: var(--bg-surface);
  }
  .pr-case-modal .dc-bar:focus-within,
  .pr-case-modal .dc-bar:has(input:not(:placeholder-shown)) { position: sticky; }
  .pr-case-modal .dc-tools { flex-wrap: wrap; gap: 8px 6px; margin-bottom: 10px; }
  .pr-case-modal .pr-find-doc { flex: 1 1 100%; height: 40px; }
  .pr-case-modal .pr-find-doc input { font-size: 16px; } /* меньше 16 — iOS приближает страницу */
  .pr-case-modal .dc-mode button { padding: 0 9px; font-size: 12px; }
  /* Стрелки «к следующему совпадению» появляются, когда есть что листать, —
     иначе они отнимали у поля половину ширины. */
  .pr-case-modal .pr-find-doc .dc-nav:disabled { display: none; }
  .pr-case-modal .dc-go { height: 30px; padding: 0 14px; font-size: 13px; }

  /* Нижняя панель: листание подборки и действия в чате. */
  .pr-case-modal .dc-bottom {
    display: flex; align-items: center; gap: 8px;
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: var(--bg-surface);
    border-top: 1px solid var(--pr-hair);
    box-shadow: 0 -6px 18px rgba(0, 0, 0, .18);
  }
  .pr-case-modal .dc-bottom:empty { display: none; }
  .dc-bottom-nav { display: flex; align-items: center; gap: 2px; }
  .dc-bottom-pos {
    min-width: 58px; text-align: center; font-size: 12.5px; color: var(--text-muted);
    font-variant-numeric: tabular-nums;
  }
  .dc-bottom-chat { display: flex; gap: 6px; margin-left: auto; }
  .dc-bottom-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 42px; min-width: 42px; padding: 0; border: 0; border-radius: 12px;
    background: color-mix(in srgb, var(--text-primary) 6%, transparent);
    color: var(--text-secondary); font: inherit; font-size: 13px; cursor: pointer;
    transition: background-color .15s ease, transform .12s ease;
  }
  .dc-bottom-btn:active { transform: scale(.96); background: color-mix(in srgb, var(--text-primary) 11%, transparent); }
  .dc-bottom-btn:disabled { opacity: .32; }
  .dc-bottom-btn.has-label { padding: 0 13px; }
  .dc-bottom-btn svg { width: 16px; height: 16px; flex: none; }
  .dc-step[data-dir="-1"] svg { transform: rotate(90deg); }
  .dc-step[data-dir="1"] svg { transform: rotate(-90deg); }

  /* Карточка закона: текст статьи крупнее, сведения и ссылка — под ним. */
  .norm-modal .case-viewer-main { padding: 6px 18px 8px; }
  .norm-modal .case-viewer-full-label { margin-top: 10px; }
  .case-viewer-content.is-norm-card .case-viewer-main .case-text {
    font-size: calc(16px * var(--text-zoom, 1)); line-height: 1.62;
  }
  .norm-modal .case-viewer-sidebar {
    width: 100%; padding: 14px 18px calc(24px + env(safe-area-inset-bottom));
    background: none; border: 0; border-top: 1px solid var(--pr-hair, var(--border));
  }
}

@media (pointer: coarse) and (max-width: 768px) and (prefers-reduced-motion: reduce),
       (max-width: 560px) and (prefers-reduced-motion: reduce) {
  .case-viewer-modal.pr-case-modal .case-viewer-content,
  .case-viewer-modal.norm-modal .case-viewer-content { animation: dcFadeIn .18s linear both !important; }
  .case-viewer-modal.pr-case-modal.is-closing .case-viewer-content,
  .case-viewer-modal.norm-modal.is-closing .case-viewer-content { animation: dcFadeOut .16s linear both !important; }
}

/* ── Строка ввода: полоса прокрутки не наезжает на текст (25.09) ──────────
   У поля не было правого отступа, и появившаяся полоса ложилась на буквы.
   Место под полосу держим всегда (scrollbar-gutter), чтобы текст не прыгал,
   когда она появляется, и даём небольшой отступ от неё. */
.input-field,
.input-bar .input-field {
  scrollbar-gutter: stable;
  padding-right: 8px;
  scrollbar-width: thin;
}
@media (pointer: coarse) and (max-width: 768px), (pointer: coarse) and (max-height: 480px), (max-width: 560px) {
  .input-bar .input-field { padding-right: 6px; }
}

/* ── «Копировать ответ»: галочка на пару секунд ─────────────────────────── */
.reply-action-btn.is-copied { color: var(--accent); }
.reply-action-btn.is-copied svg { animation: copiedPop .28s ease-out both; }
@keyframes copiedPop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .reply-action-btn.is-copied svg { animation: none; }
}

/* ── Практика: полоса «Чем закончились» появляется плавно (25.09) ─────────
   Доли приходят отдельным запросом после списка. Раньше пустая полоска над
   шапкой таблицы вдруг заполнялась и сдвигала таблицу. Теперь, пока доли
   считаются, стоит заготовка той же высоты, а при появлении сегменты полосы
   по очереди вырастают слева направо, легенда всплывает следом. */
#practiceView .pr-stats { min-height: 41px; box-sizing: border-box; }
#practiceView .pr-stats:empty { display: none; }
.pr-stats-skel { display: flex; align-items: center; gap: 12px; height: 17px; width: 100%; }
.pr-stats-skel i {
  display: block; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--pr-hair) 0%, var(--bg-hover) 50%, var(--pr-hair) 100%);
  background-size: 200% 100%;
  animation: prStatsShimmer 1.3s ease-in-out infinite;
}
.pr-stats-skel i:nth-child(1) { width: 96px; }
.pr-stats-skel i:nth-child(2) { width: 190px; height: 5px; }
.pr-stats-skel i:nth-child(3) { width: 150px; }
@keyframes prStatsShimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.pr-stats.is-in .pr-stats-label { animation: prStatsUp .35s cubic-bezier(.2,.8,.2,1) backwards; }
.pr-stats.is-in .pr-bar i {
  transform-origin: left center;
  animation: prStatsGrow .62s cubic-bezier(.22,.9,.24,1) backwards;
  animation-delay: calc(90ms + var(--i, 0) * 90ms);
}
.pr-stats.is-in .pr-legend > * {
  animation: prStatsUp .42s cubic-bezier(.2,.8,.2,1) backwards;
  animation-delay: calc(430ms + var(--i, 0) * 80ms);
}
@keyframes prStatsGrow { from { transform: scaleX(0); opacity: 0; } 40% { opacity: .9; } to { transform: scaleX(1); } }
@keyframes prStatsUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .pr-stats-skel i { animation: none; }
  .pr-stats.is-in .pr-bar i,
  .pr-stats.is-in .pr-legend > *,
  .pr-stats.is-in .pr-stats-label { animation: prStatsFade .25s ease backwards; animation-delay: 0s; }
  @keyframes prStatsFade { from { opacity: 0; } to { opacity: 1; } }
}

/* ── Уведомление внизу («Ответ скопирован» и др.): пилюля с галочкой ────── */
.app-toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 20000; pointer-events: none;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px 9px 10px; border-radius: 999px;
  background: var(--bg-elevated); /* без размытия — дёшево и на слабых устройствах */
  border: 1px solid var(--border);
  color: var(--text-primary); font-size: 13px; font-weight: 500; letter-spacing: .01em;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28), 0 1px 0 rgba(255, 255, 255, .04) inset;
  opacity: 0; transform: translate(-50%, 12px) scale(.96);
  transition: opacity .22s ease, transform .38s cubic-bezier(.2, .9, .25, 1.25);
}
.app-toast.is-shown { opacity: 1; transform: translate(-50%, 0) scale(1); }
.app-toast-ico {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.app-toast-ico svg { width: 11px; height: 11px; }
.app-toast.is-shown .app-toast-ico svg { animation: copiedPop .3s .08s ease-out backwards; }
@media (pointer: coarse) and (max-width: 768px), (pointer: coarse) and (max-height: 480px), (max-width: 560px) {
  .app-toast { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 32px); }
}
@media (prefers-reduced-motion: reduce) {
  .app-toast { transition: opacity .2s ease; transform: translate(-50%, 0); }
}

/* Проявление страницы чата: index.html держит body прозрачным, пока не загрузится эта таблица
   (она подключается последней) — так не мелькает разметка без стилей. */
body { opacity: 1; animation: protoPageIn .32s ease-out both; }
@keyframes protoPageIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { body { animation: none; } }

/* ── История чатов: название гаснет ДО кнопки «⋯», а не под ней (08.10.2026) ──
   В style.css затухание шло на последних 44px до самого края — под кнопкой (24px у края справа)
   текст оставался видимым наполовину и сливался с точками. Теперь текст полностью прозрачен
   за 6px до кнопки. На компьютере — только при наведении (кнопка видна лишь тогда), на телефоне
   кнопка видна всегда (38px) — и затухание постоянное, под её размер. */
.sidebar-history-row:hover .sidebar-history-item,
.sidebar-history-row:has(.history-menu-btn.is-open) .sidebar-history-item {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 62px), transparent calc(100% - 32px));
  mask-image: linear-gradient(to right, #000 calc(100% - 62px), transparent calc(100% - 32px));
}
@media (pointer: coarse) and (max-width: 768px), (pointer: coarse) and (max-height: 480px), (max-width: 560px) {
  .sidebar-history-item,
  .sidebar-history-row:hover .sidebar-history-item {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 78px), transparent calc(100% - 46px));
    mask-image: linear-gradient(to right, #000 calc(100% - 78px), transparent calc(100% - 46px));
  }
}
