.page-header {
    text-align: center;
    padding: 24px 0 32px;
}
.page-title {
    font-size: 24px; font-weight: 700;
    color: var(--text-main); margin-bottom: 8px;
}
.page-subtitle {
    color: var(--text-secondary); font-size: 14px;
}

.writing-form {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 32px;
    margin-bottom: 24px;
}

.form-section { margin-bottom: 28px; }
.form-section:last-child { margin-bottom: 0; }

.form-label {
    display: block; font-size: 14px; font-weight: 600;
    color: var(--text-main); margin-bottom: 12px;
}

/* 双栏表单布局 */
.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 28px;
}
.form-row .form-section {
    flex: 1;
    margin-bottom: 0;
}
@media (max-width: 768px) {
    .form-row { flex-direction: column; gap: 20px; }
}

/* 学科选择 */
.subject-select {
    width: 135px;
    padding: 14px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 15px;
    background: var(--bg-surface);
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}
.subject-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* 论文风格选择 */
.style-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.style-option { position: relative; }
.style-option input {
    position: absolute; opacity: 0; width: 0; height: 0;
}
.style-label {
    display: block;
    padding: 12px 14px;
    background: #f9fafb;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.style-option input:checked + .style-label {
    background: #eef2ff;
    border-color: var(--primary);
    color: var(--primary);
}
.style-label:hover { border-color: #d1d5db; }

/* 标题输入组 */
.input-group {
    display: flex; gap: 12px; align-items: flex-start;
}

.text-input {
    flex: 1; padding: 14px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 15px; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.text-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.text-input::placeholder { color: #9ca3af; }

.btn-recommend {
    padding: 14px 20px;
    background: #f3f4f6;
    color: var(--text-secondary);
    font-size: 14px; font-weight: 500;
    border-radius: var(--radius-lg);
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-recommend:hover {
    background: #e5e7eb; color: var(--text-main);
}

.btn-recommend:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    color: white;
}


/* 推荐标题列表 */
.recommend-list {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}

.recommend-item {
    padding: 12px 14px;
    background: #f9fafb;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.recommend-item:hover {
    background: #eef2ff;
    border-color: var(--primary);
    color: var(--primary);
}

/* 字数选择 */
.type-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.type-option { position: relative; }
.type-option input {
    position: absolute; opacity: 0; width: 0; height: 0;
}

.type-label {
    display: block;
    padding: 12px 12px;
    text-align: center;
    background: #f9fafb;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.type-option input:checked + .type-label {
    background: #eef2ff;
    border-color: var(--primary);
    color: var(--primary);
}

.type-label:hover { border-color: #d1d5db; }

.type-label .count {
    display: block;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.type-label .desc {
    font-size: 11px;
    color: #9ca3af;
}

/* 图表插入选项 */
.chart-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #f9fafb;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s;
}
.chart-option:hover { border-color: #d1d5db; }
.chart-option.active {
    background: #eef2ff;
    border-color: var(--primary);
}
.chart-option input { display: none; }

.chart-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chart-toggle svg {
    width: 20px; height: 20px;
    color: var(--text-secondary);
}
.chart-option.active .chart-toggle svg {
    color: var(--primary);
}
.chart-toggle span {
    font-size: 14px; font-weight: 500;
    color: var(--text-main);
}

/* Toggle 开关 */
.toggle-switch {
    position: relative;
    width: 44px; height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #d1d5db;
    border-radius: 24px;
    transition: 0.2s;
}
.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}
input:checked + .toggle-slider { background: var(--primary); }
input:checked + .toggle-slider::before { transform: translateX(20px); }

/* 图表类型选择（展开） */
.chart-types {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border-light);
    display: none;
}
.chart-types.show {
    display: block;  /* 通过 JS 添加 show 类显示 */
}
.chart-type-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.chart-type-tag {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: 99px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.chart-type-tag:hover, .chart-type-tag.selected {
    background: #eef2ff;
    border-color: var(--primary);
    color: var(--primary);
}
.chart-type-tag.selected svg { color: var(--primary); }
.chart-type-tag svg {
    width: 14px; height: 14px;
    color: var(--text-secondary);
}

/* 生成按钮 */
.btn-generate {
    width: 200px;
    margin: 0 auto;
    padding: 10px;
    background: var(--primary);
    color: white;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-xl);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-generate:hover { background: var(--primary-hover); }
.btn-generate:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* 加载动画 */
.loading-spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-generate.loading .loading-spinner { display: inline-block; }
.btn-generate:not(.loading) .loading-spinner { display: none; }

/* ================= 大纲展示区域 ================= */
/* ================= 大纲展示区域（优化版） ================= */
.outline-section {
    display: none;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 32px;

    /* 新增：限制最大高度，基于视口 */
    max-height: calc(100vh - 110px);
    flex-direction: column;
}
.outline-section.show {
    display: flex;  /* 改为 flex 布局 */
}

.outline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;  /* 防止被压缩 */
}

.btn-edit {
    padding: 8px 16px;
    background: #f3f4f6;
    color: var(--text-secondary);
    font-size: 13px; font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
}
.btn-edit:hover { background: #e5e7eb; color: var(--text-main); }

.outline-title {
    font-size: 18px; font-weight: 600;
    color: var(--text-main);
}

.outline-meta {
    font-size: 13px; color: var(--text-secondary);
}

/* 大纲内容区 - 可滚动 */
.outline-tree {
    flex: 1;  /* 占据剩余空间 */
    overflow-y: auto;  /* 超出时显示滚动条 */
    margin-bottom: 20px;
    padding-right: 8px;  /* 给滚动条留空间 */

    /* 自定义滚动条样式 */
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

/* Chrome/Safari 滚动条样式 */
.outline-tree::-webkit-scrollbar {
    width: 6px;
}
.outline-tree::-webkit-scrollbar-track {
    background: transparent;
}
.outline-tree::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 3px;
}
.outline-tree::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af;
}

.outline-item {
    padding: 10px 16px;
    margin-bottom: 6px;
    background: #f9fafb;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-main);
    border-left: 3px solid transparent;
}

.outline-item.level-1 {
    background: #eef2ff;
    border-left-color: var(--primary);
    font-weight: 600;
    color: var(--primary);
}

.outline-item.level-2 {
    margin-left: 24px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
}

.outline-item.level-3 {
    margin-left: 48px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* 图表占位提示 */
.chart-placeholder {
    margin: 8px 0;
    padding: 10px 14px;
    background: #f0fdf4;
    border-left: 3px solid #22c55e;
    border-radius: 6px;
    font-size: 12px;
    color: #166534;
    display: flex;
    align-items: center;
    gap: 6px;
}
.chart-placeholder svg {
    width: 14px; height: 14px;
    flex-shrink: 0;
}

/* 操作按钮区 - 固定底部 */
.outline-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;  /* 防止被压缩 */
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.btn-regenerate {
    flex: 1;
    padding: 14px;
    background: #f3f4f6;
    color: var(--text-secondary);
    font-size: 14px; font-weight: 500;
    border-radius: var(--radius-lg);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-regenerate:hover {
    background: #e5e7eb;
    color: var(--text-main);
}

.btn-regenerate:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    color: white;
}

.btn-confirm {
    flex: 1;
    padding: 14px;
    background: var(--primary);
    color: white;
    font-size: 14px; font-weight: 500;
    border-radius: var(--radius-lg);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ordermsg {
    width: 600px;
    height: 40px;
    line-height: 40px;
    background: linear-gradient(98deg,rgba(255,191,0,0),#f5f3ff 34%,#ede9fe 65%,rgba(255,191,0,0));
    border-radius: 4px 4px 4px 4px;
    text-align: center;
    margin: 20px auto 0;
    font-size: 13px;
    color: #787d87;
    overflow: hidden;
    position: relative;
}

/* 论文风格选择（优化版） */
.word-count-options {
    display: flex;
    gap: 40px;
}

.word-count-option {
    position: relative;
    cursor: pointer;
}

.word-count-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.word-count-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    padding-left: 42px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    text-align: center;
    justify-content: center;
    position: relative;
}

.word-count-label::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    background: white;
    transition: all 0.2s;
}

.word-count-label::after {
    content: '';
    position: absolute;
    left: 21px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    opacity: 0;
    transition: all 0.2s;
}

.word-count-option input:checked + .word-count-label {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border-color: #7c3aed;
    color: #7c3aed;
}

.word-count-option input:checked + .word-count-label::before {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    border-color: #7c3aed;
    box-shadow: 0 2px 4px rgba(124, 58, 237, 0.3);
}

.word-count-option input:checked + .word-count-label::after {
    opacity: 1;
}

.word-count-label:hover {
    border-color: #a5b4fc;
    background: #f5f3ff;
}

/* ================= 下拉选择框样式 ================= */
.subject-select {
    padding-right: 40px; /* 为箭头留出空间 */
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    background-color: var(--bg-surface);
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none; /* 移除默认箭头 */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.subject-select:hover {
    border-color: var(--primary);
    background-color: #f9fafb;
}

.subject-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background-color: var(--bg-surface);
}

.subject-select option {
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-main);
    background-color: var(--bg-surface);
}

.subject-select option:checked {
    background-color: var(--primary);
    color: white;
}

.notallow {
    background: var(--text-secondary);
    cursor: not-allowed;
}

.outline-div-list {
    display: flex;
    gap: 5px;
    flex-wrap:wrap;
}

.his-outline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #eef2ff;
    color: var(--text-secondary);
    font-size: 12px;
    border-radius: 99px;
    cursor: pointer;
}