/* ========================================================
   高考作文提分系统 · 主样式
   设计风格：大气学术感，米白+深蓝+金色点缀
   ======================================================== */

:root {
    --bg: #f7f5f0;
    --bg-card: #ffffff;
    --primary: #1a3a5c;
    --primary-light: #2e5e8e;
    --accent: #c8922a;
    --accent-light: #f0b429;
    --text: #2c2c2c;
    --text-mute: #6b7280;
    --border: #e2ddd5;
    --success: #2d7a4f;
    --danger: #c0392b;
    --step-active: #1a3a5c;
    --step-done: #2d7a4f;
    --step-idle: #ccc;
    --shadow: 0 2px 12px rgba(26,58,92,0.10);
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ---- 顶部 Banner ---- */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, #0d2540 100%);
    color: #fff;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.site-header .logo { font-size: 28px; }
.site-header h1 { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.site-header p  { font-size: 12px; opacity: 0.7; margin-top: 2px; }
.header-nav {
    margin-left: auto;
    display: flex;
    gap: 12px;
}
.header-nav button {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    padding: 6px 16px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}
.header-nav button:hover, .header-nav button.active {
    background: var(--accent);
    border-color: var(--accent);
}

/* ---- 主容器 ---- */
.main-container {
    max-width: 960px;
    margin: 28px auto;
    padding: 0 16px;
}

/* ---- 步骤进度条 ---- */
.steps-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 28px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 24px;
    box-shadow: var(--shadow);
}
.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    position: relative;
    cursor: default;
}
.step-item:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 18px;
    right: -50%;
    width: 100%;
    height: 2px;
    background: var(--step-idle);
    z-index: 0;
    transition: background 0.3s;
}
.step-item.done:not(:last-child)::after { background: var(--step-done); }
.step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--step-idle);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    z-index: 1;
    transition: background 0.3s, transform 0.2s;
}
.step-item.active .step-num { background: var(--step-active); transform: scale(1.15); }
.step-item.done .step-num   { background: var(--step-done); }
.step-label {
    font-size: 12px;
    color: var(--text-mute);
    text-align: center;
    white-space: nowrap;
}
.step-item.active .step-label { color: var(--primary); font-weight: 600; }
.step-item.done  .step-label  { color: var(--success); }

/* ---- 面板卡片 ---- */
.panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 32px;
    margin-bottom: 20px;
    display: none;
    animation: fadeIn 0.3s ease;
}
.panel.active { display: block; }
@keyframes fadeIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform:none; } }

.panel-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- 表单元素 ---- */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.form-group textarea,
.form-group input[type=text],
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    color: var(--text);
    background: #fafaf8;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    resize: vertical;
}
.form-group textarea:focus,
.form-group input[type=text]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46,94,142,0.12);
    background: #fff;
}
.form-group textarea { min-height: 90px; }

