/* Modern Visual Concept Designer CSS - Clean & Minimal */

:root {
    /* Color Palette - Modern Fixed Colors */
    --primary-color: #1a8fe3;
    --primary-dark: #0d6fc0;
    --primary-light: #5cb3ef;
    --primary-bg: #e8f4fe;
    
    --secondary-color: #22D3EE;
    --secondary-dark: #0EA5C6;
    --secondary-light: #67E8F9;
    
    --success-color: #10B981;
    --success-dark: #059669;
    --success-light: #34D399;
    --success-bg: #ECFDF5;
    
    --danger-color: #EF4444;
    --danger-dark: #DC2626;
    --danger-light: #F87171;
    --danger-bg: #FEF2F2;
    
    --warning-color: #F59E0B;
    --warning-dark: #D97706;
    --warning-light: #FCD34D;
    --warning-bg: #FFFBEB;
    
    /* Neutral Colors */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    /* UI Colors */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F9FAFB;
    --bg-tertiary: #F3F4F6;
    
    --text-primary: #000000;
    --text-secondary: #000000;
    --text-tertiary: #000000;
    
    --border-color: #E5E7EB;
    --border-dark: #D1D5DB;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    
    --shadow-primary: 0 10px 25px -5px rgba(26, 143, 227, 0.2);
    --shadow-success: 0 10px 25px -5px rgba(16, 185, 129, 0.2);
    --shadow-danger: 0 10px 25px -5px rgba(239, 68, 68, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

 

#cy {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    border-radius: 14px;
}

/* Clean Controls Panel */
#controls {
    position: relative;
    top: 0;
    left: 0;
    z-index: 1000;
    background: #fff;
    padding: 8px 14px;
    border-radius: 0px;
    box-shadow: none;
    border: none;
    border-bottom: 0.5px solid #e0e3e8;
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
    animation: slideDown 0.5s ease-out;
    width: 100%;
}

/* Button Group Dropdown Styles */
.btn-group {
    position: relative;
    display: inline-block;
}

.btn-group-toggle {
    padding: 9px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s ease;
    box-shadow: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-group-toggle:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    filter: brightness(1.03);
}

/* Match the example toolbar: menu toggles are OUTLINE pills (white, hairline),
   only Sidekick is a solid accent pill. Scoped under #controls so these win
   over the higher-specificity `#controls button` rule. */
#controls .btn-group-toggle {
    background: #fff;
    color: #333;
    border: 0.5px solid #dde0e8;
    box-shadow: none;
    padding: 9px 15px;
    font-size: 13px;
}

/* Keep every toolbar button the same height (Sidekick / View & Export /
   Migration / Build). min-height + centered flex guarantees equal pills
   regardless of outline-vs-solid borders or icon content. */
#controls .btn-group-toggle,
#controls #build-btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
}
#controls #build-btn {
    padding: 9px 16px;
    font-size: 13px;
    border-radius: 20px;
}
#controls .btn-group-toggle:hover {
    background: #f4f8fe;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: none;
    filter: none;
}
#controls .btn-group-toggle .btn-group-arrow { color: inherit; opacity: 0.7; }

/* Sidekick → solid accent pill */
#controls .btn-group-toggle[onclick*="toggleAIChat"] {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}
#controls .btn-group-toggle[onclick*="toggleAIChat"]:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
    filter: brightness(1.04);
}

.btn-group-toggle .btn-group-arrow {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.btn-group.open .btn-group-toggle .btn-group-arrow {
    transform: rotate(180deg);
}

.btn-group-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 200px;
    background: var(--bg-primary);
    border-radius: 14px;
    box-shadow: var(--shadow-xl);
    border: 0.5px solid var(--border-color);
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 1001;
    animation: dropdownFadeIn 0.2s ease-out;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-group.open .btn-group-dropdown {
    display: flex;
}

/* Dropdown items mirror the "View & Export" toggle pill: white fill,
   hairline grey border, dark text, accent icon. Scoped under #controls so
   these win over the higher-specificity `#controls button` base rule, and
   forced with !important to override any leftover inline background colours. */
#controls .btn-group-dropdown button {
    width: 100%;
    text-align: left;
    padding: 9px 14px;
    background: #fff !important;
    color: #333 !important;
    border: 0.5px solid #dde0e8 !important;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: visible;
}

#controls .btn-group-dropdown button i {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    color: var(--primary-color);
}

#controls .btn-group-dropdown button:hover {
    background: #f4f8fe !important;
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    box-shadow: none;
    opacity: 1;
    transform: translateX(4px);
}

#controls .btn-group-dropdown button:hover i {
    color: var(--primary-color);
}

/* Section heading inside a dropdown — groups related actions
   (Canvas / Export Diagrams / Migration) so the merged menu stays scannable. */
.btn-group-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    opacity: 0.65;
    padding: 6px 14px 2px;
}

.btn-group-divider {
    height: 1px;
    margin: 4px 8px;
    background: var(--border-color);
}

.btn-group-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.btn-group-item-row label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.btn-group-item-row select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg-primary);
    cursor: pointer;
}

@keyframes slideDown {
    from {
        transform: translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#controls button {
    padding: 9px 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s ease;
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

/* Ripple flourish removed to match the flatter together aesthetic. */
#controls button::before { display: none; }

#controls button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    filter: brightness(1.03);
}

#controls button:active {
    transform: translateY(0);
}

/* AI Agent button special styling */
#controls button[onclick*="toggleAIChat"] {
    background: var(--secondary-color);
}

#controls button[onclick*="toggleAIChat"]:hover {
    background: var(--secondary-dark);
    box-shadow: 0 10px 25px -5px rgba(34, 211, 238, 0.3);
}

#controls select {
    padding: 10px 18px;
    padding-left: 11px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    min-width: 131px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

#controls select:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

#controls select:focus {
    outline: none;
    border-color: var(--primary-color);
}

#controls label {
    font-weight: 600;
    margin-right: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

/* Zoom Indicator */
#zoom-indicator {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 410px;
    background: var(--bg-primary);
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    z-index: 1000;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    animation: fadeIn 0.5s ease-out;
}

/* Enhanced Node Form */
.node-form {
    position: fixed;
    background: var(--bg-primary);
    border: 2px solid var(--primary-color);
    border-radius: 20px;
    padding: 28px;
    box-shadow: var(--shadow-2xl);
    z-index: 2000;
    display: none;
    width: 850px;
    max-height: 90vh !important;
    height: auto;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.node-form h3 {
    color: var(--primary-color);
    font-size: 24px;
    margin-bottom: 20px;
    font-weight: 700;
}

.node-form-content {
    display: flex;
    gap: 24px;
    margin-top: 20px;
}

.node-form-left, .node-form-right {
    flex: 1;
}

.node-form input, .node-form textarea {
    width: 100%;
    padding: 12px 16px;
    margin: 8px 0;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.node-form input:focus, .node-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
 }

.node-form button {
    padding: 12px 24px;
    margin: 6px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.node-form button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary);
}

.node-form button[onclick*="deleteNode"] {
    background: var(--danger-color);
}

.node-form button[onclick*="deleteNode"]:hover {
    background: var(--danger-dark);
    box-shadow: var(--shadow-danger);
}

.node-form button[onclick*="closeNodeForm"] {
    background: var(--gray-500);
}

.node-form button[onclick*="closeNodeForm"]:hover {
    background: var(--gray-600);
}

/* Enhanced Item List */
.item-list {
    max-height: 550px;
    overflow-y: auto;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    background: var(--bg-secondary);
}

.item-list h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
}

.item-entry {
    padding: 12px;
    margin: 8px 0;
    background: var(--bg-primary);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    border-left: 4px solid var(--primary-color);
}

.item-entry:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.item-entry button {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.item-entry button:hover {
    background: var(--danger-dark);
    transform: scale(1.05);
}

/* Enhanced Connection Entry */
.connection-entry {
    padding: 12px;
    margin: 8px 0;
    background: var(--success-bg);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--success-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.connection-entry:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.connection-entry input {
    padding: 6px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s ease;
    background: var(--bg-primary);
}

.connection-entry input:focus {
    outline: none;
    border-color: var(--success-color);
}

.connection-entry button {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.connection-entry button:hover {
    background: var(--danger-dark);
}

#connections-list {
    max-height: 250px;
    overflow-y: auto;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    background: var(--bg-secondary);
}

/* Enhanced HTML Node Labels */
.cy-node-html-label {
    background: var(--bg-primary);
     border-radius: 4px;
     border:1px solid grey;
    padding: 16px;
    box-shadow: var(--shadow-lg);
    width: 302px;
    height: 454px;
    cursor: pointer;
     pointer-events: all;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    position: relative;
}

.cy-node-html-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-color);
    border-radius: 16px 16px 0 0;
}

 

.node-header {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.node-icon {
    font-size: 20px;
    filter: grayscale(0.2);
}

.node-comment {
    color: var(--text-secondary);
    font-size: 13px;
    font-style: italic;
    margin-bottom: 12px;
    padding: 10px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--primary-color);
    border-radius: 6px;
}

.node-items {
    margin-top: 3px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Node Roles Section - bottom right of concept blocks */
.node-roles-section {
    margin-top: 10px;
    padding: 8px 0 0 0;
    border-top: 2px solid var(--border-color);
}

.node-roles-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.node-roles-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
}

.node-role-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    background: var(--gray-50);
    border-left: 3px solid var(--gray-300);
}

.node-role-item.role-full {
    border-left-color: var(--success-color);
    background: #ecfdf5;
}

.node-role-item.role-readonly {
    border-left-color: #3b82f6;
    background: #eff6ff;
}

.node-role-item.role-hidden {
    border-left-color: var(--danger-color);
    background: #fef2f2;
}

.node-role-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.node-role-access {
    font-size: 14px;
}

.node-items::-webkit-scrollbar {
    width: 6px;
}

.node-items::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 3px;
}

.node-items::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 3px;
}

.node-items::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

