/* ===== STAGE 5 ===== */

.s5-workspace {
    display: flex;
    flex: 1;
    width: 100%;
    min-height: 0;
    gap: 15px; /* Spaced panels instead of one solid block */
    border-radius: 20px;
    overflow: hidden;
    padding: 0 15px; /* ایجاد فاصله کمی از چپ و راست */
    box-sizing: border-box; /* جلوگیری از افزایش عرض کل ناشی از پدینگ */
}

/* Inspector (right panel) — matches the generation panel’s dark, compact chrome */
.s5-right-panel {
    width: 300px;
    height: 100%;
    min-width: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 18px 12px 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #e0e0e0;
    box-sizing: border-box;
    box-shadow: none;
}
.s5-right-panel::-webkit-scrollbar { width: 5px; }
.s5-right-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}
.s5-right-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.22);
}
.s5-right-panel * { box-sizing: border-box; }

/* Global button chrome (pill + scale) would make inspector controls look cheap */
.s5-right-panel button {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transform: none;
}
.s5-right-panel button:hover {
    transform: none;
    box-shadow: none;
}

/* ===== Left panel ==== */

/* Container Styling — translucent, no backdrop-filter (overflow + blur blocks clicks) */
.s5-settings-panel {
    width: 380px;
    height: 100%;
    position: relative;
    background: #141414;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    padding: 12px 12px 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 10px;
    z-index: 10;
    font-family: var(--font-main, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
    color: var(--text-main, #f5f5f7);
    box-sizing: border-box;
    font-variant-emoji: text;
    box-shadow: none;
}

.s5-settings-panel::-webkit-scrollbar { width: 5px; }
.s5-settings-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}
.s5-settings-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.22);
}

.s5-settings-panel * {
    box-sizing: border-box;
}

/* Global button chrome (pill + scale) would make generate / handles look cheap */
.s5-settings-panel .s5-generate-btn {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transform: none;
}

.s5-ico {
    width: 14px;
    height: 14px;
    display: block;
    flex-shrink: 0;
    color: inherit;
    pointer-events: none;
}
.s5-ref-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9a9aa0;
}
.s5-ref-box .s5-ico,
.s5-add-media-bar .s5-ico {
    width: 16px;
    height: 16px;
}
.s5-ref-box:hover .s5-ref-ico,
.s5-add-media-bar:hover .s5-ref-ico {
    color: #e8e8ea;
}
.s5-model-right .s5-ico {
    width: 14px;
    height: 14px;
}

/* Tabs — no surrounding frame */
.s5-tabs {
    display: flex;
    justify-content: stretch;
    gap: 4px;
    margin-bottom: 18px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}
.s5-tab {
    flex: 1;
    text-align: center;
    padding: 7px 8px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: #8e8e93;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.s5-tab:hover {
    color: #f5f5f7;
    background: rgba(255, 255, 255, 0.04);
}
.s5-tab.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Common Typography */
.s5-section-title {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted, #86868b);
    font-weight: 600;
    letter-spacing: 0.8px;
    margin: 2px 2px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.s5-section-title > span:last-child {
    font-variant-numeric: tabular-nums;
    color: #6e6e73;
}

/* Model Selector */
.s5-model-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 18px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #f2f2f4;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.s5-model-selector:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
}
.s5-model-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.s5-model-left [data-smp-label] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.s5-model-right {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8e8e93;
    flex-shrink: 0;
    transition: color 0.15s ease, transform 0.15s ease;
}
.s5-model-selector:hover .s5-model-right { color: #fff; }

/* References (Image & Video) */
/* کادرهای مرجع به اندازه تامنیل هستند، پس به جای گرید کشسان از چیدمان ردیفی استفاده می‌شود */
.s5-ref-grid-4,
.s5-ref-grid-2 {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.s5-ref-box {
    background: rgba(255, 255, 255, 0.045);
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px;
    font-size: 9px;
    line-height: 1.15;
    text-align: center;
    color: #9a9aa0;
    cursor: pointer;

    /* اندازه ثابت تامنیل */
    width: 64px;
    height: 64px;
    flex: 0 0 auto;
    position: relative; /* برای کنترل تصویر داخل کادر */
    overflow: hidden; /* جلوگیری از بیرون زدن تصویر از گوشه‌های گرد شده */

    /* اگر تصویر با جاوا اسکریپت به عنوان پس‌زمینه (background-image) ست می‌شود: */
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.s5-ref-box:hover {
    border-color: rgba(255, 255, 255, 0.38);
    color: #f2f2f4;
    background: rgba(255, 255, 255, 0.07);
}

/* اگر تصویر با جاوا اسکریپت به صورت یک تگ <img> داخل کادر قرار می‌گیرد: */
.s5-ref-box img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* باعث می‌شود تصویر کل کادر را بدون به هم خوردن نسبت ابعاد پر کند */
    z-index: 1;
    border-radius: 12px;
}

.s5-ref-box span { 
    margin-top: 0; 
    z-index: 2; /* برای اینکه در صورت نیاز، متن روی تصویر بماند (می‌توانید با JS آن را مخفی کنید) */
}

/* تامنیل‌های مرجعی که کاربر برای هر کادر انتخاب می‌کند، کنار همان کادر می‌نشینند */
.s5-ref-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    flex: 0 0 auto;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.s5-ref-thumb:hover { border-color: rgba(255, 255, 255, 0.5); }
.s5-ref-thumb-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 16px;
    height: 16px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: none;
}
.s5-ref-thumb:hover .s5-ref-thumb-remove { display: block; }
.s5-ref-thumb.is-audio,
.s5-ref-thumb.is-video {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #16161c;
    color: #f2f2f4;
    font-size: 18px;
}
.s5-ref-thumb.is-video {
    background-size: cover;
    background-position: center;
}
.s5-ref-thumb.is-video::after {
    content: '▶';
    position: absolute;
    inset: auto auto 4px 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 8px;
    line-height: 16px;
    text-align: center;
}
/* دکمه Add media هم‌شکل و هم‌اندازه کادرهای مرجع، کنار End image می‌نشیند */
.s5-add-media-bar {
    background: rgba(255, 255, 255, 0.045);
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px;
    width: 64px;
    height: 64px;
    flex: 0 0 auto;
    font-size: 9px;
    line-height: 1.15;
    text-align: center;
    color: #9a9aa0;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.s5-add-media-bar:hover {
    border-color: rgba(255, 255, 255, 0.38);
    color: #f2f2f4;
    background: rgba(255, 255, 255, 0.07);
}

/* با هاور، یک‌سوم پایین کادر نوار Assets می‌شود؛
   کلیک روی خود کادر فایل‌بروزر را باز می‌کند و کلیک روی Assets پیکر کتابخانه را */
.s5-split-box {
    position: relative;
    overflow: hidden;
}
.s5-ref-box .s5-ref-file-input,
.s5-add-media-bar .s5-ref-file-input {
    display: none !important;
}
.s5-ref-browse {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 33.33%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 4;
}
.s5-split-box:hover .s5-ref-browse {
    opacity: 1;
    transform: translateY(0);
}
.s5-ref-browse:hover {
    background: rgba(0, 0, 0, 0.94);
}

.s5-settings-panel.is-prompt-expanded {
    overflow: hidden;
}

/* Prompt Box */
.s5-prompt-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 14px;
    padding: 8px 10px 6px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    height: 182px;
    min-height: 182px;
    max-height: 182px;
    flex: 0 0 auto;
    position: relative;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.s5-prompt-container:focus-within {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.05);
}
.s5-prompt-container textarea,
.s5-prompt-container textarea:focus,
#s5-image-prompt,
#s5-video-prompt,
#s5-audio-prompt,
#s5-image-prompt:focus,
#s5-video-prompt:focus,
#s5-audio-prompt:focus {
    background: transparent;
    background-color: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: #fff;
    resize: none;
    flex-grow: 1;
    outline: none;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 4px;
    -webkit-appearance: none;
    appearance: none;
}
.s5-prompt-container textarea::placeholder {
    color: #6e6e73;
}
.s5-prompt-loading {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    background: rgba(12, 12, 14, 0.55);
    border-radius: 14px;
    color: #9a9a9a;
    font-size: 12px;
    letter-spacing: 0.02em;
    z-index: 6;
    pointer-events: none;
}
.s5-prompt-container.is-loading .s5-prompt-loading {
    display: flex;
}
.s5-prompt-container.is-loading .s5-prompt-footer {
    visibility: hidden;
}
.s5-prompt-container.is-loading textarea,
.s5-prompt-container.is-writing textarea {
    pointer-events: none;
}
.s5-prompt-container.is-loading textarea {
    color: transparent;
    caret-color: transparent;
}
.s5-prompt-container.is-loading textarea::placeholder {
    color: transparent;
    opacity: 0;
    -webkit-text-fill-color: transparent;
}
.s5-prompt-container.is-loading .s5-prompt-editor {
    color: transparent;
    caret-color: transparent;
}
.s5-prompt-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 16px;
}
.s5-prompt-dots i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #c8c8c8;
    animation: s5-prompt-dot 1s infinite ease-in-out;
}
.s5-prompt-dots i:nth-of-type(1) { animation-delay: 0s; }
.s5-prompt-dots i:nth-of-type(2) { animation-delay: 0.16s; }
.s5-prompt-dots i:nth-of-type(3) { animation-delay: 0.32s; }
.s5-prompt-loading-label {
    color: #8e8e93;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.04em;
}
@keyframes s5-prompt-dot {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-4px); }
}
.s5-prompt-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto;
    font-size: 11px;
    color: #8e8e93;
}
.s5-prompt-tools {
    display: flex;
    gap: 6px;
    align-items: center;
}
.s5-prompt-tools span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    color: #8e8e93;
    transition: background 0.15s ease, color 0.15s ease;
}
.s5-prompt-tools span:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.s5-prompt-tools .s5-ico {
    width: 14px;
    height: 14px;
}

.s5-prompt-highlight-wrap {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    margin-bottom: 4px;
    overflow: hidden;
}
.s5-prompt-highlight-wrap > textarea,
.s5-prompt-highlight-wrap > textarea:focus,
.s5-prompt-highlight-wrap > #s5-image-prompt,
.s5-prompt-highlight-wrap > #s5-video-prompt,
.s5-prompt-highlight-wrap > #s5-audio-prompt,
.s5-prompt-highlight-wrap > #s5-image-prompt:focus,
.s5-prompt-highlight-wrap > #s5-video-prompt:focus,
.s5-prompt-highlight-wrap > #s5-audio-prompt:focus {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}
.s5-prompt-editor {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    color: #fff;
    caret-color: #fff;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-wrap: break-word;
    outline: none;
    background: transparent;
    unicode-bidi: plaintext;
    padding-right: 26px;
}
.s5-prompt-editor::-webkit-scrollbar { width: 5px; }
.s5-prompt-editor::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 8px;
}
.s5-prompt-editor div,
.s5-prompt-editor p {
    margin: 0;
    min-height: 1.6em;
}
.s5-prompt-editor:empty::before {
    content: attr(data-placeholder);
    color: #6e6e73;
    pointer-events: none;
}
.s5-prompt-expand-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 8;
    width: 26px;
    height: 26px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #8e8e93;
    cursor: pointer;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transform: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.s5-settings-panel .s5-prompt-expand-btn,
