/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg:        #f0f2f7;
    --surface:   #ffffff;
    --surface2:  #f7f9fc;
    --border:    #e4e9f2;
    --border2:   #d0d8e8;
    --accent:    #2355c3;
    --accent2:   #1a44a8;
    --accent-bg: #eef2fc;
    --text:      #1a2030;
    --text2:     #4a5568;
    --text3:     #8a95a8;
    --success:   #16a34a;
    --success-bg:#f0fdf4;
    --error:     #dc2626;
    --error-bg:  #fef2f2;
    --nav-bg:    #162040;
    --nav-text:  rgba(255,255,255,0.88);
    --radius:    14px;
    --radius-sm: 8px;
    --shadow:    0 2px 12px rgba(30,50,100,0.08);
    --shadow-md: 0 4px 24px rgba(30,50,100,0.12);
    --shadow-lg: 0 8px 40px rgba(30,50,100,0.16);
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --transition: 0.18s ease;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ===== NAV ===== */
nav {
    background: var(--nav-bg);
    height: 62px;
    padding: 0 20px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 1px 0 rgba(255,255,255,0.05), 0 4px 24px rgba(0,0,0,0.25);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

/* Логотип */
.logo {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 9px;
    white-space: nowrap;
}

.logo img {
    height: 32px;
    width: 32px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

/* Центральные ссылки */
.nav-link {
    color: rgba(255,255,255,0.7);
    font-size: 13.5px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-link.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* Кнопка темы */
.theme-toggle {
    background: transparent;
    border: 1.5px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.75);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    outline: none;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.4);
    color: #fff;
    transform: rotate(25deg);
}

/* Кнопки для гостей */
.btn-nav {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.25);
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-nav:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.4);
    transform: none;
    box-shadow: none;
}

.btn-nav-outline {
    background: transparent;
    color: rgba(255,255,255,0.8);
    border: none;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn-nav-outline:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: none;
    box-shadow: none;
}

/* Уведомления */
#notif-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

#notif-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

#notif-btn svg { pointer-events: none; }

#notif-count {
    display: none;
    background: #ef4444;
    color: #fff;
    border-radius: 99px;
    min-width: 17px;
    height: 17px;
    font-size: 10px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 1px;
    right: 1px;
    padding: 0 4px;
    line-height: 1;
    border: 2px solid var(--nav-bg);
    pointer-events: none;
}

/* Пользователь + дропдаун */
.nav-user {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 6px;
    border-radius: 99px;
    cursor: pointer;
    transition: background var(--transition);
    border: 1.5px solid rgba(255,255,255,0.12);
    user-select: none;
}

.nav-user:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.22);
}

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.nav-avatar-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a7aee, #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.nav-username {
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    font-weight: 600;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-chevron {
    color: rgba(255,255,255,0.5);
    transition: transform var(--transition);
    flex-shrink: 0;
}

.nav-user.open .nav-chevron { transform: rotate(180deg); }

/* Дропдаун меню */
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    animation: dropdownIn 0.18s ease;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.user-dropdown.open { display: block; }

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 12px;
}

.dropdown-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.dropdown-avatar-placeholder {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a7aee, #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
}

.dropdown-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
}

.dropdown-role {
    font-size: 12px;
    color: var(--text3);
    margin-top: 2px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text2);
    transition: all var(--transition);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--accent-bg);
    color: var(--accent);
}

.dropdown-item svg { opacity: 0.7; flex-shrink: 0; }

.dropdown-item-danger { color: var(--error); }
.dropdown-item-danger:hover { background: var(--error-bg); color: var(--error); }

/* Бургер */
.burger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 6px;
    border: none;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    flex-shrink: 0;
}

.burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: rgba(255,255,255,0.9);
    border-radius: 2px;
    transition: all 0.2s;
}

