/* ==========================================================
   Elite Builder — Message Builder Workspace Styles
   Built on the same design tokens defined in main.css
   ========================================================== */

html, body {
    height: 100%;
}

.builder-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
}

/* ==================================================
   TOOLBAR
================================================== */

.builder-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.builder-toolbar::-webkit-scrollbar {
    height: 4px;
}

.builder-toolbar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.toolbar-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    color: var(--text);
    background: transparent;
    transition: background .2s ease;
}

.toolbar-back:hover {
    background: var(--surface-light);
}

.toolbar-back i {
    width: 18px;
    height: 18px;
}

.project-name-input {
    background: transparent;
    border: 1px solid transparent;
    color: var(--white);
    font-family: "Poppins", sans-serif;
    font-size: 15px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    min-width: 160px;
    max-width: 320px;
}

.project-name-input:hover {
    border-color: var(--border);
}

.project-name-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface-light);
}

.save-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--surface-light);
}

.save-status i {
    width: 13px;
    height: 13px;
}

.save-status[data-state="saved"] {
    color: #4ade80;
}

.save-status[data-state="saving"] {
    color: var(--secondary);
}

.save-status[data-state="unsaved"] {
    color: #fbbf24;
}

.save-status[data-state="error"] {
    color: #f87171;
}

.toolbar-divider {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 4px;
}

.toolbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--border);
    transition: background .2s ease, transform .1s ease, color .2s ease;
}

.toolbar-icon-btn i {
    width: 16px;
    height: 16px;
}

.toolbar-icon-btn:hover:not(:disabled) {
    background: rgba(139, 92, 246, .18);
    color: var(--primary-light);
}

.toolbar-icon-btn:active:not(:disabled) {
    transform: scale(0.94);
}

.toolbar-icon-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.toolbar-icon-btn.danger:hover:not(:disabled) {
    background: rgba(248, 113, 113, .15);
    color: #f87171;
}

.secondary-btn,
.primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    font-family: "Poppins", sans-serif;
    transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease;
    white-space: nowrap;
}

.secondary-btn i,
.primary-btn i {
    width: 15px;
    height: 15px;
}

.secondary-btn {
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.secondary-btn:hover {
    border-color: var(--primary);
    color: var(--white);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
    box-shadow: var(--shadow);
}

.primary-btn:hover {
    transform: translateY(-1px);
    opacity: .92;
}

.export-dropdown {
    position: relative;
}

.export-menu {
    position: fixed;
    display: none;
    flex-direction: column;
    min-width: 190px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: var(--shadow);
    z-index: 50;
}

.export-menu.open {
    display: flex;
}

.export-menu button {
    text-align: left;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
    background: transparent;
}

.export-menu button:hover {
    background: rgba(139, 92, 246, .15);
    color: var(--white);
}

/* ==================================================
   BODY LAYOUT
================================================== */

.builder-body {
    display: grid;
    grid-template-columns: 260px 1fr 320px;
    flex: 1;
    min-height: 0;
}

/* ==================================================
   PALETTE (LEFT)
================================================== */

.builder-palette {
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px 12px 40px;
}

.palette-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 18px;
}

.palette-search i {
    width: 15px;
    height: 15px;
    color: var(--muted);
    flex-shrink: 0;
}

.palette-search input {
    background: transparent;
    border: none;
    color: var(--white);
    font-family: "Poppins", sans-serif;
    font-size: 13px;
    width: 100%;
}

.palette-search input:focus {
    outline: none;
}

.palette-group {
    margin-bottom: 22px;
}

.palette-group h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin-bottom: 8px;
    padding-left: 4px;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 10px;
    color: var(--text);
    background: transparent;
    font-size: 13px;
    font-family: "Poppins", sans-serif;
    cursor: grab;
    transition: background .15s ease, color .15s ease;
}

.palette-item i {
    width: 16px;
    height: 16px;
    color: var(--primary-light);
    flex-shrink: 0;
}

.palette-item:hover {
    background: var(--surface-light);
    color: var(--white);
}

.palette-item:active {
    cursor: grabbing;
}

.palette-item.dragging {
    opacity: .4;
}

/* ==================================================
   CANVAS (CENTER)
================================================== */

.builder-canvas-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}

.canvas-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
}

.canvas-toolbar-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}

.builder-canvas {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    justify-content: center;
}