.s5-settings-panel .s5-prompt-expand-btn:hover,
.s5-settings-panel .s5-prompt-expand-btn:active {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transform: none;
    border: none;
}
.s5-prompt-expand-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.s5-prompt-expand-btn svg {
    width: 14px;
    height: 14px;
    display: block;
}
.s5-prompt-expand-btn .s5-prompt-expand-ico-collapse {
    display: none;
}
.s5-prompt-container.is-expanded .s5-prompt-expand-btn .s5-prompt-expand-ico-expand {
    display: none;
}
.s5-prompt-container.is-expanded .s5-prompt-expand-btn .s5-prompt-expand-ico-collapse {
    display: block;
}
.s5-prompt-container.is-expanded {
    position: absolute;
    inset: 8px;
    z-index: 50;
    margin: 0;
    height: auto;
    min-height: 0;
    max-height: none;
    width: auto;
    border-radius: 16px;
    padding: 14px 14px 12px;
    background: #161618;
    border-color: rgba(255, 255, 255, 0.14);
}
.s5-prompt-container.is-expanded .s5-prompt-expand-btn {
    background: rgba(255, 255, 255, 0.08);
    color: #f2f2f4;
}
.s5-prompt-expand-spacer {
    height: 182px;
    flex: 0 0 182px;
    margin-bottom: 12px;
    pointer-events: none;
    visibility: hidden;
}
.s5-prompt-container.is-loading .s5-prompt-editor,
.s5-prompt-container.is-writing .s5-prompt-editor {
    pointer-events: none;
}
.s5-prompt-container.is-loading .s5-prompt-editor {
    color: transparent;
    caret-color: transparent;
}
.s5-prompt-container.is-loading .s5-prompt-editor::before {
    color: transparent;
}
.s5-prompt-highlight-wrap .s5-ref-chip,
.s5-prompt-editor .s5-ref-chip,
.s5g-prompt-view .s5-ref-chip {
    display: inline;
    color: #f0b429;
    background: rgba(232, 163, 23, 0.18);
    border: 0;
    border-radius: 4px;
    padding: 0 0.22em;
    margin: 0 0.02em;
    font-size: 0.92em;
    font-weight: 600;
    letter-spacing: 0;
    line-height: inherit;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
    vertical-align: baseline;
    cursor: default;
    pointer-events: auto;
}
.s5-prompt-editor .s5-ref-chip {
    cursor: pointer;
}
.s5-prompt-editor .s5-ref-chip.is-known,
.s5g-prompt-view .s5-ref-chip.is-known {
    color: #f0b429;
    background: rgba(232, 163, 23, 0.2);
}
.s5-prompt-editor .s5-ref-chip.is-missing,
.s5g-prompt-view .s5-ref-chip.is-missing {
    color: #ff453a;
    background: rgba(255, 69, 58, 0.16);
}
.s5-prompt-editor .s5-ref-chip.is-selected {
    box-shadow: 0 0 0 1px currentColor;
}
.s5-ref-tag-label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 2px 3px;
    font-size: 8px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    text-align: center;
    background: rgba(0, 0, 0, 0.62);
    pointer-events: none;
    z-index: 3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.s5-ref-box .s5-ref-tag-label {
    border-radius: 0 0 11px 11px;
}
.s5-ref-thumb .s5-ref-tag-label,
.s3-upload-thumb .s5-ref-tag-label {
    border-radius: 0 0 7px 7px;
}
.s5-ref-mention-menu {
    position: fixed;
    z-index: 12000;
    min-width: 220px;
    max-width: 280px;
    max-height: 220px;
    overflow-y: auto;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(18, 18, 22, 0.96);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(16px);
}
.s5-ref-mention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    text-align: left;
    cursor: pointer;
}
.s5-ref-mention-item.is-active,
.s5-ref-mention-item:hover {
    background: rgba(10, 132, 255, 0.18);
}
.s5-ref-mention-thumb {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08) center/cover no-repeat;
}
.s5-ref-mention-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.s5-ref-mention-copy strong {
    font-size: 12px;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.s5-ref-mention-copy em {
    font-size: 10px;
    font-style: normal;
    color: #8e8e93;
}
.s5-ref-mention-preview {
    position: fixed;
    z-index: 100200;
    width: auto;
    height: auto;
    max-width: min(320px, calc(100vw - 16px));
    max-height: min(320px, calc(100vh - 16px));
    padding: 6px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(12, 12, 16, 0.96);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}
.s5-ref-mention-preview img {
    display: block;
    width: auto;
    height: auto;
    max-width: min(308px, calc(100vw - 28px));
    max-height: min(308px, calc(100vh - 28px));
    object-fit: contain;
    object-position: center;
    border-radius: 10px;
}

/* Toggle Switch (AI Prompt) */
.s5-toggle-wrap { display: flex; align-items: center; gap: 8px; color: #aaa; font-size: 12px;}
.s5-toggle {
    width: 32px; height: 18px;
    background: #444;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
}
.s5-toggle::after {
    content: ''; position: absolute;
    top: 2px; left: 2px; width: 14px; height: 14px;
    background: #fff; border-radius: 50%;
}

/* Control Row */
.s5-controls-row {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}
.s5-control-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    padding: 8px 4px;
    color: #e8e8ea;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.1px;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.s5-control-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
}
.s5-prompt-clear-btn {
    cursor: pointer;
}
.s5-prompt-clear-btn:hover {
    color: #fff;
}
#s5-image-count-minus,
#s5-image-count-plus {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #9a9aa0;
}
#s5-image-count-minus:hover,
#s5-image-count-plus:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
#s5-image-count {
    min-width: 1.2em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.s5-control-btn-dropdown {
    position: relative;
}
.s5-control-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 80px;
    max-height: 180px;
    overflow-y: auto;
    background: rgba(22, 22, 24, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 4px;
    z-index: 80;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.s5-control-dropdown.active {
    display: block;
}
.s5-control-dropdown-item {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: #ddd;
    font-size: 11px;
    padding: 7px 10px;
    border-radius: 7px;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
}
.s5-control-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.s5-ref-box.s5-ref-clickable {
    cursor: pointer;
}
.s5-clip.s5-clip-reordering {
    opacity: 0.85;
    z-index: 20;
    cursor: grabbing;
    box-shadow: 0 6px 18px rgba(0,0,0,0.55);
}

/* Generate Button — sits between model controls and the Image / Video / Sound / Agent tabs */
.s5-generate-btn {
    background: #f4f4f5;
    color: #111;
    border: 0;
    border-radius: 14px;
    padding: 0 16px 0 18px;
    width: 100%;
    min-height: 48px;
    height: 48px;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0.01em;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
    transition: background 0.16s ease, box-shadow 0.16s ease;
}
.s5-generate-btn:hover {
    background: #fff;
    color: #111;
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.42);
}
.s5-generate-btn:active,
.s5-generate-btn:disabled {
    background: #1c1c20;
    color: #f4f4f5;
    transform: translateY(0);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    opacity: 1;
}
.s5-generate-btn[hidden] { display: none !important; }
html:not(.app-phone) #s5-generate-btn .s5-generate-arrow { display: none; }
.s5-generate-label {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0.01em;
    color: inherit;
}
.s5-generate-credits {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
    border-radius: 0;
    padding: 0;
    background: transparent;
    color: #9a6708;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}
.s5-generate-btn:hover .s5-generate-credits {
    background: transparent;
    color: #7c5206;
}
.s5-generate-btn:active .s5-generate-credits,
.s5-generate-btn:disabled .s5-generate-credits {
    background: transparent;
    color: #e4c56a;
}

/* History Section */
.s5-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin-bottom: 16px;
}
.s5-history-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.s5-history-item:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
}
.s5-history-thumb {
    width: 50px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    background: #2a2a2c;
}
.s5-history-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.s5-history-version { color: #ececee; font-size: 13px; font-weight: 550; }
.s5-history-model { color: #8e8e93; font-size: 11px; }

/* ========= */


.s5-editor-container { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    gap: 15px;
    min-width: 0;
    user-select: none; 
}

/* ===== PREVIEW AREA ===== */
.s5-preview-area { 
    position: relative; 
    background: rgba(0, 0, 0, 0.4); 
    border-radius: 20px; 
    overflow: hidden; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    width: 100%; 
    flex: 1; 
    min-height: 0;
    aspect-ratio: 16 / 9; 
    margin: 0 auto; 
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}
.s5-preview-area video { width: 100%; height: 100%; object-fit: contain; pointer-events: auto; cursor: pointer; transition: none; position: absolute; top: 0; left: 0;}
.s5-play-overlay {
    position: absolute;
    inset: 0;
    font-size: 80px;
    color: rgba(255,255,255,0.8);
    text-shadow: 0 4px 20px rgba(0,0,0,0.8);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.s5-preview-area.s5-show-play-chrome .s5-play-overlay {
    opacity: 1;
}

/* تایم‌کد شناور پایین پیش‌نمایش: با ورود موس یا فول‌اسکرین محو می‌شود */
.s5-preview-timecode {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    padding: 9px 22px;
    border-radius: 14px;
    background: rgba(8, 8, 10, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    color: #f2f2f2;
    font-family: 'Courier New', monospace;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.18s ease;
}
.s5-preview-area:hover .s5-preview-timecode,
.s5-preview-area:fullscreen .s5-preview-timecode {
    opacity: 0;
}

/* ===== TIMELINE ===== */
.s5-timeline-layout { 
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2); 
    border: 1px solid rgba(255, 255, 255, 0.05); 
    border-radius: 20px; 
    overflow: hidden; 
    height: 230px; 
    flex-shrink: 0;
    backdrop-filter: blur(10px);
    --s5-track-height: 50px;
}
.s5-timeline-top-row {
    display: flex;
    flex-shrink: 0;
    height: 25px;
    background: rgba(20,20,20,0.95);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    z-index: 45;
}
.s5-top-gutter {
    width: 80px;
    flex-shrink: 0;
    height: 25px;
}
.s5-top-gutter-end {
    width: 40px;
}
.s5-ruler-viewport {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    position: relative;
    height: 25px;
    cursor: text;
}
.s5-fixed-headers, .s5-fixed-tails { 
    display: flex; flex-direction: column;
    background: rgba(255,255,255,0.02); position: relative; z-index: 10;
    flex-shrink: 0;
}
.s5-fixed-headers {
    border-right: 1px solid rgba(255,255,255,0.05);
    width: 80px;
    height: max-content;
    min-height: 100%;
}
.s5-fixed-tails {
    border-left: 1px solid rgba(255,255,255,0.05);
    width: 40px;
    align-self: flex-start;
    position: sticky;
    top: 0;
    height: 100%;
    max-height: 100%;
    justify-content: flex-start;
}
.s5-timeline-tools {
    position: sticky;
    top: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
    z-index: 30;
}
.s5-tl-tool-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 7px;
    background: rgba(0,0,0,0.35);
    color: #9a9a9a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}
.s5-tl-tool-btn:hover { color: #fff; border-color: rgba(255,255,255,0.28); }
.s5-tl-tool-btn.active {
    color: #fff;
    border-color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.12);
}
.s5-tl-tool-add-wrap { position: relative; }
.s5-tl-add-menu {
    position: absolute;
    right: calc(100% + 6px);
    top: 0;
    min-width: 168px;
    background: rgba(22, 22, 24, 0.98);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.5);
    z-index: 80;
}
.s5-tl-add-menu[hidden] { display: none; }
.s5-tl-add-item {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: #ddd;
    font-size: 12px;
    text-align: left;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.s5-tl-add-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.s5-tl-vzoom {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
    margin-top: auto;
    padding: 0 0 8px;
    border: none;
    background: transparent;
}
.s5-tl-vzoom button {
    width: 28px;
    height: 22px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #8a8a8a;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: none;
    padding: 0;
}
.s5-tl-vzoom button:hover { color: #fff; background: transparent; border: none; }
#s5-timeline-inner[data-s5-tool="cut"] { cursor: crosshair; }
#s5-timeline-inner[data-s5-tool="cut"] .s5-clip,
#s5-timeline-inner[data-s5-tool="cut"] .s5-audio-block {
    cursor: cell;
}

/* ستون‌های تایم‌لاین با هم به صورت عمودی اسکرول می‌شوند؛ خط‌کش و اسکرول افقی بیرون این ناحیه می‌مانند */
.s5-timeline-tracks-scroll {
    display: flex;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    align-items: flex-start;
}
.s5-timeline-tracks-scroll::-webkit-scrollbar { width: 6px; }
.s5-timeline-tracks-scroll::-webkit-scrollbar-track { background: transparent; }
.s5-timeline-tracks-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.s5-timeline-tracks-scroll { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent; }
.s5-timeline-container {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    cursor: text;
    display: flex;
    flex-direction: column;
    height: max-content;
    min-height: 100%;
    min-width: 0;
    scrollbar-width: none;
}
.s5-timeline-container::-webkit-scrollbar { display: none; height: 0; }

.s5-timeline-hscroll-row {
    display: flex;
    flex-shrink: 0;
    height: 10px;
    background: transparent;
    z-index: 46;
}
.s5-hscroll-gutter {
    width: 80px;
    flex-shrink: 0;
}
.s5-hscroll-gutter-end {
    width: 48px; /* 40px tail + ~8px vertical scrollbar */
}
.s5-timeline-hscroll {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.s5-timeline-hscroll::-webkit-scrollbar { height: 6px; }
.s5-timeline-hscroll::-webkit-scrollbar-track { background: transparent; }
.s5-timeline-hscroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.s5-timeline-hscroll-spacer { height: 1px; pointer-events: none; }

.s5-timeline-inner { 
    position: relative; 
    min-width: 100%; 
    width: max-content;
    flex: none;
    display: flex;
    flex-direction: column;
    height: max-content;
    min-height: 100%;
}

/* نوار بالای ستون دکمه‌ها که هم‌ارتفاع خط‌کش زمان است تا ردیف‌ها روبروی هم بمانند */
.s5-track-spacer {
    height: 25px;
    flex-shrink: 0;
    background: rgba(20,20,20,0.95);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.s5-video-buffer {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}
.s5-hdr-cell { display: flex; align-items: center; justify-content: space-between; width: 100%; margin:0; padding: 0 10px; box-sizing: border-box; flex-shrink: 0;}
.s5-tail-cell { display: flex; align-items: center; justify-content: center; width: 100%; margin:0; padding:0; flex-shrink: 0;}
.s5-track-wrapper { margin: 0; padding: 0; border: none; flex-shrink: 0; }
.s5-track-mixer-btns {
    display: flex;
    gap: 3px;
    align-items: center;
    justify-content: center;
}
.s5-track-btn {
    min-width: 18px;
    height: 16px;
    padding: 0 4px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.35);
    color: #666;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: 0.15s;
}
.s5-track-btn:hover { color: #ddd; border-color: rgba(255,255,255,0.28); }
.s5-mute-btn.muted { color: #ff6b6b; border-color: rgba(255,107,107,0.45); background: rgba(255,80,80,0.12); }
.s5-solo-btn.solo-active { color: #f5d90a; border-color: rgba(245,217,10,0.55); background: rgba(245,217,10,0.12); }

.s5-add-track-btn { width: 20px; height: 20px; background: transparent; border: none; color: #777; cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; box-shadow: none;}
.s5-add-track-btn:hover { color: #fff; }

.s5-track-wrapper.video, .s5-hdr-cell.video, .s5-tail-cell.video { height: var(--s5-track-height, 50px); }
.s5-track-wrapper.audio, .s5-hdr-cell.audio, .s5-tail-cell.audio { height: var(--s5-track-height, 50px); } 

/* Clips & Playhead */
.s5-clip { position: absolute; top: 0; left: 0; height: 100%; cursor: grab; border: 1px solid rgba(255,255,255,0.1); opacity: 0.7; transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s; box-sizing: border-box; overflow: hidden; flex-shrink: 0; background: #000; border-radius: 6px; }
.s5-kf-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 16;
}
.s5-kf-mark {
    position: absolute;
    width: 18px;
    height: 18px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    pointer-events: auto;
    cursor: ew-resize;
    transform: translate(-50%, -50%);
    z-index: 16;
    user-select: none;
    -webkit-user-drag: none;
}
.s5-kf-mark::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: #4a5d6c;
    border: 1.5px solid rgba(214, 224, 232, 0.92);
    transform: rotate(45deg);
    border-radius: 1px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
}
.s5-kf-mark:hover::after,
.s5-kf-mark.selected::after {
    background: #6b8294;
    border-color: #f0f4f7;
}
.s5-kf-mark.on-playhead::after {
    background: #7d93a4;
    border-color: #f4f7fa;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 5px rgba(180, 198, 210, 0.45);
}
.s5-audio-block { position: absolute; top: 0; height: 100%; background: rgba(255,255,255,0.1); border-radius: 6px; cursor: grab; overflow: hidden; display: block; opacity: 0.8; border: 1px solid rgba(255,255,255,0.2);}
.s5-audio-generating-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 11px;
    letter-spacing: 0.02em;
    pointer-events: none;
    z-index: 3;
}
.s5-audio-block.s5-audio-generating {
    opacity: 0.7;
}

.s5-ruler { position: relative; z-index: 40; height: 25px; pointer-events: none; background: transparent; min-width: 100%;}
.s5-ruler-tick { position: absolute; bottom: 0; width: 1px; background: rgba(255,255,255,0.2); height: 6px; }
.s5-ruler-tick.major { height: 12px; background: rgba(255,255,255,0.4); }
.s5-ruler-time { position: absolute; bottom: 12px; font-size: 10px; color: #999; transform: translateX(-50%); }

.s5-playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: #fff; z-index: 50; pointer-events: none; box-shadow: 0 0 10px rgba(255,255,255,0.5); }
.s5-playhead::before { content: none; }
.s5-ruler-playhead { bottom: auto; height: 25px; }
.s5-ruler-playhead::before {
    content: '';
    position: absolute;
    top: 0;
    left: -5px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #fff;
}
.s5-marquee {
    position: absolute;
    border: 1px solid rgba(255,255,255,0.55);
    background: rgba(255,255,255,0.08);
    pointer-events: none;
    z-index: 55;
    box-sizing: border-box;
}
.s5-context-sep {
    height: 1px;
    margin: 4px 6px;
    background: rgba(255,255,255,0.1);
}

.s5-video-track { display: block; height: 100%; position: relative; }

.s5-clip:active { cursor: grabbing; }
/* کلیپی که نوار لغزنده روی آن است فقط روشن‌تر می‌شود؛ قاب سفید مخصوص کلیپ انتخاب‌شده است */
.s5-clip.playing:not(.s5-clip-gen-pending):not(.s5-clip-gen-ready) {
    opacity: 1;
    border-color: rgba(255,255,255,0.35);
}
.s5-clip[data-clip-color] {
    border-color: var(--s5-clip-color);
}
.s5-clip.playing[data-clip-color]:not(.s5-clip-gen-pending):not(.s5-clip-gen-ready) {
    border-color: var(--s5-clip-color);
}
.selected-clip:not(.s5-clip-gen-pending):not(.s5-clip-gen-ready) {
    border: 2px solid #fff;
    opacity: 1;
    z-index: 5;
    box-shadow: 0 0 15px rgba(255,255,255,0.3);
}
.s5-clip.selected-clip[data-clip-color]:not(.s5-clip-gen-pending):not(.s5-clip-gen-ready) {
    border: 2px solid var(--s5-clip-color);
    box-shadow: 0 0 15px color-mix(in srgb, var(--s5-clip-color) 45%, transparent);
}
.s5-audio-block[data-clip-color],
.s5-audio-block[data-wave-color] {
    border-color: rgba(255,255,255,0.2);
}
.s5-audio-block.selected-clip:not(.s5-clip-gen-pending):not(.s5-clip-gen-ready) {
    border: 2px solid #fff;
}
.s5-clip.s5-clip-gen-pending {
    border: 2px solid #ff9800 !important;
    box-shadow: 0 0 12px rgba(255, 152, 0, 0.45);
    opacity: 1;
    z-index: 4;
}
.s5-clip.s5-clip-gen-ready {
    border: 2px solid #4caf50 !important;
    box-shadow: 0 0 12px rgba(76, 175, 80, 0.4);
    opacity: 1;
    z-index: 4;
}
.s5-clip.s5-clip-uploading,
.s5-audio-block.s5-clip-uploading {
    --s5-upload: 0%;
    opacity: 1;
}
.s5-clip.s5-clip-uploading.selected-clip,
.s5-audio-block.s5-clip-uploading.selected-clip {
    opacity: 1;
}
.s5-clip.s5-clip-uploading::after,
.s5-audio-block.s5-clip-uploading::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.72);
    clip-path: inset(0 0 0 var(--s5-upload, 0%));
    transition: clip-path 0.16s linear;
}
.s5-clip.s5-clip-uploading::before,
.s5-audio-block.s5-clip-uploading::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--s5-upload, 0%);
    width: 2px;
    transform: translateX(-1px);
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.25);
    z-index: 9;
    pointer-events: none;
    transition: left 0.16s linear;
}
.s5-clip img { width: 100%; height: 100%; object-fit: cover; opacity: 0.8; }
.s5-clip.playing img { opacity: 1; }

.s5-clip,
.s5-audio-block {
    --s5-trim-l: 0;
    --s5-trim-r: 0;
    --s5-trim-hit: 6px;
}
.s5-trim-handle, .s5-audio-trim-handle {
    position: absolute;
    top: 0; bottom: 0;
    width: var(--s5-trim-hit, 6px);
    cursor: ew-resize;
    z-index: 10;
    pointer-events: auto;
    background: transparent;
    opacity: 1;
}
.s5-trim-handle.left, .s5-audio-trim-handle.left {
    left: 0;
}
.s5-trim-handle.right, .s5-audio-trim-handle.right {
    right: 0;
}
#s5-timeline-inner .s5-audio-trim-handle:hover {
    background: transparent;
}
.s5-trim-handle::before,
.s5-audio-trim-handle::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 26px;
    pointer-events: none;
    background: transparent;
}
.s5-trim-handle.left::before,
.s5-audio-trim-handle.left::before,
#s5-timeline-inner .s5-audio-trim-handle.left:hover::before {
    left: 0;
    opacity: var(--s5-trim-l, 0);
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0.8) 0%,
        rgba(255, 255, 255, 0.28) 42%,
        rgba(255, 255, 255, 0) 100%
    );
}
.s5-trim-handle.right::before,
.s5-audio-trim-handle.right::before,
#s5-timeline-inner .s5-audio-trim-handle.right:hover::before {
    right: 0;
    left: auto;
    opacity: var(--s5-trim-r, 0);
    background: linear-gradient(
        to left,
        rgba(255, 255, 255, 0.8) 0%,
        rgba(255, 255, 255, 0.28) 42%,
        rgba(255, 255, 255, 0) 100%
    );
}
body.s5-is-trimming .s5-trim-handle,
body.s5-is-trimming .s5-audio-trim-handle,
body.s5-is-trimming .s5-trim-handle:hover,
body.s5-is-trimming .s5-audio-trim-handle:hover,
#s5-timeline-inner.s5-is-trimming .s5-trim-handle,
#s5-timeline-inner.s5-is-trimming .s5-audio-trim-handle {
    opacity: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}
