:root {
  --bg: #111214;
  --panel: #1a1b1f;
  --panel-2: #222328;
  --line: #2e2f36;
  --text: #eceef2;
  --muted: #8d909a;
  --accent: #7c6cf0;
  --accent-2: #9384ff;
  --ok: #3fb67a;
  --warn: #e6a23c;
  --danger: #ef5b5b;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.end { justify-content: flex-end; }
.error { color: var(--danger); margin: 0; }

/* ---------- Formulaires & boutons ---------- */

input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
select { width: auto; padding: 5px 8px; cursor: pointer; }
textarea { resize: vertical; min-height: 44px; }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
label.check input { width: auto; accent-color: var(--accent); }
label.check.small { font-size: 12px; color: var(--muted); gap: 5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #2b2c33; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.icon { padding: 6px 9px; min-width: 34px; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.ok { border-color: var(--ok); color: var(--ok); }
.btn.ok:hover:not(:disabled) { background: var(--ok); color: #fff; }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn.warn:hover:not(:disabled) { background: var(--warn); color: #111; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; padding: 2px 4px; }
.link:hover { color: var(--text); }
.link.danger:hover { color: var(--danger); }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.status-approved { background: rgba(63, 182, 122, .15); color: var(--ok); border-color: rgba(63, 182, 122, .35); }
.status-changes { background: rgba(230, 162, 60, .15); color: var(--warn); border-color: rgba(230, 162, 60, .35); }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: rgba(124, 108, 240, .2); color: var(--accent-2); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  color: #fff; font-size: 12px; font-weight: 700; flex: none;
}

/* ---------- Cadre ---------- */

.topbar {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px; flex: none;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-weight: 700; letter-spacing: .2px; }
#whoami { gap: 8px; }

main { flex: 1; min-height: 0; }
.page { overflow: auto; padding: 24px clamp(16px, 4vw, 40px) 60px; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.editable { cursor: text; border-radius: 6px; padding: 2px 6px; margin-left: -6px; }
.editable:hover { background: var(--panel-2); }

.center-page { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card.narrow { width: 100%; max-width: 380px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.card.setup { max-width: 460px; margin: 24px 0; }
.card.setup h2 { font-size: 15px; margin-top: 8px; }
.card.setup p { margin: 0; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.checks .ok { color: var(--ok); }
.checks .ko { color: var(--danger); }
details summary { cursor: pointer; font-size: 13px; }
details label { margin-top: 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.tile { display: flex; flex-direction: column; overflow: visible; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: #3d3e47; }
.thumb {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb-icon { font-size: 34px; color: #555; }
.thumb .duration, .thumb .ver {
  position: absolute; bottom: 8px; font-size: 11px; background: rgba(0, 0, 0, .7); color: #fff; border: 0;
}
.thumb .duration { right: 8px; padding: 2px 6px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.thumb .ver { left: 8px; }
.tile-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.tile-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu {
  position: absolute; top: 40px; right: 8px; z-index: 20;
  display: flex; flex-direction: column; min-width: 180px; padding: 4px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.menu button { background: none; border: 0; color: var(--text); font: inherit; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: #33343c; }
.menu button.danger { color: var(--danger); }

.empty-state {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 60px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.dropzone { cursor: pointer; }
.dropzone:hover { border-color: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 24px 12px; margin: 0; }
body.dragging::after {
  content: "Déposez vos fichiers ici";
  position: fixed; inset: 12px; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 600;
  border: 3px dashed var(--accent); border-radius: 16px;
  background: rgba(17, 18, 20, .85);
  pointer-events: none;
}

/* ---------- Modales, notifications, envois ---------- */

.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card { width: 100%; max-width: 420px; padding: 22px; display: flex; flex-direction: column; gap: 14px; max-height: 90vh; overflow: auto; }
.modal-card.wide { max-width: 640px; }
.modal-card p { margin: 0; }

.share-list { display: flex; flex-direction: column; gap: 10px; }
.share-item { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.share-item.inactive { opacity: .5; }
.share-url { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.share-new { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 16px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); transition: opacity .3s;
}
.toast.error { border-color: var(--danger); color: #ffb4b4; }
.toast.out { opacity: 0; }

.upload-tray {
  position: fixed; right: 16px; bottom: 16px; z-index: 60; width: min(360px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); max-height: 50vh; overflow: auto;
}
.upload-row { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.upload-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .track { height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.upload-row .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload-row.done .bar { background: var(--ok); }
.upload-row.failed .bar { background: var(--danger); }

/* ---------- Lecteur ---------- */

.page-viewer { display: flex; min-height: 0; }
.viewer { display: flex; flex: 1; min-width: 0; min-height: 0; }
.v-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #000; }
.v-top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.v-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.v-title strong, .v-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }
.v-title span { font-size: 12px; }
.status-area { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.stage { flex: 1; position: relative; min-height: 200px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.media-wrap { position: relative; }
.media-wrap video, .media-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; }
.media-wrap audio { display: none; }
.audio-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 80px; color: #333; background: radial-gradient(circle, #1d1e24, #000);
}
canvas.draw { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
canvas.draw.active { pointer-events: auto; cursor: crosshair; outline: 2px solid var(--accent); }
.media-error {
  position: absolute; inset: auto 16px 16px; padding: 12px 16px; border-radius: 8px;
  background: rgba(239, 91, 91, .15); border: 1px solid var(--danger);
  display: flex; flex-direction: column; gap: 2px;
}

.pins { position: absolute; inset: 0; pointer-events: none; }
.pin {
  position: absolute; transform: translate(-50%, -50%); pointer-events: auto;
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff;
  color: #fff; font-weight: 700; font-size: 12px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.pin.selected { transform: translate(-50%, -50%) scale(1.25); }
.pin.resolved { opacity: .45; }
.pin.new { background: var(--accent); display: flex; align-items: center; justify-content: center; }
.media-wrap:has(img) { cursor: crosshair; }

.controls { background: var(--panel); border-top: 1px solid var(--line); padding: 6px 12px 8px; }
.controls-row { gap: 4px; }
.controls .btn.icon { background: transparent; border-color: transparent; font-size: 15px; }
.controls .btn.icon:hover { background: var(--panel-2); }
.play { min-width: 40px; }
.tc { font-family: ui-monospace, Menlo, monospace; font-size: 13px; margin-left: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.speed { background: transparent; border-color: transparent; }

.timeline { position: relative; height: 26px; cursor: pointer; touch-action: none; }
.timeline .track { position: absolute; left: 0; right: 0; top: 15px; height: 4px; background: #33343c; border-radius: 2px; overflow: hidden; }
.timeline:hover .track { height: 6px; top: 14px; }
.timeline .buffer { position: absolute; inset: 0 auto 0 0; background: #4a4b55; }
.timeline .progress { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.markers { position: absolute; inset: 0; pointer-events: none; }
.marker {
  position: absolute; top: 2px; width: 10px; height: 10px; margin-left: -5px; padding: 0;
  border-radius: 50%; border: 2px solid var(--panel); cursor: pointer; pointer-events: auto;
}
.marker.resolved { opacity: .35; }
.marker.selected { transform: scale(1.4); border-color: #fff; }
.hover-tc {
  position: absolute; bottom: 28px; transform: translateX(-50%);
  background: #000; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px;
  font-family: ui-monospace, Menlo, monospace; font-size: 11px; pointer-events: none; white-space: nowrap;
}

/* ---------- Commentaires ---------- */

.v-side {
  width: 360px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--line);
}
.c-header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.c-header .count { color: var(--muted); font-weight: 500; }
.c-list { flex: 1; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.comment { border: 1px solid transparent; border-radius: 8px; padding: 10px; cursor: pointer; background: var(--panel-2); }
.comment:hover { border-color: var(--line); }
.comment.selected { border-color: var(--accent); }
.comment.resolved > .c-item .c-text { color: var(--muted); text-decoration: line-through; }
.c-item { display: flex; flex-direction: column; gap: 6px; }
.c-head { display: flex; align-items: center; gap: 7px; font-size: 13px; min-width: 0; }
.c-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-head .muted { font-size: 11px; white-space: nowrap; }
.c-text { white-space: pre-wrap; word-wrap: break-word; }
.c-actions { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.replies { margin: 8px 0 0 14px; padding-left: 10px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.replies .avatar { width: 20px; height: 20px; font-size: 10px; }

.tc-chip {
  font: 600 11px/1 ui-monospace, Menlo, monospace;
  padding: 4px 7px; border-radius: 5px; border: 1px solid var(--line);
  background: var(--bg); color: var(--muted); cursor: pointer; white-space: nowrap;
}
button.tc-chip:hover { color: var(--text); }
.tc-chip.on, .comment .tc-chip { color: var(--accent-2); border-color: rgba(124, 108, 240, .5); }

.composer { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.reply-banner { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--accent-2); }
.tools { gap: 4px; flex-wrap: wrap; }
.tool { font-size: 15px; background: transparent; border-color: transparent; }
.tool.on { background: rgba(124, 108, 240, .25); border-color: var(--accent); }
.swatches { display: flex; gap: 4px; margin-left: 2px; }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: #fff; }

/* ---------- Petits écrans ---------- */

@media (max-width: 860px) {
  .page-viewer { overflow: auto; }
  .viewer { flex-direction: column; min-height: auto; }
  .v-main { flex: none; }
  .speed { display: none; }
  .tc { font-size: 11px; margin-left: 2px; }
  .controls .btn.icon { min-width: 30px; padding: 6px 4px; }
  .stage { flex: none; height: 56vw; min-height: 220px; max-height: 60vh; }
  .v-side { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  .c-list { max-height: none; overflow: visible; }
  .v-title strong, .v-title span { max-width: 60vw; }
}
