/* ── Media Agent (Image & Vidéo) ─────────────────────────────────────────── */

.nd-media-panel {
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.nd-code-layout.nd-img-active .nd-code-explorer,
.nd-code-layout.nd-img-active .nd-code-viewer,
.nd-code-layout.nd-img-active .nd-code-chat-panel,
.nd-code-layout.nd-img-active .nd-ios-preview,
.nd-code-layout.nd-img-active .nd-web-preview,
.nd-code-layout.nd-img-active .nd-hf-preview,
.nd-code-layout.nd-img-active .nd-translate-input-panel,
.nd-code-layout.nd-img-active .nd-document-preview,
.nd-code-layout.nd-img-active .nd-slides-preview,
.nd-code-layout.nd-img-active .nd-spreadsheet-preview,
.nd-code-layout.nd-img-active .nd-research-panel,
.nd-code-layout.nd-img-active .nd-synth-panel,
.nd-code-layout.nd-vid-active .nd-code-explorer,
.nd-code-layout.nd-vid-active .nd-code-viewer,
.nd-code-layout.nd-vid-active .nd-code-chat-panel,
.nd-code-layout.nd-vid-active .nd-ios-preview,
.nd-code-layout.nd-vid-active .nd-web-preview,
.nd-code-layout.nd-vid-active .nd-hf-preview,
.nd-code-layout.nd-vid-active .nd-translate-input-panel,
.nd-code-layout.nd-vid-active .nd-document-preview,
.nd-code-layout.nd-vid-active .nd-slides-preview,
.nd-code-layout.nd-vid-active .nd-spreadsheet-preview,
.nd-code-layout.nd-vid-active .nd-research-panel,
.nd-code-layout.nd-vid-active .nd-synth-panel {
    display: none !important;
}

.nd-code-layout.nd-img-active .nd-img-panel { display: flex; }
.nd-code-layout.nd-vid-active .nd-vid-panel { display: flex; }

/* ══════════════════════════════════════════════════════════════════════
   VIDÉO PANEL — column layout, mode-select entry
════════════════════════════════════════════════════════════════════════ */

.nd-vid-panel { flex-direction: column; }

.nd-vid-mode-select {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
}

.nd-vid-mode-select[hidden] { display: none; }

/* Cache le header partagé quand on est en mode-select (le panel a son propre header) */
.nd-vid-panel:has(#nd-vid-mode-select:not([hidden])) > .nd-img-header {
    display: none;
}

/* Colle la chatbox en bas du sous-panel basique, sans fond parasite */
#nd-vid-sub-basic .nd-img-controls-bar {
    margin-top: auto;
    background: transparent;
    border-top: none;
}

/* Sub-panels */
.nd-vid-sub {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.nd-vid-sub[hidden] { display: none; }

.nd-vid-sub-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.1);
}

.nd-vid-sub-back {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.35);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.12s, background 0.12s;
}

.nd-vid-sub-back:hover {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.05);
}

.nd-vid-sub-title {
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
}

/* Basic sub-panel wraps sidebar + result in a row */
.nd-vid-basic-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

/* HyperFrames sub-panel */
.nd-hf-feed {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
}

.nd-hf-feed-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.18);
    padding: 24px;
    text-align: center;
}

.nd-hf-feed-empty span { font-size: 13px; }
.nd-hf-feed-empty__sub { font-size: 11px !important; color: rgba(255,255,255,0.12) !important; margin-top: 2px; }

/* Canvas sub-panel */
.nd-canvas-pipeline {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 24px 20px 32px;
}

.nd-canvas-node {
    width: 100%;
    max-width: 480px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
    flex-shrink: 0;
}

.nd-canvas-node__header {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
}

.nd-canvas-node__badge {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 3px;
    flex-shrink: 0;
}