.node-item {
    display: flex;
    padding: 8px 4px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.node-item:hover {
    background: var(--primary-bg);
    padding-left: 8px;
}

.node-item:last-child {
    border-bottom: none;
}

.node-item .item-type {
    font-weight: 600;
    color: var(--primary-color);
    margin-right: 8px;
    min-width: 60px;
}

.node-item .item-label {
    color: var(--text-secondary);
    flex: 1;
}

/* Enhanced Modal Overlays */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-dialog {
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 0px;
    min-width: 450px;
    max-width: 550px;
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--border-color);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        transform: translateY(-30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--primary-color);
    padding-bottom: 16px;
    padding-top: 16px;
    border-bottom: 2px solid var(--border-color);
}

.modal-body {
    margin-bottom: 24px;
}

.modal-field {
    margin-bottom: 20px;
}

.modal-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-field input,
.modal-field select,
.modal-field textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-field input:focus,
.modal-field select:focus,
.modal-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
 }

.modal-field select {
    cursor: pointer;
    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='%235B57D1' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-footer button {
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.modal-footer .btn-primary {
    background: var(--primary-color);
    color: white;
}

.modal-footer .btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary);
}

.modal-footer .btn-secondary {
    background: var(--gray-200);
    color: var(--text-primary);
}

.modal-footer .btn-secondary:hover {
    background: var(--gray-300);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Dim backdrop behind the Sidekick chat — shown when the chat is open */
.ai-chat-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1000;
    display: none;
    animation: aiChatBackdropFade 0.25s ease;
}

.ai-chat-backdrop.show {
    display: block;
}

@keyframes aiChatBackdropFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Enhanced AI Chat Window */
.ai-chat-window {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 780px;
    height: 95vh;
    max-height: 90vh;
    max-width: calc(100vw - 48px);
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    z-index: 2500;
    animation: chatSlideUp 0.4s ease-out;
    overflow: hidden;
}

/* While dragging, freeze the slide-up animation so it doesn't fight inline left/top updates */
.ai-chat-window.is-dragging {
    animation: none;
    transition: none;
    user-select: none;
}

@keyframes chatSlideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.ai-chat-header {
    background: var(--primary-color);
    color: white;
    padding: 10px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    cursor: move;
    user-select: none;
}

/* Don't show the move cursor on the close button — it has its own click target */
.ai-chat-header .ai-chat-close {
    cursor: pointer;
}

.ai-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.ai-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-secondary);
}

.ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

.ai-message {
    display: flex;
    margin-bottom: 20px;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message-user {
    flex-direction: row-reverse;
}

.ai-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

.ai-message-bot .ai-message-avatar {
    background: var(--primary-color);
    margin-right: 12px;
}

.ai-message-user .ai-message-avatar {
    background: var(--gray-200);
    margin-left: 12px;
}

.ai-message-content {
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
}

.ai-message-bot .ai-message-content {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}

.ai-message-user .ai-message-content {
    background: var(--primary-color);
    color: #000;
    border-top-right-radius: 4px;
}

/* Light theme — the vivid accent fill (#1a8fe3) reads as a harsh electric-blue
   wall over a long message. Use a soft blue tint with deep-blue text instead,
   mirroring the dark theme's pale-blue user bubble. */
html:not([data-theme="black"]) .ai-message-user .ai-message-content {
    background: #dcecfb;
    color: #0c2a40;
    border: 1px solid #b9d9f6;
    border-top-right-radius: 4px;
}

.ai-message-content ul {
    margin: 12px 0 0 20px;
    padding: 0;
}

.ai-message-content li {
    margin: 6px 0;
}

/* Sidekick intro — tiles shown in the first bot message instead of a plain hello */
.sidekick-intro-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.sidekick-intro-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.sidekick-intro-tiles {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidekick-intro-tile {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.sidekick-intro-tile:hover {
    border-color: var(--primary-color);
    background: var(--primary-bg);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(26, 143, 227, 0.12);
}

.sidekick-intro-tile-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 15px;
    flex-shrink: 0;
}

.sidekick-intro-tile-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.sidekick-intro-tile-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.sidekick-intro-tile-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.ai-chat-input-container {
    padding: 12px 14px 14px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

/* Layer context label shown above textarea when opening from Make Changes */
.ai-chat-layer-context-label {
    width: 100%;
    padding: 8px 14px;
    background: #e8f4fe;
    color: #0d6fc0;
    border: 1px solid #b5d4f4;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 8px;
}

/* Wrapper that holds the textarea + the floating icon column */
.ai-chat-input-wrapper {
    position: relative;
    width: 100%;
}

.ai-chat-input {
    width: 100%;
    padding: 12px 56px 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 14px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    min-height: 167px;
    max-height: 240px;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    box-sizing: border-box;
}

.ai-chat-input:focus {
    border-color: var(--primary-color);
 }

/* Floating icon column at bottom-right of the textarea */
.ai-chat-input-actions {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 2;
}

.ai-chat-icon-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}

.ai-chat-icon-btn:hover {
    background: var(--primary-bg);
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.ai-chat-icon-btn:active {
    transform: translateY(0);
}

.ai-chat-send-icon-btn {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(26, 143, 227, 0.25);
}

.ai-chat-send-icon-btn:hover {
    background: var(--primary-dark);
    color: #ffffff;
    border-color: var(--primary-dark);
}

/* Voice icon button — recording state shows a red pulsing stop button */
.ai-chat-voice-btn.recording {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
    animation: aiChatVoicePulse 1.4s ease-out infinite;
}

.ai-chat-voice-btn.recording:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

@keyframes aiChatVoicePulse {
    0%   { box-shadow: 0 0 0 0    rgba(239, 68, 68, 0.55); }
    70%  { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);    }
    100% { box-shadow: 0 0 0 0    rgba(239, 68, 68, 0);    }
}

/* Attached files chip row above the textarea */
.ai-chat-attached-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0;
}

.ai-chat-attached-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    font-size: 12px;
    color: #1e40af;
    max-width: 240px;
}

.ai-chat-attached-file .file-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.ai-chat-attached-file .file-size {
    opacity: 0.7;
    font-size: 11px;
}

.ai-chat-attached-file .file-remove {
    background: none;
    border: none;
    color: #1e40af;
    cursor: pointer;
    padding: 0;
    font-size: 11px;
    line-height: 1;
    display: flex;
    align-items: center;
}

.ai-chat-attached-file .file-remove:hover {
    color: #ef4444;
}

/* ── Sidekick font scale (+~22%) ──────────────────────────────────────
   Bumps every text element in the chat window ~20-25% without changing
   padding/layout. Scoped under .ai-chat-window so these win on specificity
   over the single-class rules above. Adjust values here to re-scale. */
.ai-chat-window .ai-chat-header h3 { font-size: 18px; }
.ai-chat-window .ai-chat-close { font-size: 22px; }
.ai-chat-window .ai-message-avatar { font-size: 27px; }
.ai-chat-window .ai-message-content { font-size: 17px; }
.ai-chat-window .ai-message-content li { font-size: 17px; }
.ai-chat-window .sidekick-intro-title { font-size: 18px; }
.ai-chat-window .sidekick-intro-subtitle { font-size: 16px; }
.ai-chat-window .sidekick-intro-tile-icon { font-size: 18px; }
.ai-chat-window .sidekick-intro-tile-title { font-size: 16px; }
.ai-chat-window .sidekick-intro-tile-desc { font-size: 15px; }
.ai-chat-window .ai-chat-layer-context-label { font-size: 16px; }
.ai-chat-window .ai-chat-input { font-size: 17px; }
.ai-chat-window .ai-chat-icon-btn { font-size: 17px; }
.ai-chat-window .ai-chat-attached-file { font-size: 15px; }
.ai-chat-window .ai-chat-attached-file .file-size { font-size: 13px; }
.ai-chat-window .ai-chat-attached-file .file-remove { font-size: 13px; }

.ai-typing-indicator {
    display: flex;
    align-items: center;
    padding: 14px;
    background: var(--bg-primary);
    border-radius: 18px;
    border-top-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    width: fit-content;
    border: 1px solid var(--border-color);
}

.ai-typing-indicator span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    margin: 0 3px;
    animation: typing 1.4s infinite;
}

.ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-15px) scale(1.2);
        opacity: 1;
    }
}

/* Save Indicator Enhanced */
.save-indicator {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    animation: slideInRight 0.4s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.save-indicator.saving {
    background: var(--warning-bg);
    color: var(--warning-dark);
    border: 1px solid var(--warning-color);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.2);
}

.save-indicator.success {
    background: var(--success-bg);
    color: var(--success-dark);
    border: 1px solid var(--success-color);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.2);
}

.save-indicator.error {
    background: var(--danger-bg);
    color: var(--danger-dark);
    border: 1px solid var(--danger-color);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.2);
}

/* Custom Scrollbar Styles */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* JSON Output Panel */
#json-output {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 400px;
    height: 200px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    overflow: auto;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    #controls {
        flex-direction: column;
        width: auto;
        max-width: 200px;
    }
    
    .node-form {
        width: 90%;
        left: 5%;
        right: 5%;
    }
    
    .ai-chat-window {
        width: 90%;
        height: 70vh;
        right: 5%;
        bottom: 5%;
    }
}

/* Focus States for Accessibility */
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
     outline-offset: 2px;
}

 

@keyframes gentleFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-3px);
    }
}

/* Loading States */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}


/* Voice Processing Overlay */
/* Voice Processing Overlay */
.voice-processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.voice-processing-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-2xl);
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.voice-processing-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

.voice-processing-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Build Loading Overlay - Similar to Voice Processing */
.build-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.build-loading-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-2xl);
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.build-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--success-color);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

.build-loading-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Build Loading Overlay - Similar to Voice Processing */
.build-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.build-loading-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-2xl);
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.build-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--success-color);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

.build-loading-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Build UI Design Modal Styles */
#build-ui-design-modal .modal-dialog {
    max-width: 600px;
}

#build-ui-design-modal textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
}

#build-ui-design-modal textarea:focus {
    outline: none;
    border-color: #0d6fc0;
    box-shadow: 0 0 0 3px rgba(13, 111, 192, 0.1);
}

