/* ================================================================
   AI创作助手 - PC + 移动端响应式样式
   ================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --bg: #f0f4f8;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --tab-height: 64px;
    --header-height: 56px;
    --sidebar-width: 240px;
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* ===== 移动端正向布局 ===== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

.app-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    height: var(--header-height);
}

    .app-header .title {
        font-size: 1.1rem;
        font-weight: 700;
        letter-spacing: -0.3px;
    }

        .app-header .title .highlight {
            color: var(--primary);
        }

.header-mine-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

    .header-mine-btn:hover {
        background: var(--bg);
    }

.app-main {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.tab-page {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 16px 20px calc(var(--tab-height) + 20px);
    -webkit-overflow-scrolling: touch;
    display: none;
    animation: fadeUp 0.25s ease;
}

    .tab-page.active {
        display: block;
    }

    .tab-page::-webkit-scrollbar {
        width: 3px;
    }

    .tab-page::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 4px;
    }

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 首页工具网格 ===== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 4px;
}

.tool-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px 8px 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

    .tool-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

    .tool-card:active {
        transform: scale(0.96);
    }

    .tool-card .tool-icon {
        font-size: 2rem;
        display: block;
        margin-bottom: 6px;
    }

    .tool-card .tool-name {
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--text);
    }

    .tool-card .tool-desc {
        font-size: 0.65rem;
        color: var(--text-muted);
        margin-top: 3px;
    }

.home-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding-bottom: 8px;
}

/* ===== 历史记录 ===== */
.page-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.history-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.filter-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

    .filter-btn.active {
        background: var(--primary);
        color: #fff;
        border-color: var(--primary);
    }

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 10px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.h-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

    .h-thumb img, .h-thumb video {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.h-info {
    flex: 1;
    min-width: 0;
}

.h-title {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.h-meta {
    display: flex;
    gap: 8px;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.h-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

    .h-actions button {
        background: var(--bg);
        border: none;
        border-radius: 8px;
        padding: 6px 8px;
        font-size: 0.85rem;
        cursor: pointer;
        transition: background 0.2s;
    }

        .h-actions button:hover {
            background: var(--border);
        }

.btn-download {
    color: #10b981;
}

.btn-delete {
    color: #ef4444;
}

.history-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.history-batch {
    display: flex;
    justify-content: center;
    padding: 16px 0;
}

.batch-btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 24px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

    .batch-btn:hover {
        background: #fef2f2;
        color: #ef4444;
        border-color: #fecaca;
    }

/* ===== 我的页面 ===== */
.profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

    .profile-card .avatar {
        font-size: 2.5rem;
    }

.p-info .p-name {
    font-weight: 600;
    font-size: 1rem;
}

.p-info .p-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-item {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 16px 8px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-num {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.mine-section {
    margin-bottom: 20px;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    padding-left: 4px;
}

.mine-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.mine-grid-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
}

    .mine-grid-item:hover {
        transform: scale(1.03);
    }

    .mine-grid-item img, .mine-grid-item video {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.mine-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.8rem;
    background: var(--card);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
}

/* ===== 详情页面 ===== */
.detail-page {
    position: absolute;
    inset: 0;
    background: var(--bg);
    z-index: 200;
    display: none;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

    .detail-page.active {
        display: flex;
    }

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.detail-nav {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    z-index: 5;
}

.back-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

    .back-btn:hover {
        background: var(--border);
    }

.detail-title {
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
}

.detail-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.detail-content {
    padding: 16px;
}

.params-section {
    margin-bottom: 20px;
}

.section-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.prompt-input-wrap {
    position: relative;
}

.prompt-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    resize: none;
    background: var(--card);
    color: var(--text);
    transition: border-color 0.2s;
    line-height: 1.6;
}

    .prompt-input:focus {
        outline: none;
        border-color: var(--primary);
    }

.char-count {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.style-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 6px 14px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: 0.78rem;
    cursor: pointer;
    background: var(--card);
    transition: all 0.2s;
    color: var(--text-secondary);
}

    .tag:hover {
        border-color: var(--primary);
        color: var(--primary);
    }

    .tag.active {
        background: var(--primary);
        color: #fff;
        border-color: var(--primary);
    }

.custom-style-input {
    margin-top: 8px;
}

    .custom-style-input input {
        width: 100%;
        padding: 10px 14px;
        border: 1.5px solid var(--border);
        border-radius: var(--radius-sm);
        font-size: 0.85rem;
        background: var(--card);
        color: var(--text);
    }

        .custom-style-input input:focus {
            outline: none;
            border-color: var(--primary);
        }

.option-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.opt {
    padding: 10px 4px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.8rem;
    cursor: pointer;
    background: var(--card);
    transition: all 0.2s;
    color: var(--text-secondary);
}

    .opt:hover {
        border-color: var(--primary);
    }

    .opt.active {
        background: var(--primary);
        color: #fff;
        border-color: var(--primary);
    }

/* 上传区域 */
.upload-section {
    margin-bottom: 20px;
}

.upload-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

    .upload-tabs button {
        flex: 1;
        padding: 8px;
        border: 1px solid var(--border);
        border-radius: 8px;
        font-size: 0.78rem;
        background: var(--card);
        cursor: pointer;
        color: var(--text-secondary);
        transition: all 0.2s;
    }

        .upload-tabs button.active {
            background: var(--primary-light);
            color: var(--primary);
            border-color: var(--primary);
        }

.upload-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--card);
}

    .upload-drop:hover, .upload-drop.dragover {
        border-color: var(--primary);
        background: var(--primary-light);
    }

.drop-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 6px;
}

.drop-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.upload-drop input[type="file"] {
    display: none;
}

.upload-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

    .upload-row input {
        flex: 1;
        padding: 10px 12px;
        border: 1.5px solid var(--border);
        border-radius: 8px;
        font-size: 0.85rem;
        background: var(--card);
    }

        .upload-row input:focus {
            outline: none;
            border-color: var(--primary);
        }

.btn-add {
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

.thumb-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
}

.thumb-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.thumb-item {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg);
}

    .thumb-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.thumb-order {
    position: absolute;
    top: 2px;
    left: 2px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 0.55rem;
    padding: 1px 4px;
    border-radius: 4px;
}