.nd-canvas-node__badge--img { background: rgba(110, 70, 220, 0.7); color: #ddd0ff; }
.nd-canvas-node__badge--vid { background: rgba(210, 85, 15, 0.7);  color: #ffc070; }
.nd-canvas-node__badge--up  { background: rgba(15, 160, 130, 0.7); color: #70e8c8; }

.nd-canvas-node__label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    flex: 1;
}

/* nd-cn-model-btn — small inline model trigger inside canvas node header */
.nd-cn-model-btn.nd-model-trigger {
    margin-left: auto;
    padding: 3px 8px;
    font-size: 11px;
    height: auto;
}

.nd-canvas-node__body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nd-canvas-node__prompt {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.75);
    font-family: inherit;
    font-size: 12px;
    padding: 8px 10px;
    resize: none;
    box-sizing: border-box;
    line-height: 1.5;
    transition: border-color 0.12s;
}

.nd-canvas-node__prompt:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.18);
}

.nd-canvas-node__placeholder {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.2);
    text-align: center;
    padding: 6px 0;
}

.nd-canvas-node__result {
    width: 100%;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
}

.nd-canvas-node__result img,
.nd-canvas-node__result video {
    width: 100%;
    display: block;
    border-radius: 6px;
}

.nd-canvas-node__footer {
    padding: 0 14px 12px;
}

.nd-canvas-node__run {
    width: 100%;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.65);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.nd-canvas-node__run:hover:not(:disabled) { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.9); }
.nd-canvas-node__run:disabled { opacity: 0.3; cursor: default; }

.nd-canvas-node__run--img { border-color: rgba(110, 70, 220, 0.4); }
.nd-canvas-node__run--vid { border-color: rgba(210, 85, 15, 0.4); }
.nd-canvas-node__run--up  { border-color: rgba(15, 160, 130, 0.4); }

.nd-canvas-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    color: rgba(255, 255, 255, 0.15);
    padding: 2px 0;
    flex-shrink: 0;
}

.nd-canvas-connector__line {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.12);
}

/* ══════════════════════════════════════════════════════════════════════
   CANVAS INTERACTIF (Higgsfield-style)
════════════════════════════════════════════════════════════════════════ */

.nd-cvs-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    gap: 10px;
    background: rgba(0,0,0,0.12);
}

.nd-cvs-add-group { display: flex; gap: 5px; }

.nd-cvs-add-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 600;
    font-family: inherit;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.nd-cvs-add-btn:hover { background: rgba(255,255,255,0.09); color: rgba(255,255,255,0.85); }

.nd-cvs-run-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    font-family: inherit;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    padding: 5px 12px;
    cursor: pointer;
    margin-left: auto;
    transition: background 0.12s, color 0.12s;
}
.nd-cvs-run-btn:hover { background: rgba(255,255,255,0.13); color: #fff; }

/* Stage */
.nd-cvs-stage {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background-color: #0a0a0a;
    background-image: radial-gradient(rgba(255,255,255,0.07) 1px, transparent 1px);
    background-size: 22px 22px;
}
.nd-cvs-stage:active { cursor: grabbing; }

.nd-cvs-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
}

.nd-cvs-world {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
}

/* Nodes */
.nd-cvs-node {
    position: absolute;
    width: 240px;
    background: rgba(20, 20, 24, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: visible;
    user-select: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    backdrop-filter: blur(4px);
}
.nd-cvs-node:hover {
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.nd-cvs-node--dragging {
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7) !important;
    z-index: 100;
}

.nd-cvs-node__drag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: grab;
    border-radius: 12px 12px 0 0;
    background: rgba(0, 0, 0, 0.2);
}
.nd-cvs-node__drag:active { cursor: grabbing; }

.nd-cvs-badge {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 3px;
}
.nd-cvs-badge--image  { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.1); }
.nd-cvs-badge--video  { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.1); }
.nd-cvs-badge--prompt { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.1); }

