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

:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #eff6ff;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --background: #ffffff;
    --surface: #f8fafc;
    --surface-light: #e2e8f0;
    --surface-border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

/* Navigation */
.navbar {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-nav {
    display: flex;
    gap: 0.5rem;
}

.navbar-nav a {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.navbar-nav a:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.navbar-nav a.active {
    background: var(--primary-light);
    color: var(--primary-color);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.2rem;
    font-weight: 400;
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.tool-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.tool-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.tool-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.tool-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.tool-card p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.features {
    list-style: none;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.features li {
    color: var(--text-secondary);
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

.features li::before {
    content: "✓ ";
    color: var(--success-color);
    margin-right: 0.5rem;
    font-weight: 600;
}

/* Buttons */
.btn-primary {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    font-size: 0.9rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--primary-color);
}

.icp-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.icp-info a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.icp-info a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.toast-close {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 0.25rem;
    transition: color 0.2s ease;
}

.toast-close:hover {
    color: var(--text-primary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast.removing {
    animation: slideOut 0.3s ease forwards;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--surface-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 腾讯广告联盟样式 */
.ad-section {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin: 1.5rem 0;
    border: 1px solid var(--border-color);
}

.ad-section .panel-title {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

#ad-container {
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-ad-container {
    width: 100%;
    max-width: 800px;
}

.ad-content {
    padding: 0.75rem;
}

.ad-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.ad-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.cta-button {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.cta-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.ad-image {
    width: 100%;
    margin-bottom: 0.75rem;
}

.ad-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.ad-video {
    width: 100%;
    margin-bottom: 0.75rem;
}

.ad-video video {
    width: 100%;
    border-radius: 8px;
}

.advertiser {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.ad-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-size: 0.9rem;
}

.ad-error {
    text-align: center;
    color: var(--danger-color);
    padding: 1rem;
    display: none;
    font-size: 0.9rem;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.back-btn:hover {
    background: var(--surface);
    color: var(--text-primary);
}

/* Upload Area */
.upload-area {
    background: white;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.upload-area input {
    display: none;
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.upload-text {
    font-size: 1rem;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
    font-weight: 500;
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Preview Area */
.preview-area {
    display: none;
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.preview-area.active {
    display: block;
}

.preview-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.main-content .controls {
    position: sticky;
    top: 1rem;
    margin-bottom: 0;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .main-content .controls {
        position: static;
    }
}

.preview-box {
    background: var(--surface);
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.preview-box h3 {
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.preview-box img,
.preview-box canvas {
    width: 100%;
    border-radius: 8px;
    display: block;
}

.image-info {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Controls */
.controls {
    display: none;
    background: white;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.controls.active {
    display: block;
}

.controls h3 {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.control-group {
    margin-bottom: 0.75rem;
}

.control-group label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.control-group input[type="range"] {
    width: 100%;
    height: 4px;
    background: var(--surface-light);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.range-value {
    display: inline-block;
    background: var(--surface-light);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    min-width: 3rem;
    text-align: center;
}

.button-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.btn-primary,
.btn-secondary {
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
}

/* Controls Grid Layout */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.controls-grid .control-group {
    margin-bottom: 0;
}

/* Crop Area */
#cropCanvas {
    max-width: 100%;
    border-radius: 8px;
    cursor: crosshair;
    background: var(--surface);
}

.crop-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.crop-controls .control-group label {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.crop-controls select,
.crop-controls input[type="number"] {
    width: 100%;
    padding: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.crop-controls button {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

.crop-preview-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .preview-container,
    .crop-preview-container {
        grid-template-columns: 1fr;
    }

    .image-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .main-content {
        grid-template-columns: 1fr;
    }
}
