/* ==================== Aurora Theme for Free Scripts Panels ==================== */

:root {
    --aurora-bg: radial-gradient(1200px 600px at 20% 10%, rgba(70,123,255,0.08), transparent 8%), 
                 #061026;
    --aurora-panel-bg: rgba(255,255,255,0.02);
    --aurora-button-bg: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.09));
    --aurora-button-bg-hover: rgba(255,255,255,0.14);
    --aurora-accent: linear-gradient(180deg,#60a5fa,#a78bfa,#fb7185);
    --aurora-accent-glow: linear-gradient(180deg,#60a5fa,#a78bfa,#fb7185);
    --aurora-text-color: #eaf2ff;
    --aurora-muted-text: rgba(234,242,255,0.65);
    --aurora-border-color: rgba(255,255,255,0.05);
}

/* Free Scripts Section Container
   Sits in normal document flow below the header; negative margins
   cancel .main-content padding so the aurora background is full-bleed. */
#free-scripts.section {
    position: relative;
    isolation: isolate;
    color: var(--aurora-text-color);
    min-height: calc(100vh - 70px);
    padding: 40px 20px 48px; /* extra bottom space so modal/buttons don't sit flush */
    margin: -2rem;
    background: transparent;
    background-color: transparent;
    transition: background 500ms ease, color 500ms ease;
}

#free-scripts .section-content,
#free-scripts h2 {
    position: relative;
    z-index: 1;
}

#free-scripts .free-scripts-header {
    position: relative;
    z-index: 50;
}

@media (max-width: 768px) {
    #free-scripts.section {
        margin: -1rem; /* .main-content padding shrinks to 1rem on mobile */
    }
}

#free-scripts .section-content {
    max-width: 1200px;
    margin: 0 auto;
}

/* Free Scripts header */
.free-scripts-header {
    margin-bottom: 36px;
}

.free-scripts-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 20px;
}

.free-scripts-title-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 14px;
    min-width: 0;
}

#free-scripts h2 {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    margin: 0;
    font-size: clamp(1.55rem, 2.4vw, 2.15rem);
    font-weight: 650;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: #ffffff;
    background: none;
    -webkit-text-fill-color: #ffffff;
    background-clip: border-box;
    -webkit-background-clip: border-box;
    text-shadow: none;
}

#free-scripts #freeScriptsTitle {
    position: relative;
    top: -1px;
    left: 3px;
}

#free-scripts .free-scripts-header-icon {
    width: 2.15rem;
    height: 2.15rem;
    margin-top: 0;
    filter: drop-shadow(0 2px 10px rgba(96, 165, 250, 0.35));
}

.free-scripts-intro {
    margin: 12px 0 0;
    max-width: 560px;
    padding-left: 2.85rem; /* align under title text (icon + gap) */
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.55;
    letter-spacing: 0.005em;
    color: rgba(255, 255, 255, 0.55);
}

/* Tip button + popover */
.fs-tip {
    position: relative;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    transform: translate(15px, 0);
}

.fs-tip-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 11px 0 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(234, 242, 255, 0.78);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
    user-select: none;
}

.fs-tip-btn:hover,
.fs-tip-btn[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(96, 165, 250, 0.35);
    color: #eaf2ff;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
}

.fs-tip-btn-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.9;
}

.fs-tip-btn-label {
    line-height: 1;
}

.fs-tip-popover {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 70;
    min-width: 280px;
    max-width: min(360px, calc(100vw - 40px));
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(12, 22, 44, 0.96);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--aurora-text-color);
    animation: fsTipIn 140ms ease;
}

.fs-tip-popover[hidden] {
    display: none;
}

.fs-tip-popover::before {
    content: "";
    position: absolute;
    top: -5px;
    left: 18px;
    width: 10px;
    height: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(12, 22, 44, 0.96);
    transform: rotate(45deg);
}

@keyframes fsTipIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fs-tip-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fs-tip-list li {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px 8px;
    font-size: 0.86rem;
    line-height: 1.4;
    color: rgba(234, 242, 255, 0.82);
}

.fs-tip-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.55rem;
    height: 1.45rem;
    padding: 0 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 1px 2px rgba(0, 0, 0, 0.25);
    color: #eaf2ff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
}