.discord-message-frame {
    width: 100%;
    max-width: 620px;
    background: #313338;
    border-radius: var(--radius);
    padding: 20px;
    height: fit-content;
    box-shadow: var(--shadow);
    /* Discord's client uses "gg sans", which isn't ours to embed --
       this is the same fallback stack Discord itself falls back to
       when gg sans isn't available, and reads as authentic "native
       app UI" rather than a branded font like the rest of this
       builder's own Poppins-based interface. */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.discord-message-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.discord-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    flex-shrink: 0;
}

.discord-message-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.discord-bot-name {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #f2f3f5;
    font-weight: 600;
    font-size: 15px;
}

.discord-bot-tag {
    background: var(--primary);
    color: var(--white);
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
}

.discord-timestamp {
    color: #949ba4;
    font-size: 11px;
}

.discord-components-root {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 120px;
    border: 2px dashed transparent;
    border-radius: 10px;
    transition: border-color .15s ease, background .15s ease;
}

.discord-components-root.drag-over {
    border-color: var(--primary);
    background: rgba(139, 92, 246, .06);
}

.canvas-empty-state {
    color: #6d6f78;
    font-size: 13px;
    text-align: center;
    padding: 40px 12px;
    border: 2px dashed rgba(255, 255, 255, .08);
    border-radius: 10px;
}

/* ==================================================
   PROPERTIES PANEL (RIGHT)
================================================== */

.builder-properties {
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.properties-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.properties-header h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--white);
}

.properties-body {
    padding: 18px;
    flex: 1;
}

.properties-empty-state {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
    padding: 30px 8px;
}

/* Shared field styles reused by properties.js in Milestone 3 */

.field-group {
    margin-bottom: 16px;
}

.field-group label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.field-group input[type="text"],
.field-group input[type="url"],
.field-group input[type="number"],
.field-group textarea,
.field-group select {
    width: 100%;
    background: var(--surface-light);
    border: 1px solid var(--border);
    color: var(--white);
    border-radius: 8px;
    padding: 9px 10px;
    font-family: "Poppins", sans-serif;
    font-size: 13px;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.field-group textarea {
    resize: vertical;
    min-height: 70px;
}

.field-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ==================================================
   RESPONSIVE
================================================== */

@media (max-width: 1080px) {

    .builder-body {
        grid-template-columns: 220px 1fr 280px;
    }

}

@media (max-width: 860px) {

    .builder-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(320px, 1fr) auto;
        overflow-y: auto;
    }

    .builder-palette,
    .builder-properties {
        border: none;
        border-bottom: 1px solid var(--border);
        max-height: 220px;
    }

    .builder-canvas-wrap {
        min-height: 360px;
    }

    .builder-canvas {
        display: flex;
        justify-content: center;
        padding: 16px 12px 40px;
    }

    #components-root {
        width: 100%;
        max-width: 420px;
        margin: 0 auto;
    }

}

@media (max-width: 560px) {

    .builder-toolbar {
        padding: 8px 10px;
        gap: 8px;
    }

    .toolbar-center {
        display: none;
    }

}

/* ==================================================
   RENDERED COMPONENT NODES (preview.js output)
================================================== */

.eb-node {
    position: relative;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease;
}

.eb-node:hover {
    border-color: rgba(139, 92, 246, .35);
}

.eb-node.eb-selected {
    border-color: var(--primary);
    background: rgba(139, 92, 246, .06);
}

.eb-node.eb-dragging {
    opacity: .35;
}

.eb-node-badge {
    position: absolute;
    top: -9px;
    left: 8px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: var(--primary);
    color: var(--white);
    padding: 2px 6px;
    border-radius: 5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease;
}

.eb-node:hover .eb-node-badge,
.eb-node.eb-selected .eb-node-badge {
    opacity: 1;
}