.nd-cvs-del {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.2);
    font-size: 15px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    font-family: inherit;
    border-radius: 3px;
    transition: color 0.1s;
    flex-shrink: 0;
}
.nd-cvs-del:hover { color: rgba(255, 255, 255, 0.7); }

.nd-cvs-preview {
    height: 148px;
    background: rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0;
}
.nd-cvs-preview img,
.nd-cvs-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.nd-cvs-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: rgba(255, 255, 255, 0.2);
}

.nd-cvs-node__prompt {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.65);
    font-size: 11.5px;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    min-height: 46px;
    box-sizing: border-box;
}
.nd-cvs-node__prompt:focus { outline: none; }
.nd-cvs-node__prompt::placeholder { color: rgba(255,255,255,0.2); }

/* Controls — revealed on hover */
.nd-cvs-controls {
    padding: 7px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.15s, max-height 0.2s;
}
.nd-cvs-node:hover .nd-cvs-controls {
    opacity: 1;
    pointer-events: auto;
    max-height: 80px;
}

.nd-cvs-model-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 5px;
    padding: 4px 8px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.1s, color 0.1s;
}
.nd-cvs-model-btn:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.85); }
.nd-cvs-model-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nd-cvs-chips { display: flex; gap: 4px; }
.nd-cvs-chip {
    flex: 1;
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    padding: 3px 4px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: transparent;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    text-align: center;
    transition: all 0.1s;
    white-space: nowrap;
}
.nd-cvs-chip--active,
.nd-cvs-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.18);
}

/* Generate button inside node */
.nd-cvs-node__footer {
    padding: 0 10px 8px;
}
.nd-cvs-gen-btn {
    width: 100%;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.nd-cvs-gen-btn:hover:not(:disabled) { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.9); }
.nd-cvs-gen-btn:disabled { opacity: 0.35; cursor: default; }

/* Connection ports */
.nd-cvs-port {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(15, 15, 18, 0.9);
    cursor: crosshair;
    z-index: 10;
    transition: background 0.1s, transform 0.1s;
}
.nd-cvs-port:hover { background: rgba(255,255,255,0.8); transform: translateY(-50%) scale(1.3); }
.nd-cvs-port--out { right: -7px; }
.nd-cvs-port--in  { left: -7px; }

/* SVG connections */
.nd-cvs-conn {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 1.5;
    stroke-linecap: round;
    pointer-events: stroke;
    cursor: pointer;
    transition: stroke 0.15s;
}
.nd-cvs-conn:hover { stroke: rgba(255,255,255,0.55); }
.nd-cvs-conn--draft {
    stroke: rgba(255, 255, 255, 0.4);
    stroke-dasharray: 5 3;
    pointer-events: none;
    cursor: default;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.nd-md-sidebar {
    width: 380px;
    min-width: 340px;
    max-width: 420px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.015);
    overflow: hidden;
    flex-shrink: 0;
}

.nd-md-result-wrap {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.12);
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.nd-md-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 13px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.nd-md-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.01em;
}

.nd-md-badge svg {
    color: rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
}

.nd-md-back-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: transparent;
    color: rgba(255, 255, 255, 0.35);
    font-size: 11px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.nd-md-back-btn:hover {
    color: rgba(255, 255, 255, 0.65);
    border-color: rgba(255, 255, 255, 0.13);
}

/* ── Mode tabs ───────────────────────────────────────────────────────────── */

.nd-md-mode-tabs {
    display: flex;
    gap: 0;
    padding: 10px 13px 8px;
    flex-shrink: 0;
}

.nd-md-mode-tab {
    flex: 1;
    padding: 6px 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.3);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    letter-spacing: 0.02em;
}

.nd-md-mode-tab:first-child {
    border-radius: 5px 0 0 5px;
    border-right: none;
}

.nd-md-mode-tab:last-child {
    border-radius: 0 5px 5px 0;
}

.nd-md-mode-tab--active {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.75);
    border-color: rgba(255, 255, 255, 0.12);
}

