:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --pink: #ec4899;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,.1);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.1);
    --transition: all .3s cubic-bezier(.4,0,.2,1);
    --sidebar-width: 260px;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0,0,0,.5);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; transition: var(--transition); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1000px; margin: 0 auto; padding: 0 1rem; }

/* 🔘 ЕДИНАЯ СИСТЕМА КНОПОК */
.btn, .btn-secondary, .btn-danger, .btn-ghost, .btn-w, .btn-o {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    border-radius: var(--radius);
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
    user-select: none;
}

.btn:focus-visible, .btn-secondary:focus-visible, .btn-danger:focus-visible, .btn-ghost:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn:active, .btn-secondary:active, .btn-danger:active, .btn-ghost:active { transform: translateY(1px); }

.btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}
.btn:hover { box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35); transform: translateY(-1px); }

.btn-secondary {
    background: var(--card);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}
.btn-danger:hover { box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35); transform: translateY(-1px); }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid transparent;
    padding: 0.5rem 0.8rem;
}
.btn-ghost:hover { background: var(--bg); color: var(--primary); }

.btn-w { background: var(--warning); color: #000; }
.btn-o { border: 1px solid var(--border); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-icon { padding: 0.5rem; border-radius: 50%; width: 40px; height: 40px; }
.btn:disabled, .btn-secondary:disabled, .btn-danger:disabled, .btn-ghost:disabled {
    opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important;
}

/* 📱 Header и навигация */
header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,.9);
    box-shadow: var(--shadow);
}
[data-theme="dark"] header { background: rgba(30,41,59,.9); }

.nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo {
    display: flex; align-items: center; gap: 0.5rem;
    font-weight: 800; font-size: 1.3rem;
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}
.logo:hover { transform: translateY(-2px); filter: drop-shadow(0 4px 8px rgba(59,130,246,.3)); }
.links { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

/* 📱 Mobile Bottom Nav */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0,0,0,.1);
}
.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    color: var(--muted);
    text-decoration: none;
    padding: 0.5rem;
    transition: var(--transition);
}
.mobile-nav a.active, .mobile-nav a:hover { color: var(--primary); }

/* 🎨 Theme Toggle */
.theme-toggle {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 1.3rem;
}
.theme-toggle:hover { transform: rotate(180deg); background: var(--primary); color: #fff; }

/* 📦 Карточки и виджеты */
.widget {
    background: var(--card);
    padding: 1.2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}
.widget:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.widget h3 { margin: 0 0 0.4rem; font-size: 1rem; color: var(--muted); font-weight: 500; }
.widget-content { font-size: 1.8rem; font-weight: 700; color: var(--primary); }

.post-card, .form-card, .chat-container {
    background: var(--card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.post-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--purple), var(--pink));
    opacity: 0; transition: var(--transition);
}
.post-card:hover::before { opacity: 1; }

/* 🏷️ Бейджи */
.badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.3rem 0.8rem; border-radius: 20px;
    font-size: 0.8rem; font-weight: 600; color: #fff;
    margin-right: 0.5rem;
    transition: var(--transition);
}
.badge:hover { transform: scale(1.05); }
.badge-news { background: var(--warning); }
.badge-classified { background: var(--primary); }
.badge-event { background: var(--success); }
.badge-complaint { background: var(--danger); }
.badge-urgent { background: var(--danger); animation: pulse 2s infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.7} }

/* 🖼️ Изображения в постах */
.post-img {
    max-width: 100%; height: auto;
    border-radius: var(--radius);
    margin: 1rem 0;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
}
.post-img:hover { transform: scale(1.02); }

