:root {
    --ai-global-color-blue-400: #1473e6;
    --ai-global-color-blue-500: #0d66d0;
    --ai-global-color-blue-600: #095aba;
    --ai-global-color-gray-25: #fcfcfc;
    --ai-global-color-gray-50: #f9f9f9;
    --ai-global-color-gray-75: #f4f4f4;
    --ai-global-color-gray-100: #efefef;
    --ai-global-color-gray-200: #e1e1e1;
    --ai-global-color-gray-300: #c8c8c8;
    --ai-global-color-gray-400: #b3b3b3;
    --ai-global-color-gray-500: #8e8e93;
    --ai-global-color-gray-600: #6e6e73;
    --ai-global-color-gray-700: #3a3a3c;
    --ai-global-color-gray-800: #1d1d1f;
    --ai-global-color-gray-900: #000000;
    --ai-global-color-green-400: #33ab84;
    --ai-global-color-green-500: #2d9d78;
    --ai-global-color-green-600: #268e6c;
    --ai-global-color-red-400: #e34850;
    --ai-global-color-red-500: #d7373f;
    --ai-global-color-red-600: #c9252d;
    --ai-global-font-family-base: "Adobe Clean", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Trebuchet MS", "Lucida Grande", sans-serif;
    --ai-global-font-weight-light: 300;
    --ai-global-font-weight-regular: 400;
    --ai-global-font-weight-medium: 500;
    --ai-global-font-weight-bold: 700;
    --ai-global-dimension-size-25: 2px;
    --ai-global-dimension-size-50: 4px;
    --ai-global-dimension-size-65: 5px;
    --ai-global-dimension-size-75: 6px;
    --ai-global-dimension-size-85: 7px;
    --ai-global-dimension-size-100: 8px;
    --ai-global-dimension-size-115: 9px;
    --ai-global-dimension-size-125: 10px;
    --ai-global-dimension-size-130: 10px;
    --ai-global-dimension-size-150: 12px;
    --ai-global-dimension-size-160: 13px;
    --ai-global-dimension-size-175: 14px;
    --ai-global-dimension-size-185: 15px;
    --ai-global-dimension-size-200: 16px;
    --ai-global-dimension-size-225: 18px;
    --ai-global-dimension-size-250: 20px;
    --ai-global-dimension-size-300: 24px;
    --ai-global-dimension-size-400: 32px;
    --ai-global-dimension-size-500: 40px;
    --ai-global-dimension-size-600: 48px;
    --ai-global-dimension-border-radius-small: 3px;
    --ai-global-dimension-border-radius-medium: 4px;
    --ai-global-dimension-border-radius-large: 8px;
    --ai-global-drop-shadow-color: rgba(0, 0, 0, 0.15);
    --ai-drop-shadow-y: 1px;
    --ai-drop-shadow-blur: 4px;
}
#comfyPage * {
    box-sizing: border-box;
    -webkit-user-select: initial !important;
    -moz-user-select: initial !important;
    -ms-user-select: initial !important;
    user-select: initial !important;
}
#comfyPage {
    font-family: var(--ai-global-font-family-base);
    font-weight: var(--ai-global-font-weight-regular);
    background-color: var(--ai-global-color-gray-50);
    color: var(--ai-global-color-gray-800);
    margin: 0;
    padding: 0;
    height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
