* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --dmt-primary: #FF4D5B;
    --dmt-primary-hover: #E63D4C;
    --dmt-surface: #F9F1EF;
    --dmt-text: #0D0D0D;
    --dmt-muted: #6b7280;
    --dmt-border: #F3C4C9;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    background-color: var(--dmt-surface);
    color: var(--dmt-text);
}

#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(180deg, #fff8f7 0%, #fff1ef 100%);
    box-shadow: 0 3px 16px rgba(13, 13, 13, 0.08);
    border-bottom: 2px solid var(--dmt-primary);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 10px;
    z-index: 1000;
    overflow-x: auto;
    overflow-y: hidden;
}

#brand-dmt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid var(--dmt-border);
    min-width: 178px;
}

#brand-dmt img {
    width: 156px;
    height: 32px;
    object-fit: contain;
}

#toolbar button {
    padding: 8px 16px;
    border: 1px solid var(--dmt-border);
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
    flex: 0 0 auto;
}

#toolbar .btn-stack-order {
    padding: 8px 12px;
    font-size: 13px;
}

#toolbar button:hover {
    background: #fff6f5;
    border-color: var(--dmt-primary);
}

#toolbar button:active,
#toolbar button.active {
    background: var(--dmt-primary);
    color: white;
    border-color: var(--dmt-primary);
}

#toolbar button:disabled,
#toolbar input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.15);
}

#toolbar button:disabled:hover {
    background: #ffffff;
    border-color: var(--dmt-border);
}

#toolbar .separator {
    width: 1px;
    height: 30px;
    background: var(--dmt-border);
    margin: 0 5px;
}

#toolbar label {
    font-size: 12px;
    color: var(--dmt-muted);
}

#toolbar input[type="color"] {
    width: 40px;
    height: 35px;
    border: 1px solid var(--dmt-border);
    border-radius: 4px;

    #tl-color {
        width: 40px;
        height: 32px;
        padding: 0;
    }
    cursor: pointer;
}

#users-count {
    margin-left: auto;
    font-size: 14px;
    color: var(--dmt-muted);
}

#board-tabs-bar {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    height: 44px;
    background: #fffaf9;
    border-bottom: 1px solid var(--dmt-border);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    z-index: 950;
}

#board-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-right: 8px;
}

.board-tab-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    cursor: grab;
}

.board-tab-item.is-dragging {
    opacity: 0.55;
}

.board-tab-item.drag-over .board-tab {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.22);
}

.board-tab {
    border: 1px solid var(--dmt-border);
    border-radius: 8px;
    background: #ffffff;
    color: #374151;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.board-tab.active {
    border-color: var(--dmt-primary);
    color: var(--dmt-primary);
    background: #fff0f2;
}

.board-tab-delete {
    border: 1px solid #f3b0b7;
    background: #fff;
    color: #c53b49;
    border-radius: 999px;
    width: 26px;
    height: 26px;
    padding: 0;
    line-height: 1;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    flex: 0 0 auto;
}

.board-tab-delete:hover {
    background: #ffecef;
    border-color: var(--dmt-primary);
}

#board-tabs-bar button {
    padding: 6px 10px;
    border: 1px solid var(--dmt-border);
    background: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}

#board-tabs-bar button:hover {
    background: #fff4f3;
}

#current-board-label {
    margin-left: auto;
    font-size: 12px;
    color: #6b7280;
}

#canvas-container {
    position: fixed;
    top: 104px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

#whiteboard {
    background: #fffdfd;
    cursor: default;
}

#whiteboard.panning {
    cursor: grab;
}

#whiteboard.panning:active {
    cursor: grabbing;
}

/* Barre d'outils de formatage de texte */
#text-format-toolbar {
    position: fixed;
    top: 114px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2000;
    border: 2px solid var(--dmt-primary);
}

#text-format-toolbar select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

#text-format-toolbar button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    min-width: 32px;
    transition: all 0.2s;
}

#text-format-toolbar button:hover {
    background: #f8f9fa;
    border-color: var(--dmt-primary);
}

#text-format-toolbar button.active {
    background: var(--dmt-primary);
    color: white;
    border-color: var(--dmt-primary);
}

#text-format-toolbar #btn-close-editor {
    background: #27ae60;
    color: white;
    border-color: #27ae60;
    margin-left: 10px;
}

#text-format-toolbar #btn-close-editor:hover {
    background: #229954;
}

