:root {
  --bg: #0e0e10;
  --bg-2: #161618;
  --bg-3: #1e1e21;
  --line: #2a2a2e;
  --text: #ececec;
  --muted: #8f8f96;
  --gold: #c9a44a;
  --gold-2: #e2c06a;
  --green: #3ec27a;
  --orange: #f0994a;
  --red: #e25f5f;
  --blue: #5b9cf5;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; }
a { color: var(--gold-2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Boutons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-3); color: var(--text); font-size: 13px; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: #26262a; border-color: #3a3a40; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1405; font-weight: 600; }
.btn.primary:hover { background: var(--gold-2); border-color: var(--gold-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--bg-3); }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn.icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }
.btn.danger { color: var(--red); }
.btn.approve { border-color: rgba(62,194,122,.4); color: var(--green); }
.btn.approve:hover, .btn.approve.on { background: rgba(62,194,122,.15); }
.btn.changes { border-color: rgba(240,153,74,.4); color: var(--orange); }
.btn.changes:hover, .btn.changes.on { background: rgba(240,153,74,.15); }

/* Champs */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 60px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

/* Chips de statut */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .02em; border: 1px solid transparent; }
.chip.pending { color: var(--muted); border-color: var(--line); }
.chip.approved { color: var(--green); background: rgba(62,194,122,.12); }
.chip.changes { color: var(--orange); background: rgba(240,153,74,.12); }
.chip.processing { color: var(--blue); background: rgba(91,156,245,.12); }
.chip.error { color: var(--red); background: rgba(226,95,95,.12); }
.chip.version { color: var(--gold-2); background: rgba(201,164,74,.12); font-family: var(--mono); }
.chip.seen-chip { color: var(--blue); background: rgba(91,156,245,.12); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* En-tête */
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--bg-2); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .12em; font-size: 13px; }
.brand .mark { width: 22px; height: 22px; border: 2px solid var(--gold); border-radius: 4px; position: relative; }
.brand .mark::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--gold); }
.brand small { font-weight: 400; letter-spacing: .02em; color: var(--muted); }
.topbar .spacer { flex: 1; }

/* Mise en page */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
.head-projects { flex-wrap: wrap; }
.newp .pname { width: 320px; }
.newp .client { width: 160px; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.project-card { display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s; overflow: hidden; padding: 0; }
.project-card:hover { border-color: #444; }
.project-card .thumb { aspect-ratio: 16/9; background: var(--bg-3) center/cover no-repeat; border-bottom: 1px solid var(--line); }
.project-card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.project-card .stats { display: flex; gap: 10px; font-size: 12px; color: var(--muted); }

/* Liste d'assets */
.asset { display: grid; grid-template-columns: 160px 1fr auto; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); cursor: pointer; }
.asset:hover { border-color: #444; }
.asset .thumb { aspect-ratio: 16/9; border-radius: 6px; background: var(--bg-3) center/cover no-repeat; position: relative; }
.asset .thumb .dur { position: absolute; right: 6px; bottom: 6px; font-size: 11px; background: rgba(0,0,0,.7); padding: 1px 5px; border-radius: 4px; }
.asset .meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.asset .meta .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset .meta .sub { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }

/* Zone de dépôt */
.drop { border: 1px dashed #3a3a40; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--gold); background: rgba(201,164,74,.06); color: var(--text); }
.progress { height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--gold); width: 0; transition: width .2s; }

/* Lecteur */
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 0; height: calc(100vh - 57px); }
.viewer .stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; overflow: hidden; background: #000; }
.viewer .video-wrap { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; background: #000; }
.viewer video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; outline: none; }
.viewer .overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; color: var(--muted); background: rgba(0,0,0,.6); pointer-events: none; z-index: 5; }