.thumb-remove {
    position: absolute;
    top: 1px;
    right: 1px;
    background: rgba(239,68,68,0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-hint {
    margin-top: 8px;
    font-size: 0.7rem;
    color: var(--primary);
    background: var(--primary-light);
    padding: 6px 10px;
    border-radius: 6px;
}

.strength-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    background: var(--card);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

    .strength-row label {
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .strength-row input[type="range"] {
        flex: 1;
        accent-color: var(--primary);
    }

.strength-val {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 28px;
    text-align: right;
}

/* 结果区域 */
.result-area {
    margin-top: 16px;
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    display: none;
}

    .result-area.visible {
        display: block;
    }

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
}

.result-content {
    padding: 12px;
}

    .result-content img, .result-content video {
        width: 100%;
        border-radius: 8px;
        max-height: 280px;
        object-fit: contain;
        background: #000;
    }

.result-prompt {
    padding: 10px 14px;
    font-size: 0.72rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 底部操作栏 */
.detail-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px calc(10px + var(--safe-bottom));
    background: var(--card);
    border-top: 1px solid var(--border);
    z-index: 5;
}

    .detail-footer.hidden {
        display: none;
    }

.btn-generate {
    flex: 1;
    padding: 13px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

    .btn-generate:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(37,99,235,0.4);
    }

    .btn-generate:active {
        transform: scale(0.97);
    }

    .btn-generate:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none;
    }

.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading .spinner {
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.status-tip {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 100px;
    text-align: center;
}

/* ===== 底部 Tab 导航（仅移动端） ===== */
.bottom-tabs {
    flex-shrink: 0;
    display: flex;
    background: var(--card);
    border-top: 1px solid var(--border);
    height: var(--tab-height);
    z-index: 100;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    font-size: 0.65rem;
}

    .tab-btn .tab-icon {
        font-size: 1.2rem;
    }

    .tab-btn.active {
        color: var(--primary);
    }

/* ===== 进度弹窗 ===== */
.progress-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
}

    .progress-overlay.visible {
        display: flex;
    }

.progress-modal {
    background: var(--card);
    border-radius: 24px;
    padding: 36px 32px 28px;
    width: 280px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: scaleUp 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.progress-ring {
    width: 90px;
    height: 90px;
    margin: 0 auto;
}

    .progress-ring circle {
        fill: none;
        stroke-width: 6;
    }

    .progress-ring .bg {
        stroke: var(--border);
    }

    .progress-ring .fg {
        stroke: var(--primary);
        stroke-linecap: round;
        transform: rotate(-90deg);
        transform-origin: center;
        stroke-dasharray: 251.2;
        stroke-dashoffset: 251.2;
        transition: stroke-dashoffset 0.5s ease;
    }

.pct {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: -50px;
}

    .pct small {
        font-size: 0.6rem;
        color: var(--text-muted);
        font-weight: 400;
    }

.p-status {
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 4px;
    color: var(--text-secondary);
}

.p-bar {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 4px;
    margin-top: 14px;
    overflow: hidden;
}

    .p-bar .fill {
        height: 100%;
        background: var(--accent-gradient);
        border-radius: 4px;
        transition: width 0.5s ease;
        width: 0%;
    }

.p-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ===== Toast / Confirm ===== */
.toast {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--text);
    color: #fff;
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 0.82rem;
    z-index: 10000;
    transition: all 0.3s;
    opacity: 0;
    pointer-events: none;
    max-width: 90%;
    text-align: center;
}

    .toast.show {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

    .confirm-overlay.visible {
        display: flex;
    }

.confirm-modal {
    background: var(--card);
    border-radius: 20px;
    padding: 28px 24px 20px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: scaleUp 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

    .confirm-modal .confirm-title {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 6px;
    }

    .confirm-modal .confirm-desc {
        font-size: 0.8rem;
        color: var(--text-secondary);
        margin-bottom: 18px;
        line-height: 1.5;
    }

    .confirm-modal .confirm-actions {
        display: flex;
        gap: 10px;
    }

        .confirm-modal .confirm-actions button {
            flex: 1;
            padding: 11px;
            border: none;
            border-radius: 10px;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s;
        }

        .confirm-modal .confirm-actions .btn-cancel {
            background: var(--bg);
            color: var(--text-secondary);
        }

            .confirm-modal .confirm-actions .btn-cancel:hover {
                background: var(--border);
            }

        .confirm-modal .confirm-actions .btn-confirm {
            background: var(--primary);
            color: #fff;
        }

            .confirm-modal .confirm-actions .btn-confirm:hover {
                background: var(--primary-hover);
            }

/* ================================================================
   桌面端样式 (>= 768px)
   ================================================================ */
@media (min-width: 768px) {
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    html, body {
        overflow: hidden;
    }

    body {
        display: flex;
        background: #eef2f7;
    }

    /* 隐藏移动端元素 */
    .app-header, .bottom-tabs, .header-mine-btn {
        display: none !important;
    }

    /* 桌面端布局 */
    .app-container {
        flex-direction: row;
        height: 100vh;
        max-height: 100vh;
    }

    /* 左侧边栏 */
    .pc-sidebar {
        width: var(--sidebar-width);
        flex-shrink: 0;
        background: var(--card);
        border-right: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    .sidebar-logo {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 20px 18px;
        border-bottom: 1px solid var(--border);
    }

    .logo-icon {
        font-size: 1.6rem;
    }

    .logo-text {
        font-size: 1.05rem;
        font-weight: 700;
        color: var(--text);
    }

    .sidebar-nav {
        flex: 1;
        padding: 12px 10px;
        overflow-y: auto;
    }

    .nav-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        border-radius: 10px;
        text-decoration: none;
        color: var(--text-secondary);
        font-size: 0.9rem;
        font-weight: 500;
        transition: all 0.2s;
        cursor: pointer;
        margin-bottom: 4px;
    }

        .nav-item:hover {
            background: var(--primary-light);
            color: var(--primary);
        }

        .nav-item.active {
            background: var(--primary);
            color: #fff;
        }

    .nav-icon {
        font-size: 1.15rem;
    }

    .sidebar-footer {
        padding: 16px;
        border-top: 1px solid var(--border);
    }

    .sidebar-stats {
        display: flex;
        justify-content: space-around;
        background: var(--bg);
        border-radius: 10px;
        padding: 12px 8px;
    }

    .s-item {
        text-align: center;
    }

    .s-num {
        display: block;
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--primary);
    }

    .s-label {
        font-size: 0.65rem;
        color: var(--text-muted);
    }

    /* 主内容区（桌面端） */
    .app-main {
        flex: 1;
        overflow: hidden;
        position: relative;
        background: var(--bg);
    }

    .tab-page {
        padding: 24px 32px;
        overflow-y: auto;
    }

    /* 桌面端工具网格 - 自适应列 */
    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
        max-width: 100%;
    }

    .tool-card {
        padding: 28px 12px 20px;
    }

        .tool-card .tool-icon {
            font-size: 2.4rem;
        }

        .tool-card .tool-name {
            font-size: 0.9rem;
        }

        .tool-card .tool-desc {
            font-size: 0.72rem;
        }

    .home-footer {
        margin-top: 32px;
        font-size: 0.75rem;
    }

    /* 历史记录桌面端 - 网格自适应 */
    .history-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 14px;
    }

    .history-item {
        flex-direction: column;
        text-align: center;
        padding: 12px;
        align-items: center;
    }

    .h-thumb {
        width: 100%;
        height: 140px;
        border-radius: 10px;
    }

    .h-info {
        text-align: center;
        width: 100%;
    }

    .h-meta {
        justify-content: center;
        flex-wrap: wrap;
    }

    .h-actions {
        justify-content: center;
        width: 100%;
        margin-top: 8px;
    }

    /* 我的页面桌面端 */
    .profile-card {
        max-width: 100%;
    }

    .stats-row {
        max-width: 100%;
    }

    .mine-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .mine-section {
        max-width: 100%;
    }

    /* ===== 详情页面桌面端 - 充分利用宽度 ===== */
    .detail-page {
        flex-direction: row;
    }

    .detail-nav {
        display: none;
    }

    .detail-scroll {
        flex: 1;
        overflow-y: auto;
        padding: 0;
    }

    .detail-content {
        padding: 28px 32px; max-width: 1000px;
    }
    .detail-preview {
        width: 420px;
        flex-shrink: 0;
        padding: 28px 24px;
        border-left: 1px solid var(--border);
        display: flex;
        flex-direction: column;
    }
    .preview-placeholder {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        color: var(--text-muted);
    }
    .preview-icon { font-size: 3rem; }
    .preview-text { font-size: 0.9rem; font-weight: 500; color: var(--text-secondary); }
    .preview-hint { font-size: 0.78rem; }

    /* 表单网格：三列 */
    .form-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .form-row-full {
        grid-column: 1 / -1;
    }

    /* 参数选项网格：五列（充分利用宽度） */
    .params-section .option-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
    }
    /* 分辨率选项较少，仍用四列 */
    #resolutionOptions .option-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* 风格标签更舒展 */
    .style-tags {
        gap: 10px;
    }

    .tag {
        padding: 8px 20px;
        font-size: 0.85rem;
    }

    .detail-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px 32px;
        background: var(--card);
        border-top: 1px solid var(--border);
        z-index: 10;
    }

    .btn-generate {
        padding: 14px;
        font-size: 1rem;
    }

    .inline-generate-bar {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 20px;
        padding: 20px 0;
        border-top: 1px solid var(--border);
        margin-top: 12px;
    }

        .inline-generate-bar.hidden {
            display: none;
        }

    .btn-generate-inline {
        background: var(--accent-gradient);
        color: #fff;
        border: none;
        border-radius: 10px;
        padding: 12px 40px;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        transition: opacity 0.2s;
        flex: 0 0 auto;
    }

        .btn-generate-inline:hover {
            opacity: 0.9;
        }

        .btn-generate-inline.loading {
            opacity: 0.7;
            pointer-events: none;
        }

    .inline-status-tip {
        font-size: 0.85rem;
        color: var(--text-muted);
    }

    /* 历史页面标题 */

    .page-title {
        font-size: 1.2rem;
        margin-bottom: 16px;
    }

    .history-filter {
        margin-bottom: 16px;
    }

    .filter-btn {
        padding: 10px;
        font-size: 0.85rem;
    }

    /* 历史详情页 */
    .history-detail-content {
        max-width: 900px;
        margin: 0 auto;
        padding: 24px 32px;
    }

    .detail-context-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* 智能引导区 */
    .smart-guide {
        padding: 20px 24px;
    }

    .quick-style-tags {
        gap: 10px;
    }

    .example-prompts {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* 参考素材面板 */
    .ref-input-group {
        display: flex;
        gap: 12px;
    }

    .ref-url-input {
        flex: 1;
    }
}