/* Мобильное меню */
.mobile-menu {
    display: none;
    position: fixed;
    top: 62px;
    left: 0; right: 0;
    background: var(--nav-bg);
    padding: 12px 16px 20px;
    z-index: 198;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mobile-menu.open { display: block; }

.mobile-menu-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px 16px;
}

.mobile-menu-link {
    display: block;
    padding: 12px 8px;
    color: rgba(255,255,255,0.85);
    font-size: 15px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.mobile-menu-link:hover { background: rgba(255,255,255,0.1); color: #fff; }

.mobile-menu-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 6px 0;
}

/* ===== NOTIFICATIONS ===== */
#notif-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    color: var(--nav-text);
    font-size: 13.5px;
    font-weight: 500;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

#notif-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

#notif-count {
    display: none;
    background: #e74c3c;
    color: #fff;
    border-radius: 99px;
    min-width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 2px;
    right: 4px;
    padding: 0 4px;
    line-height: 1;
    border: 2px solid var(--nav-bg);
}

#notif-panel {
    display: none;
    position: fixed;
    top: 68px;
    right: 12px;
    width: 340px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-height: 500px;
    overflow-y: auto;
}

#notif-panel.notif-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

@keyframes notif-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}
.notif-badge-pulse { animation: notif-pulse 0.4s ease; }

/* ===== CONTAINER ===== */
.container {
    max-width: 880px;
    margin: 28px auto;
    padding: 0 16px;
    animation: fadeIn 0.25s ease;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

/* ===== SEARCH ===== */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.search-bar input {
    flex: 1;
    padding: 11px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.search-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(35,85,195,0.1);
}

.search-bar input::placeholder { color: var(--text3); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: inherit;
    line-height: 1;
}

.btn:hover {
    background: var(--accent2);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(35,85,195,0.3);
}

.btn:active { transform: translateY(0); box-shadow: none; }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent-bg);
    box-shadow: none;
    transform: none;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-danger {
    background: var(--error);
}
.btn-danger:hover { background: #b91c1c; box-shadow: 0 4px 14px rgba(220,38,38,0.3); }

/* ===== ALERTS ===== */
.error {
    background: var(--error-bg);
    color: var(--error);
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13.5px;
    border-left: 3px solid var(--error);
    line-height: 1.5;
}

.success {
    background: var(--success-bg);
    color: var(--success);
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13.5px;
    border-left: 3px solid var(--success);
}

/* ===== ONLINE COUNT ===== */
.online-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text3);
    margin-bottom: 16px;
}

.online-badge::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px #22c55e;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== CATEGORIES ===== */
.categories { display: flex; flex-direction: column; gap: 8px; }

.category-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    text-decoration: none;
    color: var(--text);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    transform: scaleY(0);
    transition: transform var(--transition);
    border-radius: 0 2px 2px 0;
}

.category-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateX(3px);
}

.category-card:hover::before { transform: scaleY(1); }

.category-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}

.category-card p {
    font-size: 13px;
    color: var(--text3);
}

.category-card .count {
    font-size: 12px;
    color: var(--accent);
    background: var(--accent-bg);
    padding: 4px 12px;
    border-radius: 99px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== TOPIC CARDS ===== */
.topic-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text);
    display: block;
    transition: all var(--transition);
}

.topic-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.topic-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.4;
}

.topic-card .meta {
    font-size: 12px;
    color: var(--text3);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.topic-card .meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ===== REPLIES ===== */
.reply {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 10px;
    transition: border-color var(--transition);
    word-break: break-word;
    overflow-wrap: break-word;
}

.reply:hover { border-color: var(--border2); }

.reply .author {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.reply .author-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--accent);
}

.reply .date {
    font-size: 12px;
    color: var(--text3);
}

.reply p {
    font-size: 14px;
    line-height: 1.75;
    color: var(--text2);
}

.reply-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.reply-actions button, .reply-actions a {
    background: none;
    border: none;
    font-size: 12px;
    color: var(--text3);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition);
    font-family: inherit;
    text-decoration: none;
}

