/* ─── Top Bar ─── */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    gap: 16px;
    min-height: 52px;
}

:root[data-theme="dark"] .top-bar {
    background: var(--bg-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.site-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 2px;
}

.site-logo {
    height: 32px;
}

.site-name {
    font-size: 18px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.site-name strong {
    font-weight: 700;
}

.brand-text {
    display: inline-flex;
}

.brand-i {
    text-transform: lowercase;
}

.brand-collapse {
    display: inline-block;
    max-width: 1em;
    opacity: 1;
    overflow: hidden;
    transition: max-width 0.3s ease, opacity 0.25s ease;
}

.site-brand:hover .brand-collapse {
    max-width: 0;
    opacity: 0;
}

.site-domain {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
}

.top-bar-right {
    display: flex;
    gap: 10px;
    align-items: center;
}


.theme-toggle-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.theme-icon-dark {
    display: none;
}

.btn-upload {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
}

/* ─── Upload Modal ─── */
.upload-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.15s ease;
}

.upload-modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    padding: 28px;
    width: 100%;
    max-width: 440px;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.2s ease;
}

.upload-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.upload-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--bg-hover);
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: all 0.2s ease;
}

.upload-close-btn:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.upload-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 16px;
    background: var(--bg-muted);
    border-radius: 10px;
    padding: 4px;
}

.upload-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.upload-option:hover {
    background: var(--bg-surface);
}

.upload-option-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.upload-option-info svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.upload-option-title {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}

.upload-option-desc {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--border-light);
    border-radius: 10px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

.file-input-wrapper {
    position: relative;
    width: 100%;
}

input[type="file"] {
    display: none;
}

.file-input-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-input);
    gap: 8px;
}

.file-input-label:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.file-input-label.dragover {
    border-color: var(--accent);
    background: var(--accent-subtle);
    transform: scale(1.01);
}

.upload-icon {
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.file-input-label:hover .upload-icon {
    color: var(--accent);
}

.file-input-label p {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
}

.file-input-label small {
    color: var(--text-muted);
    font-size: 12px;
}

#fileName {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 13px;
    margin-top: 4px;
}

.button-group {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}

#uploadBtn {
    flex: 1;
}

/* ─── Status ─── */
.status {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    display: none;
    text-align: center;
    font-weight: 500;
    font-size: 13px;
}

.status.show { display: block; }
.status.show.loading { display: flex; }

.status.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.status.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

:root[data-theme="dark"] .status.success {
    background: rgba(16, 185, 129, 0.1);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.2);
}

:root[data-theme="dark"] .status.error {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.2);
}

.status.loading {
    background: none;
    color: var(--accent);
    border: none;
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 10;
    margin: 0;
    padding: 0;
}

:root[data-theme="dark"] .status.loading {
    background: rgba(24, 24, 27, 0.95);
}

.status.loading::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--border-default);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ─── Category Navigation ─── */
.category-nav {
    display: flex;
    gap: 6px;
    padding: 8px 0;
    background: transparent;
    border: none;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
}

.category-nav-desktop {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    flex: 0 1 auto;
    min-width: 0;
}

.category-nav-mobile {
    display: none;
    position: relative;
    order: -1;
}

.category-toggle-btn {
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-toggle-btn:hover {
    color: var(--accent);
}

.category-dropdown {
    position: fixed;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 180px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

:root[data-theme="dark"] .category-dropdown {
    background: var(--bg-hover);
}

.category-dropdown-item {
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
}

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

.category-dropdown-item.active {
    background: var(--accent);
    color: white;
}

#categoryButtons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.category-btn {
    padding: 4px 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.category-btn:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

.category-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

:root[data-theme="dark"] .category-btn {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

:root[data-theme="dark"] .category-btn:hover:not(.active) {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

:root[data-theme="dark"] .category-btn.active {
    background: var(--accent);
    color: #ffffff;
}

.category-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.category-dropdown-item {
    gap: 6px;
}

.category-btn svg, .category-dropdown-item svg {
    flex-shrink: 0;
}

/* ─── Subcategory Bar ─── */
.subcategory-bar {
    display: flex;
    justify-content: center;
    padding: 8px 24px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
}

.subcategory-bar.hidden {
    display: none;
}

.subcategory-buttons {
    display: flex;
    gap: 6px;
}

.subcategory-btn {
    padding: 4px 12px;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.subcategory-btn:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
}

.subcategory-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

:root[data-theme="dark"] .subcategory-btn {
    border-color: var(--border-default);
}

:root[data-theme="dark"] .subcategory-btn:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
}

/* ─── Patch Notes Modal ─── */
.patchnotes-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.15s ease;
    padding: 16px;
}

.patchnotes-modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    padding: 32px;
    width: 100%;
    max-width: 480px;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.2s ease;
}

.patchnotes-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--bg-hover);
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: all 0.2s ease;
}

.patchnotes-close:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.patchnotes-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.patchnotes-version {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.patchnotes-subtitle {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 16px;
    margin-bottom: 12px;
}

.patchnotes-list {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.patchnotes-list li {
    font-size: 14px;
    color: var(--text-secondary);
    padding-left: 16px;
    position: relative;
    line-height: 1.5;
}

.patchnotes-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

.patchnotes-ack {
    width: 100%;
}

/* ─── Mobile Responsive ─── */
@media (max-width: 640px) {
    .top-bar {
        padding: 0 12px;
        gap: 6px;
    }

    .site-name {
        display: none;
    }

    .category-nav-desktop {
        display: none;
    }

    .category-nav-mobile {
        display: flex;
        order: 0;
    }

    .category-toggle-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .btn-upload-text {
        display: none;
    }

    .btn-upload {
        padding: 10px;
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
    }

    .btn-upload svg {
        width: 18px;
        height: 18px;
    }

    .top-bar-right {
        gap: 2px;
    }

    .theme-toggle-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .user-menu-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .search-toggle-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .search-input {
        width: 120px;
    }
}