.nd-md-mode-tab:not(.nd-md-mode-tab--active):hover {
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.03);
}

/* ── Scrollable body ─────────────────────────────────────────────────────── */

.nd-md-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 13px 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ── Section label ───────────────────────────────────────────────────────── */

.nd-md-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(255, 255, 255, 0.2);
    margin-bottom: 6px;
}

/* ── Prompt ──────────────────────────────────────────────────────────────── */

.nd-md-prompt-wrap {
    display: flex;
    flex-direction: column;
}

.nd-md-prompt {
    width: 100%;
    min-height: 100px;
    max-height: 180px;
    resize: vertical;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 7px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12.5px;
    line-height: 1.55;
    padding: 9px 11px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.nd-md-prompt:focus {
    border-color: rgba(255, 255, 255, 0.14);
}

.nd-md-prompt::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

/* ── Model cards ─────────────────────────────────────────────────────────── */

.nd-md-models {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nd-md-model-card {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    text-align: left;
    width: 100%;
}

.nd-md-model-card:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}

.nd-md-model-card--active {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.13);
}

.nd-md-model-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
    opacity: 0.85;
}

.nd-md-model-info {
    flex: 1;
    min-width: 0;
}

.nd-md-model-name {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    display: block;
}

.nd-md-model-desc {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.28);
    display: block;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nd-md-model-check {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
    transition: background 0.12s, border-color 0.12s;
}

.nd-md-model-card--active .nd-md-model-check {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.5);
}

/* ── Settings ────────────────────────────────────────────────────────────── */

.nd-md-settings {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nd-md-setting-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nd-md-setting-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.nd-md-chip {
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: transparent;
    color: rgba(255, 255, 255, 0.3);
    font-size: 11px;
    cursor: pointer;
    transition: color 0.12s, background 0.12s, border-color 0.12s;
    font-family: inherit;
}

.nd-md-chip:hover {
    color: rgba(255, 255, 255, 0.55);
}

.nd-md-chip--active {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.12);
}

/* ── Generate button ─────────────────────────────────────────────────────── */

.nd-md-footer {
    padding: 12px 13px 14px;
    flex-shrink: 0;
}

.nd-md-generate-btn {
    width: 100%;
    padding: 9px 0;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.75);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    font-family: inherit;
    letter-spacing: 0.01em;
}

.nd-md-generate-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.11);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.9);
}

.nd-md-generate-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ── Result header ───────────────────────────────────────────────────────── */

.nd-md-result-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 9px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.nd-md-action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    color: rgba(255, 255, 255, 0.38);
    font-size: 11px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.nd-md-action-btn:hover {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
}

/* ── Result area ─────────────────────────────────────────────────────────── */

.nd-md-result-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* When showing style picker, content fills naturally */
.nd-md-result-body .nd-img-style-picker {
    align-self: stretch;
}

/* When showing generated image */
.nd-md-result-body .nd-md-result-img-wrap,
.nd-md-result-body .nd-md-loading,
.nd-md-result-body .nd-md-result-empty,
.nd-md-result-body .nd-md-error {
    padding: 32px;
}

.nd-md-result-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.06);
}

.nd-md-result-empty span {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.12);
    letter-spacing: 0.02em;
}

/* Loading state */
.nd-md-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.nd-md-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-top-color: rgba(255, 255, 255, 0.45);
    border-radius: 50%;
    animation: nd-md-spin 0.9s linear infinite;
}

@keyframes nd-md-spin {
    to { transform: rotate(360deg); }
}

.nd-md-loading-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
}

.nd-md-loading-sub {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.18);
    text-align: center;
    margin-top: -8px;
}

