/* ===== 长篇文章写作 ===== */

/* 弹窗遮罩 */
.la-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.2s;
}

.la-modal {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
}

/* 顶部栏 */
.la-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-header);
    box-shadow: 0 1px 0 rgba(0,0,0,0.04), var(--shadow-card);
    flex-shrink: 0;
}

.la-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.la-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    transition: var(--transition-ui);
}

.la-close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}



/* 主体区域 */
.la-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 左侧章节导航 */
.la-chapter-nav {
    width: 220px;
    flex-shrink: 0;
    box-shadow: 1px 0 0 rgba(0,0,0,0.04);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.la-chapter-nav-title {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(128,128,128,0.1);
}

.la-chapter-nav-list {
    display: flex;
    flex-direction: column;
}

.la-chapter-nav-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(128,128,128,0.1);
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.la-chapter-nav-item:hover {
    background: var(--bg-hover);
}

.la-chapter-nav-item.active {
    color: var(--accent);
    font-weight: 600;
    background: rgba(var(--accent-rgb),.06);
    box-shadow: inset 3px 0 0 var(--accent);
}

.la-chapter-nav-item.completed {
    color: #34c759;
}

.la-chapter-nav-item.generating {
    color: var(--accent);
}

@keyframes laPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.la-chapter-nav-item.generating::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    margin-left: 6px;
    vertical-align: middle;
    animation: laPulse 1s ease-in-out infinite;
}

/* 主内容区 */
.la-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Phase 0 / Welcome */
.la-welcome {
    max-width: 600px;
    margin: 60px auto;
    text-align: center;
}

.la-welcome h2 {
    font-size: 24px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.la-welcome p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 12px;
}

.la-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    font-style: italic;
}

/* Phase 1: Input */
.la-input-section {
    max-width: 600px;
    margin: 40px auto;
}

.la-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    margin-top: 20px;
}

.la-topic-input {
    width: 100%;
    padding: 12px 16px;
    border: none;
    box-shadow: var(--ring-subtle);
    border-radius: var(--radius-md);
    font-size: var(--font-size);
    font-family: inherit;
    resize: vertical;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: box-shadow 0.2s;
    box-sizing: border-box;
}
.la-topic-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb),.25);
}

.la-system-prompt-input {
    width: 100%;
    padding: 12px 16px;
    border: none;
    box-shadow: var(--ring-subtle);
    border-radius: var(--radius-md);
    font-size: var(--font-size);
    font-family: inherit;
    resize: vertical;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: box-shadow 0.2s;
    box-sizing: border-box;
    min-height: 60px;
}
.la-system-prompt-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb),.25);
}
.la-body-prompt-section {
    max-width: 600px;
    margin: 0 auto;
}
.la-body-prompt-section h3 {
    margin-bottom: 12px;
}

.la-template-select {
    width: 100%;
    padding: 12px 16px;
    border: none;
    box-shadow: var(--ring-subtle);
    border-radius: var(--radius-md);
    font-size: var(--font-size);
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: box-shadow 0.2s;
    box-sizing: border-box;
    cursor: pointer;
    appearance: auto;
}
.la-template-select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb),.25);
}

.la-chapter-view {
    margin-top: 16px;
    padding: 24px;
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-md);
    min-height: 200px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
}
.la-chapter-view-content {
    word-wrap: break-word;
}
.la-chapter-view-content h2 { font-size: 18px; margin-bottom: 12px; }
.la-chapter-view-content h3 { font-size: 16px; margin-bottom: 8px; }
.la-chapter-view-content p { margin-bottom: 12px; }
.la-chapter-view-content pre { margin: 12px 0; }

.la-history-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
}
.la-history-item:hover {
    background: var(--bg-hover);
}
.la-history-item.active {
    background: var(--bg-active);
    font-weight: 600;
}
.la-history-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.la-history-item-delete {
    font-size: 14px;
    opacity: 0;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: opacity 0.15s, color 0.15s;
    padding: 2px 6px;
    flex-shrink: 0;
}
.la-history-item:hover .la-history-item-delete {
    opacity: 1;
}
.la-history-item-delete:hover {
    color: #ef4444;
}

.la-chapter-count-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.la-chapter-count-input {
    width: 80px;
    padding: 8px 12px;
    border: none;
    box-shadow: var(--ring-subtle);
    border-radius: var(--radius-md);
    font-size: var(--font-size);
    text-align: center;
    background: var(--bg-input);
    color: var(--text-primary);
}

.la-chapter-count-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb),.25);
}

.la-chapter-count-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Model toggle in Phase 1 */
.la-model-row {
    display: flex;
    gap: 16px;
    margin: 8px 0 4px 0;
}

.la-model-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    box-shadow: var(--ring-subtle);
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.2s, box-shadow 0.2s, color 0.2s;
    background: var(--bg-input);
}

.la-model-option:has(input:checked) {
    box-shadow: 0 0 0 1px var(--accent);
    color: var(--accent);
    font-weight: 600;
    background: rgba(var(--accent-rgb),.06);
}

.la-model-option:hover {
    box-shadow: 0 0 0 1px var(--accent);
}

.la-model-option input[type="radio"] {
    accent-color: var(--accent);
}