.fs-tip-plus {
    color: rgba(234, 242, 255, 0.4);
    font-size: 0.75rem;
    line-height: 1.45rem;
}

.fs-tip-text {
    flex: 1 1 140px;
    min-width: 0;
}

/* Panel theme switch (right side of header) */
.fs-theme-switch {
    display: inline-flex;
    align-items: stretch;
    flex-shrink: 0;
    margin-left: auto;
    padding: 3px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    gap: 2px;
}

.fs-theme-option {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 30px;
    padding: 0 11px 0 8px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
    user-select: none;
}

.fs-theme-option:hover {
    color: rgba(255, 255, 255, 0.85);
}

.fs-theme-option.is-active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.fs-theme-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 14px;
    flex-shrink: 0;
    position: relative;
}

.fs-theme-preview--aurora {
    gap: 2px;
}

.fs-theme-preview--aurora span {
    display: block;
    width: 7px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.45), rgba(167, 139, 250, 0.35));
}

.fs-theme-preview--explorer {
    width: 18px;
    height: 14px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
    gap: 0;
}

.fs-theme-preview--explorer span:nth-child(1) {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.28);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.fs-theme-preview--explorer span:nth-child(2),
.fs-theme-preview--explorer span:nth-child(3) {
    position: absolute;
    bottom: 2px;
    width: 3px;
    height: 5px;
    border-radius: 0.5px;
    background: rgba(255, 255, 255, 0.55);
}

.fs-theme-preview--explorer span:nth-child(2) { left: 4px; }
.fs-theme-preview--explorer span:nth-child(3) { left: 10px; }

/* Free Scripts Panels Container */
.free-scripts-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: calc(100% - 200px);
    margin: 0 auto;
}

/* Panel Element (Aurora theme) */
.free-script-panel {
    background: linear-gradient(180deg, rgba(255,255,255,0.005), rgba(0,0,0,0.015));
    border-radius: 12px;
    padding: 0;
    overflow: visible;
    position: relative;
    margin-bottom: -14px;
    transition: all 300ms ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.free-script-panel:last-child {
    margin-bottom: 20px;
}

/* Panel Header (topInterface) */
.panel-header {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 5px 16px;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--aurora-text-color);
    font-weight: 700;
    width: auto;
    box-shadow: 0 3px 22px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255,255,255,0.02);
    transition-property: transform, box-shadow, background, color, text-shadow;
    transition-duration: 480ms;
    transition-timing-function: cubic-bezier(.2,.9,.2,1);
    position: relative;
    top: 25px;
    z-index: 10;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.panel-header:hover {
    transform: none;
    box-shadow: 0 4px 28px rgba(255, 255, 255, 0.12), 
                inset 0 1px 0 rgba(255,255,255,0.05);
    mix-blend-mode: screen;
}

.panel-header-title {
    opacity: 0.7;
    font-weight: 700;
    font-size: 13px;
    color: rgba(234,242,255,0.95);
    letter-spacing: 0.2px;
    text-shadow: 0 1px 8px rgba(10,20,30,0.35);
    transition: opacity 420ms cubic-bezier(.25,.9,.25,1),
                text-shadow 420ms ease;
}

.panel-header-folder {
    opacity: 0.9;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: brightness(0) invert(1);
}

.panel-header:hover .panel-header-title {
    opacity: 1;
}

.panel-header-icon {
    opacity: 0.7;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    filter: drop-shadow(0 6px 18px rgba(6,182,212,0.08));
    border-radius: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: opacity 420ms cubic-bezier(.25,.9,.25,1),
                filter 420ms ease;
}

.panel-header:hover .panel-header-icon {
    opacity: 1;
}

/* Panel Body (actualButtonHolder) */
.panel-body {
    border-radius: 4px 18px 18px 4px;
    padding: 16px;
    padding-bottom: 19px;
    padding-top: 25px;
    background: linear-gradient(180deg, rgba(230, 230, 230, 0.035), rgba(0,0,0,0.025));
    border: 1px solid rgba(255,255,255,0.03);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.02);
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    justify-content: center; /* centered buttons */
    align-items: center;
    margin-top: 10px;
    width: 100%;
}

/* Ensure panel buttons are centered on small screens when stacked */
@media (max-width: 768px) {
    .panel-body {
        justify-content: center;
    }
}

