* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1bd96a;
    --primary-dark: #0faa4f;
    --accent: #42e686;
    --bg: #16181c;
    --surface: #27292e;
    --surface-hover: #34363c;
    --border: #42444a;
    --text: #b0bac5;
    --text-primary: #ffffff;
    --text-secondary: #96a2b0;
    --success: #1bd96a;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.7);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 0.8;
    }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background: var(--surface);
    border-bottom: none;
    padding: 1.5rem 0;
    animation: slideDown 0.6s ease;
    box-shadow: rgba(0, 0, 0, 0.25) 0px 2px 4px 0px;
}

header .container {
    display: block;
}

.header-content h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-content p {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
}

.header-links {
    margin-top: 1rem;
    display: flex;
    gap: 0.75rem;
}

.header-links a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    background: var(--surface-hover);
    transition: filter 0.1s ease-in-out;
    box-shadow: inset 0px -1px 1px rgba(27, 39, 51, 0.25);
}

.header-links a:hover {
    filter: brightness(1.25);
}

main {
    padding: 2rem 0 4rem 0;
    min-height: 60vh;
}

main .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    animation: fadeIn 0.8s ease;
}

.search-bar {
    margin-bottom: 2rem;
    animation: fadeIn 0.6s ease 0.2s both;
}

#search {
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: none;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    background: var(--surface-hover);
    color: var(--text);
    transition: box-shadow 0.1s ease-in-out;
    box-shadow: inset 0px -1px 1px rgba(27, 39, 51, 0.25);
    font-weight: 500;
    min-height: 36px;
}

#search:focus {
    outline: none;
    box-shadow: inset 0 0 0 transparent, 0 0 0 0.25rem rgba(27, 217, 106, 0.7);
}

#search::placeholder {
    color: var(--text);
    opacity: 0.6;
}

.filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filters select {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    background: var(--surface-hover);
    color: var(--text);
    cursor: pointer;
    transition: filter 0.1s ease-in-out;
    box-shadow: inset 0px -1px 1px rgba(27, 39, 51, 0.25);
    min-height: 36px;
}

.filters select:hover {
    filter: brightness(1.25);
}

.filters select:focus {
    outline: none;
    box-shadow: inset 0 0 0 transparent, 0 0 0 0.25rem rgba(27, 217, 106, 0.7);
}

.scripts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
    transition: all 0.3s ease;
}

.scripts-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

.script-card {
    background: var(--surface);
    border: none;
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.2s ease-in-out;
    animation: scaleIn 0.5s ease backwards;
    position: relative;
    overflow: hidden;
    box-shadow: rgba(0, 0, 0, 0.25) 0px 2px 4px 0px;
}

.script-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease-in-out;
}

.script-card:hover {
    filter: brightness(1.15);
    transform: translateY(-4px);
    box-shadow: rgba(0, 0, 0, 0.4) 0px 8px 16px 0px;
}

.script-card:hover::before {
    transform: scaleX(1);
}

.script-card:active {
    transform: translateY(-2px);
}

.script-card:nth-child(1) { animation-delay: 0.05s; }
.script-card:nth-child(2) { animation-delay: 0.1s; }
.script-card:nth-child(3) { animation-delay: 0.15s; }
.script-card:nth-child(4) { animation-delay: 0.2s; }
.script-card:nth-child(5) { animation-delay: 0.25s; }
.script-card:nth-child(6) { animation-delay: 0.3s; }

.script-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1.25rem;
    gap: 1rem;
}

.script-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.script-version {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
    background: var(--surface-hover);
    padding: 0.25rem 0.625rem;
    border-radius: 0.5rem;
}

.badge-new {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #000000;
    background: var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    animation: bounce 2s infinite;
    margin-left: 0.5rem;
}

.badge-popular {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #000000;
    background: #ffa500;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 0.5rem;
}

.script-description {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    font-size: 1rem;
    line-height: 1.6;
}

.script-meta {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.9375rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.meta-item span:first-child {
    font-size: 1.125rem;
}

.author-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}

.author-avatar-modal {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    margin-right: 0.5rem;
    vertical-align: middle;
}

.script-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
    margin-bottom: 1.5rem;
}

.tag {
    padding: 0.375rem 0.75rem;
    background: var(--surface-hover);
    border: none;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
    transition: filter 0.1s ease-in-out;
}

.tag:hover {
    filter: brightness(1.25);
}

.category-tag {
    background: rgba(27, 217, 106, 0.25);
    color: var(--primary);
}

.category-tag:hover {
    filter: brightness(1.15);
}

.script-actions {
    display: flex;
    gap: 0.875rem;
}

.btn {
    flex: 1;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all 0.1s ease-in-out;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: var(--primary);
    color: #000000;
}

.btn-primary:hover {
    filter: brightness(1.15);
}

.btn-primary:active {
    filter: brightness(1.3);
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text);
    box-shadow: inset 0px -1px 1px rgba(27, 39, 51, 0.25);
}

.btn-secondary:hover {
    filter: brightness(1.25);
}

.btn-secondary:active {
    filter: brightness(1.4);
}

.no-results {
    text-align: center;
    padding: 5rem 0;
    color: var(--text-secondary);
    font-size: 1.125rem;
    font-weight: 600;
    animation: fadeIn 0.6s ease;
}

