:root {
  --bg: #f5f6f8; --surface: #fff; --surface-2: #eef0f3; --text: #1b1f24; --muted: #6b7280; --border: #e3e6ea;
  --primary: #c62828; --primary-ink: #fff; --primary-soft: #fdecec;
  --ok: #16803c; --ok-soft: #e3f6ea; --warn: #b45309; --warn-soft: #fdf1dc; --err: #b91c1c; --err-soft: #fde8e8; --info: #1d4ed8; --info-soft: #e5edff;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #101317; --surface: #181c22; --surface-2: #232830; --text: #e8eaed; --muted: #9aa3af; --border: #2b313a;
    --primary: #ef5350; --primary-ink: #14090a; --primary-soft: #3a1c1d;
    --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #33270e; --err: #f87171; --err-soft: #3a1818; --info: #93b4ff; --info-soft: #172544;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #101317; --surface: #181c22; --surface-2: #232830; --text: #e8eaed; --muted: #9aa3af; --border: #2b313a;
  --primary: #ef5350; --primary-ink: #14090a; --primary-soft: #3a1c1d;
  --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #33270e; --err: #f87171; --err-soft: #3a1818; --info: #93b4ff; --info-soft: #172544;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35); color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.i { flex: none; vertical-align: -4px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.gap-l { gap: 20px; } .mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .mt-l { margin-top: 28px; }
.hide { display: none !important; }

/* Mise en page */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; padding: 18px 14px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.side nav { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text); font-weight: 500; }
.side nav a:hover { background: var(--surface-2); text-decoration: none; }
.side nav a.on { background: var(--primary-soft); color: var(--primary); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; }
.side-foot .me { display: flex; align-items: center; gap: 8px; flex: 1; color: var(--text); font-weight: 600; font-size: .9rem; min-width: 0; line-height: 1.2; }
.side-foot .me small { display: block; color: var(--muted); font-weight: 400; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 1.3rem; justify-content: center; margin-bottom: 18px; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: var(--primary-ink); }
.main-wrap { min-width: 0; }
.top { display: flex; align-items: center; gap: 10px; padding: 10px clamp(16px, 3vw, 40px) 0; min-height: 52px; }
.main { padding: 8px clamp(16px, 3vw, 40px) 90px; max-width: 1480px; }
.bottom, .brand.mob, .avatar.mob { display: none; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .78rem; flex: none; }
.bell { position: relative; }
.bell b { position: absolute; top: 2px; right: 2px; background: var(--primary); color: var(--primary-ink); font-size: .65rem; min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; padding: 0 4px; }

/* Boutons & formulaires */
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 38px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--primary); }
.btn.danger { color: var(--err); }
.btn.danger.fill { background: var(--err); color: #fff; border-color: var(--err); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.iconbtn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.iconbtn:hover { background: var(--surface-2); text-decoration: none; }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=url], input[type=search], select, textarea {
  width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; min-height: 40px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--primary); }
