:root {
    --radius: 8px;
    --radius-card: 12px;
    --font-sans: 'Segoe UI', -apple-system, sans-serif;
    --pad-sm: 8px;
    --pad-md: 12px;
    --pad-lg: 16px;
    --pad-xl: 24px;
    --gap-sm: 8px;
    --gap-md: 12px;
    --gap-lg: 16px;
}

/* Тема 1: Светлая (по умолчанию) */
[data-theme="light"] {
    --bg-page: #F7F8FA;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --border: #E4E6EB;
    --text-primary: #1A1A1A;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --accent: #378ADD;
    --accent-soft: #E6F1FB;
    --accent-text: #0C447C;
    --on-accent: #FFFFFF;
    --avatar-1-bg: #CECBF6;
    --avatar-1-text: #26215C;
    --avatar-2-bg: #C0DD97;
    --avatar-2-text: #173404;
    --blob-1: #378ADD;
    --blob-2: #D85A30;
    --blob-3: #1D9E75;
    --type-news: #1D9E75;
    --type-news-bg: #E8F7F1;
    --type-system: #9CA3AF;
    --type-system-bg: #F3F4F6;
}

/* Тема 2: Тёплая */
[data-theme="warm"] {
    --bg-page: #FBF6F3;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --border: #F0E2DA;
    --text-primary: #2A1810;
    --text-secondary: #8A6F63;
    --text-muted: #B8A69C;
    --accent: #D85A30;
    --accent-soft: #FAECE7;
    --accent-text: #712B13;
    --on-accent: #FAECE7;
    --avatar-1-bg: #F5C4B3;
    --avatar-1-text: #712B13;
    --avatar-2-bg: #FAC775;
    --avatar-2-text: #633806;
    --blob-1: #D85A30;
    --blob-2: #FAC775;
    --blob-3: #712B13;
    --type-news: #3B8C5A;
    --type-news-bg: #EAF4EC;
    --type-system: #B8A69C;
    --type-system-bg: #F5EEE9;
}

/* Тема 3: Тёмная */
[data-theme="dark"] {
    --bg-page: #101012;
    --bg-surface: #151517;
    --bg-card: #1F2023;
    --border: #333333;
    --text-primary: #F1EFE8;
    --text-secondary: #B4B2A9;
    --text-muted: #7A7975;
    --accent: #EF9F27;
    --accent-soft: #412402;
    --accent-text: #FAC775;
    --on-accent: #412402;
    --avatar-1-bg: #5DCAA5;
    --avatar-1-text: #04342C;
    --avatar-2-bg: #D4537E;
    --avatar-2-text: #4B1528;
    --blob-1: #EF9F27;
    --blob-2: #1D9E75;
    --blob-3: #D4537E;
    --type-news: #5DCAA5;
    --type-news-bg: #0F2A22;
    --type-system: #7A7975;
    --type-system-bg: #1A1A1C;
}

/* Тема 4: Зелёная */
[data-theme="green"] {
    --bg-page: #F5F8F0;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --border: #E1EAD4;
    --text-primary: #1C2B0E;
    --text-secondary: #5F7048;
    --text-muted: #94A87F;
    --accent: #639922;
    --accent-soft: #EAF3DE;
    --accent-text: #27500A;
    --on-accent: #EAF3DE;
    --avatar-1-bg: #C0DD97;
    --avatar-1-text: #173404;
    --avatar-2-bg: #97C459;
    --avatar-2-text: #173404;
    --blob-1: #639922;
    --blob-2: #97C459;
    --blob-3: #3B6D11;
    --type-news: #3B6D11;
    --type-news-bg: #E4EEDC;
    --type-system: #94A87F;
    --type-system-bg: #EFF3E9;
}

* {
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-page);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
    border: 2px solid var(--bg-page);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

body {
    margin: 0;
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
}

a {
    color: var(--accent-text);
    text-decoration: none;
}

input[type="text"], input[type="password"], textarea {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--pad-sm) var(--pad-md);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
}

button, input[type="submit"], input[type="button"] {
    border: none;
    border-radius: var(--radius);
    padding: var(--pad-sm) var(--pad-lg);
    background: var(--accent);
    color: var(--on-accent);
    font-family: var(--font-sans);
    font-size: 14px;
    cursor: pointer;
}

/* ---------- Layout ---------- */

.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--pad-lg);
    position: relative;
}

/* ---------- Desktop-\u0441\u0435\u0442\u043a\u0430: \u0441\u0430\u0439\u0434\u0431\u0430\u0440 + \u043a\u043e\u043d\u0442\u0435\u043d\u0442 + \u043f\u0440\u0430\u0432\u044b\u0439 \u0441\u0430\u0439\u0434\u0431\u0430\u0440 ---------- */

.app-shell {
    display: block;
}

.sidebar-left, .sidebar-right {
    display: none;
}

.sidebar-left {
    background: var(--bg-surface);
    border-radius: var(--radius-card);
    padding: var(--pad-md);
    align-self: start;
    position: sticky;
    top: var(--pad-lg);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: var(--gap-md);
}

.sidebar-nav a, .sidebar-nav .sidebar-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-secondary);
}

.sidebar-nav a.active {
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 500;
}

.sidebar-nav .sidebar-divider {
    border-top: 1px solid var(--border);
    margin-top: 6px;
    padding-top: 10px;
    height: 0;
}

.sidebar-icon {
    font-size: 15px;
    width: 18px;
    text-align: center;
}

