﻿/* --- 7. Library Styles --- */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 6px;
    padding: 8px;
    max-height: 200px;
    overflow-y: auto;
}
.library-item {
    position: relative;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s;
}
.library-item:hover { border-color: var(--accent); }
.library-thumb {
    width: 100%;
    height: 50px;
    object-fit: contain;
    background: repeating-linear-gradient(45deg, #111215 0, #111215 10px, #181a1f 10px, #181a1f 20px);
    padding: 2px;
}
.library-name {
    font-size: 9px;
    padding: 3px;
    text-align: center;
    background: var(--bg-panel-alt);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.library-controls {
    position: absolute;
    top: 2px;
    right: 2px;
    display: none;
    gap: 2px;
}
.library-item:hover .library-controls { display: flex; }
.lib-btn {
    width: 16px;
    height: 16px;
    font-size: 10px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lib-del { background: rgba(229, 72, 77, 0.9); color: white; }
.lib-export { background: rgba(48, 164, 108, 0.9); color: white; }
.lib-rename { background: rgba(99, 102, 241, 0.9); color: white; }

/* Library item in swap mode (when shapes are selected) */
.library-item.swap-mode {
    border-color: rgba(34, 197, 94, 0.5);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.2);
}
.library-item.swap-mode:hover {
    border-color: #22c55e;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.08);
}
.library-item.swap-mode::after {
    content: 'ðŸ”„';
    position: absolute;
    bottom: 2px;
    left: 2px;
    font-size: 10px;
    background: rgba(0,0,0,0.7);
    border-radius: 3px;
    padding: 1px 3px;
    line-height: 1;
}

/* Library grid scrollable â†’ merged into .library-grid above */

/* --- 8. Animation Sliders --- */
.anim-sliders-list {
    max-height: 500px;
    overflow-y: auto;
    padding: 5px 0;
}
.anim-slider-item {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: 5px 10px;
    padding: 8px 10px;
    position: relative;
    transition: border-color 0.15s;
    --slider-acc: var(--accent);
}
.anim-slider-item:hover { border-color: var(--border-light); }
.anim-slider-item.active-slider {
    border-color: var(--slider-acc);
    box-shadow: 0 0 6px color-mix(in srgb, var(--slider-acc) 30%, transparent);
}
.anim-slider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    gap: 4px;
}
.anim-slider-name {
    flex: 1;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 4px;
    border-radius: 3px;
}
.anim-slider-name:hover { background: var(--bg-hover); }
.anim-slider-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    flex-shrink: 0;
    background: var(--slider-acc);
}
.anim-slider-color-dot input[type="color"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    top: 0;
    left: 0;
}
.anim-slider-controls {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}
.anim-slider-controls button {
    width: 20px;
    height: 20px;
    border: 1px solid var(--border);
    background: var(--bg-panel);
    color: var(--text-dim);
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.anim-slider-controls button:hover {
    background: var(--bg-hover);
    color: var(--text-bright);
    border-color: var(--border-light);
}
.anim-slider-controls button.rec-active {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    animation: recBlink 0.8s infinite;
}
@keyframes recBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.anim-slider-range-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.anim-slider-range {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-hover);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}
.anim-slider-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    background: var(--slider-acc);
}
.anim-slider-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    background: var(--slider-acc);
}

.anim-slider-val {
    font-size: 10px;
    color: var(--text-main);
    min-width: 32px;
    text-align: center;
    background: var(--bg-panel-alt);
    padding: 2px 5px;
    border-radius: 3px;
    font-weight: bold;
}
.anim-slider-keyframes-bar {
    position: relative;
    height: 12px;
    margin-top: 5px;
    background: var(--bg-panel-alt);
    border-radius: 3px;
    overflow: visible;
}
.anim-kf-marker {
    position: absolute;
    top: 2px;
    width: 8px;
    height: 8px;
    background: #d4a017;
    border-radius: 2px;
    cursor: pointer;
    transform: translateX(50%);
    transition: background 0.1s, transform 0.1s;
    z-index: 2;
    border: 1px solid rgba(0, 0, 0, 0.3);
}
.anim-kf-marker:hover {
    background: #eab308;
    transform: translateX(50%) scale(1.25);
    z-index: 3;
}
.anim-kf-marker.active-kf {
    background: #fff;
    border-color: var(--slider-acc);
}
.anim-slider-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 9px;
    color: var(--text-dim);
}
.anim-slider-bottom-row input[type="number"] {
    width: 45px;
    background: var(--bg-panel-alt);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 1px 3px;
    border-radius: 3px;
    font-size: 9px;
}
.anim-slider-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 20px 10px;
    font-size: 11px;
}

