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

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
    font-weight: 600;
}

h2 {
    color: #2c3e50;
    margin: 20px 0 15px;
    font-size: 20px;
}

.container p,
.container li,
.tool-info p,
.tool-info li {
    color: #555;
    line-height: 1.6;
    margin-bottom: 10px;
}

.container ul,
.container ol,
.tool-info ul,
.tool-info ol {
    padding-left: 20px;
    margin-bottom: 15px;
}

body {
    background-color: #f5f7fa;
    padding: 0;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

nav {
    background-color: #2c3e50;
    color: white;
    padding: 0 20px;
    position: relative;
    height: 60px;
    display: flex;
    align-items: center;
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 10px 0;
    margin: 0;
    line-height: 1;
}

.nav-links {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-links li {
    position: relative;
    margin-bottom: 0;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 15px 20px;
    display: block;
    transition: background-color 0.3s;
}

.has-dropdown > a::after {
    content: "▼";
    font-size: 6px;
    margin-left: 4px;
    line-height: 1;
    transition: transform 0.2s ease;
}
.has-dropdown.active > a::after {
    transform: rotate(180deg);
}

.nav-links a:hover {
    background-color: #34495e;
}

/* Dropdown Menu */
.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-width: 200px;
    display: none;
    z-index: 100;
    padding-left: 0;
    margin-bottom: 0;
}

.dropdown a {
    color: #333;
    padding: 12px 20px;
}

.dropdown a:hover {
    background-color: #f1f1f1;
}

.dropdown li {
    margin-bottom: 0; /* 重置下拉菜单项margin */
}

.has-dropdown:hover .dropdown {
    display: block;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
        margin-left: 0;
    }

    .nav-container {
        justify-content: flex-start;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 60px;
        left: 0;
        background-color: #2c3e50;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        padding: 10px 0;
        z-index: 99;
    }

    .nav-links.active {
        display: flex;
    }

    .dropdown {
        position: static;
        box-shadow: none;
        background-color: #34495e;
        display: none;
        padding-left: 10px;
    }

    .has-dropdown.active .dropdown {
        display: block;
    }

    .dropdown a {
        color: white;
        padding-left: 40px;
    }
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.08);
    padding: 30px;
    margin-top: 20px;
    flex: 1;
}

.upload-area {
    border: 2px dashed #4a90e2;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 30px;
}

.upload-area:hover {
    background-color: #f8fbff;
    border-color: #357abd;
}

.upload-area input {
    display: none;
}

.upload-text {
    color: #666;
    margin-top: 10px;
}

.upload-icon {
    font-size: 40px;
    color: #4a90e2;
    margin-bottom: 15px;
}

.options-section {
    margin-bottom: 30px;
}

.mode-selector {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 15px;
    border-radius: 6px;
    transition: background 0.2s;
}

.mode-option:hover {
    background-color: #f0f7ff;
}

.mode-option input {
    accent-color: #4a90e2;
    width: 18px;
    height: 18px;
}

.grid-settings, .style-settings {
    display: none;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    margin-top: 10px;
}

.grid-settings.active, .style-settings.active {
    display: flex;
}

.grid-input, .style-input {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.grid-input label, .style-input label {
    font-size: 14px;
    color: #555;
}

.grid-input input, .style-input input, .style-input select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
}

.grid-input input {
    width: 80px;
}

.style-input input, .style-input select {
    width: 120px;
}

.style-input input[type="color"] {
    padding: 2px;
    height: 40px;
}

.grid-input input:focus, .style-input input:focus, .style-input select:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.25);
}

.preview-section {
    margin-bottom: 30px;
}

.preview-title {
    font-size: 18px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 8px;
    min-height: 120px;
}

.preview-item {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    aspect-ratio: 1/1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #e74c3c;
    opacity: 0;
    transition: opacity 0.2s;
}

.preview-item:hover .preview-remove {
    opacity: 1;
}

.button-section {
    margin-bottom: 30px;
}

.download-format {
    text-align: center;
    margin-bottom: 15px;
}

.download-format label {
    font-size: 14px;
    color: #555;
    margin-right: 8px;
}

.download-format select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
    background-color: white;
    width: 120px;
}

.download-format select:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.25);
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.merge-btn {
    background-color: #4a90e2;
    color: white;
}

.merge-btn:hover {
    background-color: #357abd;
}

.merge-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.download-btn {
    background-color: #28a745;
    color: white;
    display: none;
}

.download-btn.show {
    display: inline-block;
}

.download-btn:hover {
    background-color: #218838;
}

.merged-preview {
    margin-top: 20px;
    text-align: center;
    display: none;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    background-color: #f9f9f9;
}

.merged-preview.show {
    display: block;
}

.merged-preview h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 18px;
}

.merged-preview img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

#mergeCanvas {
    display: none;
}

.tool-info {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid #eee;
}

.info-section {
    margin-bottom: 30px;
}

.info-section h2 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 20px;
}

footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 20px;
    margin-top: 30px;
}

.footer-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.copyright {
    font-size: 14px;
    opacity: 0.8;
}

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: white;
    text-decoration: underline;
}

/* mobile */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        margin: 10px;
    }

    .upload-area {
        padding: 30px 15px;
    }

    .mode-selector {
        flex-direction: column;
        gap: 10px;
    }

    .button-group {
        flex-direction: column;
    }

    button, .download-format select {
        width: 100%;
    }

    .style-settings {
        flex-direction: column;
    }

    .style-input input, .style-input select {
        width: 100%;
    }

    .footer-links {
        gap: 15px;
    }

    .footer-links a {
        font-size: 13px;
    }
}