* {
    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;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

header h1 {
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
}

header h1 a {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

header h1 a:hover {
    text-decoration: underline;
}

.section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: none;
}

.section.active {
    display: block;
}

.section h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.8rem;
}

/* Login Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-form {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    min-width: 350px;
}

.login-form h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

/* Upload Area */
.upload-area {
    border: 3px dashed #ccc;
    border-radius: 10px;
    padding: 50px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9f9f9;
}

.upload-area:hover, .upload-area.dragover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-area i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 15px;
}

.upload-area p {
    font-size: 1.2rem;
    color: #666;
}

/* Video List */
.video-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.video-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: move;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.video-item:hover {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    border-color: #667eea;
}

.video-item.dragging {
    opacity: 0.6;
    transform: rotate(2deg);
}

/* New Main Layout - Horizontal with clear sections */
.video-main-layout {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
}

/* Left Section: Position & Reorder Controls */
.reorder-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.video-position-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.reorder-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 8px;
    border: 1px solid #e9ecef;
}

.reorder-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.reorder-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

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

.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 24px;
    color: #999;
    cursor: grab;
    border-radius: 4px;
    transition: all 0.2s ease;
    background: transparent;
}

.drag-handle:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.drag-handle:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.drag-handle i {
    font-size: 1rem;
}

/* Center-Left: Large Video Preview */
.video-preview-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.video-thumb-large {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-thumb-large video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #000;
}
.video-thumb-large img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #000;
}

.preview-play-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.6);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.preview-play-btn:hover { background: rgba(0,0,0,0.8); }

.video-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 10px;
    border-radius: 0 0 12px 12px;
    pointer-events: none;
}

.video-duration {
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
    text-align: center;
}

.video-info {
    max-width: 280px;
}

.video-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

.video-size {
    color: #666;
    font-size: 0.9rem;
}

/* Center-Right: Controls Section */
.video-controls-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.timing-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.timing-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.timing-control label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
}

.timing-control input {
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
    width: 120px;
}

.timing-control input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.split-input-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.split-input-group input {
    flex: 1;
    max-width: 100px;
}

.btn-split {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.btn-split:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

/* Transform controls (compact, mobile-friendly) */
.transform-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.transform-controls .transform-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.btn-compact {
    padding: 6px 8px;
    min-width: 44px;
    min-height: 36px;
    font-size: 0.85rem;
    background: #f0f2f5;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 6px;
}
.btn-compact:hover {
    background: #e6e9ef;
}

.frame-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.frame-extract-buttons {
    display: flex;
    gap: 6px;
}

.btn-frame {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #666;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-frame:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-frame i {
    font-size: 0.85rem;
}

/* Right Section: Delete Button */
.delete-section {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.btn-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.2);
}

.btn-delete:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(220, 53, 69, 0.3);
}

.btn-delete:active {
    transform: translateY(0) scale(0.98);
}

/* Improve visual hierarchy and interactions */
.video-item:hover .video-position-indicator {
    background: #5a6fd8;
    transform: scale(1.05);
}

.video-item:hover .reorder-controls {
    background: #f0f4ff;
    border-color: #667eea;
}

