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

:root {
    --bg: #f4f4f6;
    --bg-alt: #ffffff;
    --text: #16161a;
    --text-muted: #5c5c64;
    --border: #dadadc;
    --accent: #008000;
    --accent-hover: #006600;

    --cta: #e64a19;
    --cta-hover: #b83a10;
    --tag-bg: #fff2eb;
    --tag-text: #c2410c;
    --code-bg: #121214;
    --code-text: #f8fafc;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
}

.dark {
    --bg: #0c0c0e;
    --bg-alt: #141417;
    --text: #e2e2e9;
    --text-muted: #888893;
    --border: #26262b;
    --accent: #00ff88;
    --accent-hover: #33ffaa;

    --cta: #ff5500;
    --cta-hover: #ff7324;
    --tag-bg: #3d1808;
    --tag-text: #ff914d;
    --code-bg: #050506;
    --code-text: #e2e8f0;
}

body {
    font-family: var(--font-mono);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.script-body,
.script-card-desc {
    font-family: var(--font);
}

.container {
    margin: 0 5%;
}

.site-header {
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-title {
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.site-title a {
    color: var(--text);
    text-decoration: none;
}

.site-title a:hover {
    color: var(--cta);
}

.header-brand-container {
    position: relative;
    display: inline-block;
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.graffiti-bg {
    position: absolute;
    top: 0;
    left: calc(5% + 50px);
    height: 100%;
    width: auto;
    z-index: -1;
    pointer-events: none;
    user-select: none;
}

.graffiti-light {
    display: block;
}

.graffiti-dark {
    display: none;
}

.dark .graffiti-light {
    display: none;
}

.dark .graffiti-dark {
    display: block;
}

.header-sep {
    color: var(--border);
    margin: 0 0.25rem;
}

.back-arrow {
    text-decoration: none;
    color: var(--cta);
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.site-title .header-github {
    font-size: 0.875rem;
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.header-desc {
    color: var(--text-muted);
    font-size: 0.8125rem;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 40vw;
    text-align: right;
}

.theme-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 2.25rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.75rem;
}

.dark .theme-btn {
    color: var(--text-muted);
}

.theme-btn:hover {
    color: var(--cta);
    border-color: var(--cta);
}

/* Main */
main {
    padding: 2rem 0;
    min-height: 60vh;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.site-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.footer-date {
    white-space: nowrap;
    font-size: 0.8125rem;
}

.footer-site-link {
    color: inherit;
    text-decoration: none;
}

.footer-site-link:hover {
    color: var(--cta);
}

/* Script Detail */
.script-header {
    display: grid;
    grid-template-areas: "title meta . dates cta";
    grid-template-columns: auto 1fr auto auto auto;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.sh-left {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}
.sh-title {
    grid-area: title;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    min-width: 0;
}
.sh-meta {
    grid-area: meta;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sh-type {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.1875rem 0.5rem;
    border-radius: 5px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    height: 1.5rem;
    border: 1px solid var(--text-muted);
}
.sh-tags {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-left: 0.5rem;
    max-width: 100%;
}
.sh-dates {
    grid-area: dates;
    justify-self: end;
    text-align: right;
}
.sh-cta {
    grid-area: cta;
    display: flex;
}

@media (max-width: 800px) {
    .script-header {
        grid-template-areas:
            "title dates"
            "meta  cta";
        grid-template-columns: auto auto;
        justify-content: space-between;
    }
    .sh-dates,
    .sh-cta {
        justify-self: end;
    }
}

@media (max-width: 500px) {
    .script-header {
        grid-template-areas:
            "title title"
            "meta meta"
            "dates cta";
        grid-template-columns: 1fr auto;
    }
    .sh-dates {
        justify-self: start;
    }
    .sh-cta {
        justify-self: end;
    }
}

.sh-title {
    grid-area: title;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    min-width: 0;
}
.sh-tags {
    grid-area: tags;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.script-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.script-detail h2 {
    margin: 0 0 0.75rem;
    font-size: 1.375rem;
}

.script-logo {
    width: 64px;
    height: 64px;
    padding: 6px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--border);
    margin: 0 0.5rem;
}

.script-install {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.tag {
    color: var(--tag-text);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
}

.tag::before {
    content: "#";
}

.tag:hover {
    color: var(--cta);
}

.resources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.resource {
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
}

.resource-edit {
    padding: 0.25rem 0.5rem;
    display: inline-flex;
    align-items: center;
}

.resource-edit select {
    background: none;
    border: none;
    font: inherit;
    color: inherit;
    outline: none;
    cursor: pointer;
}

.res-unit {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.125rem;
}

.res-reset {
    color: var(--text-muted);
}

.res-reset:hover {
    color: var(--cta);
}

.metadata-pill {
    font-size: 0.65rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--text-muted);
    border-left: 4px solid var(--text-muted);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
}

.metadata-pill.standard {
    border-color: var(--accent);
    border-left-color: var(--accent);
    color: var(--accent);
}

.install-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 1rem;
}

.install-meta {
    grid-column: 2;
    justify-self: end;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.install-command {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
    max-width: 100%;
}

#install-mirrors {
    max-width: 100%;
}

.meta-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    padding: 0 1.25rem;
}

.meta-links a {
    color: var(--cta);
    text-decoration: none;
}

.meta-links a:hover {
    text-decoration: underline;
}

.meta-sep {
    color: var(--border);
}

.author-code {
    background: var(--tag-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.author-missing {
    color: var(--text-muted);
    font-style: italic;
}

.install-code {
    flex: 1;
    background: var(--code-bg);
    color: var(--code-text);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    padding: 0.625rem 1rem;
    border-radius: 6px;
    overflow-x: auto;
    white-space: nowrap;
}

.copy-btn {
    background: none;
    color: var(--cta);
    border: 1px solid var(--cta);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
}

.copy-btn:hover {
    background: var(--cta);
    color: white;
}



.script-body {
    line-height: 1.75;
}

.script-body h2 {
    font-size: 1.375rem;
    margin: 1.5rem 0 0.75rem;
}

.script-body h3 {
    font-size: 1.125rem;
    margin: 1.25rem 0 0.5rem;
}

.script-body p {
    margin-bottom: 1rem;
}

.script-body ul,
.script-body ol {
    margin: 0 0 1rem 1.5rem;
}

.script-body a {
    color: var(--cta);
}

.script-body code {
    background: var(--tag-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.875em;
}

.warning-banner {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 1rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-left: 6px solid #d97706;
    color: #78350f;
    opacity: 0.75;
    transition: opacity 0.6s ease;
}

.warning-banner:hover {
    opacity: 1;
}

.dark .warning-banner {
    opacity: 0.5;
    background: #1e0d04;
    border-color: #ea580c;
    border-left: 6px solid #ff5500;
    color: #ffedd5;
}

.dark .warning-banner:hover {
    opacity: 1;
}

.warning-icon {
    font-size: 1.2rem;
    line-height: 1.4;
    flex-shrink: 0;
}

.hazard-btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    font-weight: 700;
    font-family: var(--font-mono);
    background: var(--cta);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.hazard-btn:hover {
    opacity: 0.85;
}

.script-source {
    display: none;
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.8125rem;
    line-height: 1.4;
    max-height: 500px;
    overflow-y: auto;
    background: var(--code-bg);
    color: var(--code-text);
    margin-bottom: 1.5rem;
}

.script-body pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.script-body pre code {
    background: none;
    padding: 0;
    font-size: 0.8125rem;
}

/* Script Card (for index pages) */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    width: 100%;
}

.category-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.category-column:not(:last-child) {
    border-right: 1px solid var(--border);
    padding-right: 1rem;
}

.category-column h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.category-column h2 a {
    color: var(--cta);
    text-decoration: none;
    font-weight: 400;
    font-size: 0.75rem;
}

.category-column h2 a:hover {
    text-decoration: underline;
}

.count-meta {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 800px) {
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .category-grid {
        grid-template-columns: repeat(1, 1fr);
    }
}

.script-card {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s;
    overflow: hidden;
    min-width: 0;
}

.script-card:hover {
    border-color: var(--cta);
}

.script-card-logo {
    width: 40px;
    height: 40px;
    padding: 4px;
    border-radius: 6px;
    flex-shrink: 0;
    object-fit: contain;
    background: var(--border);
}

.script-card-info {
    flex: 1;
    min-width: 0;
}

.script-card-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.script-card-title a {
    color: var(--text);
    text-decoration: none;
}

.script-card-title a:hover {
    color: var(--cta);
}

.script-card-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
    min-height: calc(3 * 1.4em);
}

.script-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: flex-end;
    min-height: calc(2 * (1.2em + 0.25rem));
    overflow: hidden;
    align-content: flex-end;
}

.script-card-tags .tag {
    font-size: 0.6875rem;
}

.script-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    min-width: 0;
}

.script-card-resources {
    display: flex;
    gap: 0.25rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.dates-inner {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-align: right;
    display: flex;
    flex-direction: column;
}



.filter-bar {
    display: none;
    margin: 0.5rem 0 2rem;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-input {
    flex: 0 1 calc(50% - 1rem);
    min-width: 200px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-alt);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.filter-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
}

#toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 100;
}

.active-filter {
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--cta);
    user-select: none;
}

.active-filter:hover {
    text-decoration: underline;
}

.active-filter-close {
    font-size: 1.1em;
}

.cat-sort {
    margin-left: auto;
}

.sort-bar {
    float: right;
    font-size: 0.75rem;
    cursor: default;
}

.sort-link {
    text-decoration: none;
}

.sort-bar a.sort-link-active {
    color: var(--accent);
    font-weight: 700;
}

.sort-bar a.sort-link-inactive {
    color: var(--text-muted);
}

.sort-icon {
    font-size: 1.3125rem;
    line-height: 0.75rem;
    vertical-align: middle;
}

/* Landing */
.collection-section {
    margin-bottom: 2rem;
}

.collection-section h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.cat-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

@media (max-width: 800px) {
    .cat-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .cat-grid-3 {
        grid-template-columns: repeat(1, 1fr);
    }
}

/* Collection index */
.collection-index h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}
