/* Performance Library Styles (Unified Tabs + Filters System) */
:root {
    --layer-card-bg: rgba(30, 30, 35, 0.8);
    --layer-card-hover: rgba(45, 45, 55, 0.95);
    --layer-accent: #00ffff;
    --layer-delete: #ff4444;
    --layer-import: #00ff88;
    --fav-color: #f59e0b;
    --fav-glow: rgba(245, 158, 11, 0.4);
}

/* ========== TAB BAR ========== */
.lib-tab-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lib-tab {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    color: #666;
    padding: 6px 2px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    font-size: 0.6rem;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border-radius: 6px 6px 0 0;
}

.lib-tab:hover {
    color: #aaa;
    background: rgba(255, 255, 255, 0.05);
}

.lib-tab.active {
    color: var(--accent-primary, #8b5cf6);
    border-bottom-color: var(--accent-primary, #8b5cf6);
    background: rgba(139, 92, 246, 0.08);
}

.lib-tab-icon {
    font-size: 0.85rem;
    line-height: 1;
}

.lib-tab-label {
    font-size: 0.55rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-family: var(--font-mono, monospace);
}

/* ========== FILTER BAR ========== */
.lib-filter-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.lib-filter-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #666;
    padding: 5px 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.65rem;
    font-family: var(--font-mono, monospace);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-align: center;
}

.lib-filter-btn:hover {
    color: #aaa;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.lib-filter-btn.active {
    color: #fff;
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.15);
}

/* ========== SEARCH INPUT ========== */
.lib-search-input {
    width: 100%;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e4e4e7;
    border-radius: 6px;
    font-family: var(--font-mono, monospace);
    font-size: 0.7rem;
    box-sizing: border-box;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.2s;
}

.lib-search-input:focus {
    border-color: var(--accent-primary, #8b5cf6);
}

.lib-search-input::placeholder {
    color: #555;
}

/* ========== CONTENT AREA ========== */
.lib-content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.lib-loading {
    text-align: center;
    padding: 30px 10px;
    color: #666;
    font-size: 0.8rem;
    font-family: var(--font-mono, monospace);
}

/* ========== FAVORITE BUTTON ========== */
.lib-fav-btn {
    background: none;
    border: none;
    color: #444;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 2px 4px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.5;
}

.lib-fav-btn:hover {
    color: var(--fav-color);
    opacity: 1;
    transform: scale(1.2);
}

.lib-fav-btn.active {
    color: var(--fav-color);
    opacity: 1;
    text-shadow: 0 0 8px var(--fav-glow);
    animation: fav-pop 0.3s ease;
}

@keyframes fav-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.4);
    }

    100% {
        transform: scale(1);
    }
}

/* ========== SHADER CARDS (inside lib) ========== */
.lib-content-area .shader-library-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    align-content: start;
    padding-bottom: 12px;
}

.shader-name-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    background-color: #1a1a2e;
    border-top: 1px solid #3a3a5c;
    gap: 2px;
}

.shader-name-bar .shader-name {
    flex: 1;
    min-width: 0;
    padding: 0;
    border: none;
    background: none;
    font-size: 0.6rem;
    white-space: nowrap;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    color: #d0d0e8;
}

/* ========== LAYER CARDS ========== */
.layer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    max-height: none;
    overflow-y: visible;
    padding-right: 2px;
    padding-bottom: 12px;
}

