:root {
  --bg: #0b0e13;
  --bg-soft: #131820;
  --panel: #171d27;
  --panel-2: #1e2531;
  --line: #2a3341;
  --line-soft: #212938;
  --text: #e7ecf3;
  --muted: #8b97a8;
  --dim: #626e7f;
  --accent: #4cc2ff;
  --accent-dim: #1d5f80;
  --ok: #46d18a;
  --warn: #f0b849;
  --bad: #ff6b6b;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }

/* --- Écran de connexion --------------------------------------------------- */

#login {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1000px 600px at 50% -10%, #16202c 0%, var(--bg) 60%);
}

.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.login-card h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.2px; }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 13.5px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

input[type=text], input[type=password], input[type=search], select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(76, 194, 255, .12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #262f3d; border-color: #3a465a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06202e; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #6fcfff; border-color: #6fcfff; }
.btn.danger:hover:not(:disabled) { background: #3a2028; border-color: #6d3038; color: #ffb3b3; }
.btn.wide { width: 100%; }
.btn.small { padding: 6px 11px; font-size: 13px; }

.error {
  margin-top: 12px;
  padding: 9px 12px;
  background: #351d22;
  border: 1px solid #5e2b33;
  border-radius: 8px;
  color: #ffb3b3;
  font-size: 13.5px;
}

/* --- En-tête -------------------------------------------------------------- */

header.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 9px; font-weight: 650; letter-spacing: -.2px; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); align-self: center; }
.brand small { color: var(--dim); font-weight: 400; font-size: 12px; }

.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  padding: 7px 14px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { background: var(--panel-2); border-color: var(--line); color: var(--text); }
.tab .badge {
  margin-left: 6px; padding: 1px 6px; border-radius: 20px;
  background: var(--accent-dim); color: #cdeeff; font-size: 11px; font-weight: 600;
}

.spacer { flex: 1; }

