body {
    font-family: 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background-color: #f5f5f7;
    color: #1d1d1f;
    margin: 0;
    padding: 20px;
    height: 100vh;
    box-sizing: border-box;
}

.container {
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 1400px;
    height: calc(100vh - 40px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

h1 {
    text-align: center;
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #1d1d1f;
}

.workspace {
    display: flex;
    gap: 20px;
    flex: 1;
    overflow: hidden;
}

/* Sidebar Styles */
.sidebar {
    width: 300px;
    background-color: #fbfbfd;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.panel-section {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.panel-section:last-child {
    border-bottom: none;
}

h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
}

select {
    width: 100%;
    padding: 8px;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    font-size: 14px;
}

.upload-btn-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.btn {
    border: 1px solid #0071e3;
    color: #0071e3;
    background-color: white;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}

.btn:hover {
    background-color: #f0f7ff;
}

.upload-btn-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.tool-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.text-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background-color: #f0f0f5;
    border-radius: 6px;
    margin-bottom: 5px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-row label {
    font-size: 13px;
    color: #555;
    min-width: 40px;
}

.control-row select, .control-row input[type="color"] {
    flex: 1;
    height: 30px;
    padding: 2px 5px;
}

button {
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.primary-btn {
    background-color: #0071e3;
    color: white;
    width: 100%;
}

.primary-btn:hover {
    background-color: #0077ed;
}

.secondary-btn {
    background-color: #e8e8ed;
    color: #1d1d1f;
}

.secondary-btn:hover {
    background-color: #d2d2d7;
}

.danger-btn {
    background-color: #fff1f0;
    color: #cf1322;
    border: 1px solid #ffa39e;
}

.danger-btn:hover {
    background-color: #ffccc7;
}

.danger-btn:disabled {
    background-color: #f5f5f5;
    color: #d9d9d9;
    border-color: #d9d9d9;
    cursor: not-allowed;
}

.hint {
    font-size: 12px;
    color: #86868b;
    margin: 5px 0 0 0;
    line-height: 1.4;
}

/* Reference Preview */
.ref-img-container {
    width: 100%;
    height: 150px;
    background-color: white;
    border: 1px solid #eee;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#vehicle-ref-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Usage Guide */
.usage-guide {
    margin-top: 10px;
    background-color: #f0f7ff;
    border-radius: 8px;
    padding: 15px !important;
    border: 1px solid #cce5ff;
}

.usage-guide h3 {
    color: #0052cc;
    margin-bottom: 10px;
    font-size: 15px;
}

.guide-content ol {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: #444;
}

.guide-content li {
    margin-bottom: 6px;
    line-height: 1.4;
}

.guide-content strong {
    color: #0071e3;
}

.guide-note {
    font-size: 12px;
    color: #666;
    margin: 8px 0 0 0;
    font-style: italic;
    border-top: 1px dashed #cce5ff;
    padding-top: 5px;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f5f5f5; /* Checkerboard pattern via JS or CSS */
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    padding: 15px;
    overflow: hidden;
}

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

.canvas-header h2 {
    margin: 0;
    font-size: 18px;
}

.canvas-controls {
    display: flex;
    gap: 15px;
    font-size: 14px;
}

.canvas-wrapper {
    flex: 1;
    background-color: #fff;
    background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee), 
                      linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    border: 1px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Handle large canvas */
    position: relative;
}

/* We will scale the canvas container to fit via JS if needed, 
   but for now let Fabric handle it inside wrapper */

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding: 0;
        height: auto;
        background-color: #fff;
    }

    .container {
        height: auto;
        min-height: 100vh;
        padding: 0;
        display: flex;
        flex-direction: column;
        box-shadow: none;
        border-radius: 0;
    }

    h1 {
        font-size: 18px;
        margin: 10px 0;
        padding: 0 15px;
    }

    .workspace {
        flex-direction: column; /* Canvas on top, Controls below */
        gap: 0;
        overflow: visible; /* Allow scrolling */
        flex: 1;
    }

    /* Canvas Area - Mobile Optimized */
    .canvas-area {
        order: -1; /* Put canvas on top */
        width: 100%;
        height: 50vh; /* Fixed height for canvas area */
        min-height: 350px;
        padding: 10px;
        box-sizing: border-box;
        border-radius: 0;
        border-left: none;
        border-right: none;
        background-color: #f0f0f0;
        z-index: 10;
        position: relative; /* For sticky */
    }

    .canvas-wrapper {
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }

    /* Sidebar - Mobile Optimized */
    .sidebar {
        width: 100%;
        box-sizing: border-box; /* Include padding in width */
        border: none;
        background-color: #fff;
        padding: 15px;
        padding-bottom: 80px; /* Space for bottom content */
    }

    .panel-section {
        padding: 15px 0;
    }

    .upload-btn-wrapper .btn, button {
        padding: 12px; /* Larger touch targets */
        font-size: 16px;
    }
}

/* Context Menu */
.context-menu {
    position: fixed;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    width: 200px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    overflow: hidden;
    animation: menuFadeIn 0.2s ease;
}

.menu-item {
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid #eee;
    font-size: 16px;
    color: #0071e3;
    font-weight: 500;
}

.menu-item:active {
    background-color: #f5f5f5;
}

.menu-item.delete {
    color: #ff3b30;
}

.menu-item.cancel {
    border-bottom: none;
    color: #666;
    font-weight: 400;
}

@keyframes menuFadeIn {
    from { opacity: 0; transform: translate(-50%, -40%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}
