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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
    color: #333;
}

/* 导航栏样式 */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.nav-brand {
    font-size: 1.3em;
    font-weight: 700;
    color: #667eea;
    cursor: pointer;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 30px;
    margin: 0;
    padding: 0;
}

.nav-item {
    margin: 0;
}

.nav-link {
    text-decoration: none;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 0;
    transition: color 0.3s;
    position: relative;
}

.nav-link:hover {
    color: #667eea;
}

.nav-link.active {
    color: #667eea;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #667eea;
    border-radius: 2px;
}

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

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    min-height: calc(100vh - 200px); /* 接近全屏高度，减去导航栏和padding */
}

.input-panel h2,
.preview-panel h2 {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: #667eea;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

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

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
}

.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 6px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    background: white;
    cursor: pointer;
}

.form-group input[type="number"]:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* 文件上传按钮美化 */
.file-upload-wrapper {
    position: relative;
    overflow: hidden;
}

.file-upload-wrapper input[type="file"] {
    position: absolute;
    left: -9999px;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: #dfe3f5;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s;
    border: 2px solid #8094eb;
}

.file-upload-label:hover {
    background: #939edb;
    border-color: #5568d3;
}

.file-upload-label:active {
    background: #4a5bc0;
}

.file-upload-icon {
    font-size: 16px;
}

.file-upload-text {
    user-select: none;
}

/* 标注显示控制下拉菜单 */
.dimension-controls-wrapper {
    flex-shrink: 0;
}

.dimension-dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
}

.dimension-dropdown-toggle {
    width: 100%;
    padding: 10px 16px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.dimension-dropdown-toggle:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.dimension-dropdown-toggle.active {
    border-color: #667eea;
    background: #f8f9ff;
}

.dropdown-arrow {
    font-size: 12px;
    transition: transform 0.3s;
    color: #667eea;
}

.dimension-dropdown-toggle.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dimension-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
}

.dimension-dropdown-menu.show {
    display: block;
}

.dimension-option {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.dimension-option:hover {
    background: #f8f9ff;
}

.dimension-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    cursor: pointer;
    accent-color: #667eea;
}

.dimension-option span {
    font-size: 14px;
    color: #555;
    flex: 1;
}

.btn-secondary {
    margin-top: 6px;
    padding: 6px 12px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: #d32f2f;
}

.btn-reset {
    padding: 8px 16px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
    margin-left: 15px;
}

.btn-reset:hover {
    background: #1976D2;
}

.image-controls {
    margin-top: 6px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.image-alpha-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.image-alpha-control label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin: 0;
}

.image-alpha-control input[type="range"] {
    width: 100px;
    height: 4px;
    border-radius: 2px;
    background: #ddd;
    outline: none;
}

.image-alpha-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.image-alpha-control input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.image-alpha-control span {
    font-size: 13px;
    font-weight: 600;
    color: #667eea;
    min-width: 40px;
}

.btn-image {
    margin-top: 6px;
    padding: 6px 12px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.3s;
}

.btn-image:hover {
    background: #45a049;
}


.result-box {
    margin-top: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
}

.result-box h3 {
    margin-bottom: 15px;
    font-size: 1.2em;
}

.result-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.result-label {
    font-weight: 600;
}

.result-value {
    font-size: 1.5em;
    font-weight: bold;
}

.result-unit {
    font-size: 0.9em;
    opacity: 0.9;
}

.preview-panel {
    display: flex;
    flex-direction: column;
    min-height: 0; /* 允许flex子元素缩小 */
    overflow: hidden; /* 防止内容溢出 */
    height: 100%; /* 充分利用父容器高度 */
}

.canvas-container {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    background: #f5f5f5;
    border-radius: 10px;
    padding: 0;
    min-height: 600px; /* 增加最小高度 */
    max-height: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
    cursor: grab;
    width: 100%;
    height: 100%;
}

.canvas-container:active {
    cursor: grabbing;
}

.ruler-horizontal {
    position: absolute;
    top: 0;
    left: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid #999;
    z-index: 5;
    pointer-events: none;
}

.ruler-vertical {
    position: absolute;
    left: 0;
    top: 20px;
    width: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-right: 1px solid #999;
    z-index: 5;
    pointer-events: none;
}

#previewCanvas {
    background: transparent;
    border: 1px solid #ddd;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: block;
    position: absolute;
    top: 20px;
    left: 20px;
}

.coordinate-display {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    pointer-events: none;
    z-index: 10;
    display: none;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    /* background: #f9f9f9; */
    border-radius: 8px;
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.preview-controls label {
    font-weight: 600;
    color: #555;
}

.preview-controls input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
}

.preview-controls input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.preview-controls input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

#zoomValue {
    font-weight: 600;
    color: #667eea;
    min-width: 50px;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .nav-menu {
        gap: 20px;
    }
    
    .nav-link {
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-menu {
        gap: 15px;
    }
}

/* 页脚样式 */
.footer {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 40px;
    padding: 30px 20px;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 20px;
    color: rgba(255, 255, 255, 0.95);
    font-size: 14px;
    line-height: 1.6;
}

.footer-copyright {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.copyright-symbol {
    font-size: 16px;
    opacity: 0.9;
}

.copyright-years {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.footer-link {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
}

.footer-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.company-name {
    font-weight: 600;
    font-size: 15px;
}

.footer-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.3);
    margin: 0 5px;
}

.footer-rights {
    font-size: 13px;
    opacity: 0.85;
}

.footer-icp {
    display: flex;
    align-items: center;
}

.icp-link {
    font-size: 13px;
    opacity: 0.9;
}

.icp-icon {
    font-size: 12px;
    opacity: 0.8;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .footer {
        padding: 25px 15px;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .footer-divider {
        width: 60px;
        height: 1px;
        margin: 5px 0;
    }
    
    .footer-copyright {
        justify-content: center;
    }
    
    .copyright-years {
        display: block;
        width: 100%;
    }
}