/* Barre d'outils pour les connecteurs */
#connection-toolbar {
    position: fixed;
    top: 164px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 10px 15px;
    display: none; /* Caché par défaut */
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    row-gap: 6px;
    z-index: 2000;
    border: 2px solid var(--dmt-primary);
    width: min(1180px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    overflow-x: auto;
    overflow-y: hidden;
}

#btn-connection-toolbar-drag {
    cursor: grab;
    background: #111;
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 30px;
    min-width: 30px;
    height: 28px;
    line-height: 1;
    font-size: 14px;
}

#btn-connection-toolbar-drag:active {
    cursor: grabbing;
}

#connection-toolbar.toolbar-dragging,
#connection-toolbar.toolbar-dragging #btn-connection-toolbar-drag {
    cursor: grabbing;
}

#connection-toolbar label {
    font-size: 12px;
    color: #666;
}

#connection-toolbar select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

#connection-toolbar button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    min-width: 32px;
    transition: all 0.2s;
}

#connection-toolbar button:hover {
    background: #f8f9fa;
    border-color: var(--dmt-primary);
}

#connection-toolbar #btn-close-connection-toolbar {
    background: #27ae60;
    color: white;
    border-color: #27ae60;
    margin-left: 10px;
}

#connection-toolbar #btn-close-connection-toolbar:hover {
    background: #229954;
}

#connection-toolbar .separator {
    width: 1px;
    height: 30px;
    background: #ddd;
    margin: 0 5px;
}

/* Conteneur des éditeurs de texte */
#text-editors-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.text-editor {
    position: absolute;
    pointer-events: all;
    border: 2px solid #3498db;
    background: white;
    padding: 10px;
    outline: none;
    overflow: auto;
    resize: both;
    min-width: 90px;
    min-height: 44px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.2;
}

.text-editor p,
.text-editor div {
    margin: 0;
}

.text-editor * {
    text-transform: none;
    letter-spacing: normal;
}

.text-editor:focus {
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* Curseurs des autres utilisateurs */
.remote-cursor {
    position: absolute;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 9999;
    transition: transform 0.1s ease;
}

.remote-cursor::before {
    content: '▲';
    color: #e74c3c;
    font-size: 20px;
    text-shadow: 0 0 3px rgba(0,0,0,0.3);
}

.remote-cursor::after {
    content: attr(data-user);
    position: absolute;
    top: 20px;
    left: 5px;
    background: #e74c3c;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
}

/* Indicateur de sélection */
.selection-indicator {
    stroke: #3498db;
    stroke-width: 2;
    stroke-dasharray: 5, 5;
    fill: none;
    pointer-events: none;
}

/* Modal personnalisée */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 400px;
    text-align: center;
}

.modal-content h3 {
    margin: 0 0 25px 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.5;
    white-space: pre-line;
}

.emoji-sticker-modal-content {
    min-width: 560px;
    max-width: 760px;
}

.emoji-sticker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.emoji-sticker-header h3 {
    margin: 0;
}

.emoji-sticker-close {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--dmt-border);
    background: #fff;
    cursor: pointer;
    font-weight: 700;
}

.emoji-sticker-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.emoji-sticker-tabs button {
    padding: 8px 12px;
    border: 1px solid var(--dmt-border);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
}

.emoji-sticker-tabs button.active {
    background: var(--dmt-primary);
    color: #fff;
    border-color: var(--dmt-primary);
}

.emoji-sticker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 12px;
}

