/* Médiathèque — styles de l'admin (inspiré de l'admin SIB) */
:root {
  --bg: #f5f2ee;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6e6a65;
  --line: #e7e1d9;
  --line-strong: #d6cec3;
  --red: #b3221b;
  --red-dark: #951a14;
  --active-bg: #f3ede6;
  --green: #2f7a4a;
  --orange: #b8670e;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .04), 0 4px 18px rgba(40, 30, 20, .04);
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --sidebar-w: 230px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.55; }
a { color: inherit; }
img { max-width: 100%; }
code { font-size: .9em; background: var(--active-bg); padding: 1px 5px; border-radius: 4px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.text-red { color: var(--red); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.mb { margin-bottom: 18px; }
.mt { margin-top: 18px; }
.break { word-break: break-all; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.smallcaps { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.inline { display: inline; }
[hidden] { display: none !important; }

/* ---------- Sidebar (admin) ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 22px 22px 10px; }
.brand-mark { font-weight: 800; font-size: 36px; letter-spacing: -.04em; color: var(--red); line-height: 1; }
.brand-text { font-weight: 800; font-size: 15px; letter-spacing: .02em; }
.nav { padding: 8px 0 18px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 4px 22px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #4a4642;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-chev { display: inline-block; transition: transform .15s; font-size: 13px; width: 8px; }
.nav-group[open] .nav-chev { transform: rotate(90deg); }
.nav-leader { flex: 1; border-bottom: 2px dotted var(--line-strong); margin: 0 2px 3px 6px; }
.nav-count { font-size: 11px; }
.nav-group[open] .nav-leader, .nav-group[open] .nav-count { display: none; }
.nav-link { display: block; padding: 7px 22px; font-weight: 700; font-size: 14px; text-decoration: none; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link:hover { background: #faf7f3; }
.nav-link.is-active { color: var(--red); background: var(--active-bg); }
.nav-tools { display: flex; gap: 12px; padding: 18px 22px 0; }
button.link, a.link { background: none; border: 0; padding: 0; font: inherit; font-size: 12px; font-weight: 600; color: var(--text); text-decoration: underline; cursor: pointer; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot strong { font-size: 15px; }
.foot-link { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; text-decoration: none; margin: 12px 0 10px; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; vertical-align: 1px; }
.nav-burger { display: none; }

/* ---------- Main ---------- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; padding: 40px 32px 110px; }
.container { max-width: 1104px; margin: 0 auto; }
.container.wide { max-width: 1280px; }
.crumbs { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-head h1 { font-size: 32px; font-weight: 800; text-transform: uppercase; letter-spacing: .005em; word-break: break-word; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.intro { max-width: 770px; color: #57524d; font-size: 15.5px; line-height: 1.7; margin: 0 0 28px; }
.section-title { font-size: 19px; font-weight: 800; text-transform: uppercase; margin: 40px 0 16px; }
.section-head { margin-top: 40px; margin-bottom: 14px; }
.section-head .section-title { margin: 0; }
.sub-title { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: 22px 0 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 16px; border: 1px solid rgba(0,0,0,.02); }
.card.empty { padding: 28px; }
.steps { margin: 10px 0 0; padding-left: 20px; }
.steps li { margin: 4px 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: inherit;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; text-decoration: none;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 2px solid var(--text); background: var(--surface);
  color: var(--text); cursor: pointer; transition: background .15s, color .15s, border-color .15s; white-space: nowrap; line-height: 1.1;
}
.btn:hover { background: var(--text); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 11.5px; border-radius: 8px; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; padding: 13px 34px; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-primary.btn-sm { padding: 7px 14px; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-soft { border-width: 1px; border-color: var(--line-strong); }
.btn-soft:hover { border-color: var(--text); }

/* ---------- Forms ---------- */
.form .field, .field { margin-bottom: 16px; }
.field > label, .field label:not(.check):not(.dropzone) { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 7px; }
.hint { font-weight: 500; font-size: 11.5px; color: var(--muted); }
p.hint { margin: 6px 0 0; font-size: 12.5px; }
.input {
  width: 100%; font: inherit; font-size: 15px; color: var(--text); background: #fff;
  border: 1px solid #cfc9c1; border-radius: 8px; padding: 10px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--text); box-shadow: 0 0 0 3px rgba(28, 28, 30, .08); }
.input[readonly] { background: #faf8f5; }
.input-sm { padding: 7px 10px; font-size: 13.5px; }
textarea.input { resize: vertical; min-height: 64px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #555 50%), linear-gradient(135deg, #555 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.grid-2.tight { gap: 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 2px 0 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--red); }
.form-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.searchbar, .filters { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.searchbar .input { flex: 1; min-width: 220px; }
.filters .input[type=search] { flex: 2; min-width: 200px; }
.filters select.input { flex: 1; min-width: 150px; width: auto; }

/* ---------- Accordéons numérotés ---------- */
.acc { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; border: 1px solid rgba(0,0,0,.02); }
.acc > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 16px 20px; user-select: none;
}
.acc > summary::-webkit-details-marker { display: none; }
.acc-chev { color: var(--red); font-weight: 700; font-size: 18px; width: 10px; transition: transform .15s; line-height: 1; }
.acc[open] > summary .acc-chev { transform: rotate(90deg); }
.acc-num { font-size: 12.5px; font-weight: 800; color: #57524d; min-width: 18px; }
.acc-title { font-weight: 700; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.acc-toggle::after { content: "Déplier"; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #57524d; }
.acc[open] > summary .acc-toggle::after { content: "Replier"; }
.acc-body { padding: 4px 22px 22px 66px; border-top: 1px dashed var(--line); padding-top: 20px; }
.acc-add { background: transparent; box-shadow: none; border: 2px dashed var(--line-strong); }
.acc-add[open] { background: var(--surface); border-style: solid; border-color: var(--line); }
.acc-danger .acc-num, .acc-danger .acc-title { color: var(--red); }
.acc-static { padding: 12px 20px; }
.acc-row { display: flex; align-items: center; gap: 16px; }
.acc-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--active-bg); }
.acc-grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.note-form { display: flex; align-items: center; gap: 10px; }

/* ---------- Barre d'enregistrement ---------- */
.savebar { position: sticky; bottom: 16px; display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; z-index: 5; }
.savebar .btn-primary { box-shadow: 0 6px 20px rgba(179, 34, 27, .25); }

/* ---------- Flash ---------- */
.flash { padding: 13px 18px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 600; font-size: 14px; background: #e9f3ec; color: #1e5a33; border: 1px solid #cfe5d6; }
.flash-error { background: #fbeceb; color: var(--red-dark); border-color: #f1cfcd; }

/* ---------- Pills, chips ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .03em; background: var(--active-bg); color: #57524d; white-space: nowrap; }
.pill-nouvelle { background: var(--red); color: #fff; }
.pill-en_cours { background: #fbeedc; color: var(--orange); }
.pill-traitee { background: #e3f1e8; color: var(--green); }
.pill-off { background: #ece8e2; color: #6e6a65; }
.pill-com { background: #eef0f6; color: #3c4a74; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 4px 11px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line-strong); font-size: 12px; font-weight: 600; text-decoration: none; color: var(--text); }
.chip-soft { background: transparent; border-style: dashed; }
a.chip:hover { border-color: var(--text); }
.chip.is-on { background: var(--text); color: #fff; border-color: var(--text); }

/* ---------- Stats & listes ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 8px; }
.stat { display: flex; flex-direction: column; gap: 4px; text-decoration: none; margin: 0; }
.stat-n { font-size: 34px; font-weight: 800; line-height: 1; }
.stat-alert .stat-n { color: var(--red); }
.list { padding: 6px 0; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 22px; text-decoration: none; border-bottom: 1px solid var(--line); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: #fcfaf7; }
.list-row .muted { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-date { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 0 0 6px; font-size: 14px; }
.dl dt { font-weight: 700; }
.dl dd { margin: 0; color: #46423e; }

/* ---------- Clients ---------- */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.client-card { text-decoration: none; margin: 0; transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; gap: 12px; }
.client-card:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(40, 30, 20, .08); }
.client-card-head { display: flex; align-items: center; gap: 12px; }
.client-card-head > div { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.client-card-head strong { font-size: 16px; }
.client-initial { width: 42px; height: 42px; border-radius: 10px; background: var(--active-bg); color: var(--red); font-weight: 800; font-size: 19px; display: grid; place-items: center; flex: none; }

/* ---------- Sources ---------- */
.source-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.source-type { cursor: pointer; }
.source-type input { position: absolute; opacity: 0; pointer-events: none; }
.source-type-box { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 2px solid var(--line); border-radius: var(--radius-sm); height: 100%; transition: border-color .15s; }
.source-type input:checked + .source-type-box { border-color: var(--text); background: #fcfaf7; }
.source-type input:focus-visible + .source-type-box { box-shadow: 0 0 0 3px rgba(28,28,30,.12); }
.dropzone { display: block; border: 2px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 28px; text-align: center; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; position: relative; }
.dropzone:hover, .dropzone.is-over { border-color: var(--text); color: var(--text); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Galerie ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.tile { position: relative; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; border: 2px solid transparent; transition: border-color .15s; }
.tile.is-hidden .tile-media img { opacity: .45; }
.tile.is-selected { border-color: var(--red); }
.tile-media { display: block; border: 0; padding: 0; margin: 0; background: #efebe5 repeating-conic-gradient(#f5f2ee 0 25%, #ece7e0 0 50%) 0 0 / 16px 16px; aspect-ratio: 1 / 1; cursor: zoom-in; position: relative; width: 100%; }
.tile-media { overflow: hidden; }
.tile-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-play { position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; font-size: 17px; padding-left: 3px; pointer-events: none; }
.tile-info { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile-name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ext { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; color: var(--muted); }
.tile-check { position: absolute; top: 8px; left: 8px; z-index: 2; background: rgba(255,255,255,.92); border-radius: 6px; padding: 4px 5px 1px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.tile-check input { width: 16px; height: 16px; accent-color: var(--red); cursor: pointer; }
.tile-select { position: absolute; top: 8px; right: 8px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--text); background: rgba(255,255,255,.95); font-size: 19px; font-weight: 700; cursor: pointer; display: grid; place-items: center; line-height: 1; padding: 0; color: var(--text); }
.tile-select:hover { background: var(--text); color: #fff; }
.tile-select .when-on { display: none; }
.tile.is-selected .tile-select { background: var(--red); border-color: var(--red); color: #fff; }
.tile.is-selected .tile-select .when-on { display: inline; }
.tile.is-selected .tile-select .when-off { display: none; }
.bulkbar { position: sticky; top: 10px; z-index: 6; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface); border-radius: var(--radius); box-shadow: 0 6px 24px rgba(40,30,20,.12); padding: 12px 16px; margin-bottom: 14px; }
.bulkbar .input { width: auto; flex: 1; min-width: 160px; padding: 7px 10px; font-size: 13.5px; }
.pager { display: flex; gap: 6px; justify-content: center; margin: 26px 0 0; flex-wrap: wrap; }
.pager a { min-width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; text-decoration: none; font-weight: 700; font-size: 13px; background: var(--surface); }
.pager a.is-active { background: var(--text); color: #fff; }

/* ---------- Modal (fiche / visionneuse) ---------- */
.modal { border: 0; padding: 0; border-radius: 18px; width: min(1180px, 96vw); max-height: 92vh; background: var(--surface); box-shadow: 0 30px 80px rgba(0,0,0,.35); color: var(--text); }
.modal::backdrop { background: rgba(28, 24, 20, .62); }
.modal-inner { display: grid; grid-template-columns: 1fr 380px; max-height: 92vh; position: relative; }
.modal-preview { background: #1d1b19; display: grid; place-items: center; min-height: 420px; max-height: 92vh; overflow: hidden; }
.modal-preview img, .modal-preview video { max-width: 100%; max-height: 92vh; display: block; object-fit: contain; }
.modal-preview iframe { width: 100%; height: 88vh; border: 0; background: #fff; }
.modal-preview .preview-note { color: #ddd; text-align: center; padding: 20px; font-size: 14px; }
.modal-preview .preview-note img { max-height: 50vh; margin: 0 auto 14px; }
.modal-side { padding: 28px 24px 24px; overflow-y: auto; max-height: 92vh; display: flex; flex-direction: column; gap: 8px; }
.modal-side h3 { font-size: 19px; font-weight: 800; word-break: break-word; padding-right: 30px; }
.modal-close { position: absolute; top: 12px; right: 14px; z-index: 3; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--active-bg); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.85); font-size: 26px; cursor: pointer; line-height: 1; }
.modal-nav.prev { left: 12px; }
.modal-nav.next { left: calc(100% - 380px - 54px); }
.comments { display: flex; flex-direction: column; gap: 8px; }
.comment { background: #faf7f3; border-radius: 10px; padding: 9px 12px; font-size: 13.5px; }
.comment.from-admin { background: #eef0f6; }
.comment p { margin: 2px 0 0; white-space: pre-wrap; }
.comment-meta { font-size: 11.5px; color: var(--muted); }
.comment-row { display: flex; gap: 16px; padding: 14px 22px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.comment-row:last-child { border-bottom: 0; }
.comment-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--active-bg); }
.comment-body { flex: 1; min-width: 0; }
.comment-body p { margin: 0 0 4px; }

/* ---------- Demandes ---------- */
.req-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.req-item { display: flex; gap: 12px; align-items: flex-start; background: #faf7f3; border-radius: 10px; padding: 10px; font-size: 13.5px; }
.req-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: #fff; flex: none; }
.req-item > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.req-item strong { overflow-wrap: anywhere; }
.note { margin: 4px 0; font-style: italic; color: #46423e; }
.reply { background: #e3f1e8; border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; }
.reply p { margin: 4px 0 0; }

/* ---------- Pages d'authentification ---------- */
body.is-auth { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.auth-box { width: min(420px, 100%); }
.auth-box .brand { padding: 0 0 22px; justify-content: center; }
.auth-box h1 { font-size: 28px; font-weight: 800; text-transform: uppercase; text-align: center; margin-bottom: 10px; }
.auth-box > p { text-align: center; margin: 0 0 20px; }
.auth-box .card { padding: 26px; }

/* ---------- Espace client ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 28px; position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.topbar .brand { padding: 14px 0; }
.brand-client { display: flex; flex-direction: column; line-height: 1.2; }
.brand-client strong { font-size: 16px; }
.topnav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topnav-link { padding: 8px 12px; border-radius: 8px; font-weight: 700; font-size: 14px; text-decoration: none; }
.topnav-link:hover { background: #faf7f3; }
.topnav-link.is-active { color: var(--red); background: var(--active-bg); }
.topnav form { margin-left: 8px; }
.espace-main { padding: 40px 28px 80px; }
.espace-foot { text-align: center; padding: 0 20px 30px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.lib-card { padding: 0; overflow: hidden; text-decoration: none; margin: 0; transition: transform .15s, box-shadow .15s; }
.lib-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(40,30,20,.1); }
.lib-cover { aspect-ratio: 16 / 10; display: grid; gap: 2px; background: var(--active-bg); }
.lib-cover img { width: 100%; height: 100%; object-fit: cover; display: block; min-height: 0; }
.lib-cover.cover-2 { grid-template-columns: 1fr 1fr; }
.lib-cover.cover-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.lib-cover.cover-3 img:first-child { grid-row: span 2; }
.lib-empty { display: grid; place-items: center; color: var(--muted); font-weight: 600; }
.lib-info { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 4px; }
.lib-info strong { font-size: 18px; font-weight: 800; }
.lib-info .chips { margin-top: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .modal-inner { grid-template-columns: 1fr; overflow-y: auto; }
  .modal-preview { min-height: 280px; max-height: 60vh; }
  .modal-preview img, .modal-preview video { max-height: 60vh; }
  .modal-side { max-height: none; overflow: visible; }
  .modal-nav { top: 30vh; }
  .modal-nav.next { left: auto; right: 12px; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  body.nav-open .sidebar { transform: none; }
  .nav-burger { display: grid; place-items: center; position: fixed; top: 12px; left: 12px; z-index: 30; width: 42px; height: 42px; border-radius: 10px; border: 2px solid var(--text); background: var(--surface); font-size: 18px; cursor: pointer; }
  .main { margin-left: 0; padding: 70px 16px 100px; }
  .page-head { flex-direction: column; }
  .page-head h1 { font-size: 25px; }
  .grid-2, .grid-3, .source-types { grid-template-columns: 1fr; }
  .acc-body { padding: 16px; }
  .acc > summary { padding: 14px 14px; gap: 10px; }
  .acc-meta { display: none; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .topbar { padding: 0 16px; }
  .espace-main { padding: 26px 16px 60px; }
  .list-row { flex-wrap: wrap; padding: 12px 16px; }
  .list-row .muted { white-space: normal; flex-basis: 100%; order: 3; }
  .stats { grid-template-columns: 1fr 1fr; }
  .acc-row { flex-wrap: wrap; }
}

/* ---------- V2 : droits, versions, validation, conversions ---------- */
.pill-pending { background: #fbeedc; color: var(--orange); }
.pill-rights-expired { background: #fbeceb; color: var(--red-dark); }
.pill-rights-soon { background: #fff4d6; color: #8a6100; }
.pill-official { background: var(--text); color: #fff; }
.alert { border-radius: 10px; padding: 10px 14px; font-size: 13.5px; font-weight: 600; background: var(--active-bg); display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.alert-expired { background: #fbeceb; color: var(--red-dark); }
.alert-soon { background: #fff4d6; color: #8a6100; }
.alert-pending { background: #fbeedc; color: #7a4508; }
.export { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 10px; }
.export .input { width: auto; flex: 1; min-width: 110px; }
.versions { display: flex; flex-direction: column; gap: 6px; }
.version { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: #faf7f3; font-size: 13px; }
.version > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.version strong { overflow-wrap: anywhere; }
.version.is-official { background: #fff; border: 2px solid var(--text); }
.version .btn-row { align-items: center; flex-wrap: nowrap; }
.sub-acc { margin: 6px 0 12px; }
.sub-acc > summary { cursor: pointer; font-weight: 700; font-size: 13.5px; padding: 6px 0; }
.sub-acc[open] > summary { margin-bottom: 10px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset[disabled] .input { background: #faf8f5; }
.dl-compact { grid-template-columns: 120px 1fr; font-size: 13px; gap: 4px 12px; }
.row-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--active-bg); flex: none; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.list-row .list-date { display: inline-flex; gap: 8px; align-items: center; }
.roles-help .dl { margin: 0; }
.modal-nav.next { left: calc(100% - 380px - 54px); }
@media (max-width: 1100px) { .modal-nav.next { left: auto; right: 12px; } }

/* ---------- Médiathèque : espaces, recherche, identité de marque ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { padding: 8px 16px; border-radius: 20px; text-decoration: none; font-weight: 600; font-size: 13px; background: var(--surface); border: 1px solid var(--line); }
.tab.is-active { background: var(--red); border-color: var(--red); color: #fff; }
.kind-pill { vertical-align: middle; font-size: 11px; }
.client-initial.kind-projet { color: #2f6f8f; }
.client-initial.kind-perso { color: var(--green); }
.chip.is-active { background: var(--red); border-color: var(--red); color: #fff; }
.chip.is-active .muted { color: #fff; }
a.tile { text-decoration: none; color: inherit; }
a.tile .tile-meta { display: flex; gap: 6px; align-items: center; min-width: 0; }

.mini-swatches { display: flex; gap: 4px; margin-top: 10px; }
.mini-swatches span { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, .08); }
.mini-swatches.lg span { width: 28px; height: 28px; border-radius: 7px; }
.brand-teaser { display: flex; align-items: center; gap: 22px; padding: 18px 22px; text-decoration: none; margin-bottom: 8px; }
.brand-teaser > div:first-child { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.brand-teaser .mini-swatches { margin: 0; }
.brand-teaser:hover { border-color: var(--line-strong); }

.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.swatch { padding: 0; overflow: hidden; }
.swatch-color { height: 120px; padding: 14px 16px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; border-bottom: 1px solid var(--line); }
.swatch-color strong { font-size: 16px; }
.swatch-color span { font-size: 12px; opacity: .85; }
.swatch-values { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; padding: 12px 16px 14px; font-size: 13px; }
.swatch-values dt { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); align-self: center; }
.swatch-values dd { margin: 0; }
.copyable { font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: none; border: 0; padding: 1px 4px; margin: 0 -4px; border-radius: 4px; cursor: copy; color: inherit; text-align: left; }
.copyable:hover { background: var(--active-bg); }
.copyable.is-copied { background: #e4f1e8; color: var(--green); }
.copyable.is-copied::after { content: " ✓ copié"; font-family: var(--font); font-size: 11px; font-weight: 700; }

.font-row { display: flex; align-items: center; gap: 24px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.font-row:last-child { border-bottom: 0; }
.font-sample { font-size: 30px; line-height: 1.1; min-width: 260px; }
.font-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.logo-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.logo-preview { height: 150px; display: grid; place-items: center; padding: 18px; background: #fff; border-bottom: 1px solid var(--line);
  background-image: linear-gradient(45deg, #f6f3ef 25%, transparent 25%), linear-gradient(-45deg, #f6f3ef 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f6f3ef 75%), linear-gradient(-45deg, transparent 75%, #f6f3ef 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.logo-preview.is-dark { background: #1c1c1e; }
.logo-preview img { max-height: 110px; max-width: 100%; object-fit: contain; }
.logo-info { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.logo-info p { margin: 0; }

.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.rules { padding: 18px 22px; }
.rules h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.rules ul { margin: 0; padding-left: 18px; }
.rules li { margin: 4px 0; }
.rules-do h3 { color: var(--green); }
.rules-dont h3 { color: var(--red); }

.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; align-items: stretch; }
.rows > .btn { align-self: flex-start; }
.row, .row-head { display: grid; gap: 8px; align-items: center; }
.row-head { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.color-cols { grid-template-columns: 38px 1.3fr 1fr 1fr 1fr 1fr 1fr 24px; }
.font-cols { grid-template-columns: 1.2fr 1fr 1.2fr 1.2fr 1.6fr 24px; }
.logo-cols { grid-template-columns: 2fr 1.2fr 1.1fr 1.5fr 24px; }
.input-color { width: 38px; height: 34px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; cursor: pointer; }
.row .link { font-size: 20px; line-height: 1; color: var(--muted); text-decoration: none; }
.row .link:hover { color: var(--red); }
@media (max-width: 1100px) {
  .row-head { display: none; }
  .color-cols, .font-cols, .logo-cols { grid-template-columns: 1fr 1fr; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
  .font-row { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media print {
  .sidebar, .nav-burger, .no-print, .page-head .actions, .flash, .crumbs { display: none !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .swatch-color, .logo-preview.is-dark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Cartes de bibliothèques (page d'un espace) ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-bottom: 18px; }
.lib-card { padding: 0; overflow: hidden; text-decoration: none; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.lib-card:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(40, 30, 20, .08); }
.lib-mosaic { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; aspect-ratio: 16 / 10; background: var(--line); }
.lib-mosaic span { position: relative; background: var(--active-bg); overflow: hidden; display: grid; place-items: center; }
.lib-mosaic img { width: 100%; height: 100%; object-fit: cover; }
.lib-mosaic.n1 span { grid-column: 1 / 3; grid-row: 1 / 3; }
.lib-mosaic.n2 span { grid-row: 1 / 3; }
.lib-mosaic.n3 span:first-child { grid-row: 1 / 3; }
.lib-mosaic.n0 .lib-empty { grid-column: 1 / 3; grid-row: 1 / 3; color: var(--muted); font-size: 13px; }
.lib-mosaic .tile-play { position: absolute; font-style: normal; }
.lib-info { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 4px; }
.lib-info strong { font-size: 16px; }
.lib-desc { color: var(--text); }
.lib-info .chips { margin-top: 4px; }
.lib-mosaic span { background: #ddd6cd; } /* gris moyen : logos blancs et noirs restent lisibles */
.lib-mosaic img { object-fit: contain; padding: 14px; }
.lib-mosaic.is-photo span { background: var(--active-bg); }
.lib-mosaic.is-photo img { object-fit: cover; padding: 0; }

/* ---------- Fiche d'un fichier : aperçu réduit, fiche large sur deux colonnes ---------- */
.modal { width: min(1560px, 97vw); }
.modal-inner { grid-template-columns: 360px 1fr; }
.modal-aside { display: flex; flex-direction: column; border-right: 1px solid var(--line); max-height: 92vh; overflow-y: auto; }
.modal-aside .modal-preview { min-height: 0; height: 300px; max-height: 300px; flex: none; }
.modal-aside .modal-preview img, .modal-aside .modal-preview video { max-height: 300px; }
.modal-aside .modal-preview iframe { height: 300px; }
.modal-aside .modal-preview .preview-note img { max-height: 160px; }
.modal-aside-info { padding: 20px 22px 24px; display: flex; flex-direction: column; gap: 8px; }
.modal-aside-info h3 { font-size: 19px; font-weight: 800; word-break: break-word; }
.modal-side { display: grid; grid-template-columns: 1.15fr 1fr; gap: 0 32px; align-content: start; padding: 26px 64px 26px 28px; }
.modal-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.modal-nav { top: 150px; transform: translateY(-50%); }
.modal-nav.next, .modal-nav.next { left: calc(360px - 54px); right: auto; }
@media (max-width: 1100px) {
  .modal-inner { grid-template-columns: 300px 1fr; }
  .modal-side { grid-template-columns: 1fr; padding-right: 28px; }
  .modal-nav.next { left: calc(300px - 54px); right: auto; }
}
@media (max-width: 860px) {
  .modal-inner { grid-template-columns: 1fr; }
  .modal-aside { max-height: none; overflow: visible; border-right: 0; }
  .modal-aside .modal-preview { height: 240px; max-height: 240px; }
  .modal-side { padding: 20px; max-height: none; }
  .modal-nav { top: 120px; }
  .modal-nav.next { left: auto; right: 12px; }
}
.dl-readonly dd { white-space: pre-line; }
.lib-grid { align-items: stretch; } .lib-grid > .lib-card { height: 100%; margin: 0; }
.file-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.file-grid .lib-info strong { word-break: break-word; font-size: 15px; }

/* ---------- Visionneuse plein écran ---------- */
.viewer { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #111; color: #fff; overflow: hidden; }
.viewer::backdrop { background: rgba(0,0,0,.9); }
.viewer[open] { display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: rgba(0,0,0,.55); z-index: 2; }
.viewer-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-count { opacity: .7; font-size: 13px; }
.viewer-tools { display: flex; gap: 6px; }
.viewer-tools button { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 6px; min-width: 36px; height: 34px; font-size: 18px; cursor: pointer; }
.viewer-tools .viewer-pct { font-size: 13px; min-width: 64px; }
.viewer-tools button:hover { background: rgba(255,255,255,.25); }
.viewer:not(.can-zoom) [data-v-zoom] { display: none; }
.viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 24px 80px; touch-action: none; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; transition: transform .12s ease-out; user-select: none; cursor: zoom-in; }
.viewer.is-zoomed .viewer-stage img { cursor: grab; transition: none; }
.viewer-stage video { max-width: 100%; max-height: 100%; }
.viewer-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 34px; line-height: 1; cursor: pointer; z-index: 2; }
.viewer-nav:hover { background: rgba(255,255,255,.3); }
.viewer-nav.prev { left: 16px; } .viewer-nav.next { right: 16px; }
.viewer-nav[hidden] { display: none; }

/* Mosaïque : la taille des photos (ex. portrait de téléphone) ne doit jamais déformer la grille.
   Une grande image à gauche, les petites empilées à droite. */
.lib-mosaic { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: repeat(3, minmax(0, 1fr)); aspect-ratio: 16 / 10; min-height: 0; }
.lib-mosaic span { min-width: 0; min-height: 0; }
.lib-mosaic img { position: absolute; inset: 0; width: 100%; height: 100%; }
.lib-mosaic span:first-child { grid-column: 1; grid-row: 1 / 4; }
.lib-mosaic.n1 span:first-child, .lib-mosaic.n0 .lib-empty { grid-column: 1 / 3; grid-row: 1 / 4; }
.lib-mosaic.n2 span:nth-child(2) { grid-column: 2; grid-row: 1 / 4; }
.lib-mosaic.n3 span:nth-child(2) { grid-column: 2; grid-row: 1 / 3; }
.lib-mosaic.n3 span:nth-child(3) { grid-column: 2; grid-row: 3; }
.lib-mosaic.n4 span:nth-child(n+2) { grid-column: 2; grid-row: auto; }
.lib-mosaic.n3 span:first-child { grid-row: 1 / 4; }
.title-with-btn { display: inline-flex; align-items: center; gap: 14px; }

/* ---------- Sélecteur Cartes / Liste ---------- */
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; vertical-align: middle; }
.view-toggle button { border: 0; background: transparent; padding: 5px 11px; font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.view-toggle button + button { border-left: 1px solid var(--line); }
.view-toggle button:hover { color: var(--text); }
.view-toggle button.is-active { background: var(--active-bg); color: var(--red); }
.view-toggle-row { display: flex; justify-content: flex-end; margin: 0 0 12px; }
.title-with-btn { display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.title-with-btn .section-title { margin: 0; }
.title-with-btn { display: flex; margin: 40px 0 0; }
.section-head .title-with-btn { margin: 0; }
h2.section-title + .lib-grid, .title-with-btn + .lib-grid { margin-top: 14px; }

/* ---------- Mode Liste : lignes compactes avec une miniature ---------- */
body.view-list .lib-grid,
body.view-list .lib-grid.file-grid { grid-template-columns: 1fr; gap: 8px; }
body.view-list .lib-grid > .lib-card { flex-direction: row; align-items: center; height: auto; }
body.view-list .lib-card:hover { transform: none; }
body.view-list .lib-mosaic { flex: none; width: 112px; aspect-ratio: 4 / 3; grid-template-columns: 1fr; grid-template-rows: 1fr; }
body.view-list .lib-mosaic span:not(:first-child) { display: none; }
body.view-list .lib-mosaic span:first-child,
body.view-list .lib-mosaic .lib-empty { grid-column: 1; grid-row: 1; }
body.view-list .lib-mosaic .lib-empty { font-size: 0; }
body.view-list .lib-mosaic img { padding: 6px; }
body.view-list .lib-mosaic.is-photo img { padding: 0; }
body.view-list .lib-info { flex: 1; min-width: 0; padding: 10px 18px; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); column-gap: 20px; row-gap: 2px; align-items: center; }
body.view-list .lib-info > .smallcaps { grid-column: 1; }
body.view-list .lib-info > strong { grid-column: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.view-list .lib-info > .muted { grid-column: 2; grid-row: 1 / 3; }
body.view-list .lib-info > .lib-desc { display: none; }
body.view-list .lib-info > .chips { grid-column: 1 / 3; }
@media (max-width: 700px) {
  body.view-list .lib-info { grid-template-columns: 1fr; }
  body.view-list .lib-info > .muted { grid-column: 1; grid-row: auto; }
}
.searchbar .input-auto { flex: 0 0 170px; min-width: 0; }
.pill-print { background: #fbe3e1; color: var(--red); }
.alert-print { background: #fbe3e1; color: #7a1d14; }
.check-print { margin: 4px 0 10px; }
.print-spec { border: 1px solid #f0c9c4; background: #fdf6f5; border-radius: 10px; padding: 4px 16px 12px; margin: 10px 0 16px; }
.print-group { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--red); margin: 12px 0 6px; }
.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.print-grid .print-wide { grid-column: 1 / -1; }
.print-grid .field { margin-bottom: 8px; }