#build-ui-design-modal textarea::placeholder {
    color: var(--gray-400);
    line-height: 1.6;
}

#build-ui-design-modal .btn-primary {
    background: #0d6fc0;
    display: flex;
    align-items: center;
    gap: 8px;
}

#build-ui-design-modal .btn-primary:hover {
    background: #0d6fc0;
}

/* Theme Selection Button Styles */
#select-theme-btn:hover {
    border-color: #0d6fc0 !important;
    background: #f9fafb !important;
}

/* Theme Selection Modal Styles */
#theme-selection-modal .modal-dialog {
    max-width: 1400px;
    width: 95%;
}

#theme-selection-modal .modal-body {
    max-height: calc(90vh - 140px);
    overflow-y: auto;
}

#theme-selection-modal #theme-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

#theme-selection-modal .theme-card {
    transition: all 0.2s ease;
}

#theme-selection-modal .theme-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

@media (max-width: 1200px) {
    #theme-selection-modal #theme-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    #theme-selection-modal #theme-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    #theme-selection-modal #theme-grid {
        grid-template-columns: 1fr;
    }
}

/* Theme Demo Modal Styles */
#theme-demo-modal .modal-body {
    max-height: calc(90vh - 140px);
}

#theme-demo-modal input:focus,
#theme-demo-modal textarea:focus {
    outline: none;
}

#theme-demo-modal table {
    font-size: 14px;
}

#theme-demo-modal button:hover {
    opacity: 0.9;
}

/* Build UI Design Button Styles */
#build-ui-design-btn {
    background: #0d6fc0;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

#build-ui-design-btn:hover {
    background: #0d6fc0;
}

/* Build Presentation Button Styles */
#build-presentation-btn {
    background: #1a8fe3;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

#build-presentation-btn:hover {
    background: #1a8fe3;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(26, 143, 227, 0.4);
}

#build-presentation-btn:disabled {
    cursor: not-allowed;
    transform: none;
}

#build-presentation-btn .fa-spinner {
    animation: spin 1s linear infinite;
}

/* Documents Button Styles */
#documents-btn {
    background: #059669;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

#documents-btn:hover {
    background: #047857;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(5, 150, 105, 0.4);
}

/* Documents Modal Specific Styles */
#documents-modal .modal-dialog {
    animation: modalSlide 0.3s ease-out;
}

#documents-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#documents-modal .document-item {
    transition: all 0.2s ease;
}

#documents-modal .document-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#documents-modal .doc-btn {
    transition: all 0.2s ease;
    margin-left: 8px;
}

#documents-modal .doc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Document Success Modal */
#document-success-modal .modal-dialog {
    animation: modalSlide 0.3s ease-out;
}

#document-success-modal button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Analyze Requirements Button Styles */
#analyze-requirements-btn {
    background: #4A90E2;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

#analyze-requirements-btn:hover {
    background: #357ABD;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(74, 144, 226, 0.3);
}

/* Requirements Analyzer Modal Styles - Unique Classes */
.req-analyzer-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.req-analyzer-modal-dialog {
    background: var(--bg-primary);
    border-radius: 20px;
    max-width: 1200px;
    width: 92%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--border-color);
    animation: modalSlide 0.3s ease-out;
}

.req-analyzer-modal-header {
    background: linear-gradient(135deg, #4A90E2 0%, #3a6fb0 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.req-analyzer-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.req-analyzer-header-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.req-analyzer-header-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.req-analyzer-modal-title {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.req-analyzer-modal-subtitle {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.85;
    margin-top: 1px;
}

.req-analyzer-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.req-analyzer-close-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

.req-analyzer-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.req-analyzer-modal-body::-webkit-scrollbar {
    width: 8px;
}

.req-analyzer-modal-body::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 4px;
}

.req-analyzer-modal-body::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

.req-analyzer-modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

.req-analyzer-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
    background: var(--bg-primary);
    border-radius: 0 0 20px 20px;
}

.req-analyzer-section {
    display: block;
}

.req-analyzer-field {
    margin-bottom: 20px;
}

.req-analyzer-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.req-analyzer-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
}

.req-analyzer-textarea:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.req-analyzer-actions {
    margin-top: 20px;
    text-align: right;
}

.req-analyzer-btn {
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.req-analyzer-btn-primary {
    background: #4A90E2;
    color: white;
}

.req-analyzer-btn-primary:hover {
    background: #357ABD;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(74, 144, 226, 0.3);
}

.req-analyzer-btn-secondary {
    background: var(--gray-200);
    color: var(--text-primary);
}

.req-analyzer-btn-secondary:hover {
    background: var(--gray-300);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.req-analyzer-btn-success {
    background: #10B981;
    color: white;
}

.req-analyzer-btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.3);
}

.req-analyzer-current-req {
    background: #F9FAFB;
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #4A90E2;
}

.req-analyzer-subtitle {
    margin: 0 0 8px 0;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
}

.req-analyzer-text {
    color: #6B7280;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.req-analyzer-round-header {
    margin-bottom: 16px;
}

.req-analyzer-questions-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.req-analyzer-info-footer {
    padding: 12px 0;
    border-top: 1px solid var(--border-color);
}

.req-analyzer-info-text {
    color: #6B7280;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.req-analyzer-success-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.req-analyzer-success-icon {
    background: #10B981;
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 13px;
    flex: 0 0 auto;
}

.req-analyzer-success-title {
    margin: 0;
    color: #059669;
    font-size: 16px;
    font-weight: 700;
}

.req-analyzer-success-subtitle {
    color: #6B7280;
    font-size: 13px;
    margin: 0;
}

.req-analyzer-final-req {
    background: #F9FAFB;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #10B981;
}

/* Question Item Styles for Requirements Analyzer */
.question-item {
    background: #F9FAFB;
    padding: 16px;
    border-radius: 10px;
    border-left: 4px solid #4A90E2;
}

.question-item h5 {
    margin: 0 0 12px 0;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
}

.question-item input[type="text"],
.question-item input[type="number"],
.question-item select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
    color: #374151;
}

.question-item input:focus,
.question-item select:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.question-item textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    transition: all 0.2s ease;
    background: white;
    color: #374151;
    line-height: 1.5;
}

.question-item textarea:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.ai-decide-checkbox {
    display: flex;
    align-items: center;
    margin-top: 12px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid #E5E7EB;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-decide-checkbox:hover {
    border-color: #4A90E2;
    background: #F0F7FF;
}

.ai-decide-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

.ai-decide-checkbox label {
    margin: 0;
    cursor: pointer;
    color: #4A90E2;
    font-size: 13px;
    font-weight: 500;
}

.multiselect-container {
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    background: white;
    padding: 8px;
    overflow-y: auto;
}

.multiselect-option {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.multiselect-option:hover {
    background: #F9FAFB;
}

.multiselect-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    cursor: pointer;
}

.multiselect-option label {
    margin: 0;
    cursor: pointer;
    color: #374151;
    font-size: 14px;
}

/* ── Clarification option tiles (single + multi select) ──────────────── */
.req-select-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 12px;
}
.req-select-mode-badge.single { background: #EEF4FF; color: #2563EB; }
.req-select-mode-badge.multi  { background: #ECFDF5; color: #059669; }

.option-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    /* Reset the old multiselect-container chrome when reused on the grid */
    border: none;
    background: transparent;
    padding: 0;
}

.option-tile {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 14px;
    background: white;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.18s ease;
    position: relative;
    user-select: none;
    margin: 0;
}
.option-tile:hover {
    border-color: #4A90E2;
    background: #F5F9FF;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.12);
}
.option-tile:focus-visible {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.18);
}

.option-tile-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.option-tile-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: #EEF4FF;
    color: #4A90E2;
    font-size: 15px;
    transition: all 0.18s ease;
}

.option-tile-label {
    flex: 1;
    font-size: 13.5px;
    font-weight: 500;
    color: #374151;
    line-height: 1.3;
}

.option-tile-check {
    flex-shrink: 0;
    color: #4A90E2;
    font-size: 17px;
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.18s ease;
}

.option-tile.selected {
    border-color: #4A90E2;
    background: #EEF4FF;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.12);
}
.option-tile.selected .option-tile-icon { background: #4A90E2; color: white; }
.option-tile.selected .option-tile-check { opacity: 1; transform: scale(1); }

.option-tile-grid.disabled,
.option-tile.disabled {
    opacity: 0.45;
    pointer-events: none;
    filter: grayscale(0.3);
}

/* ── Tile toolbar: check all / uncheck all / add new item ─────────────── */
.req-tile-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.req-tile-toolbar button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    padding: 7px 13px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.16s ease;
    border: 1px solid #E5E7EB;
    background: #F9FAFB;
    color: #374151;
}
.req-tile-toolbar button:hover {
    border-color: #4A90E2;
    color: #2563EB;
    background: #F5F9FF;
}
.req-tile-toolbar button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.req-tile-add-btn {
    border-style: dashed !important;
    border-color: #4A90E2 !important;
    color: #2563EB !important;
    background: #EEF4FF !important;
}
.req-tile-add-btn:hover {
    background: #DCE9FF !important;
}

/* ── Add custom option dialog ─────────────────────────────────────────── */
.req-add-item-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: reqAddFade 0.15s ease;
}
@keyframes reqAddFade { from { opacity: 0; } to { opacity: 1; } }
.req-add-item-dialog {
    background: white;
    width: min(440px, calc(100vw - 40px));
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    animation: reqAddPop 0.18s ease;
}
@keyframes reqAddPop {
    from { transform: translateY(8px) scale(0.98); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}
.req-add-item-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}
.req-add-item-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #EEF4FF;
    color: #4A90E2;
    font-size: 16px;
}
.req-add-item-head h4 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #111827;
}
.req-add-item-sub {
    margin: 0 0 16px;
    font-size: 13px;
    color: #6B7280;
    line-height: 1.45;
}
.req-add-item-input {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 13px;
    border: 2px solid #E5E7EB;
    border-radius: 10px;
    font-size: 14px;
    color: #374151;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.req-add-item-input:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.18);
}
.req-add-item-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}
.req-add-item-actions button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.16s ease;
    border: 1px solid transparent;
}
.req-add-item-cancel {
    background: #F3F4F6;
    color: #374151;
    border-color: #E5E7EB;
}
.req-add-item-cancel:hover { background: #E5E7EB; }
.req-add-item-confirm {
    background: #4A90E2;
    color: white;
}
.req-add-item-confirm:hover { background: #2563EB; }

/* Requirements Layer Styles */
#layer-requirements .requirements-textarea {
    width: 100%;
    height: 100%;
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.2s ease;
}

#layer-requirements .requirements-textarea:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Voice Transcript Overlay - Bottom Right */
#voice-transcript {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    max-width: 400px;
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
    z-index: 9999;
    display: none;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-2xl);
    animation: fadeInRight 0.3s ease;
}

