:root {
    --bg: #0f1115;
    --surface: #181b22;
    --surface-2: #20242e;
    --border: #2a2f3a;
    --text: #e8eaed;
    --muted: #9aa3b2;
    --accent: #4f8cff;
    --accent-hover: #6ba0ff;
    --danger: #e5534b;
    --ok: #3fb950;
    --radius: 12px;
    --maxw: 1180px;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---- Topbar ---- */
.topbar {
    background: linear-gradient(180deg, var(--surface), var(--bg));
    border-bottom: 1px solid var(--border);
    padding: 22px 0;
    margin-bottom: 28px;
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.brand { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.title { margin: 2px 0 0; font-size: 26px; font-weight: 650; }

/* ---- Cards / layout ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 24px;
}
.card h2 { margin-top: 0; font-size: 18px; }
.narrow { max-width: 440px; }

.centered {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.centered .card { width: 100%; text-align: center; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }
.footer-link { margin-top: 18px; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 8px 14px;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    text-decoration: none;
}
.btn:hover { background: #2a2f3a; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); color: #fff; }
.btn.big { padding: 12px 20px; font-size: 15px; font-weight: 600; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.danger { color: #ff8b84; border-color: #5a2c2a; }
.btn.danger:hover { background: #3a1f1d; }

/* ---- Forms ---- */
.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.grid-form label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 6px; }
.grid-form input, .grid-form select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 9px;
    padding: 9px 11px;
    font-size: 14px;
}
.grid-form input:focus, .grid-form select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form-actions { grid-column: 1 / -1; }

.pw-form { display: flex; gap: 10px; margin-top: 14px; }
.pw-form input {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 9px;
    padding: 10px 12px;
    font-size: 15px;
}

/* ---- Flash ---- */
.flash { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 22px; border: 1px solid var(--border); }
.flash.success { background: #14301c; border-color: #1f5130; }
.flash.error { background: #3a1f1d; border-color: #5a2c2a; }
.newlink { display: flex; gap: 8px; margin-top: 12px; }
.newlink input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: monospace;
    font-size: 13px;
}

/* ---- Table ---- */
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.tbl .actions { white-space: nowrap; }
.inline { display: inline; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #14301c; color: var(--ok); }
.badge.off { background: #3a1f1d; color: #ff8b84; }

/* ---- Gallery ---- */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
}
.tile {
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.thumb-link {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    background: var(--surface-2);
}
.thumb-link img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dl-badge {
    position: absolute;
    right: 8px; bottom: 8px;
    background: rgba(0,0,0,.6);
    color: #fff;
    border-radius: 8px;
    padding: 4px 9px;
    font-size: 14px;
    opacity: 0;
    transition: opacity .15s;
}
.thumb-link:hover .dl-badge { opacity: 1; }
.tile figcaption {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 11px;
    font-size: 12.5px;
}
.tile .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .fsize { color: var(--muted); flex-shrink: 0; }

.section-title { font-size: 16px; margin: 28px 0 12px; }

/* ---- Lightbox ---- */
.lb {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lb[hidden] { display: none; }
.lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.92);
    cursor: zoom-out;
}
.lb-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: calc(100vw - 120px);
    max-height: 100vh;
    gap: 14px;
    padding: 20px 0;
}
.lb-spinner {
    position: absolute;
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255,255,255,.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lb-spin .7s linear infinite;
}
.lb-spinner[hidden] { display: none; }
@keyframes lb-spin { to { transform: rotate(360deg); } }

.lb-img {
    transition: opacity .2s;
    max-width: 100%;
    max-height: calc(100vh - 100px);
    object-fit: contain;
    border-radius: 8px;
    display: block;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.lb-caption {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
}
.lb-name { font-size: 14px; color: #fff; }
.lb-size { font-size: 13px; }
.lb-close, .lb-prev, .lb-next {
    position: fixed;
    z-index: 2;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,.2); }
.lb-close { top: 18px; right: 18px; width: 40px; height: 40px; font-size: 18px; }
.lb-prev  { left: 14px;  top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 28px; }
.lb-next  { right: 14px; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 28px; }

/* Thumbnail hover — kein Download-Badge mehr, Cursor zeigt Lupe */
.thumb-link { cursor: zoom-in; }
.dl-badge { display: none; }

/* ---- File list ---- */
.filelist { list-style: none; padding: 0; margin: 0; }
.filelist li { border-bottom: 1px solid var(--border); }
.filelist a {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 4px;
    color: var(--text);
}
.filelist a:hover { color: var(--accent); }
.filelist .fsize { color: var(--muted); flex-shrink: 0; }

/* ---- Disk / storage ---- */
.card-warn { border-color: #7a5c1a; }
.card-crit { border-color: #5a2c2a; }
.badge.warn { background: #3a2e10; color: #e3a020; }

.disk-bar-wrap { display: flex; align-items: center; gap: 12px; margin: 10px 0 6px; }
.disk-bar {
    flex: 1;
    height: 10px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.disk-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.disk-bar-fill.warn { background: #e3a020; }
.disk-bar-fill.crit { background: var(--danger); }
.disk-pct { font-size: 13px; color: var(--muted); width: 38px; text-align: right; flex-shrink: 0; }
.disk-stats { display: flex; gap: 20px; font-size: 13px; color: var(--muted); margin-bottom: 16px; flex-wrap: wrap; }
.disk-stats strong { color: var(--text); }

.storage-tbl { margin-top: 4px; }
.tbl-sum td { border-top: 2px solid var(--border); padding-top: 10px; }

/* ---- Folder list (admin) ---- */
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.card-head h2 { margin: 0; }
.folderlist { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.folder {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px 14px;
}
.folder > summary {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 10px 0;
    list-style: none;
    font-weight: 600;
}
.folder > summary::-webkit-details-marker { display: none; }
.folder > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.folder[open] > summary::before { transform: rotate(90deg); }
.folder > summary .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-form { padding: 6px 0 16px; border-top: 1px solid var(--border); margin-top: 10px; padding-top: 14px; }

.folder-links { display: flex; flex-direction: column; gap: 8px; padding: 10px 0 4px; }
.folder-link-row {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.folder-link-row.row-off { opacity: .6; }
.folder-link-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.folder-link-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.link-input {
    flex: 1;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 7px;
    padding: 5px 9px;
    font-family: monospace;
    font-size: 12px;
}
.badge.small { font-size: 11px; padding: 1px 7px; }

.foot { padding: 30px 20px; text-align: center; }