.reply-actions button:hover, .reply-actions a:hover {
    background: var(--accent-bg);
    color: var(--accent);
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 7px;
    letter-spacing: 0.1px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 11px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(35,85,195,0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text3); }

.form-group textarea {
    height: 150px;
    resize: vertical;
    line-height: 1.6;
}

/* ===== AUTH ===== */
.auth-container {
    max-width: 420px;
    margin: 60px auto;
    background: var(--surface);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    border: 1.5px solid var(--border);
}

.auth-container h2 {
    margin-bottom: 28px;
    font-size: 22px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.3px;
}

.auth-container input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}

.auth-container input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(35,85,195,0.1);
}

.auth-container button[type="submit"], .auth-container .btn-full {
    width: 100%;
    padding: 13px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.auth-container button[type="submit"]:hover {
    background: var(--accent2);
    box-shadow: 0 4px 14px rgba(35,85,195,0.3);
}

.auth-container p {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text3);
    text-align: center;
}

.auth-container a { color: var(--accent); font-weight: 500; }

/* ===== TABLES (admin) ===== */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    font-size: 14px;
}

table thead tr {
    background: var(--surface2);
    border-bottom: 2px solid var(--border);
}

table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text2);
    vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: var(--surface2); }

/* ===== CARD / WHITE BOX ===== */
.card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    font-size: 13px;
    color: var(--text3);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.breadcrumb a { color: var(--accent); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { color: var(--text3); }

/* ===== REPLY TEXTAREA ===== */
#reply-content {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    outline: none;
    background: var(--surface);
    color: var(--text);
    line-height: 1.6;
    transition: border-color var(--transition), box-shadow var(--transition);
}

#reply-content:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(35,85,195,0.1);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.category-card { animation: fadeIn 0.3s ease both; }
.category-card:nth-child(1) { animation-delay: 0.04s; }
.category-card:nth-child(2) { animation-delay: 0.08s; }
.category-card:nth-child(3) { animation-delay: 0.12s; }
.category-card:nth-child(4) { animation-delay: 0.16s; }
.category-card:nth-child(5) { animation-delay: 0.20s; }
.category-card:nth-child(6) { animation-delay: 0.24s; }

.topic-card { animation: fadeIn 0.3s ease both; }
.topic-card:nth-child(1) { animation-delay: 0.04s; }
.topic-card:nth-child(2) { animation-delay: 0.08s; }
.topic-card:nth-child(3) { animation-delay: 0.12s; }
.topic-card:nth-child(4) { animation-delay: 0.16s; }
.topic-card:nth-child(5) { animation-delay: 0.20s; }

.reply { animation: fadeIn 0.25s ease both; }
.reply:nth-child(1) { animation-delay: 0.04s; }
.reply:nth-child(2) { animation-delay: 0.08s; }
.reply:nth-child(3) { animation-delay: 0.12s; }

/* ===== DARK THEME ===== */
body.dark {
    --bg:        #0c1018;
    --surface:   #141922;
    --surface2:  #1a2130;
    --border:    #252f42;
    --border2:   #2d3a52;
    --accent:    #5b8df6;
    --accent2:   #4a7aee;
    --accent-bg: #1a2540;
    --text:      #e8edf5;
    --text2:     #b0bdd0;
    --text3:     #5a6a80;
    --nav-bg:    #0d1420;
    --error-bg:  #2a1515;
    --success-bg:#132218;
}

body.dark .theme-toggle { border-color: rgba(255,255,255,0.2); }
body.dark table { background: var(--surface); }
body.dark #notif-panel { background: var(--surface); border-color: var(--border); }

/* ===== MOBILE ===== */
@media (max-width: 900px) {
    .nav-center { display: none; }
    nav { grid-template-columns: auto auto; }
}

