html, body {
    background: #f4f6f8;
}

.app-main {
    max-width: 1680px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.metric-tile {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
    padding: 14px 16px;
}

.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.markdown-box {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "Consolas", "Cascadia Mono", monospace;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
}

.markdown-box.compact {
    padding: 8px;
    font-size: 0.875rem;
}

.restored-question-markdown-preview {
    min-height: 360px;
    line-height: 1.85;
    word-break: break-word;
    overflow-x: auto;
}

.restored-question-markdown-preview p {
    margin: 0 0 0.75rem;
}

.restored-question-markdown-preview img {
    display: block;
    max-width: min(100%, 620px);
    max-height: 420px;
    object-fit: contain;
    margin: 10px 0 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
}

.restored-question-markdown-preview table {
    width: max-content;
    max-width: 100%;
    margin: 10px 0 14px;
    border-collapse: collapse;
    background: #ffffff;
}

.restored-question-markdown-preview th,
.restored-question-markdown-preview td {
    border: 1px solid #d1d5db;
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}

.restored-question-markdown-preview th {
    background: #f1f5f9;
    font-weight: 600;
}

.question-markdown-source {
    max-height: 640px;
    overflow: auto;
    white-space: pre-wrap;
}

.question-markdown-source code {
    font-family: inherit;
}

.question-restore {
    display: grid;
    gap: 14px;
}

.question-restore-stem {
    line-height: 1.8;
    word-break: break-word;
}

.question-restore-images {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.question-restore-figure {
    margin: 0;
}

.question-restore-figure.inline {
    margin: 8px 0 12px;
}

.question-restore-image {
    max-width: min(100%, 560px);
    max-height: 360px;
    object-fit: contain;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
}

.question-restore-image.option {
    max-width: min(100%, 260px);
    max-height: 180px;
}

.question-restore-figure figcaption {
    margin-top: 6px;
    color: #64748b;
    font-size: 0.8125rem;
    word-break: break-word;
}

.question-restore-tables {
    display: grid;
    gap: 12px;
}

.question-restore-options {
    margin: 0;
    padding-left: 1.5rem;
    line-height: 1.8;
}

.question-restore-option-images {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.question-restore-option-label {
    display: inline-block;
    min-width: 2rem;
    font-weight: 600;
}

.table-preview {
    overflow-x: auto;
}

.question-detail-table {
    width: max-content;
    max-width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

.question-detail-table th,
.question-detail-table td {
    border: 1px solid #d1d5db;
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

.question-detail-table th {
    background: #f1f5f9;
    font-weight: 600;
}

.artifact-thumb {
    max-width: 180px;
    max-height: 140px;
    object-fit: contain;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
}

.tree-node-thumb {
    max-width: 64px;
    max-height: 48px;
    object-fit: contain;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #ffffff;
    vertical-align: middle;
    margin: 0 4px;
    cursor: zoom-in;
}

.tree-node-correct-option {
    background: #eefaf0;
    border-radius: 4px;
    border-left: 3px solid #2e7d32;
}

.tree-node-explanation {
    margin: 2px 0 2px 24px;
    padding: 4px 8px;
    background: #fafafa;
    border-left: 2px solid #cbd5e1;
    font-size: 0.9em;
    color: #475569;
}

.question-node-tree table {
    border-collapse: collapse;
    margin: 4px 0;
}

.question-node-tree table th,
.question-node-tree table td {
    border: 1px solid #cbd5e1;
    padding: 4px 8px;
}

/* 页视图复核【题目编辑】里的节点正文。表格必须有可见边框——化学题里的表格
   （实验记录、溶解度数据、选项矩阵）不画格线根本看不出哪个值属于哪一行哪一列，
   而"看得出对不对"正是复核这件事的全部意义。Markdig 只产出裸 <table>，边框得靠这里给。 */
.node-text-preview {
    overflow-x: auto;
}

.node-text-preview table {
    border-collapse: collapse;
    margin: 6px 0;
    /* 右栏比左侧页图窄，宽表格在自己的容器里横向滚动，不撑破整页布局。 */
    width: max-content;
    max-width: 100%;
    background: #ffffff;
}

.node-text-preview table th,
.node-text-preview table td {
    border: 1px solid #94a3b8;
    padding: 4px 8px;
    text-align: left;
    vertical-align: top;
}

.node-text-preview table th {
    background: #f1f5f9;
    font-weight: 600;
}

.node-text-preview p {
    margin: 0 0 6px;
}

.node-text-preview p:last-child {
    margin-bottom: 0;
}

.tree-node-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

/* 批次 4：展示模式（投影/课堂讲解）——整体调大字号，方便后排学生看清。 */
.presentation-mode {
    font-size: 1.25em;
}

.presentation-mode .tree-node-thumb {
    max-width: 96px;
    max-height: 72px;
}

.text-muted {
    color: #64748b;
}

/* 选项图矩阵（canonical 里的 option-image-matrix HTML 表，移植 codex option_matrix 主渲染） */
.option-image-matrix {
    border-collapse: collapse;
    margin: 8px 0;
}

.option-image-matrix th,
.option-image-matrix td {
    border: 1px solid #cbd5e1;
    padding: 6px 10px;
    text-align: center;
    vertical-align: middle;
}

.option-image-matrix img {
    max-width: 180px;
    max-height: 140px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