body.s5-is-trimming .s5-fade-handle,
body.s5-is-trimming .s5-audio-volume-line,
#s5-timeline-inner.s5-is-trimming .s5-fade-handle,
#s5-timeline-inner.s5-is-trimming .s5-audio-volume-line {
    opacity: 0 !important;
    visibility: hidden;
}
body.s5-is-trimming .selected-clip:not(.s5-clip-gen-pending):not(.s5-clip-gen-ready),
#s5-timeline-inner.s5-is-trimming .selected-clip:not(.s5-clip-gen-pending):not(.s5-clip-gen-ready) {
    box-shadow: none !important;
    border-width: 1px;
    border-color: rgba(255, 255, 255, 0.22);
}
body.s5-is-trimming .s5-is-trim-target.selected-clip:not(.s5-clip-gen-pending):not(.s5-clip-gen-ready) {
    box-shadow: none !important;
    border-width: 1px;
    border-color: rgba(255, 255, 255, 0.18);
}



/* ===== SETTINGS PANELS DETAILS ===== */
.s5-global-timecode { font-family: 'Courier New', monospace; font-size: 24px; color: #fff; text-align: center; background: rgba(0,0,0,0.4); padding: 10px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); font-weight: bold; letter-spacing: 2px; margin-bottom: 10px; box-shadow: inset 0 0 10px rgba(0,0,0,0.5);}

.s5-generate-btn { width: 100%; margin-top: 0; }

.s5-inspector-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #888;
    padding: 2px 28px 4px 2px;
}
.s5-clip-settings {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-height: 0;
}
#s5-video-clip-settings-panel,
#s5-audio-clip-settings-panel {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.s5-clip-settings h4,
.s5-audio-clip-settings-panel h4 {
    color: #fff;
    font-size: 11px;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.s5-param {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 2px 2px 4px;
}
.s5-param-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    color: #9a9a9e;
    letter-spacing: 0.2px;
}
.s5-param-header input {
    width: 54px;
    height: 22px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: #f2f2f2;
    background: #232324;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 7px;
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.s5-param-header input:focus {
    border-color: rgba(255, 255, 255, 0.28);
    background: #2a2a2b;
}
.s5-input-group { display: flex; gap: 4px; align-items: center; }
.s5-reset-icon,
.s5-audio-reset-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    font-size: 13px;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease, transform 0.2s ease;
    user-select: none;
}
.s5-reset-icon:hover,
.s5-audio-reset-icon:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    transform: rotate(-90deg);
}
.s5-kf-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #555;
    border-radius: 6px;
    flex-shrink: 0;
    transition: color 0.15s ease, background 0.15s ease;
}
.s5-kf-icon svg {
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.35;
}
.s5-kf-icon:hover {
    color: #ddd;
    background: rgba(255, 255, 255, 0.08);
}
.s5-kf-icon.has-keys {
    color: #9a9a9a;
}
.s5-kf-icon.has-keys svg {
    fill: rgba(255, 255, 255, 0.12);
}
.s5-kf-icon.on-key {
    color: #6ecbff;
}
.s5-kf-icon.on-key svg {
    fill: currentColor;
    stroke: currentColor;
}

.s5-param input[type="range"],
.s5-intensity-slider,
.s5-effect-mini-param input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 14px;
    background: transparent;
    padding: 0;
    border: none;
    margin: 0;
    outline: none;
    cursor: pointer;
}
.s5-param input[type="range"]::-webkit-slider-runnable-track,
.s5-intensity-slider::-webkit-slider-runnable-track,
.s5-effect-mini-param input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 3px;
    cursor: pointer;
    background: #2e2e30;
    border-radius: 99px;
}
.s5-param input[type="range"]::-webkit-slider-thumb,
.s5-intensity-slider::-webkit-slider-thumb,
.s5-effect-mini-param input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 12px;
    width: 12px;
    border-radius: 50%;
    background: #f5f5f7;
    border: none;
    cursor: pointer;
    margin-top: -4.5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    transition: transform 0.12s ease;
}
.s5-param input[type="range"]::-webkit-slider-thumb:hover,
.s5-intensity-slider::-webkit-slider-thumb:hover,
.s5-effect-mini-param input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.12);
}
.s5-param input[type="range"]::-moz-range-track,
.s5-intensity-slider::-moz-range-track,
.s5-effect-mini-param input[type="range"]::-moz-range-track {
    height: 3px;
    background: #2e2e30;
    border: none;
    border-radius: 99px;
}
.s5-param input[type="range"]::-moz-range-thumb,
.s5-intensity-slider::-moz-range-thumb,
.s5-effect-mini-param input[type="range"]::-moz-range-thumb {
    height: 12px;
    width: 12px;
    border: none;
    border-radius: 50%;
    background: #f5f5f7;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* ===== color wheels ===== */
.s5-color-wheels-container {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin: 0 0 8px;
    padding: 10px 8px 12px;
    background: #1c1c1d;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
}

.s5-wheel-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 0;
    min-width: 0;
}

.s5-wheel-box span {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: #8e8e93;
}
.s5-wheel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 8px;
    gap: 3px;
    white-space: nowrap;
}
.s5-wheel-reset {
    width: 18px;
    height: 18px;
    background: transparent;
    border: none;
    border-radius: 5px;
    color: #666;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
}
.s5-wheel-reset:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    transform: none;
}

.s5-wheel-wrapper {
    position: relative;
    width: 100%;
    max-width: 72px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.12);
    cursor: crosshair;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35), 0 4px 12px rgba(0,0,0,0.35);
    touch-action: none;
    overflow: hidden;
    background: #111;
    user-select: none;
}

.s5-wheel-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    pointer-events: none;
}

.s5-wheel-crosshair {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(to right, transparent calc(50% - 0.5px), rgba(255,255,255,0.28) calc(50% - 0.5px), rgba(255,255,255,0.28) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
        linear-gradient(to bottom, transparent calc(50% - 0.5px), rgba(255,255,255,0.28) calc(50% - 0.5px), rgba(255,255,255,0.28) calc(50% + 0.5px), transparent calc(50% + 0.5px));
    opacity: 0.7;
}

.s5-wheel-thumb {
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.65), 0 2px 6px rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}
.s5-wheel-thumb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}

.s5-wheel-meta {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.2px;
    color: #8e8e93;
}
.s5-intensity-slider {
    width: 100%;
    margin-top: 2px;
}