/* === CUSTOM TOOLS STACKING PANELS === */
#customToolsContainer {
    display: flex;
    flex-direction: column;
}
.custom-tool-section {
    border-bottom: 1px solid var(--border);
}
.custom-tool-section-header {
    padding: 6px 10px;
    font-size: 11px;
    transition: background 0.15s;
}
.custom-tool-section-header:hover {
    background: var(--bg-hover) !important;
}
.custom-tool-section-content {
    border-top: 1px solid rgba(99, 102, 241, 0.1);
}
.custom-tool-section-content .custom-tool-panel {
    font-size: 11px;
}
.custom-tool-section-content .btn-toolbar {
    font-size: 10px;
}

/* === CUSTOM TOOL MANAGEMENT UI === */
.custom-tool-wrapper {
    position: relative;
    display: inline-flex;
}
.custom-tool-wrapper:hover .custom-tool-delete-badge {
    opacity: 1;
    transform: scale(1);
}

.custom-tool-delete-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 16px;
    height: 16px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.12s, transform 0.12s;
    pointer-events: auto;
}
.custom-tool-delete-badge:hover {
    background: #c93035;
    transform: scale(1.1) !important;
}

.custom-tool-section-header .custom-tool-header-btn {
    flex-shrink: 0;
}

/* Blend group layer indicator */
.layer-item .blend-indicator {
    color: var(--success);
    font-size: 10px;
    margin-inline-end: 3px;
}

/* Add Tool Dialog Scrollbar */
#addToolDialog > div::-webkit-scrollbar {
    width: 5px;
}
#addToolDialog > div::-webkit-scrollbar-thumb {
    background: #3a3d46;
    border-radius: 3px;
}

/* Effect layer items in layer list */
.layer-item.effect-layer-item {
    border-inline-start: 3px solid #d4a017;
    background: rgba(212, 160, 23, 0.03);
}
.layer-item.effect-layer-item.selected {
    background: rgba(212, 160, 23, 0.08);
    border-inline-start-color: #eab308;
}
.layer-item.effect-layer-item .layer-name {
    color: #d4a017 !important;
}
.layer-item.effect-layer-item:hover {
    background: rgba(212, 160, 23, 0.06);
}

/* === ADDITIONAL POLISH === */

/* Global scrollbar â†’ see Dark Theme Refinements section below */

/* Ensure no excessive glow/shadow on selection states */
::selection {
    background: var(--accent);
    color: #fff;
}

/* Subtle focus ring for accessibility */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Consistent separator dividers in headers */
.header div[style*="background: var(--border)"],
.header div[style*="background:#333"] {
    opacity: 0.6;
}

/* ============================================
   Smart Propagate (ØªØ¯Ø±Ø¬ Ø§Ù„Ø­Ø±ÙƒØ©) Styles
   ============================================ */

@keyframes spNotifIn {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#smartPropagateModal .sp-ease-btn:hover,
#smartPropagateModal .sp-dir-btn:hover {
    background: #2d3748 !important;
    border-color: #4a5568 !important;
}

#smartPropagateModal .sp-ease-active,
#smartPropagateModal .sp-dir-active {
    background: #1e3a5f !important;
    border-color: #3b82f6 !important;
    color: #60a5fa !important;
}

#smartPropagateModal #spApplyBtn:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
    transform: translateY(-1px);
}