.panel-body.active {
    display: flex;
}

/* Left accent bar on panel body */
.panel-body::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 0;
    height: 100%;
    width: 6px;
    border-radius: 4px 0 0 4px;
    background: var(--aurora-accent-glow);
    box-shadow: none;
    pointer-events: none;
    z-index: 2;
}

/* Glow effect on panel body */
.panel-body::after {
    content: "";
    position: absolute;
    left: -16px;
    top: 0;
    height: 100%;
    width: 150px;
    pointer-events: none;
    background: radial-gradient(ellipse at 20% 50%, rgba(96,165,250,0.25) 0%, rgba(96,165,250,0.15) 20%, rgba(96,165,250,0.08) 40%, transparent 70%), 
                var(--aurora-accent-glow);
    background-size: 140% 100%;
    background-position: left center;
    filter: blur(28px) saturate(1.2);
    z-index: 1;
    mix-blend-mode: screen;
    opacity: 0.12;
    transition: opacity 360ms cubic-bezier(.2,.9,.2,1), filter 360ms ease, background 360ms ease;
    mask: linear-gradient(
        to right,
        transparent 0%,
        black 10%,
        black 50%,
        rgba(0,0,0,0.8) 65%,
        rgba(0,0,0,0.5) 80%,
        rgba(0,0,0,0.2) 92%,
        transparent 100%
    );
}

/* Script Button (inside panel) */
.script-button {
    background: var(--aurora-button-bg);
    color: var(--aurora-text-color);
    border: 1px solid rgba(255,255,255,0.06);
    opacity:0.7;
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.3px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.03);
    cursor: pointer;
    white-space: nowrap;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.script-button:hover {
    background: var(--aurora-button-bg-hover);
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 6px 20px rgba(96,165,250,0.1), inset 0 1px 0 rgba(255,255,255,0.05);
    opacity:1;
    /* transition:  */
        /* opacity 300ms cubic-bezier(0.4, 0.0, 0.2, 1), */
        /* box-shadow 300ms cubic-bezier(0.4, 0.0, 0.2, 1); */
        /* background 5400ms cubic-bezier(0.4, 0.0, 0.2, 1) !important; */
}

.script-button:active {
    transform: translateY(0);
    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.05);
}

.script-button .script-icon {
    display: none;
}

.script-button .script-name {
    display: inline;
}

/* ==================== Explorer / Finder panel theme (dark) ==================== */
#free-scripts.fs-theme-explorer .free-scripts-container {
    gap: 20px;
}

#free-scripts.fs-theme-explorer .free-script-panel {
    align-items: stretch;
    margin-bottom: 0;
    border-radius: 10px;
    overflow: hidden;
    background: #1e2a40;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 14px 40px rgba(0, 0, 0, 0.45),
        0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

#free-scripts.fs-theme-explorer .free-script-panel:last-child {
    margin-bottom: 8px;
}

#free-scripts.fs-theme-explorer .panel-header {
    top: 0;
    width: 100%;
    justify-content: flex-start;
    gap: 9px;
    padding: 9px 14px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, #2a3750 0%, #233048 100%);
    box-shadow: none;
    color: #e8eef8;
    mix-blend-mode: normal;
    cursor: default;
}

#free-scripts.fs-theme-explorer .panel-header:hover {
    transform: none;
    box-shadow: none;
    mix-blend-mode: normal;
}

#free-scripts.fs-theme-explorer .panel-header-folder {
    display: inline-block;
    width: 22px;
    height: 18px;
    font-size: 0;
    line-height: 0;
    color: transparent;
    filter: none;
    opacity: 1;
    background: url('icons/folder.svg') center / contain no-repeat;
}

#free-scripts.fs-theme-explorer .panel-header-title {
    opacity: 1;
    color: #e8eef8;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
    text-shadow: none;
}

#free-scripts.fs-theme-explorer .panel-header:hover .panel-header-title {
    opacity: 1;
}

#free-scripts.fs-theme-explorer .panel-body,
#free-scripts.fs-theme-explorer .panel-body.active {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: flex-start;
    align-content: flex-start;
    gap: 6px 4px;
    margin-top: 0;
    padding: 16px 14px 18px;
    width: 100%;
    border: none;
    border-radius: 0;
    background: #1a2438;
    box-shadow: none;
    animation: none;
}

