* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #14110f;
    --panel: #1c1a18;
    --card: #242220;
    --card-hover: #2c2926;
    --input: #2a2826;
    --accent: #8fa382;
    --accent-hover: #7a8b6e;
    --mine: #5e6e55;
    --theirs: #2c2926;
    --text: #f3ede6;
    --muted: #a8988c;
    --danger: #d35a4a;
    --online: #7cb98a;
    --shadow: 0 10px 22px rgba(0, 0, 0, 0.55), 0 2px 4px rgba(0, 0, 0, 0.35);
    --shadow-soft: 0 6px 14px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
    --inset: inset 0 2px 0 rgba(255, 255, 255, 0.10), inset 0 -3px 6px rgba(0, 0, 0, 0.28);
    --clay: linear-gradient(180deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.02) 42%, rgba(0,0,0,0.18) 100%);
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
}

/* ===== LOGIN ===== */
/* Страница входа может быть выше экрана — не обрезаем «Забыли пароль?» */
html:has(body.login-page),
body.login-page {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 100% !important;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0));
    box-sizing: border-box;
    background: radial-gradient(ellipse at top, #2a2622 0%, #14110f 70%);
}

.login-box {
    background: var(--panel);
    padding: 28px 24px;
    border-radius: 22px;
    width: 100%;
    max-width: 380px;
    margin: auto;
    box-shadow: var(--shadow), var(--inset);
}

.login-logo img {
    width: 96px !important;
    height: auto !important;
    max-width: 30vw;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 28px;
    color: var(--text);
}

.login-box p {
    text-align: center;
    color: var(--muted);
    margin-bottom: 30px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 14px;
    background: var(--input);
    color: var(--text);
    font-size: 15px;
    outline: none;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}

.form-group input::placeholder {
    color: #6d7f8f;
}

.form-group input:-webkit-autofill,
.form-group input:-webkit-autofill:hover,
.form-group input:-webkit-autofill:focus,
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text) !important;
    caret-color: var(--text);
    box-shadow: 0 0 0 1000px var(--input) inset !important;
    -webkit-box-shadow: 0 0 0 1000px #2a2826 inset !important;
    transition: background-color 9999s ease-out 0s;
    background-color: #2a2826 !important;
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: var(--accent);
    color: #1a1c18;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
    box-shadow: var(--shadow-soft), var(--inset);
}

.btn:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    margin-top: 12px;
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(143, 163, 130, 0.12);
}

.error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    display: none;
}

/* ===== CHAT ===== */
.chat-app {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    overflow: hidden;
    background: var(--bg);
}

.sidebar {
    width: 360px;
    background: var(--bg);
    border-right: none;
    display: flex;
    flex-direction: column;
    padding: 10px 10px 8px;
}

.sidebar-header {
    min-height: 64px;
    padding: 10px 12px;
    background: var(--card) var(--clay);
    border: none;
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-soft), var(--inset);
    margin-bottom: 10px;
}

.sidebar-header img[alt="7Я"] {
    width: 26px !important;
    height: 26px !important;
    object-fit: contain;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 650;
}

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 2px 2px 8px;
}

#search-input {
    width: 100%;
    padding: 10px 14px !important;
    border: none !important;
    border-radius: 16px !important;
    background: var(--input) !important;
    color: var(--text) !important;
    outline: none !important;
    font-size: 14px !important;
    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.45) !important;
}

.user-item {
    padding: 14px 16px;
    min-height: 76px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    background: var(--card) var(--clay);
    border-radius: 18px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-soft), var(--inset);
}

.user-item:hover, .user-item.active {
    background: var(--card-hover);
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: #1a1c18;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.28);
}

.user-info h3 {
    font-size: 16px;
    margin-bottom: 4px;
    font-weight: 650;
}

.user-info p {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.35;
    white-space: normal !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden !important;
    text-overflow: ellipsis;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    min-height: 0;
    overflow: hidden;
    padding: 10px 12px 10px 6px;
}

.chat-header {
    min-height: 64px;
    padding: 10px 14px;
    background: var(--card) var(--clay);
    border: none;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-soft), var(--inset);
    margin-bottom: 8px;
    flex-shrink: 0;
}

.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    box-shadow: var(--shadow), var(--inset);
    background-image: var(--clay);
    box-sizing: border-box;
    min-width: 0;
    flex-shrink: 0;
    overflow: visible;
}

.message > div {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
}

.message.mine {
    align-self: flex-end;
    background: var(--mine);
    border-bottom-right-radius: 4px;
}

.message.theirs {
    align-self: flex-start;
    background: var(--theirs);
    border-bottom-left-radius: 4px;
}

.message.mine::before,
.message.theirs::before,
.message.mine::after,
.message.theirs::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background-image: var(--clay);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 2px 3px rgba(0,0,0,0.3);
}

.message.mine::before,
.message.theirs::before {
    width: 8px;
    height: 8px;
}

.message.mine::after,
.message.theirs::after {
    width: 4px;
    height: 4px;
}

.message.mine::before {
    right: -7px;
    bottom: -7px;
    background-color: var(--mine);
}

.message.mine::after {
    right: -11px;
    bottom: -11px;
    background-color: var(--mine);
}

.message.theirs::before {
    left: -7px;
    bottom: -7px;
    background-color: var(--theirs);
}

.message.theirs::after {
    left: -11px;
    bottom: -11px;
    background-color: var(--theirs);
}

.message .time {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
    text-align: right;
}

.chat-input-area {
    flex-shrink: 0;
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: var(--card) var(--clay);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: nowrap;
    border-radius: 22px;
    box-shadow: var(--shadow), var(--inset);
    margin-top: 6px;
}

.chat-input-area input,
.chat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 18px;
    background: var(--input);
    color: var(--text);
    font-size: 15px;
    outline: none;
    resize: none;
    max-height: 120px;
    min-height: 42px;
    line-height: 1.4;
    font-family: inherit;
    overflow-y: auto;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.32);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent) var(--clay);
    border: none;
    color: #1a1c18;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-soft), var(--inset);
}

