/* Мобильное приложение FamilyHub — стили PWA */

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

:root {
    --bg: #f0f2f5;
    --card: #fff;
    --text: #2c3e50;
    --muted: #888;
    --border: #e0e0e0;
    --accent: #3498db;
    --accent-dark: #2980b9;
    --danger: #e74c3c;
    --ok: #27ae60;
}

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ===== Общие элементы ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-ghost { border: none; background: transparent; color: #ecf0f1; padding: 8px 10px; }
.btn-sm { padding: 8px 14px; font-size: 14px; border-radius: 8px; }
.btn-block { width: 100%; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    background: #fff;
    color: var(--text);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 6px;
    color: var(--muted);
}

.error { background: #fdecea; color: #c0392b; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 10px; }
.ok { background: #eafaf1; color: var(--ok); padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 10px; }
.muted { color: var(--muted); }

.card {
    background: var(--card);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card-title { font-size: 16px; margin-bottom: 12px; }
.view-title { font-size: 18px; margin-bottom: 16px; }

.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; }

/* ===== Экран входа ===== */

.login-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}
.login-logo { margin-bottom: 8px; }
.login-logo img { border-radius: 22px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.login-title { font-size: 28px; font-weight: 700; }
.login-subtitle { color: var(--muted); margin-bottom: 28px; }
.login-form { width: 100%; max-width: 360px; text-align: left; }
.login-version { margin-top: 24px; color: var(--muted); font-size: 12px; }

/* ===== Промежуточный экран (после входа) ===== */

.splash-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.25s;
}
.splash-screen.show { visibility: visible; opacity: 1; }
.splash-top {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 24px);
    left: 0; right: 0;
    font-size: 12px;
    color: var(--muted);
}
.splash-center img {
    max-width: 60%;
    max-height: 40vh;
    object-fit: contain;
}
.splash-bottom {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom) + 20px);
    left: 0; right: 0;
    font-size: 12px;
    color: var(--muted);
}

/* ===== Приложение ===== */

.app-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #2c3e50;
    color: #ecf0f1;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}
.app-header-title { font-weight: 700; font-size: 17px; }
.app-header-logo { height: 26px; width: auto; display: block; background: #fff; border-radius: 6px; }
.app-header-user { display: flex; align-items: center; gap: 8px; }
.app-header-user .avatar { border: 1px solid rgba(255,255,255,0.3); }

.header-notify {
    position: relative;
    margin-left: auto;
    background: transparent;
    border: none;
    color: #ecf0f1;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
}
.header-notify-icon { display: block; }
.notify-badge {
    position: absolute;
    top: -3px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-sizing: border-box;
}

.app-content { flex: 1; padding: 16px; }
.view { max-width: 520px; margin: 0 auto; }

/* ===== Баннер обновления ===== */

.update-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 520px;
    margin: 0 auto 14px;
    padding: 12px 14px;
    background: #eaf4ff;
    border: 1px solid var(--accent);
    border-radius: 12px;
}
.update-banner-body { flex: 1; min-width: 0; }
.update-banner-title { font-weight: 600; font-size: 15px; }
.update-banner-notes { color: var(--muted); font-size: 13px; margin-top: 2px; }
.update-banner-progress { color: var(--accent-dark); font-size: 13px; margin-top: 4px; font-weight: 600; }
.update-banner-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.update-dismiss {
    background: none; border: none;
    font-size: 22px; line-height: 1;
    color: var(--muted); cursor: pointer; padding: 2px 6px;
}

/* ===== Главная ===== */

