/* ============================================================
   BAC DE FRANÇAIS — Styles
   ============================================================ */
:root{
  --bg:#f1f5f9;--surface:#fff;--surface2:#f9fafb;--border:#e5e7eb;
  --text-1:#111827;--text-2:#374151;--text-m:#6b7280;
  --input-bg:#fff;--input-border:#d1d5db;
  --tab-bg:#f3f4f6;--tab-color:#374151;
  --stab-bg:#e5e7eb;--stab-color:#374151;
  --card-shadow:0 1px 4px rgba(0,0,0,.08);
  --part-head:#f3f4f6;--drop-bg:#f9fafb;
  --opt-bg:#fff;--opt-color:#374151;--opt-border:#d1d5db;
  --note-bg:#fef9c3;--note-border:#fde68a;--note-text:#78350f;--note-date:#92400e;
  --doc-bg:#f0f9ff;--doc-border:#bae6fd;--ai-box:#fff;
  --code-bg:#fef9c3;--code-text:#78350f;
}
body.dark{
  --bg:#0f172a;--surface:#1e293b;--surface2:#0f172a;--border:#334155;
  --text-1:#f1f5f9;--text-2:#cbd5e1;--text-m:#94a3b8;
  --input-bg:#1e293b;--input-border:#475569;
  --tab-bg:#1e293b;--tab-color:#cbd5e1;
  --stab-bg:#334155;--stab-color:#cbd5e1;
  --card-shadow:0 1px 4px rgba(0,0,0,.4);
  --part-head:#0f172a;--drop-bg:#1e293b;
  --opt-bg:#1e293b;--opt-color:#cbd5e1;--opt-border:#475569;
  --note-bg:#1c1a0a;--note-border:#78350f;--note-text:#fde68a;--note-date:#d97706;
  --doc-bg:#0c1e2e;--doc-border:#0369a1;--ai-box:#1e293b;
  --code-bg:#1c1a0a;--code-text:#fde68a;
}
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:'Segoe UI',sans-serif;background:var(--bg);min-height:100vh;color:var(--text-2);transition:background .2s,color .2s}

