:root{
  --bg:#F6F4EF; --surface:#FFFFFF; --surface-2:#FBFAF6;
  --text:#1E2027; --muted:#6B6E76;
  --border:#E3E0D8; --border-strong:#D4D0C5;
  --accent:#3730A3; --accent-ink:#FFFFFF; --accent-soft:#ECEBFA; --focus:#3730A3;
  --total-fg:#166534; --total-bg:#DCFCE7; --total-bd:#86EFAC;
  --ecriture-fg:#92400E; --ecriture-bg:#FEF3C7; --ecriture-bd:#FCD34D;
  --lecture-fg:#1D4ED8; --lecture-bg:#DBEAFE; --lecture-bd:#93C5FD;
  --aucun-fg:#71717A; --aucun-bg:#F1F0EC; --aucun-bd:#DDD9CF;
  --danger-fg:#B91C1C; --danger-bg:#FEE2E2; --danger-bd:#FCA5A5;
  --shadow: 0 1px 2px rgba(30,32,39,.06), 0 8px 24px -12px rgba(30,32,39,.18);
  --radius: 10px;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#15171C; --surface:#1C1F26; --surface-2:#20232B; --text:#E7E8EC; --muted:#9198A6;
    --border:#2B2F39; --border-strong:#383D49; --accent:#8B85F0; --accent-ink:#14161B; --accent-soft:#26243F; --focus:#8B85F0;
    --total-fg:#4ADE80; --total-bg:#123321; --total-bd:#1F5C39;
    --ecriture-fg:#FBBF24; --ecriture-bg:#3A2A0C; --ecriture-bd:#6B4E12;
    --lecture-fg:#60A5FA; --lecture-bg:#122A4A; --lecture-bd:#1E4577;
    --aucun-fg:#8A8F99; --aucun-bg:#23252B; --aucun-bd:#33363E;
    --danger-fg:#F87171; --danger-bg:#3A1616; --danger-bd:#6B2323;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -16px rgba(0,0,0,.6);
  }
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{background:var(--bg); color:var(--text); font-family:"Segoe UI",-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,sans-serif; -webkit-font-smoothing:antialiased;}
h1,h2,h3{font-family:"Iowan Old Style","Palatino Linotype",Georgia,serif; margin:0;}
a{color:var(--accent);}

.topbar{display:flex; align-items:center; justify-content:space-between; padding:14px 24px; border-bottom:1px solid var(--border); background:var(--surface);}
.topbar .brand{font-size:15px; font-weight:600; display:flex; align-items:center; gap:8px; text-decoration:none; color:var(--text);}
.topbar .brand .dot{width:8px; height:8px; border-radius:50%; background:var(--accent);}
.topbar nav{display:flex; gap:18px; align-items:center; font-size:13.5px;}
.topbar nav a{color:var(--muted); text-decoration:none; font-weight:600;}
.topbar nav a:hover{color:var(--text);}
.topbar .user{font-size:12.5px; color:var(--muted);}

.shell{max-width:1080px; margin:0 auto; padding:28px 24px 100px;}
.shell-narrow{max-width:520px; margin:60px auto; padding:0 24px;}

.card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); padding:22px 24px; margin-bottom:18px;}
.card h2{font-size:16px; font-weight:600; margin-bottom:4px;}
.card .card-sub{font-size:12.5px; color:var(--muted); margin:0 0 16px;}

.tabs-nav{display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:20px; flex-wrap:wrap;}
.tabs-nav button{background:none; border:none; padding:10px 16px; font-size:13.5px; font-weight:600; color:var(--muted); cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px;}
.tabs-nav button.active{color:var(--accent); border-bottom-color:var(--accent);}
.tabs-nav button:hover{color:var(--text);}
.tab-panel{display:none;}
.tab-panel.active{display:block;}

