.explorer-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-subtle);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-normal);
}

.explorer-panel.hidden {
    transform: translateX(100%);
}

body.code-panel-open .explorer-panel {
    right: 50%;
}

.explorer-close-arrow {
    position: absolute;
    left: -32px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-right: none;
    color: var(--text-muted);
    width: 32px;
    height: auto;
    padding: 16px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    transition: all var(--transition-fast);
}

.explorer-close-arrow:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.explorer-arrow-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.explorer-close-arrow i {
    font-size: 0.75rem;
    transition: transform var(--transition-normal);
}

.explorer-panel.hidden .explorer-close-arrow i {
    transform: rotate(180deg);
}

.explorer-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
}

.explorer-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.explorer-title i {
    color: var(--accent-primary);
}

.explorer-copy,
.explorer-toggle {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    font-size: 0.8125rem;
}

.explorer-copy:hover,
.explorer-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.explorer-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-subtle);
}

.explorer-status i {
    font-size: 0.375rem;
    color: var(--error);
}

.explorer-status.connected i {
    color: var(--success);
}

.explorer-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.375rem;
}

.explorer-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 1.5rem;
}

.explorer-empty i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.3;
}

.explorer-empty p {
    font-size: 0.8125rem;
}

.explorer-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.375rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    user-select: none;
    font-size: 0.8125rem;
    font-family: var(--font-mono);
}

.explorer-item:hover {
    background: var(--bg-hover);
}

.explorer-item-icon {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.explorer-item-toggle {
    color: var(--text-muted);
    font-size: 0.625rem;
    width: 12px;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.explorer-item-toggle.collapsed {
    transform: rotate(-90deg);
}

.explorer-item-name {
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.explorer-item-class {
    color: var(--text-muted);
    font-size: 0.6875rem;
    opacity: 0.7;
}

.explorer-item-mention {
    color: var(--accent-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast);
    padding: 0.125rem;
    margin-left: auto;
}

.explorer-item:hover .explorer-item-mention {
    opacity: 0.7;
}

.explorer-item-mention:hover {
    opacity: 1 !important;
}

.explorer-children {
    margin-left: 0.875rem;
    border-left: 1px solid var(--border-subtle);
    padding-left: 0.375rem;
}

.explorer-children.collapsed {
    display: none;
}

@keyframes explorerPulse {
    0% { background: transparent; }
    15% { background: rgba(88, 166, 255, 0.2); }
    100% { background: transparent; }
}

.explorer-item.pulse {
    animation: explorerPulse 1.5s ease;
}

.explorer-item.pulse .explorer-item-name {
    color: var(--accent-primary);
}

.icon-script { color: var(--accent-primary); }
.icon-localscript { color: #818cf8; }
.icon-modulescript { color: var(--error); }
.icon-folder { color: var(--text-muted); }
.icon-part { color: var(--success); }
.icon-model { color: #c4b5fd; }
.icon-screengui { color: var(--warning); }
.icon-default { color: var(--text-muted); }

.main-content.explorer-visible {
    margin-right: 280px;
}

.script-viewer-modal,
.search-results-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.script-viewer-modal.active,
.search-results-modal.active {
    display: flex;
}

.script-viewer-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.search-results-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    width: 95%;
    max-width: 1200px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.script-viewer-header,
.search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.script-viewer-title,
.search-results-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.script-viewer-title i,
.search-results-title i {
    color: var(--accent-primary);
}

.script-viewer-close,
.search-results-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    font-size: 1rem;
}

.script-viewer-close:hover,
.search-results-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.script-viewer-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.script-viewer-body pre {
    margin: 0;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.script-viewer-body code {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.explorer-item.script-item:hover {
    background: rgba(88, 166, 255, 0.1);
}

.explorer-item.script-item:hover .explorer-item-name {
    color: var(--accent-primary);
}

.search-results-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    align-content: start;
}

.search-result-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
}

.search-result-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.search-result-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.search-result-creator {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.search-results-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.search-results-empty i {
    font-size: 2rem;
    opacity: 0.3;
    margin-bottom: 0.75rem;
}

.model-badges {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-left: 0.375rem;
}

.rating-badge {
    display: flex;
    align-items: center;
    gap: 0.1875rem;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
    color: white;
}

.rating-high { background: linear-gradient(135deg, var(--success), #16a34a); }
.rating-medium { background: linear-gradient(135deg, var(--warning), #d97706); }
.rating-low { background: linear-gradient(135deg, var(--error), #dc2626); }

.script-warning-badge {
    display: flex;
    align-items: center;
    gap: 0.1875rem;
    padding: 0.125rem 0.5rem;
    background: linear-gradient(135deg, var(--warning), #d97706);
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
    color: white;
}

.favorites-count {
    display: flex;
    align-items: center;
    gap: 0.1875rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.favorites-count i {
    color: var(--error);
}

@media (max-width: 1024px) {
    .search-results-body {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .search-results-body {
        grid-template-columns: repeat(2, 1fr);
    }

    .search-results-content {
        width: 95%;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .search-results-body {
        grid-template-columns: 1fr;
    }
}