/* Image result */
.nd-md-result-img-wrap {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.nd-md-result-img {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    object-fit: contain;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

/* Video result */
.nd-md-result-vid-wrap {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.nd-md-result-vid {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: #000;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

/* Result action buttons (download + new) */
.nd-md-result-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Error state */
.nd-md-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 340px;
    text-align: center;
}

.nd-md-error-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(248, 113, 113, 0.8);
}

.nd-md-error-msg {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.3);
    line-height: 1.6;
}

/* History strip at top */
.nd-md-history-strip {
    display: flex;
    gap: 8px;
    padding: 10px 13px 0;
    overflow-x: auto;
    flex-shrink: 0;
}

.nd-md-history-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, opacity 0.15s;
    opacity: 0.65;
}

.nd-md-history-thumb:hover,
.nd-md-history-thumb--active {
    border-color: rgba(255, 255, 255, 0.25);
    opacity: 1;
}

/* hidden override so flex/display:flex panels aren't blocked by the attribute */
.nd-img-style-overlay[hidden] { display: none !important; }

/* ── Style picker OVERLAY (modal premier écran) ──────────────────────────── */

.nd-img-style-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    backdrop-filter: blur(6px);
    animation: nd-md-overlay-in 0.18s ease;
}

@keyframes nd-md-overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.nd-img-style-modal {
    width: min(860px, 92vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    background: rgba(18, 18, 20, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.nd-img-style-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 4px;
    flex-shrink: 0;
}

.nd-img-style-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

.nd-img-style-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
}

.nd-img-style-modal-close:hover {
    color: rgba(255, 255, 255, 0.6);
    border-color: rgba(255, 255, 255, 0.15);
}

.nd-img-style-modal-sub {
    padding: 4px 24px 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
}

.nd-img-style-modal-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 20px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    align-content: start;
}

/* ── Style picker (inline dans result area) ──────────────────────────────── */

.nd-img-style-picker {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    align-self: stretch;
}

.nd-img-style-header {
    padding: 20px 28px 14px;
    flex-shrink: 0;
}

.nd-img-style-title {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 3px;
}

.nd-img-style-sub {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.22);
}

.nd-img-style-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 20px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    align-content: start;
}

.nd-img-style-card {
    position: relative;
    height: 110px;
    border-radius: 9px;
    overflow: hidden;
    cursor: pointer;
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    transition: border-color 0.18s, transform 0.15s;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.04);
}

.nd-img-style-card:hover {
    border-color: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.nd-img-style-card--active {
    border-color: rgba(255, 255, 255, 0.55) !important;
    transform: translateY(-1px);
}

.nd-img-style-card--active::after {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.4);
    border-radius: 7px;
    pointer-events: none;
}

.nd-img-style-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, opacity 0.2s;
    opacity: 0.6;
}

.nd-img-style-card:hover .nd-img-style-bg {
    transform: scale(1.04);
    opacity: 0.75;
}

.nd-img-style-card--active .nd-img-style-bg {
    opacity: 0.8;
}

.nd-img-card-grad {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.2) 55%, transparent 100%);
}

.nd-img-style-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 10px 9px;
    font-size: 11.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.88);
    line-height: 1.3;
    letter-spacing: 0.01em;
}

.nd-img-style-check {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
}

.nd-img-style-card--active .nd-img-style-check {
    display: flex;
}

.nd-img-style-check svg {
    color: #000;
}

