@font-face {
    font-family: Tiny;
    src: url("/fonts/tiny.woff") format("woff");
    font-display: swap;
}

:root {
    color-scheme: dark;
    --background: #1f1e1e;
    --foreground: #faacac;
    --secondary: #bf9696;
    --border: #faacac56;
}

* { box-sizing: border-box; }

body {
    margin: 8px;
    background: var(--background);
    color: var(--foreground);
    font-family: Tiny, monospace;
    font-size: 16px;
    line-height: 1.5;
}

main { width: 100%; container-type: inline-size; }
.listing-panel, .readme-panel { min-width: 0; }

/* Two 500px columns plus a 24px gap; stack when the content is narrower. */
@container (min-width: 1024px) {
    .directory-content.has-readme {
        display: grid;
        grid-template-columns: minmax(500px, 1fr) minmax(500px, 1fr);
        gap: 24px;
        align-items: start;
    }
    .has-readme > .readme-panel { grid-column: 2; grid-row: 1; }
    .has-readme > .listing-panel { grid-column: 1; grid-row: 1; }
    .has-readme .readme-separator { display: none; }
    .has-readme .readme-panel h2 { margin-top: 0; }
}
h1 { font-size: 2em; line-height: 1.2; overflow-wrap: anywhere; }
.directory-header { display: flex; align-items: center; gap: 12px; padding-block: 12px; }
.directory-logo { flex: none; object-fit: contain; }
.directory-heading { min-width: 0; }
.directory-heading h1 { margin: 0; }
.directory-path { margin: 4px 0 0; color: var(--secondary); font-size: .9em; overflow-wrap: anywhere; }
a { color: var(--foreground); }
a:visited { color: #c58585; }
a:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }

.file-list {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    border-block: 2px solid var(--border);
}

th, td {
    padding: 0 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
    height: 34px;
}

th { font-weight: normal; }
.date { width: 185px; white-space: nowrap; }
.size { width: 100px; text-align: right; white-space: nowrap; }
.file-list a { text-decoration: none; }
.file-list th a, .name a { display: block; padding-block: 5px; }
.name a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back a { display: flex; align-items: center; gap: 10px; padding-block: 5px; }
.back-icon { flex: none; fill: currentColor; }

tbody tr:hover, tbody tr:focus-within {
    background: var(--foreground);
    color: var(--background);
}

tbody tr:hover a, tbody tr:focus-within a { color: var(--background); }
.empty { padding-block: 10px; }
.listing-note { font-size: .9em; }
.readme { display: block; width: 100%; height: 650px; border: 1px solid var(--border); margin-top: 24px; }
.readme-body { margin: 0; padding: 4px; }
.readme-body img { max-width: 100%; height: auto; }
.readme-body { overflow-wrap: anywhere; }
.readme-body pre { overflow-x: auto; padding: 10px; border: 1px solid var(--border); }
.readme-body code { font-family: monospace; font-size: .9em; }
.readme-body blockquote { margin-inline: 0; padding-left: 12px; border-left: 2px solid var(--border); color: var(--secondary); }
.readme-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.readme-body th { font-weight: bold; }
.readme-body th, .readme-body td { padding: 6px 10px; border: 1px solid var(--border); height: auto; }

[hidden] { display: none !important; }
hr { border: 0; border-top: 2px dashed var(--border); margin: 22px 0; }
.title-separator { border-top-style: solid; }
h2 { font-size: 1.25em; font-weight: normal; }
footer { width: 100%; padding-bottom: 20px; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; }
.summary { margin: 0; flex: 1 1 260px; }
.view-switch { display: flex; gap: 4px; }
.view-switch a, button { padding: 4px 12px; border: 1px solid var(--border); text-decoration: none; }
.view-switch [aria-current], button:hover { background: var(--foreground); color: var(--background); }
.sort-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; width: 100%; }
input, select, button { font: inherit; color: var(--foreground); background: var(--background); border: 1px solid var(--border); border-radius: 0; padding: 4px 8px; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--foreground); outline-offset: 2px; }
button { cursor: pointer; }
.filter-control { display: flex; align-items: center; gap: 10px; width: 100%; }
.filter-control input { flex: 1; min-width: 0; }
.parent-link { display: inline-block; margin-bottom: 16px; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 12px; }
.grid-entry { min-width: 0; border: 1px solid var(--border); }
.grid-entry a { display: flex; height: 100%; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px; text-decoration: none; }
.grid-entry a:hover, .grid-entry a:focus-visible { background: var(--foreground); color: var(--background); }
.grid-name { width: 100%; text-align: center; overflow-wrap: anywhere; }
.grid-meta { font-size: .85em; text-align: center; }
.entry-icon { width: 80px; height: 100px; stroke: currentColor; stroke-width: 1; fill: none; }
.thumbnail { width: 100%; height: 100px; object-fit: contain; }
.readme-open { font-size: .7em; margin-left: 12px; }

.gallery-folders { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-bottom: 16px; }
.gallery-folders a { display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.gallery-folders .entry-icon { width: 24px; height: 24px; flex: none; }
.image-gallery { display: flex; flex-wrap: wrap; gap: 6px; }
.image-gallery::after { content: ""; flex-grow: 999; flex-basis: 200px; }
.gallery-tile { position: relative; flex: 1 1 200px; aspect-ratio: 1; min-width: 0; max-width: 100%; overflow: hidden; background: #151414; }
.gallery-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-caption { position: absolute; inset: auto 0 0; padding: 6px 8px; background: #1f1e1ee6; color: var(--foreground); overflow-wrap: anywhere; opacity: 0; }
.gallery-tile:hover .gallery-caption, .gallery-tile:focus-visible .gallery-caption { opacity: 1; }
.gallery-other-files { margin-top: 20px; }
.gallery-other-files summary { cursor: pointer; }
.viewer-open { overflow: hidden; }
.image-viewer { width: 96vw; max-width: none; max-height: 96dvh; padding: 12px; border: 1px solid var(--border); background: var(--background); color: var(--foreground); }
.image-viewer::backdrop { background: #000e; }
.viewer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.viewer-stage { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; margin-top: 12px; }
.viewer-stage button { min-height: 48px; padding: 4px; }
.viewer-stage button:disabled { opacity: .35; cursor: default; }
.viewer-image { display: block; width: 100%; height: 72dvh; object-fit: contain; min-width: 0; }
.viewer-caption { margin: 12px 0 0; text-align: center; overflow-wrap: anywhere; }

@media (max-width: 650px) {
    .date { width: 40%; white-space: normal; font-size: .85em; }
    .size { width: 22%; }
    th, td { padding-inline: 8px; }
    h1 { font-size: 1.5em; }
}

@media (width < 250px) {
    .date { display: none; }
}