#free-scripts.fs-theme-explorer .panel-body::before,
#free-scripts.fs-theme-explorer .panel-body::after {
    display: none;
}

#free-scripts.fs-theme-explorer .script-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 96px;
    min-height: 96px;
    padding: 8px 6px 6px;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    color: #e8eef8;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0;
    white-space: normal;
    overflow: visible;
    text-align: center;
    line-height: 1.25;
}

#free-scripts.fs-theme-explorer .script-button:hover {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.22);
    box-shadow: none;
    opacity: 1;
}

#free-scripts.fs-theme-explorer .script-button:active {
    background: rgba(96, 165, 250, 0.18);
    border-color: rgba(96, 165, 250, 0.32);
    box-shadow: none;
    transform: none;
}

#free-scripts.fs-theme-explorer .script-button .script-icon {
    display: block;
    width: 42px;
    height: 49px;
    flex-shrink: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-image: url('icons/file-jsx.svg');
}

#free-scripts.fs-theme-explorer .script-button[data-ext="js"] .script-icon {
    background-image: url('icons/file-js.svg');
}

#free-scripts.fs-theme-explorer .script-button[data-ext="ffx"] .script-icon {
    background-image: url('icons/file-ffx.svg');
}

#free-scripts.fs-theme-explorer .script-button[data-ext="jsxbin"] .script-icon,
#free-scripts.fs-theme-explorer .script-button[data-ext="bin"] .script-icon {
    background-image: url('icons/file-bin.svg');
}

#free-scripts.fs-theme-explorer .script-button .script-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    word-break: break-word;
    max-width: 100%;
    color: rgba(232, 238, 248, 0.88);
}

/* Responsive Design */
@media (max-width: 960px) {
    /* Drop the desktop "calc(100% - 200px)" gutters on smaller viewports */
    .free-scripts-container {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    #free-scripts h2 {
        font-size: 1.45rem;
    }

    .free-scripts-header {
        margin-bottom: 28px;
    }

    .free-scripts-intro {
        padding-left: 0;
        max-width: none;
        font-size: 0.9rem;
    }

    .fs-theme-switch {
        margin-left: 0;
    }

    .fs-theme-option-label {
        display: none;
    }

    .fs-theme-option {
        padding: 0 9px;
    }

    .panel-body {
        flex-direction: column;
        align-items: stretch;
    }

    .script-button {
        width: 100%;
        text-align: center;
    }

    #free-scripts.fs-theme-explorer .panel-body,
    #free-scripts.fs-theme-explorer .panel-body.active {
        flex-direction: row;
        align-items: flex-start;
    }

    #free-scripts.fs-theme-explorer .script-button {
        width: 84px;
        text-align: center;
    }
}

/* Portrait phones: panels use nearly the full screen width */
@media (max-width: 768px) and (orientation: portrait) {
    #free-scripts.section {
        padding: 24px 8px 40px;
    }

    .free-scripts-container {
        max-width: 100%;
        width: 100%;
    }

    /* Override the JS-injected 15px side margins */
    #free-scripts .free-script-panel {
        margin-left: 0;
        margin-right: 0;
    }

    /*
      Header on narrow portrait:
      [ Title ........................ ]
      [ Tips .............. Theme sw. ]
      Keep desktop layout untouched (tip stays beside the title there).
    */
    .free-scripts-title-row {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "title title"
            "tip theme";
        align-items: center;
        gap: 10px 8px;
    }

    .free-scripts-title-left {
        display: contents;
    }

    #free-scripts h2 {
        grid-area: title;
        min-width: 0;
    }

    .fs-tip {
        grid-area: tip;
        transform: none;
        justify-self: start;
    }

    /* Tip sits on the left — open the popover to the right so it stays on-screen */
    .fs-tip-popover {
        left: 0;
        right: auto;
        min-width: 0;
        width: min(360px, calc(100vw - 16px));
        max-width: calc(100vw - 16px);
    }

    .fs-tip-popover::before {
        left: 18px;
        right: auto;
    }

    .fs-theme-switch {
        grid-area: theme;
        margin-left: 0;
        justify-self: end;
    }
}