/* 小屏手机适配 */
@media (max-width: 420px) {
    .tools-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .tool-card {
        padding: 14px 4px 10px;
    }

        .tool-card .tool-icon {
            font-size: 1.5rem;
        }

        .tool-card .tool-name {
            font-size: 0.72rem;
        }

        .tool-card .tool-desc {
            font-size: 0.58rem;
        }

    .stats-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .stat-num {
        font-size: 1rem;
    }

    .option-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .detail-content {
        padding: 12px 14px;
    }

    .detail-footer {
        padding: 8px 14px calc(8px + var(--safe-bottom));
    }

    .btn-generate {
        padding: 11px;
        font-size: 0.88rem;
    }

    .upload-drop {
        padding: 14px 8px;
    }

    .bottom-tabs {
        height: 56px;
    }

    .tab-btn .tab-icon {
        font-size: 1rem;
    }

    .tab-btn span:last-child {
        font-size: 0.6rem;
    }
}

/* 平板横屏 */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .pc-sidebar {
        width: 200px;
    }

    .tools-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .detail-content {
        padding: 24px 32px;
    }
}

/* ===== 历史记录详情页样式 ===== */
.history-detail-page {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 200;
    overflow-y: auto;
    padding: 0;
}

    .history-detail-page.active {
        display: block;
    }

