:root {
    color-scheme: dark;
    --bg: #070b12;
    --panel: rgba(13, 20, 33, .78);
    --panel-strong: rgba(10, 16, 27, .92);
    --line: rgba(148, 163, 184, .14);
    --line-soft: rgba(148, 163, 184, .08);
    --text: #e5edf9;
    --muted: #8fa4bf;
    --accent: #4cc2ff;
    --accent-2: #a855f7;
    --success: #4ade80;
    --danger: #f87171;
    --warning: #ffd166;
    --radius: 14px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: var(--font);
    background-color: var(--bg);
    background-image: var(--page-bg, url('/static/img/47585428.png'));
    background-position: center center;
    background-size: cover;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* Лёгкий затемняющий слой: картинка видна, но интерфейс остаётся читаемым. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(1000px 620px at 12% -8%, rgba(76, 194, 255, .17), transparent 62%),
        radial-gradient(900px 700px at 100% 0%, rgba(168, 85, 247, .12), transparent 58%),
        linear-gradient(180deg, rgba(5, 9, 16, .16), rgba(5, 9, 16, .44));
}

a { color: inherit; }

.main-content { min-height: calc(100vh - 62px); }

::selection { background: rgba(76, 194, 255, .3); }

/* ── Шапка ─────────────────────────────────────────────── */
.header {
    position: fixed;
    top: 8px;
    left: 8px;
    right: 8px;
    height: 50px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(16, 24, 39, .78), rgba(10, 16, 27, .64));
    backdrop-filter: blur(20px) saturate(1.35);
    -webkit-backdrop-filter: blur(20px) saturate(1.35);
    border: 1px solid var(--line);
    border-radius: 13px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
    z-index: 1000;
}

.panel-section { display: flex; align-items: center; gap: 6px; }
.panel-section.center { margin: 0 auto; }

.text-btn {
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 13px;
    border-radius: 9px;
    cursor: pointer;
    transition: background .18s, color .18s, transform .18s;
    color: #c7d4e5;
    font-size: .92rem;
    font-weight: 600;
    position: relative;
    user-select: none;
    white-space: nowrap;
    text-decoration: none;
    border: none;
    background: transparent;
    font-family: inherit;
}

.text-btn:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.text-btn:active { transform: scale(.97); }
.text-btn.active { color: #fff; background: rgba(76, 194, 255, .1); }
.text-btn.active::after {
    content: "";
    position: absolute;
    bottom: 2px;
    left: 14px;
    right: 14px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(76, 194, 255, .55);
}
.app-title { font-weight: 800; letter-spacing: .2px; color: #fff; }
.app-title-link .text-btn { font-size: 1rem; }

.user-menu-container { position: relative; }
.dropdown-menu {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    min-width: 220px;
    background: var(--panel-strong);
    backdrop-filter: blur(20px);
    border: 1px solid var(--line);
    border-radius: 13px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
    padding: 6px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: .18s ease;
    z-index: 1001;
}
.user-menu-container:hover .dropdown-menu,
.user-menu-container.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.menu-item {
    display: block;
    padding: 9px 12px;
    color: #c7d4e5;
    text-decoration: none;
    font-size: .87rem;
    border-radius: 8px;
    transition: .15s;
    white-space: nowrap;
}
.menu-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.menu-divider { height: 1px; background: var(--line-soft); margin: 5px 0; }
.logout-btn { color: #ff8f8f; }

/* ── Уведомления ───────────────────────────────────────── */
.notif-wrap { position: relative; }
.notif-btn { position: relative; width: 38px; padding: 0; }
.notif-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: linear-gradient(135deg, #f87171, #ec4899);
    color: #fff;
    font-size: .63rem;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px rgba(10, 16, 27, .9);
}
.notif-badge.show { display: inline-flex; }
.notif-dropdown {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    width: min(370px, calc(100vw - 24px));
    max-height: 460px;
    overflow: auto;
    background: var(--panel-strong);
    backdrop-filter: blur(20px);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: .18s;
    z-index: 1002;
}
.notif-wrap.open .notif-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 10px; }
.notif-head strong { color: #fff; font-size: .9rem; }
.notif-head button { background: none; border: none; color: var(--accent); font-size: .76rem; cursor: pointer; }
.notif-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    border: 1px solid transparent;
}
.notif-item:hover { background: rgba(255, 255, 255, .05); border-color: var(--line-soft); }
.notif-item.unread { background: rgba(76, 194, 255, .06); }
.notif-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(76, 194, 255, .12); flex: 0 0 auto; }
.notif-body { min-width: 0; flex: 1; }
.notif-title { color: #e5edf9; font-size: .82rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-text { color: var(--muted); font-size: .76rem; line-height: 1.45; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-time { color: #64748b; font-size: .68rem; margin-top: 4px; }
.notif-empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: .84rem; }

/* ── Общие стеклянные панели ───────────────────────────── */
.glass-panel {
    background: var(--panel);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, .28);
}

/* ── Кнопки ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .05);
    color: #dbe6f5;
    font: inherit;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: .18s;
}
.btn:hover { background: rgba(255, 255, 255, .1); color: #fff; transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, #4cc2ff, #3a9bd5); color: #03131f; border-color: transparent; }
.btn-primary:hover { color: #03131f; box-shadow: 0 8px 24px rgba(76, 194, 255, .28); }
.btn-secondary { background: rgba(168, 85, 247, .12); border-color: rgba(168, 85, 247, .28); color: #e9d5ff; }
.btn-danger { background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .3); color: #fecaca; }
.btn-ghost { background: transparent; }

/* ── Формы ─────────────────────────────────────────────── */
input, textarea, select { font-family: inherit; }
.form-control, .dark-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: rgba(4, 9, 17, .55);
    color: var(--text);
    outline: none;
    transition: .18s;
}
.form-control:focus, .dark-input:focus { border-color: rgba(76, 194, 255, .55); box-shadow: 0 0 0 3px rgba(76, 194, 255, .1); }