.sidebar-right {
    background: var(--bg-surface);
    border-radius: var(--radius-card);
    padding: var(--pad-md);
    align-self: start;
    position: sticky;
    top: var(--pad-lg);
}

.online-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
}

@media (min-width: 900px) {
    .app-shell {
        display: grid;
        grid-template-columns: 200px minmax(0, 1fr) 240px;
        gap: var(--gap-lg);
        align-items: start;
    }
    .sidebar-left, .sidebar-right {
        display: block;
    }
    .site-header .site-nav {
        display: none;
    }
    .site-header .logo {
        display: none;
    }
}

/* ---------- \u0426\u0432\u0435\u0442\u043e\u0432\u0430\u044f \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0430\u0446\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0432 \u043b\u0435\u043d\u0442\u0435 ---------- */

.feed-card.type-1 {
    background: var(--type-news-bg);
    border-left: 3px solid var(--type-news);
}

.feed-card.type-2 {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
}

.feed-card.type-3 {
    background: var(--type-system-bg);
    border-left: 3px solid var(--type-system);
}

.feed-type-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
}

.type-1 .feed-type-label { background: var(--type-news); color: var(--bg-surface); }
.type-2 .feed-type-label { background: var(--accent); color: var(--on-accent); }
.type-3 .feed-type-label { background: var(--type-system); color: var(--bg-surface); }

/* Декоративные размытые пятна на фоне */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 22px 22px;
    opacity: 0.5;
}
.bg-blobs span {
    position: absolute;
    border-radius: 50%;
    filter: blur(50px);
    opacity: 0.22;
}
.bg-blobs span:nth-child(1) { width: 420px; height: 420px; top: -120px; left: -120px; background: var(--blob-1); }
.bg-blobs span:nth-child(2) { width: 360px; height: 360px; bottom: -100px; right: -80px; background: var(--blob-2); }
.bg-blobs span:nth-child(3) { width: 280px; height: 280px; top: 35%; right: 5%; background: var(--blob-3); }
.bg-blobs span:nth-child(4) { width: 220px; height: 220px; top: 55%; left: 8%; background: var(--blob-1); opacity: 0.16; }
.bg-blobs span:nth-child(5) { width: 300px; height: 300px; bottom: 20%; right: 30%; background: var(--blob-2); opacity: 0.14; }

/* ---------- Шапка ---------- */

.site-header {
    background: var(--bg-surface);
    border-radius: var(--radius-card);
    padding: var(--pad-md) var(--pad-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--gap-lg);
    flex-wrap: wrap;
    gap: var(--gap-md);
}

.site-header .logo {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    font-weight: 500;
    font-size: 16px;
    color: var(--text-primary);
}

.site-header .logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.site-nav {
    display: flex;
    gap: var(--gap-md);
    flex-wrap: wrap;
}

.site-nav a {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 20px;
}

.site-nav a.active {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.theme-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px;
}

.theme-switcher button {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    padding: 0;
    border: 2px solid transparent;
    cursor: pointer;
}
.theme-switcher button[data-theme-option="light"] { background: #378ADD; }
.theme-switcher button[data-theme-option="warm"] { background: #D85A30; }
.theme-switcher button[data-theme-option="dark"] { background: #151517; }
.theme-switcher button[data-theme-option="green"] { background: #639922; }
.theme-switcher button.is-active { border-color: var(--text-primary); }

/* ---------- Карточки ленты ---------- */

.feed-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: var(--pad-md) var(--pad-lg);
    margin-bottom: var(--gap-md);
}

.feed-card-meta {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    margin-bottom: var(--pad-sm);
}

.feed-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
}

.feed-avatar.a1 { background: var(--avatar-1-bg); color: var(--avatar-1-text); }
.feed-avatar.a2 { background: var(--avatar-2-bg); color: var(--avatar-2-text); }

.feed-author {
    font-size: 13px;
    font-weight: 500;
}

.feed-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

.feed-text {
    font-size: 14px;
    color: var(--text-primary);
    margin: 0;
    white-space: pre-wrap;
}

/* ---------- Подвал ---------- */

.site-footer {
    background: var(--bg-surface);
    border-radius: var(--radius-card);
    padding: var(--pad-xl);
    display: flex;
    justify-content: space-between;
    gap: var(--gap-lg);
    flex-wrap: wrap;
    margin-top: var(--gap-lg);
    font-size: 12px;
    color: var(--text-secondary);
}

/* ---------- Пузыри переписки (диалоги) ---------- */

.msg-row {
    display: flex;
    margin-bottom: var(--gap-sm);
}

.msg-row.msg-mine {
    justify-content: flex-end;
}

.msg-row.msg-theirs {
    justify-content: flex-start;
}

.msg-bubble {
    max-width: 70%;
    padding: var(--pad-sm) var(--pad-md);
    border-radius: var(--radius-card);
}

.msg-mine .msg-bubble {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-bottom-right-radius: 2px;
}

.msg-theirs .msg-bubble {
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-bottom-left-radius: 2px;
}

.msg-meta {
    display: flex;
    gap: var(--gap-sm);
    margin-bottom: 4px;
}

.msg-author {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.msg-time {
    font-size: 11px;
    color: var(--text-muted);
}

.msg-text {
    font-size: 14px;
    margin: 0;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* ---------- Модальные окна ---------- */

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface);
    border-radius: var(--radius-card);
    padding: var(--pad-xl);
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.modal.is-open {
    display: block;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

.modal-overlay.is-open {
    display: block;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    padding: 4px 8px;
}