.field{margin-bottom:16px;}
.field:last-child{margin-bottom:0;}
.field-row{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.field-section-title{font-size:12px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; margin:24px 0 14px; padding-top:18px; border-top:1px solid var(--border);}
.field-section-title:first-child{margin-top:0; padding-top:0; border-top:none;}
label{display:block; font-size:12.5px; font-weight:600; color:var(--text); margin-bottom:6px;}
.optional{font-weight:400; color:var(--muted);}
.hint{font-size:11.5px; color:var(--muted); margin-top:5px; line-height:1.4;}

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="number"], input[type="tel"], textarea, select{
  width:100%; font-family:inherit; font-size:14px; color:var(--text); background:var(--surface);
  border:1px solid var(--border-strong); border-radius:8px; padding:9px 12px;
  color-scheme:light; /* évite une icône de calendrier illisible en thème sombre */
}
select{appearance:none; -webkit-appearance:none; cursor:pointer;}
input:focus, select:focus, textarea:focus{outline:2px solid var(--focus); outline-offset:1px; border-color:var(--focus);}
input[type="datetime-local"]::-webkit-calendar-picker-indicator{cursor:pointer; opacity:.65;}
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover{opacity:1;}
@media (prefers-color-scheme: dark){
  input[type="date"], input[type="time"], input[type="datetime-local"]{ color-scheme:dark; }
}
input[type="color"]{width:auto; height:38px; padding:3px; cursor:pointer;}

input[type="file"]{font-family:inherit; font-size:13px; color:var(--muted);}
input[type="file"]::file-selector-button{
  font-family:inherit; font-size:14px; font-weight:600; background:none; color:var(--muted);
  border:1px solid var(--border-strong); border-radius:9px; padding:9px 14px; cursor:pointer; margin-right:10px;
}
input[type="file"]::file-selector-button:hover{color:var(--text); border-color:var(--text);}

.btn-primary{
  display:inline-flex; align-items:center; gap:8px; font-family:inherit; font-size:14px; font-weight:600;
  background:var(--accent); color:var(--accent-ink); border:none; border-radius:9px; padding:11px 18px; cursor:pointer; text-decoration:none;
}
.btn-primary:hover{filter:brightness(1.08);}
.btn-secondary{
  font-family:inherit; font-size:14px; font-weight:600; background:none; color:var(--muted);
  border:1px solid var(--border-strong); border-radius:9px; padding:10px 16px; cursor:pointer; text-decoration:none; display:inline-flex; align-items:center; gap:6px;
}
.btn-secondary:hover{color:var(--text); border-color:var(--text);}

.alert{padding:11px 14px; border-radius:8px; font-size:13.5px; margin-bottom:16px; border:1px solid transparent;}
.alert-error{background:var(--danger-bg); color:var(--danger-fg); border-color:var(--danger-bd);}
.alert-success{background:var(--total-bg); color:var(--total-fg); border-color:var(--total-bd);}
.alert-info{background:var(--lecture-bg); color:var(--lecture-fg); border-color:var(--lecture-bd);}

.pill{display:inline-flex; align-items:center; gap:5px; font-size:11px; font-weight:600; padding:4px 10px; border-radius:999px; border:1px solid transparent; white-space:nowrap;}
.pill-admin, .pill-total{color:var(--accent); background:var(--accent-soft); border-color:var(--accent-soft);}
.pill-role, .pill-aucun{color:var(--aucun-fg); background:var(--aucun-bg); border-color:var(--aucun-bd);}
.pill-actif, .pill-total-lvl{color:var(--total-fg); background:var(--total-bg); border-color:var(--total-bd);}
.pill-invite, .pill-ecriture{color:var(--ecriture-fg); background:var(--ecriture-bg); border-color:var(--ecriture-bd);}
.pill-lecture{color:var(--lecture-fg); background:var(--lecture-bg); border-color:var(--lecture-bd);}

