* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

:root {

    --bg-app: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-hover: #f8fafc;
    --bg-tertiary: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #64748b;

    --accent: #0f172a;
    --accent-hover: #1e293b;
    --primary: #3b82f6;

    --success: #10b981;
    --danger: #f43f5e;
    --warning: #f59e0b;

    --border: #e2e8f0;
    --border-focus: #cbd5e1;


    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-pill: 999px;


    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.03);
    --shadow-float: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}


body.embed-mode .header,
body.embed-mode .toolbar,
body.embed-mode .properties,
body.embed-mode .boolean-panel {
    display: none !important;
}

body.embed-mode {
    padding: 0;
    margin: 0;
}

body.embed-mode .main-container {
    width: 100vw;
    height: 100vh;
    border: none;
    border-radius: 0;
}

body.embed-mode .canvas-container {
    width: 100%;
    height: 100%;
    background: #f8fafc;
}


.header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.logo {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.5px;
}

.logo-icon {
    background: linear-gradient(135deg, var(--text-primary) 0%, #334155 100%);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: var(--shadow-sm);
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}


.btn {
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.btn i {
    font-size: 14px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-primary {
    background: var(--text-primary);
    color: white;
}

.btn-primary:hover {
    background: #1e293b;
}

.btn-export {
    background: #4f46e5;
    color: white;
}

.btn-export:hover {
    background: #4338ca;
}

.btn-analyze {
    background: var(--bg-panel);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-analyze:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
}

.btn-success {
    background: var(--text-primary);
    color: white;
}

.btn-success:hover {
    background: #334155;
}

.btn-secondary {
    background: var(--bg-panel);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger,
.btn-clear {
    background: var(--bg-panel);
    color: var(--danger);
    border-color: var(--border);
}

.btn-danger:hover,
.btn-clear:hover {
    background: #fff1f2;
    border-color: #fecdd3;
}


.sim-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.sim-status.active {
    background: #ecfdf5;
    color: #059669;
    border-color: #a7f3d0;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: 0.3s;
}

.sim-status.active .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}



.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.toolbar {
    width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
    z-index: 50;
    user-select: none;
}

.toolbar-section {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

.toolbar-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
}


.mode-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border);
}

.mode-toggle label {
    flex: 1;
    text-align: center;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    border-radius: 4px;
}

.mode-toggle input {
    display: none;
}

.mode-toggle input:checked+label {
    background: var(--bg-panel);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}


.gate-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border: none;
    padding: 10px 0px;
    cursor: grab;
    border-radius: 8px;
    margin: 0 -8px;
    transition: background 0.2s;
}

.gate-btn.active-tutorial {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.gate-btn:hover:not(.active-tutorial) {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.gate-icon {
    width: 36px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gate-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: var(--text-primary);
    stroke-width: 2;
    stroke-linejoin: round;
}

.gate-btn[data-type="INPUT"] .gate-icon svg {
    stroke: var(--success);
}

.gate-btn[data-type="OUTPUT"] .gate-icon svg {
    stroke: var(--danger);
}

.template-btn {
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    color: var(--text-primary);
}

.template-btn:hover {
    background: var(--border);
}



.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle, #cbd5e1 1px, transparent 1px);
    background-size: 24px 24px;
}

#circuitCanvas {
    display: block;
    cursor: crosshair;
    outline: none;
}

.canvas-hint {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    pointer-events: none;
    border: 1px solid var(--border);
}

/* Boolean Generator Panel */
.boolean-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    padding: 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border: 1px solid var(--border);
    z-index: 50;
}

.boolean-panel input {
    width: 320px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: 'Consolas', monospace;
    outline: none;
    background: var(--bg-panel);
    transition: border 0.2s;
}

.boolean-panel input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.boolean-panel .hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
    font-weight: 500;
}

/* Timeline / Tutorial Panel */
.timeline-panel {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 1000;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 480px;
}

.timeline-panel.active {
    transform: translateX(-50%) translateY(0);
}

.tutorial-info {
    text-align: center;
}

.tutorial-step-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.tutorial-progress {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.timeline-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.timeline-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--bg-panel);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    color: var(--text-primary);
}

.timeline-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