#voice-transcript.show {
    display: block;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#voice-transcript::-webkit-scrollbar {
    width: 4px;
}

#voice-transcript::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

#voice-transcript::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

#voice-transcript::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Quickstart Modal Styles */
.quickstart-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(4px);
}

.quickstart-modal-overlay.show {
    display: flex;
}

.quickstart-modal-dialog {
    background: var(--bg-primary);
    border-radius: 24px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    animation: quickstartSlide 0.4s ease-out;
    overflow: hidden;
}

@keyframes quickstartSlide {
    from {
        transform: translateY(-40px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.quickstart-modal-header {
    padding: 32px 32px 24px 32px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.quickstart-header-icon {
    width: 64px;
    height: 64px;
    background: #1a8fe3;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px auto;
    font-size: 28px;
    color: white;
    box-shadow: 0 8px 24px rgba(26, 143, 227, 0.3);
}

.quickstart-title {
    margin: 0 0 8px 0;
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.quickstart-subtitle {
    margin: 0;
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.quickstart-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.quickstart-tiles {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quickstart-tile {
    display: flex;
    align-items: center;
    padding: 20px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    gap: 16px;
}

.quickstart-tile:hover {
    border-color: #1a8fe3;
    background: var(--primary-bg);
    transform: translateX(4px);
    box-shadow: 0 8px 24px rgba(26, 143, 227, 0.12);
}

.quickstart-tile:active {
    transform: translateX(2px);
}

.quickstart-tile-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.quickstart-tile-content {
    flex: 1;
}

.quickstart-tile-content h3 {
    margin: 0 0 6px 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.quickstart-tile-content p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.quickstart-tile-arrow {
    color: var(--gray-400);
    font-size: 16px;
    transition: all 0.25s ease;
}

.quickstart-tile:hover .quickstart-tile-arrow {
    color: #1a8fe3;
    transform: translateX(4px);
}

.quickstart-modal-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    background: var(--bg-secondary);
}

.quickstart-skip-btn {
    padding: 12px 28px;
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quickstart-skip-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--text-primary);
}

.quickstart-modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* Responsive for quickstart modal */
@media (max-width: 600px) {
    .quickstart-modal-dialog {
        width: 95%;
        max-height: 95vh;
    }
    
    .quickstart-modal-header {
        padding: 24px 20px 20px 20px;
    }
    
    .quickstart-header-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
    
    .quickstart-title {
        font-size: 22px;
    }
    
    .quickstart-modal-body {
        padding: 16px;
    }
    
    .quickstart-tile {
        padding: 16px;
    }
    
    .quickstart-tile-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .quickstart-tile-content h3 {
        font-size: 15px;
    }
    
    .quickstart-tile-content p {
        font-size: 12px;
    }
}

/* Success Details Modal Styles */
#success-details-modal .modal-dialog {
    animation: modalSlide 0.3s ease-out;
}

#success-details-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
}

#success-details-modal .modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: rotate(90deg);
}

#success-details-modal .modal-body h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}

#success-details-modal .modal-body h4 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: 16px;
}

#success-details-modal .modal-body ul {
    list-style-type: none;
    padding-left: 0;
}

#success-details-modal .modal-body ul li {
    padding: 6px 0;
    padding-left: 24px;
    position: relative;
}

#success-details-modal .modal-body ul li::before {
    content: '▪';
    position: absolute;
    left: 8px;
    color: var(--success-color);
    font-weight: bold;
}

#success-details-modal .modal-body p {
    margin: 8px 0;
    line-height: 1.6;
}


/* Branding Logo */
.branding-logo {
    position: fixed;
    bottom: 15px;
    right: 20px;
    max-height: 52px;
    width: auto;
    z-index: 900;
    pointer-events: none;
    opacity: 0.9;
    z-index: 1; 
}

/* Floating Assistant Button - Top Right */
.floating-chat-button {
    position: fixed;
    top: 5px;
    width: 60px;
    height: 36px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 7px 8px;
    background: #ffffff;
    color: #1a8fe3;
    border: 2px solid #1a8fe3;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 2px 12px rgba(26, 143, 227, 0.15);
    transition: all 0.25s ease;
    user-select: none;
}

.floating-chat-button:hover {
    background: #1a8fe3;
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(26, 143, 227, 0.3);
    transform: translateY(-1px);
}

.floating-chat-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(26, 143, 227, 0.2);
}

.floating-chat-button.active {
    background: #1a8fe3;
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(26, 143, 227, 0.3);
}

.floating-chat-button i {
    font-size: 15px;
}

.floating-chat-button .assistant-label {
    letter-spacing: 0.3px;
}


/* Context Menu Styles */
.context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    padding: 6px 0;
    min-width: 220px;
    animation: fadeIn 0.15s ease-out;
}

.context-menu-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.1s ease;
}

.context-menu-item:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
}

.context-menu-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}
/* =============================================================================
   LAYER TABS BAR
   ============================================================================= */

#layer-tabs-bar {
    position: relative;
    z-index: 999;
    display: flex;
    gap: 4px;
    border-radius: 14px;
    animation: slideDown 0.4s ease-out;
    margin-left: auto;
    padding-left: 10px;
    border-left: 0.5px solid #e0e3e8;
}

.layer-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    background: transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
    position: relative;
}

.layer-tab:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.layer-tab.active {
    background: var(--primary-color);
    color: white;
    box-shadow: none;
}

.layer-tab.active:hover {
    background: var(--primary-dark);
    color: white;
}

.layer-tab i {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.layer-tab-label {
    display: inline;
}

.layer-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
    line-height: 1;
}

.layer-tab.active .layer-tab-count {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

@media (max-width: 1800px) {
    .layer-tab-label { display: none; }
    .layer-tab { padding: 8px 10px; }
    #layer-tabs-bar { gap: 2px; }
}

@media (max-width: 1200px) {
    .layer-tab { padding: 8px 8px; }
    #layer-tabs-bar { gap: 1px; }
}

/* =============================================================================
   LAYER CONTAINERS (shared)
   ============================================================================= */

.layer-container {
    position: absolute;
    left: 0; top: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    background: var(--bg-primary);
}

/* non-cy layers get flex column layout */
#layer-requirements,
#layer-concept-summary,
#layer-business-flows,
#layer-data-objects,
#layer-roles,
#layer-integrations,
#layer-business-rules,
#layer-api-endpoints,
#layer-state-machines,
#layer-events-jobs,
#layer-environment {
    display: none;
    flex-direction: column;
}

/* =============================================================================
   LAYER TOOLBAR (inside each layer)
   ============================================================================= */

.layer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 10;
    /* margin-top: 76px removed — it reserved space for the old #controls
       toolbar, which no longer exists, and left an empty strip under the
       topbar. Layers now start flush at the top. */
}

/* UI Screens (Concept) toolbar: sibling of the #cy cytoscape container,
   pinned across the top; the canvas starts below it. */
.ui-screens-toolbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 59px;
    box-sizing: border-box;
    z-index: 15;
}
#cy.layer-container { top: 59px; }
#conceptMain.has-side-list .ui-screens-toolbar { left: 290px; }

.layer-toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.layer-toolbar-left h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.layer-toolbar-left h3 i {
    font-size: 18px;
    color: var(--primary-color);
}

.layer-toolbar-hint {
    font-size: 12px;
    color: var(--gray-400);
    font-style: italic;
}

.layer-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.layer-toolbar-right select {
    padding: 7px 14px;
    border: 0.5px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-primary);
    cursor: pointer;
    color: var(--text-primary);
}

