:root {
    --bg: #f5f6f8;
    --card: #fff;
    --text: #1d2330;
    --muted: #6b7280;
    --border: #dde1e7;
    --accent: #2563eb;
    --accent-soft: #e8efff;
    --danger: #c62828;
    --ok-bg: #e7f6ec;
    --ok-text: #1e6b3a;
    --error-bg: #fdecec;
    --error-text: #a12020;
    --private: #7c3aed;
    --private-soft: #f1eafe;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171c;
        --card: #1d2128;
        --text: #e6e8eb;
        --muted: #9aa3ae;
        --border: #2f3540;
        --accent: #6b9bff;
        --accent-soft: #1f2a40;
        --danger: #ff6b6b;
        --ok-bg: #173323;
        --ok-text: #8fdcaa;
        --error-bg: #3a1a1a;
        --error-text: #ffaaaa;
        --private: #b794ff;
        --private-soft: #2a2140;
    }
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }
h2 small { color: var(--muted); font-weight: normal; font-size: .7em; }
.muted { color: var(--muted); font-size: .9em; }

header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 12px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-size: 1.25rem; }
header h1 a { color: inherit; text-decoration: none; }
nav { display: flex; align-items: center; gap: 16px; }
nav a { text-decoration: none; }
nav a.active { font-weight: 600; text-decoration: underline; }
nav form { margin: 0; }

main { max-width: 860px; margin: 0 auto; padding: 16px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 20px;
}
.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.card h2 { margin-top: 0; }

.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 12px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--error-bg); color: var(--error-text); }

input[type=text], input[type=password] {
    width: 100%;
    padding: 9px 10px;
    font: inherit;
    color: inherit;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}
button, .button {
    display: inline-block;
    padding: 7px 12px;
    font: inherit;
    font-size: .9rem;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid transparent;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--accent); }
button[type=submit] { background: var(--accent); color: #fff; }
button.danger { color: var(--danger); background: transparent; border-color: var(--border); }
button.danger:hover { border-color: var(--danger); }
button.link { background: none; padding: 0; color: var(--accent); font-size: 1rem; }
button.link:hover { text-decoration: underline; border-color: transparent; }

.stack { display: grid; gap: 12px; }
.stack label { display: grid; gap: 4px; font-size: .9rem; }
label.check { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
form.inline input[type=text], form.inline input[type=password] { width: auto; flex: 1 1 160px; }

/* Zone d'envoi */
.dropzone {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 4px;
    padding: 32px 16px;
    margin-bottom: 24px;
    text-align: center;
    background: var(--card);
    border: 2px dashed var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { pointer-events: none; opacity: .7; }
.dropzone strong { font-size: 1.1rem; }
.dropzone small { color: var(--muted); margin-top: 6px; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* Listes */
.files, .users { list-style: none; margin: 0; padding: 0; }
.files li, .users li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
}
.users li { background: transparent; }
.info { display: grid; min-width: 0; flex: 1 1 240px; }
.info a { font-weight: 600; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions form { margin: 0; }
.badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    font-size: .75rem;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 4px;
}

/* Liens de partage */
select {
    padding: 8px 10px;
    font: inherit;
    font-size: .9rem;
    color: inherit;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.share-panel {
    flex: 1 1 100%;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}
.share-panel[hidden] { display: none; }
.links { list-style: none; margin: 10px 0 0; padding: 0; }
.files .links li {
    padding: 6px 0;
    margin: 0;
    background: none;
    border: 0;
    border-radius: 0;
}
.new-link { display: grid; gap: 8px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; }
.button.primary { background: var(--accent); color: #fff; }
.share-page .filename { overflow-wrap: anywhere; }
.share-page .actions { margin-top: 16px; }

/* Barre de progression */
.upload-progress { margin: -12px 0 24px; }
.upload-progress[hidden] { display: none; }
.bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }

/* Miniatures */
.thumb {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb.ext {
    display: grid;
    place-items: center;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .03em;
    color: var(--muted);
}
.files li .info { flex-basis: 200px; }

/* Visionneuse */
#lightbox {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(0, 0, 0, .92);
    color: #fff;
}
#lightbox[open] { display: grid; grid-template-rows: 1fr auto; }
#lightbox::backdrop { background: rgba(0, 0, 0, .6); }
#lightbox-img { place-self: center; max-width: calc(100vw - 32px); max-height: calc(100vh - 80px); object-fit: contain; }
.lightbox-bar { display: flex; align-items: center; gap: 16px; padding: 12px 16px; }
.lightbox-bar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-bar a { color: #fff; }
.lightbox-bar button { background: rgba(255, 255, 255, .15); color: #fff; }
#lightbox .nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px 16px;
    font-size: 2rem;
    line-height: 1;
    color: #fff;
    background: rgba(255, 255, 255, .12);
}
#lightbox .nav.prev { left: 12px; }
#lightbox .nav.next { right: 12px; }
#lightbox .nav[hidden] { display: none; }

/* Aperçu sur la page de partage */
.share-page .preview { display: block; max-width: 100%; max-height: 60vh; margin: 0 auto 16px; border-radius: 8px; }

/* Presse-papier */
textarea {
    width: 100%;
    padding: 10px;
    font: inherit;
    color: inherit;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    resize: vertical;
}
.clip-form { display: grid; gap: 10px; }
.form-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.clips { list-style: none; margin: 0; padding: 0; }
.clips li {
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.clip-text {
    max-height: 14em;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .9rem;
}
.clip-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }

/* Onglets Commun / Mes fichiers */
.tabs { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--border); }
.tabs a {
    padding: 8px 14px;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs a.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tabs small { margin-left: 4px; color: var(--muted); font-weight: normal; }

/* Espace de destination de l'envoi (Commun en bleu, privé en violet) */
.space-tabs { margin-bottom: 0; border-bottom: 0; }
.space-tabs a { font-size: 1.05rem; padding: 10px 16px; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; }
.space-tabs a.active { background: var(--accent-soft); border-color: var(--accent); border-bottom-color: transparent; }
.space-tabs a.private.active { background: var(--private-soft); border-color: var(--private); }
.dropzone { border-color: var(--accent); border-top-left-radius: 0; }
.dropzone .destination {
    padding: 4px 12px;
    font-weight: 700;
    color: var(--bg);
    background: var(--accent);
    border-radius: 999px;
}
.dropzone .audience { font-size: .85rem; color: var(--accent); margin-bottom: 8px; }
.dropzone.private { border-color: var(--private); background: var(--private-soft); }
.dropzone.private:hover, .dropzone.private.over { background: var(--private-soft); border-style: solid; }
.dropzone.private .destination { background: var(--private); }
.dropzone.private .audience { color: var(--private); }
