.box-model-layer > div {
    pointer-events: none;
    text-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
:root {
    --bg-dark: #1e1e1e;
    --bg-panel: #252526;
    --bg-header: #333333;
    --accent: #007acc;
    --text: #cccccc;
    --border: #3e3e42;
}
.gallery img {
  margin: 10px;
  cursor: pointer;
  transition: 0.3s;
  border-radius: 8px;
  max-height: 200px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.gallery img:hover {
  transform: scale(1.05);
}

.gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
body {

    margin: 0; padding: 0;
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* OVERLAY */
.overlay {
    position: fixed; top:0; left:0; width:100%; height:100%;
    background: rgba(0,0,0,0.8);
    display: flex; justify-content: center; align-items: center;
    z-index: 9999;
    overflow: hidden;
}
.modal {
    background: var(--bg-panel);
    padding: 2rem; border-radius: 8px; text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    min-width: 300px;
    border: 1px solid var(--border);
}

/* ANIMATED LOGO BACKGROUND */
.logo-wave-animation {
    animation: wave 3.2s ease-in-out infinite;
    will-change: transform;
}

@keyframes wave {

    0%, 100% {
        transform: rotateZ(-8deg);
        transform: scale(1.05);
    }
    25% {
        transform: rotateZ(-20deg)
    }
    50% {
        transform: rotateZ(0deg);
    }
    75% {
        transform: rotateZ(15deg);
    }
}

/* LAYOUT */
.app-container {
    display: flex; height: 100vh; width: 100vw;
}

.sidebar, .toolbox {
    width: 300px;
    min-width: 300px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
}
.toolbox { border-left: 1px solid var(--border); border-right: none; width: 200px; min-width: 200px; }

.preview-area {
    flex: 1;
    display: flex; flex-direction: column;
    background: #121212; 
}

/* HEADERS & TOOLBARS */
.sidebar-header, .toolbar {
    padding: 10px 15px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    min-height: 50px;
}
.toolbar { gap: 10px; position: relative; z-index: 100; }
.scrollable { flex: 1; overflow-y: auto; padding: 15px; }

/* CANVAS (IFRAME) */
.canvas-wrapper {
    flex: 1; 
    overflow: hidden; /* Iframe handles its own scroll */
    padding: 0;
    display: flex; 
    justify-content: center;
    background: #111;
}

.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff; /* Default white before CSS loads */
}

/* Canvas Loading Overlay */
.canvas-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 17, 17, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: auto;  /* Block all clicks while loading */
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #ccc;
    font-size: 14px;
    text-align: center;
}

.canvas-wrapper {
    position: relative;
}

/* BUTTONS & FORMS */
button {
    background: #444; color: white; border: none; padding: 8px 12px;
    cursor: pointer; border-radius: 4px; font-size: 0.9rem;
}
button:hover { background: #555; transition: all 0.2s ease; }
.btn-primary { background: var(--accent); transition: all 0.2s ease; }
.btn-primary:hover { background: #0062a3; transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0, 122, 204, 0.3); }
.btn-danger { background: #d9534f; transition: all 0.2s ease; }
.btn-danger:hover { background: #c9423f; }
.btn-success { background: #5cb85c; transition: all 0.2s ease; }
.btn-success:hover { background: #4caf50; transform: translateY(-1px); box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3); }
.btn-small { padding: 4px 8px; font-size: 0.8rem; }

.block-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px;
}

.block-btn {
    width: 100%;
    margin: 0;
    text-align: center;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: grab;
    min-height: 100px;
    background: #2a2a2a;
    border: 2px solid #444;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
}

.block-btn:hover {
    background: #333;
    border-color: #1976d2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.block-btn:active {
    cursor: grabbing;
}

.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; font-size: 0.85rem; color: #aaa; font-weight: 500; }
input, textarea, select {
    width: 100%; padding: 8px;
    background: #3c3c3c; border: 1px solid #555;
    color: white; border-radius: 4px;
    box-sizing: border-box; 
    transition: all 0.2s ease;
}
input:focus, textarea:focus, select:focus { 
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}
input::placeholder, textarea::placeholder {
    color: #888;
}





/* 1. Alapbeállítás a Firefoxnak */
.scrollable {
    overflow-y: auto;
    height: 100%; /* Vagy amennyi a panel magassága */
    
    /* Sötét csúszka, átlátszó sáv */

    scrollbar-color: #444444 transparent; 
}

/* 2. Chrome, Edge, Safari beállítások */
.scrollable::-webkit-scrollbar {
    width: 8px; /* Vékonyabb, elegánsabb */
}

.scrollable::-webkit-scrollbar-track {
    background: transparent; /* A sáv háttere láthatatlan */
}

.scrollable::-webkit-scrollbar-thumb {
    background-color: #3b3b3b; /* Ez egy nagyon sötét szürke, szinte fekete */
    border-radius: 10px;       /* Lekerekített végek */
}

/* 3. Hover effektus: Csak akkor világosodik, ha használni akarod */
.scrollable::-webkit-scrollbar-thumb:hover {
    background-color: #666666; /* Kicsit világosabb, ha ráviszed az egeret */
}

/* --- AI ASSISTANT WIDGET --- */
.ai-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: 'Segoe UI', sans-serif;
}
/* Elevate widget above backdrop when fullscreen chat is active */
.ai-widget:has(.ai-fullscreen) {
    z-index: 10000;
}

.ai-toggle-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 122, 204, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.ai-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 122, 204, 0.6);
}

.ai-toggle-btn:active {
    transform: scale(0.95);
}

/* --- AI FULLSCREEN CHAT --- */
/* Backdrop shown only in fullscreen mode */
.ai-chat-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 9998;
}

/* ---- SMALL floating chat (default) ---- */
.ai-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 500px;
    max-width: 98vw;
    height: 550px;
    max-height: 80vh;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    overflow: visible;
    animation: slideUp 0.25s ease;
}
/* Elements only visible in fullscreen */
.ai-chat-window .ai-full-only { display: none; }
.ai-chat-window .ai-full-title { display: none; }
.ai-chat-window .ai-small-title { display: block; margin: 0; font-size: 15px; color: var(--text); white-space: nowrap; }

/* ---- FULLSCREEN mode ---- */
.ai-chat-window.ai-fullscreen {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    bottom: auto; right: auto;
    width: 95%;
    max-width: 1200px;
    height: 85vh;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 10px 60px rgba(0,0,0,0.6);
    z-index: 9999;
    animation: none;
}
.ai-chat-window.ai-fullscreen .ai-full-only { display: flex; }
.ai-chat-window.ai-fullscreen .ai-full-title { display: block; margin: 0; font-size: 18px; color: var(--text); white-space: nowrap; }
.ai-chat-window.ai-fullscreen .ai-small-title { display: none; }
/* Wider message padding in fullscreen */
.ai-chat-window.ai-fullscreen .ai-messages { padding: 24px 15%; }
.ai-chat-window.ai-fullscreen .ai-input-area { padding: 16px 15%; }

.ai-fs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent);
    padding: 12px 20px;
    background: var(--bg-header);
    flex-shrink: 0;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}