.empty-chat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 16px;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 10;
        height: 100%;
        left: 0;
        top: 0;
        padding: 10px 10px 8px;
    }
    .sidebar.hidden {
        display: none;
    }
    .chat-area {
        width: 100%;
        padding: 8px 10px 8px;
        min-height: 0;
    }

    /* шапка не уезжает при открытой клавиатуре */
    .chat-header {
        position: sticky;
        top: 0;
        z-index: 40;
        flex-shrink: 0;
    }

    .chat-app {
        max-height: var(--vvh, 100dvh);
    }

    .back-btn {
        display: flex !important;
    }

    .chat-input-area {
        gap: 6px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .file-btn,
    .send-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
        flex-shrink: 0;
    }

    .chat-input-area input,
    .chat-input-area textarea {
        padding: 10px 12px;
        font-size: 14px;
        min-width: 0;
    }
}

.back-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    padding: 0 8px 0 0;
    margin-right: 4px;
}

.online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: var(--online);
    border: 2px solid var(--card);
    border-radius: 50%;
}

.file-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--input) var(--clay);
    box-shadow: var(--shadow-soft), var(--inset);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    color: var(--muted);
}

.file-btn:hover {
    background: var(--card-hover);
}

.message img {
    cursor: pointer;
    border-radius: 12px;
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: 360px;
    object-fit: contain;
    display: block;
}

.message video {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    display: block;
}

/* overflow:hidden убран: в flex-списке он сплющивал пузыри */

.msg-text {
    line-height: 1.5;
}

.unread-badge {
    background: var(--accent) !important;
    color: #1a1c18 !important;
    font-size: 12px;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: var(--inset);
}

.bottom-nav {
    display: none;
}

.mobile-panel {
    display: none;
}

.bottom-nav button[data-tab="calls"],
#panel-calls {
    display: none !important;
}

#header-logout,
#header-new-group {
    display: none !important;
}

#header-settings-btn {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    cursor: pointer;
    flex-shrink: 0;
}

#header-settings-btn img {
    width: 28px;
    height: 28px;
    display: block;
    border-radius: 50%;
}

#panel-settings.active,
#panel-more.active {
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    width: min(380px, 100%);
    height: 100%;
    background: var(--bg);
    z-index: 60;
    overflow-y: auto;
    padding: 20px 16px;
    box-shadow: var(--shadow);
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(8px + env(safe-area-inset-bottom, 0));
        height: 64px;
        padding: 5px;
        background: var(--card);
        border: none;
        border-radius: 22px;
        z-index: 50;
        justify-content: space-around;
        align-items: center;
        box-shadow: var(--shadow), var(--inset);
    }

    .bottom-nav button {
        flex: 1;
        border: none;
        background: transparent;
        color: var(--muted);
        font-size: 13px;
        font-weight: 600;
        padding: 6px 4px;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border-radius: 16px;
    }

    .bottom-nav button .nav-icon {
        font-size: 20px;
        line-height: 1;
    }

    .bottom-nav button.active {
        color: #1a1c18;
        background: var(--accent);
    }

    .bottom-nav button[data-tab="calls"] {
        display: none;
    }

    /* список чатов не прячется под нижними вкладками */
    .user-list {
        padding-bottom: calc(96px + env(safe-area-inset-bottom, 0));
    }

    .chat-app {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0));
    }

    .mobile-panel {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: calc(72px + env(safe-area-inset-bottom, 0));
        background: var(--bg);
        z-index: 45;
        overflow-y: auto;
        padding: 16px;
    }

    .mobile-panel.active {
        display: block;
    }

    #panel-settings.active,
    #panel-more.active {
        left: 0;
        right: 0;
        width: auto;
        bottom: calc(72px + env(safe-area-inset-bottom, 0));
        height: auto;
        box-shadow: none;
    }

    #header-settings-btn {
        display: none !important;
    }
}

.circle-wrap {
    position: relative;
    display: block;
    width: 160px;
    height: 160px;
    margin: 0 auto 2px auto;
}

.circle-video-preview {
    width: 160px !important;
    height: 160px !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    background: #000;
    display: block;
    cursor: pointer;
}

.circle-play-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    color: rgba(255,255,255,0.9);
    pointer-events: none;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.circle-duration-out {
    display: block;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin: 0 0 6px 0;
    width: 160px;
}

#circle-viewer {
    display: none !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0,0,0,0.88) !important;
    z-index: 9999 !important;
    align-items: center !important;
    justify-content: center !important;
}

#circle-viewer.active {
    display: flex !important;
}

#circle-viewer-box {
    position: relative !important;
    width: min(80vw, 300px) !important;
    height: min(80vw, 300px) !important;
}

#circle-viewer-video {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    background: #111 !important;
    cursor: pointer !important;
}

#circle-viewer-time {
    position: absolute !important;
    left: 50% !important;
    top: calc(100% + 12px) !important;
    transform: translateX(-50%) !important;
    z-index: 3 !important;
    color: #fff !important;
    font-size: 14px !important;
    background: transparent !important;
    padding: 0 !important;
    white-space: nowrap !important;
}

#circle-viewer-ring {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 2 !important;
    pointer-events: none !important;
    transform: rotate(-90deg) !important;
}

#circle-viewer-ring .ring-bg {
    fill: none !important;
    stroke: rgba(255,255,255,0.3) !important;
    stroke-width: 3 !important;
}

#circle-viewer-ring .ring-fg {
    fill: none !important;
    stroke: #8fa382 !important;
    stroke-width: 3 !important;
    stroke-linecap: round !important;
}

#circle-viewer-pause {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 3 !important;
    font-size: 40px !important;
    color: rgba(255,255,255,0.95) !important;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6) !important;
    pointer-events: none !important;
    display: none !important;
}

#circle-viewer-pause.show {
    display: block !important;
}

.msg-react-btn {
    display: none;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    margin-top: 2px;
}

@media (hover: hover) {
    .message:hover .msg-react-btn,
    .message-bubble:hover .msg-react-btn {
        display: inline-block;
    }
}

.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.msg-reaction {
    background: #1a1816;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid rgba(143, 163, 130, 0.45);
    user-select: none;
}

.message.mine .msg-reaction {
    background: rgba(20, 17, 15, 0.45);
    border-color: rgba(243, 237, 230, 0.18);
}

.message.theirs .msg-reaction {
    background: #3d3732;
    border: 1px solid rgba(143, 163, 130, 0.55);
}

.msg-reaction:hover {
    border-color: var(--accent);
}

#reply-bar,
#edit-bar {
    background: var(--card) var(--clay) !important;
    box-shadow: var(--shadow-soft), var(--inset) !important;
    border-radius: 14px !important;
    color: var(--text) !important;
}

