/* ─────────────────────────────────────────────────────────────
   styles/ui.css — общий интерфейс платформы
   Кнопки, окна, выезжающие панели, лоадеры, тосты, панели,
   служебные элементы (хаптик, скроллбары, autofill).
   Грузится всегда, после base.css.
   ───────────────────────────────────────────────────────────── */

/* ─── Haptic (iOS native switch) ───────────────────────────── */
/* Механика из ios-haptics (MIT, tijnjh): под пальцем прозрачный
   <label>, а <input switch> — 1×1 и visibility:hidden. WebKit
   помечает тач на switch как «обработанный» и отменяет скролл,
   поэтому switch не должен оказаться под пальцем. */
.haptic-layer {
    display: none;
}
@media (max-width: 767px) {
    .haptic-layer {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 1;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    .haptic-layer > .haptic-switch {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: 0;
        visibility: hidden;
    }
}

/* ─── Code Editor (CodeMirror 5, theme: r-dark) ────────────── */
.r-code-editor .CodeMirror {
    height: 200px;
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Menlo', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.5;
    background: var(--color-bg-quaternary);
    color: #e5e7eb;
    border-radius: 6px;
}
.cm-s-r-dark .CodeMirror-gutters {
    background: var(--color-bg-tertiary);
    border-right: 1px solid var(--color-border);
}
.cm-s-r-dark .CodeMirror-foldgutter {
    width: 1.2em;
}
.cm-s-r-dark .CodeMirror-linenumber {
    color: #6b7280;
    padding: 0 8px 0 4px;
}
.cm-s-r-dark .CodeMirror-foldgutter-open,
.cm-s-r-dark .CodeMirror-foldgutter-folded {
    color: #6b7280;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 18px;
}
@media (hover: hover) {
.cm-s-r-dark .CodeMirror-foldgutter-open:hover,
.cm-s-r-dark .CodeMirror-foldgutter-folded:hover {
    color: var(--color-accent);
}
}
.cm-s-r-dark .CodeMirror-foldgutter-open::after {
    /* Семейство берём из FontAwesome (v6/v7 alike) — не хардкодим версию */
    font-family: var(--fa-style-family-classic, 'Font Awesome 7 Free');
    font-weight: 900;
    content: '\f078';
}
.cm-s-r-dark .CodeMirror-foldgutter-folded::after {
    font-family: var(--fa-style-family-classic, 'Font Awesome 7 Free');
    font-weight: 900;
    content: '\f054';
}
.cm-s-r-dark .CodeMirror-cursor {
    border-left: 2px solid var(--color-accent);
}
.cm-s-r-dark .CodeMirror-selected {
    background: rgba(218,194,104,0.15);
}
.cm-s-r-dark.CodeMirror-focused .CodeMirror-selected {
    background: rgba(218,194,104,0.22);
}
.cm-s-r-dark .CodeMirror-activeline-background {
    background: rgba(255,255,255,0.03);
}
.cm-s-r-dark .CodeMirror-matchingbracket {
    color: var(--color-accent) !important;
    background: rgba(218,194,104,0.2);
    outline: none;
}
/* Сворачивание — цвет маркеров */
.cm-s-r-dark .CodeMirror-foldmarker {
    color: var(--color-accent);
    background: none;
    border: none;
    text-shadow: none;
    box-shadow: none;
    font-family: inherit;
    font-weight: 500;
}

/* ── Кастомная валидация (вместо lint addon) ──────────────── */
/* Номер строки с ошибкой — красный */
.cm-s-r-dark .cm-line-error .CodeMirror-linenumber {
    color: var(--color-danger-text);
}
/* Лёгкий красный фон на ошибочной строке */
.cm-s-r-dark .cm-line-error-bg {
    background: rgba(255,110,74,0.06);
}
/* Inline-сообщение под ошибочной строкой */
.cm-lint-inline-error {
    color: var(--color-danger-text);
    font-size: 11px;
    font-family: inherit;
    padding: 2px 8px 2px 6px;
    background: rgba(255,110,74,0.08);
    border-left: 2px solid var(--color-danger-text);
    line-height: 1.4;
    user-select: text;
    cursor: text;
}

/* ── Токены синтаксиса ───────────────────────────────── */
.cm-s-r-dark .cm-keyword    { color: #c792ea; }  /* var, const, function */
.cm-s-r-dark .cm-string     { color: #c3e88d; }  /* строки */
.cm-s-r-dark .cm-number     { color: #f78c6c; }  /* числа */
.cm-s-r-dark .cm-comment    { color: #676e95; font-style: italic; }
.cm-s-r-dark .cm-property   { color: #82aaff; }  /* ключи JSON */
.cm-s-r-dark .cm-def        { color: #82aaff; }  /* определения */
.cm-s-r-dark .cm-operator   { color: #89ddff; }  /* : , = */
.cm-s-r-dark .cm-bracket    { color: #89ddff; }  /* { } [ ] */
.cm-s-r-dark .cm-atom       { color: #ff5370; }  /* true, false, null */
.cm-s-r-dark .cm-meta       { color: #c792ea; }
.cm-s-r-dark .cm-variable   { color: #eeffff; }
.cm-s-r-dark .cm-variable-2 { color: #eeffff; }
.cm-s-r-dark .cm-variable-3 { color: #c792ea; }
.cm-s-r-dark .cm-type       { color: #ffcb6b; }
.cm-s-r-dark .cm-qualifier  { color: #c792ea; }
.cm-s-r-dark .cm-tag        { color: #ff5370; }
.cm-s-r-dark .cm-attribute  { color: #ffcb6b; }
.cm-s-r-dark .cm-builtin    { color: #ffcb6b; }

/* ─── Кастомная стрелка для <select> (видна в Safari, взамен appearance:none) ── */
select.appearance-none {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px 6px;
    padding-right: 32px !important;
}

/* REC pulse animation for video recorder */
@keyframes recPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.rec-dot {
    animation: recPulse 1.2s ease-in-out infinite;
}

/* ── Mobile: увеличенные размеры текста ── */
@media (max-width: 767px) {
    .text-xs   { font-size: 0.8125rem !important; }  /* 13px (было 12) */
    .text-sm   { font-size: 0.9375rem !important; }  /* 15px (было 14) */
    .text-base { font-size: 1.0625rem !important; }  /* 17px (было 16) */
    .text-lg   { font-size: 1.1875rem !important; }  /* 19px (было 18) */
    .text-xl   { font-size: 1.3125rem !important; }  /* 21px (было 20) */
    .text-2xl  { font-size: 1.625rem !important; }  /* 26px (было 24) */
    .text-3xl  { font-size: 1.9375rem !important; }  /* 31px (было 30) */
}

/* ─── R-Platform loader: круг + инлайн-логотип + бегущее кольцо ───
   Логотип рисует компонент <r-loader> (r-icons.js), здесь только
   круг и кольцо. Старого фона icons/r-logo.svg больше нет. */
.r-loader-inline {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(218,194,104,0.06);
    border: 1px solid rgba(218,194,104,0.08);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Spinning ring around the circle */
.r-loader-inline::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 5px solid transparent;
    border-top-color: var(--color-accent);
    border-right-color: var(--color-accent);
    animation: r-loader-spin 1s linear infinite;
}

@keyframes r-loader-spin {
    to { transform: rotate(360deg); }
}

/* Зона спиннера: растягивается на свободное место родителя (flex-колонка
   окна) и центрирует спиннер — одинаково во всех окнах и разделах. */
.modal-loader-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    width: 100%;
    min-height: 200px;
    margin: auto;
}
/* На мобильном загрузчик — поверх области тела окна (позиционируется
   от неё, а не от контента): центр всегда точный, независимо от длины. */
@media (max-width: 767px) {
    .modal-loader-zone {
        position: absolute;
        inset: 0;
        min-height: 0;
    }
}

/* ─── Кнопки подвала окон: единый размер во всех окнах ───
   Ширина и высота — глобально (сжатие по всей ширине, два кнопки поровну),
   цвет и фон — в самих окнах (класс modal-btn-gold — премиум-золото). */
.modal-footer { display: flex; align-items: stretch; gap: 12px; }
.modal-footer > button,
.modal-footer > a,
.modal-footer > div > button,
.modal-footer > div > a {
    flex: 1 1 0;
    min-width: 0;
    height: 44px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}
.modal-footer > div { display: flex; align-items: stretch; gap: 12px; flex: 1 1 auto; min-width: 0; }
/* Все модальные варианты — одна законченная геометрия:
   высота 44px, отступы 16px, шрифт 14/600, контур 1px.
   Меняется только цвет. */
.modal-btn-gold,
.modal-btn-dark,
.modal-btn-plate,
.modal-btn-danger {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    color: var(--color-accent);
    transition: transform 0.12s ease, opacity 0.15s ease;
}
.modal-btn-gold:active,
.modal-btn-dark:active,
.modal-btn-plate:active,
.modal-btn-danger:active { transform: scale(0.98); }
.modal-btn-gold,
.r-btn--gold {
    background: linear-gradient(180deg, rgba(218,194,104,0.22), rgba(218,194,104,0.10));
    border-color: rgba(218,194,104,0.45);
}
/* Тёмная кнопка с золотой обводкой */
.modal-btn-dark,
.r-btn--dark {
    background: var(--color-bg-canvas);
    border-color: rgba(218,194,104,0.45);
}
/* Плашка: тёмная поверхность с серой рамкой */
.modal-btn-plate,
.r-btn--plate {
    background: var(--color-bg-tertiary);
    border-color: var(--color-border);
}

/* ─── Универсальные кнопки платформы ─────────────────────────
   Все кнопки используют одну геометрию и палитру платформы.
   Толщина контура — 1px, радиус — полная пилюля. */

/* Круглая кнопка с иконкой: шапки панелей, списки, действия. */
.r-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-tertiary);
    color: var(--color-accent);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.r-icon-btn:active { transform: scale(0.94); }
.r-icon-btn > i { font-size: 14px; line-height: 1; }
.r-icon-btn--xs { width: 32px; height: 32px; }
.r-icon-btn--xs > i { font-size: 12px; }
.r-icon-btn--xs:active { transform: scale(0.90); }
.r-icon-btn--sm { width: 36px; height: 36px; }
.r-icon-btn--sm > i { font-size: 12px; }
.r-icon-btn--sm:active { transform: scale(0.92); }
.r-icon-btn--lg { width: 48px; height: 48px; }
.r-icon-btn--lg > i { font-size: 16px; }
.r-icon-btn--lg:active { transform: scale(0.95); }
.r-icon-btn--accent { border-color: rgba(218, 194, 104, 0.45); }
.r-icon-btn--dark {
    background: var(--color-bg-canvas);
    border-color: rgba(218, 194, 104, 0.45);
    color: var(--color-accent);
}
.r-icon-btn--gold {
    background: linear-gradient(180deg, rgba(218, 194, 104, 0.22), rgba(218, 194, 104, 0.10));
    border-color: rgba(218, 194, 104, 0.45);
    color: var(--color-accent);
}
.r-icon-btn--danger { color: var(--color-text-dark); }

/* Поле-пилюля: поиск и другие контейнеры с иконкой и инпутом. */
.r-field {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 16px;
    min-width: 0;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 999px;
}
/* Одиночный инпут в той же геометрии. */
.r-field-input {
    height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
    outline: none;
}

/* Кнопка-пилюля общего назначения. */
.r-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.r-btn:active { transform: scale(0.98); }
.r-btn--sm {
    height: 36px;
    padding: 0 14px;
    font-size: 12px;
}

/* Компактный чип-кнопка (настройки, быстрые действия). */
/* Компактная кнопка-пилюля: полностью самодостаточная.
   Размер по умолчанию — 32px, --md — 36px, --lg — 44px. */
.r-chip-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-tertiary);
    color: var(--color-text-muted);
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.r-chip-btn:active { transform: scale(0.94); }
.r-chip-btn--md {
    height: 36px;
    padding: 0 16px;
    font-size: 14px;
    line-height: 20px;
}
.r-chip-btn--lg {
    height: 44px;
    padding: 0 16px;
    font-size: 14px;
    line-height: 20px;
}
.r-chip-btn--dark {
    background: var(--color-bg-canvas);
    border-color: var(--color-border);
    color: var(--color-accent);
}
.r-chip-btn--danger {
    background: var(--color-danger-bg);
    border-color: var(--color-danger-border);
    color: var(--color-danger-text);
}
.r-chip-btn--gold {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #000;
}
.r-chip-btn--danger-solid,
.modal-btn-danger,
.r-btn--danger {
    background: var(--color-danger-text);
    border-color: var(--color-danger-text);
    color: #fff;
}

/* ─── Выезжающая панель (r-sheet) ─────────────────────────────
   Панель выезжает снизу и уезжает обратно тем же движением;
   фон тает вместе с ней. Пока панель тянут за «ручку»,
   transform и прозрачность тени задаются inline-стилем. */
.r-sheet-panel {
    background: #1A1A1A;
}
/* Шапка листа: ручка + заголовок. Одна на все панели —
   чуть темнее тела, с тонкой золотой линией снизу. */
.r-sheet-grab {
    background: linear-gradient(180deg, #0F0F0F 0%, #151515 100%);
    border-bottom: 1px solid rgba(218, 194, 104, 0.12);
    border-radius: 1.5rem 1.5rem 0 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
/* Мягкая тень над панелью — отдельным слоем: она тает вместе
   с панелью, а не схлопывается в последний момент. */
.r-sheet-panel::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 48px;
    transform: translateY(-100%);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0));
    opacity: var(--r-sheet-shade, 1);
    transition: opacity 0.18s ease;
    pointer-events: none;
}

.r-sheet-enter-active .r-sheet-panel,
.r-sheet-leave-active .r-sheet-panel {
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.r-sheet-enter-from .r-sheet-panel,
.r-sheet-leave-to .r-sheet-panel {
    transform: translateY(100%);
    --r-sheet-shade: 0;
}
/* Тень гаснет ровно столько же, сколько едет панель */
.r-sheet-leave-active .r-sheet-panel::before { transition-duration: 0.3s; }

.r-sheet-enter-active .r-sheet-backdrop { transition: opacity 0.2s ease; }
.r-sheet-leave-active .r-sheet-backdrop { transition: opacity 0.3s ease; }
.r-sheet-enter-from .r-sheet-backdrop,
.r-sheet-leave-to .r-sheet-backdrop {
    opacity: 0;
}

/* ─── Верхний вариант r-sheet: выезжает сверху ─────────────── */
.r-sheet-panel--top {
    top: 0;
    bottom: auto;
    border-top: 0;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0 0 1.5rem 1.5rem;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
.r-sheet-panel--top::before { display: none; }

/* Заголовок верхней панели — та же тёмная шапка, что у нижней. */
.r-sheet-head--top {
    background: linear-gradient(180deg, #0F0F0F 0%, #151515 100%);
    border-bottom: 1px solid rgba(218, 194, 104, 0.12);
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

/* Крестик верхней панели: постоянный фон, без hover-подсветки,
   нажатие — лёгкое уменьшение, как у QR-кода на карте. */
.r-sheet-close {
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.045);
    transition: transform 0.15s ease;
}
.r-sheet-close:active {
    transform: scale(0.97);
}

/* Нижняя полоса верхней панели: за неё тянут вверх. */
.r-sheet-grab--bottom {
    background: linear-gradient(0deg, #0F0F0F 0%, #151515 100%);
    border-top: 1px solid rgba(218, 194, 104, 0.12);
    border-bottom: 0;
    border-radius: 0;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

.r-sheet-enter-from .r-sheet-panel--top,
.r-sheet-leave-to .r-sheet-panel--top {
    transform: translateY(-100%);
    --r-sheet-shade: 0;
}

/* ─── Кнопка QR на карте — как чип на банковской карте ────────
   Размер привязан к ширине карты (14% / 11%), поэтому она одинаково
   смотрится и на живой карте, и в уменьшенном превью.
   Без эффектов при наведении — только отклик на нажатие. */
.rcard-card { container-type: inline-size; }

.rcard-qr {
    width: 56px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(180deg, rgba(218, 194, 104, 0.20), rgba(218, 194, 104, 0.06)),
        linear-gradient(180deg, #242424, #151515);
    border: 1px solid rgba(218, 194, 104, 0.42);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.10),
        inset 0 -1px 0 rgba(0, 0, 0, 0.35),
        0 2px 8px rgba(0, 0, 0, 0.35);
    color: #DAC268;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.rcard-qr i { font-size: 20px; line-height: 1; }

/* Тот же чип 1:1 по пропорциям карты (56×44 при ширине 420) */
@supports (container-type: inline-size) {
    .rcard-qr {
        width: 13.4cqw;
        height: 10.5cqw;
        border-radius: 2.9cqw;
    }
    .rcard-qr i { font-size: 4.8cqw; }
}

.rcard-qr:active { transform: scale(0.97); }

/* R-Battery на карте — та же тактильная реакция, что у QR-чипа. */
.rcard-battery {
    transition: transform 0.15s ease;
}
.rcard-battery:active { transform: scale(0.97); }

/* ─── R-Battery: слайдер пакетов зарядов ───────────────────── */
.battery-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 28px;
    background: transparent;
    cursor: pointer;
    outline: none;
}
.battery-slider::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg,
        #DAC268 0%,
        #DAC268 var(--battery-pct, 0%),
        rgba(255,255,255,0.08) var(--battery-pct, 0%),
        rgba(255,255,255,0.08) 100%);
}
.battery-slider::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
}
.battery-slider::-moz-range-progress {
    height: 4px;
    border-radius: 999px;
    background: #DAC268;
}
.battery-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    width: 18px;
    height: 18px;
    margin-top: -7px;
    border-radius: 50%;
    background: #DAC268;
    border: 2px solid #1A1A1A;
    box-shadow: 0 0 0 2px rgba(218,194,104,0.25);
}
.battery-slider::-moz-range-thumb {
    box-sizing: border-box;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #DAC268;
    border: 2px solid #1A1A1A;
    box-shadow: 0 0 0 2px rgba(218,194,104,0.25);
}

/* Start: та же форма, но приглушённая — карта без Premium */
.rcard-qr.is-start {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border-color: rgba(218, 194, 104, 0.20);
    color: rgba(218, 194, 104, 0.55);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 2px 6px rgba(0, 0, 0, 0.30);
}

/* В превью-карте кнопка не нажимается — она только показывает вид */
.rcard-qr.is-static { cursor: default; pointer-events: none; }

/* «Ручка»: узкая полоска — сразу видно, что панель можно тянуть.
   На наведении/нажатии только подсветка, ширина не меняется. */
.r-sheet-pill {
    width: 44px;
    height: 4px;
    background: rgba(255, 255, 255, 0.22);
    transition: background 0.18s ease;
}
.r-sheet-grab:hover .r-sheet-pill {
    background: rgba(255, 255, 255, 0.34);
}
.r-sheet-grab:active .r-sheet-pill {
    background: rgba(255, 255, 255, 0.45);
}

/* Имя владельца под QR-кодом: тот же золотой перелив, что у кода,
   чтобы читалось с ним как одно целое. */
.qr-name {
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.15;
    background: linear-gradient(180deg, #FAEFCC 0%, #DAC268 55%, #B08F38 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    overflow-wrap: anywhere;
}

/* ─── Rail (свёрнутая панель): мягкое появление иконок ─── */

/* ─── Autofill — убрать жёлтый фон Safari/Chrome ─────────────── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--color-bg-tertiary) inset !important;
    -webkit-text-fill-color: #fff !important;
    caret-color: #fff;
    transition: background-color 5000s ease-in-out 0s !important;
}
/* placeholder всегда серый, даже после очистки autofill — иначе в Safari становится белым */
input::placeholder { color: #6b7280 !important; opacity: 1 !important; }
input:-webkit-autofill::placeholder { -webkit-text-fill-color: #6b7280 !important; color: #6b7280 !important; }

/* ─── Left Sidebar Panel ──────────────────────────────────── */
/* ─── Переключение валюты баланса на R-Card (RD ⇄ локальная) ───
   Кроссфейд: старое и новое идут одновременно, без паузы посередине.
   Уходящий слой — absolute (позиция сохраняется), оба на GPU — без рывков. */
.curswap-enter-active, .curswap-leave-active { transition: opacity 0.22s cubic-bezier(0.33, 1, 0.68, 1), transform 0.22s cubic-bezier(0.33, 1, 0.68, 1); will-change: opacity, transform; backface-visibility: hidden; transform: translateZ(0); }
.curswap-leave-active { position: absolute; }
.curswap-enter-from { opacity: 0; transform: translateY(10px) translateZ(0); }
.curswap-leave-to { opacity: 0; transform: translateY(-10px) translateZ(0); }
/* ─── Notification toasts — появление/уход ────────────────── */
.r-toast-enter-active { transition: all 0.25s cubic-bezier(0.22, 0.61, 0.36, 1); }
.r-toast-leave-active { transition: all 0.18s ease; }
.r-toast-enter-from { opacity: 0; transform: translateY(-10px); }
.r-toast-leave-to { opacity: 0; transform: translateY(-6px); }
.r-toast-move { transition: transform 0.22s ease; }
/* R-Chat list items inside left panel — compact at narrower width */
.r-chat-left-item {
    font-size: 0.8125rem;
}
@media (max-width: 767px) {
    .r-chat-left-item {
        font-size: 0.875rem;
    }
}

/* ─── Дерево входящих данных: ховер на листьях ──────────────── */
.tree-leaf {
    transition: background-color 0.15s;
}
@media (hover: hover) {
.tree-leaf:hover {
    background-color: rgba(218, 194, 104, 0.3);
}
}
.tree-leaf .leaf-arrow {
    opacity: 0;
    transition: opacity 0.15s;
}
@media (hover: hover) {
.tree-leaf:hover .leaf-arrow {
    opacity: 1;
}
}

/* ─── Кнопка открытия редактора (внутри поля) ──────────────── */
@media (hover: hover) {
.field-editor-btn:hover {
    background-color: rgba(218, 194, 104, 0.35);
}
}

/* ─── Подсветка {{...}} в overlay-полях ──────────────────────── */
.r-accent-brace {
    color: var(--color-accent);
}

/* ─── Скрытый скроллбар для inspector-tabs ───────────────── */
.inspector-tabs::-webkit-scrollbar { display: none; }
.inspector-tabs { -ms-overflow-style: none; scrollbar-width: none; }

/* ─── QR-сканер (выезжающая панель окна отправки) ─────────────
   Камера заполняет сцену. Вокруг квадратного окна — матовое
   стекло единым слоем с вырезом, по углам — скобки.
   Сторона окна приходит из JS как --qr-square: значение валидно
   с первого кадра и меняется только при смене ширины сцены,
   поэтому окно никогда не «перерастает» после открытия. */
.r-qr-scanner {
    /* Тело листа — flex-колонка (body-flex): сканер ровно заполняет
       доступную высоту. Минимум даёт связка «видоискатель 260px +
       строка действий»: если окно ниже, панель скроллится. */
    flex: 1 1 0;
    width: 100%;
    display: flex;
    flex-direction: column;
}
.r-qr-scanner-stage {
    position: relative;
    flex: 1 1 0;
    min-height: 260px;
    overflow: hidden;
    background: #000;
}
.r-qr-scanner-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
    transition: opacity 0.3s ease;
}

/* Заглушка, пока камера готовится (как в записи видеоклипа в чате) */
.r-qr-scanner-preparing {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    font-weight: 500;
}
.r-qr-scanner-pulse {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-accent);
    flex-shrink: 0;
    animation: r-qr-pulse 1.2s ease-in-out infinite;
}
@keyframes r-qr-pulse {
    0%, 100% { opacity: 0.45; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1); }
}
.r-qr-scanner-veil {
    position: absolute;
    inset: -2px;
    background: rgba(4, 4, 6, 0.46);
    -webkit-backdrop-filter: blur(14px) saturate(0.9);
    backdrop-filter: blur(14px) saturate(0.9);
    pointer-events: none;
}

.r-qr-scanner-box {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--qr-square, 240px);
    height: var(--qr-square, 240px);
    transform: translate(-50%, -50%);
    border-radius: 20px;
    pointer-events: none;
}
/* Скобки снаружи окна: внешняя дуга на 2px дальше выреза,
   внутренний край на 1px заходит на скруглённый угол. */
.r-qr-scanner-corner {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 0 solid var(--color-accent);
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}
.r-qr-scanner-corner-tl {
    top: -2px;
    left: -2px;
    border-top-width: 3px;
    border-left-width: 3px;
    border-top-left-radius: 22px;
}
.r-qr-scanner-corner-tr {
    top: -2px;
    right: -2px;
    border-top-width: 3px;
    border-right-width: 3px;
    border-top-right-radius: 22px;
}
.r-qr-scanner-corner-bl {
    bottom: -2px;
    left: -2px;
    border-bottom-width: 3px;
    border-left-width: 3px;
    border-bottom-left-radius: 22px;
}
.r-qr-scanner-corner-br {
    bottom: -2px;
    right: -2px;
    border-bottom-width: 3px;
    border-right-width: 3px;
    border-bottom-right-radius: 22px;
}

.r-qr-scanner-hint {
    position: absolute;
    left: 50%;
    top: calc(50% + var(--qr-square, 240px) / 2 + (100% - var(--qr-square, 240px)) / 4);
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 28px);
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(18, 18, 18, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: #d1d5db;
    font-size: 0.875rem;
    line-height: 1.25;
    white-space: nowrap;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    pointer-events: none;
}
.r-qr-scanner-hint-text {
    overflow: hidden;
    text-overflow: ellipsis;
}
.r-qr-scanner-hint.is-error {
    color: #fda4af;
    border-color: rgba(244, 63, 94, 0.28);
}

.r-qr-scanner-retry {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(26, 26, 26, 0.9);
    color: #e5e7eb;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
    .r-qr-scanner-retry:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
}

.r-qr-scanner-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 20px;
    background: #1A1A1A;
}
.r-qr-scanner-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.05);
    color: #d1d5db;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
    .r-qr-scanner-btn:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
}
.r-qr-scanner-btn:active { transform: scale(0.98); }
.r-qr-scanner-btn.is-on {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #17130E;
}
.r-qr-scanner-file {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    left: -9999px;
}

/* ─────────────────────────────────────────────────────────────
   Portrait gate — телефон в горизонтальной ориентации.

   iOS Safari не даёт запретить поворот (Screen Orientation API и
   manifest orientation там не работают), поэтому в landscape
   показываем премиальную заглушку вместо сломанного лейаута.
   На десктопе и планшетах не показывается: только coarse pointer
   и небольшая высота экрана.
   ───────────────────────────────────────────────────────────── */
.r-rotate-gate { display: none; }

@media (orientation: landscape) and (max-height: 540px) and (hover: none) and (pointer: coarse) {
    .r-rotate-gate {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 10000;
        align-items: center;
        justify-content: center;
        padding: calc(env(safe-area-inset-top) + 14px) calc(env(safe-area-inset-right) + 20px) calc(env(safe-area-inset-bottom) + 14px) calc(env(safe-area-inset-left) + 20px);
        overflow: hidden;
        background:
            radial-gradient(90% 70% at 50% 0%, rgba(218, 194, 104, 0.14), transparent 62%),
            radial-gradient(70% 55% at 50% 110%, rgba(218, 194, 104, 0.07), transparent 70%),
            #0F0F0F;
        -webkit-tap-highlight-color: transparent;
        -webkit-user-select: none;
        user-select: none;
        touch-action: none;
    }
    .r-rotate-gate::before {
        content: '';
        position: absolute;
        top: -140px;
        left: 50%;
        width: 340px;
        height: 340px;
        border-radius: 50%;
        border: 1px solid rgba(218, 194, 104, 0.08);
        transform: translateX(-50%);
        pointer-events: none;
    }
    .r-rotate-gate::after {
        content: '';
        position: absolute;
        top: -190px;
        left: 50%;
        width: 440px;
        height: 440px;
        border-radius: 50%;
        border: 1px solid rgba(218, 194, 104, 0.05);
        transform: translateX(-50%);
        pointer-events: none;
    }
}

.r-rotate-gate__inner {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "device brand"
        "device title"
        "device text"
        "device hint";
    align-items: center;
    width: 100%;
    max-width: 560px;
    padding: 26px 30px;
    text-align: left;
    border-radius: 22px;
    border: 1px solid rgba(218, 194, 104, 0.16);
    background: linear-gradient(180deg, rgba(34, 34, 34, 0.94) 0%, rgba(22, 22, 22, 0.98) 100%);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.60), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.r-rotate-gate__inner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 28px;
    right: 28px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(218, 194, 104, 0.55), transparent);
}

.r-rotate-gate__brand {
    grid-area: brand;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    color: rgba(218, 194, 104, 0.92);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
.r-rotate-gate__logo {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    opacity: 0.95;
}

.r-rotate-gate__device {
    grid-area: device;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 110px;
    height: 110px;
    margin-right: 28px;
}
.r-rotate-gate__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(218, 194, 104, 0.14);
    background: radial-gradient(circle at 50% 45%, rgba(218, 194, 104, 0.10), transparent 65%);
}
.r-rotate-gate__ring::after {
    content: '';
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    border: 1px dashed rgba(218, 194, 104, 0.16);
}
.r-rotate-gate__phone {
    position: relative;
    width: 34px;
    height: 56px;
    border-radius: 8px;
    border: 1.5px solid rgba(218, 194, 104, 0.75);
    background: linear-gradient(180deg, rgba(218, 194, 104, 0.16), rgba(218, 194, 104, 0.04));
    box-shadow: 0 0 22px rgba(218, 194, 104, 0.14);
    animation: r-rotate-phone 3.8s ease-in-out infinite;
}
.r-rotate-gate__notch {
    position: absolute;
    top: 4px;
    left: 50%;
    width: 10px;
    height: 2px;
    border-radius: 2px;
    background: rgba(218, 194, 104, 0.55);
    transform: translateX(-50%);
}
.r-rotate-gate__screen {
    position: absolute;
    inset: 9px 4px 10px;
    border-radius: 3px;
    background: linear-gradient(180deg, rgba(218, 194, 104, 0.25), rgba(218, 194, 104, 0.04));
}
.r-rotate-gate__home {
    position: absolute;
    bottom: 4px;
    left: 50%;
    width: 8px;
    height: 1.5px;
    border-radius: 2px;
    background: rgba(218, 194, 104, 0.45);
    transform: translateX(-50%);
}
.r-rotate-gate__arrow {
    position: absolute;
    right: 0;
    bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(218, 194, 104, 0.35);
    background: #1B1B1B;
    color: var(--color-accent);
    font-size: 11px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.40);
}

@keyframes r-rotate-phone {
    0%, 18% { transform: rotate(-90deg); }
    50%, 82% { transform: rotate(0deg); }
    100% { transform: rotate(-90deg); }
}

.r-rotate-gate__title {
    grid-area: title;
    margin: 6px 0 0;
    color: #F4F1E6;
    font-size: 20px;
    line-height: 1.15;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.r-rotate-gate__text {
    grid-area: text;
    max-width: 330px;
    margin: 6px 0 0;
    color: #9CA3AF;
    font-size: 14px;
    line-height: 1.55;
}
.r-rotate-gate__hint {
    grid-area: hint;
    display: inline-flex;
    align-items: center;
    justify-self: start;
    gap: 7px;
    height: 32px;
    margin-top: 14px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(218, 194, 104, 0.22);
    background: rgba(218, 194, 104, 0.08);
    color: var(--color-accent);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.r-rotate-gate__hint i {
    font-size: 11px;
    animation: r-rotate-hint 1.8s ease-in-out infinite;
}
@keyframes r-rotate-hint {
    0%, 100% { transform: translateY(1px); }
    50% { transform: translateY(-2px); }
}

/* Очень низкие экраны (iPhone SE в горизонтали): компактнее, но
   всё ещё читаемо и без обрезаний. */
@media (orientation: landscape) and (max-height: 380px) and (hover: none) and (pointer: coarse) {
    .r-rotate-gate__inner {
        max-width: 520px;
        padding: 14px 22px;
    }
    .r-rotate-gate__device {
        width: 84px;
        height: 84px;
        margin-right: 20px;
    }
    .r-rotate-gate__phone {
        width: 30px;
        height: 50px;
    }
    .r-rotate-gate__screen { inset: 8px 4px 9px; }
    .r-rotate-gate__title { margin-top: 4px; font-size: 18px; }
    .r-rotate-gate__text { margin-top: 4px; line-height: 1.45; }
    .r-rotate-gate__hint { margin-top: 8px; height: 30px; }
}

/* ─── Производительность длинных списков ─────────────────────
   Строки имеют фиксированную высоту, поэтому content-visibility
   позволяет браузеру не раскладывать и не рисовать то, что за
   пределами экрана. contain-intrinsic-size сохраняет высоту
   скролла до первого рендера строки. */
.list-row-cv {
    content-visibility: auto;
    contain-intrinsic-size: auto 93px;
    contain: layout style paint;
}
.list-row-cv--compact {
    contain-intrinsic-size: auto 77px;
}

/* Фон элемента приложения — один общий класс вместо длинного
   inline-стиля в каждой строке. Без внешней тени и фильтров. */
.r-chat-app-row {
    background:
        radial-gradient(170px 120px at 0% 50%, rgba(246, 231, 180, 0.075), transparent 72%),
        linear-gradient(115deg, #1E1E1E 0%, #191919 50%, #1C1A16 100%);
}

/* Long-press / правый клик по строке не должен выделять текст
   ни на мобильном, ни на desktop — меню открывается одинаково. */
.r-chat-row,
.r-chat-row *,
.r-list-menu,
.r-list-menu * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Универсальное контекстное меню списка: раскрывается под строкой,
   остальной фон затемняется. */
.r-list-menu-scrim {
    background: rgba(0, 0, 0, 0.52);
    touch-action: none;
    animation: r-list-menu-scrim-in 160ms ease-out;
}
.r-list-menu {
    touch-action: pan-y;
    animation: r-list-menu-in 190ms cubic-bezier(0.2, 0.9, 0.25, 1);
    transform-origin: top center;
}
@keyframes r-list-menu-scrim-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes r-list-menu-in {
    from { opacity: 0; transform: translateY(-7px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Единые теги платформы ──────────────────────────────────
   r-tag      — тег на элементе списка или карточки;
   r-tag-chip — чип фильтра в выпадающем списке тегов/категорий.
   Размеры одинаковые во всех разделах: чаты, приложения, лента. */
.r-tag {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    white-space: nowrap;
}
.r-tag > i {
    font-size: 9px;
    opacity: 0.7;
}
.r-tag-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.r-tag-chip:active { transform: scale(0.94); }
.r-tag-chip > i {
    font-size: 10px;
    opacity: 0.7;
}

/* ─── Единая лента тегов/категорий (r-tag-strip) ───
   Одна горизонтальная полоса пилюль: чаты, R-Bot, R-Apps.
   Свой цвет, иконка тега/галка, мультивыбор, прокрутка вбок. */
.r-tags-strip {
    padding: 10px 0;
    background: #161616;
    border-bottom: 1px solid var(--color-border);
}
.r-tags-scroll {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 94%, transparent 100%);
    mask-image: linear-gradient(90deg, #000 0%, #000 94%, transparent 100%);
}
.r-tags-scroll::-webkit-scrollbar { display: none; }
.r-tag-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 2px solid transparent;
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.r-tag-pill > i { font-size: 10px; opacity: 0.75; }
.r-tag-pill:active { transform: scale(0.96); }
.r-tags-empty {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    color: #6b7280;
    font-size: 14px;
    font-style: italic;
}

/* ─── Карточка приложения (Marketplace) ─────────────────────── */
.r-app-hero-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 0 16px 2px;
    scrollbar-width: none;
}
.r-app-hero-track::-webkit-scrollbar { display: none; }
.r-app-hero-slide {
    position: relative;
    flex: 0 0 86%;
    aspect-ratio: 16 / 9;
    scroll-snap-align: center;
    border-radius: 18px;
    overflow: hidden;
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.07);
}
.r-app-hero-slide img,
.r-app-hero-slide video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.r-app-hero-play {
    position: absolute;
    inset: 0;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding-left: 3px;
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    background: rgba(12, 12, 12, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
}
.r-app-cover {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid rgba(246, 231, 180, 0.16);
    background:
        radial-gradient(120% 150% at 20% 0%, rgba(246, 231, 180, 0.20), rgba(218, 194, 104, 0.04) 55%, transparent 75%),
        linear-gradient(150deg, #2A2113 0%, #1A150C 58%, #110E08 100%);
}
.r-app-cover-glow {
    position: absolute;
    top: -60px;
    right: -40px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(246, 231, 180, 0.20), transparent 65%);
    filter: blur(6px);
    pointer-events: none;
}
.r-app-cover-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 86px;
    height: 86px;
    border-radius: 24px;
    background: radial-gradient(circle at 28% 18%, rgba(246, 231, 180, 0.32), transparent 55%), linear-gradient(150deg, #2A2113 0%, #1A150C 58%, #110E08 100%);
    box-shadow: inset 0 0 0 1px rgba(246, 231, 180, 0.22);
}
.r-app-cover-name {
    position: relative;
    margin-top: 12px;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(135deg, #FAEFCC 0%, #E7D28F 45%, #DAC268 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Полноэкранный просмотр медиа карточки */
.r-media-viewer {
    position: fixed;
    inset: 0;
    z-index: 270;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(5, 5, 5, 0.97);
}
.r-media-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}
.r-media-track::-webkit-scrollbar { display: none; }
.r-media-slide {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: center;
    padding: 0 10px;
}
.r-media-slide img {
    max-width: 100%;
    max-height: 78vh;
    border-radius: 14px;
}
.r-media-slide .r-video { border-radius: 14px; overflow: hidden; }
.r-media-close {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: 16px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(8px);
    color: #fff;
}
.r-media-count {
    position: absolute;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: rgba(255, 255, 255, 0.75);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

/* ─── Универсальный видеоплеер ───────────────────────────────
   Один компонент на всю платформу: карточки приложений, чаты,
   будущие разделы. Широкий и квадратный форматы. */
.r-video {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #000;
    user-select: none;
    -webkit-user-select: none;
}
.r-video video {
    display: block;
    width: 100%;
    height: 100%;
    background: #000;
}
.r-video-hit {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.r-video-play {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding-left: 3px;
    border-radius: 50%;
    background: rgba(14, 14, 14, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    transition: transform 0.16s ease, background-color 0.16s ease;
}
.r-video-hit:active .r-video-play { transform: scale(0.94); }
.r-video-play--lg { width: 64px; height: 64px; font-size: 20px; }
.r-video-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 30px 12px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.74), rgba(0, 0, 0, 0));
}
.r-video-time {
    min-width: 28px;
    text-align: center;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.72);
}
.r-video-track {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    height: 20px;
    cursor: pointer;
    touch-action: none;
}
.r-video-track::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
}
.r-video-fill {
    position: absolute;
    left: 0;
    height: 3px;
    border-radius: 999px;
    background: var(--color-accent);
}
.r-video-thumb {
    position: absolute;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--color-accent);
    transform: translateX(-50%);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35);
}
.r-video-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.82);
    background: rgba(255, 255, 255, 0.08);
}
.r-video-icon-btn i { font-size: 11px; }

/* Полноэкранный режим */
.r-video-fs-layer {
    position: fixed;
    inset: 0;
    z-index: 260;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 6, 6, 0.97);
}
.r-video-fs-inner {
    position: relative;
    width: 100%;
    height: 100%;
}
.r-video-fs-inner video {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    object-fit: contain;
    background: #000;
}
.r-video-fs-close {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: 16px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(8px);
    color: #fff;
}
.r-video-bar--fs { padding: 34px 20px calc(16px + env(safe-area-inset-bottom)); }
.r-video-fs-enter-active,
.r-video-fs-leave-active { transition: opacity 0.18s ease; }
.r-video-fs-enter-from,
.r-video-fs-leave-to { opacity: 0; }

/* Переключатель в меню и настройках — один стиль на всю платформу. */
.r-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    width: 44px;
    height: 26px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}
.r-switch:disabled { opacity: 0.5; cursor: not-allowed; }
.r-switch--sm { width: 40px; height: 24px; }
.r-switch--sm .r-switch-knob { top: 3px; left: 3px; }
.r-switch--sm.is-on .r-switch-knob { transform: translateX(16px); }
.r-switch-knob {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #9a9a9a;
    transition: transform 0.18s ease, background-color 0.18s ease;
}
.r-switch.is-on {
    background: rgba(218, 194, 104, 0.16);
    border-color: rgba(218, 194, 104, 0.55);
}
.r-switch.is-on .r-switch-knob {
    transform: translateX(18px);
    background: var(--color-accent);
}

/* Группа приложений — последняя в ряду вкладок и выглядит как обычная вкладка:
   те же отступы, высота, шрифт, фон и золотая подсветка. Отличие — шеврон. */
.r-gsearch-appgroup {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid transparent;
    color: #d1d5db;
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.r-gsearch-appgroup > i:first-child { font-size: 10px; opacity: 0.7; }
.r-gsearch-appgroup-chevron { font-size: 9px; opacity: 0.7; transition: transform 0.18s ease; }
/* Открыта группа или выбран апп — в точности как активная вкладка */
.r-gsearch-appgroup.is-open,
.r-gsearch-appgroup.is-active {
    background: rgba(218, 194, 104, 0.14);
    border-color: transparent;
    color: var(--color-accent);
}
.r-gsearch-appgroup.is-open .r-gsearch-appgroup-chevron { transform: rotate(180deg); }
.r-gsearch-appgroup:active { transform: scale(0.96); }
/* Раскрытая группа: вкладки приложений под системными. */
.r-gsearch-approw {
    padding: 8px 0;
    background: #171717;
    border-bottom: 1px solid var(--color-border);
}
.r-gsearch-approw button {
    font-size: 13px;
    line-height: 17px;
    padding-left: 10px;
    padding-right: 10px;
}

/* Все пилюли r-tabs мягко «прижимаются» при нажатии — как кнопки платформы. */
.r-tabs > div > button {
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.r-tabs > div > button:active { transform: scale(0.96); }

/* Счётчик на вкладке r-tabs: число найденного в разделе. */
.r-tabs-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

/* ─── Единый поиск по платформе ──────────────────────────────── */
/* Шапка окна поиска: строка ввода на всю высоту шапки. */
/* Поле поиска. Иконка — часть плейсхолдера: она нарисована в самом поле
   слева от текста-подсказки и исчезает ровно тогда, когда исчезает
   плейсхолдер (появился введённый текст) — вместе с отступом под неё. */
.r-gsearch-field {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    min-width: 0;
}
/* Кнопка очистки занимает место справа — текст не заезжает под неё */
.r-gsearch-field.has-value .r-gsearch-header-input { padding-right: 44px; }
.r-gsearch-clear-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #b8b8b8;
    font-size: 11px;
    line-height: 1;
    transition: transform 0.12s ease, background-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.r-gsearch-clear-btn:active {
    transform: translateY(-50%) scale(0.9);
    background: rgba(255, 255, 255, 0.12);
}
/* Невидимая зона нажатия: визуально 28–32px, под палец — ~44px */
.r-gsearch-clear-btn::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
}
.r-gsearch-header-input {
    width: 100%;
    height: 100%;
    padding: 0 0 0 30px;
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='16.5' y1='16.5' x2='21' y2='21'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0 50%;
    background-size: 18px 18px;
    border: 0;
    outline: none;
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    caret-color: var(--color-accent);
    -webkit-appearance: none;
    transition: padding-left 0.12s ease;
}
.r-gsearch-header-input::placeholder { color: #6b7280 !important; opacity: 1; }
.r-gsearch-header-input:not(:placeholder-shown) {
    padding-left: 0;
    background-image: none;
}

.r-gsearch-section { padding-top: 0; }
.r-gsearch-section-title {
    padding: 10px 16px;
    background: #1C1C1C;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #6b7280;
}
.r-gsearch-section-title--row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.r-gsearch-clear {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: #8a8a8a;
    transition: color 0.15s ease;
}
.r-gsearch-clear:active { color: var(--color-accent); }
/* В окне поиска подписи вкладок и последних запросов — читаемые, не мельче xs */
.r-gsearch-tabs button { font-size: 13px; line-height: 18px; padding-left: 10px; padding-right: 10px; }
.r-gsearch-recent button { font-size: 14px; line-height: 18px; }
/* Недавние запросы: компактный ряд пилюль r-tabs (size="sm", bar=false).
   Отступы слева/справа даёт сам r-tabs — они совпадают с вкладками категорий. */
.r-gsearch-recent {
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

/* Окно поиска: собственная ширина, не зависит от набора утилит Tailwind. */
.r-gsearch-modal {
    width: 100%;
    max-width: 48rem;
}
/* Строка результата — как в списке чатов и ленте активности. */
.r-gsearch-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 62px;
    padding: 0 16px;
    border-radius: 0;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    transition: background-color 0.15s ease;
}
.r-gsearch-row:hover { background: rgba(255, 255, 255, 0.025); }
.r-gsearch-row:active { background: rgba(255, 255, 255, 0.05); }
/* Строка под клавиатурным выбором ↑/↓ */
.r-gsearch-row.is-active {
    background: rgba(218, 194, 104, 0.08);
    box-shadow: inset 2px 0 0 var(--color-accent);
}
.r-gsearch-row-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: rgba(218, 194, 104, 0.10);
    color: var(--color-accent);
    font-size: 15px;
}
.r-gsearch-row-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.r-gsearch-row-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #f3f4f6;
    font-size: 15px;
    line-height: 20px;
    font-weight: 500;
}
.r-gsearch-row-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
    color: #8a8a8a;
    font-size: 14px;
    line-height: 19px;
}
.r-gsearch-row-meta {
    flex-shrink: 0;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #6b7280;
    font-size: 13px;
}
/* Подсветка совпадения в названии и подзаголовке */
.r-gsearch-hl {
    background: transparent;
    color: var(--color-accent);
    font-weight: 700;
}
/* «Show all N in …» — переход в раздел без потери запроса */
.r-gsearch-more {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-accent);
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    transition: background-color 0.15s ease;
}
.r-gsearch-more > i { font-size: 12px; opacity: 0.8; }
.r-gsearch-more:active { background: rgba(255, 255, 255, 0.04); }

/* Подвал окна поиска: подсказки клавиатуры на Desktop, только бренд на Mobile. */
.r-gsearch-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    font-size: 13px;
    color: #6b7280;
}
.r-gsearch-hints { display: inline-flex; align-items: center; gap: 12px; }
.r-gsearch-hint { display: inline-flex; align-items: center; gap: 6px; }
.r-gsearch-kbd {
    padding: 1px 6px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.04);
    color: #9a9a9a;
    font-family: inherit;
    font-size: 12px;
}
.r-gsearch-brand {
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
/* Тело поиска: всегда занимает свободную высоту окна — спиннер, заглушки
   и концовка списка центрируются в реальном остатке места. */
.r-gsearch-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
@media (min-width: 768px) {
    .r-gsearch-body { min-height: 100%; }
}
/* Обёртка тела мобильной страницы (flush): тянется на всю высоту скролла,
   чтобы вложенное тело поиска могло занять остаток и центрировать контент. */
.r-page-fill {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}
/* Заглушки по центру свободной области (нет запроса / ничего не найдено). */
.r-gsearch-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}
/* Концовка списка: заполняет свободное место под результатами. */
.r-gsearch-end {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px 40px;
    text-align: center;
}
.r-gsearch-end-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 12px;
    border-radius: 50%;
    background: rgba(218, 194, 104, 0.07);
    border: 1px solid rgba(218, 194, 104, 0.14);
}
.r-gsearch-end-title { color: #8a8a8a; font-size: 15px; }
.r-gsearch-end-text { margin-top: 4px; color: #5f5f5f; font-size: 14px; }
.r-gsearch-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    border-radius: 50%;
    background: rgba(218, 194, 104, 0.08);
    color: var(--color-accent);
    font-size: 17px;
}
.r-gsearch-empty-title { color: #fff; font-size: 16px; font-weight: 600; }
.r-gsearch-empty-text {
    max-width: 330px;
    margin: 6px auto 0;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}
.r-gsearch-loading { display: flex; justify-content: center; padding: 14px; }
.r-gsearch-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(218, 194, 104, 0.25);
    border-top-color: var(--color-accent);
    animation: r-gsearch-spin 0.8s linear infinite;
}
@keyframes r-gsearch-spin { to { transform: rotate(360deg); } }
@media (min-width: 768px) {
    /* В окне поиска шапка уже даёт нижнюю границу — верхняя у вкладок лишняя. */
    .r-gsearch-tabs { border-top-width: 0; }
}
@media (max-width: 767px) {
    .r-gsearch-row { height: 66px; }
    .r-gsearch-hints { display: none; }
    .r-gsearch-brand { margin: 0 auto; }
    .r-gsearch-appgroup { padding: 6px 10px; }
    .r-gsearch-clear-btn { width: 32px; height: 32px; font-size: 12px; }
    /* На мобильном страница и так во весь экран: концовка списка не нужна. */
    .r-gsearch-end { display: none; }
    /* Но мягкая заглушка под недавними нужна и здесь. */
    .r-gsearch-end--soft { display: flex; }
}