.home-hero {
    text-align: center;
    padding: 8px 0 20px;
}
.home-photo {
    width: 88px; height: 88px; border-radius: 50%;
    object-fit: cover; margin-bottom: 12px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.home-photo-ph {
    width: 88px; height: 88px; border-radius: 50%;
    background: #e8ecf1; color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px; font-size: 13px;
}
.home-note { color: var(--muted); margin-top: 6px; }

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}
.stat-card {
    background: var(--card);
    border-radius: 14px;
    padding: 16px 12px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-icon { font-size: 24px; }
.stat-value { font-size: 24px; font-weight: 700; margin: 4px 0; }
.stat-label { font-size: 12px; color: var(--muted); }

/* ===== Настройки / Пользователи ===== */

.photo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.photo-actions { display: flex; gap: 8px; }

.users-list { margin-bottom: 6px; }
.user-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid #f3f3f3;
}
.user-row:last-child { border-bottom: none; }
.user-row .avatar { flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; }
.user-meta { font-size: 12px; color: var(--muted); }
.role-badge {
    font-size: 11px; padding: 2px 8px; border-radius: 999px;
    background: #eef4fb; color: var(--accent-dark); margin-left: 6px;
}
.role-badge.role-owner { background: #fef3e2; color: #e67e22; }
.role-badge.role-guest { background: #f0f0f0; color: #777; }
.user-actions { display: flex; gap: 6px; flex-shrink: 0; }
.user-actions .btn { padding: 6px 10px; font-size: 13px; }

/* ===== Таб-бар ===== */

.tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 10;
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    padding-bottom: env(safe-area-inset-bottom);
}
.tab {
    flex: 1;
    border: none; background: transparent;
    padding: 10px 0 8px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 12px; color: var(--muted); cursor: pointer;
}
.tab .tab-icon { font-size: 22px; }
.tab.active { color: var(--accent); }

/* ===== Галерея / Лучшее / Обсуждения ===== */

.gallery-seg {
    display: flex;
    background: #e8ecf1;
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 14px;
    gap: 2px;
}
.gallery-seg-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 6px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}
.gallery-seg-btn.active {
    background: #fff;
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.gallery-crumbs {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
    line-height: 1.7;
    word-break: break-word;
}
.gallery-crumbs a { color: var(--accent); text-decoration: none; }
.gallery-crumbs span { margin: 0 6px; color: var(--muted); }

.gallery-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 12px;
}
.gallery-actions:empty { display: none; }

.filter-bar { display: flex; gap: 4px; flex-wrap: wrap; margin-left: 6px; }
.filter-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #555;
}
.filter-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 500;
}