/* ---- 类型选择卡片 ---- */
.type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}
.type-card {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafaf8;
}
.type-card:hover { border-color: var(--primary-light); background: #f0f5fa; }
.type-card.selected { border-color: var(--primary); background: #eaf1f9; }
.type-card h4 { font-size: 14px; color: var(--primary); margin-bottom: 4px; }
.type-card p  { font-size: 12px; color: var(--text-mute); line-height: 1.5; }
.type-card .tag {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-bottom: 6px;
}

/* ---- 结构选择 ---- */
.struct-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.struct-item {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.struct-item:hover { border-color: var(--primary-light); background: #f5f8fc; }
.struct-item.selected { border-color: var(--primary); background: #eaf1f9; }
.struct-item .badge {
    background: var(--primary);
    color: #fff;
    border-radius: 6px;
    padding: 3px 9px;
    font-size: 12px;
    white-space: nowrap;
    margin-top: 2px;
    flex-shrink: 0;
}
.struct-item .info h4 { font-size: 14px; color: var(--text); }
.struct-item .info p  { font-size: 12px; color: var(--text-mute); margin-top: 3px; line-height: 1.5; }
.struct-item.selected .badge { background: var(--accent); }

/* ---- 作文框架 ---- */
.framework-box { margin-bottom: 20px; }
.section-block {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}
.section-header {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
}
.section-header .hint-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
}
.section-body { padding: 14px 16px; }
.section-points { font-size: 13px; color: var(--text-mute); margin-bottom: 10px; line-height: 1.8; }
.section-body textarea {
    width: 100%;
    min-height: 70px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
    background: #fafaf8;
}
.section-body textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    background: #fff;
}

/* ---- 素材库面板 ---- */
.material-panel {
    border: 1px dashed var(--accent);
    border-radius: 8px;
    padding: 14px;
    margin-top: 8px;
    background: #fffbf5;
}
.material-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.mat-tab {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.mat-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.mat-search {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.mat-search input {
    flex: 1;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}
.mat-search button {
    padding: 7px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.mat-list { max-height: 220px; overflow-y: auto; }
.mat-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    transition: background 0.15s;
}
.mat-item:last-child { border-bottom: none; }
.mat-item:hover { background: #f5f0e8; }
.mat-item .mat-body { flex: 1; }
.mat-item .mat-title { font-weight: 600; color: var(--primary); margin-bottom: 3px; }
.mat-item .mat-content { color: var(--text-mute); line-height: 1.6; }
.mat-item .mat-tags { margin-top: 4px; }
.mat-tag {
    display: inline-block;
    background: #e8f0f8;
    color: var(--primary-light);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 8px;
    margin-right: 4px;
}
.mat-item .use-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}
.mat-item .del-btn {
    background: #fce8e8;
    color: var(--danger);
    border: none;
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ---- AI批改结果 ---- */
.review-result { margin-top: 20px; }
.score-board {
    display: grid;
    grid-template-columns: auto 1fr 1fr 1fr 1fr;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}
.score-total {
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    grid-row: 1;
}
.score-total .num { font-size: 42px; font-weight: 700; line-height: 1; }
.score-total .label { font-size: 12px; opacity: 0.8; margin-top: 4px; }
.score-sub {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border-left: 1px solid var(--border);
    background: #f9f9f9;
}
.score-sub .num { font-size: 24px; font-weight: 700; color: var(--primary); }
.score-sub .label { font-size: 11px; color: var(--text-mute); margin-top: 3px; }

.review-section {
    margin-bottom: 16px;
}
.review-section h3 {
    font-size: 15px;
    color: var(--primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.review-section ul { padding-left: 20px; }
.review-section li { font-size: 13px; line-height: 2; color: var(--text); }

.essay-output {
    background: #fafaf8;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 24px;
    font-size: 15px;
    line-height: 2.1;
    white-space: pre-wrap;
    color: var(--text);
    margin-top: 8px;
    position: relative;
}
.essay-copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 5px 14px;
    font-size: 12px;
    cursor: pointer;
}

/* ---- 按钮 ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-light); color: var(--text); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: #eaf1f9; }
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-group { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- AI加载动画（旧版，保留兼容） ---- */
.ai-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-mute);
    font-size: 13px;
    padding: 12px 0;
}
.ai-loading .dot-spin {
    display: flex;
    gap: 4px;
}
.ai-loading .dot-spin span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    animation: bounce 1.2s infinite;
}
.ai-loading .dot-spin span:nth-child(2) { animation-delay: 0.2s; }
.ai-loading .dot-spin span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
    0%,100% { transform: translateY(0); opacity: 0.4; }
    50%      { transform: translateY(-6px); opacity: 1; }
}

/* ---- AI工作动画（增强版） ---- */
.ai-working {
    text-align: center;
    padding: 40px 20px 30px;
}
.ai-working-icon {
    position: relative;
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
}
.ai-orbit {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: 3px solid transparent;
    border-top-color: #1a3a5c;
    border-right-color: #1a3a5c;
    border-radius: 50%;
    animation: ai-spin 1.2s linear infinite;
}
.ai-orbit-2 {
    width: 56%; height: 56%;
    top: 22%; left: 22%;
    border-top-color: #c8922a;
    border-right-color: #c8922a;
    border-left-color: transparent;
    border-bottom-color: transparent;
    animation: ai-spin 0.8s linear infinite reverse;
}
.ai-core {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    animation: ai-pulse 1.5s ease-in-out infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
@keyframes ai-pulse {
    0%,100% { transform: translate(-50%, -50%) scale(1); }
    50%     { transform: translate(-50%, -50%) scale(1.18); }
}
.ai-working-text {
    font-size: 15px;
    font-weight: 600;
    color: #1a3a5c;
    margin-bottom: 14px;
}
.ai-progress-bar {
    width: 220px;
    height: 5px;
    background: #e2ddd5;
    border-radius: 3px;
    margin: 0 auto 14px;
    overflow: hidden;
    position: relative;
}
.ai-progress-fill {
    position: absolute;
    top: 0; left: 0;
    width: 35%;
    height: 100%;
    background: linear-gradient(90deg, #1a3a5c, #c8922a);
    border-radius: 3px;
    animation: ai-progress 1.8s ease-in-out infinite;
}
@keyframes ai-progress {
    0%   { left: -35%; }
    100% { left: 100%; }
}
.ai-working-tips {
    font-size: 13px;
    color: #6b7280;
    min-height: 20px;
    line-height: 20px;
}
.ai-working-tips .ai-tip-item {
    display: inline-block;
    animation: ai-tip-fade 0.4s ease;
}
@keyframes ai-tip-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- AI动画全屏浮层 ---- */
.ai-modal-mask {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(13,37,64,0.82);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: ai-mask-in 0.3s ease;
}
.ai-modal-mask.show { display: flex; }
.ai-modal-card {
    background: #fff;
    border-radius: 16px;
    padding: 48px 40px 36px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    max-width: 420px;
    width: 90%;
    animation: ai-card-in 0.4s ease;
}
@keyframes ai-mask-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes ai-card-in {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---- 提示框 ---- */
.tip-box {
    background: #fff8ec;
    border-left: 4px solid var(--accent);
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 13px;
    color: #7a5a20;
    margin-bottom: 16px;
    line-height: 1.7;
}

/* ---- Toast通知 ---- */
#toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: rgba(26,58,92,0.92);
    color: #fff;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 9999;
    transition: transform 0.3s ease;
    pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ---- 素材库管理页 ---- */
#page-material { display: none; }
#page-material.active { display: block; }
.mat-manage-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}
.mat-manage-tab {
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    color: var(--text-mute);
    font-weight: 600;
}
.mat-manage-tab.active { border-bottom-color: var(--primary); color: var(--primary); }
.add-material-form {
    background: #f5f8fc;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}
.mat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mat-table th {
    background: var(--primary);
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
}
.mat-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.mat-table tr:hover td { background: #f5f8fc; }

/* ---- 自定义框架 ---- */
.custom-fw-section {
    margin-top: 20px;
    border-top: 2px dashed #d0d5dd;
    padding-top: 16px;
}
.custom-fw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #7a4a1a;
}
.struct-item.custom {
    border-color: #d4c5a0;
    background: #fdfaf3;
}
.struct-item.custom:hover {
    border-color: #c8922a;
    background: #fef7e6;
}
.struct-item.custom.selected {
    border-color: #7a4a1a;
    background: #fdf6e8;
}
.struct-item.custom .badge {
    background: #7a4a1a;
}
.struct-item.custom.selected .badge {
    background: #c8922a;
}
.struct-item.custom .fw-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

/* ---- 框架编辑器弹窗 ---- */
.fw-modal-mask {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.fw-modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    animation: fwModalIn 0.25s ease;
}
@keyframes fwModalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.fw-modal h3 {
    font-size: 17px;
    color: #1a3a5c;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0b429;
}
.fw-step-row {
    background: #f5f8fc;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
    position: relative;
}
.fw-step-row .fw-step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.fw-step-row .fw-step-num {
    font-size: 12px;
    font-weight: 700;
    color: #1a3a5c;
    background: #e8f0f8;
    padding: 2px 10px;
    border-radius: 10px;
}
.fw-step-row .fw-step-remove {
    background: #fce8e8;
    color: #c0392b;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
}
.fw-step-row input,
.fw-step-row textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    margin-bottom: 6px;
    box-sizing: border-box;
}
.fw-step-row input:focus,
.fw-step-row textarea:focus {
    outline: none;
    border-color: #2e5e8e;
    box-shadow: 0 0 0 2px rgba(46,94,142,0.10);
}
.fw-step-row textarea {
    min-height: 60px;
    resize: vertical;
}

/* ---- 响应式 ---- */
@media (max-width: 640px) {
    .panel { padding: 16px; }
    .type-grid { grid-template-columns: 1fr; }
    .steps-bar { padding: 12px 8px; }
    .step-label { font-size: 10px; }
    .score-board { grid-template-columns: auto 1fr 1fr; }
    .main-container { padding: 0 8px; }
}
