/* Иконка кнопки закрепа (канцелярская кнопка) */
        .pin-btn {
            cursor: pointer;
            opacity: 0.5;
            transition: 0.2s;
            margin-left: 5px;
        }
        .pin-btn:hover { opacity: 1; }
        .pin-btn.active { opacity: 1; color: #007bff; transform: rotate(-45deg); }

        /* Стиль для самого элемента чата, если он закреплен */
        .chat-item.pinned {
            background: rgba(0, 123, 255, 0.05);
            border-left: 3px solid #007bff;
        }

        .pinned-bg {
            background-color: rgba(255, 255, 255, 0.05) !important;
        }

        .pinned-bg:hover {
            background-color: rgba(255, 255, 255, 0.08) !important;
        }

        /* Фиолетовый статус для друзей по ссылке */
        .vip-id {
            color: #a370f7 !important;
            border: 1px solid #a370f7 !important;
            box-shadow: 0 0 10px rgba(163, 112, 247, 0.2);
        }
        .vip-badge { color: #a370f7; font-weight: bold; }

        .lang-item {
            padding: 12px;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.2s ease;
            border-bottom: 1px solid var(--border);
            background: rgba(22, 27, 34, 0.95);
            backdrop-filter: blur(10px);
        }
        .lang-item:last-child { border-bottom: none; }
        .lang-item:hover { background: var(--accent); color: white; }

        /* ── SETTINGS MODAL ── */
        #settings-modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.7);
            z-index: 20000;
            display: flex;
            align-items: flex-end;
            justify-content: center;
            backdrop-filter: blur(6px);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s ease;
        }
        #settings-modal-overlay.open {
            opacity: 1;
            pointer-events: all;
        }
        #settings-modal {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 24px 24px 0 0;
            width: 100%;
            max-width: 480px;
            padding: 0 0 env(safe-area-inset-bottom, 16px);
            box-shadow: 0 -20px 60px rgba(0,0,0,0.6);
            transform: translateY(40px);
            transition: transform 0.3s cubic-bezier(.34,1.2,.64,1);
            max-height: 90vh;
            overflow-y: auto;
        }
        #settings-modal-overlay.open #settings-modal {
            transform: translateY(0);
        }
        .sm-handle {
            width: 40px; height: 4px;
            background: var(--border);
            border-radius: 2px;
            margin: 14px auto 0;
        }
        .sm-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 18px 20px 14px;
            border-bottom: 1px solid var(--border);
        }
        .sm-title {
            font-family: 'Syne', sans-serif;
            font-size: 17px;
            font-weight: 800;
            color: var(--text);
            letter-spacing: -0.3px;
        }
        .sm-close-btn {
            background: rgba(255,255,255,0.05);
            border: 1px solid var(--border);
            color: var(--dim);
            border-radius: 8px;
            width: 30px; height: 30px;
            cursor: pointer;
            font-size: 16px;
            display: flex; align-items: center; justify-content: center;
            transition: all 0.15s;
            line-height: 1;
        }
        .sm-close-btn:hover { background: var(--border); color: var(--text); }
        .sm-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 10px; }
        .sm-section-label {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--dim);
            margin-top: 4px;
            margin-bottom: 2px;
        }
        .sm-row {
            display: flex;
            align-items: center;
            gap: 12px;
            background: rgba(255,255,255,0.03);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 13px 14px;
            cursor: pointer;
            transition: all 0.15s ease;
            text-decoration: none;
            color: var(--text);
        }
        .sm-row:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }
        .sm-row.danger:hover { background: rgba(248,81,73,0.08); border-color: rgba(248,81,73,0.3); }
        .sm-row-icon {
            font-size: 18px;
            width: 32px; height: 32px;
            display: flex; align-items: center; justify-content: center;
            background: rgba(255,255,255,0.05);
            border-radius: 8px;
            flex-shrink: 0;
        }
        .sm-row.danger .sm-row-icon { background: rgba(248,81,73,0.1); }
        .sm-row-text { flex: 1; }
        .sm-row-label { font-size: 13px; font-weight: 600; color: var(--text); }
        .sm-row-desc { font-size: 11px; color: var(--dim); margin-top: 1px; }
        .sm-row.danger .sm-row-label { color: var(--red); }
        .sm-row-arrow { font-size: 12px; color: var(--dim); opacity: 0.5; }
        .sm-lang-grid {
            display: grid;
            grid-template-columns: repeat(2,1fr);
            gap: 8px;
            margin-top: 4px;
        }
        .sm-lang-btn {
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 10px 12px;
            font-size: 12px;
            color: var(--dim);
            cursor: pointer;
            transition: all 0.15s;
            font-family: 'JetBrains Mono', monospace;
            text-align: center;
        }
        .sm-lang-btn:hover { border-color: var(--accent); color: var(--text); }
        .sm-lang-btn.active { background: rgba(35,134,54,0.12); border-color: var(--accent); color: #2ea043; font-weight: bold; }
        #settings-gear-btn.gear-open #gear-icon { transform: rotate(90deg); }
        #settings-gear-btn:hover { background: rgba(35,134,54,0.12) !important; }
        .sm-push-row { display: flex; gap: 8px; }
        .sm-push-row .sm-row { flex: 1; flex-direction: column; text-align: center; gap: 4px; padding: 10px 8px; }
        .sm-push-row .sm-row-icon { margin: 0 auto; }
        .sm-push-row .sm-row-text { text-align: center; }
        .sm-divider { height: 1px; background: var(--border); margin: 2px 0; }

        .lang-option {
            background: var(--bg);
            border: 1px solid var(--border);
            padding: 10px;
            border-radius: 8px;
            font-size: 13px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s ease;
            color: var(--dim);
        }
        .lang-option:hover { border-color: var(--accent); color: white; }
        .lang-option.active {
            background: var(--accent);
            border-color: var(--accent);
            color: white;
            font-weight: bold;
            box-shadow: 0 0 10px rgba(35, 134, 54, 0.3);
        }
        /* ── SVG ICON SYSTEM ── */
        .ic {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            line-height: 1;
        }
        .ic svg {
            display: block;
            fill: none;
            stroke: currentColor;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-ui); -webkit-tap-highlight-color: transparent; }
        html, body { overscroll-behavior: none; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
        body { background: var(--bg); color: var(--text); height: calc(var(--vh) * 100); overflow: hidden; display: flex; position: fixed; width: 100%; }
        body::after { content:''; position:fixed; inset:0; background-image:linear-gradient(var(--border) 1px,transparent 1px),linear-gradient(90deg,var(--border) 1px,transparent 1px); background-size:60px 60px; opacity:0.07; pointer-events:none; z-index:0; }
        #app-ui, #auth-screen, #master-modal-overlay { position:relative; z-index:1; }

        #auth-screen { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 2000; }
        .auth-card { background: var(--panel); padding: 40px; border-radius: 20px; text-align: center; border: 1px solid var(--border); width: 90%; max-width: 380px; box-shadow: 0 24px 60px rgba(0,0,0,0.5); }
        .auth-card h1 { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 28px; letter-spacing: -0.5px; }

        #app-ui { display: none; width: 100%; height: 100%; flex-direction: row; }

        .sidebar { width: 320px; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 100; transition: transform 0.3s ease; }
        .chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg); position: relative; min-width: 0; }
        .messages { background-image: radial-gradient(ellipse 60% 40% at 50% 80%, rgba(35,134,54,0.06) 0%, transparent 70%); }

        .header { padding: 15px; border-bottom: 1px solid var(--border); background: var(--panel); display: flex; align-items: center; justify-content: space-between; min-height: 70px; padding-top: max(15px, env(safe-area-inset-top)); }
        .sidebar-logo { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 20px; color: white; letter-spacing: -0.5px; margin-bottom: 4px; }
        .sidebar-logo span { color: #2ea043; }
        .back-btn { cursor: pointer; font-size: 24px; padding-right: 15px; color: var(--accent); display: none; }

        .id-badge { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #2ea043; background: rgba(35,134,54,0.06); padding: 8px 10px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; width: fit-content; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0; border: 1px solid rgba(35,134,54,0.3); letter-spacing: 0.5px; transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease; user-select: none; }
        .id-badge:hover { background: rgba(35,134,54,0.14); border-color: #2ea043; box-shadow: 0 0 10px rgba(35,134,54,0.2); }
        .id-badge:active { transform: scale(0.95); }
        .admin-id { color: #ff4d4d !important; border: 1px solid #ff4d4d !important; box-shadow: 0 0 10px rgba(255, 77, 73, 0.2); }

        .search-area { padding: 15px; display: flex; gap: 8px; border-bottom: 1px solid var(--border); }
        .search-area input { flex: 1; background: #0d1117; border: 1px solid var(--border); padding: 10px 14px; border-radius: 10px; color: white; outline: none; font-size: 13px; font-family: var(--font-ui); transition: border-color 0.2s, box-shadow 0.2s; }
        .search-area input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(35,134,54,0.1); outline: none; }

        .contact-list { flex: 1; overflow-y: auto; }
        .contact-item { padding: 10px 15px; border-bottom: 1px solid #21262d; cursor: pointer; display: flex; align-items: center; gap: 11px; transition: background 0.15s; min-height: 64px; }
        .contact-item:hover { background: rgba(255,255,255,0.03); }
        .contact-item.active { background: rgba(35,134,54,0.08); border-left: 3px solid #2ea043; }
        .del-btn { color: var(--red); font-size: 20px; opacity: 0.5; padding: 5px; cursor: pointer; }

        /* Основная часть — имя + превью */
        .ci-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
        .ci-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
        .ci-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); flex: 1; min-width: 0; }
        .ci-time { font-size: 10px; color: var(--dim); white-space: nowrap; flex-shrink: 0; }
        .ci-bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
        .ci-preview { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; line-height: 1.3; }
        .ci-preview .ci-mine { color: #4caf50; margin-right: 3px; }
        .ci-preview .ci-voice { font-style: italic; }
        .ci-right { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }

        .messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 15px; display: flex; flex-direction: column; gap: 15px; scroll-behavior: smooth; }

        .msg-system-alert {
            background: rgba(255, 0, 0, 0.15) !important;
            border: 2px dashed #ff1744 !important;
            color: #ff5252 !important;
            font-family: monospace;
            font-size: 12px;
            padding: 10px;
            margin: 10px auto;
            width: 90%;
            border-radius: 8px;
            white-space: pre-wrap;
        }

        .date-divider {
            text-align: center;
            margin: 20px 0;
            font-size: 12px;
            color: var(--dim);
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
        }
        .date-divider-line {
            flex: 1;
            height: 1px;
            background: var(--border);
        }

        .bubble { max-width: 85%; padding: 11px 15px; border-radius: 18px; font-size: 14px; position: relative; transition: all 0.2s ease; border: 1px solid transparent; word-wrap: break-word; overflow-wrap: anywhere; word-break: break-word; font-family: var(--font-ui); }

        /* Кнопка три точки — внутри footer'а сообщения */
        .msg-dots-btn {
            background: none;
            border: none;
            cursor: pointer;
            padding: 0 2px 0 4px;
            font-size: 15px;
            line-height: 1;
            border-radius: 4px;
            opacity: 0;
            transition: opacity 0.15s, background 0.15s;
            color: inherit;
            display: inline-flex;
            align-items: center;
        }
        .bubble:hover .msg-dots-btn { opacity: 0.6; }
        .msg-dots-btn:hover { opacity: 1 !important; background: rgba(255,255,255,0.12); }
        /* На мобильных всегда чуть видна */
        @media (hover: none) {
            .msg-dots-btn { opacity: 0.35; }
        }
        .bubble.sent { align-self: unset; background: var(--accent); color: white; border-bottom-right-radius: 4px; box-shadow: 0 4px 16px rgba(35,134,54,0.25); }
        .bubble.received { align-self: unset; background: #1e2430; border: 1px solid var(--border); border-bottom-left-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

        .bubble.highlight { animation: pulse-gold 1.5s ease-in-out; border: 2px solid gold; }
        @keyframes pulse-gold {
            0% { box-shadow: 0 0 0px gold; }
            50% { box-shadow: 0 0 15px gold; }
            100% { box-shadow: 0 0 0px gold; }
        }

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

        .reply-quote { font-size: 12px; background: rgba(0,0,0,0.2); padding: 5px 8px; border-left: 3px solid rgba(255,255,255,0.5); margin-bottom: 6px; border-radius: 4px; pointer-events: none; }
        .reply-quote[data-reply-to-id] { pointer-events: auto; transition: opacity 0.15s; }
        .reply-quote[data-reply-to-id]:hover { opacity: 0.8; }
        .reply-quote.deleted-reply { opacity: 0.45; font-style: italic; pointer-events: none; border-left-color: rgba(255,255,255,0.2); }
        .msg-footer { display: flex; justify-content: flex-end; align-items: center; gap: 5px; margin-top: 4px; font-size: 10px; opacity: 0.7; }
        .status-read { color: #ff4d4d; font-weight: bold; }

        .inner-search { display: none; background: var(--panel); padding: 8px 12px; border-bottom: 1px solid var(--border); align-items: center; gap: 8px; }
        .inner-search input { flex: 1; background: var(--bg); border: 1px solid var(--border); padding: 8px 12px; border-radius: 8px; color: white; font-family: var(--font-ui); font-size: 13px; outline: none; transition: border-color 0.2s; }
        .inner-search input:focus { border-color: var(--accent); }
        .search-counter { font-size: 12px; color: var(--dim); white-space: nowrap; min-width: 48px; text-align: center; }
        .search-nav-btn { background: none; border: 1px solid var(--border); color: var(--dim); border-radius: 7px; width: 30px; height: 30px; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; }
        .search-nav-btn:hover { border-color: var(--accent); color: var(--accent); }
        .search-nav-btn:disabled { opacity: 0.25; cursor: default; border-color: var(--border); color: var(--dim); }
        .bubble.search-match { outline: 2px solid rgba(255,54,76,0.45); }
        .bubble.search-current { outline: 2px solid #58a6ff; box-shadow: 0 0 12px rgba(88,166,255,0.35); }

        .reply-preview { background: var(--panel); padding: 10px 15px; border-top: 1px solid var(--border); display: none; justify-content: space-between; align-items: center; }
        #edit-bar { background: rgba(0,200,83,0.07); padding: 10px 15px; border-top: 2px solid #00c853; display: none; justify-content: space-between; align-items: center; }
        #edit-bar .edit-label { font-size: 12px; color: #00c853; display: flex; align-items: center; gap: 6px; }
        .input-bar { padding: 10px 15px; background: rgba(22,27,34,0.95); backdrop-filter: blur(8px); display: flex; gap: 10px; border-top: 1px solid var(--border); align-items: flex-end; }

        #msg-input {
            flex: 1; background: #0d1117; border: 1px solid var(--border); padding: 11px 14px; border-radius: 14px;
            color: white; outline: none; resize: none; max-height: 120px; min-height: 42px;
            font-size: 14px; line-height: 1.5; font-family: var(--font-ui);
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        #msg-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(35,134,54,0.12); }

        .btn { background: var(--accent); border: none; padding: 10px 18px; color: white; border-radius: 10px; cursor: pointer; font-weight: 700; font-family: 'Syne', sans-serif; letter-spacing: 0.3px; transition: all 0.2s; box-shadow: 0 0 20px rgba(35,134,54,0.2); }
        .btn:hover { background: #2ea043; box-shadow: 0 0 30px rgba(35,134,54,0.35); transform: translateY(-1px); }
        .btn:active { transform: translateY(0); }
        .panic-btn { background: var(--red) !important; margin-top: 10px; width: 100%; padding: 10px; }
        .unread-badge { background: var(--accent); color: white; font-size: 10px; padding: 2px 6px; border-radius: 10px; }

        .scroll-down-btn {
            position: absolute;
            bottom: 80px;
            right: 18px;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: var(--panel);
            border: 1px solid var(--border);
            color: var(--text);
            font-size: 18px;
            cursor: pointer;
            display: none;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 12px rgba(0,0,0,0.4);
            transition: opacity 0.2s, transform 0.2s;
            z-index: 50;
        }
        .scroll-down-btn:hover { background: var(--border); transform: scale(1.08); }

        /* ── МЕДИА СООБЩЕНИЯ ── */
        .media-bubble {
            display: flex;
            flex-direction: column;
            gap: 8px;
            min-width: 200px;
            max-width: 100%;
        }
        .media-preview {
            border-radius: 12px;
            overflow: hidden;
            position: relative;
            background: rgba(0,0,0,0.2);
            cursor: pointer;
        }
        .media-preview img, .media-preview video {
            display: block;
            max-width: 100%;
            max-height: 300px;
            width: 100%;
            object-fit: cover;
            border-radius: 10px;
        }
        .media-file-card {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 4px 2px;
            cursor: pointer;
            border-radius: 8px;
            transition: opacity 0.15s;
        }
        .media-file-card:hover { opacity: 0.8; }
        .media-file-icon {
            width: 40px; height: 40px;
            border-radius: 10px;
            background: rgba(255,255,255,0.12);
            display: flex; align-items: center; justify-content: center;
            flex-shrink: 0; font-size: 20px;
        }
        .media-file-info { flex: 1; min-width: 0; }
        .media-file-name {
            font-size: 13px;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: inherit;
        }
        .media-file-size {
            font-size: 10px;
            opacity: 0.65;
            margin-top: 2px;
        }
        .media-progress {
            height: 3px;
            border-radius: 2px;
            background: rgba(255,255,255,0.2);
            margin-top: 6px;
            overflow: hidden;
            display: none;
        }
        .media-progress-bar {
            height: 100%;
            background: rgba(255,255,255,0.8);
            border-radius: 2px;
            width: 0%;
            transition: width 0.2s;
        }
        .media-overlay {
            position: absolute; inset: 0;
            background: rgba(0,0,0,0.4);
            display: flex; align-items: center; justify-content: center;
            border-radius: 10px;
        }
        .media-overlay-icon {
            width: 48px; height: 48px;
            border-radius: 50%;
            background: rgba(255,255,255,0.9);
            display: flex; align-items: center; justify-content: center;
            font-size: 20px; cursor: pointer;
            transition: transform 0.15s;
        }
        .media-overlay-icon:hover { transform: scale(1.1); }

        /* Кнопка прикрепить файл */
        #attach-btn {
            background: none; border: none; cursor: pointer;
            color: var(--dim); margin-bottom: 5px; padding: 4px 2px;
            display: flex; align-items: center;
            transition: color 0.15s;
        }
        #attach-btn:hover { color: var(--accent); }
        #file-input { display: none; }

        /* Превью перед отправкой */
        #media-preview-bar {
            display: none;
            background: var(--panel);
            border-top: 1px solid var(--border);
            padding: 10px 15px;
            align-items: center;
            gap: 10px;
        }
        #media-preview-bar.active { display: flex; }
        .mpb-thumb {
            width: 48px; height: 48px;
            border-radius: 8px;
            object-fit: cover;
            flex-shrink: 0;
            background: rgba(255,255,255,0.05);
            display: flex; align-items: center; justify-content: center;
            font-size: 22px; overflow: hidden;
        }
        .mpb-thumb img, .mpb-thumb video {
            width: 100%; height: 100%; object-fit: cover;
        }
        .mpb-info { flex: 1; min-width: 0; }
        .mpb-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .mpb-size { font-size: 10px; color: var(--dim); margin-top: 2px; }
        .mpb-close { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 18px; padding: 4px; }

        /* Лайтбокс */
        #media-lightbox {
            position: fixed; inset: 0; z-index: 299000;
            background: rgba(0,0,0,0.92);
            display: none; align-items: center; justify-content: center;
            flex-direction: column;
            backdrop-filter: blur(12px);
            overflow: hidden;
            touch-action: none;
        }
        #media-lightbox.active { display: flex; }

        /* Контейнер трансформации — именно он двигается и масштабируется */
        #lightbox-transform {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            transform-origin: center center;
            will-change: transform;
            cursor: grab;
        }
        #lightbox-transform.dragging { cursor: grabbing; }

        #lightbox-content {
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: none;
        }
        #lightbox-content img {
            max-width: 90vw; max-height: 90vh;
            border-radius: 12px; display: block;
            user-select: none;
            -webkit-user-drag: none;
        }
        #lightbox-content video {
            max-width: 90vw; max-height: 85vh;
            border-radius: 12px; display: block;
            pointer-events: all;
        }

        /* Крестик */
        #lightbox-close {
            position: fixed;
            top: max(20px, env(safe-area-inset-top, 20px));
            right: 20px;
            background: rgba(0,0,0,0.6);
            border: 1.5px solid rgba(255,255,255,0.25);
            color: white;
            border-radius: 50%; width: 44px; height: 44px;
            font-size: 20px; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            backdrop-filter: blur(8px);
            transition: all 0.2s;
            z-index: 10;
        }
        #lightbox-close:hover {
            background: rgba(248,81,73,0.75);
            border-color: rgba(248,81,73,0.8);
            transform: scale(1.08);
        }

        /* Кнопка скачать + счётчик зума */
        #lightbox-footer {
            position: fixed;
            bottom: max(24px, env(safe-area-inset-bottom, 24px));
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            gap: 10px;
            z-index: 10;
        }
        #lightbox-dl {
            background: rgba(0,0,0,0.55);
            border: 1px solid rgba(255,255,255,0.2);
            color: white; border-radius: 10px;
            padding: 8px 20px; cursor: pointer;
            font-family: 'JetBrains Mono', monospace;
            font-size: 12px;
            display: flex; align-items: center; gap: 8px;
            backdrop-filter: blur(8px);
            transition: all 0.2s;
        }
        #lightbox-dl:hover { background: rgba(255,255,255,0.15); }
        #lightbox-zoom-label {
            background: rgba(0,0,0,0.55);
            border: 1px solid rgba(255,255,255,0.15);
            color: rgba(255,255,255,0.7);
            border-radius: 8px;
            padding: 7px 12px;
            font-family: 'JetBrains Mono', monospace;
            font-size: 11px;
            backdrop-filter: blur(8px);
            min-width: 52px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
        }
        #lightbox-zoom-label:hover { background: rgba(255,255,255,0.1); }

        /* ── YouTube inline player ── */
        .yt-link-wrap {
            display: inline-block;
            max-width: 100%;
            word-break: break-all;
            overflow-wrap: anywhere;
        }
        .yt-link-wrap a {
            word-break: break-all;
            overflow-wrap: anywhere;
        }
        .yt-play-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: #ff4444;
            border: none;
            border-radius: 5px;
            color: white;
            width: 26px; height: 18px;
            cursor: pointer;
            flex-shrink: 0;
            transition: background 0.15s, transform 0.1s;
            vertical-align: middle;
            margin-left: 4px;
        }
        .yt-play-btn:hover { background: #cc0000; transform: scale(1.1); }

        #yt-modal-overlay {
            position: fixed; inset: 0; z-index: 199500;
            background: rgba(0,0,0,0.85);
            backdrop-filter: blur(10px);
            display: none; align-items: center; justify-content: center;
            flex-direction: column;
            padding: 20px;
        }
        #yt-modal-overlay.active { display: flex; }

        #yt-modal-close {
            position: absolute;
            top: max(18px, env(safe-area-inset-top, 18px));
            right: 18px;
            background: rgba(0,0,0,0.55);
            border: 1.5px solid rgba(255,255,255,0.2);
            color: white; border-radius: 50%;
            width: 40px; height: 40px; font-size: 18px;
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            backdrop-filter: blur(8px); transition: all 0.15s; z-index: 10;
        }
        #yt-modal-close:hover { background: rgba(248,81,73,0.7); }

        #yt-iframe-wrap {
            width: 100%; max-width: 680px;
            border-radius: 14px; overflow: hidden;
            box-shadow: 0 20px 60px rgba(0,0,0,0.7);
            background: #000;
            aspect-ratio: 16/9;
        }
        #yt-iframe-wrap iframe {
            width: 100%; height: 100%;
            border: none; display: block;
        }

        #yt-modal-actions {
            display: flex;
            gap: 10px;
            margin-top: 14px;
        }
        .yt-action-btn {
            padding: 10px 22px;
            border-radius: 10px;
            border: none;
            font-family: 'JetBrains Mono', monospace;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.15s;
            display: flex; align-items: center; gap: 8px;
        }
        .yt-action-btn.primary {
            background: #ff4444; color: white;
        }
        .yt-action-btn.primary:hover { background: #cc0000; }
        .yt-action-btn.secondary {
            background: rgba(255,255,255,0.1);
            border: 1px solid rgba(255,255,255,0.2);
            color: rgba(255,255,255,0.8);
        }
        .yt-action-btn.secondary:hover { background: rgba(255,255,255,0.18); }

        /* ── ГОЛОСОВЫЕ: Telegram-стиль waveform ── */
        .voice-container { display: flex; align-items: center; gap: 10px; min-width: 220px; padding: 4px 0; }
        .v-play-btn {
            width: 38px; height: 38px; border-radius: 50%; border: none;
            background: rgba(255,255,255,0.95); color: var(--accent);
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            font-size: 15px; flex-shrink: 0;
            box-shadow: 0 1px 4px rgba(0,0,0,0.3);
            transition: transform 0.1s ease;
        }
        .v-play-btn:active { transform: scale(0.92); }
        .v-right { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
        .v-waveform { display: flex; align-items: center; gap: 2px; height: 28px; cursor: pointer; }
        .v-bar {
            flex-shrink: 0; width: 3px; border-radius: 2px;
            background: rgba(255,255,255,0.35);
            transition: background 0.15s;
        }
        .v-bar.played { background: rgba(255,255,255,0.95); }
        .v-time { font-size: 11px; color: rgba(255,255,255,0.75); font-family: monospace; }

        /* ── ЗАКРЕПЛЁННОЕ СООБЩЕНИЕ ── */
        #pinned-msg-bar {
            display: none;
            align-items: center;
            gap: 10px;
            padding: 8px 14px;
            background: var(--panel);
            border-bottom: 1px solid var(--border);
            cursor: pointer;
            transition: background 0.15s;
            position: relative;
            overflow: hidden;
        }
        #pinned-msg-bar::before {
            content: '';
            position: absolute;
            left: 0; top: 0; bottom: 0;
            width: 3px;
            background: var(--accent);
            border-radius: 0 2px 2px 0;
        }
        #pinned-msg-bar:hover { background: rgba(255,255,255,0.03); }
        #pinned-msg-bar.active { display: flex; }
        .pinned-bar-icon {
            color: var(--accent);
            flex-shrink: 0;
            display: flex;
            align-items: center;
        }
        .pinned-bar-text {
            flex: 1;
            min-width: 0;
        }
        .pinned-bar-label {
            font-size: 10px;
            color: var(--accent);
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 2px;
        }
        .pinned-bar-preview {
            font-size: 12px;
            color: var(--dim);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-family: 'JetBrains Mono', monospace;
        }
        .pinned-bar-close {
            background: none;
            border: none;
            color: var(--dim);
            cursor: pointer;
            padding: 4px;
            border-radius: 6px;
            display: flex;
            align-items: center;
            transition: all 0.15s;
            flex-shrink: 0;
        }
        .pinned-bar-close:hover { background: var(--border); color: var(--text); }

        .pinned-indicator {
            width: 3px;
            border-radius: 2px;
            background: rgba(35,134,54,0.3);
            transition: all 0.2s ease;
            flex: 1;
            min-height: 4px;
        }
        .pinned-indicator.active {
            background: var(--accent);
        }

        /* Подсветка закреплённого сообщения */
        .bubble.pinned-highlight {
            outline: 2px solid var(--accent);
            box-shadow: 0 0 12px rgba(35,134,54,0.3);
        }


        .msg-menu {
            position: fixed; background: var(--panel); border: 1px solid var(--border);
            border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 3000;
            display: none; min-width: 180px; overflow: hidden; animation: fadeIn 0.1s ease-out;
        }
        @keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
        @keyframes heartPop {
            0%   { opacity: 1; transform: scale(0.5) translateY(0); }
            50%  { opacity: 1; transform: scale(1.4) translateY(-20px); }
            100% { opacity: 0; transform: scale(1) translateY(-40px); }
        }

        @keyframes chatSlideIn {
            from { opacity: 0; transform: translateX(45px); }
            to   { opacity: 1; transform: translateX(0);    }
        }
        @keyframes connPulse {
            0%, 100% { opacity: 0.2; transform: scale(0.8); }
            50%       { opacity: 1;   transform: scale(1.2); }
        }


        .chat-main.slide-in   { animation: chatSlideIn 0.3s cubic-bezier(0.34,1.15,0.64,1) both; }
        .menu-item { padding: 12px 16px; cursor: pointer; font-size: 14px; transition: background 0.2s; display: flex; align-items: center; gap: 10px; }
        .menu-item:hover { background: var(--border); }
        .menu-item.del { color: var(--red); border-top: 1px solid var(--border); }

        /* ============================================================
           МАСТЕР-ПАРОЛЬ: стили модальных окон
           ============================================================ */

        /* Оверлей поверх всего */
        #master-modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.85);
            z-index: 25000;
            display: flex;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(6px);
        }

        .master-modal-card {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 18px;
            padding: 32px 28px;
            width: 90%;
            max-width: 400px;
            text-align: center;
            box-shadow: 0 20px 60px rgba(0,0,0,0.7);
            animation: modalSlideIn 0.3s ease-out;
        }

        @keyframes modalSlideIn {
            from { opacity: 0; transform: translateY(20px) scale(0.97); }
            to   { opacity: 1; transform: translateY(0)   scale(1);    }
        }

        .master-modal-card h2 {
            font-size: 20px;
            margin-bottom: 8px;
            color: #c9d1d9;
        }

        .master-modal-card p {
            font-size: 13px;
            color: var(--dim);
            margin-bottom: 20px;
            line-height: 1.6;
        }

        /* Блок отображения сгенерированного пароля */
        #generated-password-display {
            background: #0d1117;
            border: 2px dashed var(--accent);
            border-radius: 10px;
            padding: 16px;
            font-family: 'Courier New', monospace;
            font-size: 22px;
            letter-spacing: 3px;
            color: #fff;
            margin-bottom: 14px;
            word-break: break-all;
            cursor: pointer;
            transition: background 0.2s;
            user-select: all;
        }

        #generated-password-display:hover {
            background: #131920;
        }

        .master-warning-box {
            background: rgba(248, 81, 73, 0.1);
            border: 1px solid rgba(248, 81, 73, 0.4);
            border-radius: 10px;
            padding: 12px 14px;
            font-size: 12px;
            color: #f85149;
            margin-bottom: 20px;
            line-height: 1.6;
            text-align: left;
        }

        .master-warning-box b {
            display: block;
            margin-bottom: 4px;
            font-size: 13px;
        }

        /* Инпут для повторного входа */
        #master-password-input {
            width: 100%;
            background: var(--bg);
            border: 1px solid var(--border);
            padding: 12px 14px;
            border-radius: 10px;
            color: white;
            font-size: 16px;
            outline: none;
            margin-bottom: 12px;
            letter-spacing: 2px;
            text-align: center;
            font-family: 'Courier New', monospace;
            transition: border-color 0.2s;
        }

        #master-password-input:focus {
            border-color: var(--accent);
        }

        #master-password-input.input-error {
            border-color: var(--red);
            animation: shake 0.3s ease;
        }

        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25%       { transform: translateX(-6px); }
            75%       { transform: translateX(6px); }
        }

        #master-error-text {
            color: var(--red);
            font-size: 12px;
            margin-bottom: 10px;
            min-height: 18px;
        }

        .master-copy-hint {
            font-size: 11px;
            color: var(--dim);
            margin-bottom: 16px;
        }

        /* ============================================================ */

        @media (max-width: 768px) {
            .sidebar { position: fixed; width: 100%; height: 100%; transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1); }
            .chat-main { display: none; width: 100%; transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1); }
            body.in-chat .sidebar { display: none; }
            body.in-chat .chat-main { display: flex; }
            body.in-chat .back-btn { display: block; }
            body.swiping .chat-main, body.swiping .sidebar { transition: none !important; }
        }

        /* ============================================================
           КАСТОМНЫЕ МОДАЛКИ (замена confirm/prompt)
           ============================================================ */
        #custom-modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.75);
            z-index: 99000;
            display: none;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(4px);
            padding: 20px;
        }
        #custom-modal-overlay.visible {
            display: flex;
        }
        #cm-body { white-space: pre-line; }
        .custom-modal-box {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 16px;
            padding: 24px 22px 20px;
            width: 100%;
            max-width: 360px;
            box-shadow: 0 16px 48px rgba(0,0,0,0.6);
            animation: cmSlideIn 0.18s ease-out;
        }
        @keyframes cmSlideIn {
            from { opacity: 0; transform: translateY(12px) scale(0.97); }
            to   { opacity: 1; transform: translateY(0) scale(1); }
        }
        .custom-modal-icon {
            font-size: 28px;
            margin-bottom: 10px;
            display: block;
            text-align: center;
        }
        .custom-modal-title {
            font-family: 'Syne', sans-serif;
            font-size: 15px;
            font-weight: 700;
            color: var(--text);
            margin-bottom: 8px;
            line-height: 1.4;
            text-align: center;
        }
        .custom-modal-body {
            font-size: 13px;
            color: var(--dim);
            margin-bottom: 18px;
            line-height: 1.6;
            text-align: center;
        }
        .custom-modal-input {
            width: 100%;
            background: var(--bg);
            border: 1px solid var(--border);
            padding: 11px 14px;
            border-radius: 10px;
            color: white;
            font-size: 14px;
            outline: none;
            margin-bottom: 16px;
            font-family: 'JetBrains Mono', monospace;
            transition: border-color 0.2s;
            display: none;
        }
        .custom-modal-input:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px rgba(35,134,54,0.12);
        }
        .custom-modal-actions {
            display: flex;
            gap: 10px;
        }
        .cm-btn {
            flex: 1;
            padding: 11px;
            border: none;
            border-radius: 10px;
            font-family: 'Syne', sans-serif;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.15s;
        }
        .cm-btn-cancel {
            background: var(--border);
            color: var(--dim);
        }
        .cm-btn-cancel:hover { background: #3a4150; color: var(--text); }
        .cm-btn-ok {
            background: var(--accent);
            color: white;
            box-shadow: 0 0 16px rgba(35,134,54,0.25);
        }
        .cm-btn-ok:hover { background: #2ea043; }
        .cm-btn-ok.danger {
            background: var(--red);
            box-shadow: 0 0 16px rgba(248,81,73,0.25);
        }
        /* ============================================================
           РЕАКЦИИ
           ============================================================ */
        .reactions-row {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
            margin-top: 5px;
            min-height: 0;
        }
        .reaction-chip {
            display: inline-flex;
            align-items: center;
            gap: 3px;
            background: rgba(255,255,255,0.08);
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 20px;
            padding: 3px 8px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.18s ease;
            user-select: none;
            line-height: 1;
        }
        .reaction-chip:hover { background: rgba(255,255,255,0.14); transform: scale(1.08); }
        .reaction-chip:active { transform: scale(0.88) !important; }
        .reaction-chip.mine {
            background: rgba(35,134,54,0.25);
            border-color: rgba(35,134,54,0.5);
            box-shadow: 0 0 8px rgba(35,134,54,0.2);
        }
        .reaction-chip .r-count {
            font-size: 11px;
            opacity: 0.75;
            font-family: 'JetBrains Mono', monospace;
        }
        @keyframes reactionPop {
            0%   { transform: scale(0.3) rotate(-10deg); opacity: 0; }
            60%  { transform: scale(1.3) rotate(5deg);  opacity: 1; }
            100% { transform: scale(1)   rotate(0deg);  opacity: 1; }
        }
        .reaction-chip.just-added {
            animation: reactionPop 0.38s cubic-bezier(0.34, 1.5, 0.64, 1) both;
        }

        /* Пикер реакций */
        .reaction-picker {
            display: none;
            position: absolute;
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 30px;
            padding: 7px 10px;
            box-shadow: 0 8px 24px rgba(0,0,0,0.5);
            z-index: 2000;
            white-space: nowrap;
            animation: fadeIn 0.12s ease-out;
        }
        .reaction-picker.active { display: flex; gap: 4px; align-items: center; }
        .rp-btn {
            font-size: 22px;
            cursor: pointer;
            padding: 3px 4px;
            border-radius: 8px;
            transition: transform 0.15s, background 0.15s;
            line-height: 1;
            border: none;
            background: none;
        }
        .rp-btn:hover { transform: scale(1.35); background: rgba(255,255,255,0.07); }

        /* Обёртка для позиционирования пикера */
        .bubble-wrap {
            display: flex;
            flex-direction: column;
            max-width: 85%;
        }
        .bubble-wrap.sent { align-self: flex-end; align-items: flex-end; }
        .bubble-wrap.received { align-self: flex-start; align-items: flex-start; }
        .bubble-wrap .bubble { max-width: 100%; align-self: unset; }

        /* ── АДМИН ПАНЕЛЬ ── */
        .admin-panel-wrap {
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            background: var(--bg);
        }
        .ap-header {
            padding: max(16px, env(safe-area-inset-top)) 20px 16px;
            border-bottom: 1px solid var(--border);
            background: var(--panel);
            display: flex;
            align-items: center;
            justify-content: space-between;
            min-height: 70px;
        }
        .ap-title {
            font-family: 'Syne', sans-serif;
            font-size: 18px;
            font-weight: 800;
            color: #ff9500;
        }
        .ap-tabs {
            display: flex;
            border-bottom: 1px solid var(--border);
            background: var(--panel);
            overflow-x: auto;
        }
        .ap-tab {
            padding: 12px 18px;
            cursor: pointer;
            font-size: 12px;
            color: var(--dim);
            border-bottom: 2px solid transparent;
            white-space: nowrap;
            transition: all 0.2s;
            flex-shrink: 0;
        }
        .ap-tab.active {
            color: #ff9500;
            border-bottom-color: #ff9500;
        }
        .ap-tab:hover { color: var(--text); }
        .ap-content {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
        }
        .ap-section { display: none; }
        .ap-section.active { display: block; }
        .ap-card {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 14px;
        }
        .ap-card-title {
            font-size: 12px;
            color: var(--dim);
            margin-bottom: 12px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        .ap-stat-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
            margin-bottom: 14px;
        }
        .ap-stat {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 14px;
            text-align: center;
        }
        .ap-stat-num {
            font-family: 'Syne', sans-serif;
            font-size: 28px;
            font-weight: 800;
            color: #ff9500;
        }
        .ap-stat-label {
            font-size: 11px;
            color: var(--dim);
            margin-top: 2px;
        }
        .ap-input {
            width: 100%;
            background: var(--bg);
            border: 1px solid var(--border);
            padding: 10px 14px;
            border-radius: 10px;
            color: white;
            font-size: 13px;
            font-family: 'JetBrains Mono', monospace;
            outline: none;
            margin-bottom: 10px;
            transition: border-color 0.2s;
        }
        .ap-input:focus { border-color: #ff9500; }
        .ap-btn {
            padding: 10px 16px;
            border: none;
            border-radius: 8px;
            font-family: 'Syne', sans-serif;
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s;
            margin-right: 6px;
            margin-bottom: 6px;
        }
        .ap-btn-orange { background: #ff9500; color: black; }
        .ap-btn-orange:hover { background: #ffaa33; }
        .ap-btn-red { background: var(--red); color: white; }
        .ap-btn-red:hover { background: #ff6b68; }
        .ap-btn-green { background: var(--accent); color: white; }
        .ap-btn-green:hover { background: var(--accent2); }
        .ap-btn-gray { background: var(--border); color: var(--dim); }
        .ap-btn-gray:hover { background: #3a4150; color: var(--text); }
        .ap-online-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 12px;
            background: var(--bg);
            border-radius: 8px;
            margin-bottom: 6px;
            font-size: 12px;
            font-family: 'JetBrains Mono', monospace;
        }
        .ap-online-dot {
            width: 7px; height: 7px;
            border-radius: 50%;
            background: #2ea043;
            margin-right: 8px;
            flex-shrink: 0;
        }
        .ap-invite-item {
            display: grid;
            gap: 9px;
            padding: 12px;
            background: rgba(2, 9, 8, 0.72);
            border: 1px solid var(--border);
            border-radius: 12px;
            margin-bottom: 10px;
            font-size: 11px;
            font-family: 'JetBrains Mono', monospace;
        }
        .ap-invite-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
        }
        .ap-invite-meta {
            min-width: 0;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 6px 10px;
            color: var(--dim);
        }
        .ap-invite-id {
            color: var(--text);
            font-family: 'Syne', sans-serif;
            font-size: 12px;
            font-weight: 700;
        }
        .ap-invite-field {
            display: grid;
            grid-template-columns: 50px minmax(0, 1fr) 36px;
            align-items: start;
            gap: 8px;
            padding: 9px;
            background: var(--bg);
            border: 1px solid rgba(113, 215, 166, 0.1);
            border-radius: 9px;
        }
        .ap-invite-label {
            padding-top: 8px;
            color: var(--dim);
            font-size: 9px;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
        }
        .ap-invite-value {
            min-width: 0;
            padding: 6px 2px;
            color: var(--text);
            font-size: 10px;
            line-height: 1.55;
            overflow-wrap: anywhere;
            word-break: break-all;
            user-select: all;
        }
        .ap-invite-value.is-unavailable {
            color: var(--dim);
            word-break: normal;
        }
        .ap-invite-icon-btn {
            width: 36px;
            height: 36px;
            display: grid;
            place-items: center;
            padding: 0;
            margin: 0;
            border: 1px solid var(--border);
            border-radius: 9px;
            background: rgba(113, 215, 166, 0.08);
            color: var(--accent);
            cursor: pointer;
            transition: border-color 0.15s, background 0.15s, color 0.15s;
        }
        .ap-invite-icon-btn:hover {
            border-color: var(--accent);
            background: rgba(113, 215, 166, 0.15);
        }
        .ap-invite-icon-btn.copied {
            color: var(--text);
            background: rgba(113, 215, 166, 0.22);
        }
        .ap-invite-icon-btn:disabled {
            opacity: 0.35;
            cursor: default;
        }
        .ap-invite-icon-btn.danger {
            flex: 0 0 auto;
            border-color: rgba(248, 81, 73, 0.28);
            background: rgba(248, 81, 73, 0.1);
            color: var(--red);
        }
        .ap-invite-icon-btn .ui-icon {
            width: 17px;
            height: 17px;
        }
        @media (max-width: 520px) {
            .ap-invite-field {
                grid-template-columns: minmax(0, 1fr) 36px;
            }
            .ap-invite-label {
                grid-column: 1 / -1;
                padding-top: 0;
            }
        }
        .ap-perm-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-bottom: 12px;
        }
        .ap-perm-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 12px;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 8px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.15s;
            user-select: none;
        }
        .ap-perm-item:hover { border-color: #ff9500; }
        .ap-perm-item input[type=checkbox] {
            accent-color: #ff9500;
            width: 15px; height: 15px;
            flex-shrink: 0;
        }
        .ap-result {
            font-size: 12px;
            padding: 8px 12px;
            border-radius: 8px;
            margin-top: 8px;
            display: none;
        }
        .ap-result.ok { background: rgba(35,134,54,0.15); color: #2ea043; display: block; }
        .ap-result.err { background: rgba(248,81,73,0.15); color: var(--red); display: block; }