/* Active style badge in sidebar */
.nd-img-active-style {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.nd-img-active-style-thumb {
    width: 18px;
    height: 13px;
    border-radius: 2px;
    object-fit: cover;
    flex-shrink: 0;
    opacity: 0.75;
}

.nd-img-active-style-name {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nd-img-active-style-change {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    transition: color 0.12s;
}

.nd-img-active-style-change:hover {
    color: rgba(255, 255, 255, 0.55);
}

/* ══════════════════════════════════════════════════════════════════════
   IMAGE PANEL — single-column layout, chatbox at bottom
════════════════════════════════════════════════════════════════════════ */

.nd-img-panel { flex-direction: column; }

.nd-img-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 16px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.nd-img-result-area {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    position: relative;
    padding: 24px;
    box-sizing: border-box;
}

.nd-img-controls-bar {
    flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.12);
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Compact model pills */
.nd-img-controls-models {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.nd-img-model-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: transparent;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    font-family: inherit;
}

.nd-img-model-pill:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
}

.nd-img-model-pill--active {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
}

.nd-img-model-pill img {
    width: 15px;
    height: 15px;
    object-fit: contain;
    border-radius: 3px;
    opacity: 0.8;
    flex-shrink: 0;
}

.nd-img-model-pill span {
    font-size: 11.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
}

.nd-img-model-pill--active span {
    color: rgba(255, 255, 255, 0.72);
}

/* Format + style row */
.nd-img-controls-row2 {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.nd-img-format-chips { display: flex; gap: 5px; flex-shrink: 0; }

/* Prompt row */
.nd-img-prompt-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.nd-img-prompt-field {
    flex: 1;
    min-height: 40px;
    max-height: 100px;
    resize: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
    line-height: 1.5;
    padding: 9px 12px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.nd-img-prompt-field:focus { border-color: rgba(255, 255, 255, 0.15); }
.nd-img-prompt-field::placeholder { color: rgba(255, 255, 255, 0.2); }

.nd-img-gen-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.72);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    flex-shrink: 0;
    letter-spacing: 0.01em;
}

.nd-img-gen-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

.nd-img-gen-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Image generation loading & reveal animation ──────────────────────── */

.nd-img-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 520px;
}

@keyframes nd-img-shimmer {
    0%   { background-position: 200% center; }
    100% { background-position: -200% center; }
}

.nd-img-gen-label {
    align-self: flex-start;
    background: linear-gradient(110deg,
        rgba(255, 255, 255, 0.28) 35%,
        rgba(255, 255, 255, 0.78) 50%,
        rgba(255, 255, 255, 0.28) 75%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: nd-img-shimmer 3s linear infinite;
    font-size: 13.5px;
    font-weight: 500;
}

.nd-img-gen-card {
    position: relative;
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.025);
    overflow: hidden;
    aspect-ratio: 1 / 1;
}

.nd-img-gen-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.nd-img-gen-blur {
    position: absolute;
    width: 100%;
    height: 125%;
    top: -25%;
    pointer-events: none;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.nd-img-gen-actions {
    align-self: flex-start;
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

/* ══════════════════════════════════════════════════════════════════════
   IMAGE PANEL — chatbox layout (feed + chatbox at bottom)
════════════════════════════════════════════════════════════════════════ */

/* Override result-area (replaced by feed) */
.nd-img-result-area { display: none; }

/* Chat feed */
.nd-img-feed {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding: 1.2rem 1.4rem !important;
    gap: 1.8rem !important;
}

/* Empty state */
.nd-img-feed-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.06);
    pointer-events: none;
    padding-bottom: 60px;
}

.nd-img-feed-empty span {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.12);
    letter-spacing: 0.02em;
}

/* Format + style meta row */
.nd-img-meta-row {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0 0;
    flex-wrap: wrap;
    width: 100%;
    max-width: min(100%, 42rem);
    margin: 0 auto;
    box-sizing: border-box;
}

.nd-img-format-chips { display: flex; gap: 5px; }

/* Chatbox wrapper — même largeur centrée que la chatbox new-discussion */
.nd-img-chatbox-wrap {
    flex-shrink: 0;
    padding: 8px 0 14px;
    width: 100%;
    max-width: min(100%, 42rem);
    margin: 0 auto;
    box-sizing: border-box;
}

/* Image messages in the chat feed */
.nd-img-msg-ai {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    max-width: min(460px, 88%);
}

/* The generating container sits inside a message bubble */
.nd-img-msg-ai .nd-img-generating {
    max-width: 100%;
    align-items: flex-start;
}

.nd-img-msg-ai .nd-img-gen-card {
    max-height: none;
}