/* Shared buttons */
.la-primary-btn, .la-secondary-btn, .la-warning-btn {
    padding: 10px 24px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, transform 0.2s;
    border: none;
}

.la-primary-btn {
    background: var(--accent);
    color: var(--text-user-bubble);
    box-shadow: 0 2px 8px rgba(var(--accent-rgb),0.2);
}

.la-primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.la-primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.la-secondary-btn {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: none;
    box-shadow: var(--ring-subtle);
}

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

.la-warning-btn {
    background: var(--btn-warning);
    color: #fff;
}

.la-warning-btn:hover {
    background: var(--btn-warning-hover);
}

/* Progress bars */
.la-outline-progress, .la-gen-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.la-progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border-lighter);
    border-radius: 999px;
    overflow: hidden;
}

.la-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #B388FF);
    border-radius: 999px;
    transition: width 0.3s;
    width: 0%;
}

.la-progress-text {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* Phase 2: Outlines */
.la-outline-header, .la-generation-header {
    margin-bottom: 20px;
}

.la-outline-header h3, .la-generation-header h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.la-outline-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 20px 0;
}

.la-outline-item {
    background: var(--bg-bubble-assistant);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-elevated);
}

.la-outline-item-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.la-outline-item-abstract {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.la-outline-chapter-num {
    user-select: none;
}
.la-outline-editable {
    display: inline;
    outline: none;
    border-radius: 3px;
    padding: 1px 4px;
    margin: -1px -4px;
    transition: background 0.15s;
}
.la-outline-editable:hover {
    background: var(--bg-hover);
}
.la-outline-editable:focus {
    background: var(--bg-input);
    box-shadow: 0 0 0 2px var(--accent-glow);
    border-radius: 4px;
}

.la-outline-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.la-outline-item-actions button {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    border: none;
    box-shadow: var(--ring-subtle);
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}

.la-outline-item-actions button:hover {
    background: var(--bg-hover);
    box-shadow: 0 0 0 1px var(--accent);
    color: var(--accent);
}

.la-outline-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}

/* Phase 3: Completed chapters (viewable during generation) */
.la-gen-completed {
    margin-bottom: 20px;
}

.la-completed-chapter {
    background: var(--bg-bubble-assistant);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-elevated);
}

.la-completed-chapter h4 {
    font-size: 15px;
    font-weight: 600;
    color: #34c759;
    margin: 0 0 8px 0;
}

.la-completed-chapter-body {
    font-size: var(--font-size);
    line-height: 1.8;
    color: var(--text-primary);
    max-height: 300px;
    overflow-y: auto;
}

/* Phase 3: Streaming */
.la-gen-current-chapter {
    margin: 20px 0;
}

.la-chapter-stream-bubble {
    background: var(--bg-bubble-assistant);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-height: 200px;
    box-shadow: var(--shadow-card);
    font-size: var(--font-size);
    line-height: 1.8;
    color: var(--text-primary);
}

.la-chapter-stream-content {
    min-height: 20px;
}

.la-gen-actions {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

/* Phase 4: Complete article */
.la-complete-header {
    text-align: center;
    margin-bottom: 20px;
}

.la-complete-header h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.la-complete-header p {
    font-size: 13px;
    color: var(--text-tertiary);
}

.la-complete-article {
    background: var(--bg-bubble-assistant);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 20px 0;
    box-shadow: var(--shadow-card);
    font-size: var(--font-size);
    line-height: 1.8;
    color: var(--text-primary);
    max-height: 55vh;
    overflow-y: auto;
}

.la-complete-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Sidebar interaction: suppress desktop push when modal open */
body.la-modal-open #mainWrapper.sidebar-open {
    margin-left: 0 !important;
}

/* ===== 长篇文章写作 - 移动端适配 ===== */
@media (max-width: 600px) {
    .la-chapter-nav {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1020;
        width: 75vw;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(.22,1,.36,1);
        box-shadow: var(--shadow-elevated);
    }

    .la-chapter-nav.mobile-open {
        transform: translateX(0);
    }

    /* Chapter nav backdrop */
    .la-chapter-nav-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 1019;
        background: rgba(0,0,0,.35);
    }

    .la-chapter-nav-backdrop.show {
        display: block;
    }

    .la-main {
        padding: 16px;
    }

    .la-welcome {
        margin: 32px auto;
    }

    .la-welcome h2 {
        font-size: 20px;
    }

    .la-input-section {
        margin: 20px auto;
    }

    .la-outline-item {
        padding: 12px;
    }

    .la-outline-item-title {
        font-size: 14px;
    }

    .la-chapter-stream-bubble {
        padding: 12px;
        min-height: 120px;
    }

    .la-complete-article {
        padding: 12px;
        max-height: 45vh;
    }

    .la-title {
        font-size: 14px;
    }

    .la-header {
        padding: 8px 12px;
    }

    .la-primary-btn, .la-secondary-btn, .la-warning-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .la-outline-actions {
        flex-direction: column;
        align-items: center;
    }
}

/* #31 暗色模式边缘高光 — 0.5px 极淡白边 */
body.dark .la-modal,
body.dark .la-sidebar,
body.dark .la-settings,
body.dark .la-header {
    box-shadow: inset 0 0 0 0.5px rgba(255,255,255,0.04);
}