/* Filter Grid */
.s5-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 2px;
}
.s5-filter-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-end;
    height: 48px;
    padding: 0 4px 6px;
    overflow: hidden;
    background: #1c1c1d;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    text-align: center;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.15;
    cursor: pointer;
    color: #9a9a9e;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.s5-filter-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 16px;
    pointer-events: none;
}
.s5-filter-item[data-preset="none"]::before { background: linear-gradient(90deg, #5a5a5a, #d8d8d8, #5a5a5a); }
.s5-filter-item[data-preset="vivid"]::before { background: linear-gradient(90deg, #2f6bff, #ff3b5c, #ffcc33); }
.s5-filter-item[data-preset="vivid-warm"]::before { background: linear-gradient(90deg, #ff7a3c, #ff4d6d, #ffd166); }
.s5-filter-item[data-preset="cine-teal"]::before { background: linear-gradient(90deg, #1c6b73, #2a3a44, #c47a3a); }
.s5-filter-item[data-preset="dramatic"]::before { background: linear-gradient(90deg, #1a1f3a, #4a3a6a, #0d0d12); }
.s5-filter-item[data-preset="dram-warm"]::before { background: linear-gradient(90deg, #3a2418, #b45a2a, #1a100c); }
.s5-filter-item[data-preset="cine-warm"]::before { background: linear-gradient(90deg, #6b4a28, #e0b070, #3a2a18); }
.s5-filter-item[data-preset="mono"]::before { background: linear-gradient(90deg, #222, #bbb, #222); }
.s5-filter-item[data-preset="noir"]::before { background: linear-gradient(90deg, #050508, #8899aa, #000); }
.s5-filter-item:hover {
    border-color: rgba(255, 255, 255, 0.22);
    color: #fff;
    background: #232324;
}
.s5-filter-item.active {
    background: #fff;
    color: #111;
    border-color: #fff;
    font-weight: 700;
}

/* Sub-Controls */
.s5-prompt-actions button.outline { padding: 8px; font-size: 11px; border-radius: 12px;}
.s5-model-select { display: flex; align-items: center; justify-content: space-between; margin-top: 5px; font-size: 12px; color: #ccc; }
.s5-model-select select { width: 120px; padding: 8px; font-size: 12px; border-radius: 12px;}

.s5-cam-selector { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.1); padding: 14px; border-radius: 16px; cursor: pointer; text-align: center; color: #fff; font-size: 13px; transition: 0.2s;}
.s5-cam-selector:hover { border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.05);}
.s5-cam-grid { display: none; position: absolute; bottom: 100%; left: 0; width: 100%; background: rgba(20,20,20,0.95); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 10px; grid-template-columns: repeat(3, 1fr); gap: 6px; z-index: 50; backdrop-filter: blur(20px); margin-bottom: 5px;}
.s5-cam-grid.active { display: grid; }
.s5-cam-item { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.05); height: 40px; display: flex; align-items: center; justify-content: center; font-size: 10px; text-align: center; border-radius: 8px; cursor: pointer; transition: 0.2s;}
.s5-cam-item:hover { background: #fff; color: #000; }

.s5-history-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    max-height: none;
    margin-top: 0;
    padding-right: 2px;
}
.s5-history-list::-webkit-scrollbar { width: 5px; }
.s5-history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}
.s5-history-thumb-wrap {
    position: relative;
    width: 50px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #222;
}
.s5-history-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
}
.s5-history-spinner .spinner {
    width: 18px;
    height: 18px;
    border-width: 2px;
}
.s5-image-ref-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 4px;
    min-height: 0;
}
.s5-image-ref-previews .s3-upload-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
}

.s5-style-picker,
.s5-style-picker * {
    box-sizing: border-box;
}
.s5-style-picker {
    position: fixed;
    z-index: 48;
    top: 72px;
    bottom: 84px;
    left: calc(var(--studio-rail-width, 76px) + var(--s5-settings-width, 380px) + 16px);
    width: min(720px, calc(100vw - var(--studio-rail-width, 76px) - var(--s5-settings-width, 380px) - 36px));
    margin: 0;
    padding: 16px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-radius: 22px;
    background: #141416;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}
.s5-style-picker[hidden] { display: none !important; }
.s5-style-picker-search-wrap {
    position: relative;
    display: block;
    flex: 0 0 auto;
}
.s5-style-picker-search-wrap svg {
    position: absolute;
    left: 14px;
    top: 50%;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    color: #8e8e93;
    pointer-events: none;
}
.s5-style-picker-search {
    width: 100%;
    height: 44px;
    margin: 0;
    padding: 0 14px 0 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: #f5f5f7;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    box-shadow: none;
}
.s5-style-picker-search::placeholder { color: #6e6e73; }
.s5-style-picker-search:focus {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}
.s5-style-picker-tabs {
    display: flex;
    gap: 6px;
    margin: 0;
    flex: 0 0 auto;
}
.s5-style-picker-tabs button,
.s5-style-picker-tabs button:hover,
.s5-style-picker-tabs button:active {
    flex: 1;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #9a9aa0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    transform: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.s5-style-picker-tabs button.is-active,
.s5-style-picker-tabs button.is-active:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #f5f5f7;
}
.s5-style-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 16px 12px;
    align-content: start;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 4px 4px 8px;
}
.s5-style-picker-grid::-webkit-scrollbar { width: 8px; }
.s5-style-picker-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 8px;
}
.s5-style-picker-empty {
    grid-column: 1 / -1;
    margin: 28px 0;
    text-align: center;
    font-size: 13px;
    color: #86868b;
}
.s5-style-picker-tile,
.s5-style-picker-tile:hover,
.s5-style-picker-tile:focus,
.s5-style-picker-tile:active {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 4px 2px 2px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    box-shadow: none;
    transform: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    outline: none;
    cursor: pointer;
    color: #c7c7cc;
    transition: none;
}
.s5-style-picker-cover {
    width: 100%;
    aspect-ratio: 1;
    height: auto;
    border-radius: 18px;
    background: #1c1c1e center/cover no-repeat;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
    transition: box-shadow 0.32s ease;
}
.s5-style-picker-tile:hover .s5-style-picker-cover,
.s5-style-picker-tile:focus-visible .s5-style-picker-cover {
    box-shadow:
        0 0 26px 3px rgba(255, 255, 255, 0.34),
        0 12px 24px rgba(0, 0, 0, 0.35);
}
.s5-style-picker-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: radial-gradient(circle at 30% 20%, #3a3a3c, #1c1c1e);
}
.s5-style-picker-tile.is-selected .s5-style-picker-cover {
    box-shadow:
        0 0 22px 2px rgba(255, 255, 255, 0.42),
        0 10px 22px rgba(0, 0, 0, 0.4);
}
.s5-style-picker-tile.is-selected:hover .s5-style-picker-cover {
    box-shadow:
        0 0 30px 4px rgba(255, 255, 255, 0.5),
        0 12px 24px rgba(0, 0, 0, 0.4);
}
.s5-style-picker-custom .s5-style-picker-cover,
.s5-style-picker-custom:hover .s5-style-picker-cover {
    border: 1.4px dashed rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.04);
    color: #c7c7cc;
}
.s5-style-picker-custom:hover .s5-style-picker-cover {
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.16);
}
.s5-style-picker-name {
    max-width: 100%;
    font-size: 12px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
.s5-style-picker-drop,
.s5-style-picker-drop:hover,
.s5-style-picker-drop:active {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 52px;
    margin-top: 0;
    padding: 10px;
    border-radius: 14px;
    border: 1.4px dashed rgba(255, 255, 255, 0.22);
    background: transparent;
    color: #9a9aa0;
    font-size: 13px;
    cursor: pointer;
    box-shadow: none;
    transform: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    flex: 0 0 auto;
}
.s5-style-picker-drop:hover,
.s5-style-picker-drop.is-dragover {
    border-color: rgba(255, 255, 255, 0.5);
    color: #f5f5f7;
    background: rgba(255, 255, 255, 0.05);
}
.s5-style-picker-drop.is-busy { opacity: 0.7; pointer-events: none; }
#s5-image-ref-style.has-style {
    border-style: solid;
    color: transparent;
}
#s5-image-ref-style.has-style span { opacity: 0; pointer-events: none; }
#s5-image-ref-style .s5-style-box-clear {
    position: absolute;
    top: 3px;
    right: 3px;
    z-index: 4;
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    padding: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 11px;
    line-height: 16px;
    cursor: pointer;
}
.s3-style-block .mini-thumb {
    width: 48px;
    height: 48px;
    border-radius: 10px;
}
.s5-history-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }

/* ===== BOTTOM CONTROLS ===== */
.s5-bottom-center-tools {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 58px;
    overflow: visible;
}
.s5-stage-nav {
    padding-left: 28px;
    padding-right: 28px;
    gap: 12px;
    overflow: visible;
}
.s5-zoom-controls {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: rgba(0,0,0,0.3);
    padding: 6px 14px;
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    min-width: min(520px, 72vw);
    overflow: visible;
}
.s5-toolbar-segment {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.s5-toolbar-left { justify-content: flex-start; padding-right: 36px; }
.s5-toolbar-right { justify-content: flex-end; padding-left: 36px; }
.s5-tool-divider {
    width: 1px;
    height: 16px;
    background: rgba(255,255,255,0.1);
    margin: 0 2px;
}
.s5-zoom-label {
    color: #aaa;
    font-size: 12px;
    margin-right: 2px;
}
.s5-timeline-play-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) !important;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: #fff;
    box-shadow: 0 6px 24px rgba(0,0,0,0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 8;
    padding: 0;
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}
.s5-timeline-play-btn:hover,
.s5-timeline-play-btn:focus,
.s5-timeline-play-btn:active {
    transform: translate(-50%, -50%) !important;
    filter: brightness(0.96);
    box-shadow: 0 8px 26px rgba(0,0,0,0.5);
}

.s5-zoom-btn { background: transparent; box-shadow: none; border: none; color: #ccc; width: 28px; height: 28px; padding: 0 !important; border-radius: 50%; cursor: pointer; font-size: 16px; display: flex; justify-content: center; align-items: center; transform: none !important;}
.s5-zoom-btn:hover { background: rgba(255,255,255,0.1); color: #fff; transform: none !important;}
.s5-save-btn svg {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    flex-shrink: 0;
    display: block;
    overflow: visible;
}
.s5-save-btn.is-saving { opacity: 0.55; pointer-events: none; }
.s5-save-btn.is-saved { color: #7dffa0; }
.s5-save-btn.is-error { color: #ff6b6b; }
.s5-save-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.s5-autosave-pop {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(6px);
    display: none;
    align-items: center;
    gap: 8px;
    padding: 7px 8px 7px 7px;
    border-radius: 14px;
    background: rgba(16, 16, 20, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    z-index: 80;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
}
.s5-save-wrap.is-open .s5-autosave-pop {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}
.s5-autosave-toggle {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.62);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.02em;
    padding: 5px 9px;
    border-radius: 999px;
    cursor: pointer;
    line-height: 1;
    transform: none !important;
    box-shadow: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.s5-autosave-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.88);
}
.s5-autosave-toggle.is-on {
    color: #111;
    background: #fff;
    border-color: #fff;
}
.s5-autosave-toggle.is-on:hover {
    background: #fff;
    color: #111;
}
.s5-autosave-mins {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    font-weight: 600;
}
.s5-autosave-mins input {
    width: 42px;
    height: 24px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 0 4px;
    outline: none;
}
.s5-autosave-mins input:focus {
    border-color: rgba(255, 255, 255, 0.32);
}
.s5-autosave-mins input::-webkit-outer-spin-button,
.s5-autosave-mins input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.s5-autosave-mins input[type='number'] {
    -moz-appearance: textfield;
    appearance: textfield;
}
.s5-tool-btn {
    background: transparent;
    border: none;
    color: #ccc;
    width: 28px;
    height: 28px;
    padding: 0 !important;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: none !important;
}
.s5-tool-btn:hover { background: rgba(255,255,255,0.1); color: #fff; transform: none !important; }
.s5-volume-wrapper { position: relative; display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; cursor: pointer; color: #ccc; font-size: 18px; transition: 0.2s; z-index: 80;}
.s5-volume-wrapper:hover { color: #fff; }
.s5-vol-slider-container { position: absolute; bottom: 38px; left: 50%; transform: translateX(-50%); background: rgba(20,20,20,0.95); padding: 12px 0; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); display: none; width: 36px; height: 110px; z-index: 200; backdrop-filter: blur(10px); overflow: hidden;}
.s5-volume-wrapper.open .s5-vol-slider-container { display: block; }
.s5-vol-slider-container::before {
    content: '';
    position: absolute;
    left: -12px;
    right: -12px;
    bottom: -8px;
    top: -8px;
    pointer-events: none;
}
.s5-vol-slider-container input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 86px;
    height: 18px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(-90deg);
}
.s5-vol-slider-container input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255,255,255,0.28);
    border-radius: 2px;
}
.s5-vol-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    margin-top: -4px;
    border: none;
}
.s5-vol-slider-container input[type="range"]::-moz-range-track {
    height: 4px;
    background: rgba(255,255,255,0.28);
    border-radius: 2px;
}
.s5-vol-slider-container input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: none;
    border-radius: 50%;
    background: #fff;
}

#s5-export-btn { background: transparent; color: rgba(232, 228, 220, 0.62); font-weight: 650; border: none; padding: 8px 12px; border-radius: 0; cursor: pointer; transition: color 0.15s ease; font-size: 11px; letter-spacing: 0.22em;}
#s5-export-btn:hover { background: transparent; transform: none; box-shadow: none; }
#s5-btn-prev {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0 !important;
    border-radius: 50%;
    background: transparent;
    color: #ccc;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transform: none !important;
    box-shadow: none;
}
#s5-btn-prev:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: none !important;
}

/* ===== MODALS ===== */
.s5-audio-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 2000; display: none; align-items: center; justify-content: center; }
.s5-audio-modal.active { display: flex; }
.s5-audio-modal-content { background: rgba(20,20,20,0.9); padding: 30px; border-radius: 24px; width: 450px; display: flex; flex-direction: column; gap: 16px; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 20px 50px rgba(0,0,0,0.5); position: relative; backdrop-filter: blur(20px);}
.s5-audio-dropzone { border: 2px dashed rgba(255,255,255,0.2); background: rgba(0,0,0,0.2); padding: 30px; text-align: center; border-radius: 16px; cursor: pointer; color: #999; font-size: 13px; transition: 0.2s; }
.s5-audio-dropzone:hover { border-color: #fff; color: #fff; background: rgba(255,255,255,0.05); }

#s5-render-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.82);
    backdrop-filter: blur(10px);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
}
#s5-render-overlay.is-open { display: flex !important; }
.s5-render-box {
    background: rgba(20,20,20,0.94);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 28px 32px 24px;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    width: min(720px, calc(100% - 40px));
}
.s5-render-box h2 { margin: 0; font-size: 18px; font-weight: 600; color: #fff; }
.s5-render-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}
.s5-render-preview canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.s5-render-bar-bg { width: 100%; height: 12px; background: rgba(0,0,0,0.5); border-radius: 6px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1);}
.s5-render-bar-fill { height: 100%; width: 0%; background: #fff; border-radius: 6px; transition: width 0.1s linear; }
.s5-render-text { font-size: 14px; color: #fff; letter-spacing: 0.04em; }
.s5-render-hint { font-size: 11px; color: #999; margin-top: -6px; }
#s5-render-cancel-btn {
    margin-top: 4px;
    background: transparent;
    color: #ddd;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 999px;
    padding: 8px 22px;
    cursor: pointer;
    font-size: 13px;
}
#s5-render-cancel-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.s5-audio-track { position: relative; height: 100%; min-width: max-content; }
.s5-audio-block:active { cursor: grabbing; background: #333; }
.s5-audio-volume-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    margin-top: -1px;
    background: #fff;
    box-shadow: 0 0 4px rgba(0,0,0,0.8);
    z-index: 12;
    cursor: ns-resize;
    pointer-events: none;
    opacity: 0.1;
    transition: opacity 0.15s;
}
.s5-audio-volume-line::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -6px;
    height: 15px;
}
.s5-audio-block.selected-clip .s5-audio-volume-line,
.s5-clip.selected-clip .s5-audio-volume-line,
.s5-audio-block:hover .s5-audio-volume-line,
.s5-clip:hover .s5-audio-volume-line {
    opacity: 0.4;
}
.s5-volume-armed > .s5-audio-volume-line {
    pointer-events: auto;
    opacity: 0.7;
}
.s5-volume-db-tooltip {
    position: fixed;
    z-index: 3000;
    display: none;
    padding: 3px 7px;
    border-radius: 4px;
    background: rgba(10,10,12,0.92);
    border: 1px solid rgba(255,255,255,0.15);
    color: #eee;
    font-size: 11px;
    font-weight: 600;
    pointer-events: none;
    white-space: nowrap;
}
.s5-clip-waveform {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 65%;
    pointer-events: none;
    overflow: hidden;
    z-index: 3;
    background: linear-gradient(to top, rgba(0,0,0,0.5), rgba(0,0,0,0));
}
.s5-clip-empty-bg {
    position: absolute;
    inset: 0;
    background: #444;
    pointer-events: none;
    z-index: 0;
}
.s5-clip-plan-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
    color: #ddd;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.04em;
    pointer-events: none;
    white-space: nowrap;
    max-width: calc(100% - 8px);
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}
.s5-clip.has-still .s5-clip-plan-label {
    top: auto;
    bottom: 4px;
    transform: translateX(-50%);
    font-size: 8px;
    font-weight: 600;
    opacity: 0.92;
}
.s5-clip-waveform canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ===== FADE IN / FADE OUT ===== */
.s5-fade-handle {
    position: absolute;
    width: 11px;
    height: 11px;
    margin-top: -5px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.6);
    box-shadow: 0 0 3px rgba(0,0,0,0.7);
    z-index: 14;
    cursor: ew-resize;
    opacity: 0.35;
    transition: opacity 0.15s;
}
.s5-clip:hover .s5-fade-handle,
.s5-audio-block:hover .s5-fade-handle,
.s5-clip.selected-clip .s5-fade-handle,
.s5-audio-block.selected-clip .s5-fade-handle {
    opacity: 1;
}
.s5-fade-handle.left { transform: translateX(-1px); }
.s5-fade-handle.right { transform: translateX(-8px); }
.s5-fade-ramp {
    display: none;
}
.s5-track-wrapper.audio.s5-audio-track-drag-over {
    outline: 1px dashed rgba(255,255,255,0.45);
    outline-offset: -1px;
    background: rgba(255,255,255,0.04);
}

.s5-audio-effect-add-wrap {
    position: relative;
    margin: 6px 2px 4px;
}
.s5-audio-effect-add-btn {
    width: 100%;
    height: 32px;
    border-radius: 10px;
    border: 1px dashed rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.04);
    color: #e8e8ea;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transform: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.s5-right-panel .s5-audio-effect-add-btn,
.s5-right-panel .s5-audio-effect-add-btn:hover,
.s5-right-panel .s5-audio-effect-add-btn:active {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transform: none;
}
.s5-audio-effect-add-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.28);
    color: #fff;
}
.s5-audio-effect-menu {
    display: none;
    position: fixed;
    z-index: 12020;
    min-width: 168px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: #1a1a1c;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.s5-audio-effect-menu.active { display: block; }
.s5-audio-effect-menu button,
.s5-audio-effect-menu button:hover,
.s5-audio-effect-menu button:active {
    display: block;
    width: 100%;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #f2f2f4;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transform: none;
}
.s5-audio-effect-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.s5-audio-effect-card {
    margin-top: 8px;
    padding: 10px;
    border-radius: 12px;
    background: #1c1c1d;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.s5-audio-effect-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 11px;
    color: #ddd;
    font-weight: 600;
    letter-spacing: 0.4px;
}
.s5-audio-effect-remove {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #777;
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.s5-audio-effect-remove:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}
.s5-eq-canvas {
    width: 100%;
    height: 90px;
    border-radius: 8px;
    background: #111;
    cursor: crosshair;
    display: block;
}
.s5-effect-mini-param { margin-top: 6px; }
.s5-effect-mini-param label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #aaa;
    margin-bottom: 3px;
}
.s5-effect-mini-param input[type=range] { width: 100%; }

/* ===== TIMELINE CONTEXT MENU ===== */
.s5-context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 150px;
    background: rgba(28, 28, 30, 0.97);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.55);
    backdrop-filter: blur(12px);
}
.s5-context-item {
    padding: 8px 12px;
    cursor: pointer;
    color: #ddd;
    font-size: 12px;
    border-radius: 5px;
    white-space: nowrap;
}
.s5-context-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.s5-context-menu.s5-ctx-kf-mode #ctx-add-video-track,
.s5-context-menu.s5-ctx-kf-mode #ctx-add-audio-track,
.s5-context-menu.s5-ctx-kf-mode .s5-context-sep,
.s5-context-menu.s5-ctx-kf-mode #ctx-extract-audio,
.s5-context-menu.s5-ctx-kf-mode #ctx-separate-stems,
.s5-context-menu.s5-ctx-kf-mode #ctx-disable-clip,
.s5-context-menu.s5-ctx-kf-mode #ctx-add-frame-ref,
.s5-context-menu.s5-ctx-kf-mode #ctx-color {
    display: none;
}

.s5-clip.s5-clip-disabled,
.s5-audio-block.s5-clip-disabled {
    opacity: 0.38;
    filter: grayscale(0.28) brightness(0.72);
}

/* ===== CONTEXT SUBMENU (COLOR) ===== */
.s5-context-item.s5-has-submenu {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.s5-context-item.s5-has-submenu > .s5-ctx-arrow {
    font-size: 10px;
    opacity: 0.6;
}
.s5-context-submenu {
    display: none;
    position: absolute;
    left: calc(100% - 2px);
    top: -8px;
    margin-left: 0;
    padding: 8px;
    background: #18181b;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    z-index: 3100;
}
.s5-context-submenu::before {
    content: '';
    position: absolute;
    top: -12px;
    bottom: -12px;
    left: -16px;
    width: 18px;
}
.s5-context-item.s5-has-submenu:hover > .s5-context-submenu,
.s5-context-item.s5-has-submenu:focus-within > .s5-context-submenu {
    display: block;
}
.s5-context-submenu.flip-left {
    left: auto;
    right: calc(100% - 2px);
    margin-left: 0;
    margin-right: 0;
}
.s5-context-submenu.flip-left::before {
    left: auto;
    right: -16px;
}
.s5-color-swatches {
    display: grid;
    grid-template-columns: repeat(8, 18px);
    gap: 5px;
}
.s5-color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.18);
    cursor: pointer;
    padding: 0;
}
.s5-color-swatch:hover {
    transform: scale(1.15);
    border-color: #fff;
}
.s5-color-clear {
    margin-top: 8px;
    width: 100%;
    padding: 5px 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 5px;
    color: #ccc;
    font-size: 11px;
    cursor: pointer;
}
.s5-color-clear:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* ===== RIPPLE TOGGLE ===== */
.s5-ripple-btn {
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.04em;
    border: none !important;
    color: rgba(255, 255, 255, 0.34);
}
.s5-ripple-btn.active {
    background: transparent;
    color: rgba(255, 255, 255, 0.92);
    border: none !important;
}
.s5-ripple-btn.active:hover { background: transparent; color: rgba(255, 255, 255, 0.92); }

.s5-toolbar-left .s5-ripple-btn.s5-zoom-btn,
.s5-toolbar-left .s5-ripple-btn.s5-zoom-btn:hover,
.s5-toolbar-left .s5-ripple-btn.s5-zoom-btn:focus,
.s5-toolbar-left .s5-ripple-btn.s5-zoom-btn:focus-visible,
.s5-toolbar-left .s5-ripple-btn.s5-zoom-btn:active,
.s5-toolbar-left .s5-ripple-btn.s5-zoom-btn.active,
.s5-toolbar-left .s5-ripple-btn.s5-zoom-btn.active:hover,
.s5-ripple-btn,
.s5-ripple-btn:hover,
.s5-ripple-btn:focus,
.s5-ripple-btn:active,
.s5-ripple-btn.active,
.s5-ripple-btn.active:hover {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    outline: none !important;
    transform: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transition: color 0.12s ease !important;
}
.s5-ripple-btn:not(.active),
.s5-ripple-btn:not(.active):hover,
.s5-ripple-btn:not(.active):focus {
    color: rgba(255, 255, 255, 0.34) !important;
}
.s5-ripple-btn.active,
.s5-ripple-btn.active:hover,
.s5-ripple-btn.active:focus {
    color: rgba(255, 255, 255, 0.92) !important;
}

#s5-save-btn.s5-zoom-btn,
#s5-split-btn.s5-zoom-btn,
#s5-import-s4-btn.s5-tool-btn,
#s5-tool-cut.s5-tl-tool-btn {
    color: rgba(255, 255, 255, 0.42);
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transform: none !important;
    transition: color 0.12s ease !important;
}
#s5-save-btn.s5-zoom-btn:hover,
#s5-split-btn.s5-zoom-btn:hover,
#s5-import-s4-btn.s5-tool-btn:hover,
#s5-tool-cut.s5-tl-tool-btn:hover {
    color: rgba(255, 255, 255, 0.62) !important;
    background: transparent !important;
    box-shadow: none !important;
}
#s5-save-btn.s5-zoom-btn:active,
#s5-split-btn.s5-zoom-btn:active,
#s5-import-s4-btn.s5-tool-btn:active,
#s5-tool-cut.s5-tl-tool-btn:active {
    color: rgba(255, 255, 255, 0.95) !important;
    background: transparent !important;
}
#s5-tool-cut.s5-tl-tool-btn {
    border-color: transparent;
}
#s5-tool-cut.s5-tl-tool-btn.active,
#s5-tool-cut.s5-tl-tool-btn.active:hover {
    color: rgba(255, 255, 255, 0.72);
    background: transparent !important;
    border-color: transparent;
}
#s5-save-btn.s5-save-btn.is-saved { color: #7dffa0 !important; }
#s5-save-btn.s5-save-btn.is-error { color: #ff6b6b !important; }

