:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #111827;
    --muted: #667085;
    --line: #d8dee8;
    --accent: #0f6bcb;
    --accent-2: #12805c;
    --danger: #b42318;
    --shadow: 0 8px 18px rgba(17, 24, 39, .07);
    --input-bg: #ffffff;
    --soft: #eef4ff;
    --panel-2: #f9fbff;
    --accent-soft: #dbeafe;
}

body[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0e1117;
    --panel: #151a23;
    --text: #eef2f7;
    --muted: #a4adbb;
    --line: #293241;
    --accent: #5aa2ff;
    --accent-2: #45c38a;
    --danger: #ff7b72;
    --shadow: 0 8px 18px rgba(0, 0, 0, .22);
    --input-bg: #10151d;
    --soft: #1c2a3d;
    --panel-2: #111722;
    --accent-soft: #17375f;
}
body[data-theme="dark"] .sidebar-filter-select select option {
    background: #151a23;
    color: #eef2f7;
}

* {
    box-sizing: border-box;
}

/* html gets the solid base colour so it always fills the full viewport */
html {
    background-color: var(--bg);
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 28rem),
        radial-gradient(circle at 95% 12%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 24rem);
    background-color: var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-rendering: optimizeLegibility;
}

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

a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 38%, transparent);
    outline-offset: 2px;
}

button,
input,
textarea,
select {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px clamp(16px, 5vw, 56px);
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .04);
}

.brand {
    color: var(--text);
    font-weight: 800;
    font-size: 20px;
    letter-spacing: .2px;
}

.brand::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 9px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 13%, transparent);
}

.nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.nav form {
    margin: 0;
}

.nav-tools {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px;
    background: var(--soft);
    border-radius: 8px;
}

.nav-tools a {
    border-radius: 6px;
    padding: 5px 8px;
    color: var(--text);
    font-size: 13px;
}

.nav-tools a.active,
.nav-tools a:hover {
    background: var(--panel);
    color: var(--accent);
    text-decoration: none;
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto 60px;
    padding-top: calc(56px + 16px);
}

.forum-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 22px;
    min-height: 190px;
    padding: clamp(26px, 5vw, 46px);
    position: relative;
    overflow: hidden;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(15, 107, 203, .96), rgba(18, 128, 92, .96)),
        radial-gradient(circle at 20% 0%, rgba(255, 255, 255, .22), transparent 30%);
    border-radius: 14px;
    box-shadow: 0 18px 44px rgba(15, 107, 203, .18);
}

.forum-hero::after {
    content: "";
    position: absolute;
    inset: auto -8% -45% 48%;
    height: 220px;
    background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 62%);
    pointer-events: none;
}

.forum-hero > * {
    position: relative;
    z-index: 1;
}

.forum-hero h1 {
    margin: 0 0 8px;
    font-size: clamp(34px, 5vw, 60px);
    line-height: 1;
}

.forum-hero p {
    max-width: 680px;
    margin: 0;
    color: rgba(255, 255, 255, .88);
    font-size: 18px;
}

.toolbar,
.dashboard-head,
.section-title,
.product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.toolbar {
    padding: 16px;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.search {
    display: flex;
    gap: 10px;
    flex: 1;
}

.search input[type="search"] {
    min-width: min(360px, 100%);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 13px;
    background: var(--input-bg);
    color: var(--text);
}

input:focus,
textarea:focus,
select:focus {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

textarea {
    resize: vertical;
}

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 10px;
    padding: 0 16px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover {
    color: #fff;
    text-decoration: none;
    filter: brightness(.96);
}

.button:active,
.link-button:active {
    transform: translateY(1px);
}

.button.secondary {
    background: var(--soft);
    color: var(--accent);
}

.button.small {
    min-height: 34px;
    padding: 0 12px;
    font-size: 14px;
}

.link-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
}

.danger {
    color: var(--danger);
}

.catalog-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
}

.filters,
.panel,
.form-shell,
.download-box,
.content,
.report-box,
.review,
.message,
.table-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.admin-section {
    margin-bottom: 24px;
}

.filters {
    display: grid;
    gap: 6px;
    padding: 12px;
    position: sticky;
    top: 82px;
}

.filters a {
    border-radius: 10px;
    padding: 11px 12px;
    color: var(--text);
}

.filters a.active,
.filters a:hover {
    background: var(--soft);
    color: var(--accent);
    text-decoration: none;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.product-card {
    position: relative;
    display: grid;
    gap: 12px;
    min-height: 250px;
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    contain: layout paint;
    transition: border-color .14s ease, transform .14s ease;
}

.product-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    border-radius: 14px 0 0 14px;
    background: linear-gradient(var(--accent), var(--accent-2));
    opacity: .7;
}

.product-card:hover {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
    transform: translateY(-1px);
}

.card-open {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: 14px;
}

.product-card h2,
.product-card .tags,
.product-card .product-meta,
.product-card p,
.product-card .card-preview {
    position: relative;
    z-index: 2;
    pointer-events: none;
}

.product-card h2 a {
    pointer-events: auto;
}

.above-card-link {
    position: relative;
    z-index: 3;
}

.card-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--soft);
}