.ai-fs-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.ai-fs-header-left h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text);
    white-space: nowrap;
}
.ai-fs-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-model-selector-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ai-model-dropdown {
    background: var(--bg-dark);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 13px;
    min-width: 180px;
    max-width: 320px;
    cursor: pointer;
}
.ai-model-dropdown:focus {
    outline: none;
    border-color: var(--accent);
}

.ai-icon-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-icon-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--border);
}

/* Force-visible state used by JS toggle */
.ai-chat-window.open {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure overlays can be forced visible via the open class (used by JS) */
.overlay.open {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 99998 !important;
}

.ai-close-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    border-radius: 6px;
}

.ai-close-btn:hover {
    color: var(--accent);
    background: rgba(255,255,255,0.08);
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.ai-message {
    padding: 14px 18px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.55;
    font-size: 14px;
}

.ai-message.ai-system {
    background: var(--bg-header);
    color: var(--text);
    align-self: flex-start;
    border-left: 3px solid var(--accent);
    max-width: 75%;
}

.ai-message.ai-user {
    background: var(--accent);
    color: white;
    align-self: flex-end;
    border-radius: 12px 12px 4px 12px;
}

.ai-message.ai-response {
    background: var(--bg-header);
    color: var(--text);
    align-self: flex-start;
    border-left: 3px solid var(--accent);
}

.ai-message.ai-error {
    background: #5f2020;
    color: #ffaaaa;
    align-self: flex-start;
    border-left: 3px solid #ff6b6b;
}

.ai-message.ai-loading {
    background: var(--bg-header);
    color: var(--accent);
    align-self: flex-start;
    font-style: italic;
}
.ai-message.ai-warning {
    background: #3d3520;
    color: #ffd666;
    align-self: flex-start;
    border-left: 3px solid #ff9500;
}

/* AI undo row — shows after successful AI edits */
.ai-message.ai-undo-row {
    background: transparent;
    padding: 4px 0;
    align-self: flex-start;
}
.ai-undo-btn {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 6px;
    padding: 5px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.ai-undo-btn:hover {
    background: var(--accent);
    color: #fff;
}
.ai-undo-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

/* Scrollbar styling for AI messages */
.ai-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.ai-messages::-webkit-scrollbar-thumb:hover {
    background: #555555;
}

/* AI input at the bottom - ChatGPT style */
.ai-input-area {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
    flex-shrink: 0;
    border-radius: 0 0 12px 12px;
    overflow: visible;
}

/* --- Attachment chips strip (Copilot-style) --- */
.ai-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
}
.ai-attachments.has-items {
    max-height: 200px;
    padding: 0 0 8px 0;
}
.ai-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(0, 122, 204, 0.15);
    border: 1px solid rgba(0, 122, 204, 0.35);
    color: var(--text);
    border-radius: 16px;
    padding: 3px 10px 3px 8px;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 220px;
    animation: chipSlideIn 0.25s ease both;
    cursor: default;
}
.ai-chip.removing {
    animation: chipSlideOut 0.2s ease both;
}
.ai-chip-icon {
    font-size: 13px;
    flex-shrink: 0;
    opacity: 0.7;
}
.ai-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    opacity: 0.5;
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
}
.ai-chip-remove:hover {
    opacity: 1;
    background: rgba(255,80,80,0.25);
    color: #ff6b6b;
}