.table-wrap{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); overflow:auto;}
table{border-collapse:separate; border-spacing:0; width:100%;}
thead th{
  text-align:left; padding:11px 14px; font-size:11px; font-weight:600; letter-spacing:.04em; text-transform:uppercase;
  color:var(--muted); border-bottom:1px solid var(--border-strong); background:var(--surface-2); white-space:nowrap;
}
tbody td{padding:12px 14px; font-size:13.5px; border-bottom:1px solid var(--border); vertical-align:middle;}
tbody tr:last-child td{border-bottom:none;}
tbody tr:hover td{background:var(--surface-2);}
.empty-row td{text-align:center; color:var(--muted); padding:30px 14px;}

/* Matrice rôles/permissions : la colonne "Module" reste visible au scroll
   horizontal (peut vite s'allonger si beaucoup de rôles sont créés). */
.roles-matrix table{width:auto; min-width:100%;}
.roles-matrix th:first-child,
.roles-matrix td:first-child{
  position:sticky; left:0; z-index:2;
  background:var(--surface);
  box-shadow:2px 0 4px -2px rgba(0,0,0,.2);
  white-space:normal;
}
.roles-matrix thead th:first-child{ background:var(--surface-2); z-index:3; }
.roles-matrix tbody tr:hover td:first-child{ background:var(--surface-2); }

.project-grid{display:grid; grid-template-columns:repeat(auto-fill, minmax(260px,1fr)); gap:16px;}
.project-card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); padding:16px 18px; text-decoration:none; color:var(--text); display:block;}
.project-card:hover{border-color:var(--accent);}
.project-card-thumb{width:100%; height:120px; object-fit:cover; border-radius:8px; margin-bottom:12px; display:block;}
.project-card-thumb.project-thumb-placeholder{display:flex; align-items:center; justify-content:center; background:var(--surface-2); border:1px solid var(--border); font-size:34px;}
.project-card h3{font-size:15px; font-weight:600; margin-bottom:6px;}
.project-card .meta{font-size:12px; color:var(--muted); margin-top:4px;}

.page-head{display:flex; justify-content:space-between; align-items:flex-end; gap:20px; margin-bottom:20px; flex-wrap:wrap;}
.page-head h1{font-size:24px; font-weight:600;}
.page-head p{margin:6px 0 0; color:var(--muted); font-size:13.5px;}
.page-head-title{display:flex; align-items:center; gap:14px;}
.project-thumb-link{display:block; line-height:0; flex-shrink:0;}
.project-thumb-sm{width:48px; height:48px; object-fit:cover; border-radius:10px; display:block;}
.project-thumb-sm.project-thumb-placeholder{display:flex; align-items:center; justify-content:center; background:var(--surface-2); border:1px solid var(--border); font-size:22px;}

.lvl-select{font-size:12.5px; font-weight:600; padding:5px 8px; border-radius:8px;}
.lvl-total{color:var(--total-fg); background-color:var(--total-bg); border-color:var(--total-bd);}
.lvl-ecriture{color:var(--ecriture-fg); background-color:var(--ecriture-bg); border-color:var(--ecriture-bd);}
.lvl-lecture{color:var(--lecture-fg); background-color:var(--lecture-bg); border-color:var(--lecture-bd);}
.lvl-aucun{color:var(--aucun-fg); background-color:var(--aucun-bg); border-color:var(--aucun-bd);}

.invite-box{background:var(--accent-soft); border:1px solid var(--accent-soft); border-radius:9px; padding:12px 14px; margin-top:10px; font-size:13px;}
.invite-box code{display:block; word-break:break-all; background:var(--surface); border:1px solid var(--border); border-radius:6px; padding:8px 10px; margin-top:6px; font-size:12px;}