/* Landscape phones / short viewports: more width, but keep modest gutters */
@media (max-width: 960px) and (orientation: landscape) {
    #free-scripts.section {
        padding: 20px 16px 32px;
    }

    .free-scripts-container {
        max-width: min(720px, 100%);
    }

    #free-scripts .free-script-panel {
        margin-left: 0;
        margin-right: 0;
    }
}

/* Animation for panel expand/collapse */
@keyframes panelExpand {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 200px;
    }
}

.panel-body.active {
    animation: panelExpand 300ms ease-out;
}

/* Loading, empty and error states */
.fs-loading, .fs-empty, .fs-error {
    padding: 28px 16px;
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
    color: var(--aurora-muted-text);
    text-align: center;
}

/* Modal for viewing script content */
.fs-script-modal { position: fixed; inset: 0; display: none; z-index: 20000; }
.fs-script-modal.open { display: block; }
.fs-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6);  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);}
.fs-modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(1100px, 94%); max-height: 86%; overflow: hidden; border-radius: 12px; 
    /* background: linear-gradient(180deg, rgba(10,12,20,0.98), rgba(6,10,20,0.99));  */
    background: linear-gradient(180deg, rgba(17, 19, 31, 0.98), rgba(16, 19, 29, 0.99)); 
    box-shadow: 0 32px 80px rgba(2,6,20,0.7); border: 1px solid rgba(255,255,255,0.04); }
.fs-modal-header { 
    display:flex; align-items:center; justify-content:space-between; gap:42px; 
    /* padding: 42px 16px;  */
    border-bottom: 1px solid rgba(255,255,255,0.03); 
    padding: 15px 12px;
    border-bottom: none;
}
.fs-modal-title { color: var(--aurora-text-color); font-weight:700; }
.fs-modal-actions button { margin-left:8px; padding:6px 10px; font-weight:700; border-radius:8px; border:1px solid rgba(255,255,255,0.06); background: rgba(255,255,255,0.02); color: var(--aurora-text-color); cursor:pointer; }
.fs-modal-body { padding: 0; overflow: hidden; max-height: calc(86vh - 84px); background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(0,0,0,0.02)); position: relative; }
.fs-modal-body pre { margin: 0; font-size: 13px; line-height:1.5; color: #e6eefb; }
.fs-modal-body code { display:block; white-space: pre; overflow: auto; padding: 30px 42px 42px 42px; border-radius: 12px; background: rgba(0,0,0,0.35); height: calc(86vh - 84px - 60px); box-sizing: border-box; }

/* Thin scrollbar for code block */
.fs-modal-body code::-webkit-scrollbar {
    width: 4px;
}

.fs-modal-body code::-webkit-scrollbar-track {
    background: transparent;
}

.fs-modal-body code::-webkit-scrollbar-thumb {
    background: rgba(96,165,250,0.5);
    border-radius: 2px;
}

.fs-modal-body code::-webkit-scrollbar-thumb:hover {
    background: rgba(96,165,250,0.7);
}

/* Code action buttons - sticky position in top right of code area */
.fs-code-actions { 
    position: sticky; 
    top: 36px;
    right:10px; 
    display: flex; 
    gap: 8px; 
    z-index: 100;
    margin-left: auto;
    margin-right: 0;
    width: fit-content;
}
.fs-code-actions .fs-copy-btn,
.fs-code-actions .fs-download-btn { 
    padding: 6px 12px; 
    border-radius: 9px; 
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.06) !important;
    color: var(--aurora-text-color);
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all 200ms ease;
    min-width: 68px;
    height: 28px;
    line-height: 1;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
.fs-code-actions .fs-copy-btn:hover,
.fs-code-actions .fs-download-btn:hover { 
    background: rgba(255,255,255,0.12) !important;
    border-color: rgba(255,255,255,0.15);
}

.fs-code-actions .fs-copy-btn.copied {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.3);
    background: rgba(74, 222, 128, 0.1) !important;
    animation: copyFadeOut 600ms ease-out 3.4s forwards;
}

@keyframes copyFadeOut {
    0% {
        color: #4ade80;
        border-color: rgba(74, 222, 128, 0.3);
        background: rgba(74, 222, 128, 0.1) !important;
    }
    100% {
        color: var(--aurora-text-color);
        border-color: rgba(255,255,255,0.06);
        background: rgba(255,255,255,0.06) !important;
    }
}