@keyframes chipSlideIn {
    from { opacity: 0; transform: translateY(8px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes chipSlideOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-4px) scale(0.85); }
}

/* Attach (paperclip) button in input row */
.ai-attach-btn {
    background: none;
    border: none;
    color: var(--text);
    opacity: 0.5;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 6px;
    transition: all 0.15s;
}
.ai-attach-btn:hover {
    opacity: 1;
    background: rgba(255,255,255,0.08);
}

/* Attach menu popup */
.ai-attach-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: var(--bg-dark, #1e1e1e);
    border: 1px solid var(--border, #444);
    border-radius: 8px;
    padding: 8px 0;
    z-index: 10001;
    min-width: 200px;
    max-width: 320px;
    max-height: 50vh;
    overflow-y: auto;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
    animation: chipSlideIn 0.15s ease;
}
.ai-attach-menu.open { display: block; }
.ai-attach-section-title {
    padding: 6px 14px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #777);
}
.ai-attach-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.12s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.ai-attach-item:hover {
    background: rgba(255,255,255,0.06);
}
.ai-attach-item .ai-chip-icon {
    opacity: 0.6;
}
.ai-attach-item.attached {
    color: var(--accent, #007acc);
}
.ai-attach-item.attached .ai-chip-icon {
    opacity: 1;
}

.ai-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 12px;
    transition: border-color 0.2s;
}
.ai-input-row:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.15);
}

.ai-input {
    flex: 1;
    background: transparent;
    color: var(--text);
    border: none;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
    resize: none;
    box-sizing: border-box;
    min-height: 24px;
    max-height: 200px;
    line-height: 1.5;
    padding: 4px 0;
    overflow-y: auto;
}
.ai-input:focus {
    outline: none;
}

.ai-input::placeholder {
    color: #888888;
}

