* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: #343541;
    color: #ececf1;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* Script Editor Styles */
.script-editor {
    width: 400px;
    background: #202123;
    border-right: 1px solid #4d4d4f;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100;
}

.script-editor.hidden {
    transform: translateX(-100%);
    position: absolute;
    left: 0;
    height: 100%;
}

.script-header {
    padding: 20px;
    border-bottom: 1px solid #4d4d4f;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.script-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    color: #ececf1;
    font-size: 32px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    line-height: 1;
    padding: 0;
}

.btn-close:hover {
    background: #40414f;
}

#scriptInput {
    flex: 1;
    background: #40414f;
    border: none;
    color: #ececf1;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: none;
    outline: none;
}

#scriptInput::placeholder {
    color: #8e8ea0;
}

.script-controls {
    padding: 20px;
    display: flex;
    gap: 10px;
    border-top: 1px solid #4d4d4f;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #10a37f;
    color: white;
}

.btn-primary:hover {
    background: #0d8c6d;
}

.btn-secondary {
    background: #40414f;
    color: #ececf1;
}

.btn-secondary:hover {
    background: #565869;
}

.script-settings {
    padding: 20px;
    border-top: 1px solid #4d4d4f;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 40px;
    height: 20px;
    appearance: none;
    background: #40414f;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-label input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #8e8ea0;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
}

.toggle-label input[type="checkbox"]:checked {
    background: #10a37f;
}

.toggle-label input[type="checkbox"]:checked::before {
    background: white;
    left: 22px;
}

.toggle-text {
    color: #ececf1;
    font-size: 14px;
}

.scroll-mode-container,
.scroll-speed-container {
    margin-top: 15px;
}

.speed-label {
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: default;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.speed-indicator {
    color: #8e8ea0;
    font-size: 12px;
    min-width: 35px;
}

#scrollSpeedSlider {
    flex: 1;
    height: 4px;
    appearance: none;
    background: #40414f;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

#scrollSpeedSlider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #10a37f;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

#scrollSpeedSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#scrollSpeedSlider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #10a37f;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

#scrollSpeedSlider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #343541;
}

.chat-header {
    background: #343541;
    border-bottom: 1px solid #4d4d4f;
    padding: 12px 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.btn-toggle {
    background: none;
    border: none;
    color: #ececf1;
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.btn-toggle:hover {
    background: #40414f;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.message {
    margin-bottom: 20px;
    display: flex;
    gap: 16px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background: #343541;
}

.message.assistant {
    background: #444654;
    margin-left: -20px;
    margin-right: -20px;
    padding: 20px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.message.user .avatar {
    background: #5436da;
}

.message.assistant .avatar {
    background: #10a37f;
}

.message-content {
    flex: 1;
    padding-top: 6px;
}

.message-text {
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Thinking indicator */
.thinking {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    color: #8e8ea0;
    font-style: italic;
}

.thinking .hourglass-spinner {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* Image placeholder */
.image-placeholder {
    width: 100%;
    max-width: 512px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #8e8ea0;
    margin: 10px 0;
    padding: 60px 0;
    gap: 20px;
}

.image-placeholder .hourglass-spinner {
    width: 200px;
    height: 200px;
}

.message-image {
    max-width: 512px;
    border-radius: 8px;
    margin: 10px 0;
    display: block;
}

.image-wrapper {
    position: relative;
    max-width: 512px;
    margin: 10px 0;
    border-radius: 8px;
    overflow: hidden;
}

.message-image-blurred,
.message-image-sharp {
    max-width: 512px;
    width: 100%;
    border-radius: 8px;
    display: block;
}

.message-image-blurred {
    position: relative;
}

.message-image-sharp {
    position: absolute;
    top: 0;
    left: 0;
}

/* Chat Input */
.chat-input-container {
    padding: 20px;
    background: #343541;
}

.input-wrapper {
    background: #40414f;
    border-radius: 12px;
    display: flex;
    align-items: flex-end;
    padding: 12px;
    gap: 12px;
    border: 1px solid #565869;
}

.input-wrapper:focus-within {
    border-color: #10a37f;
}

#userInput {
    flex: 1;
    background: none;
    border: none;
    color: #ececf1;
    font-size: 16px;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 200px;
    line-height: 1.5;
}

#userInput::placeholder {
    color: #8e8ea0;
}

#userInput:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn {
    background: #10a37f;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: #0d8c6d;
}

.send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #343541;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #565869;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #6e6e80;
}

#scriptInput::-webkit-scrollbar {
    width: 8px;
}

#scriptInput::-webkit-scrollbar-track {
    background: #40414f;
}

#scriptInput::-webkit-scrollbar-thumb {
    background: #565869;
    border-radius: 4px;
}
