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

:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --secondary: #7209b7;
    --accent: #f72585;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --card-bg: rgba(255, 255, 255, 0.95);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

html,
body {
    height: 100%;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    color: var(--dark);
    padding: 0;
}

.container {
    width: auto;
    max-width: 100vw;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 0;
    transform-origin: bottom center;
    transition: transform 0.3s ease;
}

.main-panel {
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 8px 8px 4px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
}

/* 画布区域样式 */
.canvas-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-height: 0;
    justify-content: center;
}

.tabs {
    display: flex;
    background: rgba(67, 97, 238, 0.1);
    border-radius: 50px;
    padding: 0;
    max-width: 200px;
    margin: 0 auto;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.3);
}

.canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1/1;
    max-width: 90vw;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    background: white;
    flex: 1;
    min-height: 0;
}

/* 确保画布填满容器 */
#sketchCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

canvas,
.ai-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    object-fit: contain;
}

.ai-image {
    display: none;
}

/* 工具按钮样式 */
.tools {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
    padding: 0 0 4px;
    margin: 0;
    flex-shrink: 0;
    width: 100%;
}

.tool-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    color: var(--gray);
    flex-shrink: 0;
}

.tool-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(67, 97, 238, 0.25);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
}

/* 控制区域样式 */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(245, 247, 250, 0.7);
    border-radius: 16px;
    padding: 4px 2px 0;
    flex-shrink: 0;
    margin-top: auto;
}

.style-selectors {
    display: flex;
    gap: 4px;
    width: 100%;
}

select {
    flex: 1;
    min-width: 100px;
    height: 36px;
    padding: 0;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.prompt-container {
    display: flex;
    gap: 4px;
    width: 100%;
}

#promptInput {
    flex: 1 1 auto;
    min-width: 50px;
    height: 36px;
    padding: 4px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    font-size: 1rem;
    transition: all 0.2s ease;
}

#promptInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

/* 生成按钮解决方案 - 保持按钮宽度不变 */
.generate-btn {
    position: relative;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(114, 9, 183, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
    width: 60px;
    height: 36px;
    overflow: hidden;
}

.generate-btn-text {
    display: flex;
    align-items: center;
    gap: 0;
    transition: opacity 0.3s ease;
}

.generate-btn-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.generate-btn:disabled .generate-btn-text {
    opacity: 0;
}

.generate-btn:disabled .generate-btn-loading {
    opacity: 1;
}

.generate-btn:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(114, 9, 183, 0.4);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.generate-btn:disabled {
    background: var(--gray);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 备案信息样式 */
.footer-info {
    text-align: center;
    font-size: 0.5rem;
    color: var(--gray);
    padding-top: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    white-space: nowrap;
    /* 防止换行 */
    overflow: hidden;
    text-overflow: ellipsis;
}

.footer-info a {
    color: inherit;
    /* 继承父元素颜色 */
    text-decoration: none;
    /* 去除下划线 */
    cursor: pointer;
    /* 保持指针样式 */
}

.footer-info a:hover {
    text-decoration: none;
    /* 悬停时也不要下划线 */
}

/* 在文件末尾添加以下水印样式 */
.watermark {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* 垂直居中 */
    align-items: center;
    /* 水平居中 */
    pointer-events: none;
    /* 关键：确保水印不会拦截鼠标事件 */
    z-index: 1;
    /* 确保在画布上方但低于工具栏 */
    font-size: 18px;
    /* 减小字体大小 */
    font-weight: bold;
    color: rgba(67, 97, 238, 0.15);
    /* 稍微增加透明度 */
    font-family: 'Microsoft YaHei', sans-serif;
    line-height: 1.8;
    /* 增加行间距 */
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
    /* 添加白色阴影增强可读性 */
    text-align: center;
}

/* 当切换到AI标签页时隐藏水印 */
#aiImage.active~.watermark {
    display: none;
}

/* 在文件末尾添加以下样式 */

/* AI图弹窗样式 */
.ai-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(67, 97, 238, 0.1);
}

.ai-popup.active {
    display: flex;
}

.popup-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 4px;
}

.popup-images {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 1px;
    overflow: hidden;
}

.popup-ad-item {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: white;
}

.popup-ad-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.popup-ad-item img {
    width: 100%;
    height: 100%;
}

.popup-close {
    margin-top: 4px;
    padding: 6px 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: center;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 20;
}

.popup-close:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(67, 97, 238, 0.2);
}

.popup-close:active {
    transform: translateY(0);
}

i.fa.fa-spinner,
i.fa.fa-times {
    vertical-align: middle !important;
}