.history-detail-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-detail-content {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.detail-preview-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.detail-no-result {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.detail-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.detail-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.detail-prompt-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
    background: var(--bg);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
}

.detail-context-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.detail-context-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.dc-label {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.dc-value {
    font-weight: 500;
}

.detail-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.detail-regenerate {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.regenerate-prompt {
    width: 100%;
    min-height: 80px;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

    .regenerate-prompt:focus {
        outline: none;
        border-color: var(--primary);
    }

.regenerate-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0 4px;
}

.btn-regenerate {
    align-self: flex-start;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

    .btn-regenerate:hover {
        opacity: 0.9;
    }

.detail-loading, .detail-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.detail-error {
    color: #ef4444;
}

/* ===== 智能引导区样式 ===== */
.smart-guide {
    background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.guide-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.guide-icon {
    font-size: 1.1rem;
}

.guide-hint {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
}

.guide-section {
    margin-bottom: 14px;
}

    .guide-section:last-child {
        margin-bottom: 0;
    }

.section-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.section-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* 快捷风格标签 */
.qtag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--card);
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.2s;
    user-select: none;
}

    .qtag:hover {
        border-color: var(--primary);
        color: var(--primary);
    }

    .qtag.active {
        background: var(--primary);
        border-color: var(--primary);
        color: #fff;
    }

.quick-style-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* 示例提示词 */
.example-prompts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.example-prompt {
    padding: 10px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.5;
}

    .example-prompt:hover {
        border-color: var(--primary);
        background: var(--primary-light);
        color: var(--primary);
    }

/* ===== 参考素材面板样式 ===== */
.ref-panel {
    margin-top: 8px;
}

    .ref-panel.collapsed #refBody {
        display: none;
    }

    .ref-panel.collapsed #refToggleArrow {
        transform: rotate(-90deg);
    }

.ref-toggle-arrow {
    transition: transform 0.2s;
    font-size: 0.7rem;
}

.ref-body {
    padding: 12px 0;
}

.ref-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.ref-tab {
    flex: 1;
    padding: 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    color: var(--text-secondary);
}

    .ref-tab.active {
        border-color: var(--primary);
        background: var(--primary-light);
        color: var(--primary);
    }

.ref-url-input {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
}

    .ref-url-input:focus {
        border-color: var(--primary);
    }

.ref-btn-analyze {
    padding: 8px 16px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
}

    .ref-btn-analyze:hover {
        opacity: 0.9;
    }

    .ref-btn-analyze:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.ref-result {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.ref-result-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.ref-result-text {
    font-size: 0.78rem;
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.ref-btn-apply {
    margin-top: 8px;
    padding: 6px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

    .ref-btn-apply:hover {
        opacity: 0.9;
    }

/* AI扩写按钮 */
.refine-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    white-space: nowrap;
}

    .refine-btn:hover {
        opacity: 0.9;
        transform: scale(1.02);
    }

    .refine-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        transform: none;
    }

.refine-icon {
    font-size: 0.95rem;
}

.refine-text {
    font-size: 0.82rem;
}

/* ===== 表单样式 ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-select {
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

    .form-select:focus {
        border-color: var(--primary);
    }

/* ===== 结果操作按钮 ===== */
.btn-action {
    padding: 8px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

    .btn-action:hover {
        border-color: var(--primary);
        color: var(--primary);
        background: var(--primary-light);
    }

/* 内联生成栏在宽屏下的调整 */
@media (min-width: 1024px) {
    .inline-generate-bar {
        padding: 24px 0;
    }

    .btn-generate-inline {
        padding: 12px 32px;
        font-size: 1.1rem;
    }
}

/* 历史详情页桌面端重新调整 */
@media (min-width: 768px) {
    .history-detail-content {
        max-width: 900px;
        margin: 0 auto;
        padding: 24px 32px;
    }

    .detail-context-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}



/* ===== 创作背景信息面板样式 ===== */
.context-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}
.context-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
    user-select: none;
}
.context-header-icon { font-size: 1.1rem; }
.context-header-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}
.context-header-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-right: auto;
}
.context-toggle-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.context-panel.collapsed .context-toggle-arrow {
    transform: rotate(-90deg);
}
.context-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.context-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.context-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.context-select {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    transition: border-color 0.2s;
}
.context-select:focus {
    border-color: var(--primary);
}
.context-footer {
    padding-top: 4px;
    border-top: 1px solid var(--border);
    margin-top: 2px;
}
.context-saved-hint {
    font-size: 0.75rem;
    color: var(--primary);
}
/* ================================================================
   登录/注册弹窗
=============================================================== */
.auth-modal-backdrop {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
}
.auth-modal {
    background: var(--card);
    border-radius: var(--radius);
    width: 340px; max-width: 90vw;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: authSlideIn 0.2s ease;
}
@keyframes authSlideIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.auth-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px 0;
}
.auth-modal-title {
    font-size: 1.1rem; font-weight: 700; color: var(--text);
}
.auth-modal-close {
    background: none; border: none; font-size: 1.4rem;
    color: var(--text-muted); cursor: pointer; padding: 4px; line-height: 1;
}
.auth-modal-close:hover { color: var(--text); }
.auth-modal-tabs {
    display: flex; margin: 14px 20px 0; border-bottom: 2px solid var(--border);
}
.auth-tab {
    flex: 1; padding: 9px 0; border: none; background: none;
    font-size: 0.9rem; font-weight: 500; color: var(--text-muted);
    cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all 0.2s;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
#authForm { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-label { font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); }
.auth-input {
    padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.9rem; background: var(--bg); color: var(--text); outline: none;
    transition: border-color 0.2s;
}
.auth-input:focus { border-color: var(--primary); }
.auth-submit-btn {
    padding: 11px; border: none; border-radius: var(--radius-sm);
    background: var(--accent-gradient); color: #fff;
    font-size: 0.95rem; font-weight: 600; cursor: pointer;
    transition: opacity 0.2s; margin-top: 2px;
}
.auth-submit-btn:hover { opacity: 0.9; }
.auth-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-switch-hint {
    text-align: center; font-size: 0.78rem; color: var(--text-muted);
    padding: 0 20px 16px;
}
.auth-switch-hint a { color: var(--primary); text-decoration: none; }
.auth-switch-hint a:hover { text-decoration: underline; }
@media (max-width: 767px) {
    .auth-modal { width: 92vw; }
}