.ai-send-btn-round {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.ai-send-btn-round:hover {
    background: #0099ff;
    transform: scale(1.05);
}
.ai-send-btn-round:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

.ai-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    padding-top: 6px;
    position: relative;
}
.ai-toolbar-select {
    background: var(--bg-dark);
    color: var(--text-muted, #999);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 4px 12px;
    font-size: 11px;
    cursor: pointer;
    height: 26px;
    line-height: 1;
    vertical-align: middle;
    transition: border-color 0.15s, color 0.15s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 22px;
}
.ai-toolbar-select:hover {
    border-color: var(--accent);
    color: var(--text);
}
.ai-toolbar-select:focus {
    outline: none;
    border-color: var(--accent);
    color: var(--text);
}
.ai-toolbar-scope {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ai-disclaimer {
    font-size: 11px;
    font-style: italic;
    color: #666;
    margin-left: auto;
}

.ai-repair-btn {
    padding: 4px 10px;
    background: #ff9500;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    height: 28px;
    line-height: 1;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ai-repair-btn:hover {
    background: #ffb143;
}

.ai-repair-btn:disabled {
    background: #666666;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Responsive: Smaller screens */
@media (max-width: 768px) {
    .ai-chat-window.ai-fullscreen {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }
    .ai-chat-window.ai-fullscreen .ai-messages {
        padding: 16px 8px;
    }
    .ai-chat-window.ai-fullscreen .ai-input-area {
        padding: 12px 8px;
    }
    .ai-widget {
        bottom: 10px;
        right: 10px;
    }
    .ai-fs-header-left h2 {
        font-size: 15px;
    }
    .ai-message {
        max-width: 95%;
    }
}

/* Text editor overlay and inline field */
.text-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 12000;
    backdrop-filter: blur(2px);
}

/* Backward compatibility */
.rich-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 12000;
    backdrop-filter: blur(2px);
}

.text-editor-dialog {
    background: #1b1b1b;
    color: #f2f2f2;
    width: 860px;
    max-width: 96vw;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #333;
}

/* Backward compatibility */
.rich-editor-dialog {
    background: #1b1b1b;
    color: #f2f2f2;
    width: 860px;
    max-width: 96vw;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #333;
}

.text-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #2e2e2e;
    background: linear-gradient(90deg, #1f1f1f, #242424);
}

/* Backward compatibility */
.text-editor-editable {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.text-editor-editable:focus {
    outline: none;
}
.rte-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #2e2e2e;
    background: linear-gradient(90deg, #1f1f1f, #242424);
}

.text-editor-title {
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Backward compatibility */
.rte-title {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.text-editor-close {
    background: transparent;
    border: none;
    color: #bbb;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
}

.text-editor-close:hover {
    color: #fff;
}

/* Backward compatibility */
.rte-close {
    background: transparent;
    border: none;
    color: #bbb;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
}

.rte-close:hover {
    color: #fff;
}

.text-editor-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px 4px 14px;
    overflow: hidden;
}

.text-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    background: #202020;
    border: 1px solid #303030;
    border-radius: 8px;
    padding: 8px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.text-editor-btn {
    background: #2c2c2c;
    border: 1px solid #3a3a3a;
    color: #f2f2f2;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.text-editor-btn:hover {
    background: #373737;
}

.text-editor-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* Backward compatibility */
.rte-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px 4px 14px;
    overflow: hidden;
}

.rich-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    background: #202020;
    border: 1px solid #303030;
    border-radius: 8px;
    padding: 8px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.rte-btn {
    background: #2c2c2c;
    border: 1px solid #3a3a3a;
    color: #f2f2f2;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.rte-btn:hover {
    background: #373737;
}

.rte-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

.text-editor-select {
    background: #2c2c2c;
    color: #e6e6e6;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 6px 10px;
}

.text-editor-color {
    width: 38px;
    height: 32px;
    background: #2c2c2c;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    cursor: pointer;
}

/* Backward compatibility */
.rte-select {
    background: #2c2c2c;
    color: #e6e6e6;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 6px 10px;
}

.rte-color {
    width: 38px;
    height: 32px;
    background: #2c2c2c;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    cursor: pointer;
}

.text-editor-canvas {
    min-height: 280px;
    max-height: 58vh;
    overflow: auto;
    background: #121212;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 14px;
    line-height: 1.6;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
    color: #e6e6e6;
}

.text-editor-canvas:focus {
    outline: 1px solid #007acc;
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.35);
}

/* Ensure text color is visible even when applied */
.text-editor-canvas span {
    color: inherit;
}

/* Make highlighted/background text visible */
.text-editor-canvas span[style*="background"] {
    padding: 2px 3px;
    border-radius: 2px;
}

.text-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 14px 14px 14px;
    border-top: 1px solid #2e2e2e;
    background: #1f1f1f;
}

.text-editor-html-code {
    font-family: 'Courier New', monospace;
}

/* Backward compatibility */
.rich-editor-canvas {
    min-height: 280px;
    max-height: 58vh;
    overflow: auto;
    background: #121212;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 14px;
    line-height: 1.6;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
    color: #e6e6e6;
}

.rich-editor-canvas:focus {
    outline: 1px solid #007acc;
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.35);
}