.reply-quote {
    background: rgba(143, 163, 130, 0.16) !important;
    border-left: 3px solid var(--accent) !important;
    border-radius: 8px !important;
}

.message-bubble {
    position: relative;
}

.msg-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
}

.msg-menu-item:hover:not(:disabled) {
    background: var(--input);
}

.msg-menu-item:disabled {
    cursor: default;
}

#msg-menu-reactions button {
    border: none;
    background: var(--input);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}

.msg-react-btn,
.react-picker {
    display: none !important;
}

#file-preview {
    background: var(--card) !important;
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
}

/* Перекрыть старый синий, который остался в chat.html */
button[style*="#2AABEE"],
button[style*="#2aabee"] {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #1a1c18 !important;
}

.avatar[style*="#2AABEE"],
.avatar[style*="#2aabee"] {
    background: var(--accent) !important;
    color: #1a1c18 !important;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
}
.icon-btn img {
    width: 40px;
    height: 40px;
    display: block;
    border-radius: 50%;
}

::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg);
}
::-webkit-scrollbar-thumb {
    background: var(--card);
    border-radius: 8px;
}

.file-btn,
.send-btn,
#pin-btn {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: hidden;
    flex-shrink: 0 !important;
}

.file-btn,
.send-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
}

.file-btn img,
.send-btn img {
    width: 44px !important;
    height: 44px !important;
    display: block;
    border-radius: 50%;
    object-fit: contain;
}

#pin-btn {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
}

#pin-btn img {
    width: 24px !important;
    height: 24px !important;
    display: block;
    border-radius: 50%;
    object-fit: contain;
}

.bottom-nav button {
    max-height: 56px !important;
    overflow: hidden;
}

.bottom-nav button .nav-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.bottom-nav button .nav-icon img {
    width: 28px !important;
    height: 28px !important;
    display: block !important;
    border-radius: 50%;
    object-fit: contain;
}

.pin-inline,
.user-item h3 img,
.user-info h3 img {
    width: 14px !important;
    height: 14px !important;
    max-width: 14px !important;
    max-height: 14px !important;
    display: inline-block !important;
    vertical-align: middle;
    margin-right: 4px;
    border-radius: 50%;
    object-fit: contain;
}

audio {
    display: block;
    min-width: 200px;
    min-height: 40px;
    max-width: 240px;
    margin-bottom: 4px;
}

.circle-play-icon {
    font-size: 0 !important;
    width: 48px !important;
    height: 48px !important;
    background: url('/static/icons/icon-play.png') center / contain no-repeat !important;
}

.circle-play-icon img {
    width: 48px !important;
    height: 48px !important;
    display: block;
}

#circle-viewer-pause {
    font-size: 0 !important;
    width: 72px !important;
    height: 72px !important;
    background: url('/static/icons/icon-pause.png') center / contain no-repeat !important;
    text-shadow: none !important;
    color: transparent !important;
}

#circle-viewer-pause img {
    width: 72px !important;
    height: 72px !important;
    display: block;
}

[style*="#17212b"],
[style*="#242f3d"],
[style*="#0e1621"],
[style*="#182533"] {
    background: var(--card) !important;
    background-color: var(--card) !important;
    border-color: var(--input) !important;
}

#panel-settings [style*="background"]:not([style*="#e53935"]),
#create-group-modal > div,
#msg-menu {
    background: var(--card) !important;
    background-color: var(--card) !important;
    color: var(--text) !important;
}

#emoji-panel {
    background: var(--card) !important;
    border-top-color: var(--input) !important;
}

.settings-title {
    margin: 0 0 18px;
    font-size: 22px;
}

.settings-card {
    background: var(--card) var(--clay);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-soft), var(--inset);
    display: flex;
    align-items: center;
    gap: 14px;
}
.settings-card.settings-stack {
    flex-direction: column;
    align-items: stretch;
}
.settings-input {
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: var(--input);
    color: var(--text);
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
}
.day-status-line {
    font-size: 12px;
    color: var(--muted);
    margin: 1px 0 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-profile .avatar {
    width: 56px;
    height: 56px;
    font-size: 22px;
}

.settings-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.settings-name,
#settings-notif-status {
    font-size: 17px;
}

.settings-row-text {
    flex: 1;
}

.settings-btn {
    width: 100%;
    min-height: 48px;
    padding: 14px;
    margin-bottom: 10px;
    border: none;
    border-radius: 14px;
    background: var(--input);
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
}

.settings-logout {
    background: transparent !important;
    color: #e57373 !important;
    border: none;
    box-shadow: none !important;
    margin-top: 8px;
}
.btn-danger-text {
    background: transparent;
    color: #e57373;
    border: none;
    box-shadow: none;
}
.btn-danger-text:hover {
    background: rgba(229, 115, 115, 0.12);
}

/* Крупный шрифт */
body.font-large .message { font-size: 19px; }
body.font-large .message .time { font-size: 13px; }
body.font-large .user-info h3 { font-size: 19px; }
body.font-large .user-info p { font-size: 15px; }
body.font-large .chat-input-area input,
body.font-large .chat-input-area textarea { font-size: 18px; }
body.font-large .settings-title { font-size: 26px; }
body.font-large .settings-name,
body.font-large #settings-notif-status { font-size: 20px; }
body.font-large .settings-label { font-size: 15px; }
body.font-large .settings-btn { font-size: 18px; padding: 14px 16px; }
body.font-large .btn { font-size: 18px; }
body.font-large .msg-menu-item { font-size: 18px; }
body.font-large .sidebar-header h2 { font-size: 22px; }
body.font-large #search-input { font-size: 17px !important; }
body.font-large .bottom-nav button { font-size: 13px; }

.font-size-row { display: flex; gap: 8px; margin-top: 10px; }
.font-size-row button {
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 10px 8px;
    background: var(--input);
    color: var(--text);
    font-size: 15px;
}
body.font-large .font-size-row button { font-size: 17px; }
.font-size-row button.active {
    background: var(--accent);
    color: #1a1a14;
}

.user-item {
    position: relative;
}
.chat-more-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin-left: 4px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.chat-more-btn:hover {
    background: var(--card-hover);
    color: var(--text);
}
#chat-list-menu {
    display: none;
    position: fixed;
    z-index: 80;
    min-width: 220px;
    background: var(--card);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 6px;
}
#chat-list-menu button {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 15px;
}
#chat-list-menu button:hover {
    background: var(--card-hover);
}