/* ── Утилиты ───────────────────────────────────────────── */
.muted { color: var(--muted); }
.hidden { display: none !important; }
.page-wrap { max-width: 1180px; margin: 0 auto; padding: 84px 18px 42px; }
.page-title { color: #fff; font-size: clamp(1.5rem, 2.6vw, 2rem); margin: 0 0 8px; letter-spacing: -.02em; }
.page-subtitle { color: var(--muted); margin: 0 0 22px; line-height: 1.6; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

@media (max-width: 980px) {
    .header { height: auto; min-height: 50px; flex-wrap: wrap; padding: 6px 10px; gap: 4px; }
    .panel-section.center { order: 3; width: 100%; overflow-x: auto; justify-content: flex-start; padding: 2px 0; }
    .panel-section.center::-webkit-scrollbar { display: none; }
    .panel-section.center .text-btn { font-size: .84rem; padding: 0 10px; }
    .page-wrap { padding-top: 112px; }
}

@media (max-width: 560px) {
    .text-btn { font-size: .82rem; padding: 0 9px; }
    .app-title-link { display: none; }
}

@media (max-width: 980px) {
    .forum-wrapper, .repo-page, .int-page, .repos-page, .profile-wrapper,
    .soft-page, .games-page, .support-page, .forms-page, .dev-page {
        padding-top: 112px !important;
    }
    .chat-wrapper { margin-top: 112px; height: calc(100vh - 122px); }
    .ai-app { margin-top: 112px; height: calc(100vh - 122px); }
}

/* Единая оболочка для страниц входа, ошибок и подтверждений */
.unified-auth-page {
    min-height: calc(100vh - 74px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 96px 16px 48px;
}

.unified-auth-page > * {
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
}

.unified-auth-page .auth-container,
.unified-auth-page .logout-container,
.unified-auth-page .verify-container,
.unified-auth-page .unavailable-container,
.unified-auth-page .confirmation-card {
    background: rgba(10, 16, 27, .78) !important;
    border-color: rgba(148, 163, 184, .16) !important;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .38) !important;
}

@media (max-width: 980px) {
    .unified-auth-page { padding-top: 124px; padding-bottom: 30px; }
}

.mod-badge { display:inline-flex; align-items:center; margin-left:8px; padding:2px 8px; border-radius:999px; font-size:.64rem; font-weight:700; vertical-align:middle; letter-spacing:.02em; }
.mod-badge.approved { color:#86efac; background:rgba(74,222,128,.12); border:1px solid rgba(74,222,128,.25); }
.mod-badge.pending { color:#fde68a; background:rgba(251,191,36,.12); border:1px solid rgba(251,191,36,.25); }
.mod-badge.rejected { color:#fca5a5; background:rgba(248,113,113,.12); border:1px solid rgba(248,113,113,.25); }

/* ── Группированное меню пользователя ─────────────────────── */
.dropdown-menu { min-width: 270px; max-height: min(78vh, 640px); overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 8px; }
.menu-item .svg-icon { width: 16px; height: 16px; flex: 0 0 auto; opacity: .9; }
.menu-group { display: block; }
.menu-summary { cursor: pointer; list-style: none; color: #dbe4f3; font-weight: 600; }
.menu-summary::-webkit-details-marker { display: none; }
.menu-summary::after { content: '›'; margin-left: auto; color: #64748b; font-size: 1rem; transition: transform .15s; }
.menu-group[open] > .menu-summary::after { transform: rotate(90deg); }
.menu-group[open] > .menu-summary { color: #fff; background: rgba(255,255,255,.05); }
.menu-group .menu-item.sub { padding-left: 34px; font-size: .82rem; color: #aebdd0; }
.menu-group .menu-item.sub:hover { color: #fff; }
.menu-group .menu-item.sub .svg-icon { width: 14px; height: 14px; opacity: .75; }
.menu-group + .menu-group { border-top: 1px solid rgba(148,163,184,.07); margin-top: 2px; padding-top: 2px; }

/* Иерархия групп в меню пользователя: отступы и направляющие линии */
.dropdown-menu { padding: 8px; }
.menu-group { border-radius: 9px; }
.menu-group[open] { background: rgba(255,255,255,.018); margin: 2px 0; }
.menu-group[open] > .menu-summary { border-left: 2px solid rgba(167,139,250,.55); border-radius: 6px 6px 0 0; }
.menu-group .menu-item.sub { margin-left: 10px; padding-left: 23px; position: relative; font-weight: 400; }
.menu-group .menu-item.sub::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: rgba(167,139,250,.26); }
.menu-group .menu-item.sub::after { content: ''; position: absolute; left: 0; top: 50%; width: 10px; height: 1px; background: rgba(167,139,250,.26); }
.menu-group .menu-item.sub:last-child::before { bottom: 50%; }
.menu-summary::after { content: '▸'; font-size: .78rem; }
.menu-group[open] > .menu-summary::after { content: '▾'; transform: none; }

/* Нативные выпадающие списки — тёмная тема вместо белых option */
select { color-scheme: dark; }
select option, select optgroup, datalist option {
  background-color: #0b1220;
  color: #e5edf9;
}
select option:checked { background-color: #1e293b; color: #fff; }
