/**
 * Caly-Elec Classroom — Admin inline-edit styles
 * ================================================
 * Loaded only inside the LMS iframe when the host enables "edit mode"
 * (Phase 2 of click-to-edit). Provides:
 *   - visual outline on hoverable editable elements
 *   - "editing" highlight during contentEditable
 *   - floating toolbar (+ Para, + Titre, + Image, 🛠 Lab, etc.)
 *   - modals for image edit / catalog picker / new slide template
 *
 * These styles are scoped to :root.classroom-edit-mode so they are
 * completely inert when edit mode is OFF.
 *
 * NOTE: All edit-mode DOM elements (floating toolbar, modals) live
 * OUTSIDE the .reveal container so they are NOT captured by html2canvas
 * and not broadcast to trainees.
 */

/* ════════════════════════════════════════
   Host-level: edit-mode toggle button styling
   ════════════════════════════════════════ */
.admin-unlocked #host-btn-admin-unlock.admin-active {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.55);
    color: #34d399;
    font-weight: 600;
}

.admin-unlocked #host-btn-edit-toggle {
    /* Revealed only when admin is unlocked */
    display: inline-flex !important;
}

#host-btn-edit-toggle {
    display: none;  /* hidden until admin unlocks */
}

.admin-unlocked #host-btn-edit-toggle.edit-active {
    background: rgba(245, 158, 11, 0.22);
    border-color: rgba(245, 158, 11, 0.7);
    color: #fcd34d;
    font-weight: 700;
}

/* ════════════════════════════════════════
   Iframe-level: .classroom-edit-mode on <html>
   ════════════════════════════════════════ */

/* Dashed outline on hoverable editables (only the current .present slide) */
html.classroom-edit-mode .reveal .slides .present .caly-slide-content-body *:hover,
html.classroom-edit-mode .reveal .slides .present .caly-slide-title:hover,
html.classroom-edit-mode .reveal .slides .present .caly-slide-subtitle:hover {
    outline: 2px dashed rgba(245, 158, 11, 0.75);
    outline-offset: 3px;
    cursor: text;
    background: rgba(245, 158, 11, 0.05);
    transition: outline-color 0.15s, background 0.15s;
}

/* Click image in edit mode → crosshair cursor + outline */
html.classroom-edit-mode .reveal .slides .present img:hover {
    outline: 2px dashed rgba(139, 92, 246, 0.75);
    outline-offset: 3px;
    cursor: pointer;
}

/* Active editing state (contentEditable focused) */
html.classroom-edit-mode .caly-editing {
    outline: 2px solid #f59e0b !important;
    outline-offset: 3px;
    background: rgba(245, 158, 11, 0.12) !important;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15);
    border-radius: 2px;
}

/* Ensure the editable elements show a text cursor even on non-hovered
   contentEditable state so the user knows they can type. */
html.classroom-edit-mode [contenteditable="true"] {
    cursor: text;
}

/* ════════════════════════════════════════
   Floating edit toolbar (injected into <body>, hors capture)
   ════════════════════════════════════════ */

#caly-edit-toolbar {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 100000;
    display: none;  /* revealed by .classroom-edit-mode below */
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(245, 158, 11, 0.55);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.78rem;
    color: #f1f5f9;
    backdrop-filter: blur(10px);
    user-select: none;
}

html.classroom-edit-mode #caly-edit-toolbar {
    display: flex;
}

#caly-edit-toolbar .caly-et-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: #f59e0b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 0 6px 0 2px;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    margin-right: 2px;
}

#caly-edit-toolbar button {
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    color: #f1f5f9;
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

#caly-edit-toolbar button:hover {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.55);
    color: #fcd34d;
    transform: translateY(-1px);
}

#caly-edit-toolbar button.accent {
    background: rgba(245, 158, 11, 0.22);
    border-color: rgba(245, 158, 11, 0.7);
    color: #fcd34d;
    font-weight: 600;
}

#caly-edit-toolbar .caly-et-sep {
    width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, 0.12);
    margin: 0 3px;
}