#s5-export-btn,
#s5-export-btn:hover,
#s5-export-btn:focus,
#s5-export-btn:focus-visible,
#s5-export-btn:active {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transform: none !important;
    outline: none !important;
    padding: 8px 12px;
    border-radius: 0;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.22em;
    color: rgba(232, 228, 220, 0.62);
    transition: color 0.15s ease !important;
}
#s5-export-btn:hover,
#s5-export-btn:focus {
    color: rgba(245, 241, 232, 0.92) !important;
}
#s5-export-btn:active {
    color: #fff !important;
}
#s5-export-btn:disabled {
    color: rgba(255, 255, 255, 0.28) !important;
}

.s5-export-cluster {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    flex-shrink: 0;
    position: relative;
}
.s5-download-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.s5-download-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 0;
    color: rgba(232, 228, 220, 0.62);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}
.s5-download-btn:hover,
.s5-download-btn:focus,
.s5-download-wrap.is-open .s5-download-btn {
    color: rgba(245, 241, 232, 0.92);
}
.s5-download-btn:active {
    color: #fff;
}
.s5-download-btn:disabled,
.s5-download-wrap.is-busy .s5-download-btn {
    color: rgba(255, 255, 255, 0.28);
    cursor: wait;
}
.s5-download-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: max-content;
    min-width: 0;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    z-index: 90;
}
.s5-download-wrap.is-open .s5-download-menu {
    display: flex;
}
.s5-download-item {
    appearance: none;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.78);
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}
.s5-download-item:hover,
.s5-download-item:focus {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.s5-download-item:disabled {
    opacity: 0.45;
    cursor: wait;
}

.s5-toolbar-left .s5-snap-btn.s5-zoom-btn,
.s5-toolbar-left .s5-snap-btn.s5-zoom-btn:hover,
.s5-toolbar-left .s5-snap-btn.s5-zoom-btn:focus,
.s5-toolbar-left .s5-snap-btn.s5-zoom-btn:focus-visible,
.s5-toolbar-left .s5-snap-btn.s5-zoom-btn:active,
.s5-toolbar-left .s5-snap-btn.s5-zoom-btn.active,
.s5-toolbar-left .s5-snap-btn.s5-zoom-btn.active:hover,
.s5-snap-btn,
.s5-snap-btn:hover,
.s5-snap-btn:focus,
.s5-snap-btn:active,
.s5-snap-btn.active,
.s5-snap-btn.active:hover {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    outline: none !important;
    transform: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transition: color 0.12s ease !important;
}
.s5-snap-btn:not(.active),
.s5-snap-btn:not(.active):hover,
.s5-snap-btn:not(.active):focus {
    color: rgba(255, 255, 255, 0.34) !important;
}
.s5-snap-btn.active,
.s5-snap-btn.active:hover,
.s5-snap-btn.active:focus {
    color: rgba(255, 255, 255, 0.92) !important;
}
.s5-snap-btn svg {
    display: block;
    width: 16px;
    height: 16px;
}

/* ===== MODULAR LAYOUT (resize + rearrange) ===== */
.s5-modular-panel {
    position: relative;
    isolation: isolate;
}

/* نوار بین دو کادر که با کشیدن آن اندازه کادر قبلی تغییر می‌کند */
.s5-splitter {
    flex: 0 0 auto;
    position: relative;
    border-radius: 6px;
    background: transparent;
    transition: background 0.15s ease;
    z-index: 30;
}
.s5-splitter::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.s5-splitter-row {
    width: 8px;
    align-self: stretch;
    cursor: col-resize;
    margin: 0 -7px;
}
.s5-splitter-row::after {
    top: 50%;
    left: 50%;
    width: 3px;
    height: 36px;
    transform: translate(-50%, -50%);
}
.s5-splitter-column {
    height: 8px;
    align-self: stretch;
    cursor: row-resize;
    margin: -7px 0;
}
.s5-splitter-column::after {
    top: 50%;
    left: 50%;
    width: 36px;
    height: 3px;
    transform: translate(-50%, -50%);
}
.s5-splitter:hover,
.s5-splitter-active {
    background: rgba(255, 255, 255, 0.05);
}
.s5-splitter:hover::after,
.s5-splitter-active::after {
    opacity: 1;
    background: rgba(255, 255, 255, 0.55);
}

body.s5-resizing-col,
body.s5-resizing-col * {
    cursor: col-resize !important;
    user-select: none !important;
}
body.s5-resizing-row,
body.s5-resizing-row * {
    cursor: row-resize !important;
    user-select: none !important;
}

/* دستگیره جابه‌جایی: در کادرهای اسکرول‌دار چسبان و در بقیه مطلق قرار می‌گیرد */
.s5-panel-handle-slot {
    position: sticky;
    top: 0;
    order: -9999;
    flex: 0 0 auto;
    align-self: stretch;
    height: 0;
    min-height: 0;
    overflow: visible;
    display: flex;
    justify-content: flex-end;
    pointer-events: none;
    z-index: 70;
}
.s5-panel-handle-slot.is-absolute {
    position: absolute;
    top: 0;
    right: 0;
    left: auto;
    height: auto;
    align-self: auto;
}
.s5-panel-drag-handle {
    appearance: none;
    -webkit-appearance: none;
    pointer-events: auto;
    margin: 4px 4px 0 0;
    width: 22px;
    height: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none !important;
    border-radius: 0;
    background: transparent !important;
    color: rgba(255, 255, 255, 0.42);
    cursor: grab;
    opacity: 0;
    transform: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transition: opacity 0.15s ease, color 0.15s ease;
}
.s5-modular-panel:hover > .s5-panel-handle-slot > .s5-panel-drag-handle,
.s5-panel-drag-handle:focus-visible {
    opacity: 1;
}
.s5-panel-drag-handle:hover,
.s5-panel-drag-handle:focus-visible {
    color: rgba(255, 255, 255, 0.92);
    border: none !important;
    background: transparent !important;
    transform: none !important;
    box-shadow: none !important;
}
.s5-panel-drag-handle:active { cursor: grabbing; transform: none !important; }
.s5-settings-panel > .s5-panel-handle-slot > .s5-panel-drag-handle {
    margin: 0;
}

.s5-panel-drag-source { opacity: 0.55; }
.s5-panel-drop-target {
    outline: none;
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.5),
        0 0 0 4px rgba(255, 255, 255, 0.08);
}
body.s5-panel-dragging,
body.s5-panel-dragging * {
    cursor: grabbing !important;
    user-select: none !important;
}
.s5-panel-drag-ghost {
    position: fixed;
    z-index: 10100;
    padding: 7px 14px;
    border-radius: 10px;
    background: rgba(18, 18, 20, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #eee;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    pointer-events: none;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
}

/* ===== COLLAPSIBLE SECTIONS IN THE RIGHT PANEL ===== */
.s5-right-panel .s5-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 11px 2px 8px;
    margin: 4px 0 0;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    background: transparent;
    color: #c8c8cc;
    transition: color 0.15s ease;
}
.s5-right-panel .s5-section-header:hover {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
}
.s5-right-panel .s5-section-header:hover .s5-section-caret {
    color: #fff;
}
.s5-right-panel .s5-section-header h4 {
    margin: 0;
    flex: 0 1 auto;
    color: inherit;
}
.s5-section-caret {
    width: 12px;
    height: 12px;
    margin-left: auto;
    flex-shrink: 0;
    font-size: 0;
    color: #8e8e93;
    position: relative;
    transition: color 0.15s ease;
}
.s5-section-caret::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}
.s5-section-header.collapsed .s5-section-caret {
    transform: none;
}
.s5-section-header.collapsed .s5-section-caret::before {
    transform: rotate(-45deg);
    top: 4px;
}
.s5-section-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 4px;
    padding: 4px 2px 12px;
}
.s5-section-body.collapsed {
    display: none;
}

.s5-history-thumb-empty {
    width: 100%;
    height: 100%;
    background: #3a3a3c;
    border-radius: 8px;
}
.s5-clip-poster {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    display: block;
}
.s5-clip > video,
.s5-clip video.s5-clip-video-src {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

/* ===== RIGHT PANEL TABS + TRANSITIONS ===== */
.s5-right-panel {
    position: relative;
    padding-top: 34px;
}
.s5-inspector-chrome {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin: 0 0 4px;
    padding: 0 0 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.s5-inspector-collapse-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 72;
}
.s5-inspector-collapse-btn,
.s5-inspector-expand-btn {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #9a9a9e;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}
.s5-inspector-collapse-btn:hover,
.s5-inspector-expand-btn:hover {
    background: #2a2a2b;
    color: #fff;
}
.s5-inspector-collapse-btn svg,
.s5-inspector-expand-btn svg,
.s5-inspector-rail-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}
.s5-inspector-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
    min-width: 0;
    padding: 0;
    margin: 0;
    border: none;
}
.s5-inspector-rail {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-height: 0;
    padding: 2px 0 8px;
}
.s5-inspector-rail-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #8e8e93;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}
.s5-inspector-rail-btn:hover,
.s5-inspector-rail-btn.active {
    background: #2a2a2b;
    color: #fff;
}
.s5-inspector-rail-btn[hidden] { display: none !important; }
.s5-inspector-rail-sep {
    width: 18px;
    height: 1px;
    margin: 2px 0 6px;
    background: rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}
.s5-right-panel.s5-inspector-collapsed {
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    flex: 0 0 52px !important;
    padding: 10px 8px 12px;
}
.s5-right-panel.s5-inspector-collapsed > .s5-panel-handle-slot,
.s5-right-panel.s5-inspector-collapsed .s5-inspector-chrome,
.s5-right-panel.s5-inspector-collapsed .s5-inspector-collapse-btn,
.s5-right-panel.s5-inspector-collapsed .s5-inspector-pane {
    display: none !important;
}
.s5-right-panel.s5-inspector-collapsed .s5-inspector-rail {
    display: flex;
}
.s5-inspector-flyout {
    position: fixed;
    z-index: 12010;
    width: 300px;
    max-height: min(78vh, 720px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #141414;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
    color: #e0e0e0;
}
.s5-inspector-flyout[hidden] { display: none !important; }
.s5-inspector-flyout button {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transform: none;
}
.s5-inspector-flyout-title {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #c8c8cc;
}
.s5-inspector-flyout .s5-section-header {
    display: none;
}
.s5-inspector-flyout .s5-section-body,
.s5-inspector-flyout .s5-section-body.collapsed {
    display: flex !important;
}
.s5-inspector-flyout::-webkit-scrollbar { width: 5px; }
.s5-inspector-flyout::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}
.s5-inspector-tab {
    flex: 1;
    height: 30px;
    padding: 0 8px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: #888;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.s5-inspector-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.s5-inspector-tab.active {
    background: #2a2a2b;
    color: #fff;
}
.s5-inspector-pane {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.s5-inspector-pane[hidden] { display: none !important; }
.s5-inspector-pane::-webkit-scrollbar { width: 5px; }
.s5-inspector-pane::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}