.timeline-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.timeline-btn.play-pause {
    width: 44px;
    height: 44px;
    background: var(--text-primary);
    color: white;
    border: none;
}

.timeline-btn.play-pause:hover {
    background: #1e293b;
    transform: scale(1.05);
}

.speed-control {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-left: 10px;
    background: var(--bg-panel);
}

.speed-btn {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    background: transparent;
    border: none;
    cursor: pointer;
    border-right: 1px solid var(--border);
    color: var(--text-secondary);
}

.speed-btn:last-child {
    border: none;
}

.speed-btn.active {
    background: var(--text-primary);
    color: white;
}

.timeline-btn.recording {
    background: #fef1f2 !important;
    color: var(--danger) !important;
    border-color: #fecdd3 !important;
    animation: recordPulse 2s infinite;
}

@keyframes recordPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.4);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(244, 63, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(244, 63, 94, 0);
    }
}



.properties {
    width: 280px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    padding: 24px;
    overflow-y: auto;
    z-index: 50;
    user-select: none;
}

.prop-title {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.prop-group {
    margin-bottom: 16px;
}

.prop-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prop-value {
    font-size: 13px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-family: 'Consolas', monospace;
    font-weight: 600;
    word-wrap: break-word;
    color: var(--text-primary);
}

.help-text {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.help-text kbd {
    background: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: -apple-system, sans-serif;
    font-size: 11px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    font-weight: 600;
    color: var(--text-primary);
}



.context-menu {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 1000;
    min-width: 160px;
    display: none;
}

.context-item {
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.context-item:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.context-item.delete:hover {
    color: var(--danger);
    background: #fff1f2;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-float);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: scale(0.98);
    animation: scaleUp 0.2s ease forwards;
}

@keyframes scaleUp {
    to {
        transform: scale(1);
    }
}

.modal h2 {
    font-size: 20px;
    margin-bottom: 12px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
    font-size: 14px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Analysis Tables */
.analysis-section {
    margin-bottom: 24px;
}

.analysis-section h3 {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

table.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: center;
    font-family: 'Consolas', monospace;
    font-size: 13px;
    margin-bottom: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

table.data-table th,
table.data-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

table.data-table th:last-child,
table.data-table td:last-child {
    border-right: none;
}

table.data-table tr:last-child td {
    border-bottom: none;
}

table.data-table th {
    background: var(--bg-tertiary);
    font-weight: 700;
    color: var(--text-primary);
}

table.data-table td.out-col {
    font-weight: 700;
    background: #fff1f2;
    color: var(--danger);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
    border: 2px solid var(--bg-panel);
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Virtual Mouse */
#virtualMouse {
    position: fixed;
    display: none;
    pointer-events: none;
    z-index: 9999;
    margin-top: -2px;
    margin-left: -5px;
    width: 24px;
    height: 24px;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#virtualMouse.clicking {
    transform: scale(0.85);
}

#virtualMouse svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.vm-ripple {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

#virtualMouse.clicking .vm-ripple {
    animation: clickRipple 0.6s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes clickRipple {
    0% {
        transform: scale(0.2);
        opacity: 1;
        border-width: 4px;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
        border-width: 0px;
    }
}



.header {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    background: #2563eb;
    /* Bright Blue */
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.header-divider {
    width: 1px;
    height: 20px;
    background: #e5e7eb;
    margin: 0 4px;
}

.icon-group {
    display: flex;
    gap: 6px;
}

/* Icon Only Buttons (Undo, Redo, Stop, Trash etc) */
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #4b5563;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.icon-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #111827;
}

.icon-btn-danger {
    color: #dc2626;
}

.icon-btn-danger:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* Standard Buttons */
.btn {
    padding: 0 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    font-family: inherit;
}

/* Outline Buttons (Analyze, Export) */
.btn-outline {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #374151;
}

.btn-outline:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* Run Button (Dark Green) */
.btn-run {
    background: #115e59;
    border: 1px solid #115e59;
    color: white;
}

.btn-run:hover {
    background: #0f4a46;
    border-color: #0f4a46;
}

/* Status Badge */
.sim-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 32px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    background: #f3f4f6;
    color: #6b7280;
    transition: all 0.3s;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    transition: 0.3s;
}

/* Active Status Colors */
.sim-status.active {
    background: #ecfdf5;
    color: #047857;
}

.sim-status.active .status-dot {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

:root {
    /* ... keep your existing colors ... */
    --font-ui: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --sidebar-bg: #f8fafc;
}

body {
    font-family: var(--font-ui);
    /* ... rest of your body styles ... */
}

/* Update Toolbar & Properties Container */
.toolbar,
.properties {
    background: var(--sidebar-bg);
}

.toolbar-title,
.prop-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    margin-bottom: 16px;
}



.gate-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border: none;
    padding: 10px 8px;
    cursor: grab;
    border-radius: 8px;
    margin: 0 -8px;
    transition: background 0.2s;
}

.gate-btn:hover {
    background: #f1f5f9;
}

.gate-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.gate-icon-clean {
    width: 36px;
    height: 26px;
}

.gate-icon-clean svg {
    width: 100%;
    height: 100%;
    stroke: #0f172a;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* I/O Specific Icons */
.io-icon {
    width: 36px;
    height: 22px;
    border: 2px solid #0f172a;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.io-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-in {
    background: #10b981;
}

.dot-out {
    background: #ef4444;
}

.gate-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.gate-title {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
}

.gate-sub {
    font-size: 11px;
    font-weight: 500;
    color: #94a3b8;
    margin-top: 2px;
}

.gate-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    color: white;
    letter-spacing: 0.5px;
}

/* Badge Colors */
.bg-blue {
    background: #4a8bf5;
}

.bg-green {
    background: #34a853;
}

.bg-purple {
    background: #a156e3;
}

.bg-red {
    background: #ea4335;
}

.bg-orange {
    background: #f29900;
}

.bg-teal {
    background: #12b5cb;
}

.bg-pink {
    background: #d81b60;
}


.template-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.template-btn:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.template-icon {
    color: #3b82f6;
    font-size: 12px;
    width: 14px;
    text-align: center;
}

.template-text {
    font-size: 13px;
    font-weight: 500;
    color: #334155;
}



.empty-props {
    text-align: center;
    color: #94a3b8;
    margin: 30px 0 40px 0;
}

.empty-icon {
    font-size: 32px;
    color: #cbd5e1;
    margin-bottom: 12px;
}

.empty-text {
    font-size: 13px;
    line-height: 1.5;
    font-weight: 500;
}

.shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #475569;
    font-weight: 500;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
}

.shortcut-item:last-child {
    border-bottom: none;
}

.shortcut-item kbd {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px 6px;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}



.export-modal {
    max-width: 540px;
    padding: 32px;
    border-radius: 16px;
}

.export-modal h2 {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
}

.export-modal p {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 24px;
}

.export-cards {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.export-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.export-card:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.export-card i {
    font-size: 24px;
    margin-bottom: 12px;
    color: #111827;
}

.export-card .ec-title {
    font-weight: 700;
    font-size: 14px;
    color: #111827;
    margin-bottom: 6px;
}

.export-card .ec-sub {
    font-size: 12px;
    color: #6b7280;
}

/* Blue Primary Card */
.export-card.primary {
    background: #2563eb;
    border-color: #2563eb;
}

.export-card.primary i,
.export-card.primary .ec-title {
    color: #ffffff;
}

.export-card.primary .ec-sub {
    color: #bfdbfe;
    /* Light blue text for contrast */
}

.export-card.primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.modal-divider {
    height: 1px;
    background: #e5e7eb;
    margin-bottom: 16px;
}





.header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    padding: 8px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.03);
}

/* Nav Menus */
.nav-menu {
    display: flex;
    gap: 4px;
    align-items: center;
}

.dropdown-container {
    position: relative;
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.dropdown-container:hover .nav-btn {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Glassmorphism Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-float);
    min-width: 220px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.98);
    transform-origin: top left;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
}