#caly-edit-toolbar button.danger {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.35);
}

#caly-edit-toolbar button.danger:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.65);
    color: #fecaca;
}

/* ════════════════════════════════════════
   Save status indicator (toast-lite in the toolbar)
   ════════════════════════════════════════ */
#caly-edit-status {
    font-size: 0.7rem;
    color: #94a3b8;
    padding: 0 6px;
    min-width: 0;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* When the status is an error, let it wrap and grow to 420px so the
   admin can read long messages (e.g. "Cours non trouvé: ..." with the
   full course_id). The full error is also shown in a separate toast
   (#caly-save-error-toast) managed by _showSaveErrorToast in app.js. */
#caly-edit-status.error {
    max-width: 420px;
    white-space: normal;
    line-height: 1.25;
}

#caly-edit-status.saving { color: #fcd34d; }
#caly-edit-status.saved  { color: #34d399; }
#caly-edit-status.error  { color: #fca5a5; }

/* ════════════════════════════════════════
   Read-only hint for non-supported slide types
   ════════════════════════════════════════ */
.caly-edit-type-hint {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100001;
    padding: 12px 18px;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(245, 158, 11, 0.55);
    border-radius: 10px;
    color: #f1f5f9;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.82rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 520px;
    animation: caly-hint-in 0.25s ease-out;
}

@keyframes caly-hint-in {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

.caly-edit-type-hint a {
    color: #fcd34d;
    text-decoration: underline;
    font-weight: 600;
    white-space: nowrap;
}

.caly-edit-type-hint button.close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

/* ════════════════════════════════════════
   Phase 4: Image edit modal
   ════════════════════════════════════════ */
.caly-image-edit-modal {
    position: fixed;
    inset: 0;
    z-index: 100002;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', system-ui, sans-serif;
}

.caly-image-edit-modal .caly-imem-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(4px);
}

.caly-image-edit-modal .caly-imem-card {
    position: relative;
    max-width: 520px;
    width: 92%;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(245, 158, 11, 0.55);
    border-radius: 14px;
    padding: 22px 24px;
    color: #f1f5f9;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: caly-imem-in 0.2s ease-out;
}

@keyframes caly-imem-in {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

.caly-image-edit-modal .caly-imem-header {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f59e0b;
    margin-bottom: 14px;
}

.caly-image-edit-modal .caly-imem-preview {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 14px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.caly-image-edit-modal .caly-imem-preview img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 4px;
}

.caly-image-edit-modal .caly-imem-alt-row {
    margin-bottom: 16px;
}

.caly-image-edit-modal .caly-imem-alt-row label {
    display: block;
    font-size: 0.78rem;
    color: #94a3b8;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}

.caly-image-edit-modal .caly-imem-alt-row input {
    width: 100%;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.88rem;
    box-sizing: border-box;
}

.caly-image-edit-modal .caly-imem-alt-row input:focus {
    outline: none;
    border-color: #f59e0b;
    background: rgba(255, 255, 255, 0.08);
}

.caly-image-edit-modal .caly-imem-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.caly-image-edit-modal .caly-imem-actions button {
    flex: 1 1 auto;
    min-width: 120px;
    padding: 9px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.caly-image-edit-modal .caly-imem-actions button:hover {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.55);
    color: #fcd34d;
    transform: translateY(-1px);
}

.caly-image-edit-modal .caly-imem-actions button.accent {
    background: rgba(245, 158, 11, 0.22);
    border-color: rgba(245, 158, 11, 0.7);
    color: #fcd34d;
    font-weight: 700;
}

.caly-image-edit-modal .caly-imem-actions button.danger {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.35);
}

.caly-image-edit-modal .caly-imem-actions button.danger:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.65);
    color: #fecaca;
}

.caly-image-edit-modal .caly-imem-status {
    min-height: 18px;
    font-size: 0.78rem;
    color: #94a3b8;
    text-align: center;
    padding-top: 4px;
}