.product-card h2,
.panel h2,
.table-section h2,
.reviews h2,
.messages h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.25;
}

.product-card h2 a {
    color: var(--text);
}

.product-card p,
.panel p,
.message p,
.review p {
    margin: 0;
}

.product-meta,
.product-footer,
.message span,
.muted {
    color: var(--muted);
    font-size: 14px;
}

.product-meta,
.product-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.product-footer {
    align-self: end;
    align-items: center;
}

.product-footer strong,
.download-box strong {
    color: var(--text);
    font-size: 18px;
    overflow-wrap: anywhere;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tags span {
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--soft);
    color: var(--text);
    font-size: 13px;
}

.pagination {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.pagination a {
    display: grid;
    place-items: center;
    min-width: 36px;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.pagination a.active {
    background: var(--accent);
    color: #fff;
}

.form-shell {
    width: min(520px, 100%);
    margin: 0 auto;
    padding: 26px;
}

.form-shell.wide {
    width: min(760px, 100%);
}

.form,
.columns,
.messages,
.reviews,
.product-page {
    display: grid;
    gap: 16px;
}

.profile-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.profile-form h2,
.profile-form label:has(textarea),
.profile-form button {
    grid-column: 1 / -1;
}

.form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
}

.columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 24px;
}

.columns.single {
    grid-template-columns: 1fr;
}

.panel,
.table-section {
    padding: 20px;
}

.download-box {
    display: grid;
    gap: 10px;
    justify-items: end;
    padding: 20px;
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
}

.product-header {
    align-items: stretch;
}

.product-header h1,
.dashboard-head h1,
.form-shell h1,
.profile h1,
.empty h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.05;
}

.user-summary,
.author-line {
    display: flex;
    align-items: center;
    gap: 12px;
}

.author-line {
    color: var(--text);
}

.author-line:hover {
    text-decoration: none;
}

.author-line small {
    color: var(--muted);
}

.avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 50%;
    object-fit: cover;
    background: var(--soft);
}