.no-results-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-results-message {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.no-results-hint {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.skeleton-card {
    background: var(--surface);
    border-radius: 1rem;
    padding: 1.5rem;
    animation: fadeIn 0.3s ease;
}

.skeleton-line {
    height: 1rem;
    background: linear-gradient(90deg, var(--surface-hover) 0%, var(--border) 50%, var(--surface-hover) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.title {
    height: 1.5rem;
    width: 70%;
}

footer {
    background: var(--surface);
    border-top: 2px solid var(--border);
    padding: 3rem 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    margin-top: 4rem;
}

footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .header-content h1 {
        font-size: 2rem;
    }

    .header-content p {
        font-size: 1rem;
    }

    .scripts-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .filters {
        flex-direction: column;
    }

    .filters select {
        width: 100%;
    }

    .script-card {
        padding: 1.5rem;
    }

    .script-title {
        font-size: 1.25rem;
    }

    .script-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

html {
    scroll-behavior: smooth;
}

.scripts-grid:empty::after {
    content: 'Loading amazing scripts...';
    display: block;
    text-align: center;
    padding: 4rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 1.125rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    background: var(--bg);
    width: 100vw;
    height: 100vh;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    animation: modalSlideUp 0.3s ease;
    border: none;
    display: flex;
    flex-direction: row;
}

.modal-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.modal-sidebar {
    width: 350px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1.5rem;
}

.modal-sidebar::-webkit-scrollbar {
    width: 8px;
}

.modal-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.modal-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.modal-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--surface-hover);
    border: none;
    border-radius: 0.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    z-index: 1001;
    color: var(--text);
    font-weight: 300;
    line-height: 1;
    box-shadow: inset 0px -1px 1px rgba(27, 39, 51, 0.25);
}

.modal-close:hover {
    filter: brightness(1.25);
    transform: scale(1.05);
}

.modal-close:active {
    transform: scale(0.95);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    gap: 1rem;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-header .script-version {
    background: var(--surface-hover);
    color: var(--text-secondary);
    border: none;
    flex-shrink: 0;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}



.modal-code {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.code-header h3 {
    font-size: 0.75rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
}

.copy-btn {
    padding: 0.375rem 0.875rem;
    background: var(--surface-hover);
    border: none;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    color: var(--text);
    box-shadow: inset 0px -1px 1px rgba(27, 39, 51, 0.25);
}

.copy-btn:hover {
    filter: brightness(1.25);
    transform: translateY(-1px);
}

.copy-btn:active {
    transform: translateY(0);
}

.copy-btn.copied {
    background: var(--success);
    color: #000000;
    transform: scale(1.05);
}

.modal-code pre {
    flex: 1;
    background: #1e1e1e;
    border: none;
    border-radius: 0;
    padding: 1.5rem 2rem;
    overflow: auto;
    margin: 0;
}

.modal-code pre::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.modal-code pre::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.modal-code pre::-webkit-scrollbar-thumb {
    background: #4a4a4a;
}

.modal-code pre::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.modal-code code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.9375rem;
    line-height: 1.65;
    color: #d4d4d4;
    white-space: pre;
    display: block;
}

.token.keyword {
    color: #569cd6;
    font-weight: 600;
}

.token.class-name {
    color: #4ec9b0;
    font-weight: 600;
}

.token.function {
    color: #dcdcaa;
}

.token.string {
    color: #ce9178;
}

.token.number {
    color: #b5cea8;
}

.token.comment {
    color: #6a9955;
    font-style: italic;
}

.token.annotation {
    color: #9cdcfe;
}

.token.operator {
    color: #d4d4d4;
}

.token.punctuation {
    color: #d4d4d4;
}

.token.boolean,
.token.null {
    color: #569cd6;
}

.token.package {
    color: #c586c0;
}

.token.builtin {
    color: #4ec9b0;
}

.script-card {
    cursor: pointer;
}

.script-card .script-actions {
    pointer-events: none;
}

.script-card .script-actions .btn {
    pointer-events: auto;
}

@media (max-width: 768px) {
    .modal-content {
        flex-direction: column;
    }
    
    .modal-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 45vh;
        padding: 1.25rem;
    }
    
    .modal-main {
        height: 55vh;
    }

    .modal-header {
        padding: 1rem 1.25rem;
    }

    .modal-header h2 {
        font-size: 1.125rem;
    }

    .modal-close {
        top: 0.875rem;
        right: 0.875rem;
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }

    .modal-code pre {
        padding: 1rem 1.25rem;
    }

    .modal-code code {
        font-size: 0.875rem;
        line-height: 1.6;
    }
    
    .sidebar-actions {
        padding-top: 1.25rem;
    }

    .btn-large {
        padding: 0.875rem 1.25rem;
        font-size: 1rem;
    }

    .code-header {
        padding: 0.625rem 1.25rem;
    }

    .sidebar-section {
        margin-bottom: 1.25rem;
    }
}

.sidebar-section {
    margin-bottom: 1.75rem;
    transition: all 0.2s ease;
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-section h3 {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    opacity: 0.7;
}

.sidebar-description {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text);
}

.sidebar-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.sidebar-item:last-child {
    border-bottom: none;
}

.sidebar-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.sidebar-value {
    font-size: 0.8125rem;
    color: var(--text);
    font-weight: 600;
    text-align: right;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-actions {
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.btn-large {
    padding: 1rem 1.5rem;
    font-size: 1.0625rem;
    font-weight: 700;
    width: 100%;
}

#modal-req-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#modal-req-content div {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--text);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

#modal-req-content div:last-child {
    border-bottom: none;
}

#modal-req-content strong {
    color: var(--text-secondary);
    font-weight: 500;
}