/* Comparaison de deux versions */
.video-wrap { --wipe: 50%; }
.video-wrap .cmp { display: none; }
.video-wrap .wipe-handle { display: none; }
.video-wrap.cmp-side .cmp,
.video-wrap.cmp-wipe .cmp { display: block; }
.video-wrap.cmp-side > video:not(.cmp) { right: 50%; width: auto; }
.video-wrap.cmp-side > .cmp { left: 50%; width: auto; border-left: 1px solid var(--line); }
.video-wrap.cmp-wipe > .cmp { z-index: 2; clip-path: inset(0 0 0 var(--wipe)); }
.video-wrap.cmp-wipe .wipe-handle { display: block; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: var(--gold); z-index: 3; cursor: ew-resize; touch-action: none; }
.video-wrap.cmp-wipe .wipe-handle::after { content: "⇄"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: #1a1405; font-size: 14px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.cmp-label { position: absolute; top: 10px; padding: 2px 8px; border-radius: 4px; background: rgba(0,0,0,.7); font-size: 11px; font-weight: 600; color: var(--gold-2); z-index: 4; pointer-events: none; }
.cmp-label.lab-a { left: 10px; }
.cmp-label.lab-b { right: 10px; }
.btn.mode.on { border-color: var(--gold); color: var(--gold-2); }
.controls .cmpbar { border-top: 1px solid var(--line); padding-top: 8px; }
.controls { padding: 10px 14px 12px; background: var(--bg-2); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.scrub { position: relative; height: 26px; cursor: pointer; }
.scrub .track { position: absolute; left: 0; right: 0; top: 11px; height: 4px; background: #333; border-radius: 2px; }
.scrub .buffered { position: absolute; left: 0; top: 11px; height: 4px; background: #4a4a50; border-radius: 2px; width: 0; }
.scrub .played { position: absolute; left: 0; top: 11px; height: 4px; background: var(--gold); border-radius: 2px; width: 0; }
.scrub .head { position: absolute; top: 7px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--gold-2); box-shadow: 0 0 0 3px rgba(201,164,74,.25); left: 0; }
.scrub .marker { position: absolute; top: 0; width: 2px; height: 8px; margin-left: -1px; background: var(--blue); border-radius: 1px; cursor: pointer; }
.scrub .marker.resolved { background: #4a4a50; }
.scrub .marker.drawn { background: var(--gold); }
.scrub .marker.active { background: #fff; height: 10px; }

/* Annotation dessinée sur l'image */
.video-wrap .draw { position: absolute; z-index: 4; pointer-events: none; overflow: visible; }
.video-wrap.drawing .draw { pointer-events: auto; cursor: crosshair; touch-action: none; }
.video-wrap.drawing { outline: 2px solid var(--gold); outline-offset: -2px; }
.controls .drawbar { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; flex-wrap: wrap; }
.controls .tool.on { border-color: var(--gold); color: var(--gold-2); }
.controls .drawbtn.on { border-color: var(--gold); color: var(--gold-2); background: rgba(201,164,74,.12); }
.swatches { display: inline-flex; gap: 4px; margin: 0 4px; }
.sw { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.sw.on { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.comment .drawmark { color: var(--gold-2); font-size: 12px; }

/* Séries photo : planche contact */
.photos { display: flex; flex-direction: column; gap: 10px; }
.pfolder .sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px 14px 16px; }
.pfolder .pickcount { color: var(--gold-2); }
.pcell { position: relative; display: flex; flex-direction: column; gap: 4px; }
/* Les vignettes montrent l'image entière, jamais recadrée : sur une planche contact,
   le cadrage fait partie de ce qu'on regarde. */
.pcell .pimg { aspect-ratio: 1; border-radius: 8px; background: #0a0a0c center/contain no-repeat; cursor: zoom-in;
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; transition: border-color .15s; }
.pcell .pimg:hover { border-color: #555; }
.pcell.picked .pimg { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.pcell .star { position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,.55); border: none; border-radius: 6px;
  color: #fff; font-size: 15px; line-height: 1; padding: 4px 6px; opacity: .75; }
.pcell .star:hover { opacity: 1; }
.pcell.picked .star { color: var(--gold-2); opacity: 1; }
.pcell .pname { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcell .pmeta { font-size: 10px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; min-height: 12px; }
.pcell .pmeta .pk { color: var(--gold-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Visionneuse d'image */
/* La grille doit être bornée en hauteur, sinon une image en portrait étire la colonne
   de droite et renvoie le formulaire hors de l'écran. */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(8,8,10,.94); display: grid;
  grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
.lightbox .lb-stage { position: relative; display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.5);
  border: 1px solid var(--line); color: #fff; font-size: 26px; line-height: 1; padding: 10px 14px; border-radius: 10px; }
.lightbox .lb-nav:hover { background: rgba(0,0,0,.8); }
.lightbox .lb-nav.prev { left: 14px; } .lightbox .lb-nav.next { right: 14px; }
.lightbox .lb-side { background: var(--bg-2); border-left: 1px solid var(--line); display: flex; flex-direction: column;
  gap: 10px; padding: 14px; overflow-y: auto; min-height: 0; }
.lightbox .lb-head { display: flex; align-items: center; gap: 8px; }
.lightbox .lb-info { font-size: 12px; }
.lightbox .lb-comments { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 40px; }
.lightbox .lb-form textarea { width: 100%; }
.composer .drawtag { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gold-2);
  background: rgba(201,164,74,.1); border: 1px solid rgba(201,164,74,.35); border-radius: 6px; padding: 4px 8px; }
.composer .drawtag .rmdraw { background: none; border: none; color: var(--muted); padding: 0 2px; margin-left: auto; }
.composer .drawtag .rmdraw:hover { color: var(--red); }
.controls .bar { display: flex; align-items: center; gap: 6px; }
.controls .tc { font-family: var(--mono); font-size: 13px; padding: 0 6px; min-width: 100px; }
.controls .tc.total { color: var(--muted); }
.controls select { width: auto; padding: 5px 8px; }
.stage .head-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.stage .head-row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage .head-row select { width: auto; max-width: 300px; padding: 5px 8px; }
.chip { white-space: nowrap; }

/* Panneau de commentaires */
.panel { display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--bg-2); min-height: 0; }
.panel .panel-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.panel .list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.comment { padding: 10px 12px; border-radius: 8px; background: var(--bg-3); border: 1px solid transparent; cursor: pointer; }
.comment:hover { border-color: #3a3a40; }
.comment.active { border-color: var(--gold); }
.comment.resolved { opacity: .55; }
.comment .head { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.comment .head .author { font-weight: 600; }
.comment .head .author.admin { color: var(--gold-2); }
.comment .head .tcb { font-family: var(--mono); color: var(--blue); background: rgba(91,156,245,.12); padding: 0 5px; border-radius: 4px; font-size: 11px; }
.comment .head .when { color: var(--muted); margin-left: auto; }
.comment .text { white-space: pre-wrap; word-break: break-word; }
.comment .actions { display: flex; gap: 4px; margin-top: 6px; }
.comment .replies { margin: 8px 0 0 12px; padding-left: 10px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.comment .reply { font-size: 13px; }
.comment .reply .head { margin-bottom: 2px; }
.panel .composer { padding: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.composer .tcb { font-family: var(--mono); color: var(--blue); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.composer textarea { min-height: 54px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13px; }

/* Modales */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin-bottom: 2px; }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #26262a; border: 1px solid #3a3a40; padding: 10px 16px; border-radius: 8px; z-index: 100; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.toast.err { border-color: var(--red); }

/* Page de connexion */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.login .brand { justify-content: center; margin-bottom: 8px; font-size: 15px; }

table.shares { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
table.shares td:last-child { width: 108px; }
table.shares .acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
table.shares .nt { color: var(--text); outline: none; border-bottom: 1px dotted transparent; }
table.shares .nt:focus { border-bottom-color: var(--gold); }
table.shares .nt:hover { border-bottom-color: var(--line); }
table.shares .nt:not(:empty) + .ntph { display: none; }
table.shares .ntph { font-style: italic; opacity: .7; }
table.shares .lng { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 4px;
  font-size: 10px; letter-spacing: .06em; padding: 1px 5px; cursor: pointer; font-family: inherit; }
table.shares .lng:hover { border-color: var(--gold); color: var(--gold-2); }
table.shares .seen { color: var(--blue); }
table.shares td, table.shares th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.shares th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.shares code { font-family: var(--mono); font-size: 12px; color: var(--gold-2); word-break: break-all; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); }

@media (max-width: 900px) {
  .viewer { grid-template-columns: 1fr; height: auto; }
  .viewer .stage { height: auto; overflow: visible; }
  .viewer .video-wrap { aspect-ratio: var(--ar, 16/9); flex: none; }
  .panel { border-left: none; border-top: 1px solid var(--line); max-height: 60vh; }
  .asset { grid-template-columns: 110px 1fr; }
  .asset > .right { grid-column: 1 / -1; }
  .controls .tc { min-width: 0; }
  .controls .bar { flex-wrap: wrap; }
  .controls .bar .grow.muted { display: none; }
  .controls .bar .dl { margin-left: auto; }
  .stage .head-row { flex-wrap: wrap; }
  .stage .head-row .title { flex-basis: 100%; }
  .topbar { gap: 10px; padding: 10px 12px; }
  .brand { font-size: 11px; letter-spacing: .08em; }
  .topbar .crumb { display: none; }
  body { overflow-x: hidden; }
  .cols { grid-template-columns: 1fr !important; }
  .head-projects h1 { flex: 1 1 100%; }
  .newp { flex: 1 1 100%; flex-wrap: wrap; }
  .newp .pname { flex: 1 1 100%; width: auto; }
  .newp .client { flex: 1 1 120px; width: auto; min-width: 0; }
  .newp .btn { flex: 0 0 auto; }
  .head-project > .grow { flex: 1 1 100%; }
  footer.credit { gap: 6px 14px; padding: 22px 16px 28px; }
  .pfolder .sheet { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; padding: 10px; }
  .lightbox { grid-template-columns: 1fr; grid-template-rows: 46vh minmax(0, 1fr); }
  .lightbox .lb-side { border-left: none; border-top: 1px solid var(--line); }
  .lightbox .lb-stage { padding: 10px; }
}

/* Dossiers de version */
.folder { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); overflow: hidden; }
.folder > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; align-items: center; gap: 10px; user-select: none; }
.folder > summary::-webkit-details-marker { display: none; }
.folder > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; font-size: 12px; }
.folder[open] > summary::before { transform: rotate(90deg); }
.folder > summary:hover { background: var(--bg-3); }
.folder .fname { font-weight: 600; font-size: 15px; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder .fmeta { display: flex; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.folder .fbody { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.folder .fbody .asset { background: var(--bg-3); }
.folder.latest > summary .fname { color: var(--gold-2); }
.folder .fname[contenteditable]:focus { outline: 1px solid var(--gold); border-radius: 4px; padding: 0 4px; }
.asset .meta .name[contenteditable]:focus { outline: 1px solid var(--gold); border-radius: 4px; padding: 0 4px; white-space: normal; }

/* Signature en pied de page, masquée pendant la lecture pour ne pas manger l'écran */
footer.credit { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap;
  padding: 26px 20px 34px; border-top: 1px solid var(--line); margin-top: 20px;
  font-size: 12px; color: var(--muted); letter-spacing: .01em; }
footer.credit b { color: var(--text); font-weight: 600; }
footer.credit a { color: var(--gold-2); }
footer.credit a:hover { text-decoration: underline; }
body.in-viewer footer.credit { display: none; }
