:root {
    --primary-color: #4a6fa5;
    --secondary-color: #6b93d6;
    --accent-color: #ff6b6b;
    --background-color: #f5f7fa;
    --panel-color: #ffffff;
    --text-color: #333333;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --text-light: #666666;
    --border-color: #e1e5eb;
    --border-radius-lg: 16px;
    --border-radius-sm: 8px;
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --canvas-border-color: #4a6fa5;
    --canvas-border-width: 3px;
    --canvas-bg-color: #ffffff;
    --safe-area-padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --header-height: 120px;
    --control-panel-height: auto;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    height: 100%;
    margin: 10px auto;
    display: grid;
    grid-template-columns: 2fr 350px;
    gap: 20px;
}

header {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 10px;
    margin-bottom: 10px;
}

h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.description {
    color: #666;
    max-width: 800px;
    margin: 0 auto;
}

/* 画布样式 */
.canvas-container {
    background-color: var(--canvas-bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 600px;
    border: var(--canvas-border-width) solid var(--canvas-border-color);
    transition: var(--transition);
    touch-action: manipulation;
}

.canvas-container:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--secondary-color);
    transform: translateY(-1px);
}

#drawing-canvas {
    background-color: white;
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

/* 控制面板样式 */
.control-panel {
    background-color: var(--panel-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.custom-color-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.custom-color-container label {
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
}

.panel-section {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.panel-section:last-child {
    border-bottom: none;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

/* 摄像头区域 */
.camera-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background-color: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#hand-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.camera-buttons {
    display: flex;
    gap: 10px;
}

button {
    padding: 10px 15px;
    border: none;
    border-radius: var(--border-radius);
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
    flex: 1;
}

button:hover {
    background-color: var(--secondary-color);
}

button#stop-camera {
    background-color: var(--accent-color);
}

button#stop-camera:hover {
    background-color: #ff4f4f;
}

/* 画布覆盖层 - 显示信息 */
.canvas-overlay {
    position: absolute;
    bottom: 15px;
    left: 0;
    right: 0;
    /* display: flex; */
    display: none;
    justify-content: center;
    pointer-events: none;
}

.canvas-info {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-sm);
    padding: 10px 20px;
    /* display: flex; */
    display: none;
    gap: 20px;
    font-size: 0.9rem;
    color: var(--text-color);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(74, 111, 165, 0.1);
}

.canvas-info span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

/* 颜色选择器 */
.color-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.color-option {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid #eee;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

input[type="color"] {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
}

/* 画笔控制 */
.brush-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="range"] {
    flex: 1;
}

.value-display {
    min-width: 30px;
    text-align: center;
}

/* 工具按钮 */
.tool-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* 保存选项 */
.save-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

select {
    padding: 10px;
    border-radius: var(--border-radius);
    border: 1px solid #ddd;
}

/* 引导信息 */
.guide {
    background-color: #e7f3ff;
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.guide h3 {
    margin-bottom: 8px;
    color: var(--primary-color);
}

.guide ul {
    padding-left: 20px;
}

.guide li {
    margin-bottom: 5px;
}

/* 加载指示器 */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 警告框 */
.alert {
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    text-align: center;
}

.alert.warning {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.alert.info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.alert.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

/* 光标画布样式 */
#cursor-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10;
}

/* 确保canvas容器有相对定位 */
.canvas-container {
    position: relative;
}

/* 模式切换 */
.mode-toggle {
    display: flex;
    background-color: #eee;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 15px;
}

.mode-btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: none;
    color: #666;
}

.mode-btn.active {
    background-color: var(--primary-color);
    color: white;
}





    /* 摄像头区域特殊样式 */
    #video-container {
        position: relative;
        width: 100%;
        aspect-ratio: 4/3;
        background-color: #1a1a1a;
        border-radius: var(--border-radius-sm);
        overflow: hidden;
        box-shadow: var(--shadow);
    }

    #video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        transform: scaleX(-1); /* 镜像翻转，使动作更自然 */
    }

    #hand-skeleton {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        z-index: 2;
    }

    /* 新增：手部遮罩画布 */
    #hand-mask {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        z-index: 3;
    }

    /* 摄像头控制区域 */
    .camera-controls {
        display: flex;
        flex-direction: column;
        gap: 15px;
        margin-top: 15px;
    }

    .camera-buttons {
        display: flex;
        gap: 12px;
    }

    .camera-mode-toggle {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: var(--border-radius-sm);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    .camera-mode-toggle label {
        font-weight: 500;
        color: var(--text-color);
        font-size: 2.3rem;
        margin-bottom: 15px;
    }

    .camera-mode-toggle select {
        flex: 1;
        padding: 8px 12px;
        border-radius: var(--border-radius-sm);
        border: 1px solid var(--border-color);
        background-color: rgba(255, 255, 255, 0.9);
        font-size: 0.9rem;
        color: var(--text-color);
    }

    /* 不同显示模式的视觉指示 */
    .display-mode-indicator {
        position: absolute;
        top: 10px;
        right: 10px;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 4px 8px;
        border-radius: 4px;
        font-size: 0.8rem;
        z-index: 10;
    }




/* 响应式设计 */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }

    .canvas-container {
        aspect-ratio: 16/9;
    }
}

/* 响应式设计 */
@media (max-width: 767px) {
    .container {
        grid-template-columns: 1fr;
    }

    .canvas-container {
        aspect-ratio: 16/9;
    }

}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .color-palette {
        grid-template-columns: repeat(8, 1fr);
    }

    .tool-buttons {
        grid-template-columns: 1fr;
    }
}
/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #1a1d23;
        --panel-color: #2a2d35;
        --text-color: #f0f0f0;
        --text-light: #b0b0b0;
        --border-color: #3a3d45;
        --canvas-bg-color: #2a2d35;
        --canvas-border-color: #5a8de0;
    }

    body {
        background: linear-gradient(135deg, #1a1d23 0%, #252830 100%);
    }

    .canvas-info {
        background: rgba(42, 45, 53, 0.9);
        color: #f0f0f0;
    }

    .mode-toggle {
        background: linear-gradient(135deg, #252830, #2a2d35);
    }

    .guide {
        background: linear-gradient(135deg, rgba(42, 52, 65, 0.8), rgba(35, 45, 58, 0.8));
    }

    select {
        background-color: #2a2d35;
        color: #f0f0f0;
    }

    input[type="range"] {
        background: linear-gradient(to right, #3a3d45, var(--primary-color));
    }

    #loading {
        background: rgba(26, 29, 35, 0.95);
    }
}

/* 打印样式 */
@media print {
    .control-section,
    .mode-toggle,
    .alert,
    .canvas-overlay,
    footer {
        display: none !important;
    }

    .canvas-container {
        box-shadow: none;
        border: 2px solid #000;
        page-break-inside: avoid;
    }

    body {
        background: white;
        padding: 0;
    }
}