:root {
    --bg: #111827;
    --surface: #1a1d26;
    --surface-hover: #22262f;
    --card-bg: #1e293b;
    --card-border: rgba(148, 163, 184, 0.14);
    --card-accent: #3b82f6;
    --meta-value: #94a3b8;
    --dot-version: #3b82f6;
    --dot-size: #eab308;
    --dot-date: #ef4444;
    --border: #2a3142;
    --text: #e8eaed;
    --text-muted: #9aa0a6;
    --accent-blue: #4a9eff;
    --accent-green: #34a853;
    --accent-red: #ea4335;
    --accent-orange: #ff6d3a;
    --gold: #d4a017;
    --gold-light: #f5d76e;
    --header-h: 52px;
    --max-width: 1100px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(17, 24, 39, 0.95);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
    color: var(--gold-light);
}

.brand-logo-sm {
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 50%;
}

.header-actions {
    display: flex;
    align-items: center;
    position: relative;
}

.header-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem 1.25rem;
    justify-content: flex-end;
    align-items: center;
}

.nav-link {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text);
    text-decoration: none;
}

.nav-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

.nav-menu-toggle:hover {
    background: var(--surface-hover);
    border-color: #3d4659;
}

.nav-menu-bars,
.nav-menu-bars::before,
.nav-menu-bars::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    position: relative;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-menu-bars::before,
.nav-menu-bars::after {
    content: '';
    position: absolute;
    left: 0;
}

.nav-menu-bars::before {
    top: -6px;
}

.nav-menu-bars::after {
    top: 6px;
}

.site-header.nav-open .nav-menu-bars {
    background: transparent;
}

.site-header.nav-open .nav-menu-bars::before {
    top: 0;
    transform: rotate(45deg);
}

.site-header.nav-open .nav-menu-bars::after {
    top: 0;
    transform: rotate(-45deg);
}

@media (max-width: 768px) {
    .nav-menu-toggle {
        display: flex;
    }

    .header-nav {
        display: none;
        position: absolute;
        top: calc(100% + 0.5rem);
        right: 0;
        min-width: 11rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0.35rem 0;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
        z-index: 110;
    }

    .site-header.nav-open .header-nav {
        display: flex;
    }

    .header-nav .nav-link {
        display: block;
        padding: 0.65rem 1rem;
        font-size: 0.875rem;
        border-radius: 0;
    }

    .header-nav .nav-link:hover {
        background: rgba(59, 130, 246, 0.1);
    }
}

/* Main */
.main-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
}

/* Hero */
.hero {
    text-align: center;
    padding: 1.5rem 0 0.5rem;
}

.hero-logo {
    margin-bottom: 1.25rem;
    object-fit: contain;
    border-radius: 50%;
}

.tabs {
    display: flex;
    width: 100%;
    margin: 0 auto 0.5rem;
    gap: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 0.5rem 1.25rem;
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.25;
    transition: background 0.2s, color 0.2s;
    border: none;
}

.tab:hover {
    color: var(--text);
    text-decoration: none;
}

.tab-active {
    background: var(--accent-blue);
    color: #fff;
}

.tab-active:hover {
    color: #fff;
}

/* Search & filter */
.search-section {
    margin-bottom: 1.5rem;
}

.search-row {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.filter-wrap {
    position: relative;
    flex-shrink: 0;
}

.filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 100%;
    min-height: 48px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.filter-btn svg {
    width: 20px;
    height: 20px;
}

.filter-btn:hover,
.filter-btn:focus-visible {
    color: var(--text);
    border-color: var(--accent-blue);
    outline: none;
}

.filter-btn-active {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.12);
}

.filter-panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    z-index: 50;
    min-width: 10rem;
    max-width: min(16rem, calc(100vw - 2rem));
    max-height: 16rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.filter-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.55rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.filter-option:hover {
    background: rgba(255, 255, 255, 0.06);
}

.filter-option-active {
    background: var(--accent-blue);
    color: #fff;
}

.filter-option-active:hover {
    background: var(--accent-blue);
    color: #fff;
}

.search-wrap {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 0.5rem 0 2.5rem;
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    font-size: 0.9rem;
    opacity: 0.6;
    pointer-events: none;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1rem;
    padding: 0.85rem 0.5rem;
    outline: none;
    min-width: 0;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    background: var(--accent-red);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.search-clear.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Apps catalog */
.apps-catalog {
    display: block;
}

/* App grid — 3 per row on desktop (CyPwn reference proportions) */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.875rem;
}

@media (max-width: 992px) {
    .apps-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }
}

@media (max-width: 576px) {
    .apps-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .brand span {
        font-size: 0.85rem;
    }
}

