/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* 容器 */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 15px;
}

/* 无padding容器 - Reverted to 100% for full width sections */
.container-no-padding {
    /* max-width: 800px; - Reverted */
    width: 100%;
    margin: 0 auto;
    padding: 0;
}

/* main-content 内部的 container */
.main-content .container {
    padding: 0 10px;
}

/* 分类标签 */
/* Tabs Wrapper for 100% Band */
.tabs-wrapper {
    background-color: #fff;
    width: 100%;
    border-bottom: 1px solid #eee;
    /* Optional visual separation */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Shadow moves here */
    margin-bottom: 20px;
}

/* 分类标签 Inner Container */
.category-tabs {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    /* justify-content: center; */
    padding: 15px 0;
    /* background-color: #fff; Removed, handled by wrapper */
    margin: 0 auto;
    /* Center the container itself */
    max-width: 800px;
    /* Constraint content */
    /* box-shadow: ...; Removed */
    -webkit-overflow-scrolling: touch;
    width: 100%;
    white-space: nowrap;
}

/* .category-tabs::-webkit-scrollbar { display: none; } Removed */

/* Header Styling */
/* Header Styling - Connected to Tabs */
/* Header Styling */
header {
    text-align: center;
    background-color: #fff;
    padding: 20px 0;
    margin-bottom: 20px;
    /* Default spacing for non-home pages */
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    /* Faint separator line */
}

header.header-connected {
    margin-bottom: 0;
    /* No gap for connected tabs */
    /* Keep the border as requested for distinction, or remove if "seamless" wanted. 
       User said: "要有一条较淡的分割线，这样首页和标签模块也有区分度" -> Keep border. */
}

header h1 {
    max-width: 800px;
    margin: 0 auto;
}

/* 分类标签项基础样式 */
.category-tab {
    flex-shrink: 0;
    padding: 8px 16px;
    margin: 0 4px;
    background-color: #f0f0f0;
    border-radius: 20px;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Center tabs when they fit, scroll when they don't */
.category-tab:first-child {
    margin-left: auto;
}

.category-tab:last-child {
    margin-right: auto;
}

/* 响应式设计 - 手机端优化 */
@media (max-width: 768px) {
    .category-tabs {
        justify-content: flex-start;
        padding: 10px 5px;
    }
}

@media (max-width: 480px) {
    .category-tabs {
        padding: 10px 5px;
        margin: 0 0 15px 0;
    }

    .category-tab {
        padding: 6px 14px;
        margin: 0 4px;
        font-size: 13px;
    }
}

.category-tab:hover,
.category-tab.active {
    background-color: #4a90e2;
    color: #fff;
}

/* 图片列表 */
.image-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 80px;
}

.image-item {
    background-color: transparent;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    transition: transform 0.3s ease;
}

.image-item:hover {
    transform: translateY(-3px);
    box-shadow: none;
}

.image-item a {
    display: block;
    text-decoration: none;
    color: #333;
}

.image-item img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: 4px;
    /* Subtle radius */
}

.image-info {
    display: none;
}

/* 生成页面样式 */
.generate-container {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: 250px;
    /* More space for fixed controls if needed, generally useful */
}

.generate-section {
    background-color: #fff;
    border-radius: 8px;
    /* Subtle radius */
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
    padding-left: 5px;
    border-left: 4px solid #4a90e2;
    line-height: 1.2;
}

.image-grid.fixed-4-columns {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 0;
}

.generate-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
    padding: 0;
    /* Aligned with the White Sections (cards) themselves, not the inner grid */
}

.controls-row {
    display: flex;
    gap: 16px;
    width: 100%;
}

.image-select-btn-container,
.aspect-ratio-selector-container {
    flex: 1;
    /* 50% split */
    position: relative;
    width: 50%;
    /* Ensuring equal width */
}

/* Image Select Button */
.image-select-btn,
.aspect-ratio-btn {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 0 16px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    width: 100%;
    height: 52px;
    /* Consistent Height */
    color: #555;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.image-select-btn:hover,
.aspect-ratio-btn:hover {
    background-color: #f8f9fa;
    border-color: #ccc;
    transform: translateY(-1px);
}

/* Preview Thumbnail Floating Style */
/* Preview Thumbnail Floating Style */
.selected-image-preview {
    position: absolute;
    bottom: 70px;
    /* Adjusted for larger size + arrow */
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 120px;
    /* 3:4 aspect ratio */
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    border: 3px solid #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 20;
    display: none;
    pointer-events: none;
}

/* Triangle Arrow */
.selected-image-preview::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -8px;
    border-width: 8px;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
}

.selected-image-preview.show {
    display: block;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translate(-50%, 10px) scale(0.8);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

.aspect-ratio-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px;
    min-width: 120px;
    z-index: 100;
    display: none;
}

.aspect-ratio-menu::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: #ddd transparent transparent transparent;
}

.aspect-menu-item {
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-align: center;
}

.aspect-menu-item:hover {
    background-color: #f0f0f0;
}

.aspect-menu-item input[type="radio"] {
    display: none;
}

.aspect-menu-item input[type="radio"]:checked+span {
    font-weight: bold;
    color: #646cff;
}

.base-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.upload-image-item {
    width: 100%;
    aspect-ratio: 3/4;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: transparent;
}

.upload-image-item:hover {
    border-color: #4a90e2;
    background-color: transparent;
}

.upload-icon {
    font-size: 40px;
    color: #999;
    transition: color 0.3s ease;
}

.upload-image-item:hover .upload-icon {
    color: #4a90e2;
}

.uploaded-image-item {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: none;
}

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