.layer-toolbar-btn {
    padding: 7px 15px;
    border: 0.5px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.layer-toolbar-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

.layer-toolbar-btn.btn-add {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.layer-toolbar-btn.btn-add:hover {
    background: var(--success-dark);
    border-color: var(--success-dark);
}

/* View toggle (cards / matrix / graph) */
.layer-view-toggle {
    display: flex;
    border: 0.5px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
}

.layer-view-btn {
    padding: 7px 14px;
    border: none;
    background: var(--bg-primary);
    color: var(--gray-500);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.layer-view-btn:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.layer-view-btn.active {
    background: var(--primary-color);
    color: white;
}

.layer-view-btn:hover:not(.active) {
    background: var(--gray-100);
}

/* =============================================================================
   LAYER CANVAS (cytoscape containers inside layers)
   ============================================================================= */

.layer-canvas {
    flex: 1;
    width: 100%;
    min-height: 0;
    position: relative;
}

/* =============================================================================
   LAYER SIDE LIST  (left object list between the sidebar menu and the canvas)
   Shown for every diagram layer (blocks, flows, data objects, roles,
   integrations, rules). `top` is set in JS to clear the #controls toolbar.
   ============================================================================= */
.layer-side-list {
    position: absolute;
    left: 0;
    top: 0;            /* JS overrides to #controls height */
    bottom: 0;
    width: 290px;
    background: var(--bg-primary, #fff);
    border-right: 1px solid var(--border-color, #e0e3e8);
    z-index: 30;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.03);
}

/* Shift the canvases right to make room for the side list */
#conceptMain.has-side-list #cy,
#conceptMain.has-side-list #layer-concept-summary,
#conceptMain.has-side-list #layer-business-flows,
#conceptMain.has-side-list #layer-data-objects,
#conceptMain.has-side-list #layer-roles,
#conceptMain.has-side-list #layer-integrations,
#conceptMain.has-side-list #layer-business-rules,
#conceptMain.has-side-list #layer-api-endpoints,
#conceptMain.has-side-list #layer-state-machines,
#conceptMain.has-side-list #layer-events-jobs,
#conceptMain.has-side-list #layer-environment {
    left: 290px;
    width: auto;   /* let left+right anchors size it; 100% would overflow off-screen */
}

.layer-side-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color, #e0e3e8);
    flex-shrink: 0;
}
.layer-side-list-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}
.layer-side-list-title i { color: var(--primary-color, #1a8fe3); }
.layer-side-list-count {
    background: #eef2f7;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 11px;
}

.layer-side-list-search {
    position: relative;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color, #eef0f3);
    flex-shrink: 0;
}
/* Direct child only — otherwise this also grabs the <i> icons inside the
   global-search results dropdown (which now lives in this container) and
   absolutely-positions them into the corner, hiding them. */
.layer-side-list-search > i {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 12px;
    pointer-events: none;
}
.layer-side-list-search input {
    width: 100%;
    padding: 8px 12px 8px 30px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    background: #f8fafc;
    box-sizing: border-box;
}
.layer-side-list-search input:focus {
    outline: none;
    border-color: var(--primary-color, #1a8fe3);
    background: #fff;
}

/* The global object search reuses this slot — strip its pill styling so it
   looks identical to the old filter (compact, 8px radius). */
.layer-side-list-search .object-search-input {
    width: 100%;
    min-height: 0;
    padding: 8px 30px 8px 30px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    background: #f8fafc;
    font-size: 13px;
    box-sizing: border-box;
}
.layer-side-list-search .object-search-input:focus {
    outline: none;
    border-color: var(--primary-color, #1a8fe3);
    background: #fff;
}
.layer-side-list-search .object-search-clear {
    top: 50%;
    transform: translateY(-50%);
}

.layer-side-list-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.layer-side-item-wrap { margin-bottom: 3px; }
.layer-side-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s;
}
.layer-side-item:hover { background: #f4f8fe; }

/* Expand / collapse twisty */
.layer-side-twisty {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    background: none;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.layer-side-twisty:hover { background: #e2e8f0; color: #475569; }
.layer-side-twisty i { font-size: 10px; transition: transform 0.15s ease; }
.layer-side-twisty.open i { transform: rotate(90deg); }
.layer-side-twisty-spacer { flex-shrink: 0; width: 18px; }

.layer-side-childcount {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 1px 7px;
    border-radius: 9px;
}

/* Nested inner-element rows */
.layer-side-children { padding: 2px 0 4px 0; }
.layer-side-child {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px 5px 10px;
    margin-left: 26px;
    border-left: 2px solid #eef2f7;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.layer-side-child:hover { background: #f4f8fe; border-left-color: var(--primary-color, #1a8fe3); }
.layer-side-child-icon {
    width: 14px;
    flex-shrink: 0;
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
}
.layer-side-child-label {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.layer-side-child-sub {
    flex-shrink: 0;
    font-size: 10px;
    color: #a3aab5;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 6px;
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.layer-side-item.active {
    background: #e8f4fe;
    border-color: var(--primary-color, #1a8fe3);
}
.layer-side-item-icon {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef2f7;
    color: var(--primary-color, #1a8fe3);
    font-size: 13px;
}
.layer-side-item-info { min-width: 0; flex: 1; cursor: pointer; }
.layer-side-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.layer-side-item-meta {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.layer-side-list-empty {
    padding: 30px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}
.layer-side-list-empty i {
    display: block;
    font-size: 30px;
    color: #cbd5e1;
    margin-bottom: 10px;
}

@media (max-width: 900px) {
    .layer-side-list { width: 210px; }
    #conceptMain.has-side-list #cy,
    #conceptMain.has-side-list #layer-concept-summary,
    #conceptMain.has-side-list #layer-business-flows,
    #conceptMain.has-side-list #layer-data-objects,
    #conceptMain.has-side-list #layer-roles,
    #conceptMain.has-side-list #layer-integrations,
    #conceptMain.has-side-list #layer-business-rules,
    #conceptMain.has-side-list #layer-api-endpoints,
    #conceptMain.has-side-list #layer-state-machines,
    #conceptMain.has-side-list #layer-events-jobs,
    #conceptMain.has-side-list #layer-environment {
        left: 210px;
        width: auto;
    }
}

/* =============================================================================
   LAYER SCROLL CONTENT (for Roles, Integrations, Rules)
   ============================================================================= */

.layer-scroll-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-secondary);
}

/* (Removed the 92px roles top-clearance: Roles has a real .layer-toolbar
   again, so its scroll content starts right below it like every layer.) */

/* =============================================================================
   LAYER DETAIL PANEL (slide-in for flows & data objects)
   ============================================================================= */


.layer-detail-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 400px;
    max-width: 90vw;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
    z-index: 20;
    display: none;
    flex-direction: column;
    animation: slideInFromRight 0.25s ease-out;
    overflow: hidden;
    z-index: 99999;
}

@keyframes slideInFromRight {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.detail-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.detail-panel-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.detail-panel-close {
    background: var(--gray-200);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    color: var(--gray-600);
}

.detail-panel-close:hover {
    background: var(--gray-300);
}

.detail-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section > label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    color: var(--gray-400);
    margin-bottom: 6px;
}

.detail-section > p {
    margin: 0;
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

.detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.detail-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background: var(--primary-bg);
    color: var(--primary-color);
}

.detail-steps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-step-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.detail-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.detail-fields-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.detail-fields-table th {
    text-align: left;
    padding: 8px 10px;
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 2px solid var(--border-color);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-fields-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* =============================================================================
   CROSS-REFERENCE BADGES
   ============================================================================= */

.cross-ref-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    white-space: nowrap;
}

.cross-ref-badge:hover {
    background: var(--primary-bg);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.cross-ref-badge i {
    font-size: 10px;
}

/* =============================================================================
   CROSS-REFERENCE TOAST
   ============================================================================= */

.cross-ref-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--gray-800);
    color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    font-size: 13px;
    font-weight: 600;
    animation: toastSlideUp 0.25s ease-out;
}

@keyframes toastSlideUp {
    from { transform: translateX(-50%) translateY(30px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.cross-ref-toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary-color);
    color: white;
    font-size: 12px;
}

.cross-ref-toast-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.cross-ref-toast-close:hover {
    background: rgba(255,255,255,0.25);
}

/* =============================================================================
   LAYER EMPTY STATE
   ============================================================================= */

.layer-empty-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    z-index: 5;
}

.layer-empty-state {
    text-align: center;
    padding: 40px;
    color: var(--gray-400);
}

.layer-empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    opacity: 0.5;
}

.layer-empty-state h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-500);
}

.layer-empty-state p {
    margin: 0;
    font-size: 14px;
}

/* In grid-based card containers (roles, integrations) the lone empty-state
   would otherwise sit in the first column on the left — span all columns so
   it centers like the flex-based containers (data objects, business rules). */
.roles-cards-container .layer-empty-state,
.integrations-cards-container .layer-empty-state {
    grid-column: 1 / -1;
}

/* =============================================================================
   LAYER 2: BUSINESS FLOWS — Cytoscape node HTML
   ============================================================================= */

.cy-flow-node {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    width: 281px;
    height: 131px;
    overflow: auto;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
    pointer-events: all;
}

.cy-flow-node:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.flow-node-main {
    border-left: 4px solid #1a8fe3;
    height: 200px;
}

.flow-node-main::before {
    content: '';
    display: block;
    height: 3px;
    background: linear-gradient(90deg, #1a8fe3, #5cb3ef);
    border-radius: 3px;
    margin-bottom: 10px;
}

.flow-node-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.flow-node-header i {
    color: #1a8fe3;
    font-size: 14px;
}

.flow-node-meta {
    font-size: 11px;
    color: var(--gray-400);
    margin-bottom: 6px;
}

.flow-node-desc {
    font-size: 12px;
    color: var(--gray-500);
    line-height: 1.4;
    margin-bottom: 8px;
}

.flow-node-actors {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.flow-actor-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    background: #ede9fe;
    color: #1a8fe3;
}

/* Step nodes */
.flow-node-step {
    border-left: 4px solid #22d3ee;
 }

.flow-step-end {
    border-left-color: #10b981;
}

.flow-step-header {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.flow-step-header i {
    color: #22d3ee;
    font-size: 12px;
}

.flow-step-type {
    font-size: 11px;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.flow-step-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

/* =============================================================================
   LAYER 3: DATA OBJECTS — Cytoscape node HTML (ER-diagram style)
   ============================================================================= */

.cy-data-node {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    width: 260px;
    height: 402px;
    overflow: auto;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
    pointer-events: all;
}

.cy-data-node:hover {
    box-shadow: var(--shadow-lg);
    border-color: #10b981;
}

.data-node-header {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-node-header i {
    font-size: 14px;
}

.data-node-table {
    padding: 4px 14px;
    font-size: 11px;
    color: var(--gray-400);
    background: var(--gray-50);
    border-bottom: 1px solid var(--border-color);
    font-family: 'IBM Plex Mono', monospace;
}

.data-node-fields {
    padding: 6px 0;
}

.data-field-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    font-size: 12px;
    border-bottom: 1px solid var(--gray-100);
}

.data-field-row:last-child {
    border-bottom: none;
}

.data-field-name {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-field-type {
    font-size: 10px;
    color: var(--gray-400);
    font-family: 'IBM Plex Mono', monospace;
    padding: 1px 6px;
    background: var(--gray-100);
    border-radius: 4px;
    flex-shrink: 0;
}

.field-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.field-badge.pk  { background: #fef3c7; color: #d97706; }
.field-badge.req { background: #fee2e2; color: #dc2626; }
.field-badge.uniq { background: #d7ecfb; color: #0d6fc0; }
.field-badge.idx  { background: #d1fae5; color: #059669; }

.data-field-more {
    color: var(--gray-400);
    font-style: italic;
    font-size: 11px;
}

.data-field-empty {
    color: var(--gray-400);
    font-style: italic;
    font-size: 11px;
}

.data-node-rels {
    padding: 6px 10px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-top: 1px solid var(--border-color);
}

/* =============================================================================
   LAYER 4: ROLES — Cards & Matrix
   ============================================================================= */

.roles-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.role-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.role-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.role-card-system {
    border-left: 4px solid #f59e0b;
}

.role-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.role-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary-bg);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.role-card-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.role-level {
    font-size: 11px;
    color: var(--gray-400);
    margin-left: 8px;
}

.role-system-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: #fef3c7;
    color: #d97706;
    margin-left: 8px;
}

.role-card-desc {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.5;
    margin-bottom: 12px;
}

.role-card-section {
    margin-bottom: 10px;
}

.role-card-section > label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    color: var(--gray-400);
    margin-bottom: 6px;
}

.role-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.access-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.15s;
}

.access-badge:hover {
    background: var(--primary-bg);
    color: var(--primary-color);
}

.access-badge.access-full  { background: #d1fae5; color: #059669; }
.access-badge.access-read_only { background: #dbeafe; color: #2563eb; }
.access-badge.access-hidden { background: #fee2e2; color: #dc2626; }

.no-access {
    font-size: 12px;
    color: var(--gray-400);
    font-style: italic;
}

.perm-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: #fef3c7;
    color: #d97706;
}

/* Roles Matrix */
.roles-matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: var(--bg-primary);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.roles-matrix-table th {
    padding: 10px 14px;
    background: var(--gray-100);
    font-weight: 700;
    color: var(--gray-600);
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    font-size: 12px;
}

.roles-matrix-table th:first-child {
    text-align: left;
}

.roles-matrix-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    font-size: 16px;
}

.roles-matrix-table td:first-child {
    text-align: left;
    font-size: 13px;
}

.matrix-cell.matrix-full    { background: #ecfdf5; }
.matrix-cell.matrix-read_only { background: #eff6ff; }
.matrix-cell.matrix-hidden  { background: #fef2f2; }

/* =============================================================================
   LAYER 5: INTEGRATIONS — Cards
   ============================================================================= */

/* =============================================================================
   INTEGRATIONS GRAPH VIEW (integrations on the left → screens on the right)
   rendered by renderIntegrationsGraph(). Sharp corners — no border radius.
   ============================================================================= */
#integrations-graph-view {
    height: calc(100vh - 210px);
    min-height: 480px;
}
#cy-integrations {
    width: 100%;
    height: 100%;
    border-radius: 0;
    background:
        radial-gradient(circle at 1px 1px, rgba(100,116,139,0.18) 1px, transparent 0) 0 0 / 22px 22px,
        linear-gradient(180deg, #fbfcfe 0%, #f4f7fb 100%);
}

/* Integration node (left column) */
.ig-node {
    width: 210px;
    height: 96px;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid #e5e8ef;
    border-left: 4px solid #6366f1;
    border-radius: 0;
    padding: 11px 13px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.ig-node:hover {
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
    transform: translateY(-2px);
}
.ig-node-top {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ig-node-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
}
.ig-node-titles { min-width: 0; }
.ig-node-name {
    font-size: 13.5px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ig-node-provider {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ig-node-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ig-node-status {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: capitalize;
    padding: 2px 9px;
    border-radius: 0;
}
.ig-node-caps {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Screen node (right column) with its available methods */
.ig-screen {
    width: 200px;
    height: 76px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 10px 13px;
    background: #fff;
    border: 1px solid #dbe3ef;
    border-right: 4px solid #0ea5e9;
    border-radius: 0;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.ig-screen:hover {
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
    transform: translateY(-2px);
}
.ig-screen-top {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    min-width: 0;
}
.ig-screen-top i { color: #0ea5e9; font-size: 13px; flex-shrink: 0; }
.ig-screen-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ig-screen-methods {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.ig-method {
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.3px;
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 0;
}
.ig-screen-nomethods {
    font-size: 10.5px;
    color: #94a3b8;
    font-style: italic;
    font-weight: 500;
}

.integrations-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.integ-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.integ-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.integ-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.integ-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.integ-card-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.integ-provider {
    font-size: 12px;
    color: var(--gray-400);
    display: block;
    margin-top: 2px;
}

.integ-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: var(--gray-100);
    color: var(--gray-600);
    text-transform: uppercase;
    margin-right: 4px;
}

.integ-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.integ-status-required { background: #fee2e2; color: #dc2626; }
.integ-status-optional { background: #fef3c7; color: #d97706; }
.integ-status-planned  { background: var(--gray-100); color: var(--gray-500); }

.integ-card-desc {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.5;
    margin-bottom: 12px;
}

.integ-card-section {
    margin-bottom: 10px;
}

.integ-card-section > label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    color: var(--gray-400);
    margin-bottom: 6px;
}

.integ-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.integ-cap {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.integ-cap-method {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
    background: #dbeafe;
    color: #2563eb;
}

/* =============================================================================
   LAYER 6: BUSINESS RULES — List
   ============================================================================= */

.rules-list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* =========================================================================
   Layers 8–11 shared card grid (API Endpoints, State & Lifecycle,
   Events & Jobs, Environment & Config). Mirrors the rule-card look.
   ========================================================================= */
.concept-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
    padding: 4px;
}
.concept-card-grid .layer-empty-state {
    grid-column: 1 / -1;
}
.concept-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.concept-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    transform: translateY(-2px);
}
.concept-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.concept-card-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex: 0 0 auto;
}
.concept-card-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1 1 auto;
}
.concept-card-desc {
    margin: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.concept-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 0;
}
.concept-card-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}
.concept-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-secondary, #4b5563);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Layer 8 — API Endpoints */
.api-method-badge {
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.4px;
    padding: 3px 9px;
    border-radius: 6px;
    flex: 0 0 auto;
}
.api-path {
    font-family: 'Roboto Mono', ui-monospace, monospace;
    font-size: 12.5px;
    color: var(--text-primary);
    background: var(--bg-secondary, #f3f4f6);
    padding: 2px 8px;
    border-radius: 6px;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}

/* Layer 9 — State & Lifecycle */
.sm-states {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 4px;
}
.sm-state-pill {
    border: 1.5px solid #9333ea;
    color: #9333ea;
    background: transparent;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
}
.sm-transitions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}
.sm-transition {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.sm-transition .sm-from, .sm-transition .sm-to {
    font-weight: 700;
    color: var(--text-primary);
}
.sm-transition .fa-arrow-right { color: #9333ea; font-size: 10px; }
.sm-trans-name {
    font-style: italic;
    color: #6b7280;
}

/* Layer 10 — Events & Jobs */
.evt-trigger {
    margin: 6px 0;
    font-size: 12px;
    color: var(--text-secondary);
}
.evt-trigger code, .evt-action {
    font-size: 12.5px;
}
.evt-trigger code {
    font-family: 'Roboto Mono', ui-monospace, monospace;
    background: var(--bg-secondary, #f3f4f6);
    padding: 2px 8px;
    border-radius: 6px;
    color: var(--text-primary);
}
.evt-action {
    margin: 6px 0;
    font-size: 12.5px;
    color: var(--text-secondary);
}

/* Layer 11 — Environment & Config */
.env-key {
    font-family: 'Roboto Mono', ui-monospace, monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}

.rule-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.rule-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(2px);
}

.rule-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.rule-severity {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.rule-card-title h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.rule-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.rule-cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: var(--gray-100);
    color: var(--gray-600);
    text-transform: uppercase;
}

.rule-sev-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.rule-sev-error   { background: #fee2e2; color: #dc2626; }
.rule-sev-warning { background: #fef3c7; color: #d97706; }
.rule-sev-info    { background: #dbeafe; color: #2563eb; }

.rule-inactive-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: var(--gray-200);
    color: var(--gray-500);
    text-transform: uppercase;
}

.rule-card-desc {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.5;
    margin-bottom: 8px;
}

.rule-expression {
    padding: 8px 12px;
    background: var(--gray-800);
    border-radius: 8px;
    margin-bottom: 10px;
}

.rule-expression code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: #a5f3fc;
    word-break: break-all;
}

.rule-card-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.rule-violation {
    font-size: 12px;
    color: var(--gray-500);
    padding: 8px 12px;
    background: #EEE;
    border-radius: 6px;
    border-left: 3px solid blue;
}

/* =============================================================================
   RESPONSIVE for Layer Tabs
   ============================================================================= */

@media (max-width: 768px) {
    #layer-tabs-bar {
        top: auto;
        bottom: 60px;
        left: 10px;
        right: 10px;
        overflow-x: auto;
        padding: 4px 6px;
    }

    .layer-tab {
        padding: 6px 8px;
        font-size: 12px;
    }

    .layer-tab-label {
        display: none;
    }

    .layer-toolbar {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        margin-top: 60px;
    }

    .layer-toolbar-right {
        flex-wrap: wrap;
    }

    .layer-detail-panel {
        width: 100%;
    }

    .roles-cards-container,
    .integrations-cards-container {
        grid-template-columns: 1fr;
    }
}
/* Role Selector Dropdown */
.role-selector-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 900;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    animation: slideInRight 0.4s ease-out;
}

#role-select {
    border: none;
    background: transparent;
    font-size: 21px;
    font-weight: 100;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    min-width: 120px;
}

/* Highlighting for Role Access */
.node-role-access {
    border-color: #006400 !important; /* Dark Green */
    border-width: 6px !important; /* 3x normal */
    background-color: #c1ffc1 !important; /* Light Green */
}

.node-role-no-access {
    opacity: 0.1 !important;
}

/* HTML Label Styles for Role Access */
.cy-node-html-label.role-access {
    border: 6px solid #006400 !important;
    box-shadow: 0 0 12px rgba(0, 100, 0, 0.4) !important;
}

.cy-node-html-label.role-no-access {
    opacity: 0.15 !important;
    filter: grayscale(100%) !important;
    pointer-events: none !important;
}

/* =============================================================================
   NODE PREVIEW POPUP (opened on single click)
   ============================================================================= */

.node-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s ease;
}

.node-preview-overlay.active {
    background: rgba(0, 0, 0, 0.6);
}

.node-preview-overlay.closing {
    background: rgba(0, 0, 0, 0);
}

.node-preview-popup {
    width: 95vw;
    height: 90vh;
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(40px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.node-preview-popup.active {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.node-preview-popup.closing {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: transform 0.25s ease-in, opacity 0.2s ease-in;
}

.node-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.node-preview-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.node-preview-icon {
    font-size: 22px;
}

.node-preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.node-preview-open-btn {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.node-preview-open-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.node-preview-close-btn {
    width: 36px;
    height: 36px;
    background: var(--gray-200);
    color: var(--gray-600);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.node-preview-close-btn:hover {
    background: var(--gray-300);
    color: var(--gray-800);
}

.node-preview-iframe-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.node-preview-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--gray-500);
    font-size: 14px;
    font-weight: 500;
    z-index: 2;
}

.node-preview-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}

.node-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Keyboard shortcut - close popup on Escape */
@media (max-width: 768px) {
    .node-preview-popup {
        width: 98vw;
        height: 90vh;
        border-radius: 12px;
    }
    
    .node-preview-header {
        padding: 12px 16px;
    }
    
    .node-preview-title {
        font-size: 15px;
    }
    
    .node-preview-open-btn span {
        display: none;
    }
}



#node-summary-overlay .node-preview-popup{
    width: 1000px !important;
}

/* =============================================================================
   NODE SUMMARY CONTENT STYLES
   ============================================================================= */

#node-summary-overlay #node-summary-content {
    margin: 0 auto;
    padding: 40px 48px 60px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.75;
    color: var(--gray-700);
}

#node-summary-overlay #node-summary-content h2 {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

#node-summary-overlay #node-summary-content h2 + p {
    font-size: 16px;
    color: var(--gray-500);
    margin-bottom: 32px;
    line-height: 1.8;
}

#node-summary-overlay #node-summary-content h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
    margin-top: 36px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-bg);
}

#node-summary-overlay #node-summary-content h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-700);
    margin-top: 24px;
    margin-bottom: 10px;
}

#node-summary-overlay #node-summary-content hr {
    border: none;
    height: 1px;
    background: var(--gray-200);
    margin: 32px 0;
}

#node-summary-overlay #node-summary-content p {
    font-size: 15px;
    color: var(--gray-600);
    margin-bottom: 16px;
}

#node-summary-overlay #node-summary-content strong {
    color: var(--gray-800);
    font-weight: 650;
}

#node-summary-overlay #node-summary-content em {
    color: var(--gray-500);
    font-style: italic;
}

/* Tables */
#node-summary-overlay #node-summary-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 24px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
    font-size: 14px;
}

#node-summary-overlay #node-summary-content th {
    background: var(--gray-50);
    color: var(--gray-500);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--gray-200);
}

#node-summary-overlay #node-summary-content td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-600);
    vertical-align: top;
    line-height: 1.6;
}

#node-summary-overlay #node-summary-content tr:last-child td {
    border-bottom: none;
}

#node-summary-overlay #node-summary-content tr:hover td {
    background: var(--gray-50);
}