.s5-tx-toolbar { padding: 0 2px 8px; }
.s5-tx-hint {
    margin: 8px 2px 4px;
    color: #7c7c82;
    font-size: 11px;
    line-height: 1.4;
}
.s5-tx-library { display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 12px; }
.s5-tx-cat { display: flex; flex-direction: column; gap: 8px; }
.s5-tx-cat-title {
    margin: 0;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #888;
}
.s5-tx-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}
.s5-inspector-pane .s5-clip-settings {
    flex: none;
    min-height: auto;
}
#s5-video-clip-settings-panel > .s5-inspector-section:first-child > .s5-section-header,
#s5-video-clip-settings-panel > .s5-section-header:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 8px;
}
.s5-tx-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    cursor: grab;
    text-align: left;
    user-select: none;
    -webkit-user-drag: element;
}
.s5-tx-card:active { cursor: grabbing; }
.s5-tx-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 1.15 / 1;
    border-radius: 7px;
    overflow: hidden;
    background: #1b1b1d;
    border: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: none;
}
.s5-tx-card:hover .s5-tx-preview,
.s5-tx-card.s5-tx-dragging .s5-tx-preview,
.s5-tx-card.selected .s5-tx-preview {
    border-color: rgba(255, 255, 255, 0.55);
}
.s5-tx-card.selected .s5-tx-preview {
    box-shadow: 0 0 0 1px #fff;
}
.s5-tx-card.selected .s5-tx-name { color: #fff; }
.s5-tx-pane {
    position: absolute;
    inset: 0;
}
.s5-tx-from { background: linear-gradient(135deg, #3d5a80 0%, #98c1d9 100%); }
.s5-tx-to { background: linear-gradient(135deg, #ee6c4d 0%, #f7b267 100%); }
.s5-tx-name {
    font-size: 9px;
    font-weight: 500;
    color: #c8c8cc;
    padding: 0 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.s5-tx-preview[data-tx] .s5-tx-to { animation-duration: 1.5s; animation-iteration-count: infinite; animation-timing-function: ease-in-out; }
.s5-tx-preview[data-tx="crossfade"] .s5-tx-to,
.s5-tx-preview[data-tx="dissolve"] .s5-tx-to,
.s5-tx-preview[data-tx="ghost"] .s5-tx-to,
.s5-tx-preview[data-tx="overlay"] .s5-tx-to,
.s5-tx-preview[data-tx="softlight"] .s5-tx-to { animation-name: s5TxFade; }
.s5-tx-preview[data-tx="fadeblack"] .s5-tx-to,
.s5-tx-preview[data-tx="colordip"] .s5-tx-to { animation-name: s5TxFade; background: #000; }
.s5-tx-preview[data-tx="fadewhite"] .s5-tx-to { animation-name: s5TxFade; background: #fff; }
.s5-tx-preview[data-tx="blurfade"] .s5-tx-to,
.s5-tx-preview[data-tx="dreamy"] .s5-tx-to,
.s5-tx-preview[data-tx="mosaic"] .s5-tx-to { animation-name: s5TxFade; filter: blur(6px); }
.s5-tx-preview[data-tx="flashwhite"] .s5-tx-to,
.s5-tx-preview[data-tx="glowflash"] .s5-tx-to { animation-name: s5TxFlash; background: #fff; }
.s5-tx-preview[data-tx="dipbloom"] .s5-tx-to,
.s5-tx-preview[data-tx="lightleak"] .s5-tx-to,
.s5-tx-preview[data-tx="filmburn"] .s5-tx-to { animation-name: s5TxFade; filter: brightness(1.6); }
.s5-tx-preview[data-tx="wipeleft"] .s5-tx-to,
.s5-tx-preview[data-tx="brush"] .s5-tx-to { animation-name: s5TxWipeL; }
.s5-tx-preview[data-tx="wiperight"] .s5-tx-to { animation-name: s5TxWipeR; }
.s5-tx-preview[data-tx="wipeup"] .s5-tx-to { animation-name: s5TxWipeU; }
.s5-tx-preview[data-tx="wipedown"] .s5-tx-to { animation-name: s5TxWipeD; }
.s5-tx-preview[data-tx="wipediag"] .s5-tx-to { animation-name: s5TxWipeDiag; }
.s5-tx-preview[data-tx="wipediag2"] .s5-tx-to { animation-name: s5TxWipeDiag2; }
.s5-tx-preview[data-tx="iris"] .s5-tx-to,
.s5-tx-preview[data-tx="circle"] .s5-tx-to,
.s5-tx-preview[data-tx="radial"] .s5-tx-to { animation-name: s5TxIris; }
.s5-tx-preview[data-tx="irisclose"] .s5-tx-from { animation-name: s5TxIris; }
.s5-tx-preview[data-tx="clock"] .s5-tx-to,
.s5-tx-preview[data-tx="fan"] .s5-tx-to { animation-name: s5TxClock; }
.s5-tx-preview[data-tx="barnh"] .s5-tx-to,
.s5-tx-preview[data-tx="splitv"] .s5-tx-to { animation-name: s5TxBarnH; }
.s5-tx-preview[data-tx="barnv"] .s5-tx-to,
.s5-tx-preview[data-tx="splith"] .s5-tx-to { animation-name: s5TxBarnV; }
.s5-tx-preview[data-tx="blinds"] .s5-tx-to,
.s5-tx-preview[data-tx="venetian"] .s5-tx-to { animation-name: s5TxBlinds; }
.s5-tx-preview[data-tx="slideleft"] .s5-tx-to,
.s5-tx-preview[data-tx="pushleft"] .s5-tx-to,
.s5-tx-preview[data-tx="bounceleft"] .s5-tx-to,
.s5-tx-preview[data-tx="wind"] .s5-tx-to { animation-name: s5TxSlideL; }
.s5-tx-preview[data-tx="slideright"] .s5-tx-to,
.s5-tx-preview[data-tx="pushright"] .s5-tx-to,
.s5-tx-preview[data-tx="bounceright"] .s5-tx-to,
.s5-tx-preview[data-tx="overshoot"] .s5-tx-to { animation-name: s5TxSlideR; }
.s5-tx-preview[data-tx="slideup"] .s5-tx-to,
.s5-tx-preview[data-tx="pushup"] .s5-tx-to,
.s5-tx-preview[data-tx="whipup"] .s5-tx-to { animation-name: s5TxSlideU; }
.s5-tx-preview[data-tx="slidedown"] .s5-tx-to,
.s5-tx-preview[data-tx="pushdown"] .s5-tx-to,
.s5-tx-preview[data-tx="whipdown"] .s5-tx-to { animation-name: s5TxSlideD; }
.s5-tx-preview[data-tx="zoomin"] .s5-tx-to,
.s5-tx-preview[data-tx="punchzoom"] .s5-tx-to { animation-name: s5TxZoomIn; }
.s5-tx-preview[data-tx="zoomout"] .s5-tx-from,
.s5-tx-preview[data-tx="smashzoom"] .s5-tx-from,
.s5-tx-preview[data-tx="crosszoom"] .s5-tx-from { animation-name: s5TxZoomOut; }
.s5-tx-preview[data-tx="zoomrotate"] .s5-tx-to,
.s5-tx-preview[data-tx="swirl"] .s5-tx-to { animation-name: s5TxZoomRot; }
.s5-tx-preview[data-tx="whip"] .s5-tx-to { animation-name: s5TxWhip; }
.s5-tx-preview[data-tx="spin"] .s5-tx-to,
.s5-tx-preview[data-tx="roll"] .s5-tx-to { animation-name: s5TxSpin; }
.s5-tx-preview[data-tx="flipx"] .s5-tx-to,
.s5-tx-preview[data-tx="cubeleft"] .s5-tx-to,
.s5-tx-preview[data-tx="cuberight"] .s5-tx-to,
.s5-tx-preview[data-tx="fold"] .s5-tx-to,
.s5-tx-preview[data-tx="book"] .s5-tx-to,
.s5-tx-preview[data-tx="doorleft"] .s5-tx-to,
.s5-tx-preview[data-tx="doorright"] .s5-tx-to { animation-name: s5TxFlipX; }
.s5-tx-preview[data-tx="flipy"] .s5-tx-to { animation-name: s5TxFlipY; }
.s5-tx-preview[data-tx="squeeze"] .s5-tx-to,
.s5-tx-preview[data-tx="stretch"] .s5-tx-to { animation-name: s5TxSqueeze; }
.s5-tx-preview[data-tx="diamond"] .s5-tx-to { animation-name: s5TxDiamond; }
.s5-tx-preview[data-tx="plus"] .s5-tx-to { animation-name: s5TxPlus; }
.s5-tx-preview[data-tx="inset"] .s5-tx-to,
.s5-tx-preview[data-tx="checker"] .s5-tx-to,
.s5-tx-preview[data-tx="corner"] .s5-tx-to { animation-name: s5TxInset; }
.s5-tx-preview[data-tx="shake"] .s5-tx-to,
.s5-tx-preview[data-tx="handheld"] .s5-tx-to,
.s5-tx-preview[data-tx="glitch"] .s5-tx-to,
.s5-tx-preview[data-tx="rgb"] .s5-tx-to,
.s5-tx-preview[data-tx="static"] .s5-tx-to,
.s5-tx-preview[data-tx="mirror"] .s5-tx-to { animation-name: s5TxFade; }

@keyframes s5TxFade { 0%, 8% { opacity: 0; } 48%, 58% { opacity: 1; } 100% { opacity: 0; } }
@keyframes s5TxFlash { 0%, 15% { opacity: 0; } 40% { opacity: 1; } 55% { opacity: 0.2; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes s5TxWipeL { from { clip-path: inset(0 100% 0 0); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 100% 0 0); } }
@keyframes s5TxWipeR { from { clip-path: inset(0 0 0 100%); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 0 0 100%); } }
@keyframes s5TxWipeU { from { clip-path: inset(100% 0 0 0); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(100% 0 0 0); } }
@keyframes s5TxWipeD { from { clip-path: inset(0 0 100% 0); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 0 100% 0); } }
@keyframes s5TxWipeDiag { from { clip-path: polygon(0 0, 0 0, 0 0); } 50% { clip-path: polygon(0 0, 200% 0, 0 200%); } to { clip-path: polygon(0 0, 0 0, 0 0); } }
@keyframes s5TxWipeDiag2 { from { clip-path: polygon(100% 0, 100% 0, 100% 0); } 50% { clip-path: polygon(-50% 0, 100% 0, 100% 150%); } to { clip-path: polygon(100% 0, 100% 0, 100% 0); } }
@keyframes s5TxIris { from { clip-path: circle(0% at 50% 50%); } 50% { clip-path: circle(80% at 50% 50%); } to { clip-path: circle(0% at 50% 50%); } }
@keyframes s5TxClock { from { clip-path: polygon(50% 50%, 50% 0, 50% 0); } 25% { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%, 0 100%, 0 0, 50% 0); } 50% { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%, 0 100%, 0 0, 50% 0); } to { clip-path: polygon(50% 50%, 50% 0, 50% 0); } }
@keyframes s5TxBarnH { from { clip-path: inset(0 50% 0 50%); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 50% 0 50%); } }
@keyframes s5TxBarnV { from { clip-path: inset(50% 0 50% 0); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(50% 0 50% 0); } }
@keyframes s5TxBlinds { from { clip-path: inset(0 0 100% 0); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 0 100% 0); } }
@keyframes s5TxSlideL { from { transform: translateX(-100%); } 50% { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes s5TxSlideR { from { transform: translateX(100%); } 50% { transform: translateX(0); } to { transform: translateX(100%); } }
@keyframes s5TxSlideU { from { transform: translateY(-100%); } 50% { transform: translateY(0); } to { transform: translateY(-100%); } }
@keyframes s5TxSlideD { from { transform: translateY(100%); } 50% { transform: translateY(0); } to { transform: translateY(100%); } }
@keyframes s5TxZoomIn { from { transform: scale(0.55); opacity: 0; } 50% { transform: scale(1); opacity: 1; } to { transform: scale(0.55); opacity: 0; } }
@keyframes s5TxZoomOut { from { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes s5TxZoomRot { from { transform: scale(0.6) rotate(-18deg); opacity: 0; } 50% { transform: none; opacity: 1; } to { transform: scale(0.6) rotate(-18deg); opacity: 0; } }
@keyframes s5TxWhip { from { transform: translateX(-70%) skewX(16deg); opacity: 0; } 50% { transform: none; opacity: 1; } to { transform: translateX(70%) skewX(-16deg); opacity: 0; } }
@keyframes s5TxSpin { from { transform: rotate(-90deg) scale(0.7); opacity: 0; } 50% { transform: none; opacity: 1; } to { transform: rotate(90deg) scale(0.7); opacity: 0; } }
@keyframes s5TxFlipX { from { transform: rotateY(90deg); opacity: 0; } 50% { transform: none; opacity: 1; } to { transform: rotateY(-90deg); opacity: 0; } }
@keyframes s5TxFlipY { from { transform: rotateX(90deg); opacity: 0; } 50% { transform: none; opacity: 1; } to { transform: rotateX(-90deg); opacity: 0; } }
@keyframes s5TxSqueeze { from { transform: scaleX(0); } 50% { transform: none; } to { transform: scaleX(0); } }
@keyframes s5TxDiamond { from { clip-path: polygon(50% 50%, 50% 50%, 50% 50%, 50% 50%); } 50% { clip-path: polygon(50% -20%, 120% 50%, 50% 120%, -20% 50%); } to { clip-path: polygon(50% 50%, 50% 50%, 50% 50%, 50% 50%); } }
@keyframes s5TxSplitV { from { clip-path: inset(0 50% 0 50%); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 50% 0 50%); } }
@keyframes s5TxSplitH { from { clip-path: inset(50% 0 50% 0); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(50% 0 50% 0); } }
@keyframes s5TxPlus { from { clip-path: inset(45% 45% 45% 45%); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(45% 45% 45% 45%); } }
@keyframes s5TxInset { from { clip-path: inset(50% 50% 50% 50%); } 50% { clip-path: inset(0 0 0 0); } to { clip-path: inset(50% 50% 50% 50%); } }

.s5-preview-stack {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    perspective: 1100px;
}
.s5-preview-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    backface-visibility: hidden;
    transform: translateZ(0);
    isolation: isolate;
}
.s5-preview-area.is-transitioning video,
.s5-preview-area.is-transitioning img,
.s5-preview-area.is-transitioning .s5-preview-layer {
    transition: none !important;
}
.s5-preview-area.is-transitioning .s5-preview-layer {
    will-change: opacity, transform, clip-path, filter;
}
.s5-preview-layer video,
.s5-preview-layer img {
    pointer-events: auto;
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
    transition: none !important;
    transform: translateZ(0);
    backface-visibility: hidden;
}
#s5-preview-layer-b { z-index: 1; }
#s5-preview-layer-a { z-index: 0; }

.s5-transition-handle {
    position: absolute;
    top: 0;
    height: 100%;
    z-index: 18;
    padding: 0;
    margin: 0;
    border: 1px solid rgba(210, 214, 220, 0.28);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.07);
    box-sizing: border-box;
    pointer-events: none;
    display: block;
    overflow: visible;
}
.s5-transition-handle.selected {
    border-color: rgba(230, 234, 238, 0.5);
    background: rgba(255, 255, 255, 0.11);
}
.s5-transition-handle.s5-tx-drop-target {
    background: rgba(255, 255, 255, 0.08);
    border: 1px dashed rgba(255, 255, 255, 0.45);
}
.s5-transition-handle.s5-tx-drop-hot {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.7);
}
.s5-tx-mix-icon {
    position: absolute;
    left: 50%;
    top: 5px;
    width: 22px;
    height: 16px;
    margin: 0;
    transform: translateX(-50%);
    color: #8d8d92;
    pointer-events: auto;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.s5-tx-mix-icon svg {
    width: 22px;
    height: 16px;
    display: block;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}
.s5-transition-handle.selected .s5-tx-mix-icon {
    color: #c8c8cc;
}
.s5-tx-edge {
    position: absolute;
    top: 0;
    width: 8px;
    height: 100%;
    pointer-events: auto;
    cursor: ew-resize;
    z-index: 3;
}
.s5-tx-edge.left { left: 0; }
.s5-tx-edge.right { right: 0; }
.s5-tx-edge:hover,
.s5-transition-handle.selected .s5-tx-edge {
    background: rgba(255, 255, 255, 0.16);
}
.s5-tx-drop-target .s5-tx-edge,
.s5-tx-drop-target .s5-tx-handle-x {
    display: none;
}
.s5-transition-handle .s5-tx-handle-x {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: none;
    background: #1c1c1e;
    color: #fff;
    font-size: 10px;
    line-height: 14px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    z-index: 4;
}
.s5-transition-handle.selected .s5-tx-handle-x,
.s5-transition-handle:hover .s5-tx-handle-x { display: flex; }

body.s5-tx-dragging,
body.s5-tx-dragging * { cursor: grabbing !important; }
body.s5-tx-resizing,
body.s5-tx-resizing * { cursor: ew-resize !important; }

/* ===== STAGE 5 GALLERY ===== */
.s5-gallery-pane {
    display: none;
    flex: 1;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 16px;
    overflow: hidden;
    box-sizing: border-box;
    box-shadow: none;
    container-type: inline-size;
    container-name: s5gallery;
    --s5-gallery-tile: 290px;
    --s5-gallery-folder-tile: 116px;
}
.s5-gallery-pane::-webkit-scrollbar { width: 8px; }
.s5-gallery-pane::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}
.s5-gallery-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.s5-gallery-scroll::-webkit-scrollbar { width: 8px; }
.s5-gallery-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}

#stage-5.s5-gallery-mode .s5-gallery-pane {
    display: flex;
    position: relative;
}
#stage-5.s5-gallery-mode .s5-gallery-pane::before {
    content: '';
    position: absolute;
    top: 22px;
    bottom: 22px;
    left: 0;
    width: 1px;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.12) 12%,
        rgba(255, 255, 255, 0.22) 50%,
        rgba(255, 255, 255, 0.12) 88%,
        rgba(255, 255, 255, 0)
    );
    pointer-events: none;
    z-index: 2;
}
#stage-5.s5-gallery-mode .s5-editor-container,
#stage-5.s5-gallery-mode .s5-right-panel,
#stage-5.s5-gallery-mode .s5-stage-nav,
#stage-5.s5-gallery-mode .s5-timeline-layout,
#stage-5.s5-gallery-mode .s5-preview-area,
#stage-5.s5-gallery-mode .s5-inspector-pane {
    display: none !important;
}

.s5-gallery-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.s5-gallery-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.s5-gallery-filter svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
}
.s5-gallery-filter:hover {
    color: #eee;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
}
.s5-gallery-filter.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.05);
}
.s5-gallery-toolbar-end {
    display: inline-flex;
    margin-left: auto;
    align-items: center;
    gap: 8px;
    position: relative;
    flex-shrink: 0;
}
.s5-gallery-projects-btn {
    margin-left: 0;
}
.s5-gallery-projects-label-standalone,
.s5-gallery-folder-back-standalone {
    display: none;
}
html.ai-generate-mode .s5-gallery-projects-label-studio,
body.ai-generate-mode .s5-gallery-projects-label-studio,
html.ai-generate-mode .s5-gallery-folder-back-studio,
body.ai-generate-mode .s5-gallery-folder-back-studio {
    display: none;
}
html.ai-generate-mode .s5-gallery-projects-label-standalone,
body.ai-generate-mode .s5-gallery-projects-label-standalone,
html.ai-generate-mode .s5-gallery-folder-back-standalone,
body.ai-generate-mode .s5-gallery-folder-back-standalone {
    display: inline;
}
.s5-gallery-likes-btn.active svg,
.s5-gallery-likes-btn.active svg path {
    fill: currentColor;
}
.s5-gallery-zoom-btn {
    width: 36px;
    padding: 0;
    justify-content: center;
}
.s5-gallery-zoom-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 30;
    display: flex;
    align-items: center;
    height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(22, 22, 24, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.s5-gallery-zoom-pop[hidden] {
    display: none !important;
}
.s5-gallery-zoom-pop input[type="range"] {
    width: 132px;
    height: 4px;
    margin: 0;
    accent-color: #fff;
    cursor: pointer;
}
html.ai-generate-mode .s5-gallery-pane,
body.ai-generate-mode .s5-gallery-pane {
    --s5-gallery-tile: 290px;
    --s5-gallery-folder-tile: 116px;
}
html.ai-generate-mode .s5-gallery-grid,
body.ai-generate-mode .s5-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(var(--s5-gallery-tile, 290px), 1fr)) !important;
    gap: clamp(8px, calc(var(--s5-gallery-tile) * 0.08), 14px);
}
html.ai-generate-mode .s5-gallery-grid.is-folders,
body.ai-generate-mode .s5-gallery-grid.is-folders {
    grid-template-columns: repeat(auto-fill, minmax(var(--s5-gallery-folder-tile, 116px), var(--s5-gallery-folder-tile, 116px))) !important;
    gap: clamp(12px, calc(var(--s5-gallery-folder-tile) * 0.16), 20px);
    justify-content: start;
}
.s5-gallery-folder-bar {
    display: none;
    align-items: center;
    gap: 12px;
    margin: -2px 0 12px;
    min-height: 28px;
    flex-shrink: 0;
}
.s5-gallery-folder-bar:not([hidden]) {
    display: flex;
}
.s5-gallery-folder-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 8px 0 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.s5-gallery-folder-back svg {
    width: 16px;
    height: 16px;
}
.s5-gallery-folder-back:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}
.s5-gallery-folder-current {
    color: rgba(255, 255, 255, 0.88);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.s5-gallery-folder {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.s5-gallery-folder-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.s5-gallery-folder-thumb > img,
.s5-gallery-folder-thumb > video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}
.s5-gallery-folder-mosaic {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    background: rgba(0, 0, 0, 0.35);
}
.s5-gallery-folder-mosaic[data-count="2"] {
    grid-template-rows: 1fr;
}
.s5-gallery-folder-tile {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
}
.s5-gallery-folder-tile.is-blank {
    background: rgba(255, 255, 255, 0.03);
}
.s5-gallery-folder-tile img,
.s5-gallery-folder-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}
.s5-gallery-folder-tile.is-audio,
.s5-gallery-folder-thumb.is-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.38);
    background:
        radial-gradient(circle at 30% 20%, rgba(94, 92, 230, 0.22), transparent 55%),
        #16161a;
}
.s5-gallery-folder-tile.is-audio svg,
.s5-gallery-folder-thumb.is-empty svg {
    width: 42%;
    height: 42%;
    max-width: 28px;
    max-height: 28px;
}
.s5-gallery-folder-thumb.is-empty svg {
    max-width: 42px;
    max-height: 42px;
    color: rgba(255, 255, 255, 0.32);
}
.s5-gallery-folder-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    width: clamp(16px, calc(var(--s5-gallery-folder-tile, 116px) * 0.18), 24px);
    height: clamp(16px, calc(var(--s5-gallery-folder-tile, 116px) * 0.18), 24px);
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.58);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.s5-gallery-folder-badge svg {
    width: 62%;
    height: 62%;
}
.s5-gallery-folder-name {
    padding: 0 2px;
    color: rgba(255, 255, 255, 0.85);
    font-size: clamp(10px, calc(var(--s5-gallery-folder-tile, 116px) * 0.12), 12px);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.s5-gallery-folder:hover .s5-gallery-folder-thumb {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
}

.s5-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--s5-gallery-tile, 290px), 1fr));
    gap: clamp(8px, calc(var(--s5-gallery-tile, 290px) * 0.08), 14px);
    width: 100%;
}
.s5-gallery-grid:not(.is-folders) {
    display: flex !important;
    flex-direction: column;
    gap: 0;
}
.s5-gallery-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
}
.s5-gallery-masonry {
    display: flex;
    align-items: flex-start;
    width: 100%;
    gap: clamp(8px, calc(var(--s5-gallery-tile, 290px) * 0.08), 14px);
}
.s5-gallery-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: clamp(8px, calc(var(--s5-gallery-tile, 290px) * 0.08), 14px);
}
.s5-gallery-grid.is-folders {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(var(--s5-gallery-folder-tile, 116px), var(--s5-gallery-folder-tile, 116px)));
    gap: clamp(12px, calc(var(--s5-gallery-folder-tile, 116px) * 0.16), 20px);
    justify-content: start;
}
.s5-gallery-date-heading {
    grid-column: 1 / -1;
    margin: 8px 2px 2px;
    padding: 4px 2px 2px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}