/* Дерево разделов и галерей */
.tree-section {
    margin-bottom: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.tree-section-header {
    padding: 12px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    background: #f9fafb;
    user-select: none;
}
.tree-section-header strong { word-break: break-word; }
.tree-section-actions { margin-left: auto; display: flex; gap: 4px; flex-shrink: 0; }
.tree-galleries { padding: 4px 0; }
.tree-gallery {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px 9px 28px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
}
.tree-gallery:active { background: #f0f7ff; }
.tree-gallery-count { color: #999; font-size: 11px; margin-left: auto; flex-shrink: 0; }
.tree-gallery-empty { color: #ccc; font-size: 12px; padding: 4px 14px 4px 28px; display: block; }

/* Сетки карточек */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}
.gallery-card {
    background: #fafbfc;
    border: 1px solid #e8eaed;
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    position: relative;
}
.gallery-card h3 { margin: 0 0 6px; font-size: 15px; color: var(--text); word-break: break-word; padding-right: 56px; }
.gallery-card .card-date { font-size: 12px; color: #999; }
.gallery-card .card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
}
.gallery-card .card-actions .btn { padding: 5px 9px; font-size: 13px; }
.guest-hidden-badge { display: inline-block; font-size: 13px; opacity: 0.7; vertical-align: middle; cursor: help; }

/* Сетка медиа */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 8px;
}
.media-card {
    background: #fafbfc;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}
.media-thumb-wrap {
    position: relative;
    line-height: 0;
    background: #1a1a2e;
    min-height: 90px;
    overflow: hidden;
}
.media-thumb-wrap img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    display: block;
}
.media-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    pointer-events: none;
    z-index: 1;
    background: rgba(0,0,0,0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.media-thumb-wrap::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    pointer-events: none;
    z-index: 1;
}
.media-reactions-overlay {
    position: absolute;
    bottom: 6px;
    left: 6px;
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    pointer-events: none;
    z-index: 2;
}
.media-reaction-emoji { font-size: 13px; line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.media-comment-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    pointer-events: none;
    z-index: 2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.media-card .media-info { padding: 7px 9px; font-size: 12px; }
.media-card .media-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.media-card .media-meta { color: #999; font-size: 11px; margin-top: 2px; }
.media-card .media-del {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 3px 7px;
    font-size: 12px;
    cursor: pointer;
    z-index: 3;
}

/* Форма создания/редактирования галереи */
.inline-form {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
}
.inline-form input[type="text"],
.inline-form input[type="date"] {
    padding: 8px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.inline-form input:focus { outline: none; border-color: var(--accent); }
.inline-form .checkbox-label {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.inline-form .checkbox-label input[type="checkbox"] { cursor: pointer; }

.gallery-date-info { color: #999; font-size: 12px; padding: 0 0 8px 0; }

/* Прогресс загрузки */
.upload-progress {
    margin-bottom: 14px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}
.upload-progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    color: #555;
    gap: 8px;
}
.upload-progress-bar { height: 6px; background: #e8ecf1; border-radius: 3px; overflow: hidden; }
.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.pagination-btn {
    padding: 7px 11px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #555;
}
.pagination-btn:disabled { opacity: 0.4; cursor: default; }
.pagination-active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.pagination-info { font-size: 12px; color: #999; margin: 0 10px; }
.pagination-ellipsis { padding: 6px 4px; font-size: 13px; color: #999; user-select: none; }

/* Лучшее / Обсуждения */
.best-info { padding: 9px 11px 11px; }
.best-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    font-size: 13px;
}
.best-path { font-size: 12px; color: #999; margin-bottom: 3px; }
.best-path a { color: var(--accent); text-decoration: none; }
.best-path a:active { text-decoration: underline; }

/* Лайтбокс */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.94);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s;
    padding-bottom: env(safe-area-inset-bottom);
}
.lightbox-overlay.show { visibility: visible; opacity: 1; }

.lightbox-content {
    max-width: 92vw;
    max-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-content img,
.lightbox-content video {
    max-width: 92vw;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 4px;
}
.lightbox-content img {
    touch-action: none;
    transform-origin: center center;
    will-change: transform;
}
.lightbox-fallback { text-align: center; padding: 30px 20px; color: #ccc; }
.lightbox-fallback-icon { font-size: 56px; margin-bottom: 14px; }
.lightbox-fallback-name { font-size: 16px; margin-bottom: 6px; word-break: break-word; }
.lightbox-fallback-hint { font-size: 13px; color: #999; margin-bottom: 14px; }

.lightbox-close {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 12px);
    right: 16px;
    background: none;
    border: none;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    z-index: 2001;
    opacity: 0.8;
}

.lightbox-viewer {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
}
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 34px;
    width: 44px;
    height: 70px;
    cursor: pointer;
    border-radius: 6px;
    opacity: 0.7;
    z-index: 2001;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-prev { left: 6px; }
.lightbox-next { right: 6px; }

.lightbox-reactions {
    display: flex;
    gap: 3px;
    justify-content: center;
    padding: 12px 8px 4px;
    flex-wrap: wrap;
    max-width: 92vw;
}
.reaction-btn {
    font-size: 20px;
    padding: 4px 7px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: rgba(255,255,255,0.08);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 2px;
    color: #ddd;
}
.reaction-btn.my { border-color: #3498db; background: rgba(52,152,219,0.2); }
.reaction-count { font-size: 11px; color: #aaa; min-width: 10px; }

.lightbox-info {
    color: #ccc;
    font-size: 12px;
    margin-top: 10px;
    display: flex;
    gap: 12px;
    align-items: center;
    max-width: 92vw;
    padding: 0 8px;
}
.lightbox-info #lightbox-name { word-break: break-word; }
.lightbox-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}
.lightbox-actions .btn {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #ddd;
    font-size: 12px;
    padding: 7px 11px;
    white-space: nowrap;
}
.lightbox-actions .btn-danger { color: #ff6b6b; border-color: rgba(255,107,107,0.4); }

/* Панель комментариев */
.comments-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    background: #fff;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    visibility: hidden;
    transform: translateX(100%);
    transition: transform 0.25s;
}
.comments-panel.show { visibility: visible; transform: translateX(0); }
.comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
    border-bottom: 1px solid #e5e7eb;
}
.comments-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.comments-header .lightbox-close { position: static; color: #333; font-size: 24px; z-index: auto; }
.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.comment-item {
    padding: 10px 14px;
    border-radius: 10px;
    background: #f3f4f6;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    max-width: 88%;
    align-self: flex-start;
}
.comment-item.my { align-self: flex-end; background: #e8f4fd; }
.comment-user { font-size: 11px; font-weight: 600; color: #6b7280; display: block; margin-bottom: 2px; }
.comment-text { color: #1f2937; white-space: pre-wrap; word-break: break-word; }
.comment-time { font-size: 10px; color: #9ca3af; display: block; margin-top: 6px; text-align: right; }
.comment-delete {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px;
}
.comment-delete:active { color: #ef4444; }
.comments-form {
    display: flex;
    gap: 8px;
    padding: 12px 14px calc(env(safe-area-inset-bottom) + 12px);
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}
.comments-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    min-width: 0;
}
.comments-form input:focus { outline: none; border-color: var(--accent); }

/* Модальное окно */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s;
}
.modal-overlay.show { visibility: visible; opacity: 1; }
.modal-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    transform: translateY(-20px) scale(0.97);
    transition: transform 0.2s;
}
.modal-overlay.show .modal-box { transform: translateY(0) scale(1); }
.modal-header { padding: 20px 22px 6px; }
.modal-header h3 { font-size: 17px; color: var(--text); margin: 0; }
.modal-body { padding: 8px 22px 16px; }
.modal-body p { color: #555; font-size: 14px; line-height: 1.5; margin: 0; word-break: break-word; }
.modal-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    margin-top: 12px;
}
.modal-input:focus { outline: none; border-color: var(--accent); }
.modal-footer {
    padding: 0 22px 18px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Уведомления ===== */

.notifications-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 420px;
    height: 100%;
    background: #fff;
    z-index: 2200;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
}
.notifications-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
    border-bottom: 1px solid #e5e7eb;
}
.notifications-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.notifications-header .lightbox-close { position: static; color: #333; font-size: 24px; z-index: auto; }
.notifications-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.notifications-empty {
    padding: 40px 20px;
    text-align: center;
    color: #888;
    font-size: 15px;
}
.notification {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
}
.notification.unread { background: #eef6fd; }
.notification:active { background: #f0f2f5; }
.notification-icon { font-size: 22px; line-height: 1.2; }
.notification-body { flex: 1; min-width: 0; }
.notification-text { font-size: 14px; color: #2c3e50; line-height: 1.4; }
.notification.unread .notification-text { font-weight: 600; }
.notification-time { font-size: 12px; color: #888; margin-top: 2px; }

/* ===== Чат ===== */

#view-chat {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 156px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-width: 520px;
    margin: 0 auto;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-msg {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
}

.chat-msg-mine {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg-other {
    align-self: flex-start;
    background: #f0f2f5;
    color: #333;
    border-bottom-left-radius: 4px;
}

.chat-msg-user {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.8;
}

.chat-msg-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-msg-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

.chat-msg-mine .chat-msg-time { color: rgba(255,255,255,0.7); }

.chat-form {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding-top: 8px;
}

.chat-form input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 22px;
    font-size: 15px;
    font-family: inherit;
}

.chat-form input:focus { outline: none; border-color: var(--accent); }

.chat-send-btn {
    flex-shrink: 0;
    align-self: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-send-btn:active { background: var(--accent-dark); }

/* Ответ на сообщение: цитата исходного (как в Telegram) */
.chat-msg-quote {
    padding: 4px 10px;
    margin-bottom: 6px;
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    background: rgba(0,0,0,0.07);
    line-height: 1.3;
}
.chat-msg-quote-user {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-msg-quote-text {
    font-size: 12px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-msg-mine .chat-msg-quote {
    border-left-color: rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.18);
}
.chat-msg-mine .chat-msg-quote-user { color: #fff; }
.chat-msg-mine .chat-msg-quote-text { opacity: 0.9; }

/* Ответ по тапу на чужое сообщение */
.chat-msg-other { cursor: pointer; }

/* Баннер «в ответ …» над полем ввода */
.chat-reply-banner {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: #e8f1fb;
    border-radius: 10px;
    font-size: 13px;
}
.chat-reply-banner-text {
    flex: 1;
    min-width: 0;
}
.chat-reply-banner-label {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 1px;
}
.chat-reply-banner-label b { color: var(--accent-dark); }
.chat-reply-banner-msg {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-reply-cancel {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
}

.tab { position: relative; }
.tab-badge {
    position: absolute;
    top: 2px;
    left: 50%;
    margin-left: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

/* Кнопка «Открыть чат» на главной — компактная, по центру (меньше полноширинной) */
#home-chat-btn {
    display: flex;
    width: fit-content;
    margin: 14px auto 0;
    padding: 10px 16px;
    font-size: 13px;
}