.eb-node-body {
    padding: 6px 8px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.eb-child-zone {
    margin: 0 8px 8px;
    padding: 8px;
    border-radius: 8px;
    min-height: 30px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* Children must take full width; otherwise min-content + word-break
       collapses each text node to ~1ch and wraps every character. */
    align-items: stretch;
}

.eb-child-zone > .eb-node {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.eb-child-empty {
    font-size: 11px;
    color: #6d6f78;
    text-align: center;
    padding: 8px;
    border: 1px dashed rgba(255, 255, 255, .1);
    border-radius: 6px;
}

.eb-drop-zone.drag-over {
    background: rgba(139, 92, 246, .08);
    outline: 1.5px dashed var(--primary);
    outline-offset: -2px;
}

.eb-invalid-drop .discord-message-frame {
    animation: eb-shake .25s ease;
}

@keyframes eb-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Text Display
   IMPORTANT: do NOT use word-break: break-word here inside a flex column.
   That makes min-content width ~1 character, so the flex item shrinks and
   every character wraps onto its own visual line. */
.eb-text-display {
    color: #dbdee1;
    font-size: 14px;
    line-height: 1.375;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.eb-custom-emoji {
    display: inline !important;
    width: 1.375em;
    height: 1.375em;
    max-width: 1.375em !important;
    max-height: 1.375em !important;
    vertical-align: -0.25em;
    object-fit: contain;
    margin: 0 0.05em;
    border-radius: 0;
    flex-shrink: 0;
    /* Do not freeze animated GIFs */
    image-rendering: auto;
}

.eb-custom-emoji--animated {
    /* Same box as static; GIF frames play in the real <img> */
}

.eb-inline-mention {
    display: inline;
    background: rgba(88, 101, 242, 0.3);
    color: #c9cdfb;
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 500;
    white-space: nowrap;
}

/* Container */
.eb-container-card {
    border-left: 4px solid transparent;
    background: rgba(255, 255, 255, .03);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.eb-container-card.eb-container-has-accent {
    /* Color is applied via inline border-left-color when accent is set */
}

.eb-container-card > .eb-child-zone {
    margin: 0;
    padding: 0;
}

/* Section */
.eb-section-preview {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.eb-section-text-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.eb-section-accessory {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

/* Separator */
.eb-separator {
    padding: 2px 0;
}

.eb-separator hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.eb-separator-large {
    padding: 10px 0;
}

/* Thumbnail */
.eb-thumbnail-preview {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, .06);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

/* Media Gallery */
.eb-media-gallery-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 6px;
}

.eb-media-tile {
    aspect-ratio: 1;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, .06);
    background-size: cover;
    background-position: center;
}

/* File */
.eb-file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    font-size: 13px;
    color: #dbdee1;
    width: fit-content;
}

.eb-file-preview i {
    width: 15px;
    height: 15px;
    color: var(--primary-light);
}

/* Action Row */
.eb-action-row-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Buttons */
.eb-button-preview {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    width: fit-content;
    line-height: 1.15;
}

.eb-btn-primary { background: #5865f2; color: #fff; }
.eb-btn-secondary { background: #4e5058; color: #fff; }
.eb-btn-success { background: #248046; color: #fff; }
.eb-btn-danger { background: #da373c; color: #fff; }

/* Link buttons render as a normal secondary-grey button with a
   trailing "opens externally" icon -- exactly how Discord marks
   them, since visually they'd otherwise be indistinguishable from
   a regular Secondary button. */
.eb-btn-link {
    background: #4e5058;
    color: #fff;
}

.eb-link-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Premium buttons use Discord's light, distinct "monetization"
   style -- never confusable with the other four button styles,
   which are all solid/dark. */
.eb-btn-premium {
    background: #f3f4f5;
    color: #23272a;
}

.eb-btn-premium .eb-premium-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.eb-button-preview.eb-disabled {
    opacity: .5;
}

/* Selects */
.eb-select-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #1e1f22;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    font-size: 14px;
    color: #dbdee1;
}

.eb-select-preview i {
    width: 14px;
    height: 14px;
    color: #949ba4;
    flex-shrink: 0;
}

/* Text Input */
.eb-text-input-preview label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #b5bac1;
    margin-bottom: 4px;
}

.eb-text-input-box {
    padding: 8px 10px;
    background: #1e1f22;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 6px;
    font-size: 13px;
    color: #6d6f78;
}

/* ==================================================
   LOCAL BACKUP RECOVERY BANNER
================================================== */

.eb-recovery-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    background: rgba(251, 191, 36, .12);
    border-bottom: 1px solid rgba(251, 191, 36, .35);
    color: #fbbf24;
    font-size: 13px;
}

.eb-recovery-banner span {
    flex: 1;
}

.eb-recovery-restore,
.eb-recovery-discard {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.eb-recovery-restore {
    background: #fbbf24;
    color: #1e1f22;
}

.eb-recovery-discard {
    background: transparent;
    border: 1px solid rgba(251, 191, 36, .4);
    color: #fbbf24;
}

/* ==================================================
   PUBLISH (SEND TO DISCORD) DROPDOWN
================================================== */

.publish-dropdown {
    position: relative;
}

.publish-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.publish-menu {
    position: fixed;
    display: none;
    flex-direction: column;
    min-width: 220px;
    max-height: 320px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: var(--shadow);
    z-index: 250;
    overflow-y: auto;
}

.publish-menu.open {
    display: flex;
}

.publish-menu-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    padding: 8px 10px 6px;
}

.publish-channel-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.publish-channel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
    background: transparent;
}

.publish-channel-item i {
    width: 14px;
    height: 14px;
    color: var(--muted);
    flex-shrink: 0;
}

.publish-channel-item:hover:not(:disabled) {
    background: rgba(34, 197, 94, .15);
    color: var(--white);
}

.publish-channel-item:disabled {
    opacity: .6;
}

.publish-menu-empty {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 16px 10px;
}

/* ==================================================
   FLOATING PREVIEW BUTTON + BOTTOM DRAWER
================================================== */

.preview-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
    box-shadow: 0 6px 20px rgba(139, 92, 246, .45);
    z-index: 200;
    transition: transform .15s ease;
}

.preview-fab:hover {
    transform: scale(1.06);
}

.preview-fab i {
    width: 22px;
    height: 22px;
}

.preview-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 210;
}

.preview-drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.preview-drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 78vh;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .4);
    transform: translateY(100%);
    transition: transform .25s ease;
    z-index: 220;
    display: flex;
    flex-direction: column;
}