.caly-image-edit-modal .caly-imem-status.saving { color: #fcd34d; }
.caly-image-edit-modal .caly-imem-status.saved  { color: #34d399; }
.caly-image-edit-modal .caly-imem-status.error  { color: #fca5a5; }

/* ════════════════════════════════════════
   Phase 5: Catalog picker modal (labs & resources)
   ════════════════════════════════════════ */
.caly-catalog-modal {
    position: fixed;
    inset: 0;
    z-index: 100003;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', system-ui, sans-serif;
}

.caly-catalog-modal .caly-cm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(4px);
}

.caly-catalog-modal .caly-cm-card {
    position: relative;
    max-width: 720px;
    width: 94%;
    max-height: 82vh;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(245, 158, 11, 0.55);
    border-radius: 14px;
    padding: 20px 22px;
    color: #f1f5f9;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    animation: caly-imem-in 0.2s ease-out;
}

.caly-catalog-modal .caly-cm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.caly-catalog-modal .caly-cm-title {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #f59e0b;
}

.caly-catalog-modal .caly-cm-hint {
    font-size: 0.72rem;
    color: #94a3b8;
    font-style: italic;
}

.caly-catalog-modal .caly-cm-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
}

.caly-catalog-modal .caly-cm-search {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.88rem;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.caly-catalog-modal .caly-cm-search:focus {
    outline: none;
    border-color: #f59e0b;
}

.caly-catalog-modal .caly-cm-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.caly-catalog-modal .caly-cm-cat {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    color: #cbd5e1;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
}

.caly-catalog-modal .caly-cm-cat:hover,
.caly-catalog-modal .caly-cm-cat.active {
    background: rgba(245, 158, 11, 0.18);
    border-color: #f59e0b;
    color: #fcd34d;
    font-weight: 600;
}

.caly-catalog-modal .caly-cm-list {
    flex: 1 1 auto;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 6px;
}

.caly-catalog-modal .caly-cm-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.12s;
    border: 1px solid transparent;
}

.caly-catalog-modal .caly-cm-item:hover {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.35);
    transform: translateX(2px);
}

.caly-catalog-modal .caly-cm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.caly-catalog-modal .caly-cm-body {
    flex: 1 1 auto;
    min-width: 0;
}

.caly-catalog-modal .caly-cm-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 2px;
}

.caly-catalog-modal .caly-cm-cat-label {
    font-size: 0.66rem;
    color: #f59e0b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 3px;
}

.caly-catalog-modal .caly-cm-desc {
    font-size: 0.76rem;
    color: #94a3b8;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.caly-catalog-modal .caly-cm-empty {
    padding: 30px 20px;
    text-align: center;
    color: #94a3b8;
    font-style: italic;
    font-size: 0.85rem;
}

.caly-catalog-modal .caly-cm-status {
    min-height: 18px;
    font-size: 0.76rem;
    color: #94a3b8;
    text-align: center;
    padding-top: 10px;
}

.caly-catalog-modal .caly-cm-status.saving { color: #fcd34d; }
.caly-catalog-modal .caly-cm-status.saved  { color: #34d399; }
.caly-catalog-modal .caly-cm-status.error  { color: #fca5a5; }

/* ════════════════════════════════════════
   Phase 6: New slide modal + delete confirm
   ════════════════════════════════════════ */
.caly-newslide-modal {
    position: fixed;
    inset: 0;
    z-index: 100004;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', system-ui, sans-serif;
}

.caly-newslide-modal .caly-ns-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(4px);
}

.caly-newslide-modal .caly-ns-card {
    position: relative;
    max-width: 560px;
    width: 92%;
    max-height: 84vh;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(245, 158, 11, 0.55);
    border-radius: 14px;
    padding: 22px 24px;
    color: #f1f5f9;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    animation: caly-imem-in 0.2s ease-out;
}

.caly-newslide-modal .caly-ns-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
}

.caly-newslide-modal .caly-ns-title {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 1.12rem;
    font-weight: 700;
    color: #f59e0b;
}

.caly-newslide-modal .caly-ns-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
}