.s5-gallery-date-heading:first-child {
    margin-top: 0;
}
.s5-gallery-group + .s5-gallery-group .s5-gallery-date-heading {
    margin-top: 18px;
}
.s5-gallery-empty {
    margin: auto;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
    letter-spacing: 0.3px;
    padding: 48px 16px;
    text-align: center;
}
.s5-gallery-sentinel {
    height: 24px;
    width: 100%;
    flex-shrink: 0;
}

.s5-gallery-card {
    position: relative;
    width: 100%;
    flex: none;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    background: #1c1c1e;
    border: 1px solid rgba(255, 255, 255, 0.06);
    isolation: isolate;
    cursor: pointer;
}
.s5-gallery-card.is-generating {
    cursor: default;
    background: #121214;
}
.s5-gallery-card.is-generating[data-media-type="video"] {
    background: #101218;
}
.s5-gallery-card.is-generating[data-media-type="audio"] {
    background: #151218;
}
.s5-gallery-glows,
.gen-glows {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    display: flex;
    pointer-events: none;
    z-index: 3;
    animation: s5-gallery-glows-drift 8s linear infinite;
}
.s5-gallery-glows-set,
.gen-glows-set {
    position: relative;
    flex: 0 0 50%;
    height: 100%;
}
.s5-gallery-glow,
.gen-glow {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(
        circle at center,
        rgba(255, 255, 255, 0.58) 0%,
        rgba(255, 255, 255, 0.22) 24%,
        rgba(255, 255, 255, 0.07) 52%,
        rgba(255, 255, 255, 0) 78%
    );
    filter: blur(34px);
    will-change: transform, opacity;
}
.s5-gallery-card.is-generating[data-media-type="video"] .s5-gallery-glow,
.s5-gallery-card.is-generating[data-media-type="video"] .gen-glow {
    background: radial-gradient(
        circle at center,
        rgba(186, 206, 255, 0.58) 0%,
        rgba(140, 168, 240, 0.22) 26%,
        rgba(94, 92, 230, 0.08) 52%,
        rgba(255, 255, 255, 0) 78%
    );
}
.s5-gallery-card.is-generating[data-media-type="audio"] .s5-gallery-glow,
.s5-gallery-card.is-generating[data-media-type="audio"] .gen-glow {
    background: radial-gradient(
        circle at center,
        rgba(214, 186, 255, 0.58) 0%,
        rgba(168, 140, 230, 0.22) 26%,
        rgba(130, 90, 200, 0.08) 52%,
        rgba(255, 255, 255, 0) 78%
    );
}
.s5-gallery-glow-1,
.gen-glow-1 {
    left: 4%;
    top: 2%;
    width: 58%;
    height: 78%;
    animation: s5-gallery-glow-1 4.6s ease-in-out infinite;
}
.s5-gallery-glow-2,
.gen-glow-2 {
    left: 42%;
    top: -6%;
    width: 52%;
    height: 70%;
    animation: s5-gallery-glow-2 6.2s ease-in-out infinite;
}
.s5-gallery-glow-3,
.gen-glow-3 {
    left: 16%;
    top: 36%;
    width: 48%;
    height: 66%;
    animation: s5-gallery-glow-3 3.8s ease-in-out infinite;
}
@keyframes s5-gallery-glows-drift {
    from { transform: translateX(-50%); }
    to { transform: translateX(0); }
}
@keyframes s5-gallery-glow-1 {
    0%, 100% { transform: translate(-8%, -12%) scale(0.9); opacity: 0.42; }
    42% { transform: translate(14%, 22%) scale(1.14); opacity: 1; }
    68% { transform: translate(4%, 36%) scale(0.96); opacity: 0.48; }
}
@keyframes s5-gallery-glow-2 {
    0%, 100% { transform: translate(6%, 8%) scale(0.88); opacity: 0.4; }
    28% { transform: translate(-8%, 18%) scale(0.98); opacity: 0.52; }
    58% { transform: translate(12%, 10%) scale(1.16); opacity: 1; }
}
@keyframes s5-gallery-glow-3 {
    0%, 100% { transform: translate(8%, 6%) scale(0.92); opacity: 0.44; }
    50% { transform: translate(-12%, -16%) scale(1.08); opacity: 0.55; }
    78% { transform: translate(16%, -6%) scale(1.14); opacity: 1; }
}
.s5-gallery-card.is-generating .s5-gallery-media,
.s5-gallery-card.is-generating .s5-gallery-audio-face,
.s5-gallery-card.is-generating .s5-gallery-play,
.s5-gallery-card.is-generating .s5-gallery-actions,
.s5-gallery-card.is-generating .s5-gallery-seek {
    display: none !important;
}
.s5-gallery-card.is-failed {
    cursor: default;
    outline: 1px solid rgba(255, 69, 58, 0.35);
    background: #161214;
}
.s5-gallery-fail {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: rgba(12, 10, 12, 0.55);
    text-align: center;
}
.s5-gallery-fail-text {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    color: #ff8a8a;
    max-width: 90%;
}
.s5-gallery-fail .generation-retry-btn svg {
    stroke: currentColor;
    fill: none;
}

.s5-gallery-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #111;
}
.s5-gallery-audio-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 30% 20%, rgba(94, 92, 230, 0.28), transparent 55%),
        radial-gradient(circle at 80% 90%, rgba(10, 132, 255, 0.18), transparent 50%),
        #16161a;
    color: rgba(255, 255, 255, 0.78);
}
.s5-gallery-audio-face svg {
    width: clamp(18px, calc(var(--s5-gallery-tile, 180px) * 0.22), 42px);
    height: clamp(18px, calc(var(--s5-gallery-tile, 180px) * 0.22), 42px);
}

.s5-gallery-play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: clamp(28px, calc(var(--s5-gallery-tile, 180px) * 0.24), 48px);
    height: clamp(28px, calc(var(--s5-gallery-tile, 180px) * 0.24), 48px);
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    z-index: 2;
    transition: transform 0.2s ease, background 0.2s ease;
}
.s5-gallery-play:hover {
    transform: translate(-50%, -50%) scale(1.06);
    background: rgba(0, 0, 0, 0.7);
}
.s5-gallery-play svg { width: 20px; height: 20px; }
.s5-gallery-card.is-playing .s5-gallery-play {
    background: rgba(255, 255, 255, 0.92);
    color: #111;
}

.s5-gallery-actions {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    display: flex;
    justify-content: center;
    gap: 6px;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 3;
}
.s5-gallery-card:hover .s5-gallery-actions,
.s5-gallery-card:focus-within .s5-gallery-actions {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.s5-gallery-actions button {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(12, 12, 14, 0.72);
    color: rgba(255, 255, 255, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.s5-gallery-actions button:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.22);
}
.s5-gallery-actions button svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
}
.s5-gallery-actions button.is-liked {
    color: #ff453a;
    border-color: rgba(255, 69, 58, 0.35);
}
.s5-gallery-actions button.is-liked svg { fill: currentColor; }
.s5-gallery-type {
    position: absolute;
    top: 8px;
    left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 22px;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 999px;
    padding: 4px 8px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
    z-index: 2;
}
.s5-gallery-type svg {
    width: 13px;
    height: 13px;
    display: block;
    stroke: currentColor;
    fill: none;
}
.s5-gallery-duration {
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.2px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.s5-gallery-card.is-generating .s5-gallery-type {
    z-index: 5;
    color: rgba(255, 255, 255, 0.88);
}
.s5-gallery-card.is-generating[data-media-type="video"] .s5-gallery-type {
    color: #c9d7ff;
}
.s5-gallery-card.is-generating[data-media-type="audio"] .s5-gallery-type {
    color: #e0d0ff;
}
.s5-gallery-duration:empty { display: none; }

.s5-gallery-seek {
    position: absolute;
    left: 14px;
    right: 14px;
    top: calc(50% + 34px);
    height: 18px;
    display: none;
    align-items: center;
    z-index: 3;
    cursor: pointer;
    touch-action: none;
}
.s5-gallery-card.is-playing .s5-gallery-seek {
    display: flex;
}
.s5-gallery-seek-track {
    width: 100%;
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.22);
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: height 0.15s ease;
}
.s5-gallery-seek:hover .s5-gallery-seek-track,
.s5-gallery-seek:active .s5-gallery-seek-track {
    height: 6px;
}
.s5-gallery-seek-fill {
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 99px;
}

/* ===== STAGE 5 GALLERY MODAL ===== */
.s5g-media-stage {
    background: transparent;
}
.s5g-stage-image,
.s5g-stage-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: transparent;
    cursor: zoom-in;
}
.s5g-stage-image:fullscreen,
.s5g-stage-video:fullscreen,
.s5g-media-stage:fullscreen {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    cursor: zoom-out;
}
.s5g-stage-image[hidden],
.s5g-stage-video[hidden],
.s5g-video-play[hidden],
.s5g-audio-stage[hidden] {
    display: none !important;
}
.s5g-stage-video {
    cursor: pointer;
    max-height: 100%;
}
.s5g-video-play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 72px;
    height: 72px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 4;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}