.avatar.large {
    width: 92px;
    height: 92px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stats-grid.expanded {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-grid div {
    display: grid;
    gap: 6px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stats-grid div:nth-child(3n + 1) {
    border-top: 3px solid var(--accent);
}

.stats-grid div:nth-child(3n + 2) {
    border-top: 3px solid var(--accent-2);
}

.stats-grid div:nth-child(3n + 3) {
    border-top: 3px solid color-mix(in srgb, var(--danger) 70%, var(--accent));
}

.stats-grid span {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.stats-grid strong {
    font-size: 28px;
}

.content {
    padding: 24px;
    white-space: normal;
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
}

.screenshots {
    display: grid;
    gap: 14px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.screenshots h2 {
    margin: 0;
}

.screenshot-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.screenshot-grid a {
    display: block;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
}

.screenshot-grid img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.report-box {
    padding: 14px 18px;
}

.report-box summary {
    cursor: pointer;
    color: var(--danger);
    font-weight: 700;
}

.inline {
    margin-top: 14px;
}

.comment-form,
.review-form,
.message-form {
    grid-template-columns: 100px 1fr auto;
    align-items: start;
}

.message-form {
    grid-template-columns: 1fr auto;
}

.review,
.message {
    display: grid;
    gap: 6px;
    padding: 16px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
}

tbody tr:hover {
    background: color-mix(in srgb, var(--soft) 58%, transparent);
}

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.row-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.admin-filter {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 150px auto;
    gap: 8px;
    align-items: center;
}

.admin-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 18px;
    padding: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.admin-tabs a {
    border-radius: 9px;
    padding: 9px 12px;
    color: var(--text);
}

.admin-tabs a:hover {
    background: var(--soft);
    color: var(--accent);
    text-decoration: none;
}

.admin-actions {
    display: grid;
    gap: 8px;
    min-width: 220px;
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.profile {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 26px;
}

.profile img {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--line);
}

.empty {
    padding: 34px;
    text-align: center;
}

.flash {
    margin-bottom: 14px;
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--soft);
    border: 1px solid var(--line);
}

.flash.success {
    background: color-mix(in srgb, var(--accent-2) 16%, var(--panel));
    border-color: color-mix(in srgb, var(--accent-2) 36%, var(--line));
}

.flash.error {
    background: color-mix(in srgb, var(--danger) 14%, var(--panel));
    border-color: color-mix(in srgb, var(--danger) 36%, var(--line));
}

@media (max-width: 860px) {
    .toolbar,
    .dashboard-head,
    .section-title,
    .product-header {
        align-items: stretch;
        flex-direction: column;
    }

    .catalog-layout,
    .columns,
    .product-grid {
        grid-template-columns: 1fr;
    }

    .filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        position: static;
    }

    .search,
    .comment-form,
    .review-form,
    .message-form {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .admin-filter {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .profile-form {
        grid-template-columns: 1fr;
    }

    .download-box {
        justify-items: start;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .screenshot-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid.expanded {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .columns.single {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 540px) {
    .page {
        width: min(100% - 20px, 1180px);
        margin-top: 14px;
    }

    .nav {
        gap: 10px;
        width: 100%;
        justify-content: flex-start;
    }

    .topbar {
        position: static;
    }

    .brand {
        width: 100%;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .product-card,
    .panel,
    .table-section,
    .form-shell,
    .content {
        padding: 14px;
    }

    .forum-hero {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .screenshot-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid.expanded {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding: 10px 8px;
    }

    .author-line,
    .user-summary,
    .profile {
        align-items: flex-start;
    }
}

/* Reactions */
.reaction-banner {
    background: var(--bg-alt, #f5f5f5);
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    padding: .5rem .75rem;
    font-size: .9rem;
    margin: .5rem 0;
}
.reaction-row {
    margin-top: .5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.reaction-done {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
}

/* ── Topbar row1 (brand + tools) ─────────────────────────── */
.topbar-row1 {
    display: contents; /* on desktop: items flow into flex parent naturally */
}

/* On desktop the nav-tools was inside .nav, now it's in row1.
   Keep same look — no change needed for desktop since display:contents
   makes children participate in topbar's flex context. */

/* ── Nav avatar ──────────────────────────────────────────── */
.nav-avatar-link {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
}

.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--line);
    background: var(--soft);
    transition: border-color .2s;
}

.nav-avatar-link:hover .nav-avatar {
    border-color: var(--accent);
}

/* ── Mobile nav: topbar-row1 becomes a real flex row ─────── */
@media (max-width: 540px) {
    .topbar-row1 {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE ADAPTIVE — все правки только через media queries,
   десктопный дизайн не затронут
   ═══════════════════════════════════════════════════════════ */

/* ── Prevent horizontal overflow globally ────────────────── */
html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    min-width: 0;
}

img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* ── Tablet 860px ────────────────────────────────────────── */
@media (max-width: 860px) {

    /* Topbar: brand left, nav tools right, then nav below */
    .topbar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px 16px;
    }

    .brand {
        flex: 1 1 auto;
    }

    /* Hero: stack vertically */
    .forum-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        min-height: unset;
    }

    .hero-action {
        align-self: flex-start;
    }

    /* Toolbar: stack search + button */
    .toolbar {
        flex-direction: column;
        gap: 10px;
    }

    .search {
        flex-wrap: wrap;
    }

    .search input[type="search"] {
        flex: 1 1 100%;
        min-width: 0;
    }

    .search select {
        flex: 1 1 calc(50% - 5px);
        min-width: 0;
    }

    /* Product grid: 2 columns on tablet */
    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Stats: 3 cols */
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stats-grid.expanded {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ── Mobile 540px ─────────────────────────────────────────── */
@media (max-width: 540px) {

    /* ─ Layout ─ */
    .page {
        width: calc(100% - 24px);
        margin: 12px auto 40px;
    }

    /* ─ Topbar: hamburger-style stacking ─ */
    /* Устаревший блок от старого дизайна топбара. flex-direction:column
       здесь конфликтовал с новым топбаром (см. .topbar на строке ~1616)
       и уводил .topbar-right (поиск/тема/аватар) за пределы экрана —
       из-за этого кнопка смены темы "пропадала" на телефонах. */

    .topbar-row1 {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }

    .brand {
        font-size: 18px;
    }

    .nav {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 12px;
        padding-top: 10px;
        width: 100%;
        border-top: 1px solid var(--line);
        margin-top: 10px;
        align-items: center;
    }

    .nav > a,
    .nav > form > button {
        font-size: 14px;
        padding: 4px 0;
    }

    .nav .button.small {
        font-size: 13px;
        min-height: 30px;
        padding: 0 10px;
    }

    .nav-tools {
        margin-left: auto;
        font-size: 12px;
    }

    .nav-tools a {
        font-size: 12px;
        padding: 4px 7px;
    }

    .nav-avatar {
        width: 28px;
        height: 28px;
    }

    /* ─ Hero ─ */
    .forum-hero {
        padding: 18px 16px;
        border-radius: 10px;
        gap: 14px;
        flex-direction: column;
        align-items: flex-start;
    }

    .forum-hero h1 {
        font-size: clamp(26px, 8vw, 40px);
    }

    .forum-hero p {
        font-size: 14px;
        line-height: 1.5;
    }

    .hero-action {
        width: 100%;
        justify-content: center;
    }

    /* ─ Toolbar & Search ─ */
    .toolbar {
        padding: 12px;
        border-radius: 10px;
        flex-direction: column;
        gap: 8px;
    }

    .search {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .search input[type="search"] {
        grid-column: 1 / -1;
        min-width: 0;
    }

    .search > .button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .toolbar > .button.secondary {
        width: 100%;
        justify-content: center;
    }

    /* ─ Catalog layout: stack ─ */
    .catalog-layout {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .filters {
        position: static;
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
        padding: 10px;
        border-radius: 10px;
    }

    .filters a {
        padding: 8px 10px;
        font-size: 13px;
        border-radius: 8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ─ Product grid: 1 column ─ */
    .product-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .product-card {
        padding: 14px;
        border-radius: 12px;
        min-height: unset;
        gap: 10px;
    }

    .product-card h2 {
        font-size: 16px;
    }

    .product-card p {
        font-size: 14px;
    }

    .product-meta,
    .product-footer {
        font-size: 13px;
        flex-wrap: wrap;
        gap: 6px;
    }

    .card-preview {
        border-radius: 8px;
    }

    /* ─ Panels, forms, tables ─ */
    .panel,
    .table-section,
    .form-shell,
    .content,
    .download-box,
    .report-box,
    .screenshots {
        padding: 14px;
        border-radius: 10px;
    }

    .form-shell {
        width: 100%;
        margin: 0;
    }

    .form-shell h1 {
        font-size: 22px;
    }

    input,
    textarea,
    select {
        padding: 11px 12px;
        font-size: 16px; /* prevents iOS zoom on focus */
        border-radius: 8px;
    }

    .button,
    button.button {
        min-height: 44px; /* touch target */
        font-size: 15px;
    }

    /* ─ Dashboard head ─ */
    .dashboard-head {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .dashboard-head .button {
        width: 100%;
        justify-content: center;
    }

    .user-summary {
        align-items: center;
        gap: 14px;
    }

    .user-summary h1 {
        font-size: 20px;
    }

    .user-summary p {
        font-size: 13px;
        word-break: break-all;
    }

    .avatar.large {
        width: 64px;
        height: 64px;
    }

    /* ─ Profile ─ */
    .profile {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 18px;
    }

    .profile h1 {
        font-size: 20px;
    }

    .profile-form {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    /* ─ Stats grid ─ */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 16px;
    }

    .stats-grid.expanded {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid div {
        padding: 12px;
    }

    .stats-grid strong {
        font-size: 20px;
    }

    .stats-grid span {
        font-size: 11px;
    }

    /* ─ Columns ─ */
    .columns {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }

    /* ─ Admin ─ */
    .admin-tabs {
        padding: 6px;
        gap: 4px;
        border-radius: 10px;
    }

    .admin-tabs a {
        padding: 8px 10px;
        font-size: 13px;
        flex: 1 1 auto;
        text-align: center;
    }

    .admin-filter {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .admin-actions {
        min-width: unset;
        width: 100%;
    }

    /* ─ Tables (always wrap) ─ */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    table {
        min-width: 560px;
    }

    th, td {
        padding: 10px 8px;
        font-size: 13px;
    }

    /* ─ Comments & messages ─ */
    .comment-form,
    .review-form {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .message-form {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .message-form .button,
    .comment-form .button,
    .review-form .button {
        width: 100%;
    }

    .review,
    .message {
        padding: 12px;
        border-radius: 10px;
    }

    /* ─ Screenshots ─ */
    .screenshot-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* ─ Product page ─ */
    .product-header {
        flex-direction: column;
        gap: 12px;
    }

    .product-header h1 {
        font-size: 20px;
    }

    /* ─ Download box ─ */
    .download-box {
        justify-items: stretch;
    }

    .download-box .button {
        width: 100%;
        justify-content: center;
    }

    .download-box strong {
        font-size: 15px;
        word-break: break-all;
    }

    /* ─ Section title ─ */
    .section-title {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        margin-bottom: 12px;
    }

    .section-title h2 {
        font-size: 16px;
    }

    /* ─ Tags ─ */
    .tags span {
        font-size: 12px;
        padding: 4px 8px;
    }

    /* ─ Pagination ─ */
    .pagination {
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 16px;
    }

    .pagination a {
        min-width: 38px;
        min-height: 38px;
        font-size: 14px;
    }

    /* ─ Flash messages ─ */
    .flash {
        padding: 10px 12px;
        font-size: 14px;
        border-radius: 8px;
    }

    /* ─ Reaction ─ */
    .reaction-banner {
        font-size: 14px;
    }

    .reaction-row {
        flex-wrap: wrap;
    }

    .reaction-row .button {
        flex: 1 1 auto;
        justify-content: center;
    }

    /* ─ Error pages ─ */
    .empty {
        padding: 24px 16px;
    }

    .empty h1 {
        font-size: 20px;
    }

    /* ─ Author line ─ */
    .author-line,
    .user-summary {
        align-items: center;
    }

    /* ─ Actions row ─ */
    .actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .actions .button {
        flex: 1 1 auto;
        justify-content: center;
        min-width: 120px;
    }

    /* ─ Row form (inline selects in tables) ─ */
    .row-form {
        flex-wrap: wrap;
        gap: 6px;
    }

    .row-form select,
    .row-form input {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* ─ Verify pending page ─ */
    #verify-waiting,
    #verify-status {
        font-size: 14px;
    }
}

/* ── Very small screens 360px ────────────────────────────── */
@media (max-width: 380px) {
    .filters {
        grid-template-columns: 1fr;
    }

    .stats-grid,
    .stats-grid.expanded {
        grid-template-columns: 1fr;
    }

    .screenshot-grid {
        grid-template-columns: 1fr;
    }

    .search {
        grid-template-columns: 1fr;
    }

    .search > .button {
        grid-column: unset;
    }

    .nav-tools a {
        padding: 3px 5px;
        font-size: 11px;
    }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE-FIRST REDESIGN — v2
   ═══════════════════════════════════════════════════════════ */

/* ── НОВЫЙ ТОПБАР ───────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════
   ТОПБАР (мобильный, фиксированный)
   ═══════════════════════════════════════════════════════════ */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    height: 56px;
    padding: 0 8px 0 4px;
    background: color-mix(in srgb, var(--panel) 97%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
}

/* Логотип по центру */
.topbar .brand {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    text-align: center;
    font-size: 17px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    pointer-events: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

/* Иконка-кнопка (бургер, поиск, профиль) */
.topbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .15s;
}
.topbar-btn:hover { background: var(--soft); text-decoration: none; color: var(--text); }

/* Бургер */
.burger {
    flex-direction: column;
    gap: 5px;
    padding: 12px;
}
.burger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}

/* Аватар */
.topbar-avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    text-decoration: none;
    margin-left: 2px;
}
.topbar-avatar {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
.topbar-avatar-fallback {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Десктопная навигация — скрыта по умолчанию, показывается на ≥860px */
.topbar-desktop-nav {
    display: none;
    align-items: center;
    gap: 4px;
    margin-left: 12px;
}
.topbar-desktop-nav a {
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}
.topbar-desktop-nav a:hover { background: var(--soft); color: var(--accent); }
.topbar-desktop-nav .button { color: #fff; }
.topbar-desktop-nav .button:hover { color: #fff; background: var(--accent); filter: brightness(.95); }

/* ═══════════════════════════════════════════════════════════
   БОКОВОЕ МЕНЮ (drawer)
   ═══════════════════════════════════════════════════════════ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.52);
    z-index: 200;
    opacity: 0;
    transition: opacity .25s;
}
.sidebar-overlay.open {
    display: block;
    opacity: 1;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 88vw);
    background: var(--panel);
    border-right: 1px solid var(--line);
    z-index: 300;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar.open { transform: translateX(0); }

/* Шапка сайдбара: лого + крестик */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: var(--panel);
    z-index: 1;
    min-height: 56px;
}
.sidebar-close {
    width: 36px; height: 36px;
    border: none; background: var(--soft);
    border-radius: 10px; cursor: pointer;
    color: var(--text); font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
}
.sidebar-close:hover { background: var(--line); }

/* Поиск внутри сайдбара */
.sidebar-search {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 56px;
    background: var(--panel);
    z-index: 1;
}
.sidebar-search-input {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--input-bg);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 9px 14px;
}
.sidebar-search-input svg {
    flex-shrink: 0;
    color: var(--muted);
}
.sidebar-search-input input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    color: var(--text);
    font-size: 15px;
}
.sidebar-search-input input::placeholder { color: var(--muted); }

/* Фильтры в сайдбаре */
.sidebar-filters {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-filter-select {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--input-bg);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 9px 14px;
    cursor: pointer;
}
.sidebar-filter-select svg { flex-shrink: 0; color: var(--muted); }
.sidebar-filter-select select {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    appearance: none;
    color-scheme: dark;
}
.sidebar-filter-select select option {
    background: #1e2433;
    color: #e2e8f0;
}
.sidebar-filter-chevron { display: none; }
.sidebar-filter-apply {
    width: 100%;
    margin-top: 4px;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s;
}
.sidebar-filter-apply:hover { filter: brightness(.92); }

/* Навигация */
.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}
.sidebar-section-title {
    padding: 14px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .9px;
    text-transform: uppercase;
    color: var(--muted);
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s;
}
.sidebar-link:hover, .sidebar-link.active {
    background: var(--soft);
    color: var(--accent);
    text-decoration: none;
}
.sidebar-link svg { flex-shrink: 0; opacity: .75; }

/* Категории */
.sidebar-cat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text);
    font-size: 14px;
    text-decoration: none;
    transition: background .15s;
    border-radius: 0;
}
.sidebar-cat:hover, .sidebar-cat.active {
    background: var(--soft);
    color: var(--accent);
    text-decoration: none;
}

/* Подсветка активной категории — полоска слева */
.sidebar-cat.active {
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

/* Футер сайдбара */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.sidebar-lang {
    display: flex;
    gap: 4px;
    background: var(--soft);
    border-radius: 8px;
    padding: 3px;
}
.sidebar-lang a {
    padding: 4px 11px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}
.sidebar-lang a.active, .sidebar-lang a:hover {
    background: var(--panel);
    color: var(--accent);
}
.sidebar-logout {
    border: none;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-size: 14px;
    padding: 6px 0;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   НИЖНЯЯ НАВИГАЦИЯ
   ═══════════════════════════════════════════════════════════ */
.bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--panel) 97%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    color: var(--muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    transition: color .15s;
    min-height: 54px;
    position: relative;
}
.bottom-nav-item:hover, .bottom-nav-item.active {
    color: var(--accent);
    text-decoration: none;
}
/* Кнопка «Загрузить» по центру — чуть выделяется */
.bottom-nav-item.upload-btn {
    color: var(--accent);
}
.bottom-nav-item.upload-btn svg {
    background: var(--accent);
    color: #fff;
    border-radius: 14px;
    padding: 7px;
    width: 36px;
    height: 36px;
    transition: filter .15s;
}
.bottom-nav-item.upload-btn:hover svg { filter: brightness(.9); }
.bottom-nav-item svg { flex-shrink: 0; }

/* Отступ снизу для основного контента на мобиле */
.page { padding-bottom: 80px; }

/* ── КОМПАКТНЫЙ ПОИСК ───────────────────────────────────── */
.search-compact-wrap {
    margin-bottom: 20px;
}
.search-bar {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px;
    box-shadow: var(--shadow);
}
.search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 150px;
}
.search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.search-input-wrap input {
    padding-left: 36px;
    height: 40px;
    border-radius: 10px;
    font-size: 14px;
}
.search-filters-desktop {
    display: flex;
    gap: 6px;
}
.search-filters-desktop select {
    height: 40px;
    padding: 0 10px;
    font-size: 13px;
    border-radius: 10px;
    width: auto;
    min-width: 100px;
}
.search-submit {
    height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    gap: 6px;
}
.filter-btn-mobile {
    display: none;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    gap: 6px;
    font-size: 13px;
}

/* ── BOTTOM SHEET (ФИЛЬТРЫ) ─────────────────────────────── */
.sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 400;
    opacity: 0;
    transition: opacity .2s;
}
.sheet-overlay.open { display: block; opacity: 1; }

.bottom-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 500;
    background: var(--panel);
    border-radius: 20px 20px 0 0;
    padding: 0 16px calc(env(safe-area-inset-bottom) + 16px);
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    max-height: 80vh;
    overflow-y: auto;
}
.bottom-sheet.open { transform: translateY(0); }
.sheet-handle {
    width: 40px; height: 4px;
    background: var(--line);
    border-radius: 2px;
    margin: 12px auto 4px;
}
.sheet-title {
    font-size: 16px;
    font-weight: 700;
    margin: 12px 0;
}
.sheet-body { margin-bottom: 16px; }
.sheet-body select { height: 44px; }
.sheet-actions { display: flex; gap: 8px; }
.sheet-actions .button { flex: 1; }

/* ── АВАТАР (заглушка) ──────────────────────────────────── */
.avatar-wrap {
    position: relative;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.avatar-wrap.large { width: 72px; height: 72px; }
.avatar-wrap.medium { width: 56px; height: 56px; }
.avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.avatar-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-weight: 700;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}
.avatar-wrap.medium .avatar-fallback { font-size: 18px; }

.avatar-upload-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
}
.avatar-upload-label { display: block; }

/* ── ГЛАВНАЯ СТРАНИЦА — СЕКЦИИ ───────────────────────────── */
.home-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.home-stat-item {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    box-shadow: var(--shadow);
}
.home-stat-number {
    font-size: clamp(20px, 4vw, 32px);
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}
.home-stat-label {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.home-section {
    margin-bottom: 32px;
}
.home-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.home-section-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}
.home-section-title svg { color: var(--accent); }
.home-section-more {
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.home-section-more:hover { text-decoration: underline; }

/* Горячий список (самые скачиваемые) */
.hot-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.hot-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: var(--text);
    transition: background .15s;
}
.hot-item:last-child { border-bottom: none; }
.hot-item:hover { background: var(--soft); text-decoration: none; }
.hot-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--soft);
    color: var(--accent);
    font-weight: 800;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.hot-item:nth-child(1) .hot-rank { background: #fef3c7; color: #d97706; }
.hot-item:nth-child(2) .hot-rank { background: #f1f5f9; color: #64748b; }
.hot-item:nth-child(3) .hot-rank { background: #fef0e7; color: #ea580c; }
.hot-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.hot-meta { font-size: 12px; color: var(--muted); }

/* Активность / комментарии */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}
.activity-item:last-child { border-bottom: none; }
.activity-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--soft);
    display: flex;
    align-items: center;
    justify-content: center;
}
.activity-avatar img { width: 100%; height: 100%; object-fit: cover; }
.activity-avatar .avatar-fallback {
    font-size: 14px;
    width: 36px;
    height: 36px;
}
.activity-meta { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.activity-meta a { color: var(--accent); }
.activity-text { font-size: 14px; color: var(--text); line-height: 1.4; }

/* Результаты поиска (при активном поиске) */
.catalog-results { margin-top: 0; }

/* ── ДВУХКОЛОНОЧНЫЙ БЛОК ─────────────────────────────────── */
.home-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    margin-bottom: 0;
}
.home-two-col .home-section {
    margin-bottom: 0;
}

/* ── ЛЕНТА «НЕДАВНО ОПУБЛИКОВАННЫЕ» ─────────────────────── */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: var(--text);
    transition: background .15s;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: var(--soft); text-decoration: none; }
.recent-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--soft);
}
.recent-thumb-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border: 1px solid var(--line);
}
.recent-info {
    flex: 1;
    min-width: 0;
}
.recent-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.recent-meta {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.recent-date {
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
    margin-left: 4px;
}

/* ═══════════════════════════════════════════════════════════
   ДЕСКТОП (≥860px)
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 860px) {
    /* Нижнюю навигацию скрыть на десктопе */
    .bottom-nav { display: none; }

    /* Убрать отступ снизу на десктопе */
    .page { padding-bottom: 60px; }

    /* Показать топбар навигацию на десктопе */
    .topbar-desktop-nav { display: flex; }

    /* Скрыть мобильные кнопки фильтров */
    .filter-btn-mobile { display: none !important; }

    /* Топбар: больше padding */
    .topbar { padding: 0 clamp(16px, 5vw, 56px); }

    /* Боковое меню — на десктопе не нужно как drawer, но кнопку бургер показываем для категорий */
    .sidebar {
        width: 300px;
    }

    /* Поиск: выровнять всё в ряд */
    .search-row { flex-wrap: nowrap; }
    .search-filters-desktop { display: flex; }
}

/* ═══════════════════════════════════════════════════════════
   МОБИЛЬНЫЕ (≤860px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 860px) {
    .topbar-desktop-nav { display: none; }
    .filter-btn-mobile { display: inline-flex !important; }
    .search-filters-desktop { display: none !important; }
    .search-row { flex-wrap: wrap; }

    /* Статистика: 2×2 на телефоне */
    .home-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .home-stat-item { padding: 12px 8px; }

    /* Двухколоночный блок → одна колонка */
    .home-two-col { grid-template-columns: 1fr; gap: 0; }
    .home-two-col .home-section { margin-bottom: 32px; }

    /* Топбар: старые строки убираем */
    .topbar-row1, .nav { display: none; }
    .nav-tools { display: none; }

    /* Секции главной */
    .home-section-title { font-size: 15px; }

    /* Грид: 1 колонка на телефоне */
    .product-grid { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
    .home-stats { grid-template-columns: repeat(2, 1fr); }
    .home-stat-number { font-size: 18px; }
    .home-stat-label { font-size: 11px; }

    .search-input-wrap { min-width: 0; }
    .search-submit .search-submit-text { display: none; }
    .search-submit { padding: 0 12px; }
}

/* ═══════════════════════════════════════════════
   AUTH TABS (login / register toggle)
═══════════════════════════════════════════════ */
.auth-shell {
    width: min(480px, 100%);
    margin: 40px auto;
    padding: 0 16px;
}

.auth-tabs {
    display: flex;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-bottom: none;
}

.auth-tab {
    flex: 1;
    text-align: center;
    padding: 14px 20px;
    font-weight: 600;
    font-size: 15px;
    color: var(--muted);
    background: var(--panel-2);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.auth-tab:hover {
    text-decoration: none;
    color: var(--accent);
    background: var(--soft);
}

.auth-tab.active {
    background: var(--panel);
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0 0 12px 12px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.auth-card h1 {
    margin: 0 0 20px;
    font-size: 24px;
}

.auth-switch {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin: 8px 0 0;
}

/* ═══════════════════════════════════════════════
   LIGHTBOX (screenshot viewer)
═══════════════════════════════════════════════ */
.screenshot-thumb {
    display: block;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
    padding: 0;
    cursor: pointer;
    width: 100%;
    transition: transform 0.15s, box-shadow 0.15s;
}

.screenshot-thumb:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.screenshot-thumb img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.screenshot-zoom-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.35);
    color: #fff;
    opacity: 0;
    transition: opacity 0.15s;
    border-radius: 8px;
}

.screenshot-thumb:hover .screenshot-zoom-icon {
    opacity: 1;
}

/* Lightbox overlay */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.lightbox-overlay.open {
    display: block;
}

/* Lightbox dialog */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1001;
    align-items: center;
    justify-content: center;
    padding: 24px;
    flex-direction: column;
}

.lightbox.open {
    display: flex;
}

.lightbox-img-wrap {
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    object-fit: contain;
    display: block;
}

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 20px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.22);
    color: #fff;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 1002;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.25);
}

.lightbox-prev,
.lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.22);
    color: #fff;
    border-radius: 50%;
    width: 46px;
    height: 46px;
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 1002;
    line-height: 1;
}

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,0.28); }

.lightbox-counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    background: rgba(0,0,0,0.4);
    padding: 4px 14px;
    border-radius: 20px;
}

