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


/* RESET EVERYTHING - FORCE NATURAL SCROLLING */

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y pinch-zoom !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #fff;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    height: 100vh !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y pinch-zoom !important;
    position: static !important;
}


/* SIMPLE TOUCH HANDLING */

body,
html,
.app-container,
.main-content {
    touch-action: pan-y pinch-zoom !important;
}

.timeline {
    touch-action: pan-y !important;
}

.handle {
    touch-action: pan-x !important;
}

.playhead-cursor {
    touch-action: pan-x !important;
}


/* NO SCROLL LAYOUT - FIT EVERYTHING IN VIEWPORT */

.app-container {
    width: 100%;
    height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: static !important;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 0.6rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    z-index: 10;
}

.header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.main-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    overflow: hidden !important;
    position: static !important;
    flex: 1 !important;
}

.video-section {
    background: #2a2a2a;
    height: 50vh !important;
    max-height: 50vh !important;
    min-height: 300px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: static !important;
    flex-shrink: 0 !important;
}

.video-header {
    padding: 0.6rem;
    background: #333;
    border-bottom: 1px solid #444;
    flex-shrink: 0;
}

.video-header h3 {
    font-size: 0.9rem;
    margin: 0;
}

.video-container {
    background: #000;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    flex: 1;
}

.video-container video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    display: block;
}


/* Responsive video on touch devices */

@media (hover: none) and (pointer: coarse) {
    .video-container video {
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        object-fit: cover !important;
    }
}

.camera-selector {
    display: flex;
    gap: 0.4rem;
    padding: 0.6rem;
    overflow-x: auto;
    background: #333;
    flex-shrink: 0;
    border-top: 1px solid #444;
    min-height: 0;
}

.camera-btn {
    padding: 0.4rem 0.8rem;
    background: #555;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 70px;
}

.camera-btn:hover {
    background: #666;
}

