:root {
    --bg: #0f1117;
    --surface: #1a1f2b;
    --surface-2: #222938;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f3f4f6;
    --muted: #9ca3af;
    --accent: #4f6bff;
    --accent-soft: rgba(79, 107, 255, 0.16);
    --ext: #7dd3fc;
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, system-ui, -apple-system, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(79, 107, 255, 0.14), transparent 30%),
        var(--bg);
}

.page {
    width: min(1200px, calc(100% - 1.5rem));
    margin: 0 auto;
    padding: 1.25rem 0 2rem;
}

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: rgba(26, 31, 43, 0.92);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.brand-link {
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.brand-sub {
    color: var(--muted);
    font-size: 0.88rem;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
}

.search-form input {
    width: min(240px, 56vw);
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    padding: 0.65rem 0.85rem;
    font: inherit;
}

.search-form button,
.btn {
    border: none;
    border-radius: 10px;
    padding: 0.65rem 0.95rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-form button {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.panel-body {
    padding: 1.25rem 1.5rem 1.5rem;
}

.panel-title {
    margin: 0 0 0.35rem;
    font-size: 1.25rem;
}

.panel-subtitle {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.28);
    color: #fde68a;
}

.alert-info {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.28);
    color: #bfdbfe;
}

.search-result-link {
    color: #dbeafe;
    word-break: break-all;
    text-decoration: none;
}

.search-result-link:hover {
    color: #fff;
    text-decoration: underline;
}

mark {
    background: #ffd966;
    color: #111;
    padding: 0 2px;
}

.path-label {
    color: var(--muted);
    font-size: 0.88rem;
    word-break: break-all;
}

.results-summary {
    margin: 0 0 1rem;
    color: var(--muted);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
}

.pagination a {
    display: inline-block;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: #aebaff;
    text-decoration: none;
}

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

.listing-shell {
    background: rgba(26, 31, 43, 0.92);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.search-results table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.search-results th,
.search-results td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.search-results tr:last-child td {
    border-bottom: none;
}

.search-results th {
    background: #151923;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
}

.search-results th:nth-child(1),
.search-results td:nth-child(1) {
    width: 38%;
}

.search-results th:nth-child(2),
.search-results td:nth-child(2) {
    width: auto;
}

.search-results th:nth-child(3),
.search-results td:nth-child(3) {
    width: 170px;
    white-space: nowrap;
    color: var(--muted);
    font-size: 0.88rem;
}

.search-results th:nth-child(4),
.search-results td:nth-child(4) {
    width: 90px;
    white-space: nowrap;
    text-align: right;
    color: var(--muted);
    font-size: 0.88rem;
}

.search-results tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.listing-shell:not(.search-results) table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.listing-shell:not(.search-results) th,
.listing-shell:not(.search-results) td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.listing-shell:not(.search-results) tr:last-child td {
    border-bottom: none;
}

.listing-shell:not(.search-results) th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #151923;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
}

.listing-shell:not(.search-results) th a {
    color: var(--muted);
    text-decoration: none;
}

.listing-shell:not(.search-results) th a:hover {
    color: var(--text);
}

.listing-shell:not(.search-results) td {
    font-size: 0.95rem;
}

.listing-shell:not(.search-results) td img {
    opacity: 0.85;
}

.listing-shell:not(.search-results) hr {
    display: none;
}

.listing-shell:not(.search-results) th:nth-child(1),
.listing-shell:not(.search-results) td:nth-child(1),
.listing-shell .col-icon-hidden {
    display: none;
}

.listing-shell:not(.search-results) th:nth-child(2),
.listing-shell:not(.search-results) td:nth-child(2) {
    width: auto;
    min-width: 0;
}

.listing-shell:not(.search-results) th:nth-child(3),
.listing-shell:not(.search-results) td:nth-child(3) {
    width: 170px;
    white-space: nowrap;
    color: var(--muted);
    font-size: 0.88rem;
}

.listing-shell:not(.search-results) th:nth-child(4),
.listing-shell:not(.search-results) td:nth-child(4) {
    width: 90px;
    white-space: nowrap;
    text-align: right !important;
    color: var(--muted);
    font-size: 0.88rem;
}

.listing-shell:not(.search-results) th:nth-child(5),
.listing-shell:not(.search-results) td:nth-child(5) {
    display: none;
}

.listing-shell:not(.search-results) tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.listing-shell a {
    color: #dbeafe;
    text-decoration: none;
}

.listing-shell a:hover {
    color: #fff;
}

.file-link,
.dir-link {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 0;
}

.file-ext {
    flex: 0 0 auto;
    min-width: 4.25rem;
    margin-right: 0.75rem;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--ext);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    white-space: nowrap;
}

.file-base {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.dir-link .file-ext {
    background: rgba(34, 197, 94, 0.14);
    color: #86efac;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.site-footer a {
    color: #aebaff;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 760px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form {
        width: 100%;
    }

    .search-form input {
        width: 100%;
        flex: 1;
    }

    .listing-shell:not(.search-results) th:nth-child(3),
    .listing-shell:not(.search-results) td:nth-child(3),
    .search-results th:nth-child(3),
    .search-results td:nth-child(3) {
        width: 120px;
        font-size: 0.78rem;
    }

    .listing-shell:not(.search-results) th:nth-child(4),
    .listing-shell:not(.search-results) td:nth-child(4),
    .search-results th:nth-child(4),
    .search-results td:nth-child(4) {
        width: 72px;
    }
}