#smartPropagateModal #spCancelBtn:hover {
    background: #3d3d4d !important;
    border-color: #555 !important;
}

/* ============================================
   Shape Morphs (Ø§Ù„ØªØ­ÙˆÙ„Ø§Øª Ø§Ù„Ø´ÙƒÙ„ÙŠØ©) Styles
   ============================================ */

/* Morph Group Container */
.morph-group {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: 5px 0;
    overflow: hidden;
    transition: border-color 0.15s;
}
.morph-group:hover {
    border-color: var(--border-light);
}

/* Morph Group Header */
.morph-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    cursor: pointer;
    background: var(--bg-panel-alt);
    border-bottom: 1px solid rgba(42, 45, 53, 0.5);
    transition: background 0.15s;
}
.morph-group-header:hover {
    background: var(--bg-hover);
}

/* Morph Group Action Buttons */
.morph-group-btn {
    width: 22px;
    height: 22px;
    border: 1px solid var(--border);
    background: var(--bg-panel);
    color: var(--text-dim);
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, border-color 0.15s;
}
.morph-group-btn:hover {
    background: var(--bg-hover);
    color: var(--text-bright);
    border-color: var(--border-light);
}
.morph-group-btn-danger:hover {
    background: rgba(229, 72, 77, 0.12);
    border-color: var(--danger);
    color: var(--danger);
}

/* Morph Group Content */
.morph-group-content {
    padding: 8px;
    background: var(--bg-panel);
}

/* Add variant buttons */
.morph-add-btn {
    flex: 1;
    background: var(--bg-hover);
    border: 1px dashed var(--border);
    color: var(--text-dim);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 10px;
    text-align: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.morph-add-btn:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--accent);
    color: var(--accent);
}
.morph-add-btn-sel:hover {
    background: rgba(48, 164, 108, 0.08);
    border-color: var(--success);
    color: var(--success);
}

/* Variants Grid */
.morph-variants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}
.morph-variants-grid::-webkit-scrollbar { width: 4px; }
.morph-variants-grid::-webkit-scrollbar-thumb { background: #3a3d46; border-radius: 3px; }

/* Variant Item */
.morph-variant-item {
    position: relative;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.morph-variant-item:hover {
    border-color: #ec4899;
}

/* Swappable variant (when shape is selected on stage) */
.morph-variant-swappable {
    border-color: rgba(236, 72, 153, 0.4);
    box-shadow: 0 0 4px rgba(236, 72, 153, 0.15);
}
.morph-variant-swappable:hover {
    border-color: #ec4899;
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.35);
    background: rgba(236, 72, 153, 0.06);
}
.morph-variant-swappable::after {
    content: '\ud83d\udd04';
    position: absolute;
    bottom: 18px;
    left: 2px;
    font-size: 10px;
    background: rgba(0,0,0,0.7);
    border-radius: 3px;
    padding: 1px 3px;
    line-height: 1;
    z-index: 2;
}

/* Variant Thumbnail */
.morph-variant-thumb {
    width: 100%;
    height: 50px;
    object-fit: contain;
    background: repeating-linear-gradient(45deg, #111215 0, #111215 10px, #181a1f 10px, #181a1f 20px);
    padding: 2px;
}

/* Variant Name */
.morph-variant-name {
    font-size: 9px;
    padding: 3px;
    text-align: center;
    background: var(--bg-panel-alt);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-dim);
}

/* Variant Controls (on hover) */
.morph-variant-controls {
    position: absolute;
    top: 2px;
    right: 2px;
    display: none;
    gap: 2px;
    z-index: 3;
}
.morph-variant-item:hover .morph-variant-controls {
    display: flex;
}
.morph-var-btn {
    width: 16px;
    height: 16px;
    font-size: 9px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.9);
    color: white;
}
.morph-var-btn-del {
    background: rgba(229, 72, 77, 0.9);
}

/* ============================================
   Lip Sync Track Styles
   ============================================ */

