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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    font-weight: 600;
}

.upload-section {
    padding: 40px;
    text-align: center;
    background: #f8f9fa;
}

#videoInput {
    display: none;
}

.upload-btn {
    display: inline-block;
    padding: 15px 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 20px;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.drag-drop-zone {
    border: 3px dashed #667eea;
    border-radius: 12px;
    padding: 40px 20px;
    margin: 20px 0;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.drag-drop-zone:hover {
    border-color: #764ba2;
    background: #f8f9ff;
    transform: scale(1.02);
}

.drag-drop-zone.drag-over {
    border-color: #28a745;
    background: #f0fff4;
    transform: scale(1.05);
}

.drag-drop-zone p {
    margin: 10px 0;
    font-size: 1.1em;
    color: #667eea;
    font-weight: 500;
}

.drag-drop-hint {
    font-size: 0.9em !important;
    color: #999 !important;
    font-weight: normal !important;
}

.video-info {
    margin-top: 20px;
    color: #666;
    font-size: 0.9em;
}

.main-content {
    padding: 30px;
}

.video-section {
    margin-bottom: 30px;
}

#videoPlayer {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.frame-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.frame-controls button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    transition: background 0.2s;
}

.frame-controls button:hover {
    background: #5568d3;
}

#frameInfo {
    font-weight: 500;
    color: #333;
}

.editor-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-btn {
    padding: 10px 20px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.tool-btn:hover {
    border-color: #667eea;
    background: #f0f0ff;
}

.tool-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.tool-btn:disabled {
    background: #e0e0e0;
    color: #999;
    border-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.tool-group label {
    font-weight: 500;
    color: #333;
}

#brushSize {
    width: 100px;
}

#colorPicker {
    width: 50px;
    height: 40px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

#colorInput {
    width: 80px;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: monospace;
}

.canvas-container {
    display: flex;
    justify-content: center;
    background: #e0e0e0;
    padding: 20px;
    border-radius: 8px;
    overflow: auto;
    position: relative;
    max-height: 600px;
}

.canvas-wrapper {
    position: relative;
    display: inline-block;
    cursor: grab;
}

.canvas-wrapper.panning {
    cursor: grabbing;
}

#drawCanvas {
    background: white;
    border: 2px solid #ccc;
    border-radius: 4px;
    cursor: crosshair;
    display: block;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transform-origin: top left;
    transition: transform 0.2s ease;
}

.zoom-btn {
    padding: 5px 12px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    transition: all 0.2s;
    min-width: 35px;
}

.zoom-btn:hover {
    border-color: #667eea;
    background: #f0f0ff;
}

.zoom-btn:active {
    transform: scale(0.95);
}

#zoomValue {
    min-width: 50px;
    display: inline-block;
    text-align: center;
    font-weight: 500;
    color: #333;
}

.edited-frames-section {
    margin-top: 30px;
    padding: 20px;
    background: white;
    border-radius: 8px;
}

.edited-frames-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2em;
}

.edited-frames-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    min-height: 100px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.no-edits-message {
    color: #999;
    font-style: italic;
    width: 100%;
    text-align: center;
    padding: 20px;
}

.frame-thumbnail {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 10px;
    border: 3px solid transparent;
    border-radius: 8px;
    transition: all 0.2s;
    background: white;
}

.frame-thumbnail:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.frame-thumbnail.active {
    border-color: #28a745;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.frame-thumbnail canvas {
    width: 120px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.frame-thumbnail .frame-number {
    margin-top: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
}

.thumb-download-btn {
    margin-top: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    transition: opacity 0.2s, transform 0.2s;
    width: 100%;
}

.thumb-download-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

#downloadCurrentFrame {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-weight: 600;
}

.frame-range-section {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.frame-range-section h3 {
    margin-bottom: 15px;
    color: #856404;
}

.range-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.range-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.range-controls input[type="number"] {
    width: 100px;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
}

.range-controls button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    transition: background 0.2s;
}

#applyRange {
    background: #28a745;
    color: white;
}

#applyRange:hover {
    background: #218838;
}

#cancelRange {
    background: #dc3545;
    color: white;
}

#cancelRange:hover {
    background: #c82333;
}

.export-section {
    text-align: center;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 8px;
}

.export-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.download-all-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.export-btn {
    padding: 15px 40px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.export-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.progress-bar {
    width: 100%;
    max-width: 500px;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    margin: 20px auto;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    width: 0%;
    transition: width 0.3s;
    border-radius: 15px;
}

#exportStatus {
    margin-top: 15px;
    color: #666;
    font-size: 0.95em;
}

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .tool-group {
        width: 100%;
        justify-content: space-between;
    }

    .frame-controls {
        flex-direction: column;
    }
}
