.plugins-layout {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: var(--spacing-sm);
    align-items: start;
}

.plugins-sidebar {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: linear-gradient(to bottom, rgba(255,255,255,0.92) 0%, rgba(255,248,241,0.72) 100%);
    box-shadow: var(--shadow-subtle);
    padding: var(--spacing-sm);
    min-width: 0;
}

.plugins-sidebar-header {
    margin-bottom: var(--spacing-sm);
    align-items: flex-start;
    gap: var(--spacing-xs);
}

.plugins-panel-note {
    margin-top: 4px;
    font-size: var(--font-size-caption);
    color: var(--color-text-tertiary);
    line-height: 1.5;
}

.plugins-list {
    display: grid;
    gap: 8px;
}

.plugins-item {
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast) var(--ease-spring);
}

.plugins-item:hover {
    background: rgba(255,255,255,0.7);
    transform: translateX(2px);
}

.plugins-item.active {
    border-color: rgba(208,88,58,0.2);
    background: linear-gradient(to right, rgba(255,243,236,0.96) 0%, rgba(255,255,255,0.86) 100%);
    box-shadow: 0 2px 8px rgba(200,121,99,0.1);
}
.plugins-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--color-brand);
}

.plugins-item-main {
    min-width: 0;
}

.plugins-item-title {
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-secondary);
    color: var(--color-text-primary);
}

.plugins-item-meta {
    margin-top: 3px;
    font-size: var(--font-size-caption);
    color: var(--color-text-tertiary);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.plugins-main {
    min-width: 0;
}

.plugins-panel {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: linear-gradient(to bottom, rgba(255,255,255,0.95) 0%, rgba(255,248,241,0.72) 100%);
    box-shadow: var(--shadow-card);
    padding: var(--spacing-md);
}

.plugins-panel-head {
    margin-bottom: var(--spacing-sm);
}

.plugins-panel-title {
    font-size: var(--font-size-title);
    font-weight: var(--font-weight-title);
    color: var(--color-text-primary);
    letter-spacing: -0.02em;
}

.plugins-panel-subtitle {
    margin-top: 6px;
    font-size: var(--font-size-caption);
    color: var(--color-text-tertiary);
    line-height: 1.55;
}

.plugins-panel-subtitle code {
    font-family: var(--font-family-mono);
    font-size: 0.92em;
    background: var(--color-brand-light);
    padding: 2px 6px;
    border-radius: 6px;
}

/* Prompt templates modebar */
.prompt-templates-modebar {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: linear-gradient(to bottom, rgba(255,255,255,0.82) 0%, rgba(255,248,241,0.58) 100%);
    backdrop-filter: blur(12px);
    margin-bottom: var(--spacing-md);
}

.mode-pill {
    border: 0;
    border-radius: var(--radius-full);
    padding: 9px 18px;
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-caption);
    letter-spacing: 0.03em;
    cursor: pointer;
    background: transparent;
    color: var(--color-text-tertiary);
    transition: all var(--transition-fast) var(--ease-spring);
}

.mode-pill.active {
    background: var(--color-surface-elevated);
    color: var(--color-text-primary);
    box-shadow: 0 1px 4px rgba(92,68,52,0.1), inset 0 0 0 1px rgba(200,121,99,0.2);
}

.mode-pill:hover:not(.active) {
    color: var(--color-text-secondary);
    background: rgba(255,255,255,0.5);
}

.prompt-compose {
    display: grid;
    gap: var(--spacing-md);
}

.prompt-compose-command-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.prompt-compose-command-input {
    flex: 1;
    min-width: 240px;
    background-color: var(--color-surface);
    border-color: var(--color-border);
    box-shadow: inset 0 1px 2px rgba(31, 26, 23, 0.03);
}

.prompt-compose-form {
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-soft);
    background: rgba(255,255,255,0.6);
    display: grid;
    gap: 12px;
}

.prompt-compose-template-select {
    width: 100%;
}

.prompt-compose-code-input {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-caption);
    line-height: 1.55;
    white-space: pre;
}

.prompt-compose-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.prompt-compose-modal {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: grid;
    place-items: center;
}

.prompt-compose-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 16, 12, 0.45);
    backdrop-filter: blur(2px);
}

.prompt-compose-modal-dialog {
    position: relative;
    width: min(760px, calc(100vw - 32px));
    max-height: min(72vh, 640px);
    overflow: hidden;
    border-radius: calc(var(--radius-md) + 4px);
    border: 1px solid rgba(210, 180, 160, 0.35);
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.86) 100%);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    padding: 14px;
}

.prompt-compose-modal-head {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.prompt-compose-modal-title {
    font-size: var(--font-size-secondary);
    font-weight: var(--font-weight-secondary);
    color: var(--color-text-secondary);
}

.prompt-compose-modal-search {
    margin-bottom: 12px;
}

.prompt-compose-picker-list {
    display: grid;
    gap: 10px;
    overflow: auto;
    padding-right: 2px;
}

.prompt-compose-picker-item {
    width: 100%;
    text-align: left;
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.5);
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all var(--transition-fast) var(--ease-spring);
}