@media (max-width: 768px) {
    nav { padding: 0 14px; height: 56px; }
    .logo span { font-size: 15px; }
    .logo img { height: 28px; width: 28px; }
    .burger { display: flex; }
    .nav-username { display: none; }
    .nav-chevron { display: none; }
    .user-dropdown { display: none !important; }
    .nav-user { border: none; padding: 4px; gap: 4px; }
    .nav-user:hover { background: rgba(255,255,255,0.12); }

    #notif-panel {
        width: calc(100vw - 16px);
        right: 8px; left: 8px;
        top: 64px;
    }

    .container { padding: 0 12px; margin: 16px auto; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header h1 { font-size: 19px; }
    .category-card { padding: 14px 16px; }
    .category-card h3 { font-size: 14px; }
    .category-card:hover { transform: none; }
    .topic-card { padding: 14px 16px; }
    .topic-card h3 { font-size: 14px; }
    .topic-card:hover { transform: none; }
    .reply { padding: 14px 16px; }
    .auth-container { margin: 24px auto; padding: 24px 20px; }
    .auth-container h2 { font-size: 19px; }
    .btn { padding: 10px 16px; font-size: 13px; }
    table { font-size: 12px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table td, table th { padding: 10px 12px; white-space: nowrap; }
}

@media (max-width: 480px) {
    .search-bar { flex-direction: column; }
    .search-bar .btn { width: 100%; justify-content: center; }
    .page-header .btn { width: 100%; justify-content: center; }
    .category-card { padding: 12px 14px; }
    .reply p { font-size: 13.5px; }
}

/* ===== MISC ===== */
button { -webkit-tap-highlight-color: transparent; }
input, textarea, select { -webkit-tap-highlight-color: transparent; }

/* Inline style dark overrides */
body.dark [style*="background:#fff"],
body.dark [style*="background: #fff"] { background: var(--surface) !important; color: var(--text) !important; }
body.dark [style*="background:#f4f6fb"],
body.dark [style*="background: #f4f6fb"] { background: var(--bg) !important; }
body.dark [style*="color:#888"],
body.dark [style*="color: #888"] { color: var(--text3) !important; }
body.dark [style*="color:#1a3a6b"],
body.dark [style*="color: #1a3a6b"] { color: var(--accent) !important; }
body.dark [style*="background:#f5f7fb"] { background: var(--surface2) !important; }
body.dark [style*="background:#f4f6fb"] { background: var(--bg) !important; }
body.dark [style*="border-color:#e8edf5"] { border-color: var(--border) !important; }
body.dark [style*="color:#2d3748"] { color: var(--text) !important; }
body.dark [style*="background:#e8eef7"] { background: var(--accent-bg) !important; }

body.dark .reply p { color: var(--text2); }
body.dark .reply .author-name { color: var(--accent); }
body.dark .form-group input,
body.dark .form-group textarea,
body.dark .form-group select,
body.dark #reply-content,
body.dark .auth-container input,
body.dark .search-bar input {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
}
body.dark .form-group input:focus,
body.dark .form-group textarea:focus,
body.dark #reply-content:focus,
body.dark .auth-container input:focus,
body.dark .search-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(91,141,246,0.12);
}
body.dark .page-header h1 { color: var(--text); }
body.dark table { background: var(--surface); }
body.dark table thead tr { background: var(--surface2); }
body.dark table td, body.dark table th { color: var(--text2); border-color: var(--border); }
body.dark tbody tr:hover { background: var(--surface2); }

#page-content { position: relative; }


/* ===== VIEW TRANSITIONS ===== */
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slide-from-right {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slide-to-left {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-30px); opacity: 0; }
}

/* ===== VIEW TRANSITIONS ===== */
::view-transition-old(root) {
    animation: 0.15s ease both fade-out-vt;
}
::view-transition-new(root) {
    animation: 0.2s ease both fade-in-vt;
}
@keyframes fade-out-vt {
    to { opacity: 0; }
}
@keyframes fade-in-vt {
    from { opacity: 0; }
}
::view-transition-group(*) {
    animation-duration: 0.3s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