#node-summary-overlay #node-summary-content td strong {
    color: var(--gray-800);
    font-weight: 600;
    font-size: 13.5px;
}

/* Lists */
#node-summary-overlay #node-summary-content ul,
#node-summary-overlay #node-summary-content ol {
    margin-bottom: 20px;
    padding-left: 0;
    list-style: none;
}

#node-summary-overlay #node-summary-content li {
    position: relative;
    padding: 10px 16px 10px 28px;
    margin-bottom: 6px;
    font-size: 14.5px;
    color: var(--gray-600);
    background: var(--gray-50);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
    line-height: 1.7;
}

#node-summary-overlay #node-summary-content li strong {
    color: var(--gray-800);
}

/* Nested lists (flow steps etc) */
#node-summary-overlay #node-summary-content li ul {
    margin-top: 8px;
    margin-bottom: 0;
}

#node-summary-overlay #node-summary-content li li {
    background: white;
    border-left-color: var(--gray-300);
    font-size: 13.5px;
    padding: 8px 14px 8px 24px;
}

.cy-node-html-label, .cy-flow-node, .cy-data-node, .cy-arch-node {
    overscroll-behavior: contain; /* Add this line */
}

/* =============================================================================
   LAYER 1.5: CONCEPT SUMMARY — System Architecture node cards
   ============================================================================= */

