.scripts-page {
    padding: 40px 24px 60px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 1;
}

.scripts-header {
    text-align: center;
    margin-bottom: 40px;
}

.scripts-header h1 {
    font-size: clamp(32px, 5vw, 48px);
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -1px;
    text-transform: uppercase;
    color: var(--text-primary);
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-orange-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

.scripts-header p {
    color: var(--text-secondary);
    font-size: clamp(14px, 2vw, 16px);
    font-weight: 400;
    margin-bottom: 24px;
}

.search-container {
    position: relative;
    max-width: 480px;
    margin: 0 auto;
}

.search-box {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.search-box::placeholder {
    color: var(--text-secondary);
}

.search-box:focus {
    outline: none;
    border-color: var(--border-accent);
    box-shadow: 0 0 16px rgba(255, 140, 50, 0.1);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.scripts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.script-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-top: 1px solid var(--border-accent);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.script-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-orange);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6);
}

.script-card-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
}

.script-card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.script-link-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 4px 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--accent-orange);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    text-decoration: none;
}

.script-link-btn:hover {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
    color: #09090b;
}

.script-link-btn svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
}

.script-card-body {
    padding: 12px;
}

.script-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

.script-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.script-tag {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.script-detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.3s ease;
    overscroll-behavior: contain;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.script-detail-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-top: 1px solid var(--border-accent);
    border-radius: 12px;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.8);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    overscroll-behavior: contain;
}

.script-detail-content::-webkit-scrollbar {
    width: 6px;
}

.script-detail-content::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.script-detail-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.script-detail-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-accent);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    z-index: 10001;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.detail-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 20px;
    letter-spacing: -0.5px;
}

.detail-description {
    margin-bottom: 24px;
}

.detail-description h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.detail-description p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-top: 12px;
}

.detail-description strong {
    color: var(--text-primary);
    font-weight: 600;
}

.detail-description em {
    color: var(--text-secondary);
    font-style: italic;
}

.detail-loadstring {
    margin-bottom: 12px;
}

.detail-loadstring h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.loadstring-box {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-orange);
    border-radius: 8px;
    padding: 16px;
    position: relative;
    margin-bottom: 16px;
}

.loadstring-box code {
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    word-break: break-all;
    display: block;
    overflow-wrap: break-word;
}

.code-keyword {
    color: var(--accent-orange-light);
    font-weight: 700;
}

.code-punctuation {
    color: #a1a1aa;
}

.code-string {
    color: #4ade80;
    word-break: break-all;
}

.copy-loadstring-btn { display: none; }

.detail-copy-btn {
    width: 100%;
    padding: 14px 16px;
    margin-top: 8px;
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-orange-light) 100%);
    border: none;
    border-radius: 8px;
    color: #09090b;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(255, 140, 50, 0.2);
}

.detail-copy-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.detail-copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 140, 50, 0.3);
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--border-color) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
}

.skeleton-title {
    height: 16px;
    border-radius: 4px;
    margin-bottom: 8px;
    width: 80%;
}

.skeleton-tags {
    display: flex;
    gap: 4px;
}

.skeleton-tag {
    display: inline-block;
    height: 18px;
    width: 48px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--border-color) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (max-width: 600px) {
    .script-detail-content {
        padding: 24px;
        margin: 16px;
    }
    .detail-title {
        font-size: 22px;
    }
}