/* 🔍 Поиск */
.search-box { position: relative; margin: 1.5rem 0; }
.search-box input {
    width: 100%; padding: 0.8rem 1rem 0.8rem 2.5rem;
    border: 2px solid var(--border); border-radius: var(--radius);
    background: var(--card); color: var(--text); font-size: 1rem;
    transition: var(--transition);
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-clear { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.2rem; display: none; }
.search-clear.show { display: block; }

/* 📋 Фильтры */
.filters { display: flex; gap: 0.5rem; margin: 1.5rem 0; flex-wrap: wrap; overflow-x: auto; padding-bottom: 0.5rem; }
.filter-btn {
    white-space: nowrap;
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    background: var(--card);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    color: var(--muted);
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(59,130,246,.3); }

/* 💬 Чаты */
.chat-box {
    height: 60vh;
    overflow-y: auto;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--bg);
    scroll-behavior: smooth;
}
.msg {
    padding: 0.8rem 1rem;
    margin: 0.5rem 0;
    border-radius: var(--radius);
    max-width: 85%;
    word-wrap: break-word;
    animation: msgIn 0.3s ease;
    position: relative;
}
@keyframes msgIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.msg.me {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    margin-left: auto;
    text-align: right;
    box-shadow: 0 4px 12px rgba(59,130,246,.3);
}
.msg:not(.me) { background: var(--card); border: 1px solid var(--border); }
.msg-name { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.2rem; opacity: 0.9; }
.msg-time { font-size: 0.75rem; opacity: 0.7; margin-top: 0.2rem; }
.chat-form { display: flex; gap: 0.5rem; }

.file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.4rem;
    padding: 0.3rem 0.6rem;
    background: var(--bg);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    font-size: 0.9rem;
}
.btn-download {
    font-size: 0.8rem;
    margin-top: 0.3rem;
    display: inline-block;
    text-decoration: none;
    opacity: 0.8;
    border-bottom: 1px dashed currentColor;
}

/* 🖼️ Лайтбокс */
#lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.92);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
}
#lightbox-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0,0,0,0.6);
    object-fit: contain;
}

/* 😊 Emoji Picker */
#emoji-picker {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 5px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem;
    box-shadow: var(--shadow);
    z-index: 10;
    width: 100%;
    max-width: 320px;
}
#emoji-picker button {
    font-size: 1.3rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 4px;
    transition: var(--transition);
}
#emoji-picker button:hover { background: var(--bg); }

/* 🗺️ Карта */
#map { height: 85vh; width: 100%; border-radius: var(--radius); margin: 1rem 0; box-shadow: var(--shadow-lg); border: 2px solid var(--border); }

/* 📝 Формы */
input, textarea, select {
    width: 100%;
    padding: 0.8rem;
    margin: 0.5rem 0;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--card);
    color: var(--text);
    transition: var(--transition);
    font-family: inherit;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
textarea { min-height: 120px; resize: vertical; }
.form-group { margin: 1rem 0; }
.form-label { display: block; margin-bottom: 0.4rem; font-weight: 600; color: var(--text); font-size: 0.95rem; }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }

/* 🔔 Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--card);
    color: var(--text);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    z-index: 1000;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s;
    max-width: 400px;
}
@keyframes toastIn { from{transform:translateX(400px);opacity:0} to{transform:translateX(0);opacity:1} }
@keyframes toastOut { to{transform:translateX(400px);opacity:0} }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* ⬆️ Back to Top */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
    border: none;
    z-index: 99;
}
.back-to-top.show { opacity: 1; visibility: visible; }
.back-to-top:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(59,130,246,.4); }

/* 🔐 Auth Box */
.auth-box {
    max-width: 420px;
    margin: 3rem auto;
    background: var(--card);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: slideIn 0.5s ease;
}
@keyframes slideIn { from{opacity:0;transform:translateY(-20px)} to{opacity:1;transform:translateY(0)} }
.auth-box h2 {
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 📊 Admin Panel */
.admin-layout { display: flex; min-height: calc(100vh - 80px); }
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    position: sticky;
    top: 80px;
    height: calc(100vh - 80px);
    overflow-y: auto;
}
.admin-logo { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin-bottom: 2rem; display: flex; align-items: center; gap: 0.5rem; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    margin: 0.3rem 0;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    transition: var(--transition);
}
.nav-item:hover { background: var(--bg); color: var(--primary); }
.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(59,130,246,.3);
}
.nav-divider { height: 1px; background: var(--border); margin: 1rem 0; }