/* ═══════════════════════════════════════════════
   WATERMARK — semi-transparent text overlay
   (applied via GD in PHP; also CSS fix for display)
═══════════════════════════════════════════════ */
.screenshot-thumb img {
    opacity: 0.96;
}

/* ═══════════════════════════════════════════════
   GENERAL UI IMPROVEMENTS
═══════════════════════════════════════════════ */

/* Smoother card hover on home grid */
.card {
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.10);
}

/* Better tag pills */
.tags span {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--accent-soft);
    transition: background 0.12s;
}
.tags span:hover {
    background: var(--accent-soft);
}

/* Author line refinement */
.author-line {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    padding: 8px 0;
}
.author-line:hover { text-decoration: none; }

/* Download box refinement */
.download-box {
    border-radius: 10px;
    border: 1px solid var(--line);
}

/* Flash messages improved */
.flash {
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 4px;
    font-weight: 500;
}
.flash.success {
    background: color-mix(in srgb, var(--accent-2) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-2) 30%, transparent);
    color: var(--accent-2);
}
.flash.error {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
    color: var(--danger);
}

/* Input focus glow */
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* Button shine effect */
.button:not(.secondary):not(.small) {
    background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 80%, #0040a0) 100%);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}
.button:not(.secondary):not(.small):hover {
    box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 42%, transparent);
    filter: brightness(1.07);
}