#comfyPage .ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--ai-global-color-gray-25);
    width: 100%;
    max-width: 300px;
    font-family: var(--ai-global-font-family-base);
    position: relative;
    overflow: hidden;
}
#comfyPage .ai-chat-header {
    padding: var(--ai-global-dimension-size-150);
    background: var(--ai-global-color-green-500);
    color: white;
    font-weight: var(--ai-global-font-weight-medium);
    font-size: var(--ai-global-dimension-size-175);
    text-align: center;
    border-bottom: 1px solid var(--ai-global-color-gray-200);
    flex-shrink: 0; 
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}
#comfyPage .ai-chat-messages {
    flex: 1; 
    overflow-y: auto;
    padding: var(--ai-global-dimension-size-150);
    background: var(--ai-global-color-gray-50);
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    box-sizing: border-box;
    min-height: 200px;
}
#comfyPage .ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}
#comfyPage .ai-chat-messages::-webkit-scrollbar-track {
    background: var(--ai-global-color-gray-200);
    border-radius: 4px;
}
#comfyPage .ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--ai-global-color-gray-400);
    border-radius: 4px;
}
#comfyPage .ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--ai-global-color-gray-500);
}
#comfyPage .ai-message {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    margin-bottom: 3px !important; 
    position: relative;
    clear: both;
    display: block;
    flex-shrink: 0;
    min-height: auto; 
}
#comfyPage .ai-message-content {
    display: block;
    padding: var(--ai-global-dimension-size-175);
    border-radius: var(--ai-global-dimension-border-radius-medium);
    font-family: var(--ai-global-font-family-base);
    font-size: var(--ai-global-dimension-size-160);
    line-height: 1.5;
    border: 1px solid var(--ai-global-color-gray-300);
    background: var(--ai-global-color-gray-75);
    color: var(--ai-global-color-gray-800);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    box-sizing: border-box;
    width: 100%;
    overflow: visible;
    position: relative;
    z-index: 1;
    min-height: auto;
    height: auto;
}
#comfyPage .ai-message-content:hover {
    background: var(--ai-global-color-gray-100);
    border-color: var(--ai-global-color-blue-400);
}
#comfyPage .ai-message--user .ai-message-content {
    background: var(--ai-global-color-blue-500);
    color: white;
    border-color: var(--ai-global-color-blue-600);
}
#comfyPage .ai-message--user .ai-message-content:hover {
    background: var(--ai-global-color-blue-600);
    border-color: var(--ai-global-color-blue-700);
}
#comfyPage .ai-message--assistant .ai-message-content {
    background: var(--ai-global-color-gray-75);
    color: var(--ai-global-color-gray-800);
    border-color: var(--ai-global-color-gray-300);
}
#comfyPage .ai-message--assistant .ai-message-content:hover {
    background: var(--ai-global-color-gray-100);
    border-color: var(--ai-global-color-blue-400);
}
#comfyPage .ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--ai-global-dimension-size-175);
    color: var(--ai-global-color-gray-600);
    font-style: italic;
    border: 1px solid var(--ai-global-color-gray-300);
    border-radius: var(--ai-global-dimension-border-radius-medium);
    background: var(--ai-global-color-gray-75);
    font-family: var(--ai-global-font-family-base);
    font-size: var(--ai-global-dimension-size-160);
    margin-bottom: 3px !important; 
    flex-shrink: 0;
    min-height: auto;
    height: auto;
}
#comfyPage .ai-loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: var(--ai-global-dimension-size-100);
    border: 2px solid transparent;
    border-top: 2px solid var(--ai-global-color-blue-500);
    border-radius: 50%;
    animation: ai-spin 1s linear infinite;
}
@keyframes ai-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
#comfyPage .ai-error {
    background-color: #fef2f2;
    border: 1px solid var(--ai-global-color-red-400);
    color: var(--ai-global-color-red-600);
    padding: var(--ai-global-dimension-size-175);
    border-radius: var(--ai-global-dimension-border-radius-medium);
    margin-bottom: 3px !important; 
    font-size: var(--ai-global-dimension-size-160);
    font-family: var(--ai-global-font-family-base);
    line-height: 1.5;
    width: 100%;
    user-select: text;
    cursor: text;
    box-sizing: border-box;
    flex-shrink: 0;
    min-height: auto;
    height: auto;
}
.ai-message-edit-input.pure-text-input {
    background: var(--ai-global-color-gray-25) !important;
    border: 2px solid var(--ai-global-color-blue-400) !important;
    border-radius: var(--ai-global-dimension-border-radius-medium) !important;
    color: var(--ai-global-color-gray-800) !important;
    font-family: var(--ai-global-font-family-base) !important;
    font-size: var(--ai-global-dimension-size-160) !important;
    line-height: 1.5 !important;
    outline: none !important;
    width: 100% !important;
    max-height: 380px !important;
    padding: var(--ai-global-dimension-size-175) !important;
    box-sizing: border-box !important;
    position: relative !important;
    z-index: 10 !important;
    resize: none !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    box-shadow: 0 0 8px rgba(20, 115, 230, 0.3) !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    overflow-y: auto !important;
    scrollbar-width: thin !important;
    scrollbar-color: var(--ai-global-color-blue-400) var(--ai-global-color-gray-200) !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    cursor: text !important;
}
#comfyPage .ai-message--user .ai-message-edit-input.pure-text-input {
    background: var(--ai-global-color-blue-500) !important;
    color: white !important;
    border-color: white !important;
}
#comfyPage .ai-message--user .ai-message-edit-input.pure-text-input:focus {
    border-color: white !important;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.4) !important;
}
#comfyPage .ai-message--user .ai-message-edit-input.pure-text-input::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.7) !important;
}
#comfyPage .ai-message--user .ai-message-edit-input.pure-text-input::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.9) !important;
}
#comfyPage .ai-edit-hint {
    font-size: 12px;
    color: var(--ai-global-color-gray-500);
    font-style: italic;
    margin-top: 4px;
    margin-bottom: 0; 
    text-align: center;
}
#comfyPage .ai-chat-input-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 3px !important;
    padding: 10px 10px 10px 10px !important; 
    width: 100% !important;
    box-sizing: border-box !important;
}
#comfyPage .ai-textarea-input {
    width: 260px !important; 
    max-width: 260px !important; 
    height: 80px !important;
    min-height: 80px !important;
    max-height: 120px !important;
    margin: 0 !important; 
    resize: none !important;
    box-sizing: border-box !important;
    text-align: left !important;
    overflow-y: auto !important;
    flex-shrink: 0 !important; 
    display: block !important; 
    scrollbar-width: thin !important;
    scrollbar-color: var(--ai-global-color-gray-400) var(--ai-global-color-gray-200) !important;
}
#comfyPage .ai-button-container {
    display: flex !important;
    justify-content: space-between !important;
    width: 260px !important; 
    max-width: 260px !important;
    margin: 0 !important; 
    flex-shrink: 0 !important; 
    padding: 0 !important; 
    box-sizing: border-box !important;
}
sp-textarea.ai-textarea-input {
    display: block !important;
    margin: 0 !important; 
    width: 260px !important; 
    max-width: 260px !important; 
    overflow-y: auto !important; 
}
sp-textarea.ai-textarea-input::-webkit-scrollbar {
    width: 8px;
}
sp-textarea.ai-textarea-input::-webkit-scrollbar-track {
    background: var(--ai-global-color-gray-200);
    border-radius: 4px;
}
sp-textarea.ai-textarea-input::-webkit-scrollbar-thumb {
    background: var(--ai-global-color-gray-400);
    border-radius: 4px;
}
sp-textarea.ai-textarea-input::-webkit-scrollbar-thumb:hover {
    background: var(--ai-global-color-gray-500);
}
sp-textarea.ai-textarea-input::part(textfield) {
    text-align: left !important;
    width: 260px !important; 
    max-width: 260px !important; 
    box-sizing: border-box !important;
    overflow-y: auto !important; 
}
sp-textarea.ai-textarea-input::part(textfield)::-webkit-scrollbar {
    width: 8px;
}
sp-textarea.ai-textarea-input::part(textfield)::-webkit-scrollbar-track {
    background: var(--ai-global-color-gray-200);
    border-radius: 4px;
}
sp-textarea.ai-textarea-input::part(textfield)::-webkit-scrollbar-thumb {
    background: var(--ai-global-color-gray-400);
    border-radius: 4px;
}
sp-textarea.ai-textarea-input::part(textfield)::-webkit-scrollbar-thumb:hover {
    background: var(--ai-global-color-gray-500);
}
#comfyPage .ai-button {
    width: 122px !important; 
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    min-width: 100px !important; 
    flex: none !important; 
    padding: 0 !important;
    border: 1px solid transparent;
    border-radius: var(--ai-global-dimension-border-radius-medium);
    font-family: var(--ai-global-font-family-base);
    font-size: var(--ai-global-dimension-size-150);
    font-weight: var(--ai-global-font-weight-medium);
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    box-sizing: border-box;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}
#comfyPage .ai-button--primary {
    background: var(--ai-global-color-green-500);
    color: white;
    border-color: var(--ai-global-color-green-600);
}
#comfyPage .ai-button--primary:hover {
    background: var(--ai-global-color-green-600);
    border-color: var(--ai-global-color-green-600);
}
#comfyPage .ai-button--primary:disabled {
    background: var(--ai-global-color-gray-200);
    color: var(--ai-global-color-gray-500);
    border-color: var(--ai-global-color-gray-300);
    cursor: not-allowed;
}
#comfyPage .ai-button--secondary {
    background: var(--ai-global-color-red-500);
    color: white;
    border-color: var(--ai-global-color-red-600);
}
#comfyPage .ai-button--secondary:hover {
    background: var(--ai-global-color-red-600);
    border-color: var(--ai-global-color-red-600);
}
#comfyPage .ai-button--secondary:disabled {
    background: var(--ai-global-color-gray-200);
    color: var(--ai-global-color-gray-500);
    border-color: var(--ai-global-color-gray-300);
    cursor: not-allowed;
}
@media (max-width: 300px) {
    #comfyPage .ai-chat-header {
        padding: 8px;
        font-size: var(--ai-global-dimension-size-160);
    }
    #comfyPage .ai-chat-messages {
        padding: 8px;
    }
    #comfyPage .ai-message {
        margin-bottom: 3px !important; 
    }
    #comfyPage .ai-message-content {
        font-size: var(--ai-global-dimension-size-150);
        padding: var(--ai-global-dimension-size-125);
    }
    #comfyPage .ai-chat-input-container {
        padding: 10px 10px 3px 10px !important; 
        gap: 3px !important; 
    }
    #comfyPage .ai-textarea-input {
        width: 248px !important; 
        height: 100px !important; 
        font-size: var(--ai-global-dimension-size-150);
    }
    #comfyPage .ai-button-container {
        width: 248px !important; 
        padding: 0 !important; 
    }
    #comfyPage .ai-button {
        height: 30px !important; 
        font-size: var(--ai-global-dimension-size-130); 
    }
    #comfyPage .ai-loading,
    #comfyPage .ai-error {
        margin-bottom: 3px !important; 
    }
}
@media (prefers-color-scheme: dark) {
    :root {
        --ai-global-color-gray-25: #1d1d1f;
        --ai-global-color-gray-50: #2c2c2e;
        --ai-global-color-gray-75: #3a3a3c;
        --ai-global-color-gray-100: #48484a;
        --ai-global-color-gray-200: #636366;
        --ai-global-color-gray-800: #f2f2f7;
        --ai-global-color-gray-900: #ffffff;
    }
    #comfyPage .ai-message--assistant .ai-message-content {
        background: var(--ai-global-color-gray-75);
        color: var(--ai-global-color-gray-900);
        border-color: var(--ai-global-color-gray-200);
    }
    #comfyPage .ai-error {
        background-color: #3a1f1f;
        border-color: var(--ai-global-color-red-400);
    }
    #comfyPage .ai-textarea-input {
        background: var(--ai-global-color-gray-75);
        color: var(--ai-global-color-gray-900);
        border-color: var(--ai-global-color-gray-400);
    }
}
#comfyPage .ai-chat-container:focus-within #comfyPage .ai-textarea-input {
    border-color: var(--ai-global-color-blue-400);
    box-shadow: 0 0 0 1px var(--ai-global-color-blue-400);
}
#comfyPage .ai-message {
    animation: ai-slideIn 0.3s ease-out;
}
@keyframes ai-slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}