body.simple-mode .chat-more-btn,
body.simple-mode .file-btn[title="Смайлики"],
body.simple-mode #emoji-panel,
body.simple-mode .msg-react-btn,
body.simple-mode #msg-menu-reactions,
body.simple-mode .settings-btn[onclick*="showCreateGroup"],
body.simple-mode #msg-menu-schedule,
body.simple-mode .simple-hide-complex {
    display: none !important;
}

.more-section {
    margin-bottom: 18px;
}
.more-section-title {
    margin: 4px 0 8px;
    font-size: 13px;
    letter-spacing: 0.02em;
    text-transform: none;
}
.more-empty {
    font-size: 14px;
    color: var(--muted, #8a9aa9);
    line-height: 1.45;
    margin: 6px 0 10px;
}
.album-count {
    font-size: 13px;
    color: var(--muted, #8a9aa9);
    margin: 4px 0 10px;
}

body.simple-mode #chat-subtitle {
    display: none !important;
}

body.simple-mode #message-input {
    resize: none !important;
    overflow: hidden !important;
}
body.simple-mode .chat-input-area {
    gap: 10px;
}

/* Убираем тёмную полоску-скролл у поля ввода */
#message-input {
    overflow-x: hidden !important;
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* старый Edge */
}
#message-input::-webkit-scrollbar {
    display: none !important;       /* Chrome / Android */
    width: 0 !important;
    height: 0 !important;
}

.password-wrap {
    position: relative;
}
.password-wrap input {
    width: 100%;
    padding-right: 48px;
}
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    padding: 6px;
}

.msg-ticks {
    display: inline-block;
    margin-left: 6px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1;
    vertical-align: middle;
    color: rgba(243, 237, 230, 0.4);
}
.msg-ticks.seen {
    color: #f3f8ec;
    text-shadow: 0 0 5px rgba(200, 230, 170, 0.7);
}

.user-item.unread h3 { font-weight: 700; }
.chat-time {
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
    margin-left: 8px;
}
.chat-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: 8px;
}
.mute-mark {
    color: var(--muted);
    margin-left: 4px;
    font-size: 13px;
    filter: grayscale(1);
    opacity: 0.65;
    display: inline;
}
.block-mark {
    margin-left: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    opacity: 0.75;
    text-transform: lowercase;
}
.blocked-banner {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 6px 10px 8px 10px;
    padding: 12px 14px;
    background: var(--card);
    border-radius: 16px;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}
.blocked-banner button {
    border: none;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
}
.search-empty {
    padding: 28px 16px;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    line-height: 1.5;
}
.search-empty-reset {
    margin-top: 10px;
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    padding: 8px 12px;
}

.app-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 800;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.app-modal-card {
    background: var(--card);
    border-radius: 18px;
    padding: 22px 18px 16px;
    width: 100%;
    max-width: 380px;
    max-height: 86vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.app-modal-card h3 {
    margin: 0 0 8px;
    font-size: 20px;
}
.whats-new-list {
    margin: 0 0 16px;
    padding-left: 18px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
}
.whats-new-list li { margin-bottom: 10px; }

textarea.settings-input {
    min-height: 72px;
    resize: vertical;
    font-family: inherit;
}

select.settings-input {
    appearance: none;
}
.list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 16px;
}
.list-item.done span {
    text-decoration: line-through;
    color: var(--muted);
}
.list-check {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.list-item.done .list-check {
    background: var(--accent);
    color: #1a1c18;
}
.list-del {
    margin-left: auto;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
}


/* Compact settings + profile */
.settings-profile-btn {
    width: 100%;
    text-align: left;
    cursor: pointer;
    border: none;
    color: inherit;
    font: inherit;
}
.settings-list {
    background: var(--card);
    border-radius: 18px;
    overflow: visible;
    margin-bottom: 12px;
    box-shadow: var(--shadow-soft), var(--inset);
}
.settings-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: relative;
    background: transparent;
    width: 100%;
    box-sizing: border-box;
    color: var(--text);
    font: inherit;
    text-align: left;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-click { cursor: pointer; border: none; }
.settings-row-main { flex: 1; min-width: 0; }
.settings-row-label { font-size: 16px; color: var(--text); }
.settings-row-label-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}
.settings-row-sub {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.settings-row-btn {
    border: none;
    background: var(--input);
    color: var(--accent);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}
.settings-chevron {
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
}
.settings-row-danger .settings-row-label { color: #e57373; }
.settings-inline-seg { flex: 0 0 auto; max-width: 200px; }
.settings-inline-seg button {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--input);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}
.settings-inline-seg button.active {
    background: var(--accent);
    color: #1a1a1a;
}
.settings-close-btn { margin-top: 4px; }
.settings-btn-ghost {
    background: transparent !important;
    color: var(--muted) !important;
    box-shadow: none !important;
}
.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}
.toggle-switch {
    width: 48px;
    height: 28px;
    border-radius: 999px;
    border: none;
    background: #3a3a3a;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    transition: transform .18s ease;
}
.toggle-switch.on { background: var(--accent); }
.toggle-switch.on::after { transform: translateX(20px); }
.hint-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--muted);
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.hint-pop {
    position: absolute;
    left: 14px;
    right: 14px;
    top: calc(100% - 4px);
    z-index: 5;
    background: #2a2826;
    color: var(--text);
    font-size: 13px;
    line-height: 1.35;
    padding: 10px 12px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.profile-sheet .profile-card { position: relative; padding-top: 28px; }
.profile-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
}
.profile-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.profile-avatar-lg {
    width: 88px !important;
    height: 88px !important;
    font-size: 36px !important;
}
.profile-name {
    font-size: 20px;
    font-weight: 600;
}
.profile-list { margin-bottom: 0; }
body.font-large .settings-row-label { font-size: 18px; }
body.font-large .settings-row { min-height: 56px; }


#header-invite-btn {
    border: none;
    background: transparent;
    color: var(--accent);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    min-width: 40px;
    min-height: 40px;
}
.chats-empty-invite {
    padding: 36px 20px;
    text-align: center;
    color: var(--text);
}
.chats-empty-invite p { margin: 0 0 14px; font-size: 15px; color: var(--muted); }
.invite-primary-btn {
    background: var(--accent) !important;
    color: #1a1a1a !important;
    font-weight: 600;
    max-width: 280px;
    margin: 0 auto !important;
}
.invite-toast {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(143,163,130,0.25);
    color: var(--accent);
    font-size: 14px;
    text-align: center;
}

