/* ===== 基础重置与变量 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --success-hover: #15803d;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --secondary: #6b7280;
    --secondary-hover: #4b5563;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
    --radius: 8px;
    --radius-sm: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== 布局 ===== */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== 顶部导航 ===== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    padding: 16px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.top-bar h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

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

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

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

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

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

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

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-delete:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ===== 区块 ===== */
.section {
    background: var(--card-bg);
    padding: 20px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== 表单 ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--card-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

select.form-input {
    cursor: pointer;
}

textarea.form-input {
    resize: vertical;
    min-height: 36px;
}

/* ===== 主体布局 ===== */
.main-layout {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

/* 左侧提示面板 */
.hint-panel {
    width: 260px;
    flex-shrink: 0;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.hint-panel h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.hint-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.hint-content p {
    margin-bottom: 8px;
}

.hint-content .hint-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    font-size: 14px;
}

.hint-content .hint-required {
    color: var(--danger);
    font-weight: 500;
}

.hint-content .hint-optional {
    color: var(--success);
    font-weight: 500;
}

.hint-content code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--primary);
}

/* 右侧编辑区 */
.editor-panel {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.editor-actions {
    display: flex;
    gap: 10px;
}

/* ===== 题目卡片 ===== */
.question-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.question-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.question-card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.question-type-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
}

.type-choice {
    background: #dbeafe;
    color: #1e40af;
}

.type-fill {
    background: #dcfce7;
    color: #166534;
}

.question-index {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    flex: 1;
}

.card-actions {
    display: flex;
    gap: 6px;
}

.card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ===== 资源 ===== */
.resource-section {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.resource-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.resource-header label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.resource-item .form-input {
    flex: 1;
    min-width: 100px;
}

.resource-item .r-name {
    flex: 1.2;
}

.resource-item .r-path {
    flex: 1.5;
}

.resource-item .r-type,
.resource-item .r-source {
    flex: 0.8;
    min-width: 80px;
}

/* ===== 选项 ===== */
.options-section {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.options-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.options-header label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    background: var(--card-bg);
    padding: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.option-label {
    font-weight: 600;
    color: var(--primary);
    min-width: 24px;
    text-align: center;
}

.option-item .o-content {
    flex: 1;
    min-width: 150px;
}

.option-item .o-analysis {
    flex: 1;
    min-width: 120px;
}

.option-resource-list {
    width: 100%;
    margin-top: 6px;
    padding-left: 32px;
}

.option-resource-list .resource-item {
    background: var(--bg);
    padding: 6px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.correct-answer {
    margin-top: 4px;
}

.correct-answer label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ===== 题目组成（填空题） ===== */
.compose-section {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.compose-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.compose-header label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-right: auto;
}

.compose-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    background: var(--card-bg);
    padding: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.compose-label {
    font-weight: 600;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 44px;
    text-align: center;
}

.fragment-item .compose-label {
    background: #dbeafe;
    color: #1e40af;
}

.blank-item .compose-label {
    background: #fef3c7;
    color: #92400e;
}

.fragment-item .f-text {
    flex: 1;
}

.blank-item .form-input {
    flex: 1;
    min-width: 80px;
}

.blank-item .b-answer {
    flex: 1.2;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== 预览区 ===== */
.preview-section {
    margin-top: 20px;
}

.preview-textarea {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
    font-size: 13px;
    line-height: 1.6;
    background: #0f172a;
    color: #e2e8f0;
    resize: vertical;
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .main-layout {
        flex-direction: column;
    }

    .hint-panel {
        width: 100%;
        position: static;
        max-height: none;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .editor-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .resource-item,
    .option-item,
    .compose-item {
        flex-direction: column;
        align-items: stretch;
    }

    .resource-item .form-input,
    .option-item .form-input,
    .compose-item .form-input {
        width: 100%;
    }
}
