/* =========================================================
 * 剧本原创化 · 样式
 * 作用域：.sw- 前缀
 * ========================================================= */

.sw-wrap {
    display: flex;
    flex-direction: column;
    background: var(--bg-warm);
    border-radius: 12px;
    min-height: calc(100vh - 160px);
    overflow: hidden;
}

/* ===== Header ===== */
.sw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: linear-gradient(135deg, #1d2233 0%, #2a2f44 100%);
    color: #ffffff;
    border-bottom: 1px solid var(--border);
}
.sw-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
}
.sw-brand i { color: #c8791f; font-size: 18px; }
.sw-header-right { display: flex; gap: 8px; }
.sw-header-right button {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid rgba(255,255,255,.24);
    border-radius: 6px;
    color: rgba(255,255,255,.72);
    font-size: 12px;
    cursor: pointer;
    transition: all .15s;
}
.sw-header-right button:hover { background: rgba(255,255,255,.08); }
.sw-header-right button.primary {
    background: #c8791f;
    border-color: #c8791f;
    color: #ffffff;
    font-weight: 600;
}
.sw-header-right button.primary:hover { background: #e0a13a; }

/* ===== 步骤条 ===== */
.sw-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    gap: 0;
}
.sw-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    color: var(--text-hint);
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
}
.sw-step:hover { background: var(--border); color: var(--text-secondary); }
.sw-step.active {
    color: #c8791f;
    background: rgba(200,121,31,.14);
    font-weight: 600;
}
.sw-step .num {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}
.sw-step.active .num { background: #c8791f; color: #ffffff; }
.sw-step-sep { width: 24px; height: 1px; background: var(--border); }

/* ===== Body ===== */
.sw-body {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
}

/* ===== 项目卡片 ===== */
.sw-projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.sw-project-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    position: relative;
    transition: all .15s;
}
.sw-project-card:hover {
    border-color: #c8791f;
    box-shadow: 0 4px 12px rgba(200,121,31,.15);
    transform: translateY(-2px);
}
.sw-project-card.new {
    border-style: dashed;
    color: var(--text-secondary);
    min-height: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.sw-project-card.new:hover { color: #c8791f; }
.sw-project-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--strong);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sw-project-src {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.sw-project-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.sw-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    border-radius: 10px;
    background: var(--border);
    color: var(--text-secondary);
}
.sw-badge.primary { background: rgba(200,121,31,.14); color: #c8791f; }
.sw-badge.success { background: rgba(77,191,168,.12); color: #4dbfa8; }
.sw-badge.info    { background: var(--bg-warm); color: #c8791f; }
.sw-project-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-hint);
}
.sw-project-card .del-btn {
    position: absolute;
    top: 8px; right: 8px;
    width: 26px; height: 26px;
    border: none;
    background: transparent;
    color: var(--border);
    cursor: pointer;
    border-radius: 4px;
    display: none;
}
.sw-project-card:hover .del-btn { display: block; }
.sw-project-card .del-btn:hover { background: rgba(224,123,99,.13); color: #e07b63; }

/* ===== 表单 ===== */
.sw-form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.sw-form-row label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}
.sw-form-row input,
.sw-form-row textarea,
.sw-form-row select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
    font-family: inherit;
}
.sw-form-row textarea {
    min-height: 220px;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 12px;
    line-height: 1.6;
    resize: vertical;
}
.sw-form-row input:focus,
.sw-form-row textarea:focus,
.sw-form-row select:focus {
    outline: none;
    border-color: #c8791f;
    box-shadow: 0 0 0 3px rgba(200,121,31,.1);
}

.sw-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ===== 按钮 ===== */
.sw-btn {
    padding: 6px 14px;
    font-size: 13px;
    background: var(--bg-white);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .15s;
}
.sw-btn:hover { background: var(--bg-warm); border-color: var(--text-hint); }
.sw-btn.primary {
    background: #c8791f;
    color: #ffffff;
    border-color: #c8791f;
}
.sw-btn.primary:hover { background: #e0a13a; }
.sw-btn.danger {
    background: var(--bg-white);
    color: #e07b63;
    border-color: #e07b63;
}
.sw-btn.danger:hover { background: rgba(224,123,99,.13); }
.sw-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 改写配置区 ===== */
.sw-config-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    max-width: 920px;
    margin: 0 auto;
}
.sw-config-card h3 {
    margin: 0 0 16px;
    font-size: 15px;
    color: var(--strong);
}

.sw-level-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}
.sw-level-card {
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
}
.sw-level-card:hover { border-color: #e0a13a; }
.sw-level-card.active {
    border-color: #c8791f;
    background: rgba(200,121,31,.14);
}
.sw-level-card .title {
    font-size: 14px;
    font-weight: 700;
    color: var(--strong);
    margin-bottom: 4px;
}
.sw-level-card .desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== 进度条 ===== */
.sw-progress {
    margin: 16px 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}
.sw-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.sw-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #c8791f, #e0a13a);
    transition: width .3s ease;
    border-radius: 4px;
}
.sw-progress-text {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}
.sw-progress-log {
    max-height: 160px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-warm);
    border-radius: 6px;
    margin-top: 10px;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ===== 对照视图 ===== */