/* Make colored text visible in rich editor */
.rich-editor-canvas span {
    color: inherit;
}

/* Make highlighted/background text visible */
.rich-editor-canvas span[style*="background"] {
    padding: 2px 3px;
    border-radius: 2px;
}

.rte-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 14px 14px 14px;
    border-top: 1px solid #2e2e2e;
    background: #1f1f1f;
}

.text-editor-field {
    border: 1px solid #3a3a3a;
    background: #202020;
    border-radius: 8px;
    padding: 10px;
}

.text-editor-preview {
    min-height: 80px;
    border: 1px dashed #3d3d3d;
    padding: 10px;
    border-radius: 6px;
    background: #161616;
    line-height: 1.6;
    margin-bottom: 10px;
}

.text-editor-empty {
    color: #777;
    font-style: italic;
}

.text-editor-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.text-editor-helper {
    color: #9c9c9c;
    font-size: 12px;
}

.text-editor-view-btn {
    background: #2c2c2c;
    border: 1px solid #3a3a3a;
    color: #a0a0a0;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 12px;
    transition: all 0.2s;
}

.text-editor-view-btn:hover {
    background: #373737;
    color: #e6e6e6;
}

.text-editor-view-btn.active {
    background: #007acc;
    color: #fff;
    border-color: #007acc;
}

/* Backward compatibility */
.rte-field {
    border: 1px solid #3a3a3a;
    background: #202020;
    border-radius: 8px;
    padding: 10px;
}

.rte-preview {
    min-height: 80px;
    border: 1px dashed #3d3d3d;
    padding: 10px;
    border-radius: 6px;
    background: #161616;
    line-height: 1.6;
    margin-bottom: 10px;
}

.rte-empty {
    color: #777;
    font-style: italic;
}

.rte-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.rte-helper {
    color: #9c9c9c;
    font-size: 12px;
}

/* Inline text editor styles */
.inline-text-editor {
    display: inline-block;
    padding: 4px 8px;
    border: 2px solid #007acc;
    background: #1a1a1a;
    color: #e6e6e6;
    border-radius: 4px;
    outline: none;
    box-shadow: 0 0 8px rgba(0, 122, 204, 0.4);
    font-family: inherit;
    font-size: inherit;
}

.inline-text-editor:focus {
    box-shadow: 0 0 12px rgba(0, 122, 204, 0.6), inset 0 0 4px rgba(0, 122, 204, 0.2);
}

/* --- GALLERY SELECTOR CARDS --- */
.gallery-selector-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #222;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 3px solid #555;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 8px;
}

.gallery-selector-card:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(25, 118, 210, 0.3);
}

.gallery-selector-card.selected {
    border-color: #1976d2;
    box-shadow: 0 0 12px rgba(25, 118, 210, 0.5);
}

.gallery-selector-card .gallery-selector-checkbox {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: #555;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    z-index: 10;
    font-weight: bold;
    color: white;
    font-size: 12px;
    transition: all 0.2s ease;
}

.gallery-selector-card.selected .gallery-selector-checkbox {
    background: #1976d2;
    box-shadow: 0 0 8px rgba(25, 118, 210, 0.6);
}

/* ============================================
   MEDIA GALLERY - DRAG & DROP STYLES
   ============================================ */

.media-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 8px;
    background: #0d0d0d;
    border-radius: 8px;
    min-height: 200px;
    overflow: auto;
    max-height: 500px;
}

.media-card {
    position: relative;
    aspect-ratio: 1;
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.2s ease;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    margin-bottom: 100px;
}

.media-card:hover {
    border-color: #555;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    transform: translateY(-2px);
}

.media-card:active {
    cursor: grabbing;
}

.media-card-ghost {
    opacity: 0.5;
    background: #111;
    border: 2px dashed #666;
}

.media-card-drag {
    opacity: 0.8;
    box-shadow: 0 8px 16px rgba(0, 122, 204, 0.5);
}

/* Container for the media element */
.media-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
}