/* ═══════════════════════════════════════════════
   FORGOT / RESET PASSWORD — extra styles
═══════════════════════════════════════════════ */

.auth-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--soft);
    color: var(--accent);
    margin: 0 auto 16px;
    border: 1px solid var(--accent-soft);
}

.auth-icon--success {
    background: color-mix(in srgb, var(--accent-2) 12%, transparent);
    color: var(--accent-2);
    border-color: color-mix(in srgb, var(--accent-2) 30%, transparent);
}

.auth-hint {
    text-align: center;
    margin: -4px 0 8px;
    font-size: 14px;
    line-height: 1.5;
}

/* Inline label row (label text + forgot link on same line) */
.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    color: var(--muted);
}

.forgot-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    opacity: 0.85;
    transition: opacity 0.15s;
}

.forgot-link:hover {
    opacity: 1;
    text-decoration: none;
}

/* Password field with show/hide toggle */
.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field input {
    width: 100%;
    padding-right: 42px;
}

.pw-toggle {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--muted);
    opacity: 0.5;
    display: flex;
    align-items: center;
    transition: opacity 0.15s;
}

.pw-toggle:hover {
    opacity: 0.85;
}

/* Password strength / match feedback */
.pw-strength,
.pw-match {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
    display: block;
    min-height: 18px;
    transition: color 0.2s;
}

