                <div
                    v-show="mainTab === 'plugins'"
                    class="mode-content"
                    id="panel-plugins"
                    role="tabpanel"
                    aria-labelledby="tab-plugins">
                    <div class="plugins-layout">
                        <aside class="plugins-sidebar" :aria-label="t('plugins.sidebar.ariaList')">
                            <div class="selector-header plugins-sidebar-header">
                                <div>
                                    <span class="selector-title">{{ t('plugins.sidebar.title') }}</span>
                                    <div class="plugins-panel-note">{{ t('plugins.sidebar.note') }}</div>
                                </div>
                                <div class="settings-tab-actions">
                                    <button type="button" class="btn-tool btn-tool-compact" @click="loadPluginsOverview({ forceRefresh: true, silent: false })" :disabled="loading || !!initError || pluginsLoading">
                                        {{ pluginsLoading ? t('plugins.refreshing') : t('plugins.refresh') }}
                                    </button>
                                </div>
                            </div>

                            <div class="plugins-list" role="list">
                                <button
                                    v-for="plugin in pluginsCatalog"
                                    :key="'plugin-' + plugin.id"
                                    type="button"
                                    :class="['plugins-item', { active: pluginsActiveId === plugin.id }]"
                                    :aria-current="pluginsActiveId === plugin.id ? 'page' : null"
                                    :disabled="loading || !!initError || pluginsLoading"
                                    @click="selectPlugin(plugin.id)">
                                    <div class="plugins-item-main">
                                        <div class="plugins-item-title">{{ plugin.title }}</div>
                                        <div class="plugins-item-meta">{{ plugin.description }}</div>
                                    </div>
                                    <span :class="['pill', plugin.tone]">{{ plugin.statusLabel }}</span>
                                </button>
                            </div>
                        </aside>

                        <section class="plugins-main" :aria-label="t('plugins.main.ariaWorkspace')">
                            <div v-if="pluginsLoading" class="skills-empty-state">{{ t('common.loading') }}</div>
                            <div v-else-if="pluginsError" class="skills-empty-state">
                                <div class="plugins-panel-note">{{ pluginsError }}</div>
                                <button type="button" class="btn-mini" @click="loadPluginsOverview({ forceRefresh: true, silent: false })" :disabled="loading || !!initError || pluginsLoading">{{ t('common.refresh') }}</button>
                            </div>
                            <div v-else-if="pluginsActiveId === 'prompt-templates'" class="plugins-panel">
                                <div class="plugins-panel-head">
                                    <div class="plugins-panel-title">{{ t('plugins.promptTemplates.title') }}</div>
                                    <div v-if="pluginsActiveAttribution" class="plugins-panel-note">{{ pluginsActiveAttribution }}</div>
                                </div>

                                <div class="prompt-templates-modebar" role="tablist" :aria-label="t('plugins.promptTemplates.mode.aria')">
                                    <button
                                        type="button"
                                        role="tab"
                                        :aria-selected="promptTemplatesMode === 'compose'"
                                        :class="['mode-pill', { active: promptTemplatesMode === 'compose' }]"
                                        @click="promptTemplatesMode = 'compose'; if(typeof saveNavState==='function')saveNavState()"><svg style="width:12px;height:12px;vertical-align:-1px;margin-right:4px" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 4h12v12H4z"/><path d="M8 8h4M8 11h2"/></svg>{{ t('plugins.promptTemplates.mode.compose') }}</button>
                                    <button
                                        type="button"
                                        role="tab"
                                        :aria-selected="promptTemplatesMode !== 'compose'"
                                        :class="['mode-pill', { active: promptTemplatesMode !== 'compose' }]"
                                        @click="promptTemplatesMode = 'manage'; if(typeof saveNavState==='function')saveNavState()"><svg style="width:12px;height:12px;vertical-align:-1px;margin-right:4px" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M3 5h14M3 10h10M3 15h12"/></svg>{{ t('plugins.promptTemplates.mode.manage') }}</button>
                                </div>

                                <div v-if="promptTemplatesMode === 'compose'" class="prompt-compose">
                                    <div class="prompt-compose-workspace">
                                        <div class="prompt-compose-selected">
                                            <div class="prompt-compose-selected-title">{{ (promptComposerActiveTemplate && promptComposerActiveTemplate.name) ? promptComposerActiveTemplate.name : t('plugins.promptTemplates.compose.chooseTemplate') }}</div>
                                            <div class="prompt-compose-selected-meta">{{ (promptComposerActiveTemplate && promptComposerActiveTemplate.description) ? promptComposerActiveTemplate.description : t('plugins.promptTemplates.compose.chooseTemplateHint') }}</div>
                                            <div v-if="promptComposerActiveTemplate && promptComposerActiveTemplate.isBuiltin && (promptComposerActiveTemplate.createdBy || (promptComposerActiveTemplate.maintainers && promptComposerActiveTemplate.maintainers.length))" class="plugins-panel-note">
                                                {{ t('plugins.meta.attribution', { createdBy: promptComposerActiveTemplate.createdBy || '', maintainers: (promptComposerActiveTemplate.maintainers || []).join(', ') }) }}
                                            </div>
                                        </div>

                                        <div class="prompt-compose-form">
                                            <label class="form-label">{{ t('plugins.promptTemplates.compose.selectTemplate') }}</label>
                                            <select
                                                class="form-select prompt-compose-template-select"
                                                :value="promptComposerSelectedTemplateId"
                                                @change="selectPromptComposerTemplate($event.target.value)"
                                                :disabled="pluginsLoading || !promptTemplatesList.length">
                                                <option v-for="tpl in promptTemplatesList" :key="'compose-tpl-' + tpl.id" :value="tpl.id">
                                                    {{ tpl.name }}{{ tpl.isBuiltin ? t('plugins.promptTemplates.compose.builtinSuffix') : '' }}
                                                </option>
                                            </select>

                                            <div v-if="!promptComposerActiveTemplate" class="plugins-panel-note">{{ t('plugins.promptTemplates.compose.empty') }}</div>
                                            <div v-else-if="!promptComposerActiveTemplate.isBuiltin" class="plugins-panel-note">{{ t('plugins.promptTemplates.compose.varsHint') }}</div>
                                            <div v-if="promptComposerActiveTemplate && !promptComposerActiveTemplate.isBuiltin" class="prompt-compose-actions">
                                                <button
                                                    type="button"
                                                    class="btn-mini"
                                                    @click="selectPromptTemplate(promptComposerSelectedTemplateId)"
                                                    :disabled="pluginsLoading || !promptComposerSelectedTemplateId">{{ t('plugins.promptTemplates.compose.goManage') }}</button>
                                            </div>
                                        </div>

                                        <div v-if="promptComposerActiveTemplate && promptComposerActiveTemplate.vars && promptComposerActiveTemplate.vars.length" class="prompt-vars-block">
                                            <div class="prompt-vars-head">
                                                <div>
                                                    <div class="prompt-vars-title">{{ t('plugins.promptTemplates.vars.title') }}</div>
                                                    <div v-if="!promptComposerActiveTemplate.isBuiltin" class="plugins-panel-note">{{ t('plugins.promptTemplates.compose.varsHint') }}</div>
                                                    <div v-if="promptComposerMissingVars.length" class="plugins-panel-note">{{ t('plugins.promptTemplates.compose.missingCount', { count: promptComposerMissingVars.length }) }}</div>
                                                </div>
                                                <div class="prompt-editor-actions">
                                                    <button v-if="promptComposerMissingVars.length" type="button" class="btn-mini" @click="focusPromptComposerFirstMissingVar" :disabled="pluginsLoading">{{ t('plugins.promptTemplates.compose.jumpToMissing') }}</button>
                                                    <button type="button" class="btn-mini" @click="resetPromptComposerVarValues" :disabled="pluginsLoading">{{ t('plugins.promptTemplates.vars.reset') }}</button>
                                                </div>
                                            </div>
                                            <div class="prompt-vars-grid">
                                                <label v-for="(name, idx) in promptComposerActiveTemplate.vars" :key="'prompt-compose-var-' + name" class="prompt-var-row">
                                                    <span class="prompt-var-label mono">{{ name }}</span>
                                                    <template v-if="idx === 0">
                                                        <input ref="promptComposerFirstField" :class="['form-input', 'prompt-var-input', { 'is-missing': promptComposerMissingVars.includes(name) }]" type="text" :value="promptComposerVarValues[name] || ''" @input="setPromptComposerVarValue(name, $event.target.value)" :placeholder="t('plugins.promptTemplates.vars.valuePlaceholder', { name })">
                                                    </template>
                                                    <template v-else>
                                                        <input :class="['form-input', 'prompt-var-input', { 'is-missing': promptComposerMissingVars.includes(name) }]" type="text" :value="promptComposerVarValues[name] || ''" @input="setPromptComposerVarValue(name, $event.target.value)" :placeholder="t('plugins.promptTemplates.vars.valuePlaceholder', { name })">
                                                    </template>
                                                </label>
                                            </div>
                                        </div>

                                        <div class="prompt-preview-block prompt-compose-preview">
                                            <div class="prompt-vars-head">
                                                <div>
                                                    <div class="prompt-vars-title">{{ t('plugins.promptTemplates.compose.outputTitle') }}</div>
                                                    <div class="plugins-panel-note">{{ t('plugins.promptTemplates.compose.outputHint') }}</div>
                                                </div>
                                                <button type="button" class="btn-mini" @click="copyPromptComposerRendered" :disabled="pluginsLoading || !promptComposerRendered">{{ t('plugins.promptTemplates.compose.copy') }}</button>
                                            </div>
                                            <textarea class="form-input prompt-preview-textarea" :value="promptComposerRendered" rows="10" readonly spellcheck="false" :aria-label="t('plugins.promptTemplates.compose.outputAria')"></textarea>
                                        </div>
                                    </div>
                                </div>

                                <div v-else class="prompt-templates-grid">
                                    <div class="prompt-templates-pane prompt-templates-pane-list">
                                        <div class="prompt-templates-toolbar">
                                            <input
                                                class="form-input"
                                                type="text"
                                                v-model.trim="promptTemplatesKeyword"
                                                :aria-label="t('plugins.promptTemplates.manage.searchAria')"
                                                :placeholder="t('plugins.promptTemplates.manage.searchPlaceholder')">
                                            <button type="button" class="btn-mini" @click="createPromptTemplate" :disabled="pluginsLoading">{{ t('plugins.promptTemplates.manage.create') }}</button>
                                            <button type="button" class="btn-mini" @click="exportPromptTemplates" :disabled="pluginsLoading || !promptTemplatesList.length">{{ t('plugins.promptTemplates.manage.export') }}</button>
                                            <button type="button" class="btn-mini" @click="triggerPromptTemplatesImport" :disabled="pluginsLoading">{{ t('plugins.promptTemplates.manage.import') }}</button>
                                        </div>

                                        <div v-if="pluginsLoading && !promptTemplatesLoadedOnce" class="skills-empty-state">{{ t('plugins.promptTemplates.manage.loading') }}</div>
                                        <div v-else-if="!filteredPromptTemplates.length" class="skills-empty-state">{{ t('plugins.promptTemplates.manage.empty') }}</div>
                                        <div v-else class="prompt-templates-list" role="list">
                                            <button
                                                v-for="tpl in filteredPromptTemplates"
                                                :key="'prompt-template-' + tpl.id"
                                                type="button"
                                                :class="['prompt-template-item', { active: promptTemplateSelectedId === tpl.id }]"
                                                :aria-current="promptTemplateSelectedId === tpl.id ? 'page' : null"
                                                @click="selectPromptTemplate(tpl.id)">
                                                <div class="prompt-template-item-main">
                                                    <div class="prompt-template-item-title">{{ tpl.name }}</div>
                                                    <div class="prompt-template-item-meta">
                                                        <span class="mono">{{ t('plugins.promptTemplates.manage.vars', { count: tpl.varCount }) }}</span>
                                                        <span>·</span>
                                                        <span class="mono">{{ tpl.updatedLabel }}</span>
                                                    </div>
                                                </div>
                                                <span :class="['pill', tpl.isBuiltin ? 'configured' : 'source']">{{ tpl.isBuiltin ? t('plugins.promptTemplates.manage.builtin') : t('plugins.promptTemplates.manage.custom') }}</span>
                                            </button>
                                        </div>
                                    </div>

                                    <div class="prompt-templates-pane prompt-templates-pane-editor">
                                        <div v-if="!promptTemplateDraft" class="skills-empty-state">{{ t('plugins.promptTemplates.editor.selectHint') }}</div>
                                        <template v-else>
                                            <div class="prompt-editor-head">
                                                <div class="prompt-editor-title-row">
                                                    <input class="form-input prompt-editor-name" type="text" v-model.trim="promptTemplateDraftRaw.name" :disabled="promptTemplateDraft.isBuiltin" :placeholder="t('plugins.promptTemplates.editor.namePlaceholder')" :aria-label="t('plugins.promptTemplates.editor.nameAria')">
                                                    <div v-if="!promptTemplateDraft.isBuiltin" class="prompt-editor-actions">
                                                        <button type="button" class="btn-mini" @click="duplicatePromptTemplate" :disabled="pluginsLoading">{{ t('plugins.promptTemplates.editor.duplicate') }}</button>
                                                        <button type="button" class="btn-mini delete" @click="deletePromptTemplate" :disabled="pluginsLoading">{{ t('plugins.promptTemplates.editor.delete') }}</button>
                                                        <button type="button" class="btn-mini" @click="savePromptTemplate" :disabled="pluginsLoading">{{ t('plugins.promptTemplates.editor.save') }}</button>
                                                    </div>
                                                </div>
                                                <div v-if="promptTemplateDraft.isBuiltin" class="plugins-panel-note">
                                                    {{ t('plugins.promptTemplates.editor.builtinReadOnly') }}
                                                </div>
                                                <div v-if="promptTemplateDraft.isBuiltin && (promptTemplateDraft.createdBy || (promptTemplateDraft.maintainers && promptTemplateDraft.maintainers.length))" class="plugins-panel-note">
                                                    {{ t('plugins.meta.attribution', { createdBy: promptTemplateDraft.createdBy || '', maintainers: (promptTemplateDraft.maintainers || []).join(', ') }) }}
                                                </div>
                                                <input class="form-input" type="text" v-model.trim="promptTemplateDraftRaw.description" :disabled="promptTemplateDraft.isBuiltin" :placeholder="t('plugins.promptTemplates.editor.descPlaceholder')" :aria-label="t('plugins.promptTemplates.editor.descAria')">
                                            </div>

                                            <div class="prompt-editor-body">
                                                <label class="form-label">{{ t('plugins.promptTemplates.editor.templateLabel') }}</label>
                                                <textarea
                                                    class="form-input prompt-editor-textarea"
                                                    v-model="promptTemplateDraftRaw.template"
                                                    :disabled="promptTemplateDraft.isBuiltin"
                                                    rows="10"
                                                    spellcheck="false"
                                                    :aria-label="t('plugins.promptTemplates.editor.templateAria')"
                                                    :placeholder="t('plugins.promptTemplates.editor.templatePlaceholder')"></textarea>

                                                <div class="prompt-vars-block">
                                                    <div class="prompt-vars-head">
                                                        <div>
                                                            <div class="prompt-vars-title">{{ t('plugins.promptTemplates.vars.title') }}</div>
                                                            <div class="plugins-panel-note">{{ t('plugins.promptTemplates.vars.hint') }}</div>
                                                        </div>
                                                        <div v-if="!promptTemplateDraft.isBuiltin" class="prompt-editor-actions">
                                                            <button type="button" class="btn-mini" @click="resetPromptVariableValues" :disabled="pluginsLoading">{{ t('plugins.promptTemplates.vars.reset') }}</button>
                                                        </div>
                                                    </div>

                                                    <div v-if="!promptTemplateVars.length" class="prompt-vars-empty">{{ t('plugins.promptTemplates.vars.empty') }}</div>
                                                    <div v-else class="prompt-vars-grid">
                                                        <label v-for="name in promptTemplateVars" :key="'prompt-var-' + name" class="prompt-var-row">
                                                            <span class="prompt-var-label mono">{{ name }}</span>
                                                            <input class="form-input prompt-var-input" type="text" :readonly="promptTemplateDraft.isBuiltin" :value="promptTemplateVarValues[name] || ''" @input="setPromptVariableValue(name, $event.target.value)" :placeholder="t('plugins.promptTemplates.vars.valuePlaceholder', { name })">
                                                        </label>
                                                    </div>
                                                </div>

                                                <div class="prompt-preview-block">
                                                    <div class="prompt-vars-head">
                                                        <div>
                                                            <div class="prompt-vars-title">{{ t('plugins.promptTemplates.preview.title') }}</div>
                                                            <div class="plugins-panel-note">{{ t('plugins.promptTemplates.preview.hint') }}</div>
                                                        </div>
                                                        <button type="button" class="btn-mini" @click="copyRenderedPrompt" :disabled="pluginsLoading">{{ t('plugins.promptTemplates.preview.copy') }}</button>
                                                    </div>
                                                    <textarea class="form-input prompt-preview-textarea" :value="renderedPrompt" rows="10" readonly spellcheck="false" :aria-label="t('plugins.promptTemplates.preview.outputAria')"></textarea>
                                                </div>
                                            </div>
                                        </template>
                                    </div>
                                </div>
                            </div>

                            <div v-else class="skills-empty-state">{{ t('plugins.promptTemplates.noPluginSelected') }}</div>
                        </section>
                    </div>
                </div>

                <input
                    ref="promptTemplatesImportInput"
                    type="file"
                    accept=".json,application/json"
                    style="display:none"
                    @change="handlePromptTemplatesImportChange">