.s5g-video-play svg { width: 28px; height: 28px; }
.s5g-video-play:hover {
    transform: translate(-50%, -50%) scale(1.06);
    background: rgba(0, 0, 0, 0.72);
}
.s5g-media-stage.is-playing .s5g-video-play {
    opacity: 0;
    pointer-events: none;
}
.s5g-audio-stage {
    width: min(860px, 92%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    padding: 20px;
}
.s5g-audio-play {
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease, background 0.2s ease;
}
.s5g-audio-play:hover { transform: scale(1.05); }
.s5g-audio-play.is-playing {
    background: #0a84ff;
    color: #fff;
}
.s5g-audio-play svg { width: 26px; height: 26px; }
.s5g-waveform {
    width: 100%;
    height: 132px;
    cursor: pointer;
    touch-action: none;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.s5g-waveform canvas {
    display: block;
    width: 100%;
    height: 100%;
}
.s5g-audio-time {
    color: rgba(255, 255, 255, 0.55);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
}
.s5g-thumb {
    position: relative;
}
.s5g-thumb-dots {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    pointer-events: none;
}
.s5g-thumb-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.55);
    animation: s5g-thumb-dot-bounce 0.9s ease-in-out infinite;
}
.s5g-thumb-dots i:nth-child(2) { animation-delay: 0.14s; }
.s5g-thumb-dots i:nth-child(3) { animation-delay: 0.28s; }
@keyframes s5g-thumb-dot-bounce {
    0%, 80%, 100% { transform: translateY(5px); opacity: 0.45; }
    40% { transform: translateY(-5px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .s5g-thumb-dots i { animation: none; opacity: 0.85; transform: none; }
}
.s5g-thumb-badge {
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 16px;
    height: 16px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.62);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.s5g-thumb-badge svg {
    width: 10px;
    height: 10px;
    display: block;
}
.s5g-thumb-audio {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 30% 20%, rgba(94, 92, 230, 0.28), transparent 55%),
        radial-gradient(circle at 80% 90%, rgba(10, 132, 255, 0.18), transparent 50%),
        #16161a;
    color: rgba(255, 255, 255, 0.8);
}
.s5g-thumb-audio svg { width: 22px; height: 22px; }
#s5g-reference-display .mini-thumb {
    cursor: pointer;
    overflow: hidden;
}
#s5g-reference-display .s5-ref-tag-label {
    border-radius: 0 0 8px 8px;
    font-size: 8px;
}
.s5g-prompt-view {
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-main, #fff);
    padding: 12px 4px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    width: 100%;
    box-sizing: border-box;
    max-height: 200px;
    overflow-y: auto;
    min-height: 2.5em;
    white-space: pre-wrap;
    word-break: break-word;
}
.s5g-prompt-view .s5-ref-chip,
.s5g-prompt-view .s5-ref-chip.is-known {
    cursor: default;
}
#s5g-tools {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 4px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
#s5g-tools .s5g-tool-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
#s5g-tools .s5g-tool-btn,
#s5g-tools .s5g-tool-scale-btn,
#s5g-tools .s5g-tool-scale-menu button {
    background: transparent;
    border: 0;
    box-shadow: none;
    transform: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    font-weight: 500;
    letter-spacing: -0.011em;
}
#s5g-tools .s5g-tool-btn {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 10px 0 8px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
#s5g-tools .s5g-tool-btn:hover,
#s5g-tools .s5g-tool-btn:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transform: none;
    box-shadow: none;
}
#s5g-tools .s5g-tool-btn:active {
    background: rgba(255, 255, 255, 0.12);
    transform: none;
    box-shadow: none;
}
#s5g-tools .s5g-tool-ico {
    display: flex;
    color: rgba(255, 255, 255, 0.48);
    flex: 0 0 auto;
}
#s5g-tools .s5g-tool-btn:hover .s5g-tool-ico {
    color: rgba(255, 255, 255, 0.78);
}
#s5g-tools .s5g-tool-ico svg {
    width: 15px;
    height: 15px;
    display: block;
}
#s5g-tools .s5g-tool-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#s5g-tools .s5g-tool-scale {
    position: relative;
    flex: 0 0 auto;
}
#s5g-tools .s5g-tool-scale-btn {
    height: 28px;
    min-width: 46px;
    margin-right: 4px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    cursor: pointer;
}
#s5g-tools .s5g-tool-scale-btn::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 3.5px solid currentColor;
    opacity: 0.45;
}
#s5g-tools .s5g-tool-scale-btn:hover,
#s5g-tools .s5g-tool-scale-btn:focus-visible {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    transform: none;
    box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.24);
}
#s5g-tools .s5g-tool-scale-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 40;
    min-width: 72px;
    padding: 4px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(28, 28, 32, 0.72);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
    flex-direction: column;
    gap: 1px;
}
#s5g-tools .s5g-tool-scale-menu.is-open {
    display: flex;
}
#s5g-tools .s5g-tool-scale-menu button {
    color: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 7px 10px;
    text-align: center;
    font-size: 12px;
    cursor: pointer;
}
#s5g-tools .s5g-tool-scale-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
    box-shadow: none;
}
.s5g-tool-tip {
    position: fixed;
    z-index: 100200;
    max-width: 240px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(28, 28, 32, 0.78);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    line-height: 1.45;
    pointer-events: none;
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.s5g-tool-tip[hidden] {
    display: none;
}
#s5g-drawing-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    z-index: 5;
    pointer-events: none;
}
#s5g-generating-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    align-items: center;
    justify-content: center;
    color: var(--text-main, #fff);
    font-size: 1.2rem;
    z-index: 6;
    backdrop-filter: blur(8px);
}
#s5g-generating-overlay.is-on { display: flex; }
.s5g-param-slots {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.s5g-chat-head {
    display: contents;
}
#s5g-attach-slot:empty {
    display: none;
}
.s5-gallery-card.is-gallery-dragging {
    opacity: 0.55;
}
.s5-gallery-drag-ghost {
    position: fixed;
    z-index: 10060;
    width: 72px;
    height: 72px;
    margin-left: -36px;
    margin-top: -88px;
    border-radius: 14px;
    background-size: cover;
    background-position: center;
    pointer-events: none;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.85);
}
.s5-ref-box.is-gallery-drop,
.s5-add-media-bar.is-gallery-drop,
#s5-image-ref-style.is-gallery-drop,
#s5g-attach-wrap.is-gallery-drop,
#s5g-attach-slot.is-gallery-drop,
#s5-style-picker-drop.is-gallery-drop {
    outline: 2px solid rgba(255, 255, 255, 0.85);
    outline-offset: 2px;
}
.s5g-attach-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}
.s5g-attach-thumbs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 220px;
}
.s5g-attach-thumbs .mini-thumb {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
}
.s5g-edit-submit {
    width: auto !important;
    min-width: 88px;
    height: 36px !important;
    border-radius: 18px !important;
    padding: 0 12px 0 8px !important;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    text-transform: lowercase;
}
.s5g-edit-submit:disabled {
    opacity: 0.35;
    pointer-events: none;
}
.s5g-edit-submit .smp-credits {
    margin-right: 2px;
}
.s5g-edit-submit .smp-credits[hidden] {
    display: none !important;
}
.s5g-copy-wrap {
    position: relative;
    flex-direction: row;
}
#s5g-copy-toast {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 8px;
    width: max-content;
}
.s5g-video-controls {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 14px;
    z-index: 7;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 8px 14px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(18, 18, 22, 0.42), rgba(8, 8, 10, 0.72));
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}
.s5g-video-controls[hidden] {
    display: none !important;
}
.s5g-video-time {
    min-width: 36px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.78);
}
#s5g-video-duration {
    color: rgba(243, 212, 138, 0.95);
}
.s5g-video-seek {
    flex: 1;
    height: 18px;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.s5g-video-seek-track {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    overflow: visible;
}
.s5g-video-seek-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, #f3d48a, #ffffff);
    position: relative;
}
.s5g-video-seek-fill::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    transform: translateY(-50%);
    box-shadow: 0 0 0 3px rgba(243, 212, 138, 0.22), 0 4px 10px rgba(0, 0, 0, 0.35);
}
.s5g-video-vol {
    display: flex;
    align-items: center;
    gap: 6px;
}
.s5g-video-mute {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.s5g-video-mute svg {
    width: 16px;
    height: 16px;
}
.s5g-video-mute:hover {
    background: rgba(255, 255, 255, 0.1);
}
.s5g-video-volume {
    width: 64px;
    height: 4px;
    margin: 0;
    padding: 0;
    appearance: none;
    background: rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    outline: none;
    cursor: pointer;
}
.s5g-video-volume::-webkit-slider-thumb {
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    border: none;
    box-shadow: 0 0 8px rgba(243, 212, 138, 0.45);
}
.s5g-video-volume::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    border: none;
}
#s5g-model-btn:disabled {
    opacity: 0.4;
    pointer-events: none;
}
#s5g-toolbar [data-s5g-image-only][hidden],
#s5g-toolbar [data-s5g-media-mirror][hidden] {
    display: none !important;
}
#s5g-chatBar {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}
#s5g-edit-input,
#s5g-edit-input:focus,
#s5g-chatBar textarea.s3-chat-input-box,
#s5g-chatBar textarea.s3-chat-input-box:focus {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ===== Generate composer (history above, dock pinned to the bottom) ===== */
.s5-settings-panel > .s5-history-list {
    order: 0;
    flex: 1 1 auto;
}
.s5-settings-panel > .s5-agent-host {
    order: 1;
    display: none !important;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    overflow: hidden;
}
.s5-settings-panel > .s5-dock {
    order: 2;
    flex: 0 0 auto;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.s5-settings-panel .s5-composer {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.s5-settings-panel.is-agent-tab > .s5-history-list,
.s5-settings-panel.is-agent-tab .s5-composer {
    display: none !important;
}
.s5-settings-panel.is-agent-tab > .s5-agent-host {
    display: flex !important;
    flex-direction: column;
}
.s5-settings-panel.is-agent-tab > .s5-dock {
    margin-top: 0;
}
.s5-settings-panel .s5-section-title {
    display: none !important;
}
.s5-settings-panel .s5-tabs {
    display: flex !important;
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    margin: 2px 0 0;
    padding: 0;
    gap: 4px;
    background: transparent;
    border: 0;
    overflow: visible;
}
.s5-settings-panel .s5-tabs .s5-tab {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 36px;
    padding: 0 4px;
    border-radius: 12px;
    background: transparent;
    color: #8e8e93;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    box-shadow: none;
}
.s5-settings-panel .s5-tabs .s5-tab svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}
.s5-settings-panel .s5-tabs .s5-tab-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.s5-settings-panel .s5-tabs .s5-tab:hover {
    color: #f2f2f4;
    background: rgba(255, 255, 255, 0.04);
}
.s5-settings-panel .s5-tabs .s5-tab.active {
    background: #2a2a2e;
    color: #fff;
    box-shadow: none;
}
.s5-settings-panel .s5-ref-grid-2,
.s5-settings-panel .s5-ref-grid-4 {
    margin-bottom: 10px;
}
.s5-settings-panel .s5-ref-box,
.s5-settings-panel .s5-add-media-bar {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    border: 1.5px dashed rgba(255, 255, 255, 0.28);
    background-color: transparent;
    color: #a1a1a6;
}
.s5-settings-panel .s5-prompt-container:not(.is-expanded) {
    height: auto;
    min-height: 148px;
    max-height: 188px;
    margin: 0 0 10px;
    padding: 12px 12px 46px;
    border-radius: 22px;
    background: #161618;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
html:not(.app-phone) .s5-settings-panel .s5-prompt-container:not(.is-expanded) {
    --s5-prompt-base: 148px;
    padding: 0;
    height: var(--s5-prompt-h, var(--s5-prompt-base));
    min-height: var(--s5-prompt-base);
    max-height: calc(var(--s5-prompt-base) * 2);
}
html:not(.app-phone) .s5-settings-panel .s5-prompt-highlight-wrap {
    position: absolute;
    top: 8px;
    right: 40px;
    bottom: 2px;
    left: 12px;
    margin: 0;
}
.s5-settings-panel .s5-prompt-container .s5-prompt-editor {
    padding-top: 2px;
    padding-right: 86px;
}
html:not(.app-phone) .s5-settings-panel .s5-prompt-container .s5-prompt-editor {
    padding: 0;
    height: 100%;
}
.s5-settings-panel .s5-prompt-tools {
    position: absolute;
    top: 8px;
    right: 36px;
    z-index: 6;
    gap: 0;
}
html:not(.app-phone) .s5-settings-panel .s5-prompt-tools {
    top: 38px;
    right: 8px;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.s5-settings-panel .s5-prompt-clear-btn {
    display: none;
}
.s5-settings-panel .s5-prompt-container:hover .s5-prompt-clear-btn,
.s5-settings-panel .s5-prompt-container:focus-within .s5-prompt-clear-btn {
    display: inline-flex;
}
.s5-settings-panel .s5-prompt-expand-btn {
    top: 8px;
    right: 8px;
}
.s5-settings-panel .s5-prompt-footer > span {
    display: none;
}
.s5-prompt-icon-btn,
.s5-settings-panel .s5-prompt-icon-btn,
.s5-settings-panel .s5-prompt-icon-btn:hover,
.s5-settings-panel .s5-prompt-icon-btn:active {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #8e8e93;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    transform: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.s5-settings-panel .s5-prompt-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.s5-settings-panel .s5-prompt-footer {
    position: absolute;
    left: 14px;
    right: 48px;
    bottom: 12px;
    margin: 0;
    min-height: 18px;
}
.s5-settings-panel .s5-controls-row {
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
    overflow: visible;
}
.s5-settings-panel .s5-controls-row .s5-control-btn,
.s5-settings-panel .s5-controls-row .s5-model-selector {
    flex: 0 0 auto;
    width: auto;
    height: 36px;
    min-height: 36px;
    margin: 0;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    background: #1c1c20;
    color: #ececee;
    font-size: 12px;
    font-weight: 600;
}
.s5-settings-panel .s5-controls-row .s5-model-selector {
    flex: 1 1 120px;
    min-width: 0;
    max-width: 100%;
    justify-content: flex-start;
    gap: 8px;
}
.s5-settings-panel .s5-controls-row .s5-model-selector:hover,
.s5-settings-panel .s5-controls-row .s5-control-btn:hover {
    background: #26262b;
    border-color: transparent;
    color: #fff;
}
.s5-settings-panel .s5-control-dropdown {
    top: auto;
    bottom: calc(100% + 8px);
}
.s5-settings-panel.is-agent-tab #s5-generate-btn {
    display: none !important;
}
#s5-dock > #s5-generate-btn {
    flex: 0 0 auto;
    align-self: stretch;
}

/* Generation column: flush to the rail and the viewport, line only on the right */
html.s5-settings-edge:not(.app-phone) #stage-5.active .s5-settings-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    left: var(--studio-rail-width, 76px);
    width: var(--s5-settings-width, 380px);
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    border: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: none;
    z-index: 30;
}
html.s5-settings-edge:not(.app-phone) #stage-5.active .s5-workspace {
    padding-left: var(--s5-settings-width, 380px);
}
html.s5-settings-edge:not(.app-phone) #stage-5.active:not(.s5-gallery-mode) .s5-editor-container {
    margin-left: 16px;
}
html:not(.app-phone) #stage-5.active:not(.s5-gallery-mode) .s5-stage-nav {
    position: relative;
}
html:not(.app-phone) #stage-5.active:not(.s5-gallery-mode) .s5-bottom-center-tools {
    position: absolute;
    left: var(--s5-editor-left, 0px);
    width: var(--s5-editor-width, 100%);
    top: 0;
    bottom: 0;
    margin: 0;
    justify-content: center;
}
html:not(.app-phone) #stage-5.active:not(.s5-gallery-mode) .s5-bottom-center-tools::before {
    content: '';
    width: 30px;
    flex: 0 0 30px;
}
html:not(.app-phone) #stage-5.active:not(.s5-gallery-mode) .s5-zoom-controls {
    transform: translateY(-12px);
}
html:not(.app-phone) #stage-5.active:not(.s5-gallery-mode) .s5-export-cluster {
    margin-left: auto;
    margin-right: 18px;
    z-index: 3;
}
html.s5-settings-edge:not(.app-phone):has(#stage-5.active) #mainHeader {
    margin-left: var(--s5-settings-width, 380px);
    width: auto;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
}
html.s5-settings-edge:not(.app-phone) #stage-5.active .s5-settings-panel + .s5-splitter {
    position: fixed;
    top: 0;
    bottom: 0;
    left: calc(var(--studio-rail-width, 76px) + var(--s5-settings-width, 380px) - 4px);
    width: 8px;
    height: auto;
    margin: 0;
    z-index: 35;
}
html.s5-settings-edge:not(.app-phone) #stage-5.active .s5-settings-panel + .s5-splitter::after {
    top: 0;
    bottom: 0;
    left: 4px;
    width: 1px;
    height: auto;
    transform: none;
    border-radius: 0;
    opacity: 0;
}
html.s5-settings-edge:not(.app-phone) #stage-5.active.s5-gallery-mode .s5-gallery-pane::before {
    display: none;
}

.s5-gallery-card {
    container-type: inline-size;
}
.s5-gallery-share svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
}
.s5-gallery-actions button.s5-gallery-timeline {
    width: auto;
    flex: 0 0 auto;
    gap: 5px;
    padding: 0 9px 0 7px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.1px;
    color: #fff;
}
.s5-gallery-actions button.s5-gallery-timeline span {
    line-height: 1;
    white-space: nowrap;
}
@container (max-width: 340px) {
    .s5-gallery-actions { gap: 4px; }
    .s5-gallery-actions button {
        width: 28px;
        height: 28px;
        border-radius: 8px;
    }
}
@container (max-width: 250px) {
    .s5-gallery-actions button {
        width: 24px;
        height: 24px;
    }
    .s5-gallery-actions button svg,
    .s5-gallery-share svg {
        width: 13px;
        height: 13px;
    }
    .s5-gallery-actions button.s5-gallery-timeline {
        width: 24px;
        height: 24px;
        padding: 0;
        gap: 0;
    }
    .s5-gallery-actions button.s5-gallery-timeline span {
        display: none;
    }
}

/* AI Generate keeps the share control in the top-right, apart from the action row. */
html.ai-generate-mode .s5-gallery-actions,
body.ai-generate-mode .s5-gallery-actions {
    top: 8px;
    height: auto;
    align-items: flex-end;
}
html.ai-generate-mode .s5-gallery-card:hover .s5-gallery-actions,
html.ai-generate-mode .s5-gallery-card:focus-within .s5-gallery-actions,
body.ai-generate-mode .s5-gallery-card:hover .s5-gallery-actions,
body.ai-generate-mode .s5-gallery-card:focus-within .s5-gallery-actions {
    pointer-events: none;
}
html.ai-generate-mode .s5-gallery-card:hover .s5-gallery-actions button,
html.ai-generate-mode .s5-gallery-card:focus-within .s5-gallery-actions button,
body.ai-generate-mode .s5-gallery-card:hover .s5-gallery-actions button,
body.ai-generate-mode .s5-gallery-card:focus-within .s5-gallery-actions button {
    pointer-events: auto;
}
html.ai-generate-mode .s5-gallery-share,
body.ai-generate-mode .s5-gallery-share {
    position: absolute;
    top: 0;
    right: 0;
}

@media (hover: none) {
    .s5-gallery-actions {
        opacity: 1;
        transform: none;
        pointer-events: none;
    }
    .s5-gallery-actions button {
        pointer-events: auto;
    }
}

.s5-share-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.s5-share-modal[hidden] { display: none; }
.s5-share-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.s5-share-card {
    position: relative;
    width: min(440px, 100%);
    padding: 22px 22px 18px;
    border-radius: 22px;
    background: rgba(20, 20, 22, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    color: #f5f5f7;
}
.s5-share-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #86868b;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
.s5-share-close:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.s5-share-kicker {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #86868b;
}
.s5-share-card h2 {
    margin: 0 36px 8px 0;
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -0.02em;
}
.s5-share-lead {
    margin: 0 0 16px;
    color: #86868b;
    font-size: 13px;
    line-height: 1.45;
}
.s5-share-link-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 14px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.s5-share-link-row input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: #f5f5f7;
    font: inherit;
    font-size: 13px;
    outline: none;
}
.s5-share-link-row button {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}
.s5-share-link-row button:hover { background: rgba(255, 255, 255, 0.14); }
.s5-share-link-row button:disabled { opacity: 0.4; cursor: default; }
.s5-share-link-row button svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
}
.s5-share-toggle {
    margin-top: 14px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}
.s5-share-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.s5-share-switch {
    width: 40px;
    height: 24px;
    flex: 0 0 40px;
    margin-top: 1px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    position: relative;
    transition: background 0.2s ease;
}
.s5-share-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
}
.s5-share-toggle input:checked + .s5-share-switch { background: #0a84ff; }
.s5-share-toggle input:checked + .s5-share-switch::after { transform: translateX(16px); }
.s5-share-toggle input:disabled + .s5-share-switch { opacity: 0.45; }
.s5-share-toggle input:focus-visible + .s5-share-switch {
    outline: 2px solid rgba(10, 132, 255, 0.8);
    outline-offset: 2px;
}
.s5-share-toggle-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.s5-share-toggle-copy strong {
    font-size: 13px;
    font-weight: 620;
}
.s5-share-toggle-copy small {
    color: #86868b;
    font-size: 12px;
    line-height: 1.4;
}
.s5-share-status {
    min-height: 18px;
    margin: 12px 0 0;
    color: #86868b;
    font-size: 12px;
}