.emoji-sticker-item {
    border: 1px solid var(--dmt-border);
    border-radius: 18px;
    cursor: pointer;
    min-height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(13, 13, 13, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.emoji-sticker-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(13, 13, 13, 0.12);
}

.emoji-item {
    font-size: 38px;
    background: #fff;
}

.sticker-item {
    flex-direction: column;
    padding: 12px;
    gap: 6px;
    text-align: center;
}

.sticker-emoji {
    font-size: 30px;
    line-height: 1;
}

.sticker-label {
    font-size: 13px;
    font-weight: 700;
}

/* ─── Timeline editor ─────────────────────────────── */
.timeline-modal-content {
    min-width: 480px;
    max-width: 680px;
}

.tl-range-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tl-range-row label {
    font-size: 13px;
    font-weight: 600;
    color: var(--dmt-muted);
}

.tl-bound-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tl-range-row input {
    width: 80px;
    padding: 6px 10px;
    border: 1px solid var(--dmt-border);
    border-radius: 6px;
    font-size: 14px;
}

.tl-range-row select {
    padding: 6px 10px;
    border: 1px solid var(--dmt-border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

.tl-auto-range-hint {
    font-size: 12px;
    color: var(--dmt-muted);
    font-style: italic;
}

.tl-ev-select {
    width: 100px;
    padding: 6px 8px;
    border: 1px solid var(--dmt-border);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}

#tl-events-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    max-height: 280px;
    overflow-y: auto;
}

.tl-event-row {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 6px;
    transition: background 0.1s;
}

.tl-drag-handle {
    cursor: grab;
    user-select: none;
    color: var(--dmt-muted);
    font-size: 16px;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}

.tl-drag-handle:active {
    cursor: grabbing;
}

.tl-event-row.tl-dragging {
    opacity: 0.35;
}

.tl-event-row.tl-drag-over {
    border-top: 2px solid var(--dmt-primary);
    padding-top: 2px;
}

.tl-event-row input[type="text"],
.tl-ev-date, .tl-ev-label {
    padding: 6px 8px;
    border: 1px solid var(--dmt-border);
    border-radius: 6px;
    font-size: 13px;
}

.tl-ev-date  { width: 80px; }
.tl-ev-label { flex: 1; }

.tl-ev-color {
    width: 36px;
    height: 32px;
    border: 1px solid var(--dmt-border);
    border-radius: 6px;
    cursor: pointer;
}

.tl-ev-del {
    width: 28px;
    height: 28px;
    border: none;
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tl-add-btn {
    padding: 8px 14px;
    background: var(--dmt-surface);
    border: 1px dashed var(--dmt-primary);
    border-radius: 8px;
    color: var(--dmt-primary);
    font-size: 13px;
    cursor: pointer;
    width: 100%;
}

    .video-player-modal-content {
        min-width: 760px;
        max-width: 92vw;
    }

    .video-player-frame,
    .video-player-native {
        width: 100%;
        height: min(62vh, 520px);
        border: 1px solid var(--dmt-border);
        border-radius: 10px;
        background: #000;
    }

/* ─── Popup événement timeline ────────────────── */
.tl-ev-popup {
    position: absolute;
    z-index: 3000;
    background: #fff;
    border: 2px solid var(--dmt-primary);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 8px 28px rgba(13,13,13,0.16);
    min-width: 260px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tl-ev-popup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.tl-ev-popup-head strong {
    font-size: 14px;
    color: var(--dmt-text);
}

.tl-ev-popup-x {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--dmt-muted);
    line-height: 1;
}

.tl-ev-popup label {
    font-size: 11px;
    color: var(--dmt-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

.tl-pop-date, .tl-pop-label {
    padding: 7px 10px;
    border: 1px solid var(--dmt-border);
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 150px;
}

.modal-btn-primary {
    background: #3498db;
    color: white;
}

.modal-btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.modal-btn-secondary {
    background: #27ae60;
    color: white;
}

.modal-btn-secondary:hover {
    background: #229954;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

.auth-modal-content {
    max-width: 420px;
}

.pdf-export-modal-content {
    max-width: 560px;
    min-width: 520px;
    text-align: left;
}

.pdf-export-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    align-items: center;
    margin-top: 8px;
}

.pdf-export-fields label {
    font-size: 13px;
    font-weight: 600;
    color: var(--dmt-muted);
}

.pdf-export-fields select,
.pdf-export-fields input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--dmt-border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}

.pdf-export-preview {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--dmt-border);
    color: #334155;
    font-size: 13px;
    line-height: 1.4;
}

.pdf-selection-hint {
    position: fixed;
    top: 114px;
    right: 16px;
    z-index: 4000;
    max-width: min(420px, calc(100vw - 32px));
    padding: 10px 14px;
    background: rgba(17, 24, 39, 0.92);
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
    font-size: 13px;
    line-height: 1.35;
    pointer-events: none;
}

.pdf-selection-toolbar {
    position: fixed;
    top: 114px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4100;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--dmt-border);
    box-shadow: 0 12px 32px rgba(13, 13, 13, 0.16);
}

.pdf-selection-toolbar span {
    font-size: 13px;
    color: #334155;
    font-weight: 600;
}

.pdf-selection-toolbar button {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--dmt-border);
    background: #fff;
    cursor: pointer;
    font-size: 13px;
}

.pdf-selection-toolbar button:hover {
    border-color: var(--dmt-primary);
    background: #fff4f3;
}
.pdf-selection-toolbar button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.auth-help {
    font-size: 13px;
    color: #495057;
    margin: 8px 0 12px;
    line-height: 1.35;
}

.auth-fields {
    display: grid;
    gap: 6px;
}

.auth-fields label {
    font-size: 13px;
    color: #343a40;
}

.auth-fields input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.auth-error {
    margin-top: 10px;
    color: #b42318;
    font-size: 13px;
}
