:root {
    color-scheme: dark;
    font-family: Georgia, 'Times New Roman', serif;
    background: #2c2824;
    color: #d2c9b0;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    margin: 0;
    background: #2c2824;
    color: #d2c9b0;
}

button,
input,
select {
    font: inherit;
}

.heading-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
    padding: 0.7rem 1rem;
    background: #211e1b;
    border-bottom: 1px solid #635b53;
}

.heading-container a {
    color: #d2c9b0;
    text-decoration: none;
}

.heading-container a:hover,
.heading-container a:focus-visible {
    text-decoration: underline;
}

.site-header {
    padding: 1.25rem 1rem 0.75rem;
    text-align: center;
}

h1 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.container {
    width: calc(100% - 1rem);
    max-width: none;
    margin: 0 auto 2rem;
    padding: 1rem;
    background: #433d37;
    border: 1px solid #635b53;
    border-radius: 0.5rem;
    box-shadow: 0 0.4rem 1.2rem rgb(0 0 0 / 35%);
}

.controls {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.primary-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.search-bar {
    width: min(32rem, 100%);
    min-height: 2.35rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid #847763;
    border-radius: 0.3rem;
    background: #211e1b;
    color: #f5f0e4;
}

.search-bar::placeholder {
    color: #aaa08e;
}

select,
button {
    min-height: 2.35rem;
    padding: 0.4rem 0.7rem;
    border: 1px solid #847763;
    border-radius: 0.3rem;
    background: #635b53;
    color: #fff;
    cursor: pointer;
}

button:hover:not(:disabled),
button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
    border-color: #c7b895;
    outline: 2px solid #c7b895;
    outline-offset: 1px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.preset-button.is-active,
.preset-button[aria-pressed='true'] {
    border-color: #d8c69d;
    background: #847763;
    box-shadow: inset 0 0 0 1px #d8c69d;
}

.table-status {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.error-message {
    color: #ffb4a8;
}

.column-picker {
    border: 1px solid #635b53;
    border-radius: 0.35rem;
    background: #302b27;
}

.column-picker summary {
    width: fit-content;
    padding: 0.55rem 0.7rem;
    cursor: pointer;
    font-weight: 700;
}

#checkbox-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.85rem;
    max-height: 14rem;
    overflow-y: auto;
    padding: 0.3rem 0.7rem 0.8rem;
}

.column-option {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.column-checkbox {
    accent-color: #a89570;
}

.column-label {
    cursor: pointer;
    user-select: none;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    margin: 0.5rem 0;
}

.pagination span {
    min-width: 10rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.table-scrollbar {
    position: sticky;
    top: 0;
    z-index: 5;
    width: 100%;
    height: 18px;
    overflow-x: scroll;
    overflow-y: hidden;
    margin-bottom: 0.35rem;
    border: 1px solid #635b53;
    border-radius: 0.35rem;
    background: #2c2824;
    scrollbar-gutter: stable;
}

.table-scrollbar-spacer {
    height: 1px;
}

.scroll-container {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    border: 1px solid #635b53;
    border-radius: 0.35rem;
    background: #2c2824;
    scrollbar-gutter: stable;
}

#itemsTable {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
}

th,
td {
    min-width: 9rem;
    max-width: 22rem;
    padding: 0.55rem 0.65rem;
    border-right: 1px solid #635b53;
    border-bottom: 1px solid #635b53;
    text-align: left;
    vertical-align: top;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

th:first-child,
td:first-child {
    min-width: 13rem;
}

th:nth-child(2),
td:nth-child(2) {
    min-width: 6rem;
    width: 6rem;
    text-align: center;
}

th:nth-child(3),
td:nth-child(3) {
    min-width: 7rem;
    width: 7rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #635b53;
    color: #f5f0e4;
    cursor: pointer;
    user-select: none;
}

th:hover,
th:focus-visible,
th.sorted-ascending,
th.sorted-descending {
    background: #847763;
}

th.sorted-ascending::after {
    content: ' ▲';
}

th.sorted-descending::after {
    content: ' ▼';
}

tbody tr:nth-child(odd) {
    background: #2c2824;
}

tbody tr:nth-child(even) {
    background: #3a342f;
}

tbody tr:hover {
    background: #4d453d;
}

.item-thumbnail {
    display: block;
    width: 72px;
    height: 72px;
    margin: 0 auto;
    object-fit: contain;
    cursor: zoom-in;
    background: #171513;
    border: 1px solid #635b53;
    border-radius: 0.2rem;
}

.placeholder-thumbnail {
    opacity: 0.7;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgb(0 0 0 / 88%);
    cursor: zoom-out;
}

.overlay img {
    max-width: min(96vw, 1600px);
    max-height: 94vh;
    object-fit: contain;
    border: 2px solid #f5f0e4;
    box-shadow: 0 0.5rem 2rem rgb(0 0 0 / 70%);
    cursor: default;
}

body.no-scroll {
    overflow: hidden;
}

noscript {
    display: block;
    padding: 1rem;
    color: #ffb4a8;
}

::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

::-webkit-scrollbar-track {
    background: #1d1a18;
}

::-webkit-scrollbar-thumb {
    background: #756a5c;
    border: 2px solid #1d1a18;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9a8b76;
}

@media (max-width: 700px) {
    body {
        font-size: 15px;
    }

    .heading-container {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0.6rem;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .site-header {
        padding: 0.9rem 0.6rem 0.55rem;
    }

    .container {
        width: 100%;
        margin-bottom: 0;
        padding: 0.55rem;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .controls {
        gap: 0.55rem;
    }

    .primary-controls {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.5rem;
        align-items: end;
    }

    .primary-controls > * {
        min-width: 0;
    }

    .primary-controls label[for='item-search'],
    #item-search,
    .table-status {
        grid-column: 1 / -1;
    }

    #item-search,
    #page-size,
    #toggle-columns,
    #basic-view {
        width: 100%;
    }

    select,
    button,
    .search-bar {
        min-height: 2.75rem;
    }

    .table-status {
        margin-left: 0;
        padding: 0.15rem 0;
    }

    .column-picker summary {
        width: 100%;
        min-height: 2.75rem;
        display: flex;
        align-items: center;
    }

    #checkbox-container {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-height: 18rem;
        gap: 0.55rem 0.7rem;
    }

    .column-option {
        min-width: 0;
        align-items: flex-start;
    }

    .column-checkbox {
        flex: 0 0 auto;
        width: 1.1rem;
        height: 1.1rem;
        margin-top: 0.05rem;
    }

    .column-label {
        overflow-wrap: anywhere;
    }

    .pagination {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.4rem;
        margin: 0.4rem 0;
    }

    .pagination span {
        grid-column: 1 / -1;
        grid-row: 1;
        min-width: 0;
    }

    .pagination button {
        width: 100%;
        min-width: 0;
        padding: 0.4rem 0.25rem;
    }

    .table-scrollbar {
        height: 18px;
        margin-bottom: 0.25rem;
    }

    .scroll-container {
        touch-action: pan-x pan-y;
        -webkit-overflow-scrolling: touch;
    }

    #itemsTable {
        min-width: max-content;
    }

    th,
    td {
        min-width: 7.25rem;
        max-width: 16rem;
        padding: 0.45rem 0.5rem;
        font-size: 0.9rem;
    }

    th:first-child,
    td:first-child {
        position: sticky;
        left: 0;
        z-index: 3;
        min-width: 10.5rem;
    }

    th:first-child {
        z-index: 4;
    }

    tbody tr:nth-child(odd) td:first-child {
        background: #2c2824;
    }

    tbody tr:nth-child(even) td:first-child {
        background: #3a342f;
    }

    tbody tr:hover td:first-child {
        background: #4d453d;
    }

    th:nth-child(2),
    td:nth-child(2) {
        min-width: 5.25rem;
        width: 5.25rem;
    }

    th:nth-child(3),
    td:nth-child(3) {
        min-width: 6.5rem;
        width: 6.5rem;
    }

    th:nth-child(4),
    td:nth-child(4),
    th:nth-child(5),
    td:nth-child(5),
    th:nth-child(8),
    td:nth-child(8),
    th:nth-child(11),
    td:nth-child(11) {
        min-width: 11rem;
    }

    .item-thumbnail {
        width: 64px;
        height: 64px;
    }

    .overlay {
        padding: 0.35rem;
    }

    .overlay img {
        max-width: 100%;
        max-height: 96vh;
    }
}

@media (max-width: 430px) {
    #checkbox-container {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.75rem;
    }
}