.sw-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.sw-compare-col {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.sw-compare-col .col-head {
    padding: 10px 14px;
    background: var(--bg-warm);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sw-compare-col.src .col-head { color: var(--text-secondary); }
.sw-compare-col.new .col-head { color: #c8791f; background: rgba(200,121,31,.14); }

.sw-compare-scene {
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
}
.sw-compare-scene:last-child { border-bottom: none; }
.sw-scene-heading {
    font-size: 12px;
    font-weight: 700;
    color: #c8791f;
    margin-bottom: 6px;
}
.sw-scene-text {
    font-size: 13px;
    color: var(--strong);
    line-height: 1.7;
    white-space: pre-wrap;
    font-family: ui-monospace, Menlo, monospace;
}
.sw-scene-stats {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
}
.sw-scene-stats b { color: var(--text-secondary); }
.sw-scene-flag {
    display: inline-block;
    padding: 1px 6px;
    font-size: 10px;
    border-radius: 4px;
    background: rgba(224,123,99,.13);
    color: #e07b63;
    margin-left: 4px;
}

/* ===== 原创度仪表 ===== */
.sw-originality {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 20px;
    align-items: center;
}
.sw-gauge {
    width: 160px; height: 160px;
    margin: 0 auto;
    position: relative;
}
.sw-gauge svg { transform: rotate(-90deg); }
.sw-gauge .score-num {
    position: absolute;
    left: 0; top: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.sw-gauge .score-num .big {
    font-size: 36px;
    font-weight: 700;
    color: var(--strong);
}
.sw-gauge .score-num .small {
    font-size: 11px;
    color: var(--text-hint);
}
.sw-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.sw-stat-item {
    padding: 10px;
    background: var(--bg-warm);
    border-radius: 8px;
    text-align: center;
}
.sw-stat-item .label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.sw-stat-item .value {
    font-size: 18px;
    font-weight: 700;
    color: var(--strong);
}

/* ===== 映射表 ===== */
.sw-mapping-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.sw-mapping-table th,
.sw-mapping-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.sw-mapping-table th {
    background: var(--bg-warm);
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 12px;
}
.sw-mapping-table td .old { color: var(--text-hint); text-decoration: line-through; }
.sw-mapping-table td .arrow { color: #c8791f; padding: 0 8px; }
.sw-mapping-table td .new { color: var(--strong); font-weight: 600; }

/* ===== 空态 ===== */
.sw-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-hint);
}
.sw-empty i {
    font-size: 40px;
    margin-bottom: 14px;
    color: var(--border);
    display: block;
}

/* ===== Toast ===== */
.sw-toast {
    position: fixed;
    top: 20px; right: 20px;
    padding: 10px 16px;
    background: var(--bg-white);
    color: var(--strong);
    font-size: 13px;
    border-radius: 6px;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    max-width: 360px;
}
.sw-toast.success { background: #16a34a; color: #ffffff; }
.sw-toast.error   { background: #dc2626; color: #ffffff; }

/* ===== 对话框 ===== */
.sw-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 9990;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.sw-modal {
    background: var(--bg-white);
    border-radius: 12px;
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.sw-modal-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}
.sw-modal-head h3 { margin: 0; font-size: 15px; }
.sw-modal-close {
    width: 28px; height: 28px;
    background: transparent;
    border: none;
    color: var(--text-hint);
    font-size: 20px;
    cursor: pointer;
}
.sw-modal-body { padding: 18px; overflow-y: auto; }
.sw-modal-foot {
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Loading Spinner ===== */
.sw-loading {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: #c8791f;
    border-radius: 50%;
    animation: sw-spin 1s linear infinite;
}
@keyframes sw-spin { to { transform: rotate(360deg); } }
