:root {
    --bg: #0f1115;
    --card: #171a21;
    --line: #262b35;
    --accent: #4f8cff;
    --accent-2: #3a6fd6;
    --text: #e7ebf3;
    --muted: #8b93a3;
    --ok: #2ecc71;
    --err: #ff5d5d;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

/* ---------- Login ---------- */
.login-page {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 26px; }
.login-card .sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }

input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    background: #0c0e12;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    outline: none;
}
input[type="password"]:focus { border-color: var(--accent); }

button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
}
button:active { background: var(--accent-2); }

.alert {
    background: rgba(255, 93, 93, .12);
    border: 1px solid var(--err);
    color: #ffb3b3;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    margin-bottom: 14px;
}

/* ---------- Upload ---------- */
.bar {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    padding-top: max(16px, env(safe-area-inset-top));
    background: var(--card);
    border-bottom: 1px solid var(--line);
    font-weight: 600;
}
.bar .logout { color: var(--muted); text-decoration: none; font-size: 14px; }
.bar .logout:active { color: var(--accent); }
.bar .nav { display: flex; gap: 14px; align-items: center; }
.bar .nav a { color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 600; }
.bar .nav a.active { color: var(--text); }
.bar .nav a:active { color: var(--accent); }

main { padding: 18px; max-width: 720px; margin: 0 auto; }

#drop {
    display: block;
    border: 2px dashed var(--line);
    border-radius: 16px;
    background: var(--card);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
#drop.over { border-color: var(--accent); background: #1b2230; }
.drop-icon { font-size: 38px; }
.drop-text { font-size: 17px; font-weight: 600; margin-top: 8px; }
.drop-hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

.list { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 10px; }
.item {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
}
.item .meta { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .size { color: var(--muted); flex: none; }
.item .track {
    height: 6px;
    background: #0c0e12;
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0 6px;
}
.item .fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.item .state { font-size: 12px; color: var(--muted); }
.item.ok .fill { background: var(--ok); }
.item.ok .state { color: var(--ok); }
.item.err .fill { background: var(--err); }
.item.err .state { color: var(--err); }

/* ---------- Galerie ---------- */
.empty { color: var(--muted); text-align: center; margin-top: 48px; line-height: 1.6; }
.empty code { background: #0c0e12; padding: 2px 6px; border-radius: 6px; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    position: sticky;
    top: 56px;
    background: var(--bg);
    padding: 10px 0;
    z-index: 5;
}
.btn-ghost, .btn-primary {
    width: auto;
    padding: 10px 14px;
    font-size: 14px;
    border-radius: 10px;
    cursor: pointer;
}
.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
}
.btn-ghost:active { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border: none; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.count { color: var(--muted); font-size: 13px; margin-left: auto; }

.grid {
    list-style: none;
    padding: 0;
    margin: 14px 0 40px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}
.tile { display: flex; flex-direction: column; gap: 6px; }
.tile .thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 2px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: var(--card);
    cursor: pointer;
}
.tile .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: var(--muted);
}
.tile .fallback[hidden] { display: none; }
.tile .badge {
    position: absolute;
    left: 6px;
    bottom: 6px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: 12px;
    padding: 1px 7px;
    border-radius: 999px;
}
.tile .check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(15, 17, 21, .7);
    border: 2px solid #fff;
    color: #fff;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
    opacity: 0;
    transition: opacity .12s;
}
.tile.selected .thumb { border-color: var(--accent); }
.tile.selected .check { opacity: 1; background: var(--accent); border-color: var(--accent); }
.tile .cap { display: flex; flex-direction: column; font-size: 12px; line-height: 1.3; }
.tile .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .fsize { color: var(--muted); font-size: 11px; }