.caly-newslide-modal .caly-ns-hint {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 14px;
    line-height: 1.5;
}

.caly-newslide-modal .caly-ns-title-row {
    margin-bottom: 16px;
}

.caly-newslide-modal .caly-ns-title-row label {
    display: block;
    font-size: 0.72rem;
    color: #94a3b8;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}

.caly-newslide-modal .caly-ns-title-row input {
    width: 100%;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.88rem;
    box-sizing: border-box;
}

.caly-newslide-modal .caly-ns-title-row input:focus {
    outline: none;
    border-color: #f59e0b;
    background: rgba(255, 255, 255, 0.08);
}

.caly-newslide-modal .caly-ns-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-right: 4px;
}

.caly-newslide-modal .caly-ns-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.caly-newslide-modal .caly-ns-item:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.55);
    transform: translateY(-1px);
}

.caly-newslide-modal .caly-ns-icon {
    font-size: 1.8rem;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.15);
    border-radius: 9px;
    flex-shrink: 0;
}

.caly-newslide-modal .caly-ns-body {
    flex: 1 1 auto;
    min-width: 0;
}

.caly-newslide-modal .caly-ns-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 2px;
}

.caly-newslide-modal .caly-ns-desc {
    font-size: 0.78rem;
    color: #94a3b8;
    line-height: 1.4;
}

.caly-newslide-modal .caly-ns-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.caly-newslide-modal .caly-ns-btn {
    flex: 1 1 auto;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.caly-newslide-modal .caly-ns-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.caly-newslide-modal .caly-ns-btn.accent-danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.6);
    color: #fecaca;
    font-weight: 700;
}

.caly-newslide-modal .caly-ns-btn.accent-danger:hover {
    background: rgba(239, 68, 68, 0.35);
    border-color: rgba(239, 68, 68, 0.85);
}

.caly-newslide-modal .caly-ns-status {
    min-height: 18px;
    font-size: 0.76rem;
    color: #94a3b8;
    text-align: center;
    padding-top: 12px;
}

.caly-newslide-modal .caly-ns-status.saving { color: #fcd34d; }
.caly-newslide-modal .caly-ns-status.saved  { color: #34d399; }
.caly-newslide-modal .caly-ns-status.error  { color: #fca5a5; }

/* ════════════════════════════════════════
   Phase 7: Rich-text toolbar (Iteration 4)
   ════════════════════════════════════════ */
#caly-rich-toolbar {
    position: fixed;
    top: 64px;       /* sits just under the existing #caly-edit-toolbar */
    right: 14px;
    z-index: 99999;  /* below the main edit toolbar, above everything else */
    display: none;   /* shown by .visible modifier below */
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 7px 9px;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(99, 102, 241, 0.55);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.78rem;
    color: #f1f5f9;
    backdrop-filter: blur(10px);
    user-select: none;
    max-width: calc(100vw - 28px);
}

#caly-rich-toolbar.visible {
    display: flex;
    animation: caly-rt-slide-in 0.2s ease-out;
}

@keyframes caly-rt-slide-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* In simple mode (title/subtitle edit), hide the advanced buttons:
   lists, headings, link, table, image, blockquote, clear, full editor.
   Keep only B/I/U/S, color, and alignment. */
#caly-rich-toolbar.mode-simple > button:nth-child(n+12),
#caly-rich-toolbar.mode-simple > .caly-rt-sep:nth-child(n+12) {
    display: none;
}

#caly-rich-toolbar .caly-rt-btn {
    padding: 5px 8px;
    min-width: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #f1f5f9;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, transform 0.12s;
    line-height: 1.1;
}

#caly-rich-toolbar .caly-rt-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.65);
    transform: translateY(-1px);
}

#caly-rich-toolbar .caly-rt-btn.caly-rt-dropdown::after {
    content: ' ▾';
    font-size: 0.6rem;
    opacity: 0.7;
}

#caly-rich-toolbar .caly-rt-sep {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.12);
    margin: 0 3px;
}

