:root {
    --primary: #5b3df5;
    --primary-dark: #4326d8;
    --surface: #ffffff;
    --surface-soft: #f7f7fc;
    --text: #19172a;
    --muted: #716f80;
    --border: #e9e7f1;
    --shadow: 0 18px 50px rgba(39, 29, 89, .10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--surface-soft);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", sans-serif;
}

a {
    color: inherit;
}

.navbar {
    background: rgba(31, 24, 76, .96);
    backdrop-filter: blur(12px);
}

.navbar-brand {
    letter-spacing: -.02em;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #8d7bff, #5b3df5);
}

.hero-section {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 90% 20%, rgba(150, 125, 255, .35), transparent 30%),
        linear-gradient(135deg, #ffffff 0%, #f0edff 55%, #e4ddff 100%);
    border-bottom: 1px solid var(--border);
}

.hero-section::after {
    content: "";
    position: absolute;
    width: 320px;
    height: 320px;
    right: -120px;
    bottom: -180px;
    border-radius: 50%;
    background: rgba(91, 61, 245, .08);
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .9rem;
    border-radius: 999px;
    color: var(--primary-dark);
    background: rgba(91, 61, 245, .10);
    font-weight: 700;
    font-size: .92rem;
}

.hero-section h1 {
    line-height: 1.15;
    letter-spacing: -.04em;
}

.hero-section h1 span {
    color: var(--primary);
}

.search-panel {
    position: relative;
    z-index: 1;
    padding: 1.5rem;
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 24px;
    background: rgba(255,255,255,.88);
    box-shadow: var(--shadow);
}

.form-control,
.input-group-text {
    border-color: var(--border);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(91, 61, 245, .15);
}

.btn-primary {
    border-color: var(--primary);
    background: linear-gradient(135deg, #6e55ff, var(--primary));
    box-shadow: 0 10px 25px rgba(91, 61, 245, .22);
}

.btn-primary:hover,
.btn-primary:focus {
    border-color: var(--primary-dark);
    background: linear-gradient(135deg, #5f46f2, var(--primary-dark));
}

.category-pill {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    padding: .65rem .9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: #504d62;
    background: #fff;
    text-decoration: none;
    transition: .2s ease;
}

.category-pill span {
    min-width: 26px;
    padding: .1rem .45rem;
    border-radius: 999px;
    text-align: center;
    background: #f1eff8;
    font-size: .78rem;
}

.category-pill:hover,
.category-pill.active {
    color: #fff;
    border-color: var(--primary);
    background: var(--primary);
    transform: translateY(-1px);
}

.category-pill.active span,
.category-pill:hover span {
    color: var(--primary-dark);
    background: #fff;
}

.file-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 10px 30px rgba(37, 28, 77, .06);
    transition: transform .25s ease, box-shadow .25s ease;
}

.file-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow);
}

.file-cover {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #eeeafc;
}

.file-cover img,
.detail-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-cover img {
    transition: transform .3s ease;
}

.file-card:hover .file-cover img {
    transform: scale(1.04);
}

.file-placeholder,
.detail-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: var(--primary);
    background:
        linear-gradient(135deg, rgba(91,61,245,.08), rgba(91,61,245,.18)),
        radial-gradient(circle at 30% 30%, #fff, transparent 45%);
}

.file-placeholder i {
    font-size: 4rem;
}

.file-category {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: .35rem .65rem;
    border-radius: 999px;
    color: #fff;
    background: rgba(35, 27, 78, .84);
    backdrop-filter: blur(8px);
    font-size: .78rem;
    font-weight: 700;
}

.stretched-link-title {
    color: var(--text);
    text-decoration: none;
}

.stretched-link-title:hover {
    color: var(--primary);
}

.file-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding-top: .8rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .83rem;
}

.empty-state {
    padding: 4rem 1.5rem;
    border: 1px dashed #cbc5e5;
    border-radius: 24px;
    text-align: center;
    background: #fff;
}

.empty-state i {
    display: block;
    margin-bottom: 1rem;
    color: var(--primary);
    font-size: 4rem;
}

.page-link {
    color: var(--primary);
    border-color: var(--border);
}

.page-item.active .page-link {
    border-color: var(--primary);
    background: var(--primary);
}

.detail-hero {
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

.detail-preview {
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border: 1px solid var(--border);
    border-radius: 26px;
    background: #eeeafc;
    box-shadow: var(--shadow);
}

.detail-placeholder i {
    font-size: 8rem;
}

.content-card,
.download-card {
    padding: 1.6rem;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 12px 36px rgba(37, 28, 77, .07);
}

.download-card {
    position: sticky;
    top: 96px;
}

.description-content {
    color: #4f4c5d;
    line-height: 1.9;
}

.download-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
    margin-top: 1.25rem;
}

.download-stats > div {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface-soft);
}

.download-stats span {
    display: block;
    margin-bottom: .25rem;
    color: var(--muted);
    font-size: .82rem;
}

.download-stats strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: .93rem;
}

.download-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    min-height: 56px;
    font-weight: 800;
}

.site-footer {
    color: #d8d5e9;
    background: #1f184c;
}

.site-footer .text-secondary {
    color: #aaa5c7 !important;
}

@media (max-width: 767.98px) {
    .hero-section h1 {
        font-size: 2.35rem;
    }

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

    .download-card {
        position: static;
    }
}