.settings-row-stack {
    flex-wrap: wrap;
    align-items: flex-start;
}
.settings-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.settings-row-btn-muted {
    color: var(--muted) !important;
    background: transparent !important;
    border: 1px solid rgba(255,255,255,0.12);
}
.settings-fallback {
    flex: 1 1 100%;
    margin: 4px 0 0;
    font-size: 12px;
    line-height: 1.35;
}


/* QA fixes */
.app-modal-nested {
    z-index: 920 !important;
    background: rgba(0,0,0,0.45);
}
#create-group-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.user-item {
    cursor: pointer;
    min-height: 64px;
    -webkit-tap-highlight-color: transparent;
}
.user-item .chat-more-btn {
    min-width: 44px;
    min-height: 44px;
}
.mic-banner, .record-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 10px 6px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.35;
}
.mic-banner {
    background: rgba(229, 115, 115, 0.15);
    color: #ffb4b4;
    justify-content: space-between;
}
.mic-banner button {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 16px;
}
.record-bar {
    background: rgba(143, 163, 130, 0.18);
    color: var(--text);
}
.record-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e53935;
    animation: recPulse 1s infinite;
}
@keyframes recPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}
.message img + .time,
.message video + .time,
.message .time {
    display: inline-block;
}
.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    max-width: 360px;
    margin: 0 auto;
}


/* BUG-01: child editors always above profile sheet */
#profile-own.app-modal,
#profile-peer.app-modal {
    z-index: 800 !important;
}
#modal-birthday.app-modal,
#modal-day-status.app-modal,
#modal-password.app-modal,
#modal-delete-account.app-modal,
#modal-feedback.app-modal,
#notif-help-modal.app-modal,
#logout-modal.app-modal {
    z-index: 960 !important;
}
#modal-birthday.app-modal .app-modal-card,
#modal-day-status.app-modal .app-modal-card,
#modal-password.app-modal .app-modal-card,
#modal-delete-account.app-modal .app-modal-card {
    position: relative;
    z-index: 961;
    pointer-events: auto;
}


/* BUG-01 replaced */

/* BUG-01 stable: profile inert under nested editors */
#profile-own.profile-under-nested,
#profile-peer.profile-under-nested,
#profile-own.profile-under-nested *,
#profile-peer.profile-under-nested * {
    pointer-events: none !important;
}
#modal-birthday.app-modal,
#modal-day-status.app-modal,
#modal-password.app-modal,
#modal-delete-account.app-modal {
    z-index: 1200 !important;
    pointer-events: auto !important;
}
#modal-birthday.app-modal .app-modal-card,
#modal-day-status.app-modal .app-modal-card,
#modal-password.app-modal .app-modal-card,
#modal-delete-account.app-modal .app-modal-card,
#modal-birthday.app-modal .app-modal-card *,
#modal-day-status.app-modal .app-modal-card *,
#modal-password.app-modal .app-modal-card *,
#modal-delete-account.app-modal .app-modal-card * {
    pointer-events: auto !important;
}

/* BUG-07: hit-target = .user-item-hit; ⋮ = только меню, без смены чата */
.user-item {
    cursor: default;
    min-height: 64px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
}
.user-item-hit {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    min-height: 64px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border-radius: 14px;
    grid-column: 1;
}
.user-item .user-info {
    flex: 1;
    min-width: 0;
}
.user-item .avatar {
    flex-shrink: 0;
}
.user-item .chat-more-btn {
    grid-column: 2;
    pointer-events: auto;
    position: relative;
    z-index: 3;
    align-self: center;
    flex-shrink: 0;
}

/* profile-info nested modal clicks */
#modal-profile-info.app-modal {
    z-index: 1200 !important;
    pointer-events: auto !important;
}
#modal-profile-info.app-modal .app-modal-card,
#modal-profile-info.app-modal .app-modal-card * {
    pointer-events: auto !important;
}


/* Список чатов на телефоне: шапка чата не перекрывает мой профиль сверху */
@media (max-width: 768px) {
    #sidebar:not(.hidden) {
        z-index: 50;
    }
}


@media (max-width: 768px) {
    .message img,
    .message video {
        max-width: min(100%, calc(100vw - 96px)) !important;
    }
}


/* ===== 1.1.27: строка ввода — тёмно-коричневая, круглые шалфейные кнопки 44px, широкое скруглённое поле ===== */
.chat-input-area.ib-bar {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    gap: 8px;
    padding: 8px 6px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    align-items: flex-end;
    flex-wrap: nowrap;
}
.ib-bar .ib-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex: 0 0 44px;
    border-radius: 50%;
    border: none;
    padding: 0;
    margin: 0;
    background: #718c6c linear-gradient(180deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.02) 45%, rgba(0,0,0,0.14) 100%);
    color: #f3ede6;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.40), inset 0 1px 0 rgba(255, 255, 255, 0.10);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: filter 0.15s, transform 0.1s;
}
.ib-bar .ib-btn[style*="display: none"] { display: none !important; }
.ib-bar .ib-btn svg { width: 24px; height: 24px; display: block; pointer-events: none; }
.ib-bar .ib-btn:hover { filter: brightness(1.07); }
.ib-bar .ib-btn:active { transform: scale(0.95); }
.ib-bar .ib-btn:disabled { opacity: 0.45; cursor: default; }
.ib-bar .ib-btn.ib-rec { background: var(--danger); animation: ib-pulse 1.2s ease-in-out infinite; }
.ib-bar .ib-btn.ib-rec svg { display: none; }
.ib-bar .ib-btn.ib-rec::after { content: ''; width: 14px; height: 14px; border-radius: 3px; background: #f3ede6; }
@keyframes ib-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(211, 90, 74, 0.55); } 50% { box-shadow: 0 0 0 7px rgba(211, 90, 74, 0); } }

.chat-input-area.ib-bar textarea#message-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    max-height: 120px;
    padding: 11px 18px;
    border-radius: 22px;
    background: #2e2724;
    color: var(--text);
    font-size: 16px;
    line-height: 22px;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.30);
    display: block !important;
    visibility: visible !important;
}
.chat-input-area.ib-bar textarea#message-input::placeholder { color: #9a8c82; }
body.font-large .chat-input-area.ib-bar textarea#message-input { font-size: 18px; }