/* Image thumbnail */
.media-thumbnail {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

/* Video icon overlay */
.media-video-icon {
    position: absolute;
    font-size: 48px;
    color: #007acc;
    opacity: 0.8;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 5;
}

/* Order badge */
.media-order-badge {
    position: absolute;
    top: -8px;
    left: -8px;
    background: linear-gradient(135deg, #d9534f, #c9302c);
    color: white;
    font-size: 14px;
    font-weight: bold;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    border: 2px solid #fff;
    z-index: 10;
    transition: all 0.2s ease;
}

.media-card:hover .media-order-badge {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(217, 83, 79, 0.8);
}

/* Info overlay at bottom */
.media-info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    color: #ddd;
    font-size: 11px;
    padding: 8px 6px 6px 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 6;
    pointer-events: none;
}

/* --- BOX MODEL EDITOR --- */
.box-model-visual {
    position: relative;
    width: 220px;
    height: 220px;
    margin: 0 auto 18px auto;
    user-select: none;
}
.box-model-layer {
    position: absolute;
    box-sizing: border-box;
    border-radius: 10px;
    pointer-events: none;
}
.box-model-margin {
    background: rgba(255,200,0,0.10);
    border: 2px dashed #e6b800;
    z-index: 1;
}
.box-model-border {
    background: rgba(0,180,255,0.10);
    border: 2px solid #00b4ff;
    z-index: 2;
}
.box-model-padding {
    background: rgba(0,255,100,0.10);
    border: 2px solid #00ff64;
    z-index: 3;
}
.box-model-content {
    background: rgba(255,255,255,0.10);
    border: 2px solid #aaa;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 13px;
}
.box-model-input {
    width: 44px;
    height: 32px;
    font-size: 15px;
    border: 1.5px solid #444;
    border-radius: 7px;
    background: #23272e;
    color: #eaf6ff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    outline: none;
    z-index: 10;
    pointer-events: auto;
    transition: border 0.18s, background 0.18s;
    text-align: center;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}
.box-model-input:focus {
    border: 2px solid #1976d2;
    background: #181c22;
}
.box-model-input-active {
    border: 2.5px solid #1976d2 !important;
    background: #181c22;
}

/* Responsive grid sizes */
@media (max-width: 1200px) {
    .media-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .media-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }
    
    .media-order-badge {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* --- BEGINNER HELPER STYLES --- */
/* Adds visual feedback for important first-time user elements */
.help-hint {
    background: rgba(25, 118, 210, 0.1);
    border-left: 3px solid #1976d2;
    padding: 12px;
    border-radius: 4px;
    font-size: 12px;
    color: #aaa;
    margin-bottom: 15px;
}

.help-hint strong {
    color: #1976d2;
}

/* ============================================
   UI/UX ENHANCEMENTS
   ============================================ */

/* --- ENHANCED TOAST NOTIFICATIONS --- */
.toast-notification {
    position: fixed;
    right: 18px;
    bottom: 18px;
    background: #1e1e1e;
    color: #fff;
    padding: 12px 18px 12px 14px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 100000;
    max-width: 420px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    transition: opacity 280ms ease, transform 280ms ease;
    border-left: 4px solid var(--accent);
    pointer-events: auto;
}

.toast-notification.toast-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-notification.toast-success {
    border-left-color: #4caf50;
}

.toast-notification.toast-error {
    border-left-color: #f44336;
    background: #2a1a1a;
}

.toast-notification.toast-warning {
    border-left-color: #ff9800;
}

.toast-notification.toast-info {
    border-left-color: var(--accent);
}

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1;
}

.toast-body {
    flex: 1;
    line-height: 1.4;
}

.toast-dismiss {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.toast-dismiss:hover {
    color: #fff;
    background: none;
}

/* --- SMOOTH OVERLAY TRANSITIONS --- */
.overlay {
    transition: opacity 0.25s ease;
}

.overlay.overlay-fade-enter {
    opacity: 0;
}

.overlay.overlay-fade-active {
    opacity: 1;
}

/* --- TOOLBAR BUTTON GROUPS --- */
.toolbar-group {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0 8px;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.toolbar-group:last-child {
    border-right: none;
}

.toolbar-group .btn-small {
    position: relative;
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.15s ease;
}

.toolbar-group .btn-small:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-1px);
}

/* Tooltip for toolbar buttons */
.toolbar-group .btn-small[title]:hover::after {
    content: attr(title);
    position: absolute;
    top: 100%;
    margin-top: 6px;
    left: 50%;
    transform: translateX(-50%);
    background: #111;
    color: #ddd;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 200000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border: 1px solid #444;
}

/* --- PAGE SELECTOR IMPROVEMENTS --- */
.page-selector {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: nowrap;
}

.page-selector label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #aaa;
    white-space: nowrap;
}