.lip-sync-track {
    position: relative;
    height: 35px;
    background: linear-gradient(180deg, rgba(59,130,246,0.08) 0%, rgba(59,130,246,0.02) 100%);
    border-bottom: 1px solid rgba(59,130,246,0.3);
    z-index: 95;
}

.lip-sync-box {
    position: absolute;
    top: 4px;
    height: 27px;
    background: rgba(59,130,246,0.25);
    border: 1px solid #3b82f6;
    border-radius: 4px;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #3b82f6;
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 0 4px;
    user-select: none;
    z-index: 10;
    transition: box-shadow 0.15s, transform 0.1s;
}

.lip-sync-box:hover {
    box-shadow: 0 0 8px rgba(59,130,246,0.5);
    transform: translateY(-1px);
}

.lip-sync-box.selected {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(59,130,246,0.6);
}

.lip-sync-box .resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    background: transparent;
}

.lip-sync-box .resize-handle:hover {
    background: rgba(255,255,255,0.2);
}

.lip-sync-box .resize-handle.left {
    left: 0;
    border-radius: 4px 0 0 4px;
}

.lip-sync-box .resize-handle.right {
    right: 0;
    border-radius: 0 4px 4px 0;
}

/* Lip Sync Edit Dialog */
#lipSyncEditDialog {
    font-family: 'Segoe UI', system-ui, sans-serif;
}

#lipSyncEditDialog input[type="text"],
#lipSyncEditDialog input[type="number"] {
    transition: border-color 0.15s;
}

#lipSyncEditDialog input[type="text"]:focus,
#lipSyncEditDialog input[type="number"]:focus {
    border-color: #3b82f6;
    outline: none;
}

#lipSyncEditDialog button:hover {
    filter: brightness(1.1);
}

/* =========================================
   NOISE LINE PANEL STYLES
   ========================================= */
#noiseLinePanel {
    background: rgba(168, 85, 247, 0.02);
}
#noiseLinePanel select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 11px;
}
#noiseLinePanel select:focus {
    border-color: #a855f7;
}
#noiseLinePanel input[type="range"] {
    accent-color: #a855f7;
}
#noiseLinePanel .btn-toolbar:hover {
    background: rgba(168, 85, 247, 0.1);
}

/* =========================================
   CAMERA TRACK ADDITIONAL STYLES
   ========================================= */

.camera-track {
    min-height: 55px;
    background: rgba(59, 130, 246, 0.05);
    border-top: 1px solid rgba(59, 130, 246, 0.2);
    position: relative;
}

.camera-clip {
    position: absolute;
    height: 50px;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.08) 100%);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 6px;
    cursor: grab;
    overflow: hidden;
    user-select: none;
    transition: border-color 0.15s;
}

.camera-clip:hover {
    border-color: rgba(59, 130, 246, 0.7);
}

.camera-clip.selected {
    border-color: #3b82f6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.camera-clip .clip-name {
    position: absolute;
    top: 2px;
    right: 6px;
    font-size: 10px;
    color: #60a5fa;
    pointer-events: none;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.camera-kf-dot {
    position: absolute;
    /* FIX v2: keyframes sit at the BOTTOM of the track, not the middle. */
    bottom: 2px;
    top: auto;
    transform: translate(-50%, 0);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #60a5fa;
    border: 2px solid #fff;
    cursor: pointer;
    z-index: 5;
    transition: transform 0.1s, background 0.1s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.camera-kf-dot:hover {
    transform: translate(-50%, 0) scale(1.3);
    background: #93c5fd;
}

.camera-kf-dot.selected {
    background: #fbbf24;
    border-color: #fff;
    transform: translate(-50%, 0) scale(1.4);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

#cameraPropsPanel {
    background: rgba(59, 130, 246, 0.03);
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
}

#cameraPropsPanel input[type="number"] {
    transition: border-color 0.15s;
}

#cameraPropsPanel input[type="number"]:focus {
    border-color: #3b82f6;
    outline: none;
}