.video-item:hover .video-thumb-large {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.video-item:hover .btn-delete {
    background: #c82333;
    box-shadow: 0 4px 16px rgba(220, 53, 69, 0.4);
}

/* Video Settings */
.video-settings {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group label {
    font-weight: 600;
    color: #333;
}

.setting-group select,
.setting-group input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.wm-fields {
    display: grid !important;
    grid-template-columns: auto 1fr;
    align-items: center;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* Progress Bar */
.progress-container {
    margin: 20px 0;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: #667eea;
    transition: width 0.3s ease;
    width: 0%;
}

/* Video Result */
.video-result {
    text-align: center;
    margin-bottom: 20px;
}

.video-result video {
    width: 100%;
    max-width: 800px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
    margin: 0 auto;
}

.generation-progress-wrapper {
    max-width: 800px;
    margin: 20px auto 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.generation-progress-wrapper .progress-container {
    flex: 1;
}

.generation-progress-wrapper #cancelGenerateBtn {
    flex: 0 0 auto;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Frame Settings */
.frame-settings {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.frame-settings .setting-group {
    margin-bottom: 15px;
}

.frame-context {
    margin-bottom: 10px;
    color: #6c757d;
    font-size: 0.95rem;
}

/* Frames Grid */
.frames-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.frame-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    border: 1px solid #e9ecef;
}

.frame-item img {
    max-width: 100%;
    border-radius: 4px;
    margin-bottom: 10px;
}

.frame-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.frame-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #000;
}

.settings-content h3 {
    margin-bottom: 20px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.settings-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.settings-actions.spaced {
    justify-content: flex-end;
}

.settings-hint {
    font-size: 0.9rem;
    color: #666;
    margin-top: -10px;
    margin-bottom: 15px;
}

.input-with-button {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-with-button input {
    flex: 1;
}

.input-with-button .btn-secondary {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* Error Messages */
.error-message {
    color: #dc3545;
    margin-top: 10px;
    padding: 10px;
    background: #f8d7da;
    border-radius: 4px;
    display: none;
}

.error-message:not(:empty) {
    display: block;
}

/* Touch optimization for all interactive elements */
@media (hover: none) and (pointer: coarse) {
    /* Touch device optimizations */
    .btn-primary, .btn-secondary {
        min-height: 48px;
        min-width: 48px;
        padding: 14px 20px;
        font-size: 1rem;
    }

    .btn-frame {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
    }

    .reorder-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .drag-handle {
        width: 44px;
        height: 32px;
        min-width: 44px;
        min-height: 32px;
    }

    .btn-split {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .btn-delete {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }

    .timing-control input {
        min-height: 48px;
        padding: 14px;
        font-size: 1.1rem;
    }

    .video-thumb-large {
        width: 220px;
        height: 220px;
    }

    .video-position-indicator {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* Responsive breakpoints */

/* Large tablets and small desktops (1024px and up) */
@media (min-width: 1024px) {
    .video-header {
        flex-wrap: nowrap;
    }

    .timing-section {
        grid-template-columns: 1fr 1.2fr;
    }

    .action-section {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }

    .frame-extract-group {
        flex: 1;
    }

    .delete-btn {
        width: auto;
        max-width: 200px;
    }
}

/* Tablets (768px to 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        padding: 16px;
    }

    .video-item {
        padding: 16px;
    }

    .video-main-layout {
        gap: 16px;
    }

    .video-thumb-large {
        width: 180px;
        height: 180px;
    }

    .video-info {
        max-width: 240px;
    }

    .video-position-indicator {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .reorder-controls {
        padding: 6px;
        gap: 3px;
    }

    .reorder-btn {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }

    .drag-handle {
        width: 30px;
        height: 20px;
    }

    .timing-control input {
        width: 100px;
        font-size: 0.9rem;
    }

    .btn-frame {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }

    .btn-delete {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* Mobile phones and small tablets (up to 767px) */
@media (max-width: 767px) {
    .container {
        padding: 12px;
    }

    header {
        flex-direction: column;
        gap: 15px;
        padding: 16px;
    }

    header h1 {
        font-size: 2rem;
    }

    .video-item {
        padding: 16px;
        gap: 12px;
    }

    .video-main-layout {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }

    .reorder-section {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 16px;
        order: 1;
    }

    .video-position-indicator {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .reorder-controls {
        flex-direction: row;
        gap: 8px;
        padding: 8px 16px;
    }

    .reorder-btn {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .drag-handle {
        width: 44px;
        height: 32px;
        background: rgba(102, 126, 234, 0.1);
        color: #667eea;
        border: 2px dashed #667eea;
        border-radius: 8px;
    }

    .video-preview-section {
        order: 2;
        align-items: center;
    }

    .video-thumb-large {
        width: 250px;
        height: 250px;
        max-width: 90vw;
        align-self: center;
    }

    .video-info {
        text-align: center;
        max-width: 100%;
    }

    .video-name {
        font-size: 1rem;
        white-space: normal;
        line-height: 1.3;
    }

    .video-controls-section {
        order: 3;
    }

    .delete-section {
        order: 4;
        justify-content: center;
    }

    .btn-delete {
        width: 56px;
        height: 56px;
        font-size: 1.3rem;
    }

    .timing-controls {
        gap: 16px;
    }

    .timing-control input {
        min-height: 48px;
        padding: 14px;
        font-size: 1.1rem;
        width: 100%;
        max-width: 150px;
    }

    .split-input-group {
        gap: 12px;
    }

    .btn-split {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .frame-extract-buttons {
        gap: 12px;
        justify-content: center;
    }

    .btn-frame {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .video-settings {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
    }

    .result-actions {
        flex-direction: column;
        gap: 12px;
    }

    .result-actions .btn-primary,
    .result-actions .btn-secondary {
        min-height: 50px;
        padding: 14px 20px;
        font-size: 1rem;
    }

    .frames-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
}

/* Very small phones (up to 480px) */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    .section {
        padding: 20px 16px;
        border-radius: 10px;
    }

    .video-item {
        padding: 12px;
        border-radius: 10px;
    }

    .video-thumb {
        height: 160px;
    }

    .video-name {
        font-size: 0.95rem;
    }

    .timing-control input {
        min-height: 48px;
        padding: 12px;
        font-size: 1rem;
    }

    .btn-frame {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .delete-btn {
        min-height: 52px;
        padding: 14px 20px;
        font-size: 1rem;
    }

    .frames-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
}

/* Improve touch interaction feedback */
.btn-primary:active, .btn-secondary:active, .btn-frame:active, .delete-btn:active, .reorder-btn:active {
    transform: translateY(1px) scale(0.98);
    transition: transform 0.1s ease;
}

.drag-handle:active {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Ensure proper focus states for accessibility */
.timing-control input:focus,
.btn-primary:focus,
.btn-secondary:focus,
.btn-frame:focus,
.delete-btn:focus,
.reorder-btn:focus {
    outline: 3px solid rgba(102, 126, 234, 0.3);
    outline-offset: 2px;
}

/* Add focus state for drag handle accessibility */
.drag-handle:focus {
    outline: 3px solid rgba(102, 126, 234, 0.3);
    outline-offset: 2px;
    background: rgba(102, 126, 234, 0.1);
}

/* Improve hover states on devices that support it */
@media (hover: hover) and (pointer: fine) {
    .reorder-btn:hover:not(:disabled) {
        background: #667eea;
        color: white;
        border-color: #667eea;
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }

    .btn-frame:hover {
        background: #667eea;
        color: white;
        border-color: #667eea;
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }
}

/* System Information */
.system-info-display {
    padding: 10px;
    background: #f5f5f5;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    border: 1px solid #ddd;
}

/* API Documentation */
.api-docs {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    max-height: 400px;
    overflow-y: auto;
}

.api-section {
    margin-bottom: 20px;
}

.api-section h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 1rem;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 5px;
}

.api-endpoint {
    background: white;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
    font-size: 0.85rem;
}

.api-endpoint strong {
    color: var(--primary-color);
    font-weight: bold;
}

  .api-description {
      margin-top: 5px;
      color: #6c757d;
      line-height: 1.4;
  }

  /* Gallery Modal */
  .gallery-modal {
      max-width: 900px;
      max-height: 85vh;
      overflow-y: auto;
  }

  .gallery-toolbar {
      display: flex;
      gap: 10px;
      margin-bottom: 15px;
      flex-wrap: wrap;
  }

  .gallery-container {
      display: flex;
      flex-direction: column;
      gap: 20px;
  }

  .gallery-section {
      border: 1px solid #e9ecef;
      border-radius: 8px;
      padding: 15px;
      background: #ffffff;
  }

  .gallery-section-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 12px;
      gap: 10px;
  }

  .gallery-list {
      display: flex;
      flex-direction: column;
      gap: 10px;
      max-height: 220px;
      overflow-y: auto;
      background: #f8f9fa;
      padding: 10px;
      border-radius: 6px;
  }

  .gallery-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 15px;
      padding: 8px 12px;
      background: #ffffff;
      border: 1px solid #e0e0e0;
      border-radius: 6px;
  }

  .gallery-item-info {
      display: flex;
      flex-direction: column;
      gap: 2px;
      font-size: 0.9rem;
      color: #333;
  }

  .gallery-item-meta {
      font-size: 0.78rem;
      color: #6c757d;
  }

  .gallery-item-actions {
      display: flex;
      gap: 12px;
      align-items: center;
      flex-shrink: 0;
  }

  .gallery-item-actions a {
      color: #667eea;
      font-weight: 600;
      font-size: 0.85rem;
      text-decoration: none;
  }

  .gallery-item-actions a:hover {
      text-decoration: underline;
  }

  .gallery-empty {
      text-align: center;
      color: #6c757d;
      font-size: 0.9rem;
      padding: 12px;
      background: #f8f9fa;
      border-radius: 6px;
      border: 1px dashed #dee2e6;
  }

/* Mode Selection */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.mode-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px;
    border-radius: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    border: 3px solid transparent;
}

.mode-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.4);
    border-color: rgba(255, 255, 255, 0.3);
}

.mode-card i {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
    opacity: 0.9;
}

.mode-card h3 {
    font-size: 1.8rem;
    margin-bottom: 12px;
    font-weight: 700;
}

.mode-card p {
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.5;
}

/* Audio Visualizer Specific Styles */
.background-options {
    margin-top: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.background-options .upload-area {
    padding: 30px;
    margin-top: 10px;
}

#visualizerSection h3 {
    color: #667eea;
    font-size: 1.4rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

#visualizerSection .setting-group {
    margin-bottom: 15px;
}

#visualizerSection .setting-group input[type="color"] {
    width: 100px;
    height: 45px;
    border-radius: 6px;
    border: 2px solid #ddd;
    cursor: pointer;
    padding: 5px;
}

#visualizerSection .setting-group input[type="color"]:hover {
    border-color: #667eea;
}

/* Visualizer Progress Styling */
#visualizerProgress {
    margin-top: 20px;
}

#visualizerResultVideo {
    max-width: 100%;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Image Preview */
#imagePreview img {
    border: 2px solid #ddd;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Responsive Mode Cards */
@media (max-width: 767px) {
    .mode-selector {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .mode-card {
        padding: 35px 25px;
    }

    .mode-card i {
        font-size: 3.5rem;
    }

    .mode-card h3 {
        font-size: 1.5rem;
    }
}