.layer-card {
    background: var(--layer-card-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px;
    cursor: grab;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.layer-card:hover {
    background: var(--layer-card-hover);
    border-color: var(--layer-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 255, 255, 0.1);
}

.layer-card.dragging {
    opacity: 0.4;
    transform: scale(0.95);
    border: 1px dashed var(--layer-accent);
}

.layer-card:active {
    cursor: grabbing;
}

.layer-card-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.layer-card-thumbnails {
    display: flex;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.layer-thumb-mini {
    width: 30px;
    height: 30px;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.layer-thumb-mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.layer-thumb-text {
    font-size: 0.5rem;
    color: #444;
    text-transform: uppercase;
}

.layer-thumb-more {
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: #888;
}

.layer-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.layer-card-name {
    margin: 0;
    font-size: 0.85rem;
    color: #fff;
    font-weight: 600;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    max-width: 100%;
}

.layer-delete-btn {
    background: none;
    border: none;
    color: #555;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.layer-delete-btn:hover {
    color: var(--layer-delete);
}

.layer-card-info {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.65rem;
    color: #888;
}

.layer-card-stat {
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 5px;
    border-radius: 10px;
}

.layer-card-source {
    font-style: italic;
    color: #555;
}

/* ========== PROJECT ITEMS ========== */
.projects-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: visible;
    padding-bottom: 12px;
}

.project-item {
    background: rgba(139, 92, 246, 0.04);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.project-item:hover {
    background: rgba(139, 92, 246, 0.12);
    border-color: var(--accent-primary, #8b5cf6);
    transform: translateX(2px);
}

.project-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.project-item-name {
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 4px;
    flex: 1;
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.project-item-meta {
    font-size: 0.65rem;
    color: #888;
    display: flex;
    justify-content: space-between;
}

.project-item-user {
    color: var(--accent-cyan, #22d3ee);
}

/* ========== IMAGE CARDS ========== */
.images-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    align-content: start;
    padding-bottom: 12px;
}

.image-card {
    background: rgba(30, 30, 40, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    overflow: hidden;
    cursor: grab;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-card:hover {
    border-color: var(--accent-cyan, #22d3ee);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 211, 238, 0.1);
}

.image-card:active {
    cursor: grabbing;
}

.image-card-preview {
    width: 100%;
    height: 70px;
    background: #111;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.image-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.image-card:hover .image-card-preview img {
    transform: scale(1.05);
}

.image-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    background: rgba(20, 20, 30, 0.9);
    gap: 4px;
}

.image-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.image-card-shader {
    font-size: 0.6rem;
    color: #ccc;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    font-family: var(--font-mono, monospace);
}

.image-card-author {
    font-size: 0.55rem;
    color: var(--accent-cyan, #22d3ee);
    font-family: var(--font-mono, monospace);
}

/* ========== SAVE SECTION ========== */
.layer-save-section {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.layer-save-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #555;
    margin-bottom: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s;
}

.layer-save-header:hover {
    color: #888;
}

.layer-save-row-btn {
    background: rgba(0, 162, 255, 0.08);
    border: 1px solid rgba(0, 162, 255, 0.2);
    color: #00a2ff;
    width: 100%;
    padding: 6px;
    border-radius: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    transition: all 0.2s;
}

.layer-save-row-btn:hover:not(.disabled) {
    background: rgba(0, 162, 255, 0.2);
    border-color: #00a2ff;
}

.layer-save-row-btn.disabled {
    opacity: 0.3;
    cursor: default;
    border-color: #333;
    color: #666;
}

.layer-save-row-btn>div:first-child {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 2px;
}

.save-row-count {
    font-size: 0.65rem;
    opacity: 0.8;
}

.row-save-thumbs {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    margin: 3px 0;
}

.row-save-thumb {
    width: 18px;
    height: 18px;
    border-radius: 2px;
    overflow: hidden;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.row-save-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 30px 15px;
    color: #555;
}

.empty-state-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    opacity: 0.4;
}

.empty-state p {
    margin: 4px 0;
    font-size: 0.8rem;
    line-height: 1.4;
}

.empty-hint {
    font-size: 0.7rem !important;
    opacity: 0.6;
}

/* ========== TOUCH DRAG CURSOR ========== */
#touch-drag-cursor {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    padding: 8px 16px;
    background: rgba(0, 255, 255, 0.9);
    border: 2px solid #00ffff;
    border-radius: 20px;
    color: #000;
    font-weight: 700;
    font-size: 12px;
    box-shadow: 0 8px 25px rgba(0, 255, 255, 0.4);
    white-space: nowrap;
    display: none;
}

/* ========== SCROLLBAR ========== */
.lib-content-area::-webkit-scrollbar {
    width: 4px;
}

.lib-content-area::-webkit-scrollbar-track {
    background: transparent;
}

.lib-content-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.lib-content-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ========== FX PANEL STYLES (kept from original) ========== */
.fx-drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #666;
    margin-bottom: 15px;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.02);
}

.fx-drop-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(0, 255, 255, 0.05);
    color: var(--accent-primary);
}

.fx-stack-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 40px;
    /* Space at the end of the stack */
}

.fx-stack-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.fx-stack-item.collapsed .fx-uniforms {
    display: none;
}

.fx-btn-toggle {
    background: rgba(139, 92, 246, 0.15) !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
    color: var(--accent-primary) !important;
    font-size: 0.6rem !important;
    padding: 2px 5px !important;
    min-width: 24px;
}

.fx-btn-toggle:hover {
    background: rgba(139, 92, 246, 0.25) !important;
}

.fx-stack-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(0, 255, 255, 0.3);
}

.fx-stack-item.muted {
    opacity: 0.5;
    border-style: dashed;
}

.fx-item-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 8px;
    gap: 8px;
    overflow: hidden;
}

.fx-title-row {
    display: block;
    width: 100%;
    margin-bottom: 4px;
    overflow: hidden;
}

.fx-btns-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.fx-controls-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fx-item-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-cyan);
    white-space: normal;
    word-break: break-all;
    line-height: 1.2;
    display: block;
}

