:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1a1d21;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --success-bg: #ecfdf5;
    --success-text: #065f46;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

body.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar h1 { margin: 0; font-size: 18px; }
.topbar-right { display: flex; gap: 18px; align-items: center; }

.logout {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
}
.logout:hover { color: var(--text); }

.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
}
.card.narrow { width: 100%; max-width: 380px; }
.card h1 { margin: 0 0 8px; font-size: 22px; }
.card h2 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 15px;
    margin-bottom: 12px;
}
input[type="password"]:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
}
button:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 14px;
}
.alert.success { background: var(--success-bg); color: var(--success-text); }
.alert.error { background: var(--error-bg); color: var(--error-text); }

.dropzone {
    display: block;
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    margin-bottom: 12px;
}
.dropzone:hover, .dropzone.hover {
    border-color: var(--accent);
    background: #f8faff;
}
.dropzone input[type="file"] { display: none; }
.dropzone-text strong { display: block; margin-bottom: 4px; }

.file-list {
    background: #f9fafb;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 13px;
}
.file-row { padding: 2px 0; }

.gallery {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.gallery-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card);
    display: flex;
    flex-direction: column;
}
.thumb {
    aspect-ratio: 1 / 1;
    background:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.ext-badge {
    font-weight: 700;
    color: var(--muted);
    font-size: 24px;
    letter-spacing: 1px;
}
.meta {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}
.filename {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.btn-small {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    width: auto;
}
.btn-small:hover { background: var(--accent-hover); }
.btn-small.danger { background: var(--danger); }
.btn-small.danger:hover { background: var(--danger-hover); }

.topbar-link {
    color: inherit;
    text-decoration: none;
}
.topbar-link:hover { color: var(--accent); }

.breadcrumb {
    max-width: 1100px;
    margin: 16px auto 0;
    padding: 0 20px;
    font-size: 13px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--border); }

.gallery-link {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
    height: 100%;
}
.gallery-item { transition: transform .12s, box-shadow .12s; }
.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.variant-card .variant-header {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.variant-preview {
    flex: 0 0 180px;
    aspect-ratio: 1 / 1;
    background:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: #fafafa;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.variant-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.variant-title h2 { margin: 0 0 4px; font-size: 20px; }

.downloads-heading {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
}
.file-list-detailed {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.file-row-detailed {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
}
.file-row-detailed:first-child { border-top: none; }
.file-row-detailed:hover { background: #f9fafb; }
.file-ext-badge {
    flex: 0 0 auto;
    min-width: 44px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-radius: 4px;
    background: #eef2f7;
    color: var(--muted);
}
.file-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}
.file-size {
    flex: 0 0 auto;
}

@media (max-width: 600px) {
    .variant-card .variant-header { flex-direction: column; align-items: flex-start; }
    .variant-preview { width: 100%; flex: none; }
    .file-row-detailed { flex-wrap: wrap; }
    .file-size { order: 3; }
}

.upload-help {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.55;
}
.upload-help summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}
.upload-help summary::-webkit-details-marker { display: none; }
.upload-help summary::before {
    content: "▾";
    font-size: 12px;
    color: var(--muted);
    transition: transform .15s;
}
.upload-help:not([open]) summary::before { transform: rotate(-90deg); }
.upload-help p { margin: 10px 0; }
.upload-help ul { margin: 8px 0 8px 20px; padding: 0; }
.upload-help li { margin: 4px 0; }
.upload-help code {
    background: #eef2f7;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 13px;
}
.upload-help pre {
    background: #1a2333;
    color: #e7ecf3;
    padding: 12px 14px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12.5px;
    line-height: 1.5;
    margin: 8px 0;
}
.upload-help pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.terms-dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 26px;
    background: var(--card);
    color: var(--text);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    font-family: inherit;
}
.terms-dialog::backdrop {
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}
.terms-dialog h3 {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}
.terms-dialog .disclaimer-text {
    max-height: 280px;
    overflow-y: auto;
    padding: 14px 16px;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
}
.terms-dialog .disclaimer-text p { margin: 0 0 10px; }
.terms-dialog .disclaimer-text p:last-child { margin-bottom: 0; }
.terms-dialog .disclaimer-text ul { margin: 8px 0 10px 18px; padding: 0; }
.terms-dialog .disclaimer-text li { margin: 4px 0; }
.disclaimer-check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 16px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.45;
}
.disclaimer-check input {
    margin-top: 3px;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.disclaimer-status { margin: 10px 0 0; }
.terms-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}
.terms-dialog-actions button {
    width: auto;
    padding: 8px 16px;
    font-size: 14px;
}
.terms-dialog-actions .btn-secondary {
    background: #ffffff;
    color: var(--text);
    border: 1px solid var(--border);
}
.terms-dialog-actions .btn-secondary:hover { background: #f3f4f6; }