.app-card {
    --card-icon-size: 62px;
    --card-gap: 0.65rem;
    --card-pad-y: 0.7rem;
    --card-pad-x: 0.75rem;
    --card-title-size: 0.8125rem;
    --card-meta-size: 0.6875rem;
    --card-view-size: 36px;
    --card-dot-size: 6px;

    display: flex;
    align-items: center;
    gap: var(--card-gap);
    padding: var(--card-pad-y) var(--card-pad-x);
    padding-left: calc(var(--card-pad-x) - 2px);
    min-height: 0;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-left: 3px solid var(--card-accent);
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(59, 130, 246, 0.06);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

@media (min-width: 577px) and (max-width: 992px) {
    .app-card {
        --card-icon-size: 58px;
        --card-title-size: 0.84rem;
        --card-meta-size: 0.72rem;
        --card-view-size: 38px;
    }
}

@media (min-width: 993px) {
    .app-card {
        --card-icon-size: 54px;
        --card-gap: 0.55rem;
        --card-pad-y: 0.65rem;
        --card-pad-x: 0.7rem;
        --card-title-size: 0.78rem;
        --card-meta-size: 0.66rem;
        --card-view-size: 34px;
        --card-dot-size: 5px;
    }
}

@media (max-width: 576px) {
    .app-card {
        --card-icon-size: 60px;
        --card-gap: 0.75rem;
        --card-pad-y: 0.8rem;
        --card-pad-x: 0.9rem;
        --card-title-size: 0.9rem;
        --card-meta-size: 0.75rem;
        --card-view-size: 40px;
        --card-dot-size: 6px;
    }
}

.app-card:hover,
.app-card:focus-visible {
    background: #243447;
    border-color: rgba(59, 130, 246, 0.28);
    box-shadow: inset 0 1px 0 rgba(59, 130, 246, 0.1), 0 4px 14px rgba(0, 0, 0, 0.18);
}

.app-card.hidden {
    display: none;
}

.app-card-icon {
    flex-shrink: 0;
    width: var(--card-icon-size, 54px);
    height: var(--card-icon-size, 54px);
    border-radius: 50%;
    background: #fff;
    border: 2px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.app-card-icon img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.app-card-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #e8eaed;
}

.app-card-body {
    flex: 1;
    min-width: 0;
}

.app-card-title {
    font-size: var(--card-title-size, 0.78rem);
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.28rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-card-meta-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.app-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.3rem;
    font-size: var(--card-meta-size, 0.66rem);
    line-height: 1.35;
    min-width: 0;
}

.app-card-meta::before {
    content: '';
    width: var(--card-dot-size, 5px);
    height: var(--card-dot-size, 5px);
    border-radius: 50%;
    flex-shrink: 0;
}

.app-card-meta--version::before {
    background: var(--dot-version);
}

.app-card-meta--size::before {
    background: var(--dot-size);
}

.app-card-meta--date::before {
    background: var(--dot-date);
}

.app-card-meta .meta-label {
    color: #fff;
    font-weight: 400;
    flex-shrink: 0;
}

.app-card-meta .meta-value {
    color: var(--meta-value);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-card-view {
    flex-shrink: 0;
    width: var(--card-view-size, 34px);
    height: var(--card-view-size, 34px);
    margin-left: 0.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1.5px solid var(--meta-value);
    border-radius: 50%;
    color: var(--meta-value);
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: none;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.app-card-view:hover {
    color: var(--card-accent);
    border-color: var(--card-accent);
    background: rgba(59, 130, 246, 0.1);
}

.app-card-view svg {
    display: block;
    width: calc(var(--card-view-size, 34px) * 0.5);
    height: calc(var(--card-view-size, 34px) * 0.5);
}

.empty-state,
.no-results {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.no-results.hidden,
.hidden {
    display: none !important;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}

.modal-overlay:not(.hidden) {
    display: flex;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--border);
    border: none;
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.modal-close:hover {
    background: var(--accent-red);
}

.modal-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-right: 2rem;
}

.modal-icon {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    object-fit: cover;
    flex-shrink: 0;
}

.modal-header-text {
    min-width: 0;
}

.modal-header-text h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.modal-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.modal-developer {
    font-size: 0.85rem;
    color: var(--accent-blue);
    margin-top: 0.25rem;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.modal-tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    background: var(--bg);
    border-radius: 4px;
    color: var(--text-muted);
}

.modal-screenshots {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}

.modal-screenshots img {
    height: 180px;
    width: auto;
    border-radius: 10px;
    flex-shrink: 0;
    object-fit: cover;
}

.modal-description {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.25rem;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.btn-download {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.85rem 1.5rem;
    background: var(--accent-blue);
    color: #fff !important;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none !important;
    transition: filter 0.2s;
}

.btn-download:hover {
    filter: brightness(1.1);
    text-decoration: none !important;
}

/* App detail page */
.app-detail-section {
    max-width: 560px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.app-detail-back {
    display: inline-block;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    text-decoration: none;
}

.app-detail-back:hover {
    color: var(--accent-blue);
}

.app-detail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.app-detail .modal-header-text h1 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.app-detail-description {
    max-height: none;
}

/* Footer */
.site-footer {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}