/* ---- Timeline programmation ---- */
.timeline-wrap{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); overflow:auto; padding:0 0 4px;}
.timeline{position:relative; padding:0 20px 16px;}
.timeline-axis{display:flex; position:sticky; top:0; background:var(--surface); z-index:3; border-bottom:1px solid var(--border-strong); padding:12px 0 8px;}
.timeline-axis .scene-label-spacer{width:150px; flex:none;}
.hour-mark{flex:none; font-size:11px; font-weight:600; color:var(--muted); text-align:left; border-left:1px solid var(--border); padding-left:6px;}
.scene-row{display:flex; align-items:stretch; border-bottom:1px solid var(--border); min-height:64px;}
.scene-row:last-child{border-bottom:none;}
.scene-label{width:150px; flex:none; display:flex; align-items:center; gap:8px; font-size:13px; font-weight:600; padding:10px 10px 10px 0; position:sticky; left:0; background:var(--surface); z-index:2;}
.scene-dot{width:9px; height:9px; border-radius:50%; flex:none;}
.scene-track{position:relative; flex:1; padding:8px 0; background-image:repeating-linear-gradient(to right, var(--border) 0, var(--border) 1px, transparent 1px, transparent 100px);}
.passage-block{position:absolute; top:8px; bottom:8px; border-radius:8px; padding:6px 9px; cursor:grab; overflow:hidden; border:1px solid transparent; transition:filter .12s ease, box-shadow .12s ease;}
.passage-block:hover{filter:brightness(1.06);}
.passage-block.dragging{cursor:grabbing; box-shadow:0 4px 14px rgba(0,0,0,.22); z-index:5; transition:none;}
.passage-artiste{font-size:12.5px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.passage-style{font-size:11px; opacity:.85; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.passage-time{font-size:10px; opacity:.75; white-space:nowrap;}
.resize-handle{position:absolute; top:0; bottom:0; width:8px; cursor:ew-resize;}
.resize-handle.resize-left{left:0;}
.resize-handle.resize-right{right:0;}
.resize-handle:hover, .passage-block.dragging .resize-handle{background:rgba(255,255,255,.35);}
.legend-row{display:flex; gap:14px; flex-wrap:wrap; margin:14px 0 0; font-size:12px; color:var(--muted);}
.legend-item{display:flex; align-items:center; gap:6px;}
.legend-dot{width:9px; height:9px; border-radius:50%;}
.artist-summary{background:var(--surface-2); border:1px solid var(--border); border-radius:9px; padding:10px 12px; margin-bottom:14px; font-size:12.5px; color:var(--text); line-height:1.7;}
.artist-summary b{color:var(--muted); font-weight:600;}
.artist-summary .edit-link{display:inline-flex; align-items:center; gap:4px; font-size:12px; font-weight:600; color:var(--accent); background:none; border:none; cursor:pointer; padding:0; margin-top:4px;}
.artist-summary .edit-link:hover{text-decoration:underline;}

/* ---- Modales génériques ---- */
.modal-overlay{position:fixed; inset:0; background:rgba(20,20,24,.45); display:flex; align-items:center; justify-content:center; padding:20px; z-index:20; opacity:0; pointer-events:none; transition:opacity .18s ease;}
.modal-overlay.show{opacity:1; pointer-events:auto;}
.modal-card{background:var(--surface); border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow); max-width:460px; width:100%; padding:22px 24px; max-height:88vh; overflow:auto; transform:translateY(8px) scale(.98); transition:transform .18s ease;}
.modal-overlay.show .modal-card{transform:translateY(0) scale(1);}
.modal-card h2{font-size:18px; font-weight:600; margin-bottom:16px;}
.modal-actions{display:flex; justify-content:space-between; align-items:center; margin-top:18px; gap:10px;}
.modal-actions-right{display:flex; gap:8px;}
.btn-danger-text{font-family:inherit; font-size:12.5px; font-weight:600; background:none; color:var(--danger-fg); border:none; cursor:pointer; padding:0;}
.btn-danger-text:hover{text-decoration:underline;}
.error-text{display:none; margin-top:5px; font-size:12px; color:var(--danger-fg); align-items:center; gap:5px;}
.error-text.show{display:flex;}
.color-swatches{display:flex; gap:8px; flex-wrap:wrap;}
.color-swatch{width:26px; height:26px; border-radius:50%; cursor:pointer; border:2px solid transparent;}
.color-swatch.selected{border-color:var(--text);}
.disclosure-row{display:flex; gap:8px; margin-bottom:14px;}
.disclosure-btn{font-family:inherit; font-size:12.5px; font-weight:600; padding:8px 13px; border-radius:8px; border:1px dashed var(--border-strong); background:none; color:var(--muted); cursor:pointer; display:inline-flex; align-items:center; gap:6px;}
.disclosure-btn:hover{color:var(--accent); border-color:var(--accent); background:var(--accent-soft);}
.disclosure-btn.open{color:var(--accent); border-style:solid; border-color:var(--accent-soft); background:var(--accent-soft);}
.disclosure-section{border:1px solid var(--border); border-radius:9px; padding:12px 14px; margin-bottom:14px; background:var(--surface-2);}
.ai-extract-field{border:1px dashed var(--accent-soft); border-radius:9px; padding:12px 14px; background:var(--accent-soft);}
.ai-extract-field label{color:var(--accent);}

.doc-section{border-top:1px solid var(--border); margin-top:6px; padding-top:14px; margin-bottom:14px;}
.doc-section h3{font-size:12.5px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); margin-bottom:2px;}
.doc-list{display:flex; flex-direction:column; gap:8px; margin-bottom:12px;}
.doc-item{display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--border); border-radius:8px; padding:8px 10px;}
.doc-item .pdf-icon{width:26px; height:26px; border-radius:6px; background:var(--danger-bg); color:var(--danger-fg); display:flex; align-items:center; justify-content:center; flex:none; font-size:10px; font-weight:700;}
.doc-item .doc-info{flex:1; min-width:0;}
.doc-item .doc-label{font-size:12.5px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-decoration:none; display:block;}
.doc-item .doc-type{font-size:11px; color:var(--muted);}
.doc-item .doc-actions{display:flex; gap:6px; flex:none;}
.doc-empty{font-size:12.5px; color:var(--muted); font-style:italic; margin-bottom:12px;}