input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.field { margin-bottom: 14px; }
.field .hint { color: var(--muted); font-size: .8rem; margin-top: 3px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: flex; align-items: center; gap: 7px; font-weight: 500; margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* Cartes, badges, tableaux */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h2 { display: flex; align-items: center; gap: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 14px; align-items: start; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 18px; }
.page-head h1 { margin: 0; flex: 1; min-width: 200px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .76rem; font-weight: 600; white-space: nowrap; }
.badge[data-s=preparation], .badge[data-s=draft], .badge[data-s=pending], .badge[data-s=todo], .badge[data-s=invited] { background: var(--surface-2); color: var(--muted); }
.badge[data-s=en_cours], .badge[data-s=review], .badge[data-s=doing], .badge[data-s=accepted] { background: var(--info-soft); color: var(--info); }
.badge[data-s=finalise], .badge[data-s=validated], .badge[data-s=done], .badge[data-s=paid], .badge[data-s=active] { background: var(--ok-soft); color: var(--ok); }
.badge[data-s=sent], .badge[data-s=archive] { background: var(--primary-soft); color: var(--primary); }
.badge[data-s=blocked], .badge[data-s=cancelled], .badge[data-s=rejected], .badge[data-s=disabled], .badge[data-s=urgent] { background: var(--err-soft); color: var(--err); }
.badge[data-s=high] { background: var(--warn-soft); color: var(--warn); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; }
@media (max-width: 720px) {
  .table.stack thead { display: none; }
  .table.stack tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 3px 0; text-align: right; }
  .table.stack td::before { content: attr(data-l); color: var(--muted); font-size: .8rem; text-align: left; }
}
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 1.5rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .82rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.due { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 600; }
.due.late { color: var(--err); } .due.soon { color: var(--warn); } .due.muted { color: var(--muted); font-weight: 500; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.lock-note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-weight: 500; display: flex; gap: 8px; align-items: center; }

/* Onglets projet */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); margin: 0 0 18px; scrollbar-width: none; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }

/* Dialogues & toasts */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(580px, 94vw); max-height: 92dvh; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog.wide { width: min(980px, 96vw); }
dialog::backdrop { background: rgba(10, 12, 16, .55); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { margin: 0; flex: 1; }
.dlg-body { padding: 18px; overflow: auto; max-height: calc(92dvh - 130px); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.menu-dlg { margin: auto auto 0; width: 100vw; max-width: none; border-radius: 16px 16px 0 0; }
.menu-list { display: flex; flex-direction: column; }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: 12px; padding: 13px 6px; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; width: 100%; text-align: left; cursor: pointer; border-bottom: 1px solid var(--border); }
.toasts { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; animation: tin .2s ease; }
.toast.err { background: var(--err); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* Page nue (connexion, dépôt) */
body.bare { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.bare-card { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.bare-card.wide { width: min(620px, 100%); }
.sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 16px 0; }
.sep::before, .sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* Kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; align-items: start; }
.kcol { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 120px; scroll-snap-align: start; }
.kcol-head { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 2px 4px 10px; }
.kcol-head .n { color: var(--muted); font-weight: 500; }
.kcards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.ktask { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); cursor: pointer; position: relative; }
.ktask.dragging { opacity: .35; }
.ktask .t { font-weight: 600; margin-bottom: 6px; padding-right: 22px; word-break: break-word; }
.ktask .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: .8rem; color: var(--muted); }
.ktask .handle { position: absolute; top: 6px; right: 4px; width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); cursor: grab; touch-action: none; font-size: 1.1rem; user-select: none; }
.ktask .pri { width: 4px; position: absolute; left: 0; top: 8px; bottom: 8px; border-radius: 0 3px 3px 0; background: transparent; }
.ktask .pri[data-p=high] { background: var(--warn); } .ktask .pri[data-p=urgent] { background: var(--err); }
.ghost-card { position: fixed; z-index: 90; pointer-events: none; opacity: .92; transform: rotate(2deg); width: 270px; }
.avatars { display: inline-flex; }
.avatars .avatar { width: 22px; height: 22px; font-size: .6rem; margin-left: -6px; border: 2px solid var(--surface); }
.avatars .avatar:first-child { margin-left: 0; }