.cy-arch-node {
    background: var(--bg-primary);
    border: 2px solid #1a8fe3;
    border-radius: 12px;
    width: 260px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.12s;
    pointer-events: all;
}

.cy-arch-node:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.arch-node-header {
    color: #fff;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 9px;
    line-height: 1.25;
}

.arch-node-header i { font-size: 15px; flex-shrink: 0; }

.arch-node-body { padding: 10px 13px 12px; }

.arch-node-type {
    font-size: 11px;
    font-weight: 700;
    text-transform: capitalize;
    letter-spacing: 0.2px;
    margin-bottom: 6px;
}

.arch-node-desc {
    font-size: 12px;
    color: var(--text-secondary, #475569);
    line-height: 1.35;
    margin-bottom: 8px;
}

.arch-node-techs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.arch-tech-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--gray-100, #f1f5f9);
    color: var(--gray-500, #64748b);
}

.arch-node-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.arch-ref-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--gray-100, #f1f5f9);
    color: var(--gray-600, #475569);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.arch-ref-chip:hover { background: #1a8fe3; color: #fff; }
.arch-ref-chip i { font-size: 10px; }

/* =============================================================================
   OBJECT SEARCH DROPDOWN
   ============================================================================= */

/* Lives inside the #controls toolbar now: flow on the row, pushed to the
   right with margin-left:auto so it sits top-right in the free space. */
.object-search-container {
    position: relative;
    margin-left: auto;
    z-index: 990;
    width: 300px;
    flex-shrink: 0;
}

.object-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.object-search-icon {
    position: absolute;
    left: 12px;
    color: var(--gray-400);
    font-size: 13px;
    pointer-events: none;
    z-index: 1;
}

/* Flat pill matching the "View & Export" toggle: white fill, hairline grey
   border, no drop shadow. */
.object-search-input {
    width: 100%;
    min-height: 38px;
    box-sizing: border-box;
    padding: 9px 32px 9px 36px;
    border: 0.5px solid #dde0e8;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: #fff;
    color: var(--text-primary);
    box-shadow: none;
    transition: all 0.15s ease;
    outline: none;
}

.object-search-input:focus {
    border-color: var(--primary-color);
}

.object-search-input::placeholder {
    color: var(--gray-400);
    font-weight: 400;
}

.object-search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.object-search-clear:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.object-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 0.5px solid #dde0e8;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1101;
    animation: dropdownFadeIn 0.15s ease-out;
}

.object-search-dropdown::-webkit-scrollbar {
    width: 6px;
}

.object-search-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.object-search-dropdown::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.object-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s ease;
    border-bottom: 1px solid var(--gray-100);
}

.object-search-item:last-child {
    border-bottom: none;
}

.object-search-item:hover,
.object-search-item.active {
    background: var(--primary-bg);
}

.object-search-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.object-search-item-icon.type-concept {
    background: var(--primary-bg);
    color: var(--primary-color);
}

.object-search-item-icon.type-business-flow {
    background: #e8f4fe;
    color: #1a8fe3;
}

.object-search-item-icon.type-data-object {
    background: #ecfdf5;
    color: #10b981;
}

.object-search-item-icon.type-role {
    background: #f5f3ff;
    color: #0d6fc0;
}

.object-search-item-icon.type-integration {
    background: #fffbeb;
    color: #f59e0b;
}

.object-search-item-icon.type-business-rule {
    background: #fef2f2;
    color: #ef4444;
}

.object-search-item-info {
    flex: 1;
    min-width: 0;
}

.object-search-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.object-search-item-type-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-left: 6px;
    vertical-align: middle;
}

.object-search-item-type-badge.badge-concept {
    background: var(--primary-bg);
    color: var(--primary-color);
}

.object-search-item-type-badge.badge-business-flow {
    background: #e8f4fe;
    color: #1a8fe3;
}

.object-search-item-type-badge.badge-data-object {
    background: #ecfdf5;
    color: #10b981;
}

.object-search-item-type-badge.badge-role {
    background: #f5f3ff;
    color: #0d6fc0;
}

.object-search-item-type-badge.badge-integration {
    background: #fffbeb;
    color: #f59e0b;
}

.object-search-item-type-badge.badge-business-rule {
    background: #fef2f2;
    color: #ef4444;
}

.object-search-item-meta {
    font-size: 11px;
    color: var(--gray-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.object-search-empty {
    padding: 20px;
    text-align: center;
    color: var(--gray-400);
    font-size: 13px;
}

.object-search-highlight {
    background: #fef08a;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* =============================================================================
   CHANGE HISTORY BUTTON & MODAL
   ============================================================================= */

/* Lives in the #controls toolbar now: flat white pill matching the other
   toolbar buttons (View & Export / Build). */
#controls .change-history-btn {
    position: static;
    min-height: 38px;
    box-sizing: border-box;
    padding: 9px 15px;
    background: #fff;
    color: #333;
    border: 0.5px solid #dde0e8;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: all 0.15s ease;
    box-shadow: none;
    overflow: visible;
}

#controls .change-history-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f4f8fe;
    transform: none;
    filter: none;
}

#controls .change-history-btn i {
    color: var(--primary-color);
}

.change-history-btn i {
    font-size: 13px;
}

/* Change History Modal Overlay */
.change-history-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.change-history-modal-overlay.open {
    display: flex;
}

.change-history-modal-dialog {
    background: var(--bg-primary);
    border-radius: 16px;
    max-width: 720px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--border-color);
    animation: modalSlide 0.3s ease-out;
    overflow: hidden;
}

.change-history-modal-header {
    background: #1e293b;
    color: white;
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.change-history-modal-title {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.change-history-close-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.change-history-close-btn:hover {
    background: rgba(255,255,255,0.25);
}

.change-history-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
}

.change-history-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 60px 20px;
    color: var(--gray-500);
    font-size: 14px;
}