/* Disabled submit button */
button[disabled].button {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
    box-shadow: none;
}

/* ═══════════════════════════════════════════════════════════════════
   SC-DROPDOWN  —  Universal custom select component
═══════════════════════════════════════════════════════════════════ */

/* Wrapper */
.sc-dropdown {
  position: relative;
  display: inline-block;
  width: 100%;
  font-size: 14px;
  user-select: none;
  -webkit-user-select: none;
}

/* Trigger button */
.sc-dropdown__btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  white-space: nowrap;
  overflow: hidden;
}

.sc-dropdown__btn:hover {
  border-color: var(--accent);
  background: var(--soft);
}

.sc-dropdown.open .sc-dropdown__btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 8px 8px 0 0;
}

.sc-dropdown__label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chevron */
.sc-dropdown__chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), color 0.15s;
}

.sc-dropdown.open .sc-dropdown__chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

/* Dropdown list panel */
.sc-dropdown__list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 9000;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.14), 0 4px 8px rgba(0,0,0,0.08);
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;

  /* Animation */
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

/* Open state */
.sc-dropdown.open .sc-dropdown__list {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Flip upward if near bottom of viewport */
.sc-dropdown.flip-up .sc-dropdown__list {
  top: auto;
  bottom: 100%;
  border-top: 1px solid var(--accent);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
}

.sc-dropdown.flip-up .sc-dropdown__btn {
  border-radius: 0 0 8px 8px;
}
.sc-dropdown.flip-up.open .sc-dropdown__btn {
  border-radius: 0 0 8px 8px;
}

/* Scrollbar styling */
.sc-dropdown__list::-webkit-scrollbar { width: 5px; }
.sc-dropdown__list::-webkit-scrollbar-track { background: transparent; }
.sc-dropdown__list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
.sc-dropdown__list::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* List items */
.sc-dropdown__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
  outline: none;
}