.fs-code-actions .fs-download-btn.downloading {
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.3);
    background: rgba(96, 165, 250, 0.1) !important;
}

/* Small tweaks for copy/download buttons */
/* .fs-copy-btn,  */
.fs-download-btn { background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)); }
/* .fs-close-btn { background: rgba(255,80,80,0.08); border-color: rgba(255,80,80,0.12); font-size: 14px; font-weight: bold; padding: 4px 10px; cursor: pointer; } */

/* Close button - override all modal action button styles */
.fs-modal-actions .fs-close-btn { 
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin-left: 28px;
    cursor: pointer;
    color: var(--aurora-text-color);
    font-size: 18px;
    font-weight: normal;
    border-radius: 0;
    position: fixed;
    top: 10px;
    right: 16px;
    z-index: 20001;
    
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* padding-left:20px; */
}

/* make code blocks readable on small screens */
@media (max-width: 780px){ .fs-modal { width: 96%; max-height: 92%; } .fs-modal-body pre { font-size: 12px; } }

/* сделать тело тем же фоном, что и код */
.fs-modal-body {
    background: transparent;
    padding-top: 0;
}







/* title script name */
.fs-modal-title {
    padding-top: 0px;
    padding-left: 15px;
    top: 20px;
    position:fixed;
}

/* Green border flash animation for copied button */
@keyframes greenBorderFlash {
    0% {
        border-color: #22c55e;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 15px rgba(34, 197, 94, 0.9), 0 0 8px rgba(34, 197, 94, 0.5);
    }
    50% {
        border-color: #22c55e;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 15px rgba(34, 197, 94, 0.7), 0 0 8px rgba(34, 197, 94, 0.3);
    }
    100% {
        border-color: rgba(255,255,255,0.08);
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.05);
    }
}

@keyframes greenBorderFlashHover {
    0% {
        border-color: #22c55e;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 15px rgba(34, 197, 94, 0.9), 0 0 8px rgba(34, 197, 94, 0.5);
    }
    50% {
        border-color: #22c55e;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 15px rgba(34, 197, 94, 0.7), 0 0 8px rgba(34, 197, 94, 0.3);
    }
    100% {
        border-color: rgba(255,255,255,0.15);
        box-shadow: 0 6px 20px rgba(96,165,250,0.2), inset 0 1px 0 rgba(255,255,255,0.08);
    }
}

.script-button.copied {
    animation: greenBorderFlash 400ms ease-out forwards;
}

.script-button:hover.copied {
    animation: greenBorderFlashHover 400ms ease-out forwards;
}

/* Blue border flash animation for downloaded button */
@keyframes blueBorderFlash {
    0% {
        border-color: #3b82f6;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 15px rgba(59, 130, 246, 0.9), 0 0 8px rgba(59, 130, 246, 0.5);
    }
    50% {
        border-color: #3b82f6;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 15px rgba(59, 130, 246, 0.7), 0 0 8px rgba(59, 130, 246, 0.3);
    }
    100% {
        border-color: rgba(255,255,255,0.08);
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.05);
    }
}

@keyframes blueBorderFlashHover {
    0% {
        border-color: #3b82f6;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 15px rgba(59, 130, 246, 0.9), 0 0 8px rgba(59, 130, 246, 0.5);
    }
    50% {
        border-color: #3b82f6;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 15px rgba(59, 130, 246, 0.7), 0 0 8px rgba(59, 130, 246, 0.3);
    }
    100% {
        border-color: rgba(255,255,255,0.15);
        box-shadow: 0 6px 20px rgba(96,165,250,0.2), inset 0 1px 0 rgba(255,255,255,0.08);
    }
}

.script-button.downloaded {
    animation: blueBorderFlash 400ms ease-out forwards;
}

.script-button:hover.downloaded {
    animation: blueBorderFlashHover 400ms ease-out forwards;
}
/* Context Menu Styles */
.script-context-menu {
    background: linear-gradient(180deg, rgba(30,30,35,0.95), rgba(20,20,25,0.95));
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6), 0 0 20px rgba(0,0,0,0.4);
    min-width: 180px;
    overflow: hidden;
    animation: contextMenuFadeIn 150ms ease-out;
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-item {
    padding: 10px 16px;
    color: #eaf2ff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: all 150ms ease;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item:hover {
    background: rgba(96,165,250,0.2);
    color: #60a5fa;
}
.context-menu-item:active {
    background: rgba(96,165,250,0.3);
}

