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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    overflow: hidden;
    height: 100vh;
    touch-action: manipulation;
}

.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Camera feed background */
.video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    z-index: 1;
    transform: scaleX(-1); /* Mirror the video like a selfie camera */
}

/* Recording Controls at Bottom */
.recording-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.85);
    padding: 15px 20px 20px 20px;
    border-radius: 25px;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.all-controls-inline {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-section {
    display: flex;
    align-items: center;
}

.separator {
    color: #666;
    font-size: 20px;
    font-weight: 300;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    overflow: hidden;
    height: 100vh;
    touch-action: manipulation;
}

.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
     .script-box {
        width: 95vw;
        height: 45vh;
    }
}

@media (orientation: landscape) and (max-width: 768px) {
    .script-box {
        width: 70vw;
        height: 70vh;
    }
}

/* Camera feed background */
.video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    z-index: 1;
    transform: scaleX(-1); /* Mirror the video like a selfie camera */
}

/* Recording Controls at Bottom */
.recording-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.85);
    padding: 20px;
    border-radius: 25px;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.control-buttons {
    display: flex;
    gap: 15px;
    align-items: center;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    position: relative;
}

.record-btn {
    background: #333;
    color: white;
    border: 2px solid #ff4444;
}

.record-btn:hover {
    background: #444;
    border-color: #ff6666;
    transform: scale(1.1);
}

.record-btn.recording {
    background: #ff0000;
    border-color: #ff0000;
    animation: pulse 1.5s infinite;
}

.rotate-btn {
    background: #4CAF50;
    color: white;
}

.rotate-btn:hover {
    background: #66BB6A;
    transform: scale(1.1);
}

.rotate-btn.active {
    background: #2E7D32;
}

.camera-btn {
    background: #2196F3;
    color: white;
}

.camera-btn:hover {
    background: #42A5F5;
    transform: scale(1.1);
}

.record-icon {
    width: 16px;
    height: 16px;
    background: #ff4444;
    border-radius: 50%;
    position: relative;
    border: 2px solid #ff4444;
}

.record-btn.recording .record-icon {
    background: white;
    border-color: white;
    border-radius: 4px;
    animation: recordingIcon 0.5s ease-in-out;
}

.rotate-icon {
    font-size: 24px;
    font-weight: bold;
}

.camera-icon {
    font-size: 20px;
}

.sliders-container {
    display: flex;
    gap: 30px;
    align-items: center;
}

.button-group {
    display: flex;
    gap: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px;
}

.control-setting-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #cccccc;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 50px;
}

.control-setting-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.control-setting-btn.active {
    background: #4CAF50;
    color: #ffffff;
}

.control-setting-btn.active:hover {
    background: #66BB6A;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 12px;
    font-weight: 500;
    color: #cccccc;
    white-space: nowrap;
}

.slider {
    width: 80px;
    height: 6px;
    border-radius: 3px;
    background: #444444;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
    background: #66BB6A;
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
}

#speedValue, #textSizeValue {
    font-size: 11px;
    color: #cccccc;
    min-width: 30px;
    text-align: center;
}

/* Script Box */
.script-box {
    position: absolute;
    top: 5px; /* Position at the top of the window */
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 300px;
    background: rgba(0, 0, 0, 0.1);
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 300px;
    min-height: 150px;
    max-width: 90vw;
    max-height: 70vh;
    z-index: 100;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    /* Enable relative positioning for resize handle */
}

/* Resize handle styling */
.script-resize-handle {
    transition: background-color 0.2s ease;
    z-index: 10;
}

.script-resize-handle-bottom {
    position: absolute;
    bottom: 0;
    left: 10px; /* Leave space for side handles */
    right: 10px; /* Leave space for side handles */
    height: 10px;
    background: rgba(255, 255, 255, 0.3);
    cursor: ns-resize;
    border-radius: 0 0 8px 8px;
}

.script-resize-handle-left {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 10px; /* Leave space for bottom handle */
    width: 10px;
    background: rgba(255, 255, 255, 0.3);
    cursor: ew-resize;
    border-radius: 12px 0 0 0;
}

.script-resize-handle-right {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 10px; /* Leave space for bottom handle */
    width: 10px;
    background: rgba(255, 255, 255, 0.3);
    cursor: ew-resize;
    border-radius: 0 12px 0 0;
}

.script-resize-handle:hover {
    background: rgba(255, 255, 255, 0.6);
}


.script-input {
    width: 100%;
    height: 100px;
    padding: 16px;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-family: inherit;
    font-size: 16px;
    resize: none;
    outline: none;
}

.script-input.unified-script {
    height: calc(100% - 10px); /* Account for bottom resize handle */
    padding: 16px 26px 16px 26px; /* Account for left and right resize handles */
    border-bottom: none;
    font-size: 24px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: transparent;
    overflow: hidden;
}

.script-input.unified-script.scrolling {
    animation: none; /* Remove the transform animation */
    pointer-events: none; /* Disable editing during scrolling */
}

.script-input::placeholder {
    color: #aaa;
}



/* Text rotation for landscape mode */
/* Rotation for centered box (default position) */
.script-box.rotated:not([style*="left"]) {
    transform: translateX(-50%) rotate(90deg);
}

/* Responsive Design */
@media (max-width: 768px) {
    .recording-controls {
        bottom: 10px;
        padding: 15px;
        max-width: 90vw;
    }
    
    .all-controls-inline {
        gap: 10px;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 14px;
    }
    
    .control-setting-btn {
        padding: 6px 8px;
        font-size: 11px;
        min-width: 40px;
    }
    
    .separator {
        font-size: 16px;
    }
    
    .script-box {
        width: 90vw;
        height: 40vh;
        top: 0px; /* Keep at top for mobile */
    }
}

@media (max-width: 480px) {
    .recording-controls {
        padding: 10px;
        gap: 8px;
    }
    
    .all-controls-inline {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 12px;
    }
    
    .control-setting-btn {
        padding: 4px 6px;
        font-size: 10px;
        min-width: 35px;
    }
    
    .separator {
        font-size: 14px;
        display: none; /* Hide separators on very small screens */
    }
    
    .script-box {
        width: 95vw;
        height: 35vh;
        top: 10px; /* Keep at top for mobile */
    }
    
    .script-display {
        font-size: 18px;
    }
}

@media (orientation: landscape) and (max-width: 768px) {
    .script-box {
        width: 70vw;
        height: 70vh;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes dots {
    0%, 20% { content: ""; }
    40% { content: "."; }
    60% { content: ".."; }
    80%, 100% { content: "..."; }
}

@keyframes recordingIcon {
    from { border-radius: 50%; }
    to { border-radius: 2px; }
}

@keyframes scroll-up {
    0% { 
        transform: translateY(0%); 
    }
    100% { 
        transform: translateY(-80%); 
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .script-box {
        border: 3px solid #ffffff;
        background: #000000;
    }
    
    .recording-controls {
        border: 2px solid #ffffff;
        background: #000000;
    }
}