.fx-item-btns,
.fx-reorder-btns {
    display: flex;
    gap: 5px;
}

.fx-item-btns button,
.fx-reorder-btns button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #888;
    padding: 2px 6px;
    font-size: 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.fx-item-btns button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.fx-btn-del:hover {
    color: var(--layer-delete) !important;
}

.fx-uniforms {
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fx-uniforms .param-control {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fx-uniforms .param-control label {
    font-size: 0.65rem;
    color: #aaa;
    font-family: var(--font-mono);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

/* ========== FILTER ROW (legacy compat) ========== */
.library-filter-row {
    display: none;
    /* Replaced by lib-filter-bar */
}

/* ========== CHAT SYSTEM STYLES ========== */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 12px;
    padding: 4px;
}

.chat-section-header {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent-cyan, #22d3ee);
    letter-spacing: 0.1em;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.connected-users-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 80px;
    overflow-y: auto;
    padding: 4px 0;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-family: var(--font-mono, monospace);
}

.user-status-dot {
    width: 6px;
    height: 6px;
    background: #00ff88;
    border-radius: 50%;
    box-shadow: 0 0 5px #00ff88;
}

.user-self-tag {
    opacity: 0.5;
    font-size: 0.6rem;
    margin-left: 2px;
}

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    min-height: 200px;
}

.chat-msg {
    align-self: flex-start;
    max-width: 90%;
}

.chat-msg.me {
    align-self: flex-end;
}

.chat-msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
    font-size: 0.6rem;
}

.chat-msg-user {
    font-weight: 700;
    color: #aaa;
}

.chat-msg.me .chat-msg-user {
    color: var(--accent-primary, #8b5cf6);
}

.chat-msg-time {
    color: #444;
}

.chat-msg-text {
    background: rgba(255, 255, 255, 0.06);
    padding: 6px 10px;
    border-radius: 8px 8px 8px 0;
    font-size: 0.75rem;
    line-height: 1.4;
    word-break: break-word;
}

.chat-msg.me .chat-msg-text {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.3);
    border-radius: 8px 8px 0 8px;
    color: #fff;
}

.chat-input-wrapper {
    display: flex;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

#lib-chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 12px;
    color: #fff;
    font-size: 0.75rem;
    outline: none;
}

#lib-chat-input:focus {
    border-color: var(--accent-primary, #8b5cf6);
}

#lib-chat-send {
    background: var(--accent-primary, #8b5cf6);
    border: none;
    color: #fff;
    padding: 0 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.65rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

#lib-chat-send:hover {
    opacity: 0.9;
}

.chat-empty {
    text-align: center;
    padding: 20px 10px;
    color: #444;
    font-size: 0.7rem;
    font-style: italic;
}