.remove-image-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(255, 0, 0, 0.8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.remove-image-btn:hover {
    background-color: rgba(255, 0, 0, 1);
    transform: scale(1.1);
}

.sample-images-grid,
.result-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.sample-image-item,
.result-image-item {
    cursor: pointer;
    transition: all 0.3s ease;
}

.sample-image-item:hover,
.result-image-item:hover {
    transform: scale(1.05);
}

.sample-image-item img,
.result-image-item img {
    width: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.aspect-1-1 img {
    aspect-ratio: 1/1;
}

.aspect-3-5 img {
    aspect-ratio: 3/5;
}

.aspect-9-16 img {
    aspect-ratio: 9/16;
}

.aspect-3-4 img {
    aspect-ratio: 3/4;
}

/* Generate Button */
.generate-btn {
    width: 100%;
    height: 52px;
    padding: 0 20px;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: #fff;
    border: none;
    border-radius: 26px;
    /* Pill shape */
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
    /* Added spacing */
    margin-bottom: 90px;
    /* Added spacing */
    z-index: 5;
    position: relative;
    /* Ensure visibility */
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

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

/* Lightbox Styles */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}

.lightbox-content-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    /* Max display width */
    text-align: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}

.lightbox-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
}

.lightbox-btn {
    padding: 10px 25px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.download-btn {
    background-color: #fff;
    color: #333;
}

.download-btn:hover {
    background-color: #f0f0f0;
    transform: scale(1.05);
}

.close-lightbox-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.close-lightbox-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 记录页面样式 */
.record-list {
    margin-bottom: 80px;
}

.record-item {
    background-color: transparent;
    border-radius: 0;
    padding: 10px 0;
    margin-bottom: 15px;
    box-shadow: none;
}

.record-images {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    overflow-x: auto;
}

.record-image {
    flex: 0 0 auto;
    width: 150px;
    height: 150px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.record-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.record-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.record-meta {
    font-size: 12px;
    color: #666;
}

.record-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.regenerate-btn {
    background-color: #4a90e2;
    color: #fff;
    border: none;
}

.delete-btn {
    background-color: #e74c3c;
    color: #fff;
    border: none;
}

/* 个人中心页面样式 */
.user-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 10px;
    margin-bottom: 80px;
}

.user-card {
    background-color: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-info {
    text-align: center;
}

.user-points {
    font-size: 36px;
    font-weight: 700;
    color: #4a90e2;
    margin: 10px 0;
}

.user-detail {
    font-size: 14px;
    color: #666;
    margin: 5px 0;
}

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #fff;
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #666;
    font-size: 12px;
    transition: color 0.3s ease;
}

.nav-item:hover,
.nav-item.active {
    color: #4a90e2;
}

.nav-item i {
    font-size: 24px;
    margin-bottom: 5px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .record-image {
        flex: 0 0 auto;
        width: 120px;
        height: 120px;
    }
}

@media (max-width: 480px) {
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }

    .record-images {
        gap: 10px;
    }

    .record-image {
        flex: 0 0 auto;
        width: 100px;
        height: 100px;
    }

    .record-info {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* 隐藏文件输入 */
#file-input {
    display: none;
}

/* 登录和注册页面样式 */
.auth-form-container,
.auth-container {
    background-color: #fff;
    border-radius: 16px;
    /* Premium aesthetics */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    /* Soft, elevated shadow */
    padding: 40px;
    /* More breathing room */
    max-width: 440px;
    margin: 40px auto 60px;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.auth-form-container h2,
.auth-container h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 24px;
    font-weight: 600;
}

.auth-form-container .form-group,
.auth-container .form-group {
    margin-bottom: 20px;
}

.auth-form-container .form-group label,
.auth-container .form-group label {
    display: block;
    margin-bottom: 8px;
    color: #666;
    font-weight: 500;
    font-size: 14px;
}

/* Unified Input Styling */
.auth-form-container .form-group input[type="text"],
.auth-form-container .form-group input[type="email"],
.auth-form-container .form-group input[type="password"],
.auth-container .form-group input[type="text"],
.auth-container .form-group input[type="email"],
.auth-container .form-group input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    background-color: #fcfcfc;
    transition: all 0.3s ease;
    height: 48px;
    /* Comfortable touch target */
}

.auth-form-container .form-group input:focus,
.auth-container .form-group input:focus {
    border-color: #4a90e2;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
    outline: none;
}

.auth-form-container .captcha-group,
.auth-container .captcha-group {
    display: block;
    /* Stack on small screens if needed, but flex is fine */
}

.captcha-container {
    display: flex;
    gap: 12px;
    align-items: center;
}

.captcha-image {
    height: 48px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid #e0e0e0;
}

.captcha-hint {
    font-size: 12px;
    color: #999;
    margin-top: 6px;
}

.auth-button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 48px;
    margin-top: 10px;
}

.auth-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.auth-button:active {
    transform: translateY(0);
}

.auth-link,
.auth-links {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: #666;
}

.auth-link a,
.auth-links a {
    color: #4a90e2;
    text-decoration: none;
    font-weight: 500;
}

.auth-link a:hover,
.auth-links a:hover {
    text-decoration: underline;
}

/* 消息提示样式 */
.success-message,
.error-message {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
    text-align: center;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.error-messages {
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.error-messages ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.error-messages li {
    color: #c33;
    padding: 5px 0;
    font-size: 14px;
}

.error-messages li i {
    margin-right: 8px;
}

/* 认证链接样式 */
.auth-links {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #666;
}

.auth-links a {
    color: #646cff;
    text-decoration: none;
    font-weight: 500;
}

.auth-links a:hover {
    text-decoration: underline;
}