:root {
    color-scheme: dark;
    font-family: Inter, system-ui, sans-serif;
    color: #fff;
    background: #0d1017;
    --canvas: #0d1017;
    --obsidian: #0a0d13;
    --surface: #161b26;
    --surface-recessed: #0f131d;
    --surface-raised: #121620;
    --border: #272f3e;
    --muted: #94a3b8;
    --amber: #f59e0b;
    --amber-hover: #fbbf24;
    --text: #fff;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--canvas);
    color: var(--text);
    font-family: Inter, system-ui, sans-serif;
}

body.upload-page,
body.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

body.dashboard-page {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
}

.container,
.auth-page main {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.container {
    max-width: 1000px;
    padding: 2rem;
}

.upload-page .container {
    max-width: 680px;
}

.auth-page main {
    max-width: 26rem;
    padding: 2rem;
}

h1,
h2,
h3 {
    color: var(--text);
}

.upload-page h1,
.auth-page h1 {
    text-align: center;
}

.auth-page h1 {
    margin-top: 0;
}

p,
li,
label,
.checkbox-container {
    color: var(--muted);
}

a {
    color: var(--amber);
}

a:hover {
    color: var(--amber-hover);
}

.top-nav {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
    margin: -2rem -2rem 1.5rem;
    padding: 0 1.5rem;
    border: 1px solid var(--border);
    border-width: 0 0 1px;
    background: var(--obsidian);
    flex-wrap: wrap;
}

.top-nav a {
    display: inline-flex;
    align-items: center;
    padding: 0.9rem 1rem calc(0.9rem - 2px);
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.top-nav a[aria-current="page"] {
    border-bottom-color: var(--amber);
    background: transparent;
    color: #fff;
}

.logout-form {
    display: flex;
    align-items: center;
    margin: 0 0 0 auto;
}

.logout-button,
.password-toggle {
    width: auto;
    margin: 0;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-recessed);
    color: var(--muted);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.how-to {
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-recessed);
}

.how-to h2 {
    margin: 0 0 0.75rem;
    color: #fff;
    font-size: 1.1rem;
}

.how-to ol {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--muted);
}

.how-to li + li {
    margin-top: 0.5rem;
}

.upload-zone {
    margin-bottom: 1.5rem;
    padding: 2rem;
    border: 2px dashed #3b4559;
    border-radius: 8px;
    background: #121620;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.upload-zone:hover,
.upload-zone.is-dragover {
    border-color: var(--amber);
    background: #1a1d22;
}

.upload-zone p {
    margin: 0;
    color: var(--muted);
}

.category-container,
.destination-container,
.naming-container,
.search-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.category-container label,
.destination-container label,
.naming-container label,
.search-container label,
.auth-page label {
    color: var(--muted);
    font-size: 0.9rem;
}

input:not([type="checkbox"]):not([type="file"]),
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-recessed);
    color: #fff;
    font: inherit;
}

.category-container input,
.destination-container select,
.naming-container select,
.naming-container input,
#fileSearch {
    border: 1px solid var(--border);
    background: var(--surface-recessed);
    color: #fff;
}

input::placeholder {
    color: #68758a;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 2px;
}

select option {
    background: var(--surface-recessed);
    color: #fff;
}

.checkbox-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.checkbox-container input {
    width: auto;
    accent-color: var(--amber);
    cursor: pointer;
}

.checkbox-container label {
    color: var(--muted);
    cursor: pointer;
    font-size: 0.9rem;
}

button,
.download-link {
    border: 0;
    border-radius: 6px;
    background: var(--amber);
    color: #0b0e14;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
}

button:hover,
.download-link:hover {
    background: var(--amber-hover);
    color: #0b0e14;
}

#submitBtn,
.auth-page form > button[type="submit"] {
    width: 100%;
    margin-top: 1.5rem;
    padding: 1rem;
    font-size: 1rem;
}

button:disabled {
    cursor: wait;
    opacity: 0.55;
}

.cleanup-button {
    margin: 0 0 1rem;
    padding: 0.65rem 1rem;
    border: 0;
    background: var(--amber);
    color: #0b0e14;
}

.delete-button {
    width: auto;
    margin: 0 0 0 0.4rem;
    padding: 0.45rem 0.7rem;
    border-radius: 5px;
    background: #9f2937;
    color: #fff;
    font-size: 0.85rem;
}

.delete-button:hover {
    background: #c33747;
    color: #fff;
}

.password-field {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.password-field input {
    flex: 1;
    min-width: 0;
}

.password-toggle {
    white-space: nowrap;
}

.auth-page label {
    display: block;
    margin: 1rem 0 0.4rem;
}

.auth-page .password-field + button {
    width: 100%;
}

#message,
#cleanupMessage {
    min-height: 1.5rem;
    margin-top: 1rem;
    text-align: center;
}

.success {
    color: #4ade80;
}

.error {
    color: #fb7185;
}

table {
    width: 100%;
    margin-top: 1rem;
    border-collapse: collapse;
}

th,
td {
    padding: 0.75rem;
    border-bottom: 1px solid #1f2633;
    color: var(--muted);
    text-align: left;
}

th {
    background: #121620;
    color: #fff;
}

tbody tr:hover {
    background: #1c2331;
}

.sort-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.sort-button:hover {
    background: transparent;
    color: var(--amber);
}

.sort-button::after {
    content: '↕';
    margin-left: 0.4rem;
    color: var(--muted);
    font-size: 0.85em;
}

th[aria-sort="ascending"] .sort-button::after {
    content: '↑';
    color: var(--amber);
}

th[aria-sort="descending"] .sort-button::after {
    content: '↓';
    color: var(--amber);
}

td:first-child {
    overflow-wrap: anywhere;
}

.download-link {
    display: inline-block;
    padding: 0.45rem 0.7rem;
    color: #0b0e14;
    text-decoration: none;
    white-space: nowrap;
}

.empty-state {
    padding: 1.5rem 0;
    color: var(--muted);
}

.auth-page main > p {
    text-align: center;
}

#fileSearch:focus {
    outline: 2px solid var(--amber);
    outline-offset: 1px;
}

@media (max-width: 600px) {
    .container {
        padding: 1.25rem;
    }

    .top-nav {
        margin: -1.25rem -1.25rem 1.5rem;
        padding: 0 0.75rem;
    }

    .top-nav a {
        padding-right: 0.65rem;
        padding-left: 0.65rem;
    }

    .logout-form {
        margin-left: auto;
    }

    th,
    td {
        padding: 0.6rem;
    }
}