.dropdown-container:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(4px) scale(1);
}

.dropdown-item {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.dropdown-item i {
    color: var(--text-secondary);
    width: 16px;
    text-align: center;
    font-size: 14px;
    transition: 0.15s;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
    transform: translateX(4px);
}

.dropdown-item:hover i {
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

.dropdown-title {
    font-size: 10px;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 14px 4px;
}

/* AI Magic Button */
.btn-ai {
    background: linear-gradient(135deg, #8b5cf6, #d946ef);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-ai i {
    color: #fff;
}

.btn-ai::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: skewX(-20deg);
    animation: ai-shine 3s infinite;
}

@keyframes ai-shine {
    0% {
        left: -100%;
    }

    20% {
        left: 200%;
    }

    100% {
        left: 200%;
    }
}

.btn-ai:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}



.sim-module {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 4px;
    gap: 8px;
    margin-left: 12px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.sim-module .sim-status {
    background: transparent;
    border: none;
    padding-left: 12px;
    padding-right: 4px;
    height: auto;
}

.sim-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.sim-run-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #10b981;
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    width: 80px;
    overflow: hidden;
}

.sim-run-btn:hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transform: scale(1.02);
}

.sim-stop-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 0;
    height: 34px;
    opacity: 0;
    margin-left: 0;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