/* ── Popovers (color, heading, table grid) ── */
.caly-rt-popover {
    position: fixed;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(99, 102, 241, 0.55);
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
    font-family: 'Inter', system-ui, sans-serif;
    color: #f1f5f9;
    backdrop-filter: blur(10px);
    animation: caly-rt-slide-in 0.15s ease-out;
}

.caly-rt-color-popover {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    width: 168px;
}

.caly-rt-swatch {
    width: 24px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
    padding: 0;
}

.caly-rt-swatch:hover {
    transform: scale(1.12);
    border-color: #f59e0b;
}

.caly-rt-heading-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 160px;
}

.caly-rt-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.caly-rt-menu-item:hover {
    background: rgba(99, 102, 241, 0.18);
}

.caly-rt-menu-tag {
    display: inline-block;
    min-width: 26px;
    padding: 1px 6px;
    background: rgba(99, 102, 241, 0.25);
    color: #c7d2fe;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.7rem;
    text-align: center;
}

/* ── Table grid picker ── */
.caly-rt-table-grid {
    padding: 10px;
}

.caly-rt-table-label {
    font-size: 0.76rem;
    color: #94a3b8;
    margin-bottom: 8px;
    text-align: center;
    letter-spacing: 0.3px;
}

.caly-rt-table-cells {
    display: grid;
    grid-template-columns: repeat(8, 18px);
    grid-template-rows: repeat(8, 18px);
    gap: 2px;
}

.caly-rt-table-cell {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.1s;
}

.caly-rt-table-cell:hover,
.caly-rt-table-cell.active {
    background: rgba(99, 102, 241, 0.55);
    border-color: #818cf8;
}

/* ── Link modal ── */
.caly-rt-link-modal {
    position: fixed;
    inset: 0;
    z-index: 100006;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', system-ui, sans-serif;
}

.caly-rt-link-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(4px);
}

.caly-rt-link-card {
    position: relative;
    max-width: 440px;
    width: 92%;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(99, 102, 241, 0.6);
    border-radius: 12px;
    padding: 22px 24px;
    color: #f1f5f9;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: caly-rt-slide-in 0.2s ease-out;
}

.caly-rt-link-title {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: #818cf8;
    margin-bottom: 14px;
}

.caly-rt-link-row {
    margin-bottom: 12px;
}

.caly-rt-link-row label {
    display: block;
    font-size: 0.72rem;
    color: #94a3b8;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}

.caly-rt-link-row input {
    width: 100%;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.88rem;
    box-sizing: border-box;
}

.caly-rt-link-row input:focus {
    outline: none;
    border-color: #818cf8;
    background: rgba(255, 255, 255, 0.08);
}

.caly-rt-link-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.caly-rt-link-actions button {
    flex: 1 1 auto;
    padding: 9px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.caly-rt-link-actions button:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.65);
}

.caly-rt-link-actions button.accent {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.75);
    color: #c7d2fe;
    font-weight: 700;
}

/* ── Tables inserted in slides ── */
.caly-slide-table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.4em 0;
    font-size: 0.88em;
}

.caly-slide-table th,
.caly-slide-table td {
    border: 1px solid #94a3b8;
    padding: 6px 10px;
}

.caly-slide-table th {
    background: rgba(245, 158, 11, 0.12);
    text-align: left;
    font-weight: 700;
}

/* ════════════════════════════════════════
   Slide visibility toggle + hidden-slide overlay
   ════════════════════════════════════════ */

/* Button in #caly-edit-toolbar — state reflects current slide.visible */
#caly-edit-toolbar #caly-et-visibility {
    /* Green by default (slide is visible) */
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.45);
    color: #34d399;
}

#caly-edit-toolbar #caly-et-visibility:hover {
    background: rgba(16, 185, 129, 0.22);
    border-color: rgba(16, 185, 129, 0.7);
    color: #6ee7b7;
}

#caly-edit-toolbar #caly-et-visibility.hidden-state {
    /* Red when slide.visible === false */
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.6);
    color: #fca5a5;
    font-weight: 600;
}