.camera-btn.active {
    background: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.controls-panel {
    background: #2a2a2a;
    border-top: 1px solid #444;
    padding: 0.8rem;
    display: flex !important;
    flex-direction: column !important;
    height: 50vh !important;
    max-height: 50vh !important;
    overflow-y: auto !important;
    position: static !important;
    flex: 1 !important;
}

.timeline-section {
    border-bottom: 1px solid #444;
    margin-bottom: 0.8rem;
    padding-bottom: 0.8rem;
    flex-shrink: 0;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.timeline-header h3 {
    font-size: 0.9rem;
    margin: 0;
}

.time-display {
    font-size: 0.8rem;
    opacity: 0.8;
}

.timeline-container {
    background: #1a1a1a;
    border-radius: 6px;
    padding: 0.8rem;
    margin-bottom: 0.8rem;
}

.timeline-info {
    background: #333;
    border-radius: 4px;
    padding: 0.4rem;
    margin-bottom: 0.4rem;
    font-size: 0.75rem;
    text-align: center;
    opacity: 0.9;
}

.timeline {
    position: relative;
    height: 25px;
    background: linear-gradient(to right, #ff4444, #ffaa00, #00ff44);
    border-radius: 4px;
    margin: 0.8rem 0;
    cursor: pointer;
}

.timeline-markers {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    margin-top: 0.4rem;
    opacity: 0.8;
    gap: 0.4rem;
}

.timeline-markers>div {
    flex: 1;
    text-align: center;
    line-height: 1.1;
}

.timeline-markers>div:first-child {
    text-align: left;
}

.timeline-markers>div:last-child {
    text-align: right;
}

.selection-handles {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #fff;
    border-radius: 4px;
    pointer-events: none;
}

.playhead-cursor {
    position: absolute;
    top: -10px;
    width: 3px;
    height: 47px;
    background: #ff6b6b;
    border-radius: 2px;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.5);
    z-index: 15;
    transition: box-shadow 0.3s ease;
}

.playhead-cursor:hover {
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.8);
}

.playhead-cursor::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    width: 10px;
    height: 10px;
    background: #ff6b6b;
    border-radius: 50%;
    border: 1px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.playhead-cursor::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: -5px;
    width: 10px;
    height: 10px;
    background: #ff6b6b;
    border-radius: 50%;
    border: 1px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.handle {
    position: absolute;
    top: -4px;
    width: 10px;
    height: 33px;
    background: #fff;
    border-radius: 9px;
    cursor: ew-resize;
    pointer-events: all;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.handle.start {
    left: -9px;
}

.handle.end {
    right: -9px;
}

.selection-info {
    background: #333;
    border-radius: 4px;
    padding: 0.6rem;
    margin-top: 0.6rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.duration-info {
    font-size: 0.8rem;
}

.controls-section {
    display: flex;
    gap: 0.8rem;
    margin-top: 0.8rem;
    flex-shrink: 0;
}

.btn {
    flex: 1;
    padding: 0.8rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #555;
    color: #fff;
}

.btn-secondary:hover:not(:disabled) {
    background: #666;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.progress-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    color: white;
    font-size: 16px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.progress-section h3 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: #fff;
}

.progress-bar {
    width: 60%;
    max-width: 400px;
    height: 8px;
    background: #444;
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.status-text {
    text-align: center;
    margin: 1rem 0;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    max-width: 80%;
}

.error-message {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid #ff4444;
    color: #ff6b6b;
    padding: 0.8rem;
    border-radius: 6px;
    margin-top: 0.6rem;
    display: none;
    flex-shrink: 0;
}


/* Mobile optimizations - adjust for no-scroll layout */

@media (max-width: 768px) {
    .header {
        padding: 0.5rem;
    }
    .header h1 {
        font-size: 1rem;
    }
    .video-section {
        height: 45vh !important;
        max-height: 45vh !important;
        min-height: 250px !important;
    }
    .controls-panel {
        height: 55vh !important;
        max-height: 55vh !important;
        padding: 0.6rem;
    }
    .timeline {
        height: 30px;
    }
    .handle {
        width: 20px;
        height: 40px;
    }
    .handle.start {
        left: -10px;
    }
    .handle.end {
        right: -10px;
    }
    .playhead-cursor {
        height: 47px;
    }
    
    .playhead-cursor::before,
    .playhead-cursor::after {
        width: 8px;
        height: 8px;
        top: -4px;
        left: -4px;
    }
    
    .playhead-cursor::after {
        bottom: -4px;
        top: auto;
    }
    .btn {
        padding: 0.7rem;
        font-size: 0.85rem;
    }
}


/* Extra small devices */

@media (max-width: 480px) {
    .header {
        padding: 0.4rem;
    }
    .header h1 {
        font-size: 0.9rem;
    }
    .video-section {
        height: 40vh !important;
        max-height: 40vh !important;
        min-height: 200px !important;
    }
    .controls-panel {
        height: 60vh !important;
        max-height: 60vh !important;
        padding: 0.5rem;
    }
    .timeline {
        height: 25px;
    }
    
    .playhead-cursor {
        height: 47px;
    }
    
    .playhead-cursor::before,
    .playhead-cursor::after {
        width: 6px;
        height: 6px;
        top: -3px;
        left: -3px;
    }
    
    .playhead-cursor::after {
        bottom: -3px;
        top: auto;
    }
    .btn {
        padding: 0.6rem;
        font-size: 0.8rem;
    }
    .camera-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
        min-width: 60px;
    }
}


/* Landscape mobile - prioritize video */

@media (max-width: 768px) and (orientation: landscape) {
    /* Ensure no-scroll layout works in landscape */
    html,
    body {
        height: 100vh !important;
        overflow: hidden !important;
    }
    .app-container {
        height: 100vh !important;
        overflow: hidden !important;
    }
    .main-content {
        height: 100vh !important;
        overflow: hidden !important;
    }
    .video-section {
        height: 65vh !important;
        max-height: 65vh !important;
        min-height: 200px !important;
        overflow: hidden !important;
    }
    .controls-panel {
        height: 35vh !important;
        max-height: 35vh !important;
        overflow-y: auto !important;
        padding: 0.4rem !important;
    }
    /* Compact layout for landscape */
    .timeline-header {
        margin-bottom: 0.4rem;
    }
    .timeline-header h3 {
        font-size: 0.8rem;
    }
    .time-display {
        font-size: 0.7rem;
    }
    .timeline-container {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }
    .timeline {
        height: 20px;
        margin: 0.4rem 0;
    }
    
    .playhead-cursor {
        height: 47px;
    }
    
    .playhead-cursor::before,
    .playhead-cursor::after {
        width: 5px;
        height: 5px;
        top: -2.5px;
        left: -2.5px;
    }
    
    .playhead-cursor::after {
        bottom: -2.5px;
        top: auto;
    }
    .timeline-markers {
        font-size: 0.6rem;
        margin-top: 0.3rem;
    }
    .selection-info {
        padding: 0.4rem;
        margin-top: 0.4rem;
    }
    .duration-info {
        font-size: 0.7rem;
    }
    .controls-section {
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    .btn {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    .camera-selector {
        padding: 0.4rem;
        gap: 0.3rem;
    }
    .camera-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
        min-width: 60px;
    }
    /* Ensure progress modal stays on top in landscape */
    .progress-section {
        z-index: 999999 !important;
        background-color: rgba(0, 0, 0, 0.95) !important;
    }
    /* Ensure video section doesn't overflow in landscape */
    .video-container {
        height: 100% !important;
        max-height: 100% !important;
    }
    .video-container video {
        height: 100% !important;
        max-height: 100% !important;
    }
}


/* Desktop - optimize space usage */

@media (min-width: 1200px) {
    .video-section {
        height: 55vh !important;
        max-height: 55vh !important;
    }
    .controls-panel {
        height: 45vh !important;
        max-height: 45vh !important;
    }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: white;
    font-size: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #555;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}


/* Video status overlays */

.video-status {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 193, 7, 0.9);
    color: #333;
    padding: 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    z-index: 10;
}


/* Hide scrollbars but keep functionality */

.controls-panel::-webkit-scrollbar {
    width: 4px;
}

.controls-panel::-webkit-scrollbar-track {
    background: #2a2a2a;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 2px;
}

.controls-panel::-webkit-scrollbar-thumb:hover {
    background: #666;
}


/* Ensure no scrolling anywhere */

html,
body,
.app-container,
.main-content {
    overflow: hidden !important;
}