.ib-attach-wrap { position: relative; flex: 0 0 44px; display: flex; }
.ib-attach-menu {
    position: absolute;
    left: 0;
    bottom: 54px;
    z-index: 60;
    min-width: 170px;
    padding: 6px;
    border-radius: 16px;
    background: var(--card);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ib-attach-menu button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
.ib-attach-menu button:hover, .ib-attach-menu button:focus-visible { background: var(--card-hover); outline: none; }
.ib-attach-menu button svg { width: 22px; height: 22px; color: #9fb594; flex: 0 0 22px; }
.ib-attach-menu button[style*="display: none"] { display: none !important; }

/* простой режим: без кружка и без смайлика (Файл в меню скрывает JS) */
body.simple-mode #ib-circle-btn,
body.simple-mode #emoji-btn { display: none !important; }

@media (max-width: 768px) {
    .chat-input-area.ib-bar { gap: 6px; padding-left: 2px; padding-right: 2px; }
    .chat-input-area.ib-bar textarea#message-input { padding: 11px 14px; font-size: 16px; }
}

/* 1.1.30-B: фото поверх чата — тёмный фон, крестик, закрытие тапом по фону / Esc / «Назад» */
#photo-viewer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.92);
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: calc(env(safe-area-inset-top, 0px) + 56px) env(safe-area-inset-right, 0px) calc(env(safe-area-inset-bottom, 0px) + 16px) env(safe-area-inset-left, 0px);
}
#photo-viewer.active { display: flex; }
#photo-viewer-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    -webkit-user-select: none;
    user-select: none;
}
#photo-viewer-close {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    right: calc(env(safe-area-inset-right, 0px) + 8px);
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 24px;
    line-height: 48px;
    padding: 0;
    cursor: pointer;
}
#photo-viewer-close:hover { background: rgba(255, 255, 255, 0.28); }

