* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e6e6e6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 加载屏幕样式 */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f1424 0%, #1a1a2e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    max-width: 600px;
    padding: 30px;
}

.loading-logo {
    margin-bottom: 40px;
}

.loading-logo i {
    font-size: 4rem;
    color: #4cc9f0;
    margin-bottom: 20px;
}

.loading-logo h1 {
    font-size: 2.5rem;
    background: linear-gradient(90deg, #4cc9f0, #4361ee);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.loading-progress {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4361ee, #4cc9f0);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: #a5b4cb;
}

.loading-log {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
}

.log-entry {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    color: #a5b4cb;
}

.log-entry:last-child {
    border-bottom: none;
}

/* 主应用样式 */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    opacity: 0;
    animation: fadeIn 0.5s ease 0.3s forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hidden {
    display: none !important;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #4cc9f0;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #4cc9f0, #4361ee);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    font-size: 1.1rem;
    color: #a5b4cb;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
}

.main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 40px;
}

.upload-section {
    flex: 1;
    min-width: 300px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.preview-section {
    flex: 2;
    min-width: 500px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.section-title {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #4cc9f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i {
    font-size: 1.6rem;
}

.upload-area {
    border: 3px dashed #4361ee;
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(67, 97, 238, 0.1);
    margin-bottom: 25px;
}

.upload-area:hover {
    background: rgba(67, 97, 238, 0.2);
    transform: translateY(-5px);
}

.upload-icon {
    font-size: 3rem;
    color: #4cc9f0;
    margin-bottom: 15px;
}

#file-input {
    display: none;
}

.canvas-container {
    width: 100%;
    height: 400px;
    background-color: #0f1424;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #2a3b5e;
    position: relative;
}

canvas {
    max-width: 100%;
    max-height: 100%;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.control-group {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #4361ee;
}

.control-title {
    font-size: 1.1rem;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.color-picker-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-preview {
    width: 30px;
    height: 30px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.color-input {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    cursor: pointer;
}

.color-hex-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    width: 100px;
    font-family: monospace;
}

.background-options {
    margin-top: 10px;
}

.option-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.option-btn {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #a5b4cb;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn.active {
    background: #4361ee;
    color: white;
    border-color: #4361ee;
}

.option-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.2);
}

.rgba-controls {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.rgba-slider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.rgba-slider:last-child {
    margin-bottom: 0;
}

.rgba-slider label {
    width: 20px;
    font-weight: bold;
}

.rgba-slider-input {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    background: linear-gradient(90deg, #4361ee, #4cc9f0);
    border-radius: 4px;
    outline: none;
}

.rgba-slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.rgba-value {
    min-width: 40px;
    text-align: right;
    font-family: monospace;
    font-size: 0.9rem;
}

.btn-text {
    background: none;
    border: none;
    color: #4cc9f0;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 0;
}

.btn-text:hover {
    color: #7bd3f0;
}

.hint-text {
    font-size: 0.85rem;
    color: #a5b4cb;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: #a5b4cb;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4361ee;
}

input:checked + .slider:before {
    transform: translateX(26px);
    background-color: white;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.slider-container label {
    min-width: 120px;
    font-size: 0.9rem;
}

input[type="range"] {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    background: linear-gradient(90deg, #4361ee, #4cc9f0);
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.value-display {
    min-width: 40px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
}

.layers-section {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

.layers-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.layer-card {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 20px;
    max-width: 500px;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.layer-card.active {
    border-color: #4cc9f0;
    box-shadow: 0 0 15px rgba(76, 201, 240, 0.3);
}

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

.layer-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.layer-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

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

.btn {
    background: linear-gradient(90deg, #4361ee, #4cc9f0);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    border: 2px solid #4361ee;
}

.btn-outline:hover {
    background: rgba(67, 97, 238, 0.1);
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.9rem;
}

.buttons-row {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

/* 添加预览容器样式 */
.preview-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.preview-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.preview-label {
    font-size: 0.9rem;
    color: #a5b4cb;
    margin-bottom: 10px;
    text-align: center;
}

.original-container, .dotmatrix-container {
    height: 300px;
    background-color: #0f1424;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #2a3b5e;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* 调整画布尺寸 */
.original-container canvas,
.dotmatrix-container canvas {
    max-width: 100%;
    max-height: 100%;
}

/* 画布控制样式 */
.canvas-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.canvas-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #a5b4cb;
}

/* 自动计算按钮样式 */
#auto-canvas-btn {
    margin-left: 10px;
    padding: 4px 8px;
    background: rgba(67, 97, 238, 0.2);
    border-radius: 4px;
    font-size: 0.85rem;
}

#auto-canvas-btn:hover {
    background: rgba(67, 97, 238, 0.3);
}

/* 渲染进度条样式 */
.render-progress-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    display: none;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.render-progress-bar {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.render-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4361ee, #4cc9f0);
    width: 0%;
    transition: width 0.3s ease;
}

/* 渲染日志样式 */
.render-log {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 15px;
    max-height: 560px; /* 固定容器高度 */
    overflow: hidden;  /* 禁止外部滚动 */
}

.log-header {
    flex-shrink: 0; /* 关键：防止头部被压缩或顶走 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.9rem;
}

.log-content {
    flex-grow: 1; /* 占据剩余高度 */
    overflow-y: auto; /* 内部独立滚动 */
    padding-right: 5px; /* 留出滚动条空间 */
    font-size: 0.85rem;
    color: #a5b4cb;
    scroll-behavior: smooth;
}

/* 优化滚动条样式 */
.log-content::-webkit-scrollbar { width: 5px; }
.log-content::-webkit-scrollbar-track { background: transparent; }
.log-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.log-content::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }

.log-entry {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.info {
    color: #4cc9f0;
}

.log-entry.warning {
    color: #ff9e00;
}

.log-entry.error {
    color: #f72585;
}

.log-entry.success {
    color: #06d6a0;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    color: #4cc9f0;
    z-index: 10;
}

.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #4cc9f0;
    color: #0f1424;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.5s;
    z-index: 100;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification.error {
    background: #f72585;
    color: white;
}

.notification.success {
    background: #06d6a0;
    color: #0f1424;
}

@media (max-width: 1100px) {
    .main-content {
        flex-direction: column;
    }
    
    .preview-section, .upload-section {
        min-width: 100%;
    }
}

@media (max-width: 768px) {
    .layers-container {
        flex-direction: column;
    }
    
    .layer-card {
        width: 100%;
    }
    
    .buttons-row {
        flex-wrap: wrap;
    }
    
    .slider-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .slider-container label {
        min-width: auto;
    }
}
