* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    background: #fafaf5;
    color: #111;
    line-height: 1.4;
}

/* --- header --- */

header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 12px 20px;
    border-bottom: 2px solid #111;
}

.logo {
    font-size: 16px;
    font-weight: bold;
    text-decoration: none;
    color: #111;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.header-link {
    font-size: 12px;
    color: #666;
    text-decoration: none;
}
.header-link:hover {
    color: #111;
}

/* --- layout --- */

main {
    padding: 20px;
}

.browse {
    display: flex;
    gap: 24px;
}

/* --- filters --- */

.filters {
    flex-shrink: 0;
    width: 180px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
}

.filter-group label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    margin-bottom: 4px;
}

.filter-group select,
.filter-group input {
    width: 100%;
    font-family: inherit;
    font-size: 13px;
    padding: 5px 6px;
    border: 1px solid #111;
    background: #fff;
    color: #111;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: 2px solid #111;
    outline-offset: -1px;
}

/* --- grid --- */

.grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1px;
    background: #111;
    border: 1px solid #111;
    align-content: start;
}

.card {
    background: #fafaf5;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.card-thumb-missing {
    background: #e8e8e0;
}

.card-filename,
.card-dir,
.card-badges,
.card-sidecars {
    padding-left: 10px;
    padding-right: 10px;
}

.card-filename {
    padding-top: 8px;
}

.card-filename {
    font-weight: bold;
    font-size: 12px;
    word-break: break-all;
    line-height: 1.3;
}

.card-dir {
    font-size: 11px;
    color: #555;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-badges {
    display: flex;
    gap: 6px;
    margin-top: 2px;
}

.badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 4px;
    border: 1px solid #999;
    color: #555;
}

.badge-yes {
    border-color: #111;
    color: #111;
}

.badge-no {
    border-color: #ccc;
    color: #aaa;
}

.card-sidecars {
    display: flex;
    gap: 5px;
    margin-top: auto;
    padding-bottom: 8px;
}

.sc {
    font-size: 10px;
    font-weight: bold;
    color: #111;
    background: #ddd;
    padding: 1px 4px;
}

.grid:empty,
.grid:has(.grid-empty) {
    background: transparent;
    border: 1px dashed #999;
}

.grid-empty {
    grid-column: 1 / -1;
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
    background: transparent;
}

/* sentinel is invisible, just triggers the next load */
.sentinel {
    height: 1px;
    grid-column: 1 / -1;
}

/* --- login --- */

.login-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 240px;
}

.login-form label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
}

.login-form input {
    font-family: inherit;
    font-size: 14px;
    padding: 8px 10px;
    border: 2px solid #111;
    background: #fff;
}

.login-form input:focus {
    outline: none;
    border-color: #111;
    box-shadow: 3px 3px 0 #111;
}

.login-form button {
    font-family: inherit;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 8px;
    border: 2px solid #111;
    background: #111;
    color: #fafaf5;
    cursor: pointer;
}

.login-form button:hover {
    background: #333;
}

.login-error {
    font-size: 12px;
    color: #900;
}

/* --- responsive --- */

@media (max-width: 640px) {
    .browse {
        flex-direction: column;
    }
    .filters {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        position: static;
    }
    .filter-group {
        flex: 1;
        min-width: 120px;
    }
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}