/* HEADER */
.header{background:linear-gradient(135deg,#1e1b4b,#4f46e5);color:#fff;padding:16px 24px;display:flex;justify-content:space-between;align-items:flex-start;flex-wrap:wrap;gap:10px}
.header h1{font-size:18px;font-weight:800}
.header p{font-size:12px;opacity:.85;margin-top:4px}
.header-right{display:flex;flex-direction:column;align-items:flex-end;gap:6px;flex-shrink:0}
.header-btns{display:flex;gap:8px}
.icon-btn{background:rgba(255,255,255,.15);border:1px solid rgba(255,255,255,.25);color:#fff;border-radius:8px;padding:6px 10px;cursor:pointer;font-size:14px;white-space:nowrap;transition:background .15s}
.icon-btn:hover{background:rgba(255,255,255,.25)}
.ai-badge{display:flex;align-items:center;gap:7px;background:rgba(0,0,0,.3);border-radius:20px;padding:5px 12px;font-size:11px;font-weight:600;color:#e0e7ff}
.ai-dot{width:7px;height:7px;border-radius:50%;background:#6b7280;flex-shrink:0;transition:background .3s}
.ai-dot.idle{background:#6b7280}
.ai-dot.loading{background:#f59e0b;animation:blink .7s infinite alternate}
.ai-dot.ready{background:#22c55e}
.ai-dot.error{background:#ef4444}
@keyframes blink{to{opacity:.2}}

/* TABS */
.tabs{display:flex;gap:6px;padding:11px 16px;background:var(--surface);border-bottom:1px solid var(--border);flex-wrap:wrap;overflow-x:auto}
.tab{padding:7px 14px;border-radius:20px;border:none;cursor:pointer;font-weight:700;font-size:12px;background:var(--tab-bg);color:var(--tab-color);transition:all .15s;white-space:nowrap}
.tab.on{background:#4f46e5;color:#fff}
.tab.disabled{opacity:.4;cursor:not-allowed}

/* PAGES */
.page{display:none;padding:14px;max-width:1200px;margin:0 auto}
.page.on{display:block}

/* ŒUVRE SELECTOR */
.oeuvre-selector{display:flex;gap:8px;margin-bottom:14px;flex-wrap:wrap}
.oeuvre-btn{padding:10px 16px;border-radius:10px;border:2px solid var(--border);background:var(--surface);color:var(--text-2);font-weight:600;font-size:13px;cursor:pointer;transition:all .15s;display:flex;align-items:center;gap:8px}
.oeuvre-btn:hover{border-color:var(--oeuvre-color,#4f46e5);transform:translateY(-1px)}
.oeuvre-btn.on{background:var(--oeuvre-color,#4f46e5);color:#fff;border-color:var(--oeuvre-color,#4f46e5)}
.oeuvre-icon{font-size:18px}

/* CARDS */
.card{background:var(--surface);border-radius:10px;margin-bottom:13px;box-shadow:var(--card-shadow);overflow:hidden}
.card-head{padding:13px 16px;cursor:pointer;display:flex;justify-content:space-between;align-items:center;user-select:none}
.card-body{padding:0 16px 14px;display:none}
.card-body.on{display:block}

/* PART */
.part{border:1px solid var(--border);border-radius:8px;margin-top:10px;overflow:hidden}
.part-head{padding:9px 13px;background:var(--part-head);cursor:pointer;display:flex;justify-content:space-between;font-weight:600;font-size:13px;user-select:none;color:var(--text-2)}
.part-body{padding:13px;display:none;background:var(--surface)}
.part-body.on{display:block}

/* BLOCKS */
.block{padding:8px 12px;border-radius:0 6px 6px 0;margin-bottom:9px;font-size:13px;line-height:1.65}
.block:last-child{margin-bottom:0}
.block b{display:block;font-size:11px;margin-bottom:3px}
.b1{background:#eff6ff;border-left:3px solid #3b82f6;color:#1e40af}
.b2{background:#f0fdf4;border-left:3px solid #22c55e;color:#166534}
.b3{background:#fef9c3;border-left:3px solid #eab308;color:#78350f;font-style:italic}
.b4{background:#fdf4ff;border-left:3px solid #a855f7;color:#6b21a8}
body.dark .b1{background:#1e3a5f;color:#93c5fd}
body.dark .b2{background:#14352a;color:#86efac}
body.dark .b3{background:#2c2200;color:#fde68a}
body.dark .b4{background:#2d1b4e;color:#d8b4fe}

/* QCM */
.opt{padding:8px 12px;margin-bottom:5px;border-radius:6px;cursor:pointer;border:1.5px solid var(--opt-border);background:var(--opt-bg);color:var(--opt-color);font-size:13px;transition:all .12s}
.opt:hover{border-color:#93c5fd;background:#f0f9ff}
body.dark .opt:hover{background:#0c2340}
.opt.sel{background:#eff6ff;border-color:#3b82f6;color:#1d4ed8;font-weight:600}
body.dark .opt.sel{background:#1e3a5f;color:#93c5fd}
.opt.ok{background:#dcfce7;border-color:#22c55e;color:#15803d;font-weight:600}
.opt.ko{background:#fef2f2;border-color:#ef4444;color:#dc2626;font-weight:600}
body.dark .opt.ok{background:#14352a;color:#86efac}
body.dark .opt.ko{background:#2c1a1a;color:#fca5a5}
.badge{padding:4px 12px;border-radius:20px;font-weight:700;font-size:13px}
.badge.ok{background:#dcfce7;color:#15803d}
.badge.ko{background:#fef2f2;color:#dc2626}

/* BUTTONS */
.btn{padding:9px 18px;border:none;border-radius:8px;font-weight:700;cursor:pointer;font-size:13px;margin-right:6px;margin-top:4px;transition:opacity .15s}
.btn:hover{opacity:.85}
.btn-p{background:#4f46e5;color:#fff}
.btn-g{background:#6b7280;color:#fff}
.btn-o{background:var(--surface);border:2px solid #4f46e5;color:#4f46e5}
.btn-v{background:#059669;color:#fff}
.btn-r{background:#dc2626;color:#fff}
.btn-y{background:#ca8a04;color:#fff}
.btn:disabled{opacity:.5;cursor:not-allowed}

/* NOTES */
.note{padding:10px 13px;border-radius:8px;background:var(--note-bg);border:1px solid var(--note-border);margin-bottom:9px;position:relative}
.note-date{font-size:11px;color:var(--note-date);display:block;margin-bottom:3px}
.note-text{font-size:13px;color:var(--note-text);white-space:pre-wrap;margin-right:24px}
.del{position:absolute;top:8px;right:10px;background:none;border:none;cursor:pointer;color:#d97706;font-size:16px}

/* DROP / DOCS */
.drop{padding:14px;background:var(--drop-bg);border-radius:8px;border:2px dashed var(--border);margin-bottom:14px;display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.doc-card{padding:11px 14px;border-radius:8px;background:var(--doc-bg);border:1px solid var(--doc-border);margin-bottom:10px}
.doc-title{font-weight:600;color:#0369a1;font-size:13px;display:flex;justify-content:space-between;align-items:center}
.doc-content{font-size:12px;color:var(--text-m);margin-top:7px;white-space:pre-wrap;max-height:120px;overflow-y:auto;line-height:1.5}

/* SUB-TABS */
.stabs{display:flex;gap:6px;margin-bottom:13px;flex-wrap:wrap}
.stab{padding:6px 13px;border-radius:16px;border:none;cursor:pointer;font-weight:600;font-size:12px;background:var(--stab-bg);color:var(--stab-color)}
.stab.on{background:#4f46e5;color:#fff}

/* INPUTS */
input[type=text],textarea,select{width:100%;padding:9px 12px;border-radius:8px;border:1.5px solid var(--input-border);font-size:13px;font-family:inherit;background:var(--input-bg);color:var(--text-1)}
input[type=range]{width:100%}
.row{display:flex;gap:8px;align-items:stretch}
.row input{flex:1}
.empty{color:var(--text-m);font-size:13px;text-align:center;padding:24px}
.info{font-size:12px;color:var(--text-m);margin-bottom:12px;line-height:1.6}
.label{font-size:12px;font-weight:700;color:var(--text-2);display:block;margin-bottom:5px;margin-top:10px}
.err{color:#dc2626;font-size:12px;margin-top:7px}

/* AI */
.ai-box{background:var(--ai-box);border-radius:10px;padding:18px;box-shadow:var(--card-shadow);margin-bottom:14px}
.loader{display:inline-block;width:13px;height:13px;border:2px solid #c7d2fe;border-top-color:#4f46e5;border-radius:50%;animation:spin .7s linear infinite;vertical-align:middle;margin-right:5px}
@keyframes spin{to{transform:rotate(360deg)}}
.tag{display:inline-block;padding:3px 9px;border-radius:12px;font-size:11px;font-weight:700;margin-right:4px;margin-bottom:4px;cursor:pointer;border:1.5px solid transparent}
.tag:hover{opacity:.8}
.ai-fiche-card{background:var(--surface);border-radius:10px;box-shadow:var(--card-shadow);overflow:hidden;margin-bottom:14px}
.ai-fiche-head{padding:13px 16px;display:flex;justify-content:space-between;align-items:center;border-left:4px solid #7c3aed;background:var(--surface2)}
.doc-used{background:#f0fdf4;border:1px solid #86efac;border-radius:6px;padding:8px 12px;font-size:12px;color:#166534;margin-bottom:10px}
body.dark .doc-used{background:#14352a;border-color:#166534;color:#86efac}

/* DISSERT */
.dissert-section{margin-bottom:14px}
.dissert-head{background:linear-gradient(90deg,#7c3aed22,transparent);border-left:4px solid #7c3aed;padding:10px 14px;border-radius:0 8px 8px 0;font-weight:700;font-size:13px;color:#7c3aed;margin-bottom:8px}
.dissert-block{background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:12px;margin-bottom:8px;font-size:13px;line-height:1.65;color:var(--text-2)}
.dissert-block b{display:block;font-size:11px;font-weight:700;color:var(--text-m);margin-bottom:4px;text-transform:uppercase}

/* OVERLAY */
#ai-overlay{display:none;position:fixed;inset:0;background:rgba(10,15,30,.72);z-index:9999;flex-direction:column;align-items:center;justify-content:center;gap:20px;backdrop-filter:blur(3px)}
.ai-overlay-spinner{width:56px;height:56px;border:4px solid rgba(129,140,248,.3);border-top-color:#4f46e5;border-radius:50%;animation:spin .75s linear infinite}
#ai-overlay-txt{color:#e0e7ff;font-size:15px;font-weight:700;text-align:center;max-width:280px;line-height:1.5}
#ai-overlay-sub{color:#a5b4fc;font-size:12px;text-align:center}

/* ============= EL VIEWER (split layout) =================== */
.el-list{display:grid;gap:10px;margin-bottom:14px}
.el-list-item{padding:12px 14px;border-radius:10px;border:2px solid var(--border);background:var(--surface);cursor:pointer;transition:all .15s;display:flex;justify-content:space-between;align-items:center;gap:12px}
.el-list-item:hover{border-color:#4f46e5;transform:translateX(2px)}
.el-list-item.on{border-color:#4f46e5;background:linear-gradient(90deg,#4f46e511,transparent)}
.el-num{flex-shrink:0;width:36px;height:36px;border-radius:50%;background:var(--oeuvre-color,#4f46e5);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:14px}
.el-meta{flex:1;min-width:0}
.el-title-text{font-weight:700;font-size:14px;color:var(--text-1);margin-bottom:2px}
.el-borne{font-size:12px;color:var(--text-m);font-style:italic;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.el-placeholder-tag{background:#fef3c7;color:#92400e;font-size:10px;padding:2px 8px;border-radius:10px;font-weight:700;flex-shrink:0}

.el-viewer{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:14px}
@media (max-width:900px){.el-viewer{grid-template-columns:1fr}}

.el-pane{background:var(--surface);border-radius:10px;box-shadow:var(--card-shadow);display:flex;flex-direction:column;min-height:400px}
.el-pane-head{padding:10px 14px;border-bottom:1px solid var(--border);font-weight:700;font-size:13px;color:var(--text-1);display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:6px}
.el-pane-body{padding:14px;overflow-y:auto;flex:1;font-size:13px;line-height:1.7;color:var(--text-2)}
.el-texte-body{white-space:pre-wrap;font-family:'Georgia',serif;font-size:14px;line-height:1.85;color:var(--text-1)}
body.dark .el-texte-body{color:var(--text-1)}

/* mode toggle (rédigé / notes) */
.el-mode-toggle{display:flex;gap:4px}
.el-mode-btn{padding:5px 10px;border-radius:6px;border:1px solid var(--border);background:var(--surface2);color:var(--text-2);cursor:pointer;font-size:11px;font-weight:600}
.el-mode-btn.on{background:#4f46e5;color:#fff;border-color:#4f46e5}

.notes-style{font-family:'Courier New',monospace;font-size:13px;white-space:pre-wrap;line-height:1.7;background:var(--code-bg);color:var(--code-text);padding:12px;border-radius:8px}

.el-redige h3{color:var(--text-1);font-size:14px;margin-top:16px;margin-bottom:8px;padding-bottom:4px;border-bottom:2px solid var(--border)}
.el-redige h3:first-child{margin-top:0}
.el-redige p{margin-bottom:10px}
.el-redige strong{color:var(--text-1)}
.el-redige em{color:#7c3aed}
body.dark .el-redige em{color:#c4b5fd}
.el-redige ul,.el-redige ol{margin-left:20px;margin-bottom:10px}
.el-redige li{margin-bottom:4px}

/* GRAMMAIRE inside EL */
.gram-card{background:var(--surface2);border:1px solid var(--border);border-radius:8px;padding:12px;margin-bottom:10px}
.gram-q{font-weight:700;color:var(--text-1);margin-bottom:8px;font-size:13px}
.gram-rep{padding:10px;background:var(--surface);border-left:3px solid #059669;border-radius:0 6px 6px 0;font-size:13px;color:var(--text-2);display:none;line-height:1.7}
.gram-rep.on{display:block}
.gram-rep b{color:var(--text-1)}

/* Print */
.print-area{padding:14px;background:var(--surface);border-radius:8px;border:1px solid var(--border)}
@media print{
  .header,.tabs,.btn,.icon-btn,.oeuvre-selector,.stabs,.el-mode-toggle{display:none!important}
  .page{display:block!important;padding:0;max-width:none}
  body{background:#fff;color:#000}
  .el-viewer{grid-template-columns:1fr}
  .el-pane{border:1px solid #ccc;box-shadow:none}
}

/* SAVE INDICATOR */
.save-indicator{position:fixed;bottom:20px;right:20px;background:#059669;color:#fff;padding:10px 16px;border-radius:8px;font-size:13px;font-weight:700;box-shadow:0 4px 12px rgba(0,0,0,.2);opacity:0;transition:opacity .3s;z-index:9998;pointer-events:none}
.save-indicator.on{opacity:1}

/* AI COMMENT INSIDE EL */
.ai-coach-box{background:linear-gradient(135deg,#fdf4ff,#eff6ff);border:1px solid #c7d2fe;border-radius:8px;padding:12px;margin-top:10px}
body.dark .ai-coach-box{background:linear-gradient(135deg,#2d1b4e,#1e3a5f);border-color:#475569}
.ai-coach-box h4{color:#7c3aed;font-size:13px;margin-bottom:6px}
body.dark .ai-coach-box h4{color:#c4b5fd}

/* ============= CROSS-HIGHLIGHTING NOTES ↔ TEXTE =================== */
.hl{border-radius:3px;padding:1px 3px;cursor:pointer;transition:outline .12s,box-shadow .12s}
.hl-c1{background:#fef08a;color:#713f12}
.hl-c2{background:#bbf7d0;color:#14532d}
.hl-c3{background:#bfdbfe;color:#1e3a8a}
.hl-c4{background:#fbcfe8;color:#831843}
.hl-c5{background:#ddd6fe;color:#4c1d95}
.hl-c6{background:#fed7aa;color:#7c2d12}
.hl-c7{background:#a5f3fc;color:#164e63}
.hl-c8{background:#fecaca;color:#7f1d1d}
body.dark .hl-c1{background:#854d0e;color:#fef08a}
body.dark .hl-c2{background:#166534;color:#bbf7d0}
body.dark .hl-c3{background:#1e40af;color:#bfdbfe}
body.dark .hl-c4{background:#9d174d;color:#fbcfe8}
body.dark .hl-c5{background:#5b21b6;color:#ddd6fe}
body.dark .hl-c6{background:#9a3412;color:#fed7aa}
body.dark .hl-c7{background:#155e75;color:#a5f3fc}
body.dark .hl-c8{background:#991b1b;color:#fecaca}
.hl.is-active{outline:2px solid #4f46e5;box-shadow:0 0 0 3px rgba(79,70,229,.18)}

.mvt-sep{border:none;border-top:2px dashed var(--border);margin:14px 0}
.mvt-block{display:block}
.mvt-label{display:inline-block;font-size:10px;font-weight:800;color:var(--text-m);text-transform:uppercase;letter-spacing:.5px;margin-bottom:6px}

.notes-hl{font-family:'Segoe UI',sans-serif;font-size:13px;line-height:1.7;background:transparent;color:var(--text-2);padding:0}
.notes-hl-pb{font-style:italic;color:var(--text-2);margin-bottom:12px;padding:8px 10px;background:var(--surface2);border-left:3px solid #7c3aed;border-radius:0 6px 6px 0}
.notes-hl-mvt{margin-bottom:14px}
.notes-hl-mvt h4{color:var(--text-1);font-size:13px;margin-bottom:8px;padding-bottom:4px;border-bottom:1px solid var(--border)}
.notes-hl-mvt ul{list-style:none;padding-left:0;margin:0}
.notes-hl-mvt li{margin-bottom:5px;padding:6px 9px;border-radius:5px;line-height:1.55;font-size:12.5px}
.notes-hl-mvt li .hl-q{font-style:italic;font-weight:600;display:block;margin-bottom:2px;font-size:12px;opacity:.95}
.notes-hl-mvt li .hl-n{font-weight:500}
.notes-hl-cl{margin-top:14px;padding:8px 10px;background:var(--surface2);border-left:3px solid #059669;border-radius:0 6px 6px 0;color:var(--text-2)}