/* Timeline */
.tl-wrap { overflow-x: auto; }
.tl { position: relative; height: 150px; min-width: 760px; margin: 0 28px; }
.tl-line { position: absolute; left: 0; right: 0; top: 75px; height: 4px; background: var(--border); border-radius: 2px; }
.tl-m { position: absolute; transform: translateX(-50%); width: 130px; text-align: center; font-size: .78rem; line-height: 1.25; }
.tl-m .dot { position: absolute; left: 50%; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.tl-m.done .dot { background: var(--ok); border-color: var(--ok); }
.tl-m.up { bottom: 80px; padding-bottom: 8px; } .tl-m.up .dot { bottom: -15px; }
.tl-m.down { top: 84px; padding-top: 8px; } .tl-m.down .dot { top: -15px; }
.tl-m b { display: block; } .tl-m span { color: var(--muted); }
.tl-today { position: absolute; top: 20px; bottom: 20px; width: 0; border-left: 2px dashed var(--primary); }
.tl-today::after { content: "Aujourd'hui"; position: absolute; top: -18px; left: -30px; width: 60px; text-align: center; font-size: .68rem; color: var(--primary); font-weight: 700; }

/* Médiathèque */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mitem { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; cursor: pointer; border: 2px solid transparent; padding: 0; }
.mitem:hover { border-color: var(--primary); }
.mitem img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mitem .pdf { display: grid; place-items: center; height: 100%; color: var(--muted); background: var(--surface-2); font-weight: 700; }
.mitem .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 5px; background: linear-gradient(transparent, rgba(0,0,0,.65)); color: #fff; font-size: .72rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mitem.sel { border-color: var(--primary); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; color: #fff; background: var(--primary); }
.tag.off { background: var(--surface-2); color: var(--muted); }
.tagbar { display: flex; flex-wrap: wrap; gap: 6px; }
.tagbar button { border: 0; cursor: pointer; font: inherit; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.upl { margin-top: 8px; font-size: .85rem; }
.upl .progress { margin-top: 3px; }

/* Studio */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.pcard .thumb { background: var(--surface-2); padding: 8px; display: block; }
.pcard canvas { width: 100%; height: auto; display: block; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.pcard .info { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; overflow-wrap: anywhere; }
.ed { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.ed-main { min-width: 0; }
.stage-wrap { background: var(--surface-2); border-radius: var(--radius); padding: 14px; overflow: auto; }
.stage { position: relative; margin: 0 auto; background: #fff; box-shadow: 0 2px 14px rgba(0,0,0,.25); touch-action: none; user-select: none; -webkit-user-select: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.zlayer { position: absolute; inset: 0; }
.zbox { position: absolute; border: 1px solid rgba(37, 99, 235, .45); cursor: move; touch-action: none; }
.zbox.sel { border: 2px solid #2563eb; }
.zbox.crop { outline: 2px dashed #f59e0b; cursor: grab; }
.zbox .zlabel { position: absolute; top: -20px; left: 0; background: #2563eb; color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; white-space: nowrap; pointer-events: none; }
.zh { position: absolute; width: 16px; height: 16px; background: #fff; border: 2px solid #2563eb; border-radius: 4px; touch-action: none; }
.zh.nw { left: -9px; top: -9px; cursor: nwse-resize; } .zh.ne { right: -9px; top: -9px; cursor: nesw-resize; }
.zh.sw { left: -9px; bottom: -9px; cursor: nesw-resize; } .zh.se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.guide { position: absolute; pointer-events: none; border: 1px dashed; }
.guide.trim { border-color: rgba(220, 38, 38, .85); } .guide.safe { border-color: rgba(22, 163, 74, .8); }
.ed-side { display: flex; flex-direction: column; gap: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.savestate { font-size: .82rem; color: var(--muted); margin-left: auto; }
.savestate.err { color: var(--err); }
.dpi { font-size: .8rem; font-weight: 600; }
.dpi.ok { color: var(--ok); } .dpi.mid { color: var(--warn); } .dpi.low { color: var(--err); }
.cmts { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow: auto; margin-bottom: 10px; }
.cmt { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; font-size: .9rem; }
.cmt .who { font-weight: 700; font-size: .82rem; } .cmt .when { color: var(--muted); font-size: .75rem; margin-left: 6px; font-weight: 400; }
.cmt .mention { color: var(--primary); font-weight: 600; }
.mention-menu { position: absolute; z-index: 10; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 180px; overflow: auto; min-width: 180px; }
.mention-menu button { display: block; width: 100%; text-align: left; padding: 7px 12px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; }
.mention-menu button:hover, .mention-menu button.on { background: var(--primary-soft); }
.vlist { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.vitem { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 9px; font-size: .85rem; }
.vitem .grow { min-width: 0; } .vitem .grow small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare canvas { width: 100%; height: auto; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.25); }
/* la bibliothèque (#lib) est sous la page ; « pleine largeur » l'étend aussi sous le panneau de droite */
.ed > .ed-main { grid-column: 1; grid-row: 1; }
.ed > .ed-side { grid-column: 2; grid-row: 1 / span 2; }
.ed > #lib { grid-column: 1; grid-row: 2; min-width: 0; }
.ed.libwide > #lib { grid-column: 1 / -1; }
.ed.libwide > .ed-side { grid-row: 1; }
@media (max-width: 1000px) { .ed { grid-template-columns: minmax(0, 1fr); } .compare { grid-template-columns: 1fr; }
  .ed > .ed-main, .ed > .ed-side, .ed > #lib, .ed.libwide > #lib, .ed.libwide > .ed-side { grid-column: 1; grid-row: auto; } }
.ed-side { min-width: 0; }
.vsep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.dd { position: relative; }
.dd > summary { list-style: none; cursor: pointer; }
.dd > summary::-webkit-details-marker { display: none; }
.dd-menu { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 260px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; }
.dd-menu button { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; cursor: pointer; }
.dd-menu button:hover { background: var(--primary-soft); }
.dd-menu small { color: var(--muted); }
.viewbox { height: min(76dvh, 760px); display: grid; place-items: center; overflow: auto; }
.viewbox img { max-width: 100%; max-height: 100%; object-fit: contain; -webkit-user-drag: none; }
.viewbox iframe { width: 100%; height: 100%; border: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 54px; height: 38px; border-radius: 8px; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.swatch:hover { border-color: var(--primary); }
.tplgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tpl { background: var(--surface-2); border: 2px solid transparent; border-radius: 10px; padding: 8px; cursor: pointer; text-align: left; color: var(--text); font: inherit; }
.tpl:hover { border-color: var(--primary); }
.tpl canvas { width: 100%; height: auto; display: block; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.tpl b { display: block; margin-top: 6px; font-size: .88rem; } .tpl small { color: var(--muted); }
.fxrow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.fxrow button { padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .8rem; cursor: pointer; }
.fxrow button.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.sect { margin: 14px 0 6px; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.dd-menu a { display: flex; flex-direction: column; gap: 1px; padding: 9px 11px; border-radius: 8px; color: var(--text); text-decoration: none; }
.dd-menu a:hover { background: var(--primary-soft); text-decoration: none; }
.dd-menu.right { left: auto; right: 0; }
/* Archives : frise chronologique + cartes à miniature */
.yrs { display: flex; overflow-x: auto; padding: 6px 2px 10px; scrollbar-width: thin; }
.yr { flex: none; min-width: 66px; position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 4px 6px 0; background: none; border: 0; cursor: pointer; color: var(--muted); font: inherit; }
.yr::before { content: ""; position: absolute; top: 22px; left: 0; right: 0; height: 3px; background: var(--border); }
.yr i { position: relative; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--border); }
.yr.has i { border-color: var(--primary); }
.yr.sel i { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.yr span { font-weight: 700; font-size: .9rem; }
.yr.sel span, .yr.has span { color: var(--text); }
.yr b { font-size: .7rem; font-weight: 600; color: var(--primary); min-height: 1em; }
.yr:not(.has) { opacity: .55; }
.acards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.acard { padding: 0; display: flex; flex-direction: column; }
.athumb { display: block; position: relative; aspect-ratio: 303 / 216; background: var(--surface-2); overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; }
.athumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.athumb:hover img { transform: scale(1.03); }
.athumb.ph { display: grid; place-items: center; color: var(--muted); font-weight: 800; letter-spacing: .1em; text-decoration: none; }
.acard .yearbadge { position: absolute; top: 10px; left: 10px; background: var(--primary); color: var(--primary-ink); font-weight: 800; padding: 2px 10px; border-radius: 8px; }
.acard .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.alignbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.alignbar button { width: 32px; height: 30px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); cursor: pointer; font-size: .9rem; }
.alignbar button:hover { background: var(--primary-soft); }

/* Mur d'inspiration */
.free { position: relative; min-height: 72vh; overflow: auto; border: 1px dashed var(--border); border-radius: var(--radius); background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 24px 24px; }
.free .inner { position: relative; width: 2600px; height: 1700px; }
.note { position: absolute; width: 230px; padding: 12px 14px; border-radius: 8px; box-shadow: 0 3px 10px rgba(0,0,0,.18); color: #1b1f24; touch-action: none; cursor: grab; word-break: break-word; }
.note.dragging { cursor: grabbing; z-index: 5; box-shadow: 0 10px 24px rgba(0,0,0,.3); }
.note .q { font-style: italic; font-size: 1.02rem; } .note .by { margin-top: 6px; font-size: .8rem; opacity: .75; }
.note img { width: 100%; border-radius: 4px; display: block; margin-bottom: 6px; pointer-events: none; }
.note .x { position: absolute; top: 2px; right: 2px; opacity: .55; background: none; border: 0; cursor: pointer; font-size: 1rem; padding: 4px 7px; color: inherit; }
.note a { color: inherit; text-decoration: underline; }
@media (max-width: 700px) {
  .free { min-height: 0; background: none; border: 0; overflow: visible; }
  .free .inner { width: auto; height: auto; display: flex; flex-direction: column; gap: 10px; }
  .note { position: static; width: auto; }
}

/* Archives */
.viewer { width: 100%; height: calc(100dvh - 230px); min-height: 440px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.year { font-size: 2.2rem; font-weight: 800; color: var(--primary); line-height: 1; }

/* Mobile */
@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .brand.mob, .avatar.mob { display: flex; }
  .main { padding-bottom: 96px; }
  .bottom { display: flex; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottom a, .bottom button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px; color: var(--muted); font: inherit; font-size: .68rem; font-weight: 600; background: none; border: 0; border-radius: 8px; cursor: pointer; }
  .bottom a.on { color: var(--primary); }
  .bottom a:hover { text-decoration: none; }
  .toasts { bottom: 84px; }
  .board { grid-auto-columns: 86%; }
}
@media (hover: none) { .btn:hover, .iconbtn:hover { background: inherit; } }
@media print { .side, .bottom, .top, .toolbar { display: none !important; } }
.dd-menu .off { display: flex; flex-direction: column; gap: 1px; padding: 9px 11px; color: var(--muted); }
.dd-menu .off b { font-weight: 600; }
.dd-menu .off a { display: inline; padding: 0; color: var(--primary); }
/* Aperçu d'un dépôt : l'image tient entièrement dans la fenêtre, sans défilement, quelle que soit sa forme */
#v-dlg[open] { display: flex; flex-direction: column; height: min(92dvh, 900px); }
#v-dlg .dlg-body { flex: 1; min-height: 0; max-height: none; overflow: hidden; }
#v-dlg .viewbox { height: 100%; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); overflow: hidden; }
#v-dlg .viewbox img { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; }
/* Bibliothèque du Studio */
.tabs.sm { margin: 10px 0; gap: 2px; flex-wrap: wrap; }
.tabs.sm a { padding: 6px 10px; font-size: .82rem; }
.libgrid { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); height: 420px; min-height: 150px; max-height: 85vh; overflow: auto; align-content: start; grid-auto-rows: max-content; resize: vertical; padding: 2px 4px 2px 2px; } /* max-content : sans lui, la hauteur fixe écrase les lignes et les vignettes se superposent */
.libhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
.libhead h2 { margin: 0; }
.libhead .tabs { margin: 0; border: 0; flex-wrap: wrap; }
.libhead input[type=search] { flex: 1 1 180px; max-width: 320px; min-width: 0; }
.libgrid .libcat { grid-column: 1 / -1; margin: 6px 0 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.mitem.art img { object-fit: contain; padding: 8px; background: #fff; }
.mitem[draggable="true"] { cursor: grab; }
.stage.drop { outline: 3px dashed var(--primary); outline-offset: 2px; }
/* Onglet Transmettre : cases à cocher avec description */
.chk { align-items: flex-start; font-weight: 400; margin: 0 0 12px; cursor: pointer; }
.chk input { margin-top: 4px; flex: none; }
.chk b { font-weight: 600; }
.indent { margin-left: 28px; }
.dd-menu { text-align: left; }
/* Galerie du Studio */
.libchips { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; }
.libchips button { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: .78rem; font-weight: 600; cursor: pointer; }
.libchips button.on { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.zbox.locked { pointer-events: none; }
.mitem.art { background: repeating-conic-gradient(#e2e2e2 0 25%, #fff 0 50%) 0 0 / 14px 14px; }
.mitem.art img { background: transparent; }
/* Canva (Studio) */
.cvgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; max-height: 300px; overflow: auto; }
.cvcard { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); text-align: left; cursor: pointer; font: inherit; color: var(--text); }
.cvcard:hover, .cvcard.on { border-color: var(--primary); }
.cvcard img, .cvnone { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.cvnone { display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.cvcard b { font-size: .82rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cvcard small { color: var(--muted); }
/* notes de version (Réglages) */
.rel { border-top: 1px solid var(--border); padding: 10px 0; }
.rel summary { cursor: pointer; }
.rel h4 { margin: 12px 0 4px; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.rel h4::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--primary); }
.rel h4[data-k="better"]::before { background: var(--ok); } .rel h4[data-k="fix"]::before { background: var(--warn); }
.rel ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
/* sous-menu des Réglages (barre latérale) et onglets mobiles */
.side nav .subnav { display: flex; flex-direction: column; gap: 1px; margin: 0 0 6px 21px; padding-left: 8px; border-left: 2px solid var(--border); }
.side nav .subnav a { padding: 6px 10px; font-size: .86rem; font-weight: 500; color: var(--muted); border-radius: 7px; }
.side nav .subnav a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.settabs { display: none; }
@media (max-width: 899px) { .settabs { display: flex; margin-bottom: 14px; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
/* assistant IA (pages à reproduire) et comparaison page d'origine / modèle */
.aipages { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 46vh; overflow: auto; padding: 2px; }
.aip { position: relative; display: flex; flex-direction: column; gap: 5px; padding: 6px; border: 2px solid var(--border); border-radius: 10px; background: var(--surface-2); cursor: pointer; font-size: .8rem; }
.aip.on { border-color: var(--primary); background: var(--primary-soft); }
.aip img { width: 100%; aspect-ratio: 1.4; object-fit: contain; background: #fff; border-radius: 4px; display: block; }
.aip .aip-h { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.aip select { width: 100%; font-size: .78rem; padding: 3px 4px; }
.aip .aip-st { min-height: 1.2em; font-size: .75rem; }
.rv-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .rv-cmp { grid-template-columns: 1fr; } }
.rv-box { margin: 0; } .rv-box figcaption { font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.rv-wrap { position: relative; } .rv-wrap img, .rv-wrap canvas { width: 100%; height: auto; display: block; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.25); }
.rv-hl { position: absolute; border: 2px solid #e11d48; background: rgba(225, 29, 72, .16); pointer-events: none; }
.rv-zones { max-height: 30vh; overflow: auto; } .rv-zones li { cursor: default; } .rv-zones li:hover { background: var(--surface-2); }
