:root {
    --primary-gradient: linear-gradient(135deg, #1f2937 0%, #4b5563 100%);
    --primary-color: #111827;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #111827;
    --text-muted: #6b7280;
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --card-border: rgba(229, 231, 235, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-image:
        radial-gradient(at 0% 0%, rgba(255, 255, 255, 0.8) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(255, 255, 255, 0.8) 0px, transparent 50%);
}

/* Animated Background Orbs */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: float 25s infinite ease-in-out;
}

.bg-orb-1 {
    top: -10%;
    left: 20%;
    width: 40vw;
    height: 40vw;
    background: rgba(229, 231, 235, 0.8);
    animation-delay: 0s;
}

.bg-orb-2 {
    bottom: -5%;
    right: 10%;
    width: 50vw;
    height: 50vw;
    background: rgba(209, 213, 219, 0.6);
    animation-delay: -5s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, -20px);
    }
}

.container {
    width: 90%;
    max-width: 1000px;
    height: 92vh;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

header {
    text-align: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-color);
    letter-spacing: -1px;
    margin-bottom: 0.2rem;
    background: none;
    -webkit-text-fill-color: initial;
}

header p {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Mode Switcher */
.mode-switcher {
    display: flex;
    background: rgba(255, 255, 255, 0.5);
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.mode-btn {
    padding: 8px 24px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.mode-btn.active {
    background: #ffffff;
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Main Workspace Grid */
.workspace {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2rem;
    flex-grow: 1;
    min-height: 0;
    transition: all 0.3s ease;
}

/* Card Common Styles */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    box-shadow: var(--card-shadow);
}

/* Left: Upload & Preview */
.preview-card {
    position: relative;
    align-items: center;
    justify-content: center;
    border: 2px dashed #e5e7eb;
    cursor: pointer;
    overflow: hidden;
    background: #f9fafb;
    transition: all 0.3s ease;
}

.preview-card:hover {
    border-color: #9ca3af;
    background: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.preview-card.dragover {
    border-color: var(--primary-color);
    background: #eff6ff;
    transform: scale(0.99);
}

.upload-hint {
    text-align: center;
    z-index: 2;
    transition: all 0.3s ease;
}

.preview-card.has-image .upload-hint {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

/* Upload Icon Animation */
.icon-placeholder {
    color: #9ca3af;
    margin-bottom: 1rem;
}

.icon-placeholder svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
    transition: transform 0.3s ease;
}

.preview-card:hover .icon-placeholder svg {
    transform: translateY(-5px);
    color: var(--primary-color);
}

.upload-hint h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem;
    color: #374151;
}

.upload-hint p {
    color: #6b7280;
}

/* Canvas Wrapper with Checkerboard */
.preview-canvas-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
    border-radius: 20px;
    padding: 20px;

    /* Checkerboard pattern for transparency - Adjusted for light theme */
    background-color: #e5e7eb;
    background-image:
        linear-gradient(45deg, #f3f4f6 25%, transparent 25%),
        linear-gradient(-45deg, #f3f4f6 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f3f4f6 75%),
        linear-gradient(-45deg, transparent 75%, #f3f4f6 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.preview-card.has-image .preview-canvas-wrapper,
.preview-card.text-mode .preview-canvas-wrapper {
    opacity: 1;
}

/* Hover overlay to change image */
.preview-card.has-image:hover::after {
    content: '点击更换图片';
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    z-index: 3;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, 10px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

#previewCanvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

/* Right: Settings */
.settings-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.settings-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-card h3::before {
    content: '';
    display: block;
    width: 3px;
    height: 16px;
    background: var(--text-color);
    border-radius: 2px;
}

/* Text Settings Form */
.settings-section {
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 0.6rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: var(--text-color);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--text-color);
    background: #fff;
}

.color-picker-group {
    display: flex;
    gap: 1rem;
}

.color-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f9fafb;
    padding: 6px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

input[type="color"] {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    padding: 0;
    background: none;
    cursor: pointer;
}

.range-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="range"] {
    flex-grow: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

/* Radio Grid */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
    margin-bottom: auto;
}

/* Download Button */
.download-btn {
    width: 100%;
    padding: 0.8rem;
    margin-top: 1rem;
    border-radius: 16px;
    border: none;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--primary-color);
    color: white;
    opacity: 0.6;
    filter: grayscale(0.4);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.download-btn.active {
    opacity: 1;
    filter: none;
    pointer-events: all;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.download-btn.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.download-btn.active:active {
    transform: translateY(0);
}

.checkbox-btn {
    position: relative;
    cursor: pointer;
}

.checkbox-btn input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-btn span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.checkbox-btn:hover span {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
    transform: translateY(-2px);
}

.checkbox-btn input:checked+span {
    background: var(--primary-color);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    font-weight: 700;
    transform: translateY(-2px);
}



@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .container {
        height: auto;
        padding: 2rem 0;
    }

    body {
        overflow-y: auto;
        height: auto;
    }

    .preview-card {
        min-height: 300px;
    }
}

/* Navigation */
.top-nav {
    position: absolute;
    top: 2rem;
    left: 2rem;
    z-index: 100;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 10px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--text-color);
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.nav-link svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 900px) {
    .top-nav {
        position: relative;
        top: 0;
        left: 0;
        width: 100%;
        padding: 1rem 2rem 0;
    }
}