.admin-content { flex: 1; padding: 2rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card {
    background: var(--card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat-icon { font-size: 2rem; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; background: var(--bg); border-radius: 12px; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 0.9rem; }

.admin-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.admin-card h3 { margin: 0 0 1rem; font-size: 1.2rem; display: flex; align-items: center; gap: 0.5rem; }

.table-responsive { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { background: var(--bg); font-weight: 600; color: var(--muted); }
.admin-table tr:hover { background: var(--bg); }

.house-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
    margin: 0.5rem 0;
}

/* 📭 Empty State */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state svg { width: 80px; height: 80px; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { margin: 1rem 0; color: var(--text); }

/* 📱 Responsive */
@media (max-width: 768px) {
    .desktop-nav { display: none !important; }
    .mobile-nav { display: flex !important; justify-content: space-around; }
    main { padding-bottom: 80px; }
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
    .admin-content { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .toast { left: 1rem; right: 1rem; bottom: 6rem; max-width: none; }
    .post-card { padding: 1.2rem; }
    .post-title { font-size: 1.2rem; }
    .widgets { grid-template-columns: 1fr; }
}

/* 🖨️ Print */
@media print {
    header, .mobile-nav, .back-to-top, .reactions, .chat-form { display: none !important; }
    .post-card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}

/* ♿ Accessibility */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}
*:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ⏳ Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--bg) 25%, var(--border) 50%, var(--bg) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: var(--radius);
    height: 20px;
    margin: 0.5rem 0;
}
@keyframes skeleton { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* 🖼️ Image Preview */
.image-preview {
    max-width: 300px;
    margin: 1rem 0;
    border-radius: var(--radius);
    overflow: hidden;
    display: none;
    box-shadow: var(--shadow);
}
.image-preview.show { display: block; }
.image-preview img { width: 100%; height: auto; display: block; }
.image-remove { background: var(--danger); color: #fff; border: none; padding: 0.3rem 0.6rem; cursor: pointer; font-size: 0.85rem; width: 100%; }

/* 🔢 Character Counter */
.char-counter { text-align: right; font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }
.char-counter.warning { color: var(--warning); }
.char-counter.danger { color: var(--danger); }

/* 🏷️ Badge Private House */
.badge-private {
    background: var(--bg);
    color: var(--muted);
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
}

/* 📊 Activity Item */
.activity-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

/* 🔍 Filter Chip */
.filter-chip {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    font-size: 0.9rem;
}
.filter-chip:hover, .filter-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* 📋 Post Item */
.post-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin-bottom: 1rem;
}
.post-item h4 { margin: 0.5rem 0; }
.post-actions { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }

/* 🏠 House Form */
.house-form .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

/* 🔧 Quick Actions */
.quick-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* 🦶 Beautiful Footer */
.site-footer {
    background: linear-gradient(180deg, var(--card) 0%, var(--bg) 100%);
    border-top: 1px solid var(--border);
    padding: 3rem 0 1rem;
    margin-top: 3rem;
    font-size: 0.95rem;
}
.footer-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}
.footer-col h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
}
.footer-desc {
    color: var(--muted);
    line-height: 1.6;
    font-size: 0.9rem;
}
.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}
.footer-links li {
    margin-bottom: 0.6rem;
}
.footer-links a {
    color: var(--muted);
    text-decoration: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.footer-links a:hover {
    color: var(--primary);
    transform: translateX(4px);
}

/* Bottom Bar */
.footer-bottom {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.copyright {
    opacity: 0.8;
}

/* Studio Credit Link */
.developer-credit {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.studio-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    transition: var(--transition);
    background: rgba(59, 130, 246, 0.05);
}
.studio-link:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.studio-link:visited { color: var(--primary); }

/* Mobile Footer */
@media (max-width: 600px) {
    .footer-bottom {
        flex-direction: column;
        text-align: center;
        justify-content: center;
    }
    .footer-grid {
        text-align: center;
    }
    .footer-links a {
        justify-content: center;
    }
}

/* Кнопки фильтра карты */
.filter-btn {
    padding: 0.4rem 0.9rem;
    border: 2px solid var(--border);
    background: var(--card);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--muted);
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { 
    background: var(--primary); 
    color: #fff; 
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

/* 🏘️ Обновлённый логотип */
.logo {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 800;
    font-size: 1.2rem;
    color: #0f172a; /* Тёмный цвет для контраста с эмодзи */
    text-decoration: none;
    transition: var(--transition);
}
.logo:hover {
    transform: translateY(-2px);
    filter: drop-shadow(0 4px 8px rgba(15,23,42,.2));
}
[data-theme="dark"] .logo {
    color: #f1f5f9; /* Светлый цвет в тёмной теме */
}

/* 🏘️ Логотип - цвета для светлой и тёмной темы */
.logo {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text); /* Автоматически подставит нужный цвет из темы */
    text-decoration: none;
    transition: var(--transition);
}
.logo:hover {
    transform: translateY(-2px);
    filter: drop-shadow(0 4px 8px rgba(15,23,42,.2));
}
/* Для тёмной темы - текст становится светлым */
[data-theme="dark"] .logo {
    color: var(--text); /* В тёмной теме var(--text) = #f1f5f9 */
}

/* 📱 Mobile fixes */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 0.4rem 0.2rem;
    z-index: 999;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    justify-content: space-around;
}
.mobile-nav a {
    display: flex; flex-direction: column; align-items: center;
    gap: 0.2rem; font-size: 0.7rem; color: var(--muted);
    text-decoration: none; padding: 0.3rem; transition: var(--transition);
}
.mobile-nav a.active, .mobile-nav a:hover { color: var(--primary); }

@media (max-width: 768px) {
    .desktop-nav { display: none !important; }
    .mobile-nav { display: flex !important; }
    main { padding-bottom: 70px; }
    .toast { bottom: 5rem !important; }
    .back-to-top { bottom: 5rem !important; }
}

/* 💬 Chat popup (VK-style) */
.chat-popup {
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: 320px;
    max-height: 400px;
    background: var(--card);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.chat-popup-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.8rem 1rem; border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; border-radius: var(--radius) var(--radius) 0 0;
}
.chat-popup-body {
    padding: 1rem; overflow-y: auto; max-height: 300px;
}
.chat-popup-msg {
    padding: 0.6rem; background: var(--bg); border-radius: 8px;
    margin-bottom: 0.5rem; font-size: 0.9rem;
}
.chat-popup-footer {
    padding: 0.8rem; border-top: 1px solid var(--border);
    display: flex; gap: 0.5rem;
}
.chat-popup-toggle {
    position: fixed; bottom: 70px; right: 20px;
    background: var(--primary); color: #fff;
    width: 50px; height: 50px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; cursor: pointer; box-shadow: var(--shadow-lg);
    z-index: 999; display: none;
}
.chat-popup-toggle.show { display: flex; }
.chat-popup-toggle.new { animation: bounce 1s infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }

/* 🏠 Main page widgets */
.main-widgets {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 2rem;
}
.widget {
    background: var(--card); padding: 1.2rem; border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border);
    transition: var(--transition);
}
.widget:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.widget h3 { margin: 0 0 0.4rem; font-size: 1rem; color: var(--muted); font-weight: 500; }
.widget-content { font-size: 1.8rem; font-weight: 700; color: var(--primary); }

/* 🗂️ Category tabs */
.category-tabs {
    display: flex; gap: 0.5rem; margin: 1.5rem 0; overflow-x: auto;
    padding-bottom: 0.5rem; scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
    padding: 0.5rem 1rem; border: 2px solid var(--border);
    background: var(--card); border-radius: 20px;
    cursor: pointer; transition: var(--transition);
    font-weight: 500; color: var(--muted); white-space: nowrap;
}
.cat-tab:hover, .cat-tab.active {
    border-color: var(--primary); color: var(--primary);
    background: var(--primary); color: #fff;
}