.toast{position:fixed; left:50%; bottom:22px; transform:translate(-50%, 120%); background:var(--total-bg); color:var(--total-fg); border:1px solid var(--total-bd); padding:11px 18px; border-radius:10px; font-size:13.5px; font-weight:600; display:flex; align-items:center; gap:8px; transition:transform .3s cubic-bezier(.16,1,.3,1); z-index:30; max-width:calc(100vw - 32px);}
.toast.show{transform:translate(-50%, 0);}
.toast.toast-error{background:var(--danger-bg); color:var(--danger-fg); border-color:var(--danger-bd);}

.bo-layout{display:flex; align-items:flex-start; max-width:1180px; margin:0 auto; gap:0;}
.bo-sidebar{width:236px; flex:none; padding:28px 14px; display:flex; flex-direction:column; gap:2px; position:sticky; top:0;}
.bo-sidebar .bo-title{font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); padding:4px 10px 10px;}
.bo-nav-item{
  display:block; padding:9px 12px; border-radius:8px; color:var(--muted); font-size:13.5px; font-weight:600;
  text-decoration:none;
}
.bo-nav-item:hover{background:var(--surface-2); color:var(--text);}
.bo-nav-item.active{background:var(--accent-soft); color:var(--accent);}
.bo-content{flex:1; min-width:0; padding:28px 24px 100px;}
.bo-content .shell{max-width:100%; margin:0; padding:0;}
@media (max-width:860px){
  .bo-layout{flex-direction:column;}
  .bo-sidebar{width:100%; flex-direction:row; overflow-x:auto; position:static; padding:14px;}
}