.preview-drawer.open {
    transform: translateY(0);
}

.preview-drawer-handle {
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: var(--border);
    margin: 10px auto;
    flex-shrink: 0;
}

.preview-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px 12px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.preview-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    color: var(--muted);
}

.preview-drawer-close:hover {
    background: var(--surface-light);
    color: var(--white);
}

.preview-drawer-close i {
    width: 15px;
    height: 15px;
}

.preview-drawer-content {
    overflow-y: auto;
    padding: 18px;
}

.preview-drawer-content .discord-message-frame {
    max-width: none;
    box-shadow: none;
}

@media (min-width: 861px) {
    /* The inline canvas already shows a live preview on wider
       screens where all three panes fit — the floating button is
       primarily a mobile affordance for exact full-screen review. */
    .preview-fab {
        bottom: 24px;
        right: 24px;
    }
}

/* ==================================================
   PROPERTIES PANEL — extended field widgets
================================================== */

.properties-node-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--primary-light);
    margin-bottom: 14px;
}

.field-section-heading {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin: 18px 0 10px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.properties-hint {
    font-size: 12px;
    line-height: 1.6;
    color: var(--muted);
    margin-top: 14px;
}

.field-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-color-reset {
    flex-shrink: 0;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-light);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.field-color-reset:hover {
    color: var(--text);
    border-color: var(--text-muted, var(--border));
}

.field-color-row input[type="color"] {
    width: 38px;
    height: 34px;
    padding: 2px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-light);
    flex-shrink: 0;
}

.field-color-row input[type="text"] {
    flex: 1;
}

.field-list-card {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
}

.field-list-card-stacked {
    flex-direction: column;
    align-items: stretch;
}

.field-list-card input {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--white);
    border-radius: 6px;
    padding: 7px 8px;
    font-size: 12px;
    flex: 1;
    min-width: 0;
}

.field-list-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.field-list-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    color: var(--muted);
    flex-shrink: 0;
    transition: background .15s ease, color .15s ease;
}

.field-list-remove i {
    width: 13px;
    height: 13px;
}

.field-list-remove:hover {
    background: rgba(248, 113, 113, .15);
    color: #f87171;
}