.sc-dropdown__item:hover,
.sc-dropdown__item:focus {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.sc-dropdown__item.selected {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-weight: 600;
}

/* Check icon — hidden by default, shown when selected */
.sc-dropdown__check {
  flex-shrink: 0;
  width: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.12s;
}

.sc-dropdown__item.selected .sc-dropdown__check {
  opacity: 1;
}

/* ── Context variants ────────────────────────────────────────── */

/* Inside .sidebar-filter-select (sidebar icon+select rows) */
.sidebar-filter-select .sc-dropdown {
  flex: 1;
}

/* Inside .form label (form fields) */
label .sc-dropdown {
  margin-top: 4px;
}

/* Compact variant for admin row-forms */
.row-form .sc-dropdown .sc-dropdown__btn {
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 6px;
}

.row-form .sc-dropdown.open .sc-dropdown__btn {
  border-radius: 6px 6px 0 0;
}

.row-form .sc-dropdown__list {
  border-radius: 0 0 6px 6px;
}

/* Comment form rating dropdown — compact inline */
.comment-form .sc-dropdown {
  width: auto;
  min-width: 80px;
}

.comment-form .sc-dropdown__btn {
  padding: 7px 10px;
}

/* Admin filter bar */
.admin-filter .sc-dropdown {
  min-width: 140px;
  width: auto;
}

.admin-filter .sc-dropdown__btn {
  padding: 7px 12px;
  font-size: 13px;
}

/* Desktop search-bar filters */
.search-filters-desktop .sc-dropdown {
  min-width: 130px;
  width: auto;
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .sc-dropdown__btn {
    padding: 11px 14px;
    font-size: 15px;
  }

  .sc-dropdown__item {
    padding: 13px 14px;
    font-size: 15px;
  }

  .sc-dropdown__list {
    max-height: 60vh;
  }
}