/* ANIMATION: When #simStatus gets the '.active' class (Circuit is Running) */
.sim-module:has(#simStatus.active) {
    background: #ecfdf5;
    border-color: #a7f3d0;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.sim-module:has(#simStatus.active) .sim-run-btn {
    width: 0;
    padding: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}

.sim-module:has(#simStatus.active) .sim-stop-btn {
    width: 34px;
    opacity: 1;
    margin-right: 4px;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
    transform: scale(1.05);
}

.sim-module:has(#simStatus.active) .sim-stop-btn:hover {
    background: #dc2626;
    transform: scale(1.15);
}

/* AI Magic Button (Classic) */
.btn-ai {
    background: #8b5cf6;
    color: white;
    border: 1px solid #7c3aed;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.btn-ai:hover {
    background: #7c3aed;
    box-shadow: 0 4px 6px rgba(139, 92, 246, 0.2);
    transform: translateY(-1px);
}








.nav-menu {
    display: flex;
    gap: 4px;
    align-items: center;
}

.dropdown-container {
    position: relative;
    display: inline-block;
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.dropdown-container:hover .nav-btn {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    min-width: 220px;
    padding: 8px;

    /* Hover Magic */
    display: none;
    flex-direction: column;
    z-index: 1000;
    animation: dropIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Fix: Make dropdown show on hover */
.dropdown-container:hover .dropdown-menu {
    display: flex;
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dropdown-item {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.dropdown-item i {
    color: var(--text-secondary);
    width: 16px;
    text-align: center;
    transition: 0.15s;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
    transform: translateX(4px);
}

.dropdown-item:hover i {
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

.dropdown-title {
    font-size: 10px;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 14px 4px;
}




/* 1. Neon Rotating AI Button */
.btn-ai-spark {
    position: relative;
    padding: 2px;
    /* Creates the border thickness */
    border-radius: 99px;
    background: transparent;
    border: none;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.btn-ai-spark:hover {
    transform: translateY(-1px);
}

.btn-ai-spark:active {
    transform: translateY(1px);
}

/* The spinning gradient background */
.btn-ai-spark::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent 0%, transparent 60%, #8b5cf6 80%, #d946ef 100%);
    animation: rotate-spark 2.5s linear infinite;
}

@keyframes rotate-spark {
    100% {
        transform: rotate(360deg);
    }
}

/* The inner solid button */
.spark-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    padding: 8px 16px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    font-family: var(--font-ui);
}

.spark-content i {
    color: #8b5cf6;
}

/* 2. Embedded Hardware Engine Deck */
.engine-deck {
    background: #0f172a;
    /* Dark chassis */
    border-radius: 10px;
    padding: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4), 0 1px 1px rgba(255, 255, 255, 0.8);
    margin-left: 8px;
}

/* Digital Readout Screen */
.engine-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #000000;
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
    border: 1px solid #1e293b;
}

.status-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #475569;
    /* Off state */
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

#simStatusText {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 10px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 68px;
    /* Fixed width prevents jitter */
    text-align: center;
    transition: color 0.3s ease;
}

/* Tactile Hardware Buttons */
.engine-controls {
    display: flex;
    gap: 2px;
    background: #1e293b;
    padding: 2px;
    border-radius: 6px;
}

.engine-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 28px;
    border-radius: 4px;
    color: #64748b;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.engine-btn:hover {
    background: #334155;
    color: #f8fafc;
}