/* ===== 1.1.31 (site-sync2): свои окна вместо alert/confirm — как в приложении ===== */
.ui-dialog {
    position: fixed;
    inset: 0;
    z-index: 11000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.ui-dialog[hidden] { display: none; }
.ui-dialog-box {
    width: 100%;
    max-width: 380px;
    max-height: 86vh;
    overflow-y: auto;
    background: var(--card);
    color: var(--text);
    border-radius: 18px;
    padding: 22px 20px 16px;
    box-shadow: var(--shadow);
}
.ui-dialog-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.ui-dialog-title[hidden] { display: none; }
.ui-dialog-text {
    font-size: 17px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.ui-dialog-actions { display: flex; gap: 10px; margin-top: 20px; }
.ui-dialog-btn {
    flex: 1;
    min-height: 52px;
    padding: 12px 14px;
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ui-dialog-btn[hidden] { display: none; }
.ui-dialog-cancel { background: var(--input); color: var(--text); }
.ui-dialog-ok { background: var(--accent); color: #14110f; }
.ui-dialog-ok.danger { background: #e05a5a; color: #fff; }
.ui-dialog-btn:focus-visible { outline: 3px solid rgba(243, 237, 230, 0.6); outline-offset: 2px; }
@media (hover: none) { .ui-dialog-btn:focus-visible { outline: none; } }  /* на телефоне без рамки «выбрано» */
body.font-large .ui-dialog-title { font-size: 24px; }
body.font-large .ui-dialog-text { font-size: 21px; }
body.font-large .ui-dialog-btn { font-size: 20px; min-height: 60px; }
/* 1.1.33: простой режим — «Отмена» сверху, действие («Удалить») под ней (просьба Святослава) */
body.simple-mode .ui-dialog-actions { flex-direction: column; }
body.simple-mode .ui-dialog-btn { min-height: 60px; font-size: 19px; }
body.simple-mode.font-large .ui-dialog-btn { font-size: 21px; min-height: 64px; }
.ui-toast {
    position: fixed;
    left: 50%;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    transform: translate(-50%, 12px);
    z-index: 11100;
    max-width: min(92vw, 420px);
    background: #2a2420;
    color: var(--text);
    border-radius: 14px;
    padding: 12px 18px;
    font-size: 16px;
    line-height: 1.35;
    text-align: center;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}
.ui-toast.show { opacity: 1; transform: translate(-50%, 0); }
body.font-large .ui-toast { font-size: 19px; }

/* ===== 1.1.31: окно записи кружочка — как dialog_circle_record.xml в приложении ===== */
#circle-rec {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10500;
    background: rgba(20, 17, 15, 0.8);
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top, 0px) 16px env(safe-area-inset-bottom, 0px);
}
#circle-rec.active { display: flex; }
#circle-rec-cancel {
    position: absolute;
    top: calc(56px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    min-width: 200px;
    padding: 16px 28px;
    border: none;
    border-radius: 12px;
    background: #1e1a17;
    color: var(--text);
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.circle-rec-col { display: flex; flex-direction: column; align-items: center; }
#circle-rec-box {
    position: relative;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    overflow: hidden;
    background: #111;
}
#circle-rec-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);   /* как в зеркале, как превью в приложении */
}
.circle-rec-ring {
    position: absolute;
    inset: 0;
    border: 3px solid #e07070;
    border-radius: 50%;
    pointer-events: none;
}
#circle-rec-label { margin-top: 16px; color: var(--accent); font-size: 16px; }
#circle-rec-timer { margin-top: 6px; color: var(--text); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
#circle-rec-hint { margin-top: 10px; padding: 0 24px; color: #a89f96; font-size: 15px; line-height: 1.4; text-align: center; }
#circle-rec-send {
    margin-top: 18px;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: #d35a4a;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.circle-rec-stop { display: block; width: 20px; height: 20px; border-radius: 3px; background: #f3ede6; }
body.font-large #circle-rec-label { font-size: 19px; }
body.font-large #circle-rec-timer { font-size: 26px; }
body.font-large #circle-rec-hint { font-size: 18px; }
@media (max-height: 640px) {
    #circle-rec { flex-direction: column; }
    #circle-rec-cancel { position: static; transform: none; margin-bottom: 18px; }
    #circle-rec-box { width: 200px; height: 200px; }
}

/* ===== 1.1.31: крупный текст (замечания Святослава) ===== */
body.font-large .msg-sender-name { font-size: 16px !important; }
body.font-large #settings-notif-status {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.3;
}


/* ===== 1.1.35 (site-1135): лёгкая строка ввода — макет A′/B′ (input-light-mockup). =====
   Все значки тонкие (линия 2 px), без кружков-подложек, цвет #8fa382, 26 px в зоне нажатия 44×44.
   Стрелка «Отправить» светлее (#b5d1a6), линия 2,6 px, мягкое свечение. Смайлик (только глаза и улыбка) — в поле справа.
   Простой режим НЕ меняется: там старые круглые кнопки (svg.ib-old) и обёртка поля «прозрачна» (display: contents). */
.ib-bar .ib-btn svg.ib-new { display: none; }
body:not(.simple-mode) .ib-bar .ib-btn svg.ib-old { display: none !important; }
body:not(.simple-mode) .ib-bar .ib-btn svg.ib-new { display: block; width: 26px; height: 26px; }
body.simple-mode .ib-bar .ib-field { display: contents; }

body:not(.simple-mode) .chat-input-area.ib-bar {
    gap: 0;
    margin: 6px 8px;
    margin-bottom: max(8px, env(safe-area-inset-bottom));
    padding: 7px 6px;
    border-radius: 29px;
    background: #242220;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    align-items: flex-end;
}
body:not(.simple-mode) .ib-bar .ib-btn {
    background: none;
    box-shadow: none;
    color: #8fa382;
}
body:not(.simple-mode) .ib-bar .ib-btn:hover { filter: none; }
/* подсветка под мышью — только на ПК (на телефоне после нажатия «залипает» кружок, а кружков-подложек быть не должно) */
@media (hover: hover) and (pointer: fine) {
    body:not(.simple-mode) .ib-bar .ib-btn:not(.ib-rec):hover { background: rgba(143, 163, 130, 0.10); }
}
body:not(.simple-mode) .ib-bar .ib-btn:focus-visible { outline: 2px solid rgba(143, 163, 130, 0.7); outline-offset: -3px; }
body:not(.simple-mode) .ib-bar #main-action-btn { color: #b5d1a6; }
body:not(.simple-mode) .ib-bar #main-action-btn svg.ib-new { filter: drop-shadow(0 0 3px rgba(181, 209, 166, 0.35)); }
/* запись: та же кнопка — красный кружок с квадратиком «стоп», как раньше (это не значок, а знак «идёт запись») */
body:not(.simple-mode) .ib-bar .ib-btn.ib-rec { background: var(--danger); }
body:not(.simple-mode) .ib-bar .ib-btn.ib-rec svg { display: none !important; }

body:not(.simple-mode) .ib-bar .ib-field {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: flex-end;
}
body:not(.simple-mode) .chat-input-area.ib-bar textarea#message-input {
    padding: 11px 2px 11px 8px;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
body:not(.simple-mode) .chat-input-area.ib-bar textarea#message-input::placeholder { color: #8a7d73; }
body:not(.simple-mode) .ib-bar .ib-field .ib-emo { flex: 0 0 44px; }

/* крупный текст: значки чуть крупнее (28 px), зона нажатия та же 44×44 — ничего не наезжает */
body.font-large:not(.simple-mode) .ib-bar .ib-btn svg.ib-new { width: 28px; height: 28px; }

@media (max-width: 768px) {
    body:not(.simple-mode) .chat-input-area.ib-bar { margin-left: 6px; margin-right: 6px; padding: 7px 4px; }
}

/* ===== 1.1.36 (site-1136): полоска записи голосового. Видна всю запись: мигающая красная точка, «Идёт запись голосового»,
   таймер, «✕ Отмена» (запись выбрасывается, ничего не уходит). Как в приложении 1.1.36. ===== */
.record-bar.rec-strip {
    background: rgba(211, 90, 74, 0.16);
    border: 1px solid rgba(211, 90, 74, 0.45);
    color: #f3ede6;
    font-size: 15px;
    line-height: 1.3;
    gap: 8px;
    min-height: 50px;
    padding: 5px 5px 5px 12px;
    box-sizing: border-box;
    max-width: 100%;
}
.rec-strip .record-dot {
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    background: #e53935;
    box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.6);
    animation: recStripPulse 1.1s ease-in-out infinite;
}
@keyframes recStripPulse {
    0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.55); }
    50% { opacity: 0.45; transform: scale(0.82); box-shadow: 0 0 0 5px rgba(229, 57, 53, 0); }
}
.rec-strip #record-label { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow-wrap: normal; word-break: normal; }
/* 1.1.37 (site-1137): под надписью — подсказка «■ — отправить» (мельче, приглушённо), всегда одной строкой. */
.rec-strip .rec-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.rec-strip .rec-text #record-label { flex: 0 0 auto; }
.rec-strip #record-hint { font-size: 12.5px; line-height: 1.25; color: #e6c9c2; font-weight: 500; white-space: nowrap; overflow-wrap: normal; word-break: normal; }
.rec-strip #record-hint .rec-hint-sq { font-size: 1.2em; line-height: 1; vertical-align: -0.05em; }  /* ■ крупнее текста, чтобы читался */
/* самый узкий экран: подсказка — отдельной строкой под всей полоской, с отступом как у надписи */
.record-bar.rec-strip.rec-hint-wide { flex-wrap: wrap; row-gap: 2px; }
.rec-strip.rec-hint-wide #record-hint { flex: 1 0 100%; order: 10; padding-left: 20px; box-sizing: border-box; }
body.simple-mode .rec-strip.rec-hint-wide #record-hint { padding-left: 22px; }
body.font-large .rec-strip #record-hint { font-size: 15px; }
body.simple-mode .rec-strip #record-hint { font-size: 15px; color: #f0d9d3; }
.rec-strip #record-timer { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 600; color: #ffb4a8; }
.rec-strip #record-cancel {
    flex: 0 0 auto;
    min-height: 40px;
    min-width: 44px;
    padding: 0 12px;
    border-radius: 20px;
    border: 1px solid rgba(243, 237, 230, 0.35);
    background: transparent;
    color: #f3ede6;
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.rec-strip #record-cancel:active { background: rgba(243, 237, 230, 0.12); }
@media (hover: hover) { .rec-strip #record-cancel:hover { background: rgba(243, 237, 230, 0.08); } }
body.font-large .record-bar.rec-strip { font-size: 18px; min-height: 54px; }
body.font-large .rec-strip #record-cancel { min-height: 44px; }
body.simple-mode .record-bar.rec-strip { font-size: 18px; min-height: 62px; padding: 6px 6px 6px 14px; }
body.simple-mode .rec-strip .record-dot { flex-basis: 14px; width: 14px; height: 14px; }
body.simple-mode .rec-strip #record-cancel { min-height: 52px; padding: 0 14px; font-size: 18px; border-width: 2px; }

/* 1.1.38 (site-1138): стикер — без пузыря, на прозрачном фоне; время — маленькой плашкой под ним */
.message.sticker-msg { background: transparent !important; background-image: none !important; box-shadow: none !important; padding: 0 !important; }
.message.sticker-msg::before, .message.sticker-msg::after { display: none !important; }
.message.sticker-msg .message-bubble { background: transparent !important; }
.message.sticker-msg img.msg-sticker { width: 160px !important; max-width: 45vw !important; height: auto !important; max-height: 160px; border-radius: 0; object-fit: contain; background: transparent; margin: 0; }
body.simple-mode .message.sticker-msg img.msg-sticker, body.font-large .message.sticker-msg img.msg-sticker { width: 190px !important; max-height: 190px; max-width: 55vw !important; }
.message.sticker-msg .time { background: rgba(20, 17, 15, 0.62); color: #e8e1d8; padding: 1px 7px; border-radius: 9px; margin-top: 2px; }
.message.mine.sticker-msg .time { float: right; }
/* GIF — в обычном пузыре, как фото, с маленькой меткой «GIF»; в простом режиме — первый кадр и «▶ GIF» */
.msg-gif-wrap { position: relative; display: inline-block; max-width: 100%; margin-bottom: 4px; line-height: 0; }
.msg-gif-badge { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, 0.55); color: #fff; font: 700 11px/1 system-ui, sans-serif; padding: 3px 6px; border-radius: 6px; pointer-events: none; }
.msg-gif-still { cursor: pointer; min-width: 120px; min-height: 90px; background: rgba(0, 0, 0, 0.18); border-radius: 12px; }
.msg-gif-still canvas { display: block; max-width: min(100%, calc(100vw - 96px)); max-height: min(50vh, 360px); width: auto; height: auto; border-radius: 12px; }
.msg-gif-wrap img.msg-gif { max-height: min(50vh, 360px); width: auto; max-width: min(100%, calc(100vw - 96px)); }
.msg-gif-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, 0.62); color: #fff;
    font: 700 18px/1 system-ui, sans-serif; padding: 12px 16px; border-radius: 26px; pointer-events: none; white-space: nowrap; }