.quota { min-width: 190px; }
.quota .bar { height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.quota .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7ad3ff); transition: width .4s; }
.quota .bar i.warn { background: linear-gradient(90deg, var(--warn), #ffd98a); }
.quota .bar i.full { background: linear-gradient(90deg, var(--bad), #ff9f9f); }
.quota .lbl { font-size: 11.5px; color: var(--dim); margin-bottom: 4px; display: flex; justify-content: space-between; gap: 10px; }

.who { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted); }
.avatar {
  width: 27px; height: 27px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-dim); color: #d6f0ff;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}

main { flex: 1; overflow: auto; padding: 20px; }
.wrap { max-width: 1500px; margin: 0 auto; }

/* --- Dépôt ---------------------------------------------------------------- */

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.row label.inline { color: var(--muted); font-size: 13px; }
.row select { width: auto; min-width: 190px; }

#dropzone {
  border: 2px dashed var(--line);
  border-radius: 18px;
  padding: 64px 24px;
  text-align: center;
  background: linear-gradient(180deg, rgba(76, 194, 255, .02), transparent);
  transition: border-color .18s, background .18s, transform .18s;
}
#dropzone.hot {
  border-color: var(--accent);
  background: rgba(76, 194, 255, .07);
  transform: scale(1.005);
}
#dropzone .icon { font-size: 40px; line-height: 1; opacity: .75; margin-bottom: 14px; }
#dropzone h2 { margin: 0 0 6px; font-size: 19px; font-weight: 600; letter-spacing: -.2px; }
#dropzone p { margin: 0; color: var(--muted); font-size: 13.5px; }
#dropzone .hint { margin-top: 10px; font-size: 12.5px; color: var(--dim); }

.queue { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }
.queue-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.queue-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); }

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}
.item .nm { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .st { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item .track { grid-column: 1 / -1; height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.item .track i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.item.hashing .track i { background: var(--dim); }
.item.done .track i { background: var(--ok); }
.item.failed .track i { background: var(--bad); }
.item.done .st { color: var(--ok); }
.item.failed .st { color: var(--bad); }

/* --- Galerie -------------------------------------------------------------- */

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
/* La règle générale met les champs en pleine largeur, ce qui est voulu dans un
   formulaire mais casse l'alignement d'une barre d'outils horizontale. */
.toolbar select { width: auto; min-width: 175px; max-width: 280px; }
.toolbar input[type=search] { width: 240px; }
.toolbar .count { color: var(--dim); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
}

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, transform .12s;
}
.card:hover { border-color: #3a465a; }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card .shot {
  aspect-ratio: 4 / 3;
  background: var(--bg-soft) center/cover no-repeat;
  display: grid; place-items: center;
  color: var(--dim);
}
.card .shot .ext {
  font-size: 12px; font-weight: 700; letter-spacing: .1em;
  padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel-2);
}
.card .meta { padding: 8px 10px 9px; }
.card .meta .nm { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta .sub { font-size: 11px; color: var(--dim); margin-top: 2px; display: flex; gap: 6px; }
.card .tick {
  position: absolute; top: 8px; left: 8px;
  width: 21px; height: 21px; border-radius: 6px;
  background: rgba(11, 14, 19, .72); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 12px; color: transparent;
  backdrop-filter: blur(4px);
}
.card.sel .tick { background: var(--accent); border-color: var(--accent); color: #06202e; font-weight: 800; }

.empty { text-align: center; padding: 70px 20px; color: var(--dim); }

/* --- Barre de sélection --------------------------------------------------- */

.actionbar {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 16px -20px -20px;
  padding: 13px 20px;
  background: rgba(19, 24, 32, .93);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.actionbar .n { font-weight: 600; }
.actionbar .sz { color: var(--muted); font-size: 13px; }

/* --- Visionneuse ---------------------------------------------------------- */

#lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 7, 10, .93);
  display: flex; flex-direction: column;
  backdrop-filter: blur(3px);
}
#lightbox .lb-top {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--line-soft);
}
#lightbox .lb-top .nm { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lightbox .lb-body { flex: 1; display: flex; min-height: 0; }
#lightbox .lb-stage {
  flex: 1; display: grid; place-items: center; padding: 20px; min-width: 0;
}
#lightbox .lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
#lightbox .lb-stage .none { color: var(--dim); text-align: center; }
#lightbox .lb-side {
  width: 296px; flex-shrink: 0;
  border-left: 1px solid var(--line-soft);
  padding: 18px; overflow: auto;
}
#lightbox .nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 42px; height: 62px; display: grid; place-items: center;
  background: rgba(23, 29, 39, .8); border: 1px solid var(--line);
  border-radius: 9px; cursor: pointer; font-size: 20px; color: var(--muted);
}
#lightbox .nav:hover { color: var(--text); background: var(--panel-2); }
#lightbox .nav.prev { left: 14px; }
#lightbox .nav.next { right: 330px; }

.kv { display: grid; grid-template-columns: 84px 1fr; gap: 7px 10px; font-size: 12.5px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); }
.side-h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 20px 0 9px; }
.side-h:first-child { margin-top: 0; }

/* --- Fenêtres modales ----------------------------------------------------- */

.modal-bg {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(5, 7, 10, .72);
  display: grid; place-items: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
  max-height: 85vh; overflow: auto;
}
.modal h3 { margin: 0 0 4px; font-size: 16px; }
.modal p.sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.modal .actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }

.copyrow { display: flex; gap: 8px; }
.copyrow input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.share-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 10px; margin-bottom: 8px;
}
.share-item .info { flex: 1; min-width: 0; }
.share-item .info .t { font-size: 13.5px; }
.share-item .info .s { font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.share-item.dead { opacity: .5; }

.chips { display: flex; gap: 7px; }
.chip {
  padding: 7px 13px; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; font-size: 13px; transition: all .15s;
}
.chip.on { background: var(--accent-dim); border-color: var(--accent); color: #d6f0ff; }

.toast-host {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 17px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); font-size: 13.5px;
  animation: rise .2s ease-out;
}
.toast.bad { border-color: #6d3038; background: #351d22; color: #ffb3b3; }
.toast.good { border-color: #235c42; background: #14291f; color: #a9edc9; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 820px) {
  #lightbox .lb-body { flex-direction: column; }
  #lightbox .lb-side { width: auto; border-left: none; border-top: 1px solid var(--line-soft); max-height: 42%; }
  #lightbox .nav.next { right: 14px; }
  .toolbar input[type=search] { width: 100%; }
  header.top { gap: 10px; }
  .quota { flex: 1; min-width: 140px; }
}