/* ==================== OTHER RESOURCES (AE) ==================== */
.fs-other-resources {
    max-width: calc(100% - 200px);
    margin: calc(2.25rem + 15px) auto 1.5rem;
    padding: 1.35rem 1.4rem 1.45rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
}

.fs-other-resources[hidden] {
    display: none !important;
}

.fs-other-resources-title {
    margin: 0 0 0.85rem;
    font-size: 1.61rem; /* 1.15rem + 40% */
    font-weight: 700;
    letter-spacing: -0.01em;
    text-align: center;
    color: var(--text-primary, #fff);
}

.fs-other-resources-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin: 0 0 0.9rem;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 107, 107, 0.28);
    border-left: 3px solid rgba(255, 120, 120, 0.85);
    background: rgba(255, 90, 90, 0.08);
    color: #ffb4b4;
    font-size: 0.9rem;
    line-height: 1.5;
}

.fs-other-resources-intro {
    margin: 0 0 1.15rem;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-secondary, #b0b8d4);
}

.fs-other-resources-warning-icon {
    flex-shrink: 0;
    margin-top: 0.1rem;
    color: #ff8e8e;
}

.fs-other-resources-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.fs-other-resources-item {
    display: grid;
    grid-template-columns: minmax(10rem, 12.5rem) 5.75rem minmax(0, 1fr);
    align-items: baseline;
    column-gap: 0.85rem;
    row-gap: 0.35rem;
    padding: 0.45rem 0.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.fs-other-resources-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.fs-other-resources-author {
    min-width: 0;
    font-weight: 650;
    font-size: 0.92rem;
    color: var(--text-primary, #fff);
    overflow-wrap: anywhere;
}

.fs-other-resources-stars {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem; /* GitHub logo ↔ star group */
    width: 100%;
    min-height: 1.35em;
    padding: 0;
    border: none;
    background: none;
    color: var(--text-secondary, #b0b8d4);
    font-size: 0.9rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
    opacity: 0.45;
    transition: opacity 0.15s ease;
    box-sizing: border-box;
}

.fs-other-resources-stars.is-ready {
    opacity: 1;
}

.fs-other-resources-stars.is-empty {
    opacity: 0;
    pointer-events: none;
}

.fs-other-resources-gh-icon {
    flex-shrink: 0;
    display: block;
    width: 15px;
    height: 15px;
    color: var(--text-primary, #fff);
    opacity: 0.9;
}

.fs-other-resources-stars-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.12rem; /* star ↔ count (tighter than logo gap) */
    color: #c9a227;
    line-height: 1;
}

.fs-other-resources-stars-icon {
    flex-shrink: 0;
    display: block;
    width: 1.15em;
    height: 1.15em;
    /* Star glyph sits optically high in its box — nudge down to match digits */
    transform: translateY(calc(0.16em - 1px));
    color: inherit;
}

.fs-other-resources-stars-count {
    display: block;
    letter-spacing: 0.01em;
    min-width: 1.5ch;
    font-size: 1em;
    line-height: 1;
    color: inherit;
}

.fs-other-resources-link {
    min-width: 0;
    color: var(--accent-cyan, #00d9ff);
    text-decoration: none;
    font-size: 0.88rem;
    word-break: break-all;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.fs-other-resources-link:hover {
    color: #5ee7ff;
    text-decoration: underline;
}

@media (max-width: 900px) {
    .fs-other-resources {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
}

@media (max-width: 640px) {
    .fs-other-resources {
        padding: 1.1rem 1rem 1.2rem;
    }

    .fs-other-resources-item {
        grid-template-columns: minmax(0, 1fr) 5.75rem;
    }

    .fs-other-resources-author {
        grid-column: 1;
    }

    .fs-other-resources-stars {
        grid-column: 2;
        justify-self: end;
        width: auto;
        min-width: 5.25rem;
    }

    .fs-other-resources-link {
        grid-column: 1 / -1;
    }
}