/* ANIMATION: When JS adds '.active' to #simStatus */
.engine-status.active .status-led {
    background: #10b981;
    box-shadow: 0 0 8px #10b981, inset 0 1px 2px rgba(255, 255, 255, 0.4);
}

.engine-status.active #simStatusText {
    color: #10b981;
    text-shadow: 0 0 5px rgba(16, 185, 129, 0.4);
}

/* Highlight Active Control Buttons */
.engine-deck:has(.engine-status.active) .engine-btn.play {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    pointer-events: none;
}

.engine-deck:not(:has(.engine-status.active)) .engine-btn.stop {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    pointer-events: none;
}/* ==========================================
   FIXED DROPDOWN MENUS (No more instant hide!)
========================================== */
.nav-menu { display: flex; gap: 4px; align-items: center; }
.dropdown-container { position: relative; display: inline-block; }

.nav-btn {
    background: transparent; border: none; padding: 8px 14px; font-size: 13px;
    font-weight: 600; color: var(--text-secondary); border-radius: 8px;
    cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center; gap: 6px;
    font-family: inherit;
}
.dropdown-container:hover .nav-btn { background: var(--bg-hover); color: var(--text-primary); }

.dropdown-menu {
    position: absolute; top: 100%; left: 0;
    background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(16px);
    border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); min-width: 220px; padding: 8px;
    
    display: none; 
    flex-direction: column;
    z-index: 1000;
    animation: dropIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    margin-top: 8px; /* Visual gap */
}

/* FIX: The invisible bridge to prevent mouse drop */
.dropdown-container::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px; /* Covers the gap between button and menu */
    z-index: 999;
}

.dropdown-container:hover .dropdown-menu { display: flex; }

@keyframes dropIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
    padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
    color: var(--text-primary); display: flex; align-items: center; gap: 12px;
    cursor: pointer; transition: all 0.15s ease;
}
.dropdown-item i { color: var(--text-secondary); width: 16px; text-align: center; transition: 0.15s;}
.dropdown-item:hover { background: var(--bg-tertiary); color: var(--primary); transform: translateX(4px); }
.dropdown-item:hover i { color: var(--primary); }
.dropdown-divider { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-title { font-size: 10px; font-weight: 800; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; padding: 8px 14px 4px; }


/* ==========================================
   CLEAN WHITE MODE SIMULATOR DECK
========================================== */
.engine-deck {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    margin-left: 8px;
}

/* Digital Readout Screen */
.engine-status {
    display: flex; 
    align-items: center; 
    gap: 8px;
    background: #f3f4f6; /* Light gray screen */
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.status-led {
    width: 8px; height: 8px; border-radius: 50%;
    background: #9ca3af; /* Off state gray */
    transition: all 0.3s ease;
}

#simStatusText {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 60px; /* Fixed width prevents jitter */
    text-align: center;
    transition: color 0.3s ease;
}

/* Tactile Controls Container */
.engine-controls {
    display: flex; 
    gap: 2px;
    background: #f9fafb;
    padding: 2px;
    border-radius: 6px;
    border: 1px solid #f3f4f6;
}

/* Tactile Buttons */
.engine-btn {
    background: transparent; 
    border: none;
    width: 32px; 
    height: 28px; 
    border-radius: 4px;
    color: #9ca3af; 
    font-size: 11px;
    cursor: pointer; 
    transition: all 0.2s ease;
    display: flex; 
    align-items: center; 
    justify-content: center;
}

.engine-btn.play { color: #10b981; } /* Green play */
.engine-btn.stop { color: #ef4444; } /* Red stop */

.engine-btn:hover {
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.engine-btn.play:hover { color: #059669; }
.engine-btn.stop:hover { color: #dc2626; }

/* ANIMATION: When JS adds '.active' to #simStatus */
.engine-status.active {
    background: #ecfdf5;
    border-color: #a7f3d0;
}
.engine-status.active .status-led {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}
.engine-status.active #simStatusText { 
    color: #059669; 
}