.prompt-compose-picker-item:hover {
    border-color: rgba(200,121,99,0.4);
    background: rgba(255,243,236,0.4);
}

.prompt-compose-picker-item-title {
    font-size: var(--font-size-secondary);
    font-weight: var(--font-weight-secondary);
    color: var(--color-text-secondary);
}

.prompt-compose-picker-item-meta {
    margin-top: 6px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--color-text-tertiary);
    font-size: var(--font-size-caption);
}

.prompt-compose-picker-item-meta .mono {
    font-family: var(--font-family-mono);
}

.prompt-compose-workspace {
    display: grid;
    gap: var(--spacing-sm);
}

.prompt-compose-selected {
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-soft);
    background: linear-gradient(to bottom, rgba(255,243,236,0.5) 0%, rgba(255,255,255,0.6) 100%);
}

.prompt-compose-selected-title {
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-primary);
    color: var(--color-text-primary);
}

.prompt-compose-selected-meta {
    margin-top: 6px;
    font-size: var(--font-size-caption);
    color: var(--color-text-tertiary);
    line-height: 1.5;
}

.prompt-compose-canvas {
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-soft);
    background: rgba(255,255,255,0.6);
    font-family: var(--font-family-mono);
    font-size: var(--font-size-caption);
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.prompt-fragment-text {
    color: var(--color-text-secondary);
}

.prompt-fragment-var {
    display: inline-block;
    vertical-align: baseline;
    min-width: 120px;
    max-width: 100%;
    padding: 6px 10px;
    margin: 2px 3px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(200,121,99,0.35);
    background: linear-gradient(to bottom, rgba(255,255,255,0.98) 0%, rgba(255,243,236,0.7) 100%);
    color: var(--color-text-primary);
    font-family: var(--font-family-mono);
    font-size: var(--font-size-caption);
    line-height: 1.4;
    resize: vertical;
    transition: border-color var(--transition-fast) var(--ease-spring), box-shadow var(--transition-fast) var(--ease-spring);
}

.prompt-fragment-var:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px var(--color-brand-light);
}

.prompt-templates-grid {
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    gap: var(--spacing-sm);
    align-items: start;
}

.prompt-templates-pane {
    min-width: 0;
}

.prompt-templates-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px;
}

.prompt-templates-toolbar .form-input {
    flex: 1;
    min-width: 200px;
}

.prompt-templates-list {
    display: grid;
    gap: 10px;
    max-height: min(62vh, 560px);
    overflow: auto;
    padding-right: 2px;
}

.prompt-template-item {
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.5);
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast) var(--ease-spring);
}

.prompt-template-item:hover {
    background: rgba(255,255,255,0.75);
    border-color: var(--color-border);
}

.prompt-template-item.active {
    border-color: rgba(200,121,99,0.4);
    background: linear-gradient(to right, rgba(255,243,236,0.8) 0%, rgba(255,255,255,0.7) 100%);
}
.prompt-template-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--color-brand);
}

.prompt-template-item-title {
    font-size: var(--font-size-secondary);
    font-weight: var(--font-weight-secondary);
    color: var(--color-text-secondary);
}

.prompt-template-item-meta {
    margin-top: 6px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--color-text-tertiary);
    font-size: var(--font-size-caption);
}

.prompt-template-item-meta .mono {
    font-family: var(--font-family-mono);
}

.prompt-editor-head {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: linear-gradient(to bottom, rgba(255,255,255,0.88) 0%, rgba(255,248,241,0.6) 100%);
    margin-bottom: var(--spacing-sm);
}

.prompt-editor-title-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.prompt-editor-name {
    flex: 1;
    min-width: 220px;
}

.prompt-editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.prompt-editor-textarea,
.prompt-preview-textarea {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-caption);
    line-height: 1.55;
    white-space: pre;
}

.prompt-vars-block,
.prompt-preview-block {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-soft);
    background: rgba(255,255,255,0.6);
}

.prompt-vars-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.prompt-vars-title {
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-secondary);
    color: var(--color-text-secondary);
}

.prompt-vars-empty {
    font-size: var(--font-size-caption);
    color: var(--color-text-tertiary);
    padding: 6px 0;
}

.prompt-vars-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.prompt-var-row {
    display: grid;
    grid-template-columns: minmax(90px, 140px) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.prompt-var-label {
    color: var(--color-brand-dark);
    font-family: var(--font-family-mono);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-caption);
}

.prompt-var-input {
    min-width: 0;
}

.prompt-var-input.is-missing {
    border-color: var(--color-error);
    box-shadow: 0 0 0 2px rgba(196,69,54,0.12);
    animation: var(--transition-normal) ease-in-out;
}

@media (max-width: 980px) {
    .plugins-layout {
        grid-template-columns: 1fr;
    }
    .prompt-templates-grid {
        grid-template-columns: 1fr;
    }
    .prompt-vars-grid {
        grid-template-columns: 1fr;
    }
    .prompt-var-row {
        grid-template-columns: 1fr;
    }
}