.msg-gif-still:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ===== b1140 ===== */
/* просмотр фото: зум и перетаскивание; кнопка «Сохранить» */
#photo-viewer { touch-action: none; overscroll-behavior: contain; }
#photo-viewer-img { touch-action: none; transform-origin: 0 0; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; will-change: transform; }
#photo-viewer.zoomed #photo-viewer-img { cursor: grab; max-width: none; }
#photo-viewer.zoomed #photo-viewer-img:active { cursor: grabbing; }
#photo-viewer-save {
    position: absolute; left: 50%; transform: translateX(-50%);
    bottom: max(18px, env(safe-area-inset-bottom)); z-index: 2;
    min-height: 44px; padding: 0 20px; border-radius: 22px; border: none;
    background: rgba(143, 163, 130, 0.92); color: #10170d; font-size: 16px; font-weight: 600; cursor: pointer;
}
#photo-viewer-save:hover { background: #a3b896; }
body.simple-mode #photo-viewer-save, body.font-large #photo-viewer-save { min-height: 56px; font-size: 19px; padding: 0 28px; border-radius: 28px; }
.msg-save-btn { margin-left: 8px; background: none; border: 1px solid rgba(143,163,130,0.55); color: #b5d1a6; border-radius: 8px; padding: 2px 8px; font-size: 13px; cursor: pointer; }
body.simple-mode .msg-save-btn { font-size: 16px; padding: 6px 12px; }
/* простой режим: ⋮ в чате снова виден, крупный */
body.simple-mode #group-info-btn { font-size: 30px !important; min-width: 48px; min-height: 48px; }


/* ===== b1145: чистый список чатов на телефоне (превью-чаты-список.jpg). Компьютер не меняется. ===== */
.hib-svg { display: none; }
.bottom-nav button.nav-more-hidden { display: none !important; }  /* «Ещё» — в «Настройках» первой строкой */
.bottom-nav button .nav-icon.nav-svg svg { width: 26px; height: 26px; display: block; }
@media (max-width: 768px) {
    .sidebar-header {
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        padding: 14px 16px 6px !important;
        margin: 0 !important;
    }
    .sidebar-header #my-avatar,
    .sidebar-header img[alt="7Я"],
    .sidebar-header #current-user { display: none !important; }
    .sidebar-header h2 { font-size: 34px !important; font-weight: 800 !important; letter-spacing: -0.5px; line-height: 1.1; }
    body.font-large .sidebar-header h2 { font-size: 36px !important; }
    #header-invite-btn {
        width: 46px; height: 46px; min-width: 46px; min-height: 46px; padding: 0;
        display: inline-flex; align-items: center; justify-content: center;
        border: 1.5px solid rgba(143, 163, 130, 0.75); border-radius: 14px; background: transparent; color: var(--accent);
    }
    #header-invite-btn .hib-txt { display: none; }
    #header-invite-btn .hib-svg { display: block; }
    #search-input {
        height: 50px; border-radius: 14px !important; font-size: 17px !important; padding: 0 16px !important;
        background: var(--card) !important; box-shadow: var(--inset);
    }
    #search-input::placeholder { color: var(--muted); }
    /* меню чата — долгим нажатием; три точки у строки не показываем */
    .user-list .chat-more-btn { display: none !important; }
    .user-list .user-item, .user-list .user-item-hit { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
    /* вкладки: тонкие контурные значки, активная — шалфей на тёмно-зелёной подложке, в строку */
    .bottom-nav button {
        flex-direction: row !important; gap: 10px !important; font-size: 16px !important; font-weight: 500 !important; max-height: 54px !important;
    }
    .bottom-nav button .nav-icon.nav-svg { width: 26px !important; height: 26px !important; }
    .bottom-nav button.active { background: rgba(143, 163, 130, 0.16) !important; color: var(--accent) !important; }
    .bottom-nav button:not(.active) { color: var(--muted); }
    body.font-large .bottom-nav button { font-size: 18px !important; }
}