.field-list-add {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px dashed var(--border);
    color: var(--primary-light);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.field-list-add:hover {
    background: rgba(139, 92, 246, .08);
    border-color: var(--primary);
}

/* ==================================================
   RENDERED COMPONENT TREE (preview.js output)
================================================== */

.preview-drop-zone {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 8px;
}

.preview-drop-zone.drag-over {
    outline: 2px dashed var(--primary);
    outline-offset: 4px;
    border-radius: 8px;
    background: rgba(139, 92, 246, .06);
}

.preview-component-shell {
    position: relative;
    border-radius: 8px;
    outline: 2px solid transparent;
    outline-offset: 2px;
    cursor: pointer;
    transition: outline-color .12s ease;
}

.preview-component-shell:hover {
    outline-color: rgba(139, 92, 246, .35);
}

.preview-component-shell.selected {
    outline-color: var(--primary);
}

.preview-component-shell.dragging {
    opacity: .35;
}

/* Text Display + markdown */

.preview-text-display {
    color: #dbdee1;
    font-size: 15px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.md-inline-code {
    background: #2b2d31;
    padding: 1px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}

.md-codeblock {
    background: #2b2d31;
    border-radius: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    font-family: monospace;
    font-size: 13px;
    margin: 4px 0;
}

.md-mention {
    background: rgba(88, 101, 242, .3);
    color: #c9cdfb;
    padding: 0 3px;
    border-radius: 3px;
    font-weight: 500;
}

/* Container */

.preview-container {
    border-left: 4px solid transparent;
    background: rgba(255, 255, 255, .02);
    border-radius: 6px;
    padding: 12px 14px;
}

.preview-container.has-accent {
    border-left-color: var(--accent-color);
}

.preview-container.spoiler {
    filter: blur(4px);
}

/* Section */

.preview-section {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.preview-section-text {
    flex: 1;
    min-width: 0;
}

.preview-section-accessory {
    flex-shrink: 0;
}

/* Separator */

.preview-separator {
    display: flex;
    align-items: center;
}

.preview-separator.spacing-small { padding: 2px 0; }
.preview-separator.spacing-large { padding: 10px 0; }

.preview-separator-line {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, .08);
}

/* Thumbnail / Media Gallery / File */

.preview-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: #2b2d31;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-thumbnail img,
.preview-media-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-thumbnail.spoiler,
.preview-media-cell.spoiler {
    filter: blur(10px);
}

.preview-media-placeholder,
.preview-media-broken {
    color: #6d6f78;
}

.preview-media-placeholder i {
    width: 22px;
    height: 22px;
}

.preview-media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 6px;
}

.preview-media-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #2b2d31;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #2b2d31;
    border: 1px solid rgba(255, 255, 255, .08);
    padding: 8px 14px;
    border-radius: 8px;
    color: #dbdee1;
    font-size: 13px;
    width: fit-content;
}

.preview-file-chip i {
    width: 15px;
    height: 15px;
    color: var(--primary-light);
}

/* Action Row + Buttons */

.preview-action-row .preview-drop-zone {
    flex-direction: row;
    flex-wrap: wrap;
}

.preview-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    font-family: "Poppins", sans-serif;
    color: var(--white);
}

.preview-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.discord-btn-primary { background: #5865f2; }
.discord-btn-secondary { background: #4e5058; }
.discord-btn-success { background: #248046; }
.discord-btn-danger { background: #da373c; }
.discord-btn-link { background: #4e5058; text-decoration: underline; }
.discord-btn-premium {
    background: linear-gradient(135deg, #f0b132, #f2994a);
    color: #1a1a1a;
}

.preview-btn-premium-icon,
.preview-btn-external-icon {
    width: 14px;
    height: 14px;
}

/* Selects */

.preview-select {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #2b2d31;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    padding: 9px 12px;
    max-width: 320px;
    color: #dbdee1;
    font-size: 13px;
}

.preview-select.disabled {
    opacity: .5;
}

.preview-select-chevron {
    width: 15px;
    height: 15px;
    color: #949ba4;
    flex-shrink: 0;
}

/* Text Input block */

.preview-text-input-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 420px;
}

.preview-text-input-block label {
    font-size: 12px;
    font-weight: 600;
    color: #b5bac1;
}

.preview-text-input-block input,
.preview-text-input-block textarea {
    background: #2b2d31;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 6px;
    padding: 8px 10px;
    color: #dbdee1;
    font-family: "Poppins", sans-serif;
    font-size: 13px;
}


.palette-item--disabled,
.palette-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.toolbar-logo {
    margin-left: 4px;
}


/* Center Discord preview card in the canvas */
.builder-canvas {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#components-root {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
}

.field-group textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "Poppins", ui-sans-serif, system-ui, sans-serif;
}

.eb-md-h1 {
    display: inline;
    font-size: 1.4em;
    font-weight: 700;
    line-height: 1.3;
}

.eb-md-h2 {
    display: inline;
    font-size: 1.2em;
    font-weight: 700;
    line-height: 1.35;
}

.eb-md-h3 {
    display: inline;
    font-size: 1.05em;
    font-weight: 600;
    line-height: 1.4;
}

.eb-inline-code {
    background: #2b2d31;
    padding: 1px 5px;
    border-radius: 4px;
    font-family: ui-monospace, monospace;
    font-size: 0.9em;
}

.eb-custom-emoji {
    display: inline !important;
    width: 1.375em;
    height: 1.375em;
    max-width: 1.375em !important;
    max-height: 1.375em !important;
    vertical-align: -0.25em;
    object-fit: contain;
    margin: 0 0.05em;
    border-radius: 0;
}


/* Top-level and nested text nodes always use full canvas width */
.eb-node.eb-node-text_display,
.eb-node.eb-node-container,
.eb-node.eb-node-section {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

#components-root {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    box-sizing: border-box;
}

#components-root > .eb-node {
    width: 100%;
    min-width: 0;
}