.page-selector select {
    min-width: 120px;
    max-width: 200px;
    padding: 6px 8px;
    font-size: 13px;
}

/* --- EMPTY STATE FOR PROPERTIES PANEL --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #666;
    gap: 16px;
    min-height: 200px;
}

.empty-state-icon {
    font-size: 48px;
    opacity: 0.4;
    line-height: 1;
}

.empty-state-title {
    font-size: 15px;
    font-weight: 600;
    color: #999;
    margin: 0;
}

.empty-state-desc {
    font-size: 12px;
    color: #666;
    margin: 0;
    max-width: 220px;
    line-height: 1.5;
}

/* --- SAVE BUTTON STATES --- */
.btn-success.save-pulse {
    animation: savePulse 0.5s ease;
}

@keyframes savePulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(76, 175, 80, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

.btn-success.save-saved {
    background: #388e3c;
    position: relative;
}

.btn-success.save-saved::after {
    content: '✓';
    margin-left: 6px;
}

/* --- CUSTOM CONFIRM DIALOG --- */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100001;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.confirm-overlay.confirm-visible {
    opacity: 1;
}

.confirm-dialog {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.confirm-overlay.confirm-visible .confirm-dialog {
    transform: scale(1);
}

.confirm-title {
    font-size: 16px;
    font-weight: 600;
    color: #eee;
    margin: 0 0 8px 0;
}

.confirm-message {
    font-size: 13px;
    color: #aaa;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.confirm-actions button {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
}

/* --- ACTIONS BAR IMPROVEMENTS --- */
.actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.actions button {
    font-weight: 600;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    transition: all 0.2s ease;
}

.actions .btn-primary {
    background: linear-gradient(135deg, #1976d2, #1565c0);
    font-weight: 700;
    letter-spacing: 0.3px;
}

.actions .btn-primary:hover {
    background: linear-gradient(135deg, #1e88e5, #1976d2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.4);
}

/* --- GLOBAL SETTINGS BUTTON (SIDEBAR BOTTOM) --- */
.global-settings {
    padding: 12px 15px;
    border-top: 1px solid var(--border);
    background: var(--bg-header);
}

.global-settings button {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.global-settings button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* --- BLOCK BUTTON IMPROVEMENTS (TOOLBOX) --- */
.block-btn {
    position: relative;
    overflow: hidden;
}

.block-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 60%, rgba(255,255,255,0.03) 100%);
    pointer-events: none;
}

/* --- SETTINGS MENU ITEM IMPROVEMENTS --- */
.settings-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease !important;
}

.settings-menu-item:hover:not(.settings-menu-active) {
    background: rgba(255,255,255,0.05) !important;
    color: #ddd !important;
    border-left-color: rgba(25, 118, 210, 0.3) !important;
}

/* --- STARTUP SCREEN IMPROVEMENTS --- */
#startup-overlay .modal {
    animation: modalSlideIn 0.4s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#startup-overlay .btn-primary {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 8px;
    letter-spacing: 0.3px;
    background: linear-gradient(135deg, #1976d2, #1565c0);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
    transition: all 0.3s ease;
}

#startup-overlay .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(25, 118, 210, 0.5);
    background: linear-gradient(135deg, #1e88e5, #1976d2);
}

/* Recent project items styling */
#recent-projects-list .btn-secondary {
    transition: all 0.2s ease;
    border: 1px solid transparent;
    border-radius: 6px;
}

#recent-projects-list .btn-secondary:hover {
    border-color: var(--accent);
    background: rgba(0, 122, 204, 0.1);
    transform: translateX(4px);
}

/* --- FORM CONTROLS IMPROVEMENTS --- */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
    cursor: pointer;
}

/* --- KEYBOARD SHORTCUT HINTS --- */
.kbd-hint {
    display: inline-block;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 11px;
    font-family: monospace;
    color: #888;
    margin-left: 6px;
    vertical-align: middle;
}