.change-history-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.change-history-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.change-history-empty i {
    font-size: 48px;
    margin-bottom: 14px;
    display: block;
    opacity: 0.5;
}

.change-history-empty h4 {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 700;
    color: var(--gray-500);
}

.change-history-empty p {
    margin: 0;
    font-size: 14px;
}

/* Change History Item */
.ch-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 14px;
    transition: all 0.2s ease;
}

.ch-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    border-color: #cbd5e1;
}

.ch-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 12px;
}

.ch-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ch-item-type-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ch-item-type-badge.ai_agent { background: #ede9fe; color: #0a5694; }
.ch-item-type-badge.manual { background: #dbeafe; color: #2563eb; }
.ch-item-type-badge.rollback { background: #fee2e2; color: #dc2626; }
.ch-item-type-badge.import { background: #fef3c7; color: #d97706; }

.ch-item-status-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.ch-item-status-badge.success { background: #dcfce7; color: #166534; }
.ch-item-status-badge.failure { background: #fee2e2; color: #991b1b; }
.ch-item-status-badge.partial { background: #fef3c7; color: #92400e; }

.ch-item-time {
    font-size: 12px;
    color: #25282c;
    white-space: nowrap;
}

.ch-item-prompt {
    font-size: 14px;
    color: #1e293b;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.5;
    word-break: break-word;
}

.ch-item-explanation {
    font-size: 13px;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 10px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
    word-break: break-word;
}

.ch-item-summary {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 10px;
}

.ch-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ch-item-datetime {
    font-size: 11px;
    color: #25282c;
}

.ch-revert-btn {
    padding: 7px 14px;
    background: white;
    color: #ef4444;
    border: 1.5px solid #fecaca;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.ch-revert-btn:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #dc2626;
}

.ch-revert-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ch-item-error {
    font-size: 12px;
    color: #dc2626;
    padding: 8px 12px;
    background: #fef2f2;
    border-radius: 6px;
    margin-bottom: 10px;
}

/* ════════════════════════════════════════════════════════════════════════
   CODEBASE → CONCEPT AUTO-ANALYSIS
   Offer popup (dismissible) + forced analysis modal (non-closable). The
   forced modal embeds the together workspace via an iframe and has no close
   or cancel affordance by design.
   ════════════════════════════════════════════════════════════════════════ */

/* — Offer popup — */
.cb-offer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 12000;
    background: rgba(15, 23, 42, 0.55);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.cb-offer-overlay.open { display: flex; }
.cb-offer-dialog {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    padding: 32px 30px 26px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    animation: cbOfferIn 0.22s ease-out;
}
@keyframes cbOfferIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cb-offer-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #2563eb);
}
.cb-offer-title {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 10px;
}
.cb-offer-text {
    font-size: 14px;
    line-height: 1.55;
    color: #475569;
    margin: 0 0 18px;
}
.cb-offer-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}
.cb-offer-features span {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    background: #eef2ff;
    border: 1px solid #e0e7ff;
    border-radius: 999px;
    padding: 5px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.cb-offer-features i { color: #6366f1; }
.cb-offer-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.cb-offer-skip,
.cb-offer-go {
    border: none;
    border-radius: 10px;
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.cb-offer-skip {
    background: #f1f5f9;
    color: #475569;
}
.cb-offer-skip:hover { background: #e2e8f0; }
.cb-offer-go {
    background: linear-gradient(135deg, #6366f1, #2563eb);
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.cb-offer-go:hover { filter: brightness(1.07); }

/* — Forced analysis modal — */
.cb-analyze-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 12500;
    background: rgba(11, 16, 32, 0.92);
    /* No padding / no backdrop-click handler: the flow cannot be dismissed. */
}
.cb-analyze-overlay.open { display: block; }
.cb-analyze-shell {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
}
.cb-analyze-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 20px;
    background: linear-gradient(90deg, #1e3a8a, #2563eb);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}
.cb-analyze-bar i { font-size: 16px; flex: 0 0 auto; }
.cb-analyze-frame {
    flex: 1 1 auto;
    width: 100%;
    border: 0;
    background: #0b1020;
}

/* ════════════════════════════════════════════════════════════════════════
   REQUIREMENTS APPROVAL — editable checkbox blocks shown after the QA
   session so the user can review / edit / check before greenlighting build.
   ════════════════════════════════════════════════════════════════════════ */
.req-analyzer-subtitle-hint {
    font-weight: 400;
    font-size: 12px;
    color: #94a3b8;
}
.req-approval-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* No inner scroll — let the dialog body be the single scroll container. */
    padding: 4px;
}

/* — Section block — */
.req-block {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    transition: opacity 0.15s, border-color 0.15s;
}
.req-block-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #eef2f7;
    cursor: pointer;
    user-select: none;
}
.req-block-check {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    cursor: pointer;
    accent-color: #6366f1;
}
.req-block-title {
    flex: 1 1 auto;
    font-weight: 600;
    font-size: 14px;
    color: #0f172a;
}
.req-block-count {
    font-size: 11px;
    color: #94a3b8;
    background: #eef2f7;
    border-radius: 999px;
    padding: 2px 9px;
    white-space: nowrap;
}
.req-block-toggle {
    background: transparent;
    border: 0;
    color: #64748b;
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
    line-height: 1;
}
.req-block-toggle i { transition: transform 0.15s; }
.req-block.collapsed .req-block-items { display: none; }
.req-block.collapsed .req-block-toggle i { transform: rotate(180deg); }
.req-block.req-block-off { opacity: 0.5; }
.req-block.req-block-off .req-block-title { color: #94a3b8; }

/* — Items — */
.req-block-items {
    display: flex;
    flex-direction: column;
    padding: 6px 8px 8px;
}
.req-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
}
.req-item:hover { background: #f8fafc; }
.req-item-check {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    flex: 0 0 auto;
    cursor: pointer;
    accent-color: #6366f1;
}
.req-item-text {
    flex: 1 1 auto;
    font-size: 13px;
    line-height: 1.55;
    color: #1e293b;
    outline: none;
    border-radius: 4px;
    padding: 1px 5px;
}
.req-item-text:focus { background: #eef2ff; box-shadow: 0 0 0 1px #c7d2fe inset; }
.req-item-subhead { margin-top: 4px; }
.req-item-subhead .req-item-text { font-weight: 600; color: #334155; }
.req-item.req-item-off { opacity: 0.5; }
.req-item.req-item-off .req-item-text { text-decoration: line-through; color: #94a3b8; }
/* =============================================================================
   IMPORT PROJECT STRUCTURE — preview modal (.thinkp)
   ============================================================================= */

.import-preview-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.import-preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 48px 0;
    color: #64748b;
    font-size: 14px;
}

/* File summary card at the top of the preview */
.import-preview-file {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #eff6ff, #f0f9ff);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 18px;
}

.import-preview-file-icon {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.import-preview-file-name {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    word-break: break-all;
}

.import-preview-file-meta {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

/* Section headings */
.import-preview-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin: 18px 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.import-preview-section-title .import-preview-badges {
    display: inline-flex;
    gap: 6px;
}

/* Concept stat cards — auto-fit so all 7 sit in one row on the wide modal,
   wrapping gracefully on narrow screens */
.import-preview-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.import-preview-stat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    transition: all 0.15s ease;
}

.import-preview-stat-card:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.import-preview-stat-card i {
    color: var(--primary-color);
    font-size: 14px;
    margin-bottom: 4px;
    display: block;
}

.import-preview-stat-num {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.import-preview-stat-label {
    font-size: 10px;
    color: #64748b;
    margin-top: 2px;
}

/* New / skipped count badges */
.import-preview-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: none;
    letter-spacing: 0;
}

.import-preview-badge.new {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.import-preview-badge.skip {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

/* Item chips (page names / requirement names) */
.import-preview-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px;
}

.import-preview-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    max-width: 100%;
}

.import-preview-chip i { font-size: 10px; }

.import-preview-chip.skip {
    background: #f8fafc;
    color: #94a3b8;
    border-color: #e2e8f0;
}

.import-preview-chip .chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.import-preview-empty {
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
    padding: 4px 2px;
}

/* Replace warning */
.import-preview-warning {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    padding: 12px 14px;
    border-radius: 10px;
    margin-top: 18px;
    font-size: 12.5px;
    color: #92400e;
    line-height: 1.55;
}

.import-preview-warning i {
    color: #f59e0b;
    margin-top: 2px;
}

/* Footer */
.import-preview-footer {
    padding: 14px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f9fafb;
    flex: 0 0 auto;
}

.import-preview-btn {
    padding: 10px 22px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.import-preview-btn-cancel {
    background: #e5e7eb;
    color: #374151;
}

.import-preview-btn-cancel:hover { background: #d1d5db; }

.import-preview-btn-confirm {
    background: var(--primary-dark);
    color: #fff;
}

.import-preview-btn-confirm:hover:not(:disabled) {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(13, 111, 192, 0.35);
}

.import-preview-btn-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Detail-panel one-click copy ─────────────────────────────────────────── */
/* Header actions wrapper keeps copy + close together on the right of the
   space-between header. Colors come from theme variables (black + light). */
.detail-panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.detail-panel-copy {
    background: var(--gray-200);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    color: var(--gray-600);
}
.detail-panel-copy:hover {
    background: var(--gray-300);
    color: var(--primary-color);
}
.detail-panel-copy.t4e-copied {
    color: var(--success-dark);
}

/* ── Persistent save-state chip ──────────────────────────────────────────── */
/* The save indicator is now always visible (Saved / Saving… / Unsaved).
   Dock it bottom-right, smaller than the old toast, above the canvas but
   below modals. Colors inherit the themed .save-indicator variants. */
#concept-save-chip {
    top: auto;
    right: 16px;
    bottom: 16px;
    padding: 7px 14px;
    font-size: 12.5px;
    border-radius: 999px;
    animation: none;
    cursor: default;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
#concept-save-chip.error { cursor: pointer; }