#caly-edit-toolbar #caly-et-visibility.hidden-state:hover {
    background: rgba(239, 68, 68, 0.32);
    border-color: rgba(239, 68, 68, 0.85);
    color: #fecaca;
}

/* Hidden slide overlay — diagonal red stripes + "MASQUÉE" badge.
   Only applied to the currently-present slide when slide.visible === false,
   and only when the formateur is in classroom edit mode (so trainees never
   see the badge because their view is the PNG capture which captures the
   slide with the overlay — that's actually fine: hidden slides should be
   visually marked for the formateur, and if they accidentally stay on one
   the trainees get a clear "this is a draft" signal). */
html.classroom-edit-mode .reveal .slides .present.caly-slide-hidden {
    position: relative;
}

html.classroom-edit-mode .reveal .slides .present.caly-slide-hidden::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(239, 68, 68, 0.04),
        rgba(239, 68, 68, 0.04) 14px,
        rgba(239, 68, 68, 0.12) 14px,
        rgba(239, 68, 68, 0.12) 28px
    );
    z-index: 1;
}

html.classroom-edit-mode .reveal .slides .present.caly-slide-hidden::after {
    content: '🚫 Slide masquée';
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 16px;
    background: rgba(239, 68, 68, 0.92);
    color: #fff;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    z-index: 2;
    pointer-events: none;
    animation: caly-hint-in 0.2s ease-out;
}

/* ════════════════════════════════════════
   Speaker notes editor modal
   ════════════════════════════════════════ */
.caly-notes-modal {
    position: fixed;
    inset: 0;
    z-index: 100007;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', system-ui, sans-serif;
}

.caly-notes-modal .caly-notes-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(4px);
}

.caly-notes-modal .caly-notes-card {
    position: relative;
    max-width: 620px;
    width: 94%;
    max-height: 86vh;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(139, 92, 246, 0.6);
    border-radius: 14px;
    padding: 20px 22px;
    color: #f1f5f9;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    animation: caly-imem-in 0.2s ease-out;
}

.caly-notes-modal .caly-notes-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 6px;
}

.caly-notes-modal .caly-notes-title {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #a78bfa;
}

.caly-notes-modal .caly-notes-subtitle {
    font-size: 0.76rem;
    color: #94a3b8;
    margin-top: 2px;
}

.caly-notes-modal .caly-notes-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
    flex-shrink: 0;
}

.caly-notes-modal .caly-notes-hint {
    font-size: 0.78rem;
    color: #94a3b8;
    margin: 10px 0 14px;
    line-height: 1.5;
}

.caly-notes-modal textarea {
    width: 100%;
    min-height: 200px;
    max-height: 50vh;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #f1f5f9;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}

.caly-notes-modal textarea:focus {
    outline: none;
    border-color: #a78bfa;
    background: rgba(255, 255, 255, 0.08);
}

.caly-notes-modal .caly-notes-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.7rem;
    color: #94a3b8;
}

.caly-notes-modal .caly-notes-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.caly-notes-modal .caly-notes-actions button {
    flex: 1 1 auto;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.15s;
}

.caly-notes-modal .caly-notes-actions button:hover {
    background: rgba(139, 92, 246, 0.18);
    border-color: rgba(139, 92, 246, 0.6);
}

.caly-notes-modal .caly-notes-actions button.accent {
    background: rgba(139, 92, 246, 0.22);
    border-color: rgba(139, 92, 246, 0.7);
    color: #c4b5fd;
    font-weight: 700;
}

.caly-notes-modal .caly-notes-status {
    min-height: 18px;
    font-size: 0.76rem;
    color: #94a3b8;
    text-align: center;
    padding-top: 10px;
}

.caly-notes-modal .caly-notes-status.saving { color: #fcd34d; }
.caly-notes-modal .caly-notes-status.saved  { color: #34d399; }
.caly-notes-modal .caly-notes-status.error  { color: #fca5a5; }
